ob-loader-dumper-4.3.4-RELEASE Mysql模式 导出表结构时, check约束的处理存在bug

背景:使用obdumper导出一个DDL表结构,使用obloader导入到异机上失败了。
2025-09-10 01:48:06 [ERROR] …Loading sql of SQL-format file: “/export2/data/doccollect/TABLE/t_task-schema.sql” exec failure. (1/2). Reason: SQLException: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near ‘json_valid(f_result)
)
default charset=utf8mb4
default collate=utf8mb4_unicode’ at line 17. SQL: create table if not exists t_task (
f_id bigint(20) unsigned not null auto_increment comment ‘主键id’,
f_task_id char(36) not null comment ‘任务id’,
f_record_id bigint(20) unsigned not null comment ‘提交记录id’,
f_result longtext collate utf8mb4_bin comment ‘流转结果’,
primary key (f_id),
constraint t_doccollect_task_OBCHECK_1735194654798022 check json_valid(f_result)
)
default charset=utf8mb4
default collate=utf8mb4_unicode_ci
comment=‘提交详情表’
2025-09-10 01:48:06 [ERROR] Error: Loading SQL-format file: “/export2/data/doccollect/TABLE/t_task-schema.sql” failure. Reason: SQLException: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near ‘json_valid(f_result)
)
default charset=utf8mb4
default collate=utf8mb4_unicode’ at line 17. Please see …/logs/ob-loader-dumper.error
2025-09-10 01:48:07 [ERROR] System exit 1

根据错误提示,手动将ddl语句改成这样,重新导入就不报错了。check 后面的表达式要加括号。
constraint t_doccollect_task_OBCHECK_1735194654798022 check (json_valid(f_result))

官方后期啥时候,修复下这个bug

2 个赞

不简单啊

看看咋解决

1 个赞

具体的命令发一下

1 个赞

使用obdumper导出数据库的DDL和数据

local cmd_args=(
“$OBDUMPER_PATH”
-h “$DB_HOST”
-P “$DB_PORT”
-u “$DB_USER”
-p “$DB_PASSWORD”
-t “$DB_TENANT”
–sys-user “$SYS_USER”
–sys-password “$SYS_PASSWORD”
-D “${db_name}”
–ddl
–sql
–all
–skip-check-dir
–log-path “${db_LOG_PATH}”
-f “${db_MOUNT_POINT}”
)

if [ -n “$DB_CLUSTER_NAME” ]; then
cmd_args+=(-c “$DB_CLUSTER_NAME”)
fi

“${cmd_args[@]}” >> “$LOG_FILE” 2>&1

使用obloader导入数据

local cmd_args=(
“$OBLOADER_PATH”
-h “$DB_HOST”
-P “$DB_PORT”
-u “$DB_USER”
-p “$DB_PASSWORD”
-t “$DB_TENANT”
–sys-user “$SYS_USER”
–sys-password “$SYS_PASSWORD”
-D “$db_name”
–ddl
–sql
–all
–log-path “${db_LOG_PATH}”
-f “$db_import_path”
)

if [ -n “$DB_CLUSTER_NAME” ]; then
cmd_args+=(-c “$DB_CLUSTER_NAME”)
fi

“${cmd_args[@]}” >> “$LOG_FILE” 2>&1

1 个赞

提供一下表结构信息 show create table 版本信息在发一下