From 0463bb48fc3be6eae3ca1a2d136d0303f2e41114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B7=E5=8B=87?= Date: Fri, 25 Aug 2023 15:03:37 +0800 Subject: [PATCH] internalQueryOne select count... add tmp table flag --- app.go | 64 +++++++++++++++++++++++++++---------------------------- dbpool.go | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/app.go b/app.go index a8135ce..d2cbbea 100644 --- a/app.go +++ b/app.go @@ -2,11 +2,11 @@ package f5 import ( "flag" + "os" + "q5" "sync" "sync/atomic" "time" - "os" - "q5" ) type App interface { @@ -22,7 +22,7 @@ type App interface { GetNowSeconds() int64 GetNowMillis() int64 GetNowNano() int64 - RegisterMainThreadCb(func ()) + RegisterMainThreadCb(func()) } type UserApp interface { @@ -33,27 +33,27 @@ type UserApp interface { } type app struct { - zoneId int32 - nodeId int32 - instanceId int32 - terminated bool - flags map[int32]int32 - servicing bool - contextHash map[int32]q5.Args - loopCond *sync.Cond - imTopNode *IMMsgNode - imBotNode *IMMsgNode - imWorkNode *IMMsgNode - imMsgMutex sync.RWMutex + zoneId int32 + nodeId int32 + instanceId int32 + terminated bool + flags map[int32]int32 + servicing bool + contextHash map[int32]q5.Args + loopCond *sync.Cond + imTopNode *IMMsgNode + imBotNode *IMMsgNode + imWorkNode *IMMsgNode + imMsgMutex sync.RWMutex chGoLoopTimerExit chan int - chGoLoopWait chan int64 - nowTime time.Time - nowUnixNano int64 - imMsgHandlers [1024]func(q5.Args) - maxRunDelay int64 - maxScheduleTime int64 - uuid q5.Uuid - userApp UserApp + chGoLoopWait chan int64 + nowTime time.Time + nowUnixNano int64 + imMsgHandlers [1024]func(q5.Args) + maxRunDelay int64 + maxScheduleTime int64 + uuid q5.Uuid + userApp UserApp } func (this *app) init(userApp UserApp) { @@ -82,14 +82,14 @@ func (this *app) init(userApp UserApp) { this.nodeId = int32(tmpNodeId) this.instanceId = int32(tmpInstanceId) } - this.uuid.SetMachineId((this.nodeId - 1) * MAX_NODE_ID + this.instanceId) + this.uuid.SetMachineId((this.nodeId-1)*MAX_NODE_ID + this.instanceId) this.loopCond = sync.NewCond(new(sync.Mutex)) this.chGoLoopTimerExit = make(chan int) this.chGoLoopWait = make(chan int64) _app.RegisterIMMsgHandle( IM_EXEC_MAIN_THREAD_CB, - func (args q5.Args) { - cb := args[0].(func ()) + func(args q5.Args) { + cb := args[0].(func()) cb() }) this.outputRuningLog() @@ -125,7 +125,7 @@ func (this *app) run() { this.schedule() endTick := q5.GetTickCount() - if this.maxRunDelay < endTick - beginTick { + if this.maxRunDelay < endTick-beginTick { this.maxRunDelay = endTick - beginTick } } @@ -178,10 +178,10 @@ func (this *app) RegisterIMMsgHandle(msgId uint16, handle func(q5.Args)) { this.imMsgHandlers[msgId] = handle } -func (this *app) RegisterMainThreadCb(cb func ()) { +func (this *app) RegisterMainThreadCb(cb func()) { _app.AddIMMsg(IM_EXEC_MAIN_THREAD_CB, - []interface{} { - cb, + []interface{}{ + cb, }) } @@ -245,8 +245,8 @@ func (this *app) dispatchIMMsg() { } func (this *app) installTimer() { - GetTimer().SetInterval(1000 * 60, - func (ev int32, params *q5.Args) { + GetTimer().SetInterval(1000*60, + func(ev int32, params *q5.Args) { if ev == q5.TIMER_EXEC_EVENT { GetSysLog().Info("max_run_delay:%d max_schedule_time:%d", _app.maxRunDelay, diff --git a/dbpool.go b/dbpool.go index fc2ab87..34907fd 100644 --- a/dbpool.go +++ b/dbpool.go @@ -182,7 +182,7 @@ func (this *dbPool) PageQuery( } this.internalQueryOne( dataSource, - fmt.Sprintf("SELECT COUNT(*) FROM (%s)", finalySql), + fmt.Sprintf("SELECT COUNT(*) FROM (%s) as t", finalySql), params, func(err error, rows *DataSet) { if err != nil {