首批通过分布式安全可靠测评,为关键业务系统打造
sql mode 为 ANSI_QUOTES 时,select "column", '' 触发 core
更新时间:2026-07-31 09:11
问题现象
MySQL 租户下,将系统变量 sql_mode 设置为 ANSI_QUOTES (set @@sql_mode='ANSI_QUOTES'),select item 中存在双引号引用的 item 及 '' 时,将会导致 OBSerevr core。例如:
SELECT "c1",'' FROM "t1";
core 堆栈信息如下:
oceanbase::sql::ObSqlParameterization::get_select_item_param_info(oceanbase::common::ObIArray<oceanbase::sql::ObPCParam*> const&, _ParseNode*, oceanbase::common::ObFixedArray<oceanbase::sql::SelectItemParamInfo, oceanbase::common::ObIAllocator>*) at. xxxx.cpp:xxx
oceanbase::sql::ObSqlParameterization::transform_syntax_tree(oceanbase::common::ObIAllocator&, oceanbase::sql::ObSQLSessionInfo const&, oceanbase::common::ObIArray<oceanbase::sql::ObPCParam*> const*, long, _ParseNode*, oceanbase::sql::SqlInfo&, oceanbase::common::Ob2DArray<oceanbase::common::ObObjParam, 2096128, oceanbase::common::ObWrapperAllocator, false, oceanbase::common::ObSEArray<oceanbase::common::ObObjParam*, 1l, oceanbase::common::ObWrapperAllocator, false> >&, oceanbase::common::ObFixedArray<oceanbase::sql::SelectItemParamInfo, oceanbase::common::ObIAllocator>*, oceanbase::common::ObArray<oceanbase::share::schema::ObFixedParam, oceanbase::common::ObWrapperAllocator, false, oceanbase::common::ObArrayDefaultCallBack<oceanbase::share::schema::ObFixedParam>, oceanbase::common::NotImplementItemEncode<oceanbase::share::schema::ObFixedParam> >&, bool, bool) at. xxxx.cpp:xxx
oceanbase::sql::ObSqlParameterization::parameterize_syntax_tree(oceanbase::common::ObIAllocator&, bool, oceanbase::sql::ObPlanCacheCtx&, _ParseNode*, oceanbase::common::Ob2DArray<oceanbase::common::ObObjParam, 2096128, oceanbase::common::ObWrapperAllocator, false, oceanbase::common::ObSEArray<oceanbase::common::ObObjParam*, 1l, oceanbase::common::ObWrapperAllocator, false> >&) at. xxxx.cpp:xxx
oceanbase::sql::ObSql::parser_and_check(oceanbase::common::ObString const&, oceanbase::sql::ObExecContext&, oceanbase::sql::ObPlanCacheCtx&, ParseResult&, int, bool&, bool&) at. xxxx.cpp:xxx
关键诊断信息
触发条件
MySQL 租户下,将系统变量 sql_mode 设置为 ANSI_QUOTES (set @@sql_mode='ANSI_QUOTES'; ),select item 中存在双引号引用的 item 及 ''。
问题原因
这种 SQL 在 fast parse(V3.2.x 版本引入)时,OBServer 没有正确识别 ANSI_QUOTES,误将双引号引用的 item(如 "c1")当成字符串处理,而正常 parse 时是做 identify 处理的,导致出现 fast parse 和正常 parse 识别的参数个数不一致,最终导致 core。
问题风险及影响
OBServer 宕机,集群不可用。
影响租户
影响 OceanBase 数据库中的 MySQL 租户,对于 SYS 租户和 Oracle 租户无影响。
影响的版本
OceanBase 数据库企业版 V3.2.3 GA(oceanbase-3.2.3.0-20220418212020)及之后版本、V3.2.4 GA(oceanbase-3.2.4.0-100000072022102819)及之后版本。
解决办法及规避方式
解决方法:
升级至问题已修复版本,目前已修复版本为 OceanBase 数据库企业版 V3.2.3 BP6(oceanbase-3.2.3.3-106000102022111521)版本、V3.2.4 BP1(oceanbase-3.2.4.1-101000052023010822)版本。
规避方式(任选其一):
关闭 plan cache(从而不进行参数化),并将租户链接断开重连,命令如下。
obclient> SET GLOBAL ob_enable_plan_cache = false;限制该类 SQL 的执行。