Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 030e10f

Browse files
committed
Rename pg_constraint.conwithoutoverlaps to conperiod
pg_constraint.conwithoutoverlaps was recently added to support primary keys and unique constraints with the WITHOUT OVERLAPS clause. An upcoming patch provides the foreign-key side of this functionality, but the syntax there is different and uses the keyword PERIOD. It would make sense to use the same pg_constraint field for both of these, but then we should pick a more general name that conveys "this constraint has a temporal/period-related feature". conperiod works for that and is nicely compact. Changing this now avoids possibly having to introduce versioning into clients. Note there are still some "without overlaps" variables left, which deal specifically with the parsing of the primary key/unique constraint feature. Author: Paul A. Jungwirth <pj@illuminatedcomputing.com> Discussion: https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com
1 parent 55cdba2 commit 030e10f

File tree

13 files changed

+26
-27
lines changed

13 files changed

+26
-27
lines changed

doc/src/sgml/catalogs.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2711,7 +2711,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
27112711

27122712
<row>
27132713
<entry role="catalog_table_entry"><para role="column_definition">
2714-
<structfield>conwithoutoverlaps</structfield> <type>bool</type>
2714+
<structfield>conperiod</structfield> <type>bool</type>
27152715
</para>
27162716
<para>
27172717
This constraint is defined with <literal>WITHOUT OVERLAPS</literal>

src/backend/catalog/heap.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ StoreRelCheck(Relation rel, const char *ccname, Node *expr,
21452145
is_local, /* conislocal */
21462146
inhcount, /* coninhcount */
21472147
is_no_inherit, /* connoinherit */
2148-
false, /* conwithoutoverlaps */
2148+
false, /* conperiod */
21492149
is_internal); /* internally constructed? */
21502150

21512151
pfree(ccbin);
@@ -2196,7 +2196,7 @@ StoreRelNotNull(Relation rel, const char *nnname, AttrNumber attnum,
21962196
is_local,
21972197
inhcount,
21982198
is_no_inherit,
2199-
false, /* conwithoutoverlaps */
2199+
false, /* conperiod */
22002200
false);
22012201
return constrOid;
22022202
}

src/backend/catalog/pg_constraint.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ CreateConstraintEntry(const char *constraintName,
7676
bool conIsLocal,
7777
int conInhCount,
7878
bool conNoInherit,
79-
bool conWithoutOverlaps,
79+
bool conPeriod,
8080
bool is_internal)
8181
{
8282
Relation conDesc;
@@ -192,7 +192,7 @@ CreateConstraintEntry(const char *constraintName,
192192
values[Anum_pg_constraint_conislocal - 1] = BoolGetDatum(conIsLocal);
193193
values[Anum_pg_constraint_coninhcount - 1] = Int16GetDatum(conInhCount);
194194
values[Anum_pg_constraint_connoinherit - 1] = BoolGetDatum(conNoInherit);
195-
values[Anum_pg_constraint_conwithoutoverlaps - 1] = BoolGetDatum(conWithoutOverlaps);
195+
values[Anum_pg_constraint_conperiod - 1] = BoolGetDatum(conPeriod);
196196

197197
if (conkeyArray)
198198
values[Anum_pg_constraint_conkey - 1] = PointerGetDatum(conkeyArray);

src/backend/commands/tablecmds.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -10378,7 +10378,7 @@ addFkRecurseReferenced(List **wqueue, Constraint *fkconstraint, Relation rel,
1037810378
conislocal, /* islocal */
1037910379
coninhcount, /* inhcount */
1038010380
connoinherit, /* conNoInherit */
10381-
false, /* conWithoutOverlaps */
10381+
false, /* conPeriod */
1038210382
false); /* is_internal */
1038310383

1038410384
ObjectAddressSet(address, ConstraintRelationId, constrOid);
@@ -10677,7 +10677,7 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel,
1067710677
false,
1067810678
1,
1067910679
false,
10680-
false, /* conWithoutOverlaps */
10680+
false, /* conPeriod */
1068110681
false);
1068210682

1068310683
/*
@@ -11183,7 +11183,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
1118311183
false, /* islocal */
1118411184
1, /* inhcount */
1118511185
false, /* conNoInherit */
11186-
false, /* conWithoutOverlaps */
11186+
false, /* conPeriod */
1118711187
true);
1118811188

1118911189
/* Set up partition dependencies for the new constraint */

src/backend/commands/trigger.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
834834
true, /* islocal */
835835
0, /* inhcount */
836836
true, /* noinherit */
837-
false, /* conwithoutoverlaps */
837+
false, /* conperiod */
838838
isInternal); /* is_internal */
839839
}
840840

src/backend/commands/typecmds.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
35443544
true, /* is local */
35453545
0, /* inhcount */
35463546
false, /* connoinherit */
3547-
false, /* conwithoutoverlaps */
3547+
false, /* conperiod */
35483548
false); /* is_internal */
35493549
if (constrAddr)
35503550
ObjectAddressSet(*constrAddr, ConstraintRelationId, ccoid);

src/backend/utils/adt/ruleutils.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
23782378
Anum_pg_constraint_conkey);
23792379

23802380
keyatts = decompile_column_index_array(val, conForm->conrelid, &buf);
2381-
if (conForm->conwithoutoverlaps)
2381+
if (conForm->conperiod)
23822382
appendStringInfoString(&buf, " WITHOUT OVERLAPS");
23832383

23842384
appendStringInfoChar(&buf, ')');

src/backend/utils/cache/relcache.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -5620,9 +5620,9 @@ RelationGetExclusionInfo(Relation indexRelation,
56205620

56215621
/* We want the exclusion constraint owning the index */
56225622
if ((conform->contype != CONSTRAINT_EXCLUSION &&
5623-
!(conform->conwithoutoverlaps && (
5624-
conform->contype == CONSTRAINT_PRIMARY
5625-
|| conform->contype == CONSTRAINT_UNIQUE))) ||
5623+
!(conform->conperiod && (
5624+
conform->contype == CONSTRAINT_PRIMARY
5625+
|| conform->contype == CONSTRAINT_UNIQUE))) ||
56265626
conform->conindid != RelationGetRelid(indexRelation))
56275627
continue;
56285628

src/bin/pg_dump/pg_dump.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -7252,7 +7252,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
72527252
i_conname,
72537253
i_condeferrable,
72547254
i_condeferred,
7255-
i_conwithoutoverlaps,
7255+
i_conperiod,
72567256
i_contableoid,
72577257
i_conoid,
72587258
i_condef,
@@ -7341,10 +7341,10 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
73417341

73427342
if (fout->remoteVersion >= 170000)
73437343
appendPQExpBufferStr(query,
7344-
"c.conwithoutoverlaps ");
7344+
"c.conperiod ");
73457345
else
73467346
appendPQExpBufferStr(query,
7347-
"NULL AS conwithoutoverlaps ");
7347+
"NULL AS conperiod ");
73487348

73497349
/*
73507350
* The point of the messy-looking outer join is to find a constraint that
@@ -7412,7 +7412,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
74127412
i_conname = PQfnumber(res, "conname");
74137413
i_condeferrable = PQfnumber(res, "condeferrable");
74147414
i_condeferred = PQfnumber(res, "condeferred");
7415-
i_conwithoutoverlaps = PQfnumber(res, "conwithoutoverlaps");
7415+
i_conperiod = PQfnumber(res, "conperiod");
74167416
i_contableoid = PQfnumber(res, "contableoid");
74177417
i_conoid = PQfnumber(res, "conoid");
74187418
i_condef = PQfnumber(res, "condef");
@@ -7520,7 +7520,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
75207520
constrinfo->conindex = indxinfo[j].dobj.dumpId;
75217521
constrinfo->condeferrable = *(PQgetvalue(res, j, i_condeferrable)) == 't';
75227522
constrinfo->condeferred = *(PQgetvalue(res, j, i_condeferred)) == 't';
7523-
constrinfo->conwithoutoverlaps = *(PQgetvalue(res, j, i_conwithoutoverlaps)) == 't';
7523+
constrinfo->conperiod = *(PQgetvalue(res, j, i_conperiod)) == 't';
75247524
constrinfo->conislocal = true;
75257525
constrinfo->separate = true;
75267526

@@ -17158,7 +17158,7 @@ dumpConstraint(Archive *fout, const ConstraintInfo *coninfo)
1715817158
(k == 0) ? "" : ", ",
1715917159
fmtId(attname));
1716017160
}
17161-
if (coninfo->conwithoutoverlaps)
17161+
if (coninfo->conperiod)
1716217162
appendPQExpBufferStr(q, " WITHOUT OVERLAPS");
1716317163

1716417164
if (indxinfo->indnkeyattrs < indxinfo->indnattrs)

src/bin/pg_dump/pg_dump.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,7 @@ typedef struct _constraintInfo
479479
DumpId conindex; /* identifies associated index if any */
480480
bool condeferrable; /* true if constraint is DEFERRABLE */
481481
bool condeferred; /* true if constraint is INITIALLY DEFERRED */
482-
bool conwithoutoverlaps; /* true if the constraint is WITHOUT
483-
* OVERLAPS */
482+
bool conperiod; /* true if the constraint is WITHOUT OVERLAPS */
484483
bool conislocal; /* true if constraint has local definition */
485484
bool separate; /* true if must dump as separate item */
486485
} ConstraintInfo;

src/bin/psql/describe.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2380,9 +2380,9 @@ describeOneTableDetails(const char *schemaname,
23802380
appendPQExpBufferStr(&buf, ", false AS indisreplident");
23812381
appendPQExpBufferStr(&buf, ", c2.reltablespace");
23822382
if (pset.sversion >= 170000)
2383-
appendPQExpBufferStr(&buf, ", con.conwithoutoverlaps");
2383+
appendPQExpBufferStr(&buf, ", con.conperiod");
23842384
else
2385-
appendPQExpBufferStr(&buf, ", false AS conwithoutoverlaps");
2385+
appendPQExpBufferStr(&buf, ", false AS conperiod");
23862386
appendPQExpBuffer(&buf,
23872387
"\nFROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n"
23882388
" LEFT JOIN pg_catalog.pg_constraint con ON (conrelid = i.indrelid AND conindid = i.indexrelid AND contype IN ('p','u','x'))\n"

src/include/catalog/catversion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/* yyyymmddN */
60-
#define CATALOG_VERSION_NO 202403042
60+
#define CATALOG_VERSION_NO 202403051
6161

6262
#endif

src/include/catalog/pg_constraint.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
111111
* For primary keys and unique constraints, signifies the last column uses
112112
* overlaps instead of equals.
113113
*/
114-
bool conwithoutoverlaps;
114+
bool conperiod;
115115

116116
#ifdef CATALOG_VARLEN /* variable-length fields start here */
117117

@@ -245,7 +245,7 @@ extern Oid CreateConstraintEntry(const char *constraintName,
245245
bool conIsLocal,
246246
int conInhCount,
247247
bool conNoInherit,
248-
bool conWithoutOverlaps,
248+
bool conPeriod,
249249
bool is_internal);
250250

251251
extern bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,

0 commit comments

Comments
 (0)