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
Discussion: https://www.postgresql.org/message-id/flat/CA+renyUApHgSZF9-nd-a0+OPGharLQLO=mDHcY4_qQ0+noCUVg@mail.gmail.com
|
- conwithoutoverlaps bool
+ conperiod bool
This constraint is defined with WITHOUT OVERLAPS
is_local, /* conislocal */
inhcount, /* coninhcount */
is_no_inherit, /* connoinherit */
- false, /* conwithoutoverlaps */
+ false, /* conperiod */
is_internal); /* internally constructed? */
pfree(ccbin);
is_local,
inhcount,
is_no_inherit,
- false, /* conwithoutoverlaps */
+ false, /* conperiod */
false);
return constrOid;
}
bool conIsLocal,
int conInhCount,
bool conNoInherit,
- bool conWithoutOverlaps,
+ bool conPeriod,
bool is_internal)
{
Relation conDesc;
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);
conislocal, /* islocal */
coninhcount, /* inhcount */
connoinherit, /* conNoInherit */
- false, /* conWithoutOverlaps */
+ false, /* conPeriod */
false); /* is_internal */
ObjectAddressSet(address, ConstraintRelationId, constrOid);
false,
1,
false,
- false, /* conWithoutOverlaps */
+ false, /* conPeriod */
false);
/*
false, /* islocal */
1, /* inhcount */
false, /* conNoInherit */
- false, /* conWithoutOverlaps */
+ false, /* conPeriod */
true);
/* Set up partition dependencies for the new constraint */
true, /* islocal */
0, /* inhcount */
true, /* noinherit */
- false, /* conwithoutoverlaps */
+ false, /* conperiod */
isInternal); /* is_internal */
}
true, /* is local */
0, /* inhcount */
false, /* connoinherit */
- false, /* conwithoutoverlaps */
+ false, /* conperiod */
false); /* is_internal */
if (constrAddr)
ObjectAddressSet(*constrAddr, ConstraintRelationId, ccoid);
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, ')');
/* 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;
i_conname,
i_condeferrable,
i_condeferred,
- i_conwithoutoverlaps,
+ i_conperiod,
i_contableoid,
i_conoid,
i_condef,
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
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");
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;
(k == 0) ? "" : ", ",
fmtId(attname));
}
- if (coninfo->conwithoutoverlaps)
+ if (coninfo->conperiod)
appendPQExpBufferStr(q, " WITHOUT OVERLAPS");
if (indxinfo->indnkeyattrs < indxinfo->indnattrs)
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;
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"
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202403042
+#define CATALOG_VERSION_NO 202403051
#endif
* 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 */
bool conIsLocal,
int conInhCount,
bool conNoInherit,
- bool conWithoutOverlaps,
+ bool conPeriod,
bool is_internal);
extern bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId,