Skip to content

Commit d03c358

Browse files
jianhe-funCommitfest Bot
authored andcommitted
refactor test_ddl_deparse/sql/alter_table.sql
1. The test initially focuses on the "parent" table, then switches to the "part" table, and goes back to the "parent" table. This seemed inconsistent, so I slightly adjusted the order to cover the "parent" table first, followed by the "part" table. 2. src/test/modules/test_ddl_deparse/sql/alter_table.sql don't have ALTER TABLE ALTER COLUMN SET EXPRESSION, so I add a test on it. discussion: https://postgr.es/m/
1 parent 5487058 commit d03c358

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

src/test/modules/test_ddl_deparse/expected/alter_table.out

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,6 @@ ALTER TABLE parent ADD CONSTRAINT a_pos CHECK (a > 0);
4141
NOTICE: merging constraint "a_pos" with inherited definition
4242
NOTICE: DDL test: type alter table, tag ALTER TABLE
4343
NOTICE: subcommand: type ADD CONSTRAINT (and recurse) desc constraint a_pos on table parent
44-
CREATE TABLE part (
45-
a int
46-
) PARTITION BY RANGE (a);
47-
NOTICE: DDL test: type simple, tag CREATE TABLE
48-
CREATE TABLE part1 PARTITION OF part FOR VALUES FROM (1) to (100);
49-
NOTICE: DDL test: type simple, tag CREATE TABLE
50-
CREATE TABLE part2 (a int);
51-
NOTICE: DDL test: type simple, tag CREATE TABLE
52-
ALTER TABLE part ATTACH PARTITION part2 FOR VALUES FROM (101) to (200);
53-
NOTICE: DDL test: type alter table, tag ALTER TABLE
54-
NOTICE: subcommand: type ATTACH PARTITION desc table part2
55-
ALTER TABLE part DETACH PARTITION part2;
56-
NOTICE: DDL test: type alter table, tag ALTER TABLE
57-
NOTICE: subcommand: type DETACH PARTITION desc table part2
58-
DROP TABLE part2;
59-
ALTER TABLE part ADD PRIMARY KEY (a);
60-
NOTICE: DDL test: type alter table, tag ALTER TABLE
61-
NOTICE: subcommand: type ADD CONSTRAINT (and recurse) desc constraint part_a_not_null on table part
62-
NOTICE: subcommand: type ADD INDEX desc index part_pkey
6344
ALTER TABLE parent ALTER COLUMN a SET NOT NULL;
6445
NOTICE: DDL test: type alter table, tag ALTER TABLE
6546
NOTICE: subcommand: type SET NOT NULL (and recurse) desc constraint parent_a_not_null on table parent
@@ -117,11 +98,33 @@ NOTICE: DDL test: type alter table, tag ALTER TABLE
11798
NOTICE: subcommand: type ALTER COLUMN SET DEFAULT desc column c of table parent
11899
NOTICE: subcommand: type ALTER COLUMN SET DEFAULT desc column c of table child
119100
NOTICE: subcommand: type ALTER COLUMN SET DEFAULT desc column c of table grandchild
101+
CREATE TABLE part (
102+
a int
103+
) PARTITION BY RANGE (a);
104+
NOTICE: DDL test: type simple, tag CREATE TABLE
105+
CREATE TABLE part1 PARTITION OF part FOR VALUES FROM (1) to (100);
106+
NOTICE: DDL test: type simple, tag CREATE TABLE
107+
CREATE TABLE part2 (a int);
108+
NOTICE: DDL test: type simple, tag CREATE TABLE
109+
ALTER TABLE part ATTACH PARTITION part2 FOR VALUES FROM (101) to (200);
110+
NOTICE: DDL test: type alter table, tag ALTER TABLE
111+
NOTICE: subcommand: type ATTACH PARTITION desc table part2
112+
ALTER TABLE part DETACH PARTITION part2;
113+
NOTICE: DDL test: type alter table, tag ALTER TABLE
114+
NOTICE: subcommand: type DETACH PARTITION desc table part2
115+
DROP TABLE part2;
116+
ALTER TABLE part ADD PRIMARY KEY (a);
117+
NOTICE: DDL test: type alter table, tag ALTER TABLE
118+
NOTICE: subcommand: type ADD CONSTRAINT (and recurse) desc constraint part_a_not_null on table part
119+
NOTICE: subcommand: type ADD INDEX desc index part_pkey
120120
CREATE TABLE tbl (
121121
a int generated always as (b::int * 2) stored,
122122
b text
123123
);
124124
NOTICE: DDL test: type simple, tag CREATE TABLE
125+
ALTER TABLE tbl ALTER COLUMN a SET EXPRESSION AS (b::int * 3);
126+
NOTICE: DDL test: type alter table, tag ALTER TABLE
127+
NOTICE: subcommand: type SET EXPRESSION desc column a of table tbl
125128
ALTER TABLE tbl ALTER COLUMN a DROP EXPRESSION;
126129
NOTICE: DDL test: type alter table, tag ALTER TABLE
127130
NOTICE: subcommand: type DROP EXPRESSION desc column a of table tbl

src/test/modules/test_ddl_deparse/sql/alter_table.sql

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@ ALTER TABLE ONLY grandchild ADD CONSTRAINT a_pos CHECK (a > 0);
2424
-- Constraint, with recursion
2525
ALTER TABLE parent ADD CONSTRAINT a_pos CHECK (a > 0);
2626

27-
CREATE TABLE part (
28-
a int
29-
) PARTITION BY RANGE (a);
30-
31-
CREATE TABLE part1 PARTITION OF part FOR VALUES FROM (1) to (100);
32-
33-
CREATE TABLE part2 (a int);
34-
ALTER TABLE part ATTACH PARTITION part2 FOR VALUES FROM (101) to (200);
35-
ALTER TABLE part DETACH PARTITION part2;
36-
DROP TABLE part2;
37-
38-
ALTER TABLE part ADD PRIMARY KEY (a);
39-
4027
ALTER TABLE parent ALTER COLUMN a SET NOT NULL;
4128
ALTER TABLE parent ALTER COLUMN a DROP NOT NULL;
4229
ALTER TABLE parent ALTER COLUMN a SET NOT NULL;
@@ -62,11 +49,25 @@ ALTER TABLE parent ALTER COLUMN c TYPE numeric;
6249

6350
ALTER TABLE parent ALTER COLUMN c SET DEFAULT 0;
6451

52+
CREATE TABLE part (
53+
a int
54+
) PARTITION BY RANGE (a);
55+
56+
CREATE TABLE part1 PARTITION OF part FOR VALUES FROM (1) to (100);
57+
58+
CREATE TABLE part2 (a int);
59+
ALTER TABLE part ATTACH PARTITION part2 FOR VALUES FROM (101) to (200);
60+
ALTER TABLE part DETACH PARTITION part2;
61+
DROP TABLE part2;
62+
63+
ALTER TABLE part ADD PRIMARY KEY (a);
64+
6565
CREATE TABLE tbl (
6666
a int generated always as (b::int * 2) stored,
6767
b text
6868
);
6969

70+
ALTER TABLE tbl ALTER COLUMN a SET EXPRESSION AS (b::int * 3);
7071
ALTER TABLE tbl ALTER COLUMN a DROP EXPRESSION;
7172

7273
ALTER TABLE tbl ALTER COLUMN b SET COMPRESSION pglz;

0 commit comments

Comments
 (0)