Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0172b4c

Browse files
committed
Add some regression tests for missing DDL patterns
The following commands gain increased coverage for some of the errorsthey can trigger:- ALTER TABLE .. ALTER COLUMN- CREATE DOMAIN- CREATE TYPE (LIKE)This has come up while discussing the possibility to add moreinformation about the location of the error in such queries, and itis useful on its own as there was no coverage until now for thepatterns added in this commit.Author: Jian He, Kirill ReshkeReviewed-By: Álvaro Herrera, Michael PaquierDiscussion:https://postgr.es/m/CALdSSPhqfvKbDwqJaY=yEePi_aq61GmMpW88i6ZH7CMG_2Z4Cg@mail.gmail.com
1 parent430a595 commit0172b4c

File tree

8 files changed

+59
-0
lines changed

8 files changed

+59
-0
lines changed

‎src/test/regress/expected/alter_table.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,6 +3413,13 @@ ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE int;
34133413
ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE text;
34143414
ALTER TABLE comment_test ALTER COLUMN positive_col SET DATA TYPE int;
34153415
ALTER TABLE comment_test ALTER COLUMN positive_col SET DATA TYPE bigint;
3416+
-- Some error cases.
3417+
ALTER TABLE comment_test ALTER COLUMN xmin SET DATA TYPE x;
3418+
ERROR: cannot alter system column "xmin"
3419+
ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE x;
3420+
ERROR: type "x" does not exist
3421+
ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE int COLLATE "C";
3422+
ERROR: collations are not supported by type integer
34163423
-- Check that the comments are intact.
34173424
SELECT col_description('comment_test'::regclass, 1) as comment;
34183425
comment

‎src/test/regress/expected/domain.out

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@ NOTICE: drop cascades to type dependenttypetest
1515
-- this should fail because already gone
1616
drop domain domaindroptest cascade;
1717
ERROR: type "domaindroptest" does not exist
18+
-- some error cases
19+
create domain d_fail as no_such_type;
20+
ERROR: type "no_such_type" does not exist
21+
create domain d_fail as int constraint cc REFERENCES this_table_not_exists(i);
22+
ERROR: foreign key constraints not possible for domains
23+
create domain d_fail as int4 not null no inherit;
24+
ERROR: not-null constraints for domains cannot be marked NO INHERIT
25+
create domain d_fail as int4 not null null;
26+
ERROR: conflicting NULL/NOT NULL constraints
27+
create domain d_fail as int4 not null default 3 default 3;
28+
ERROR: multiple default expressions
29+
create domain d_fail int4 DEFAULT 3 + 'h';
30+
ERROR: invalid input syntax for type integer: "h"
31+
create domain d_fail int4 collate "C";
32+
ERROR: collations are not supported by type integer
33+
create domain d_fail as anyelement;
34+
ERROR: "anyelement" is not a valid base type for a domain
35+
create domain d_fail as int4 unique;
36+
ERROR: unique constraints not possible for domains
37+
create domain d_fail as int4 PRIMARY key;
38+
ERROR: primary key constraints not possible for domains
39+
create domain d_fail as int4 constraint cc generated by default as identity;
40+
ERROR: specifying GENERATED not supported for domains
41+
create domain d_fail as int4 constraint cc check (values > 1) no inherit;
42+
ERROR: check constraints for domains cannot be marked NO INHERIT
43+
create domain d_fail as int4 constraint cc check (values > 1) deferrable;
44+
ERROR: specifying constraint deferrability not supported for domains
1845
-- Test domain input.
1946
-- Note: the point of checking both INSERT and COPY FROM is that INSERT
2047
-- exercises CoerceToDomain while COPY exercises domain_in.

‎src/test/regress/expected/float8.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,8 @@ create function xfloat8out(xfloat8) returns cstring immutable strict
10241024
NOTICE: argument type xfloat8 is only a shell
10251025
LINE 1: create function xfloat8out(xfloat8) returns cstring immutabl...
10261026
^
1027+
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = no_such_type);
1028+
ERROR: type "no_such_type" does not exist
10271029
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8);
10281030
create cast (xfloat8 as float8) without function;
10291031
create cast (float8 as xfloat8) without function;

‎src/test/regress/expected/identity.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ CREATE TABLE itest4 (a int, b text);
4343
ALTER TABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY; -- error, requires NOT NULL
4444
ERROR: column "a" of relation "itest4" must be declared NOT NULL before identity can be added
4545
ALTER TABLE itest4 ALTER COLUMN a SET NOT NULL;
46+
ALTER TABLE itest4 ALTER COLUMN c ADD GENERATED ALWAYS AS IDENTITY; -- error, column c does not exist
47+
ERROR: column "c" of relation "itest4" does not exist
4648
ALTER TABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY; -- ok
4749
ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL; -- error, disallowed
4850
ERROR: column "a" of relation "itest4" is an identity column

‎src/test/regress/sql/alter_table.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,11 @@ ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE text;
21452145
ALTERTABLE comment_test ALTER COLUMN positive_colSET DATA TYPEint;
21462146
ALTERTABLE comment_test ALTER COLUMN positive_colSET DATA TYPEbigint;
21472147

2148+
-- Some error cases.
2149+
ALTERTABLE comment_test ALTER COLUMN xminSET DATA TYPE x;
2150+
ALTERTABLE comment_test ALTER COLUMN idSET DATA TYPE x;
2151+
ALTERTABLE comment_test ALTER COLUMN idSET DATA TYPEint COLLATE"C";
2152+
21482153
-- Check that the comments are intact.
21492154
SELECT col_description('comment_test'::regclass,1)as comment;
21502155
SELECT indexrelid::regclass::textas index, obj_description(indexrelid,'pg_class')as commentFROM pg_indexwhere indrelid='comment_test'::regclassORDER BY1,2;

‎src/test/regress/sql/domain.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ drop domain domaindroptest cascade;
1616
-- this should fail because already gone
1717
dropdomain domaindroptest cascade;
1818

19+
-- some error cases
20+
createdomaind_failas no_such_type;
21+
createdomaind_failasintconstraint ccREFERENCES this_table_not_exists(i);
22+
createdomaind_failas int4not null no inherit;
23+
createdomaind_failas int4not nullnull;
24+
createdomaind_failas int4not null default3 default3;
25+
createdomaind_fail int4 DEFAULT3+'h';
26+
createdomaind_fail int4 collate"C";
27+
createdomaind_failas anyelement;
28+
createdomaind_failas int4 unique;
29+
createdomaind_failas int4PRIMARY key;
30+
createdomaind_failas int4constraint cc generated by defaultas identity;
31+
createdomaind_failas int4constraint cccheck (values>1) no inherit;
32+
createdomaind_failas int4constraint cccheck (values>1) deferrable;
1933

2034
-- Test domain input.
2135

‎src/test/regress/sql/float8.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ create function xfloat8in(cstring) returns xfloat8 immutable strict
328328
language internalas'int8in';
329329
createfunctionxfloat8out(xfloat8) returns cstring immutable strict
330330
language internalas'int8out';
331+
createtypexfloat8 (input= xfloat8in, output= xfloat8out,like= no_such_type);
331332
createtypexfloat8 (input= xfloat8in, output= xfloat8out,like= float8);
332333
create cast (xfloat8as float8) without function;
333334
create cast (float8as xfloat8) without function;

‎src/test/regress/sql/identity.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SELECT pg_get_serial_sequence('itest1', 'a');
1919
CREATETABLEitest4 (aint, btext);
2020
ALTERTABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYSAS IDENTITY;-- error, requires NOT NULL
2121
ALTERTABLE itest4 ALTER COLUMN aSETNOT NULL;
22+
ALTERTABLE itest4 ALTER COLUMN c ADD GENERATED ALWAYSAS IDENTITY;-- error, column c does not exist
2223
ALTERTABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYSAS IDENTITY;-- ok
2324
ALTERTABLE itest4 ALTER COLUMN a DROPNOT NULL;-- error, disallowed
2425
ALTERTABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYSAS IDENTITY;-- error, already set

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp