From c18a4c387a6432ece7e7323c3ef961d29a517be9 Mon Sep 17 00:00:00 2001 From: gouhongshen Date: Fri, 13 Dec 2024 16:20:36 +0800 Subject: [PATCH 1/6] update --- pkg/frontend/back_exec.go | 17 ++++- pkg/sql/plan/function/func_mo.go | 107 ++++++++++++++++++++++++++++--- pkg/vm/process/types.go | 1 + 3 files changed, 113 insertions(+), 12 deletions(-) diff --git a/pkg/frontend/back_exec.go b/pkg/frontend/back_exec.go index 75564ee68c787..509841970435e 100644 --- a/pkg/frontend/back_exec.go +++ b/pkg/frontend/back_exec.go @@ -1140,11 +1140,12 @@ func (sh *SqlHelper) GetSubscriptionMeta(dbName string) (*plan.SubscriptionMeta, return sh.ses.txnCompileCtx.GetSubscriptionMeta(dbName, nil) } -// Made for sequence func. nextval, setval. -func (sh *SqlHelper) ExecSql(sql string) (ret [][]interface{}, err error) { +func (sh *SqlHelper) execSql( + ctx context.Context, + sql string, +) (ret [][]interface{}, err error) { var erArray []ExecResult - ctx := sh.ses.txnCompileCtx.execCtx.reqCtx /* if we run the transaction statement (BEGIN, ect) here , it creates an independent transaction. if we do not run the transaction statement (BEGIN, ect) here, it runs the sql in the share transaction @@ -1171,3 +1172,13 @@ func (sh *SqlHelper) ExecSql(sql string) (ret [][]interface{}, err error) { return erArray[0].(*MysqlResultSet).Data, nil } + +// Made for sequence func. nextval, setval. +func (sh *SqlHelper) ExecSql(sql string) (ret [][]interface{}, err error) { + ctx := sh.ses.txnCompileCtx.execCtx.reqCtx + return sh.execSql(ctx, sql) +} + +func (sh *SqlHelper) ExecSqlWithCtx(ctx context.Context, sql string) ([][]interface{}, error) { + return sh.execSql(ctx, sql) +} diff --git a/pkg/sql/plan/function/func_mo.go b/pkg/sql/plan/function/func_mo.go index 57af31effbd1b..5c015664a02bd 100644 --- a/pkg/sql/plan/function/func_mo.go +++ b/pkg/sql/plan/function/func_mo.go @@ -176,6 +176,84 @@ type GetMoTableSizeRowsFuncType = func() func( var GetMoTableSizeFunc atomic.Pointer[GetMoTableSizeRowsFuncType] var GetMoTableRowsFunc atomic.Pointer[GetMoTableSizeRowsFuncType] +func isSubscribedTable( + proc *process.Process, + reqAcc uint32, + db engine.Database, + dbName, tblName string, +) (accId, dbId, tblId uint64, ok bool, err error) { + + var ( + sql string + ret [][]interface{} + meta *plan.SubscriptionMeta + ) + + if db.IsSubscription(proc.Ctx) { + defer func() { + if err != nil { + metaInfo := "" + if meta != nil { + metaInfo = fmt.Sprintf("ACC(%s,%d)-DB(%s)-TBLS(%s)", + meta.AccountName, meta.AccountId, meta.DbName, meta.Tables) + } + + logutil.Error("MO_TABLE_SIZE/ROWS", + zap.String("source", "isSubscribedTable"), + zap.Error(err), + zap.String("sub meta", metaInfo), + zap.Uint32("request acc", reqAcc), + zap.String("db name", dbName), + zap.String("tbl name", tblName), + zap.String("sql", sql), + ) + } + }() + + meta, err = proc.GetSessionInfo().SqlHelper.GetSubscriptionMeta(dbName) + if err != nil { + return 0, 0, 0, false, + moerr.NewInternalErrorNoCtx(fmt.Sprintf("get subscription meta failed, err: %v", err)) + } + + if meta.Tables != pubsub.TableAll && !strings.Contains(meta.Tables, tblName) { + return 0, 0, 0, false, moerr.NewInternalErrorNoCtx("no such subscribed table") + } + + // check passed, get acc, db, tbl info + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + ctx = defines.AttachAccountId(ctx, uint32(sysAccountID)) + defer cancel() + + sql = fmt.Sprintf(` + select + reldatabase_id, rel_id + from + mo_catalog.mo_tables + where + account_id = %d and reldatabase = '%s' and relname = '%s';`, + meta.AccountId, meta.DbName, tblName) + + ret, err = proc.GetSessionInfo().SqlHelper.ExecSqlWithCtx(ctx, fmt.Sprintf(sql)) + if err != nil { + return 0, 0, 0, false, + moerr.NewInternalErrorNoCtx(fmt.Sprintf("exec get subscribed tbl info sql failed, err: %v", err)) + } + + if len(ret) != 1 { + return 0, 0, 0, false, + moerr.NewInternalErrorNoCtx(fmt.Sprintf("get the subscribed tbl info empty: %s", tblName)) + } + + dbId = ret[0][0].(uint64) + tblId = ret[0][1].(uint64) + + return uint64(meta.AccountId), dbId, tblId, true, nil + } + + return 0, 0, 0, false, nil +} + func MoTableSizeRowsHelper( iVecs []*vector.Vector, result vector.FunctionResultWrapper, @@ -283,17 +361,28 @@ func MoTableSizeRowsHelper( return err } - if rel, err = db.Relation(proc.Ctx, tblName, nil); err != nil { - if moerr.IsMoErrCode(err, moerr.OkExpectedEOB) { - return moerr.NewInternalErrorNoCtxf("tbl not exist: %s-%s(%s)", - dbName, tblName, "OkExpectedEOB") - } + var subAcc, subDb, subTbl uint64 + if subAcc, subDb, subTbl, ok, err = isSubscribedTable( + proc, accountId, db, dbName, tblName); err != nil { return err - } + } else if ok { + // is subscription + accIds = append(accIds, subAcc) + dbIds = append(dbIds, subDb) + tblIds = append(tblIds, subTbl) + } else { + if rel, err = db.Relation(proc.Ctx, tblName, nil); err != nil { + if moerr.IsMoErrCode(err, moerr.OkExpectedEOB) { + return moerr.NewInternalErrorNoCtxf("tbl not exist: %s-%s(%s)", + dbName, tblName, "OkExpectedEOB") + } + return err + } - accIds = append(accIds, uint64(accountId)) - dbIds = append(dbIds, uint64(rel.GetDBID(proc.Ctx))) - tblIds = append(tblIds, uint64(rel.GetTableID(proc.Ctx))) + accIds = append(accIds, uint64(accountId)) + dbIds = append(dbIds, uint64(rel.GetDBID(proc.Ctx))) + tblIds = append(tblIds, uint64(rel.GetTableID(proc.Ctx))) + } } ret, err = (*executor.Load())()( diff --git a/pkg/vm/process/types.go b/pkg/vm/process/types.go index 62ace13c8f81f..f4ce0c0b6d638 100644 --- a/pkg/vm/process/types.go +++ b/pkg/vm/process/types.go @@ -319,6 +319,7 @@ type Process struct { type sqlHelper interface { GetCompilerContext() any ExecSql(string) ([][]interface{}, error) + ExecSqlWithCtx(context.Context, string) ([][]interface{}, error) GetSubscriptionMeta(string) (sub *plan.SubscriptionMeta, err error) } From 318b310f04c9116cafbf5622201dac9bb710fd2d Mon Sep 17 00:00:00 2001 From: gouhongshen Date: Tue, 17 Dec 2024 13:40:28 +0800 Subject: [PATCH 2/6] support subscription --- pkg/sql/plan/function/func_mo.go | 99 ++++++++++++++++--- .../distributed/cases/function/func_mo.result | 42 ++++++++ test/distributed/cases/function/func_mo.sql | 49 +++++++++ 3 files changed, 175 insertions(+), 15 deletions(-) create mode 100644 test/distributed/cases/function/func_mo.result create mode 100644 test/distributed/cases/function/func_mo.sql diff --git a/pkg/sql/plan/function/func_mo.go b/pkg/sql/plan/function/func_mo.go index 5c015664a02bd..893f586e08bb5 100644 --- a/pkg/sql/plan/function/func_mo.go +++ b/pkg/sql/plan/function/func_mo.go @@ -176,12 +176,33 @@ type GetMoTableSizeRowsFuncType = func() func( var GetMoTableSizeFunc atomic.Pointer[GetMoTableSizeRowsFuncType] var GetMoTableRowsFunc atomic.Pointer[GetMoTableSizeRowsFuncType] +type subscription struct { + valid bool + + oriAccId uint64 + oriDatabaseId uint64 + oriTableId uint64 + + oriTableName string + oriDatabaseName string +} + +func (s subscription) String() string { + return fmt.Sprintf("valid: %v, oriAcc(%d), oriDatabase(%d-%s), oriTable(%d-%s)", + s.valid, + s.oriAccId, + s.oriDatabaseId, + s.oriDatabaseName, + s.oriTableId, + s.oriTableName) +} + func isSubscribedTable( proc *process.Process, reqAcc uint32, db engine.Database, dbName, tblName string, -) (accId, dbId, tblId uint64, ok bool, err error) { +) (sub subscription, err error) { var ( sql string @@ -192,6 +213,8 @@ func isSubscribedTable( if db.IsSubscription(proc.Ctx) { defer func() { if err != nil { + sub.valid = false + metaInfo := "" if meta != nil { metaInfo = fmt.Sprintf("ACC(%s,%d)-DB(%s)-TBLS(%s)", @@ -205,6 +228,7 @@ func isSubscribedTable( zap.Uint32("request acc", reqAcc), zap.String("db name", dbName), zap.String("tbl name", tblName), + zap.String("subscription", sub.String()), zap.String("sql", sql), ) } @@ -212,12 +236,12 @@ func isSubscribedTable( meta, err = proc.GetSessionInfo().SqlHelper.GetSubscriptionMeta(dbName) if err != nil { - return 0, 0, 0, false, + return sub, moerr.NewInternalErrorNoCtx(fmt.Sprintf("get subscription meta failed, err: %v", err)) } if meta.Tables != pubsub.TableAll && !strings.Contains(meta.Tables, tblName) { - return 0, 0, 0, false, moerr.NewInternalErrorNoCtx("no such subscribed table") + return sub, moerr.NewInternalErrorNoCtx("no such subscribed table") } // check passed, get acc, db, tbl info @@ -236,22 +260,27 @@ func isSubscribedTable( ret, err = proc.GetSessionInfo().SqlHelper.ExecSqlWithCtx(ctx, fmt.Sprintf(sql)) if err != nil { - return 0, 0, 0, false, + return sub, moerr.NewInternalErrorNoCtx(fmt.Sprintf("exec get subscribed tbl info sql failed, err: %v", err)) } if len(ret) != 1 { - return 0, 0, 0, false, + return sub, moerr.NewInternalErrorNoCtx(fmt.Sprintf("get the subscribed tbl info empty: %s", tblName)) } - dbId = ret[0][0].(uint64) - tblId = ret[0][1].(uint64) + sub.valid = true + sub.oriAccId = uint64(meta.AccountId) + sub.oriDatabaseId = ret[0][0].(uint64) + sub.oriTableId = ret[0][1].(uint64) + sub.oriTableName = tblName + sub.oriDatabaseName = meta.DbName - return uint64(meta.AccountId), dbId, tblId, true, nil + return sub, nil } - return 0, 0, 0, false, nil + sub.valid = false + return sub, nil } func MoTableSizeRowsHelper( @@ -361,15 +390,15 @@ func MoTableSizeRowsHelper( return err } - var subAcc, subDb, subTbl uint64 - if subAcc, subDb, subTbl, ok, err = isSubscribedTable( + var sub subscription + if sub, err = isSubscribedTable( proc, accountId, db, dbName, tblName); err != nil { return err - } else if ok { + } else if sub.valid { // is subscription - accIds = append(accIds, subAcc) - dbIds = append(dbIds, subDb) - tblIds = append(tblIds, subTbl) + accIds = append(accIds, sub.oriAccId) + dbIds = append(dbIds, sub.oriDatabaseId) + tblIds = append(tblIds, sub.oriTableId) } else { if rel, err = db.Relation(proc.Ctx, tblName, nil); err != nil { if moerr.IsMoErrCode(err, moerr.OkExpectedEOB) { @@ -488,6 +517,26 @@ func MoTableRowsOld(ivecs []*vector.Vector, result vector.FunctionResultWrapper, } return err } + + var accId uint32 + accId, err = defines.GetAccountId(foolCtx) + if err != nil { + return err + } + + var sub subscription + if sub, err = isSubscribedTable( + proc, accId, dbo, dbStr, tblStr); err != nil { + return err + } else if sub.valid { + // subscription + foolCtx = defines.AttachAccountId(foolCtx, uint32(sub.oriAccId)) + dbo, err = e.Database(foolCtx, sub.oriDatabaseName, txn) + if err != nil { + return err + } + } + rel, err = dbo.Relation(foolCtx, tblStr, nil) if err != nil { return err @@ -607,6 +656,26 @@ func MoTableSizeOld(ivecs []*vector.Vector, result vector.FunctionResultWrapper, } return err } + + var accId uint32 + accId, err = defines.GetAccountId(foolCtx) + if err != nil { + return err + } + + var sub subscription + if sub, err = isSubscribedTable( + proc, accId, dbo, dbStr, tblStr); err != nil { + return err + } else if sub.valid { + // subscription + foolCtx = defines.AttachAccountId(foolCtx, uint32(sub.oriAccId)) + dbo, err = e.Database(foolCtx, sub.oriDatabaseName, txn) + if err != nil { + return err + } + } + rel, err = dbo.Relation(foolCtx, tblStr, nil) if err != nil { return err diff --git a/test/distributed/cases/function/func_mo.result b/test/distributed/cases/function/func_mo.result new file mode 100644 index 0000000000000..7756b3856a0e7 --- /dev/null +++ b/test/distributed/cases/function/func_mo.result @@ -0,0 +1,42 @@ +drop database if exists testdb; +create database testdb; +use testdb; +create account acc admin_name "root" identified by "111"; +create publication pub1 database testdb account all; +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 select * from generate_series(1, 1000)g; +insert into t2 select * from generate_series(1, 1000)g; +insert into t3 select * from generate_series(1, 1000)g; +drop database if exists testdb_sub; +create database testdb_sub from sys publication pub1; +drop database if exists testdb_nor; +create database testdb_nor; +use testdb_nor; +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +insert into t1 select * from generate_series(1, 1001)g; +insert into t2 select * from generate_series(1, 1001)g; +insert into t3 select * from generate_series(1, 1001)g; +create table tmp(dbName varchar, tblName varchar); +insert into tmp values ("testdb_nor", "t1"), ("testdb_nor", "t2"), ("testdb_nor", "t3"); +insert into tmp values ("testdb_sub", "t1"), ("testdb_sub", "t2"), ("testdb_sub", "t3"); +set mo_table_stats.force_update = yes; +select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +mo_table_rows(dbName, tblName) +1001 +1001 +1001 +1000 +1000 +1000 +insert into tmp values ("testdb_sub", "t4"); +select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +internal error: get the subscribed tbl info empty: t4 +drop database testdb_nor; +drop database testdb_sub; +drop account acc; +drop publication pub1; +drop database testdb; \ No newline at end of file diff --git a/test/distributed/cases/function/func_mo.sql b/test/distributed/cases/function/func_mo.sql new file mode 100644 index 0000000000000..74d6d67c7b1f2 --- /dev/null +++ b/test/distributed/cases/function/func_mo.sql @@ -0,0 +1,49 @@ +drop database if exists testdb; +create database testdb; +use testdb; + +create account acc admin_name "root" identified by "111"; +create publication pub1 database testdb account all; + +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); + +insert into t1 select * from generate_series(1, 1000)g; +insert into t2 select * from generate_series(1, 1000)g; +insert into t3 select * from generate_series(1, 1000)g; + +-- @session:id=2&user=acc:root&password=111 +drop database if exists testdb_sub; +create database testdb_sub from sys publication pub1; + +drop database if exists testdb_nor; +create database testdb_nor; +use testdb_nor; + +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); + +insert into t1 select * from generate_series(1, 1001)g; +insert into t2 select * from generate_series(1, 1001)g; +insert into t3 select * from generate_series(1, 1001)g; + +create table tmp(dbName varchar, tblName varchar); +insert into tmp values ("testdb_nor", "t1"), ("testdb_nor", "t2"), ("testdb_nor", "t3"); +insert into tmp values ("testdb_sub", "t1"), ("testdb_sub", "t2"), ("testdb_sub", "t3"); + +set mo_table_stats.force_update = yes; +select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); + +insert into tmp values ("testdb_sub", "t4"); +select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); + +drop database testdb_nor; +drop database testdb_sub; + +-- @session + +drop account acc; +drop publication pub1; +drop database testdb; \ No newline at end of file From 525a6c04689bd84197666ffe88af75351376ff6b Mon Sep 17 00:00:00 2001 From: gouhongshen Date: Tue, 17 Dec 2024 14:00:31 +0800 Subject: [PATCH 3/6] fix sca --- pkg/sql/plan/function/func_mo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/sql/plan/function/func_mo.go b/pkg/sql/plan/function/func_mo.go index 893f586e08bb5..9cb4e6d87688f 100644 --- a/pkg/sql/plan/function/func_mo.go +++ b/pkg/sql/plan/function/func_mo.go @@ -258,7 +258,7 @@ func isSubscribedTable( account_id = %d and reldatabase = '%s' and relname = '%s';`, meta.AccountId, meta.DbName, tblName) - ret, err = proc.GetSessionInfo().SqlHelper.ExecSqlWithCtx(ctx, fmt.Sprintf(sql)) + ret, err = proc.GetSessionInfo().SqlHelper.ExecSqlWithCtx(ctx, sql) if err != nil { return sub, moerr.NewInternalErrorNoCtx(fmt.Sprintf("exec get subscribed tbl info sql failed, err: %v", err)) From 4912b4d07f53e8f2100373c9e17bcca14bc5d853 Mon Sep 17 00:00:00 2001 From: gouhongshen Date: Tue, 17 Dec 2024 17:27:24 +0800 Subject: [PATCH 4/6] update bvt --- test/distributed/cases/function/func_mo.result | 15 +++++++++++++++ test/distributed/cases/function/func_mo.sql | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/test/distributed/cases/function/func_mo.result b/test/distributed/cases/function/func_mo.result index 7756b3856a0e7..3f14db57e8932 100644 --- a/test/distributed/cases/function/func_mo.result +++ b/test/distributed/cases/function/func_mo.result @@ -35,6 +35,21 @@ mo_table_rows(dbName, tblName) insert into tmp values ("testdb_sub", "t4"); select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); internal error: get the subscribed tbl info empty: t4 +set mo_table_stats.force_update = no; +delete from tmp where dbName = "testdb_sub" and tblName = "t4"; +set mo_table_stats.use_old_impl = yes; +select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +mo_table_rows(dbName, tblName) +1001 +1001 +1001 +1000 +1000 +1000 +insert into tmp values ("testdb_sub", "t4"); +select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +internal error: get the subscribed tbl info empty: t4 +set mo_table_stats.use_old_impl = no; drop database testdb_nor; drop database testdb_sub; drop account acc; diff --git a/test/distributed/cases/function/func_mo.sql b/test/distributed/cases/function/func_mo.sql index 74d6d67c7b1f2..2c86b97c558eb 100644 --- a/test/distributed/cases/function/func_mo.sql +++ b/test/distributed/cases/function/func_mo.sql @@ -39,6 +39,17 @@ select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order b insert into tmp values ("testdb_sub", "t4"); select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +set mo_table_stats.force_update = no; +delete from tmp where dbName = "testdb_sub" and tblName = "t4"; + +set mo_table_stats.use_old_impl = yes; +select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); + +insert into tmp values ("testdb_sub", "t4"); +select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); + +set mo_table_stats.use_old_impl = no; + drop database testdb_nor; drop database testdb_sub; From 731b566586f5d35ce476d47d74a65c6f5fd4ab37 Mon Sep 17 00:00:00 2001 From: gouhongshen Date: Tue, 17 Dec 2024 18:54:12 +0800 Subject: [PATCH 5/6] update bvt --- pkg/sql/plan/function/func_mo.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/sql/plan/function/func_mo.go b/pkg/sql/plan/function/func_mo.go index 9cb4e6d87688f..716b78662d58a 100644 --- a/pkg/sql/plan/function/func_mo.go +++ b/pkg/sql/plan/function/func_mo.go @@ -527,6 +527,9 @@ func MoTableRowsOld(ivecs []*vector.Vector, result vector.FunctionResultWrapper, var sub subscription if sub, err = isSubscribedTable( proc, accId, dbo, dbStr, tblStr); err != nil { + logutil.Error("MoTableRowsOld", + zap.String("source", "isSubscribeTable"), + zap.Error(err)) return err } else if sub.valid { // subscription @@ -666,6 +669,9 @@ func MoTableSizeOld(ivecs []*vector.Vector, result vector.FunctionResultWrapper, var sub subscription if sub, err = isSubscribedTable( proc, accId, dbo, dbStr, tblStr); err != nil { + logutil.Error("MoTableSizeOld", + zap.String("source", "isSubscribeTable"), + zap.Error(err)) return err } else if sub.valid { // subscription From 585a74b2d36c7f09fa0399860bdc7b6612cbf827 Mon Sep 17 00:00:00 2001 From: gouhongshen Date: Tue, 17 Dec 2024 18:55:00 +0800 Subject: [PATCH 6/6] update bvt --- test/distributed/cases/function/func_mo.result | 10 ++++++++++ test/distributed/cases/function/func_mo.sql | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/test/distributed/cases/function/func_mo.result b/test/distributed/cases/function/func_mo.result index 3f14db57e8932..e0835dbcee155 100644 --- a/test/distributed/cases/function/func_mo.result +++ b/test/distributed/cases/function/func_mo.result @@ -46,9 +46,19 @@ mo_table_rows(dbName, tblName) 1000 1000 1000 +select mo_table_size(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +mo_table_size(dbName, tblName) +36036 +36036 +36036 +36000 +36000 +36000 insert into tmp values ("testdb_sub", "t4"); select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); internal error: get the subscribed tbl info empty: t4 +select mo_table_size(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +internal error: get the subscribed tbl info empty: t4 set mo_table_stats.use_old_impl = no; drop database testdb_nor; drop database testdb_sub; diff --git a/test/distributed/cases/function/func_mo.sql b/test/distributed/cases/function/func_mo.sql index 2c86b97c558eb..9f1cdb3bca72f 100644 --- a/test/distributed/cases/function/func_mo.sql +++ b/test/distributed/cases/function/func_mo.sql @@ -44,9 +44,13 @@ delete from tmp where dbName = "testdb_sub" and tblName = "t4"; set mo_table_stats.use_old_impl = yes; select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +-- @ignore:0 +select mo_table_size(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); insert into tmp values ("testdb_sub", "t4"); select mo_table_rows(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); +-- @ignore:0 +select mo_table_size(dbName, tblName) from (select * from testdb_nor.tmp order by dbName, tblName asc); set mo_table_stats.use_old_impl = no;