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
This commit is contained in:
parent
55cdba2647
commit
030e10ff1a
@ -2711,7 +2711,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>conwithoutoverlaps</structfield> <type>bool</type>
|
||||
<structfield>conperiod</structfield> <type>bool</type>
|
||||
</para>
|
||||
<para>
|
||||
This constraint is defined with <literal>WITHOUT OVERLAPS</literal>
|
||||
|
@ -2145,7 +2145,7 @@ StoreRelCheck(Relation rel, const char *ccname, Node *expr,
|
||||
is_local, /* conislocal */
|
||||
inhcount, /* coninhcount */
|
||||
is_no_inherit, /* connoinherit */
|
||||
false, /* conwithoutoverlaps */
|
||||
false, /* conperiod */
|
||||
is_internal); /* internally constructed? */
|
||||
|
||||
pfree(ccbin);
|
||||
@ -2196,7 +2196,7 @@ StoreRelNotNull(Relation rel, const char *nnname, AttrNumber attnum,
|
||||
is_local,
|
||||
inhcount,
|
||||
is_no_inherit,
|
||||
false, /* conwithoutoverlaps */
|
||||
false, /* conperiod */
|
||||
false);
|
||||
return constrOid;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ CreateConstraintEntry(const char *constraintName,
|
||||
bool conIsLocal,
|
||||
int conInhCount,
|
||||
bool conNoInherit,
|
||||
bool conWithoutOverlaps,
|
||||
bool conPeriod,
|
||||
bool is_internal)
|
||||
{
|
||||
Relation conDesc;
|
||||
@ -192,7 +192,7 @@ CreateConstraintEntry(const char *constraintName,
|
||||
values[Anum_pg_constraint_conislocal - 1] = BoolGetDatum(conIsLocal);
|
||||
values[Anum_pg_constraint_coninhcount - 1] = Int16GetDatum(conInhCount);
|
||||
values[Anum_pg_constraint_connoinherit - 1] = BoolGetDatum(conNoInherit);
|
||||
values[Anum_pg_constraint_conwithoutoverlaps - 1] = BoolGetDatum(conWithoutOverlaps);
|
||||
values[Anum_pg_constraint_conperiod - 1] = BoolGetDatum(conPeriod);
|
||||
|
||||
if (conkeyArray)
|
||||
values[Anum_pg_constraint_conkey - 1] = PointerGetDatum(conkeyArray);
|
||||
|
@ -10378,7 +10378,7 @@ addFkRecurseReferenced(List **wqueue, Constraint *fkconstraint, Relation rel,
|
||||
conislocal, /* islocal */
|
||||
coninhcount, /* inhcount */
|
||||
connoinherit, /* conNoInherit */
|
||||
false, /* conWithoutOverlaps */
|
||||
false, /* conPeriod */
|
||||
false); /* is_internal */
|
||||
|
||||
ObjectAddressSet(address, ConstraintRelationId, constrOid);
|
||||
@ -10677,7 +10677,7 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel,
|
||||
false,
|
||||
1,
|
||||
false,
|
||||
false, /* conWithoutOverlaps */
|
||||
false, /* conPeriod */
|
||||
false);
|
||||
|
||||
/*
|
||||
@ -11183,7 +11183,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
|
||||
false, /* islocal */
|
||||
1, /* inhcount */
|
||||
false, /* conNoInherit */
|
||||
false, /* conWithoutOverlaps */
|
||||
false, /* conPeriod */
|
||||
true);
|
||||
|
||||
/* Set up partition dependencies for the new constraint */
|
||||
|
@ -834,7 +834,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
|
||||
true, /* islocal */
|
||||
0, /* inhcount */
|
||||
true, /* noinherit */
|
||||
false, /* conwithoutoverlaps */
|
||||
false, /* conperiod */
|
||||
isInternal); /* is_internal */
|
||||
}
|
||||
|
||||
|
@ -3544,7 +3544,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
|
||||
true, /* is local */
|
||||
0, /* inhcount */
|
||||
false, /* connoinherit */
|
||||
false, /* conwithoutoverlaps */
|
||||
false, /* conperiod */
|
||||
false); /* is_internal */
|
||||
if (constrAddr)
|
||||
ObjectAddressSet(*constrAddr, ConstraintRelationId, ccoid);
|
||||
|
@ -2378,7 +2378,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
|
||||
Anum_pg_constraint_conkey);
|
||||
|
||||
keyatts = decompile_column_index_array(val, conForm->conrelid, &buf);
|
||||
if (conForm->conwithoutoverlaps)
|
||||
if (conForm->conperiod)
|
||||
appendStringInfoString(&buf, " WITHOUT OVERLAPS");
|
||||
|
||||
appendStringInfoChar(&buf, ')');
|
||||
|
6
src/backend/utils/cache/relcache.c
vendored
6
src/backend/utils/cache/relcache.c
vendored
@ -5620,9 +5620,9 @@ RelationGetExclusionInfo(Relation indexRelation,
|
||||
|
||||
/* We want the exclusion constraint owning the index */
|
||||
if ((conform->contype != CONSTRAINT_EXCLUSION &&
|
||||
!(conform->conwithoutoverlaps && (
|
||||
conform->contype == CONSTRAINT_PRIMARY
|
||||
|| conform->contype == CONSTRAINT_UNIQUE))) ||
|
||||
!(conform->conperiod && (
|
||||
conform->contype == CONSTRAINT_PRIMARY
|
||||
|| conform->contype == CONSTRAINT_UNIQUE))) ||
|
||||
conform->conindid != RelationGetRelid(indexRelation))
|
||||
continue;
|
||||
|
||||
|
@ -7252,7 +7252,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
|
||||
i_conname,
|
||||
i_condeferrable,
|
||||
i_condeferred,
|
||||
i_conwithoutoverlaps,
|
||||
i_conperiod,
|
||||
i_contableoid,
|
||||
i_conoid,
|
||||
i_condef,
|
||||
@ -7341,10 +7341,10 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
|
||||
|
||||
if (fout->remoteVersion >= 170000)
|
||||
appendPQExpBufferStr(query,
|
||||
"c.conwithoutoverlaps ");
|
||||
"c.conperiod ");
|
||||
else
|
||||
appendPQExpBufferStr(query,
|
||||
"NULL AS conwithoutoverlaps ");
|
||||
"NULL AS conperiod ");
|
||||
|
||||
/*
|
||||
* 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)
|
||||
i_conname = PQfnumber(res, "conname");
|
||||
i_condeferrable = PQfnumber(res, "condeferrable");
|
||||
i_condeferred = PQfnumber(res, "condeferred");
|
||||
i_conwithoutoverlaps = PQfnumber(res, "conwithoutoverlaps");
|
||||
i_conperiod = PQfnumber(res, "conperiod");
|
||||
i_contableoid = PQfnumber(res, "contableoid");
|
||||
i_conoid = PQfnumber(res, "conoid");
|
||||
i_condef = PQfnumber(res, "condef");
|
||||
@ -7520,7 +7520,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
|
||||
constrinfo->conindex = indxinfo[j].dobj.dumpId;
|
||||
constrinfo->condeferrable = *(PQgetvalue(res, j, i_condeferrable)) == 't';
|
||||
constrinfo->condeferred = *(PQgetvalue(res, j, i_condeferred)) == 't';
|
||||
constrinfo->conwithoutoverlaps = *(PQgetvalue(res, j, i_conwithoutoverlaps)) == 't';
|
||||
constrinfo->conperiod = *(PQgetvalue(res, j, i_conperiod)) == 't';
|
||||
constrinfo->conislocal = true;
|
||||
constrinfo->separate = true;
|
||||
|
||||
@ -17158,7 +17158,7 @@ dumpConstraint(Archive *fout, const ConstraintInfo *coninfo)
|
||||
(k == 0) ? "" : ", ",
|
||||
fmtId(attname));
|
||||
}
|
||||
if (coninfo->conwithoutoverlaps)
|
||||
if (coninfo->conperiod)
|
||||
appendPQExpBufferStr(q, " WITHOUT OVERLAPS");
|
||||
|
||||
if (indxinfo->indnkeyattrs < indxinfo->indnattrs)
|
||||
|
@ -479,8 +479,7 @@ typedef struct _constraintInfo
|
||||
DumpId conindex; /* identifies associated index if any */
|
||||
bool condeferrable; /* true if constraint is DEFERRABLE */
|
||||
bool condeferred; /* true if constraint is INITIALLY DEFERRED */
|
||||
bool conwithoutoverlaps; /* true if the constraint is WITHOUT
|
||||
* OVERLAPS */
|
||||
bool conperiod; /* true if the constraint is WITHOUT OVERLAPS */
|
||||
bool conislocal; /* true if constraint has local definition */
|
||||
bool separate; /* true if must dump as separate item */
|
||||
} ConstraintInfo;
|
||||
|
@ -2380,9 +2380,9 @@ describeOneTableDetails(const char *schemaname,
|
||||
appendPQExpBufferStr(&buf, ", false AS indisreplident");
|
||||
appendPQExpBufferStr(&buf, ", c2.reltablespace");
|
||||
if (pset.sversion >= 170000)
|
||||
appendPQExpBufferStr(&buf, ", con.conwithoutoverlaps");
|
||||
appendPQExpBufferStr(&buf, ", con.conperiod");
|
||||
else
|
||||
appendPQExpBufferStr(&buf, ", false AS conwithoutoverlaps");
|
||||
appendPQExpBufferStr(&buf, ", false AS conperiod");
|
||||
appendPQExpBuffer(&buf,
|
||||
"\nFROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n"
|
||||
" LEFT JOIN pg_catalog.pg_constraint con ON (conrelid = i.indrelid AND conindid = i.indexrelid AND contype IN ('p','u','x'))\n"
|
||||
|
@ -57,6 +57,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202403042
|
||||
#define CATALOG_VERSION_NO 202403051
|
||||
|
||||
#endif
|
||||
|
@ -111,7 +111,7 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
|
||||
* For primary keys and unique constraints, signifies the last column uses
|
||||
* overlaps instead of equals.
|
||||
*/
|
||||
bool conwithoutoverlaps;
|
||||
bool conperiod;
|
||||
|
||||
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
||||
|
||||
@ -245,7 +245,7 @@ extern Oid CreateConstraintEntry(const char *constraintName,
|
||||
bool conIsLocal,
|
||||
int conInhCount,
|
||||
bool conNoInherit,
|
||||
bool conWithoutOverlaps,
|
||||
bool conPeriod,
|
||||
bool is_internal);
|
||||
|
||||
extern bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,
|
||||
|
Loading…
x
Reference in New Issue
Block a user