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

Commit96b00c4

Browse files
committed
Remove obsolete pg_constraint.consrc column
This has been deprecated and effectively unused for a long time.Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
1 parentfe50382 commit96b00c4

File tree

11 files changed

+25
-79
lines changed

11 files changed

+25
-79
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,14 +2400,10 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
24002400
<entry><structfield>conbin</structfield></entry>
24012401
<entry><type>pg_node_tree</type></entry>
24022402
<entry></entry>
2403-
<entry>If a check constraint, an internal representation of the expression</entry>
2404-
</row>
2405-
2406-
<row>
2407-
<entry><structfield>consrc</structfield></entry>
2408-
<entry><type>text</type></entry>
2409-
<entry></entry>
2410-
<entry>If a check constraint, a human-readable representation of the expression</entry>
2403+
<entry>If a check constraint, an internal representation of the
2404+
expression. (It's recommended to use
2405+
<function>pg_get_constraintdef()</function> to extract the definition of
2406+
a check constraint.)</entry>
24112407
</row>
24122408
</tbody>
24132409
</tgroup>
@@ -2423,15 +2419,6 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
24232419
index.)
24242420
</para>
24252421

2426-
<note>
2427-
<para>
2428-
<structfield>consrc</structfield> is not updated when referenced objects
2429-
change; for example, it won't track renaming of columns. Rather than
2430-
relying on this field, it's best to use <function>pg_get_constraintdef()</function>
2431-
to extract the definition of a check constraint.
2432-
</para>
2433-
</note>
2434-
24352422
<note>
24362423
<para>
24372424
<literal>pg_class.relchecks</literal> needs to agree with the

‎src/backend/catalog/heap.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,6 @@ StoreRelCheck(Relation rel, const char *ccname, Node *expr,
23152315
boolis_no_inherit,boolis_internal)
23162316
{
23172317
char*ccbin;
2318-
char*ccsrc;
23192318
List*varList;
23202319
intkeycount;
23212320
int16*attNos;
@@ -2326,14 +2325,6 @@ StoreRelCheck(Relation rel, const char *ccname, Node *expr,
23262325
*/
23272326
ccbin=nodeToString(expr);
23282327

2329-
/*
2330-
* Also deparse it to form the mostly-obsolete consrc field.
2331-
*/
2332-
ccsrc=deparse_expression(expr,
2333-
deparse_context_for(RelationGetRelationName(rel),
2334-
RelationGetRelid(rel)),
2335-
false, false);
2336-
23372328
/*
23382329
* Find columns of rel that are used in expr
23392330
*
@@ -2406,14 +2397,12 @@ StoreRelCheck(Relation rel, const char *ccname, Node *expr,
24062397
NULL,/* not an exclusion constraint */
24072398
expr,/* Tree form of check constraint */
24082399
ccbin,/* Binary form of check constraint */
2409-
ccsrc,/* Source form of check constraint */
24102400
is_local,/* conislocal */
24112401
inhcount,/* coninhcount */
24122402
is_no_inherit,/* connoinherit */
24132403
is_internal);/* internally constructed? */
24142404

24152405
pfree(ccbin);
2416-
pfree(ccsrc);
24172406

24182407
returnconstrOid;
24192408
}

‎src/backend/catalog/index.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,6 @@ index_constraint_create(Relation heapRelation,
13361336
indexInfo->ii_ExclusionOps,
13371337
NULL,/* no check constraint */
13381338
NULL,
1339-
NULL,
13401339
islocal,
13411340
inhcount,
13421341
noinherit,

‎src/backend/catalog/pg_constraint.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ CreateConstraintEntry(const char *constraintName,
7878
constOid*exclOp,
7979
Node*conExpr,
8080
constchar*conBin,
81-
constchar*conSrc,
8281
boolconIsLocal,
8382
intconInhCount,
8483
boolconNoInherit,
@@ -218,22 +217,11 @@ CreateConstraintEntry(const char *constraintName,
218217
else
219218
nulls[Anum_pg_constraint_conexclop-1]= true;
220219

221-
/*
222-
* initialize the binary form of the check constraint.
223-
*/
224220
if (conBin)
225221
values[Anum_pg_constraint_conbin-1]=CStringGetTextDatum(conBin);
226222
else
227223
nulls[Anum_pg_constraint_conbin-1]= true;
228224

229-
/*
230-
* initialize the text form of the check constraint
231-
*/
232-
if (conSrc)
233-
values[Anum_pg_constraint_consrc-1]=CStringGetTextDatum(conSrc);
234-
else
235-
nulls[Anum_pg_constraint_consrc-1]= true;
236-
237225
tup=heap_form_tuple(RelationGetDescr(conDesc),values,nulls);
238226

239227
conOid=CatalogTupleInsert(conDesc,tup);
@@ -703,7 +691,6 @@ clone_fk_constraints(Relation pg_constraint, Relation parentRel,
703691
NULL,
704692
NULL,
705693
NULL,
706-
NULL,
707694
false,
708695
1, false, true);
709696
subclone=lappend_oid(subclone,constrOid);

‎src/backend/commands/tablecmds.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7704,7 +7704,6 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
77047704
NULL,/* no exclusion constraint */
77057705
NULL,/* no check constraint */
77067706
NULL,
7707-
NULL,
77087707
true,/* islocal */
77097708
0,/* inhcount */
77107709
true,/* isnoinherit */

‎src/backend/commands/trigger.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
752752
NULL,/* no exclusion */
753753
NULL,/* no check constraint */
754754
NULL,
755-
NULL,
756755
true,/* islocal */
757756
0,/* inhcount */
758757
true,/* isnoinherit */

‎src/backend/commands/typecmds.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3042,7 +3042,6 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
30423042
constchar*domainName,ObjectAddress*constrAddr)
30433043
{
30443044
Node*expr;
3045-
char*ccsrc;
30463045
char*ccbin;
30473046
ParseState*pstate;
30483047
CoerceToDomainValue*domVal;
@@ -3116,12 +3115,6 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
31163115
*/
31173116
ccbin=nodeToString(expr);
31183117

3119-
/*
3120-
* Deparse it to produce text for consrc.
3121-
*/
3122-
ccsrc=deparse_expression(expr,
3123-
NIL, false, false);
3124-
31253118
/*
31263119
* Store the constraint in pg_constraint
31273120
*/
@@ -3151,7 +3144,6 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
31513144
NULL,/* not an exclusion constraint */
31523145
expr,/* Tree form of check constraint */
31533146
ccbin,/* Binary form of check constraint */
3154-
ccsrc,/* Source form of check constraint */
31553147
true,/* is local */
31563148
0,/* inhcount */
31573149
false,/* connoinherit */

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201811011
56+
#defineCATALOG_VERSION_NO201811012
5757

5858
#endif

‎src/include/catalog/pg_constraint.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
142142
* If a check constraint, nodeToString representation of expression
143143
*/
144144
pg_node_treeconbin;
145-
146-
/*
147-
* If a check constraint, source-text representation of expression
148-
*/
149-
textconsrc;
150145
#endif
151146
}FormData_pg_constraint;
152147

@@ -224,7 +219,6 @@ extern Oid CreateConstraintEntry(const char *constraintName,
224219
constOid*exclOp,
225220
Node*conExpr,
226221
constchar*conBin,
227-
constchar*conSrc,
228222
boolconIsLocal,
229223
intconInhCount,
230224
boolconNoInherit,

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ drop table p1;
797797
CREATE TABLE ac (aa TEXT);
798798
alter table ac add constraint ac_check check (aa is not null);
799799
CREATE TABLE bc (bb TEXT) INHERITS (ac);
800-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
800+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
801801
relname | conname | contype | conislocal | coninhcount | consrc
802802
---------+----------+---------+------------+-------------+------------------
803803
ac | ac_check | c | t | 0 | (aa IS NOT NULL)
@@ -813,14 +813,14 @@ DETAIL: Failing row contains (null, null).
813813
alter table bc drop constraint ac_check; -- fail, disallowed
814814
ERROR: cannot drop inherited constraint "ac_check" of relation "bc"
815815
alter table ac drop constraint ac_check;
816-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
816+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
817817
relname | conname | contype | conislocal | coninhcount | consrc
818818
---------+---------+---------+------------+-------------+--------
819819
(0 rows)
820820

821821
-- try the unnamed-constraint case
822822
alter table ac add check (aa is not null);
823-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
823+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
824824
relname | conname | contype | conislocal | coninhcount | consrc
825825
---------+-------------+---------+------------+-------------+------------------
826826
ac | ac_aa_check | c | t | 0 | (aa IS NOT NULL)
@@ -836,29 +836,29 @@ DETAIL: Failing row contains (null, null).
836836
alter table bc drop constraint ac_aa_check; -- fail, disallowed
837837
ERROR: cannot drop inherited constraint "ac_aa_check" of relation "bc"
838838
alter table ac drop constraint ac_aa_check;
839-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
839+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
840840
relname | conname | contype | conislocal | coninhcount | consrc
841841
---------+---------+---------+------------+-------------+--------
842842
(0 rows)
843843

844844
alter table ac add constraint ac_check check (aa is not null);
845845
alter table bc no inherit ac;
846-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
846+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
847847
relname | conname | contype | conislocal | coninhcount | consrc
848848
---------+----------+---------+------------+-------------+------------------
849849
ac | ac_check | c | t | 0 | (aa IS NOT NULL)
850850
bc | ac_check | c | t | 0 | (aa IS NOT NULL)
851851
(2 rows)
852852

853853
alter table bc drop constraint ac_check;
854-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
854+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
855855
relname | conname | contype | conislocal | coninhcount | consrc
856856
---------+----------+---------+------------+-------------+------------------
857857
ac | ac_check | c | t | 0 | (aa IS NOT NULL)
858858
(1 row)
859859

860860
alter table ac drop constraint ac_check;
861-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
861+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
862862
relname | conname | contype | conislocal | coninhcount | consrc
863863
---------+---------+---------+------------+-------------+--------
864864
(0 rows)
@@ -869,7 +869,7 @@ create table ac (a int constraint check_a check (a <> 0));
869869
create table bc (a int constraint check_a check (a <> 0), b int constraint check_b check (b <> 0)) inherits (ac);
870870
NOTICE: merging column "a" with inherited definition
871871
NOTICE: merging constraint "check_a" with inherited definition
872-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
872+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2;
873873
relname | conname | contype | conislocal | coninhcount | consrc
874874
---------+---------+---------+------------+-------------+----------
875875
ac | check_a | c | t | 0 | (a <> 0)
@@ -882,7 +882,7 @@ drop table ac;
882882
create table ac (a int constraint check_a check (a <> 0));
883883
create table bc (b int constraint check_b check (b <> 0));
884884
create table cc (c int constraint check_c check (c <> 0)) inherits (ac, bc);
885-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2;
885+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2;
886886
relname | conname | contype | conislocal | coninhcount | consrc
887887
---------+---------+---------+------------+-------------+----------
888888
ac | check_a | c | t | 0 | (a <> 0)
@@ -893,7 +893,7 @@ select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg
893893
(5 rows)
894894

895895
alter table cc no inherit bc;
896-
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2;
896+
select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount,pg_get_expr(pgc.conbin, pc.oid) asconsrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2;
897897
relname | conname | contype | conislocal | coninhcount | consrc
898898
---------+---------+---------+------------+-------------+----------
899899
ac | check_a | c | t | 0 | (a <> 0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp