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

Commit7cc8af5

Browse files
committed
Got "ADD" to appear only in ALTER TABLE and not CREATE TABLE
UNIQUE-PRIMARY KEY notice message. This is what Christopher wanted fromhis patch.
1 parent434077c commit7cc8af5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

‎src/backend/parser/analyze.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.208 2001/11/0402:41:09 momjian Exp $
9+
*$Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.209 2001/11/0403:08:11 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -1238,8 +1238,10 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
12381238
elog(ERROR,"%s: failed to make implicit index name",
12391239
cxt->stmtType);
12401240

1241-
elog(NOTICE,"%s / %s will create implicit index '%s' for table '%s'",
1242-
cxt->stmtType, (index->primary ?"PRIMARY KEY" :"UNIQUE"),
1241+
elog(NOTICE,"%s / %s%s will create implicit index '%s' for table '%s'",
1242+
cxt->stmtType,
1243+
(strcmp(cxt->stmtType,"ALTER TABLE")==0) ?"ADD " :"",
1244+
(index->primary ?"PRIMARY KEY" :"UNIQUE"),
12431245
index->idxname,cxt->relname);
12441246
}
12451247
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ drop table atacc1;
452452
create table atacc1 ( test int );
453453
-- add a unique constraint
454454
alter table atacc1 add constraint atacc_test1 unique (test);
455-
NOTICE: ALTER TABLE / UNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
455+
NOTICE: ALTER TABLE /ADDUNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
456456
-- insert first value
457457
insert into atacc1 (test) values (2);
458458
-- should fail
@@ -462,7 +462,7 @@ ERROR: Cannot insert a duplicate key into unique index atacc_test1
462462
insert into atacc1 (test) values (4);
463463
-- try adding a unique oid constraint
464464
alter table atacc1 add constraint atacc_oid1 unique(oid);
465-
NOTICE: ALTER TABLE / UNIQUE will create implicit index 'atacc_oid1' for table 'atacc1'
465+
NOTICE: ALTER TABLE /ADDUNIQUE will create implicit index 'atacc_oid1' for table 'atacc1'
466466
drop table atacc1;
467467
-- let's do one where the unique constraint fails when added
468468
create table atacc1 ( test int );
@@ -471,7 +471,7 @@ insert into atacc1 (test) values (2);
471471
insert into atacc1 (test) values (2);
472472
-- add a unique constraint (fails)
473473
alter table atacc1 add constraint atacc_test1 unique (test);
474-
NOTICE: ALTER TABLE / UNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
474+
NOTICE: ALTER TABLE /ADDUNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
475475
ERROR: Cannot create unique index. Table contains non-unique values
476476
insert into atacc1 (test) values (3);
477477
drop table atacc1;
@@ -486,7 +486,7 @@ drop table atacc1;
486486
create table atacc1 ( test int, test2 int);
487487
-- add a unique constraint
488488
alter table atacc1 add constraint atacc_test1 unique (test, test2);
489-
NOTICE: ALTER TABLE / UNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
489+
NOTICE: ALTER TABLE /ADDUNIQUE will create implicit index 'atacc_test1' for table 'atacc1'
490490
-- insert initial value
491491
insert into atacc1 (test,test2) values (4,4);
492492
-- should fail
@@ -501,7 +501,7 @@ drop table atacc1;
501501
create table atacc1 (test int, test2 int, unique(test));
502502
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'atacc1_test_key' for table 'atacc1'
503503
alter table atacc1 add unique (test2);
504-
NOTICE: ALTER TABLE / UNIQUE will create implicit index 'atacc1_test2_key' for table 'atacc1'
504+
NOTICE: ALTER TABLE /ADDUNIQUE will create implicit index 'atacc1_test2_key' for table 'atacc1'
505505
-- should fail for @@ second one @@
506506
insert into atacc1 (test2, test) values (3, 3);
507507
insert into atacc1 (test2, test) values (2, 3);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp