首批通过分布式安全可靠测评,为关键业务系统打造
执行类似 select * from (subquery) where rownum < int 语句导致报错 4016
更新时间:2024-03-29 06:41
在 OceanBase 数据库中执行类似 select * from (subquery) where rownum < int 语句导致报错 -4016。
报错日志信息如下。
ERROR [SQL.CG] visit (ob_expr_generator_impl.cpp:1503) [100260][1980][xxxxx-xxxxx] [lt=14] [dc=0] expected aggr_expr(ret=-4016,sql_expr_->get_type()=0,*sql_expr_={infix_expr:{exprs:[{parent:{op:{expr_type:"T_OP_GT",expr_name:">",param_num:2,dimension:-1,real_param_num:2,result_type:{meta:{type:"INT",collation:"binary",coercibility:"NUMERIC"},accuracy:{length:-1,precision:1,scale:0},flag:0,calc_type:{type:"DECIMAL",collation:"binary",coercibility:"NUMERIC"}},input_type:[{calc_meta:{type:"DECIMAL",collation:"binary",coercibility:"NUMERIC"},length:39,flag:0},{calc_meta:{type:"DECIMAL",collation:"binary",coercibility:"NUMERIC"},length:149,flag:1}]}},param_idx_:0,param_num_:0,param_lazy_eval_:false}]},post_expr:[],gen_infix_expr:true},expr={item_type:"T_FUN_COUNT",result_type:{meta:{type:"DECIMAL",collation:"binary",coercibility:"NUMERIC"},accuracy:{length:-1,precision:38,scale:0},flag:0,calc_type:{type:"NULL",collation:"invalid_type",coercibility:"INVALID"}},expr_info:["IS_AGG","CNT_AGG"],rel_id:[],expr_level:0,expr_levels:[0],children:[],distinct:false,order_by:[],separator_param_expr:null,udf_meta:{tenant_id:18446744073709551615,name:"",ret:0,dl:"",type:0}})BACKTRACE:0xcbfd59a 0x3345d72 0xa354a25 0xa35515a 0xa355352 0xa372ea0 0x321cd19 0x321a6fb 0x321a126 0x3219c54 0xb34e7a6 0xb351c9a 0xb352324 xb3774be 0xb3773f2 0xb3773f2 0xb3773f2 0xb3773f2 0xb3773f2 0xb3773f2 0xb3773f2 0xb3773f2 0xb3773f2 0xb3773f2 0xb3780cc 0xb4562b2 0x3252484 0x3182a71 0x311e650 0x311dd80 0x30d73e2 0x30d07e2 0x30ce1a9 0x30c836a 0x9f539bb 0xc9b58e7 0xc9b3630 0xc9b143f
WARN [SQL.CG] infix_visit_child (ob_expr_generator_impl.cpp:275)[100260][1980][xxxxx-xxxxx] [lt=97] [dc=0] expr visit failed(ret=-4016,*e={item_type:"T_FUN_COUNT",result_type:{meta:{type:"DECIMAL",collation:"binary",coercibility:"NUMERIC"},accuracy:{length:-1,precision:38,scale:0},flag:0,calc_type:{type:"NULL",collation:"invalid_type",coercibility:"INVALID"}},expr_info:["IS_AGG","CNT_AGG"],rel_id:[],expr_level:0,expr_levels:[0],children:[],distinct:false,order_by:[],separator_param_expr:null,udf_meta:{tenant_id:18446744073709551615,name:"",ret:0,dl:"",type:0}})
适用版本
OceanBase 数据库 V2.x 版本和 V3.x 版本。
问题原因
由于 OceanBase 内核存在 BUG。
解决方法
升级至问题已修复版本。目前已修复的版本包括 OceanBase 数据库 V2.2.77 BP17 (oceanbase-2.2.77-117000112023051914) 及之后版本、V3.1.2 BP4 (oceanbase-3.1.2-20211013162404) 及之后版本。
规避方法:通过 HINT /+NO_REWRITE/ 的方式规避报错。