首批通过分布式安全可靠测评,为关键业务系统打造
OBClient V2.x~V2.2.5 版本中如果列名为 prompt 可能会被错误地识别为提示符关键字
更新时间:2026-05-21 09:16
问题现象
当表的 DDL 语句中有 prompt 作为列名时,通过 OceanBase Developer Center 客户端工具建表正常成功,但通过 OBClient 终端命令行工具执行建表语句时,建表是成功的,却把 prompt 字段给自动过滤掉了,如下:
$ cat t1.sql
create table t1 (
prompt varchar(100),
name varchar(100)
);
$ obclient --version
obclient Ver 2.2.4 Distrib 10.4.18-MariaDB, for Linux (x86_64) using readline 5.1
$ obclient -hxx.xxx.80.111 -P2881 -utest@oraclet -pxxx -A -c -e "source t1.sql"
varchar(100),
$ obclient -hxx.xxx.80.111 -P2881 -utest@oraclet -pxxx -A -c
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221606562
Server version: OceanBase 4.2.5.6 (r106000052025082216-22431cc723c4e07a82cac27d4347e8ac2f0afc30) (Built Aug 22 2025 18:05:13)
Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [TEST]> show create table t1;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| TABLE | CREATE TABLE |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| T1 | CREATE TABLE "T1" (
"NAME" VARCHAR2(100)
) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.023 sec)
问题原因
该问题为 OBClient V2.x~V2.2.5 版本上的已知缺陷:通过 OBClient 终端命令行工具去执行 SQL 语句时,如果某一行的开头单词为 prompt,这一行会被 OBClient 工具误识别为提示符关键字,从而导致这一行被自动过滤掉。
问题的风险及影响
通过 OBClient 终端命令行工具去执行 SQL 语句时,如果某一行的开头单词为 prompt,实际执行的 SQL 不符合预期。
解决方法
方法一: 升级 OBClient 工具至 V2.2.6 或更高的版本。
$ cat t1.sql create table t1 ( prompt varchar(100), name varchar(100) ); $ obclient --version obclient Ver 2.2.10 Distrib 10.4.18-MariaDB, for Linux (x86_64) using readline 5.1 $ obclient -hxx.xxx.80.111 -P2881 -utest@oraclet -pxxx -A -c -e "source t1.sql" $ obclient -hxx.xxx.80.111 -P2881 -utest@oraclet -pxxx -A -c Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221622074 Server version: OceanBase 4.2.5.6 (r106000052025082216-22431cc723c4e07a82cac27d4347e8ac2f0afc30) (Built Aug 22 2025 18:05:13) Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient(TEST@oraclet)[TEST]> show create table t1; +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | TABLE | CREATE TABLE | +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | T1 | CREATE TABLE "T1" ( "PROMPT" VARCHAR2(100), "NAME" VARCHAR2(100) ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 | +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.016 sec)方法二: 将 prompt 单词用双引号
""(适用于 Oracle 模式租户)或者反引号 ``(适用于 MySQL 模式租户)括起来:$ cat t1.sql create table t1 ( "prompt" varchar(100), name varchar(100) ); $ obclient --version obclient Ver 2.2.4 Distrib 10.4.18-MariaDB, for Linux (x86_64) using readline 5.1 $ obclient -hxx.xxx.80.111 -P2881 -utest@oraclet -pxxx -A -c -e "source t1.sql" $ obclient -hxx.xxx.80.111 -P2881 -utest@oraclet -pxxx -A -c Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221492876 Server version: OceanBase 4.2.5.6 (r106000052025082216-22431cc723c4e07a82cac27d4347e8ac2f0afc30) (Built Aug 22 2025 18:05:13) Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [TEST]> show create table t1; +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | TABLE | CREATE TABLE | +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | T1 | CREATE TABLE "T1" ( "prompt" VARCHAR2(100), "NAME" VARCHAR2(100) ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 | +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.016 sec)注意
Oracle 模式中创建对象(包括用户名、表名、列名、索引名等)时如果不加双引号默认会把小写全部自动转变为大写来进行储存,加了双引号的话则会保留原来的大小写格式。
方法三: 调整 SQL 语句的格式,使得 prompt 不是某一行的开头起始单词。
$ cat t1.sql create table t1 ( prompt varchar(100), name varchar(100) ); $ obclient --version obclient Ver 2.2.4 Distrib 10.4.18-MariaDB, for Linux (x86_64) using readline 5.1 $ obclient -hxx.xxx.80.111 -P2881 -utest@oraclet -pxxx -A -c -e "source t1.sql" $ obclient -hxx.xxx.80.111 -P2881 -utest@oraclet -pxxx -A -c Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221674968 Server version: OceanBase 4.2.5.6 (r106000052025082216-22431cc723c4e07a82cac27d4347e8ac2f0afc30) (Built Aug 22 2025 18:05:13) Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient [TEST]> show create table t1; +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | TABLE | CREATE TABLE | +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | T1 | CREATE TABLE "T1" ( "PROMPT" VARCHAR2(100), "NAME" VARCHAR2(100) ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 | +-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.017 sec)
规避方式
无。