已关闭
[Bug]: gs_dump导出创建自增列+索引+分区表场景下,导出内容再用gsql导入报错【DH】 #8356
zhangxubo创建于  7月27日关闭于  8月6日
zhangxubo
zhangxubo成员
7月27日 创建

测试类型

工具功能

测试版本

6.0.0

问题描述

操作系统和硬件信息

all

测试环境

企业版单机

被测功能

导入导出

预置条件

操作步骤

  1. B库里面建表
create table test100(
id int AUTO_INCREMENT,
name varchar,
datekey date,
index test100_id_index using btree(id)
)
PARTITION BY RANGE(datekey)
(
	PARTITION p202210 VALUES LESS THAN ('2022-10-01'),
	PARTITION p2022101 VALUES LESS THAN ('2022-11-01')
);
  1. gs_dump导出,在使用gsql导入,导入报错
    image.png

预期输出

导出导入正常

实际输出

导出格式无法解析

日志信息

导入后,查看文件格式,
image.png

这个语法无法创建成功。

提单组织

一线客户

测试代码

likedislike
zhangxubozhangxubo成员
7月27日 添加了label:bug
opengauss_bot
opengauss_bot成员
7月27日 评论:

This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.

likedislike
opengauss_botopengauss_bot成员
7月27日 将 TestManager 设为负责人
zhangxubozhangxubo成员
7月27日 关联了看板:openGauss 7.0.0-LTS
zhangxubozhangxubo成员
7月27日 将 zhangxubo 设为负责人
zhangxubozhangxubo成员
7月27日 移除了负责人 TestManager
opengauss_botopengauss_bot成员
7月27日 添加了label:sig/StorageEngine,sig/AI,sig/CM,sig/CloudNative,sig/SecurityTechnology,sig/SQLEngine
opengauss_bot
opengauss_bot成员
7月27日 评论:

Welcome To openGauss Community

Hey @zhangxubo , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: StorageEngine, AI, CM, CloudNative, SecurityTechnology, SQLEngine ,
and any of the maintainers: @CarrotGo, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @hwworkholic, @jemappellehc, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @totaj, @wlff234, @wofanzheng, @ywzq1161327784 ,
and any of the committers: @Igali, @bihua111, @cailei19, @h_ray, @levy53071, @libiao2024, @lihaixiao, @mrzack, @wangfeihuo, @wuyuechuan, @xiong_xjun, @zhangfengzhi123, @zhangxubo, @zhangzq131, @zjh_hw .

likedislike
zhangxubozhangxubo成员
7月28日 关联了pull request:对于导出自增列索引去掉Local以及以后的内容
zhangxubozhangxubo成员
7月29日 关联了pull request:对于导出自增列索引去掉Local以及以后的内容【回合9499】
zhangxubo
zhangxubo成员
8月5日 评论:

20260805 7.0.0LTSB017自测:

建b库建表,导出
image.png

导入:
image.png

likedislike
zhangxubozhangxubo成员
8月5日 issue状态由 待办的 改变为 已完成
zhangxubozhangxubo成员
8月5日 issue状态由 已完成 改变为 待回归
wuchenlong
wuchenlong成员
8月6日 评论:

【回归版本】openGauss 7.0.0-RC3 build 7a39d3ac(7.0.0LTS B017,compiled at 2026-08-05 14:35:47)
【回归日期】20260806
【回归人员】wuchenlong
【回归结论】通过

测试结果

B 兼容库 db_b8356 中按 issue 原始建表语句创建 test100(AUTO_INCREMENT 自增列 + 内联索引 + RANGE 分区)并插入 2 行数据;gs_dump -F p 导出后重建空 B 库,用 gsql 导入成功(CREATE TABLE 无语法错误),表结构与数据完整保留(2 行)。

说明

历史异常:gs_dump 导出的 DDL 在自增列索引处插入分区范围,导致 gsql 导入报语法错误(导出格式无法解析)。
B017 上导出 DDL 已恢复为原始表定义方式(INDEX ... USING btree(id) 保持在表定义内,PARTITION BY RANGE 正常跟随),导入不再报错,异常不再复现。

【回归步骤】

执行 SQL(B 兼容库 db_b8356):

DROP DATABASE IF EXISTS db_b8356;
CREATE DATABASE db_b8356 DBCOMPATIBILITY 'B';
\c db_b8356

create table test100(
id int AUTO_INCREMENT,
name varchar,
datekey date,
index test100_id_index using btree(id)
)
PARTITION BY RANGE(datekey)
(
	PARTITION p202210 VALUES LESS THAN ('2022-10-01'),
	PARTITION p2022101 VALUES LESS THAN ('2022-11-01')
);

INSERT INTO test100(name, datekey) VALUES ('a', '2022-09-05'), ('b', '2022-10-05');
SELECT count(*) AS cnt FROM test100;

执行结果:

DROP DATABASE
CREATE DATABASE
You are now connected to database "db_b8356" as user "wcl0623".
NOTICE:  CREATE TABLE will create implicit sequence "test100_id_seq" for serial column "test100.id"
CREATE TABLE
INSERT 0 2
 cnt
-----
   2
(1 row)

gs_dump 导出:

gs_dump -p 15600 -U wcl0623 -W 'OpenGauss@123' -F p -f /tmp/repro_8356_dump.sql db_b8356
...
gs_dump[port='15600'][db_b8356][2026-08-06 12:12:13]: dump database db_b8356 successfully

导出 DDL(关键部分,自增列索引未被插入分区范围):

CREATE TABLE "test100" (
    "id" integer AUTO_INCREMENT NOT NULL,
    "name" "varbinary" COLLATE "pg_catalog"."binary",
    "datekey" date,
    INDEX "test100_id_index" USING "btree" ("id")
) AUTO_INCREMENT = 3
WITH (orientation=row, compression=no, collate=1026)
PARTITION BY RANGE ("datekey")
(
    PARTITION "p202210" VALUES LESS THAN ('2022-10-01'),
    PARTITION "p2022101" VALUES LESS THAN ('2022-11-01')
)
ENABLE ROW MOVEMENT;

重建空 B 库后导入:

DROP DATABASE IF EXISTS db_b8356;
CREATE DATABASE db_b8356 DBCOMPATIBILITY 'B';
gsql -d db_b8356 -p 15600 -r -W 'OpenGauss@123' -f /tmp/repro_8356_dump.sql
SET
... (SET x21)
CREATE TABLE
ALTER TABLE
REVOKE
REVOKE
GRANT
GRANT
total time: 30  ms

校验数据:

select * from test100 order by id;
\d test100
 id | name |  datekey
----+------+------------
  1 | \x61 | 2022-09-05
  2 | \x62 | 2022-10-05
(2 rows)

                     Table "public.test100"
 Column  |    Type     |               Modifiers
---------+-------------+----------------------------------------
 id      | integer     | not null AUTO_INCREMENT
 name    | varbinary   | character set SQL_ASCII collate binary
 datekey | date        |
Indexes:
    "test100_id_index" btree (id) LOCAL TABLESPACE pg_default
Partition By RANGE(datekey)
Number of partitions: 2 (View pg_partition to check each partition range.)
likedislike
wuchenlongwuchenlong成员
8月6日 issue状态由 待回归 改变为 已验收
wuchenlongwuchenlong成员
8月6日 关闭了 issue