Replace enum InhOption with simple boolean.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 23 Dec 2016 18:35:11 +0000 (13:35 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 23 Dec 2016 18:35:18 +0000 (13:35 -0500)
Now that it has only INH_NO and INH_YES values, it's just weird that
it's not a plain bool, so make it that way.

Also rename RangeVar.inhOpt to "inh", to be like RangeTblEntry.inh.
My recollection is that we gave it a different name specifically because
it had a different representation than the derived bool value, but it
no longer does.  And this is a good forcing function to be sure we
catch any places that are affected by the change.

Bump catversion because of possible effect on stored RangeVar nodes.
I'm not exactly convinced that we ever store RangeVar on disk, but
we have a readfuncs function for it, so be cautious.  (If we do do so,
then commit e13486eba was in error not to bump catversion.)

Follow-on to commit e13486eba.

Discussion: http://postgr.es/m/CA+TgmoYe+EG7LdYX6pkcNxr4ygkP4+A=jm9o-CPXyOvRiCNwaQ@mail.gmail.com

12 files changed:
src/backend/commands/lockcmds.c
src/backend/commands/tablecmds.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/makefuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/backend/parser/parse_clause.c
src/include/catalog/catversion.h
src/include/nodes/primnodes.h

index ba1414ba645d94f83ac3bb116468a01d42792047..5cf535b7a6066cf6455f2ac7f14b439c154711ca 100644 (file)
@@ -54,7 +54,7 @@ LockTableCommand(LockStmt *lockstmt)
    foreach(p, lockstmt->relations)
    {
        RangeVar   *rv = (RangeVar *) lfirst(p);
-       bool        recurse = (rv->inhOpt == INH_YES);
+       bool        recurse = rv->inh;
        Oid         reloid;
 
        reloid = RangeVarGetRelidExtended(rv, lockstmt->mode, false,
index 0e7601fd94221bb6516291e218136631a32bc430..a7ac85e7ab184d8951eb6d284efc25e33f99a296 100644 (file)
@@ -1184,7 +1184,7 @@ ExecuteTruncate(TruncateStmt *stmt)
    {
        RangeVar   *rv = lfirst(cell);
        Relation    rel;
-       bool        recurse = (rv->inhOpt == INH_YES);
+       bool        recurse = rv->inh;
        Oid         myrelid;
 
        rel = heap_openrv(rv, AccessExclusiveLock);
@@ -2655,7 +2655,7 @@ renameatt(RenameStmt *stmt)
        renameatt_internal(relid,
                           stmt->subname,       /* old att name */
                           stmt->newname,       /* new att name */
-                          (stmt->relation->inhOpt == INH_YES), /* recursive? */
+                          stmt->relation->inh, /* recursive? */
                           false,       /* recursing? */
                           0,   /* expected inhcount */
                           stmt->behavior);
@@ -2807,7 +2807,8 @@ RenameConstraint(RenameStmt *stmt)
        rename_constraint_internal(relid, typid,
                                   stmt->subname,
                                   stmt->newname,
-        (stmt->relation && stmt->relation->inhOpt == INH_YES), /* recursive? */
+                                  (stmt->relation &&
+                                   stmt->relation->inh),       /* recursive? */
                                   false,       /* recursing? */
                                   0 /* expected inhcount */ );
 
@@ -3049,9 +3050,7 @@ AlterTable(Oid relid, LOCKMODE lockmode, AlterTableStmt *stmt)
 
    CheckTableNotInUse(rel, "ALTER TABLE");
 
-   ATController(stmt,
-                rel, stmt->cmds, (stmt->relation->inhOpt == INH_YES),
-                lockmode);
+   ATController(stmt, rel, stmt->cmds, stmt->relation->inh, lockmode);
 }
 
 /*
index d9732259ae826b6e07aff2d207fc765c2cdeefaf..6955298577a23a7f8b9314f1a9470b92aefd5812 100644 (file)
@@ -1112,7 +1112,7 @@ _copyRangeVar(const RangeVar *from)
    COPY_STRING_FIELD(catalogname);
    COPY_STRING_FIELD(schemaname);
    COPY_STRING_FIELD(relname);
-   COPY_SCALAR_FIELD(inhOpt);
+   COPY_SCALAR_FIELD(inh);
    COPY_SCALAR_FIELD(relpersistence);
    COPY_NODE_FIELD(alias);
    COPY_LOCATION_FIELD(location);
@@ -4192,7 +4192,6 @@ _copyAlterPolicyStmt(const AlterPolicyStmt *from)
 static PartitionSpec *
 _copyPartitionSpec(const PartitionSpec *from)
 {
-
    PartitionSpec *newnode = makeNode(PartitionSpec);
 
    COPY_STRING_FIELD(strategy);
index edc1797c424dff113e6e6d90cfeac0d1124abf6e..548a2aa876c94acca8fe34ffb8cad173b34d838e 100644 (file)
@@ -108,7 +108,7 @@ _equalRangeVar(const RangeVar *a, const RangeVar *b)
    COMPARE_STRING_FIELD(catalogname);
    COMPARE_STRING_FIELD(schemaname);
    COMPARE_STRING_FIELD(relname);
-   COMPARE_SCALAR_FIELD(inhOpt);
+   COMPARE_SCALAR_FIELD(inh);
    COMPARE_SCALAR_FIELD(relpersistence);
    COMPARE_NODE_FIELD(alias);
    COMPARE_LOCATION_FIELD(location);
index b64f7c6a8528f86f0fb81972388397d80e9d722f..c97532b3481e4aa0b2410e93ec3d2dfba783f57a 100644 (file)
@@ -423,7 +423,7 @@ makeRangeVar(char *schemaname, char *relname, int location)
    r->catalogname = NULL;
    r->schemaname = schemaname;
    r->relname = relname;
-   r->inhOpt = INH_YES;
+   r->inh = true;
    r->relpersistence = RELPERSISTENCE_PERMANENT;
    r->alias = NULL;
    r->location = location;
index 7258c0357dbb06028f0758f37faf532c7f5163dc..9fe98739c12715e00170f58c99c4d4fd27376783 100644 (file)
@@ -939,7 +939,7 @@ _outRangeVar(StringInfo str, const RangeVar *node)
     */
    WRITE_STRING_FIELD(schemaname);
    WRITE_STRING_FIELD(relname);
-   WRITE_ENUM_FIELD(inhOpt, InhOption);
+   WRITE_BOOL_FIELD(inh);
    WRITE_CHAR_FIELD(relpersistence);
    WRITE_NODE_FIELD(alias);
    WRITE_LOCATION_FIELD(location);
index d608530c6e211cbd599926425489b36365f93146..63f633634c6053b96edf922cd627c5ad946456b7 100644 (file)
@@ -449,7 +449,7 @@ _readRangeVar(void)
 
    READ_STRING_FIELD(schemaname);
    READ_STRING_FIELD(relname);
-   READ_ENUM_FIELD(inhOpt, InhOption);
+   READ_BOOL_FIELD(inh);
    READ_CHAR_FIELD(relpersistence);
    READ_NODE_FIELD(alias);
    READ_LOCATION_FIELD(location);
index 601e22abfa3e49a3fa9bc56e4b39e1e44e750874..a558083f43739ae4155131efb4931415e0d904de 100644 (file)
@@ -380,7 +380,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
 
    /* set up range table with just the result rel */
    qry->resultRelation = setTargetTable(pstate, stmt->relation,
-                                 (stmt->relation->inhOpt == INH_YES),
+                                        stmt->relation->inh,
                                         true,
                                         ACL_DELETE);
 
@@ -2177,7 +2177,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
    }
 
    qry->resultRelation = setTargetTable(pstate, stmt->relation,
-                                 (stmt->relation->inhOpt == INH_YES),
+                                        stmt->relation->inh,
                                         true,
                                         ACL_UPDATE);
 
index 931bc9aca68bb94fe0aede51af0569b63ca8fb29..834a00971a93fccd3f3516196a3a9f6e3425308b 100644 (file)
@@ -11250,28 +11250,28 @@ relation_expr:
                {
                    /* inheritance query, implicitly */
                    $$ = $1;
-                   $$->inhOpt = INH_YES;
+                   $$->inh = true;
                    $$->alias = NULL;
                }
            | qualified_name '*'
                {
-                   /* inheritance query */
+                   /* inheritance query, explicitly */
                    $$ = $1;
-                   $$->inhOpt = INH_YES;
+                   $$->inh = true;
                    $$->alias = NULL;
                }
            | ONLY qualified_name
                {
                    /* no inheritance */
                    $$ = $2;
-                   $$->inhOpt = INH_NO;
+                   $$->inh = false;
                    $$->alias = NULL;
                }
            | ONLY '(' qualified_name ')'
                {
                    /* no inheritance, SQL99-style syntax */
                    $$ = $3;
-                   $$->inhOpt = INH_NO;
+                   $$->inh = false;
                    $$->alias = NULL;
                }
        ;
index a96b3f92809f95dcdc5a5652026940a9de09bc0d..f7bb09701e6b30d0250f80d81e35d30f0204fcb9 100644 (file)
@@ -412,8 +412,7 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
    RangeTblEntry *rte;
 
    /* We need only build a range table entry */
-   rte = addRangeTableEntry(pstate, r, r->alias,
-                            (r->inhOpt == INH_YES), true);
+   rte = addRangeTableEntry(pstate, r, r->alias, r->inh, true);
 
    return rte;
 }
index 7d15189ead175491c8bd3d9d3e1bc5e198c78be4..45596abe7662e0a3da044d9b6676d42c2c2d795a 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 201612202
+#define CATALOG_VERSION_NO 201612231
 
 #endif
index d11f1120b0ac41982b6c0fd391a6e63bdba713e4..717d8220d292c1379213bbd65b44720bca8e0ab8 100644 (file)
@@ -42,12 +42,6 @@ typedef struct Alias
    List       *colnames;       /* optional list of column aliases */
 } Alias;
 
-typedef enum InhOption
-{
-   INH_NO,                     /* Do NOT scan child tables */
-   INH_YES                     /* DO scan child tables */
-} InhOption;
-
 /* What to do at commit time for temporary relations */
 typedef enum OnCommitAction
 {
@@ -61,7 +55,7 @@ typedef enum OnCommitAction
  * RangeVar - range variable, used in FROM clauses
  *
  * Also used to represent table names in utility statements; there, the alias
- * field is not used, and inhOpt shows whether to apply the operation
+ * field is not used, and inh tells whether to apply the operation
  * recursively to child tables.  In some contexts it is also useful to carry
  * a TEMP table indication here.
  */
@@ -71,7 +65,7 @@ typedef struct RangeVar
    char       *catalogname;    /* the catalog (database) name, or NULL */
    char       *schemaname;     /* the schema name, or NULL */
    char       *relname;        /* the relation/sequence name */
-   InhOption   inhOpt;         /* expand rel by inheritance? recursively act
+   bool        inh;            /* expand rel by inheritance? recursively act
                                 * on children? */
    char        relpersistence; /* see RELPERSISTENCE_* in pg_class.h */
    Alias      *alias;          /* table alias & optional column aliases */