Commit fe591f8b authored by Tom Lane's avatar Tom Lane

Replace enum InhOption with simple boolean.

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 e13486eb was in error not to bump catversion.)

Follow-on to commit e13486eb.

Discussion: http://postgr.es/m/CA+TgmoYe+EG7LdYX6pkcNxr4ygkP4+A=jm9o-CPXyOvRiCNwaQ@mail.gmail.com
parent 158df303
......@@ -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,
......
......@@ -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);
}
/*
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
}
;
......
......@@ -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;
}
......
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201612202
#define CATALOG_VERSION_NO 201612231
#endif
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment