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

Commit2f98ece

Browse files
committed
The brackets aren't put on the CHECK constraints properly.
Before patch:test=# select pg_get_constraintdef(oid) from pg_constraint; pg_get_constraintdef------------------------------------------------------------------------------------------------- CHECK (VALUE >= 0) CHECK ((((a)::text = 'asdf'::text) OR ((a)::text = 'fdsa'::text)) OR((a)::text = 'dfd'::text)) PRIMARY KEY (b) FOREIGN KEY (a) REFERENCES test2(b) UNIQUE (b)(5 rows)test=# select pg_get_constraintdef(oid, true) from pg_constraint; pg_get_constraintdef----------------------------------------------------------------------------------- CHECK VALUE >= 0 CHECK a::text = 'asdf'::text OR a::text = 'fdsa'::text OR a::text ='dfd'::text PRIMARY KEY (b) FOREIGN KEY (a) REFERENCES test2(b) UNIQUE (b)(5 rows)After patch:test=# select pg_get_constraintdef(oid) from pg_constraint; pg_get_constraintdef------------------------------------------------------------------------------------------------- CHECK (VALUE >= 0) CHECK ((((a)::text = 'asdf'::text) OR ((a)::text = 'fdsa'::text)) OR((a)::text = 'dfd'::text)) PRIMARY KEY (b) FOREIGN KEY (a) REFERENCES test2(b) UNIQUE (b)(5 rows)test=# select pg_get_constraintdef(oid, true) from pg_constraint; pg_get_constraintdef----------------------------------------------------------------------------------- CHECK (VALUE >= 0)` CHECK (a::text = 'asdf'::text OR a::text = 'fdsa'::text OR a::text ='dfd'::text) PRIMARY KEY (b) FOREIGN KEY (a) REFERENCES test2(b) UNIQUE (b)(5 rows)It's important that those brackets are there to (a) match all otherconstraints and (b) so that people can just copy and paste them and itwill work as SQL.Christopher Kings-Lynne
1 parent6000e32 commit2f98ece

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*back to source text
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.154 2003/09/15 20:03:37 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.155 2003/09/29 18:55:56 momjian Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -1056,6 +1056,10 @@ pg_get_constraintdef_worker(Oid constraintId, int prettyFlags)
10561056
*/
10571057
appendStringInfo(&buf,"CHECK ");
10581058

1059+
/* If we're pretty-printing we need to add brackets */
1060+
if (prettyFlags!=0)
1061+
appendStringInfo(&buf,"(");
1062+
10591063
/* Fetch constraint source */
10601064
val=heap_getattr(tup,Anum_pg_constraint_conbin,
10611065
RelationGetDescr(conDesc),&isnull);
@@ -1094,6 +1098,10 @@ pg_get_constraintdef_worker(Oid constraintId, int prettyFlags)
10941098
/* Append the constraint source */
10951099
appendStringInfoString(&buf,consrc);
10961100

1101+
/* If we're pretty-printing we need to add brackets */
1102+
if (prettyFlags!=0)
1103+
appendStringInfo(&buf,")");
1104+
10971105
break;
10981106
}
10991107
default:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp