已关闭
[Bug]: 【GENERATED AS IDENTITY] TRUNCATE RESTART IDENTITY 丢 START WITH,序列重置为 1 而非保留原值 #8455
cloudsbreak创建于  8月28日关闭于  22 天前
cloudsbreak
cloudsbreak成员
8月28日 创建

测试类型

SQL功能

测试版本

7.0.0LTS

问题描述

GENERATED AS IDENTITY 列执行 TRUNCATE TABLE ... RESTART IDENTITY 后,序列值重置为 1 而非保留原 START WITH 值。
PostgreSQL 17.4 实测:TRUNCATE RESTART 后下一值回到 START WITH(44)。
openGauss 实测:TRUNCATE RESTART 后下一值重置为 1。

操作系统和硬件信息

7.0.0LTS

测试环境

企业版单机

被测功能

预置条件

操作步骤

DROP TABLE IF EXISTS t_identity_trunc CASCADE;
CREATE TABLE t_identity_trunc(a int GENERATED ALWAYS AS IDENTITY (START WITH 44), b int);
INSERT INTO t_identity_trunc(b) VALUES(1);
INSERT INTO t_identity_trunc(b) VALUES(1);
-- 此时 a=1,2
TRUNCATE TABLE t_identity_trunc RESTART IDENTITY;
INSERT INTO t_identity_trunc(b) VALUES(1) RETURNING a;

预期输出

RETURNING a = 44(回到 START WITH 值)
-- PostgreSQL 17.4 实测
CREATE TABLE t_identity_trunc(a int GENERATED ALWAYS AS IDENTITY (START WITH 44), b int);
INSERT INTO t_identity_trunc(b) VALUES(1);
INSERT INTO t_identity_trunc(b) VALUES(1);
TRUNCATE TABLE t_identity_trunc RESTART IDENTITY;
INSERT INTO t_identity_trunc(b) VALUES(1) RETURNING a;
-- 结果:a = 44

实际输出

RETURNING a = 1

日志信息

RETURNING a = 1

提单组织

联合伙伴

测试代码

likedislike
cloudsbreakcloudsbreak成员
8月28日 添加了label:bug
opengauss_bot
opengauss_bot成员
8月28日 评论:

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成员
8月28日 将 TestManager 设为负责人
opengauss_bot
opengauss_bot成员
8月28日 评论:

Welcome To openGauss Community

Hey @cloudsbreak , 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. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

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, @libiao2024, @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
opengauss_botopengauss_bot成员
8月28日 添加了label:sig/SQLEngine
sungang14sungang14成员
9月3日 issue优先级由 无优先级 改变为 次要
sungang14sungang14成员
9月3日 关联了看板:openGauss 7.0.0-LTS
XXXCA
XXXCA
9月4日 评论:
ywzq1161327784
ywzq1161327784成员
27 天前 评论:

上面PR已修复,验证ok
image.png

likedislike
ywzq1161327784ywzq1161327784成员
27 天前 issue状态由 待办的 改变为 待回归
cloudsbreakcloudsbreak成员
22 天前 issue状态由 待回归 改变为 已完成
cloudsbreakcloudsbreak成员
22 天前 issue状态由 已完成 改变为 已验收
cloudsbreakcloudsbreak成员
22 天前 关闭了 issue