Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Rename pg_constraint.conwithoutoverlaps to conperiod
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 5 Mar 2024 10:15:06 +0000 (11:15 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 5 Mar 2024 10:24:17 +0000 (11:24 +0100)
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

13 files changed:
doc/src/sgml/catalogs.sgml
src/backend/catalog/heap.c
src/backend/catalog/pg_constraint.c
src/backend/commands/tablecmds.c
src/backend/commands/trigger.c
src/backend/commands/typecmds.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/cache/relcache.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/psql/describe.c
src/include/catalog/catversion.h
src/include/catalog/pg_constraint.h

index 880f717b103577b86c21b1a9916e3f6624cfe942..0ae97d1adaa797de61b459caf17317d19848c0dc 100644 (file)
@@ -2711,7 +2711,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</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>
index 348943e36ccdf475b93c541bb1480f2c84577864..5e773740f4dfed04d1b5695b7b486736f0006e11 100644 (file)
@@ -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;
 }
index 6a1fc4649ea8e352ad004594d9bdbaba9a9574eb..5ea9df219c10bdf2a714cf4f242c46b2cce607bc 100644 (file)
@@ -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);
index 764478c950ca23de50434b4363de644e5130fd05..c61f9305c2ed0208f6a200a4270baa76dd6f33a9 100644 (file)
@@ -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 */
index 3d35b64a57d4c7f0dd0cc7f3f853cdb8aac4b429..35eb7180f7eb9d2860d9287d33eb5e889b0d9d93 100644 (file)
@@ -834,7 +834,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
                                              true, /* islocal */
                                              0,    /* inhcount */
                                              true, /* noinherit */
-                                             false,    /* conwithoutoverlaps */
+                                             false,    /* conperiod */
                                              isInternal);  /* is_internal */
    }
 
index d3b6c1089e703175256ae105f99a6816f7fbbbee..f4cdec3bf2f086ee99f19467be95567cd7e1724e 100644 (file)
@@ -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);
index 75525338320a22eadd0053f30078f1f6df86a58c..2a1ee69970158fde450b4c129ffbc8bc2e59007f 100644 (file)
@@ -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, ')');
index 8cb88454c1db1b4fd0ecdefc1328fe9bd5ba0cf4..4d339ee795031e813dc11f213ed2b297b9a4985b 100644 (file)
@@ -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;
 
index 2225a12718beb6d32b0ee034b7e424b750b36f3b..10cbf02bebdd6f6232095d32c4c7c3f9037ea389 100644 (file)
@@ -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)
index 77db42e354b198068514f6161cbec1123919a89d..9bc93520b4536c83f530eeb5dbd211623750021e 100644 (file)
@@ -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;
index b6a4eb1d56546aa178e9c5781d75a2a0c6a87e29..c05befbb6f2430f5ba016cb4a358a729447c9a9c 100644 (file)
@@ -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"
index fc48f871045eaa28ff37dd06b9a2e3a8b266a20f..61790e89ba7005e4e9f6334e07983046ede86eb2 100644 (file)
@@ -57,6 +57,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202403042
+#define CATALOG_VERSION_NO 202403051
 
 #endif
index 01e6bc21cd1fb8168487f4c4b4b8a4b8ddd170fa..a33b4f17ea8bec38a73e2945e03a6bf1603b353d 100644 (file)
@@ -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,