1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-25 21:42:33 +03:00

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 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
This commit is contained in:
Tom Lane 2016-12-23 13:35:11 -05:00
parent 158df30359
commit fe591f8bf6
12 changed files with 22 additions and 31 deletions

View File

@ -54,7 +54,7 @@ LockTableCommand(LockStmt *lockstmt)
foreach(p, lockstmt->relations) foreach(p, lockstmt->relations)
{ {
RangeVar *rv = (RangeVar *) lfirst(p); RangeVar *rv = (RangeVar *) lfirst(p);
bool recurse = (rv->inhOpt == INH_YES); bool recurse = rv->inh;
Oid reloid; Oid reloid;
reloid = RangeVarGetRelidExtended(rv, lockstmt->mode, false, reloid = RangeVarGetRelidExtended(rv, lockstmt->mode, false,

View File

@ -1184,7 +1184,7 @@ ExecuteTruncate(TruncateStmt *stmt)
{ {
RangeVar *rv = lfirst(cell); RangeVar *rv = lfirst(cell);
Relation rel; Relation rel;
bool recurse = (rv->inhOpt == INH_YES); bool recurse = rv->inh;
Oid myrelid; Oid myrelid;
rel = heap_openrv(rv, AccessExclusiveLock); rel = heap_openrv(rv, AccessExclusiveLock);
@ -2655,7 +2655,7 @@ renameatt(RenameStmt *stmt)
renameatt_internal(relid, renameatt_internal(relid,
stmt->subname, /* old att name */ stmt->subname, /* old att name */
stmt->newname, /* new att name */ stmt->newname, /* new att name */
(stmt->relation->inhOpt == INH_YES), /* recursive? */ stmt->relation->inh, /* recursive? */
false, /* recursing? */ false, /* recursing? */
0, /* expected inhcount */ 0, /* expected inhcount */
stmt->behavior); stmt->behavior);
@ -2807,7 +2807,8 @@ RenameConstraint(RenameStmt *stmt)
rename_constraint_internal(relid, typid, rename_constraint_internal(relid, typid,
stmt->subname, stmt->subname,
stmt->newname, stmt->newname,
(stmt->relation && stmt->relation->inhOpt == INH_YES), /* recursive? */ (stmt->relation &&
stmt->relation->inh), /* recursive? */
false, /* recursing? */ false, /* recursing? */
0 /* expected inhcount */ ); 0 /* expected inhcount */ );
@ -3049,9 +3050,7 @@ AlterTable(Oid relid, LOCKMODE lockmode, AlterTableStmt *stmt)
CheckTableNotInUse(rel, "ALTER TABLE"); CheckTableNotInUse(rel, "ALTER TABLE");
ATController(stmt, ATController(stmt, rel, stmt->cmds, stmt->relation->inh, lockmode);
rel, stmt->cmds, (stmt->relation->inhOpt == INH_YES),
lockmode);
} }
/* /*

View File

@ -1112,7 +1112,7 @@ _copyRangeVar(const RangeVar *from)
COPY_STRING_FIELD(catalogname); COPY_STRING_FIELD(catalogname);
COPY_STRING_FIELD(schemaname); COPY_STRING_FIELD(schemaname);
COPY_STRING_FIELD(relname); COPY_STRING_FIELD(relname);
COPY_SCALAR_FIELD(inhOpt); COPY_SCALAR_FIELD(inh);
COPY_SCALAR_FIELD(relpersistence); COPY_SCALAR_FIELD(relpersistence);
COPY_NODE_FIELD(alias); COPY_NODE_FIELD(alias);
COPY_LOCATION_FIELD(location); COPY_LOCATION_FIELD(location);
@ -4192,7 +4192,6 @@ _copyAlterPolicyStmt(const AlterPolicyStmt *from)
static PartitionSpec * static PartitionSpec *
_copyPartitionSpec(const PartitionSpec *from) _copyPartitionSpec(const PartitionSpec *from)
{ {
PartitionSpec *newnode = makeNode(PartitionSpec); PartitionSpec *newnode = makeNode(PartitionSpec);
COPY_STRING_FIELD(strategy); COPY_STRING_FIELD(strategy);

View File

@ -108,7 +108,7 @@ _equalRangeVar(const RangeVar *a, const RangeVar *b)
COMPARE_STRING_FIELD(catalogname); COMPARE_STRING_FIELD(catalogname);
COMPARE_STRING_FIELD(schemaname); COMPARE_STRING_FIELD(schemaname);
COMPARE_STRING_FIELD(relname); COMPARE_STRING_FIELD(relname);
COMPARE_SCALAR_FIELD(inhOpt); COMPARE_SCALAR_FIELD(inh);
COMPARE_SCALAR_FIELD(relpersistence); COMPARE_SCALAR_FIELD(relpersistence);
COMPARE_NODE_FIELD(alias); COMPARE_NODE_FIELD(alias);
COMPARE_LOCATION_FIELD(location); COMPARE_LOCATION_FIELD(location);

View File

@ -423,7 +423,7 @@ makeRangeVar(char *schemaname, char *relname, int location)
r->catalogname = NULL; r->catalogname = NULL;
r->schemaname = schemaname; r->schemaname = schemaname;
r->relname = relname; r->relname = relname;
r->inhOpt = INH_YES; r->inh = true;
r->relpersistence = RELPERSISTENCE_PERMANENT; r->relpersistence = RELPERSISTENCE_PERMANENT;
r->alias = NULL; r->alias = NULL;
r->location = location; r->location = location;

View File

@ -939,7 +939,7 @@ _outRangeVar(StringInfo str, const RangeVar *node)
*/ */
WRITE_STRING_FIELD(schemaname); WRITE_STRING_FIELD(schemaname);
WRITE_STRING_FIELD(relname); WRITE_STRING_FIELD(relname);
WRITE_ENUM_FIELD(inhOpt, InhOption); WRITE_BOOL_FIELD(inh);
WRITE_CHAR_FIELD(relpersistence); WRITE_CHAR_FIELD(relpersistence);
WRITE_NODE_FIELD(alias); WRITE_NODE_FIELD(alias);
WRITE_LOCATION_FIELD(location); WRITE_LOCATION_FIELD(location);

View File

@ -449,7 +449,7 @@ _readRangeVar(void)
READ_STRING_FIELD(schemaname); READ_STRING_FIELD(schemaname);
READ_STRING_FIELD(relname); READ_STRING_FIELD(relname);
READ_ENUM_FIELD(inhOpt, InhOption); READ_BOOL_FIELD(inh);
READ_CHAR_FIELD(relpersistence); READ_CHAR_FIELD(relpersistence);
READ_NODE_FIELD(alias); READ_NODE_FIELD(alias);
READ_LOCATION_FIELD(location); READ_LOCATION_FIELD(location);

View File

@ -380,7 +380,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
/* set up range table with just the result rel */ /* set up range table with just the result rel */
qry->resultRelation = setTargetTable(pstate, stmt->relation, qry->resultRelation = setTargetTable(pstate, stmt->relation,
(stmt->relation->inhOpt == INH_YES), stmt->relation->inh,
true, true,
ACL_DELETE); ACL_DELETE);
@ -2177,7 +2177,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
} }
qry->resultRelation = setTargetTable(pstate, stmt->relation, qry->resultRelation = setTargetTable(pstate, stmt->relation,
(stmt->relation->inhOpt == INH_YES), stmt->relation->inh,
true, true,
ACL_UPDATE); ACL_UPDATE);

View File

@ -11250,28 +11250,28 @@ relation_expr:
{ {
/* inheritance query, implicitly */ /* inheritance query, implicitly */
$$ = $1; $$ = $1;
$$->inhOpt = INH_YES; $$->inh = true;
$$->alias = NULL; $$->alias = NULL;
} }
| qualified_name '*' | qualified_name '*'
{ {
/* inheritance query */ /* inheritance query, explicitly */
$$ = $1; $$ = $1;
$$->inhOpt = INH_YES; $$->inh = true;
$$->alias = NULL; $$->alias = NULL;
} }
| ONLY qualified_name | ONLY qualified_name
{ {
/* no inheritance */ /* no inheritance */
$$ = $2; $$ = $2;
$$->inhOpt = INH_NO; $$->inh = false;
$$->alias = NULL; $$->alias = NULL;
} }
| ONLY '(' qualified_name ')' | ONLY '(' qualified_name ')'
{ {
/* no inheritance, SQL99-style syntax */ /* no inheritance, SQL99-style syntax */
$$ = $3; $$ = $3;
$$->inhOpt = INH_NO; $$->inh = false;
$$->alias = NULL; $$->alias = NULL;
} }
; ;

View File

@ -412,8 +412,7 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
RangeTblEntry *rte; RangeTblEntry *rte;
/* We need only build a range table entry */ /* We need only build a range table entry */
rte = addRangeTableEntry(pstate, r, r->alias, rte = addRangeTableEntry(pstate, r, r->alias, r->inh, true);
(r->inhOpt == INH_YES), true);
return rte; return rte;
} }

View File

@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 201612202 #define CATALOG_VERSION_NO 201612231
#endif #endif

View File

@ -42,12 +42,6 @@ typedef struct Alias
List *colnames; /* optional list of column aliases */ List *colnames; /* optional list of column aliases */
} Alias; } 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 */ /* What to do at commit time for temporary relations */
typedef enum OnCommitAction typedef enum OnCommitAction
{ {
@ -61,7 +55,7 @@ typedef enum OnCommitAction
* RangeVar - range variable, used in FROM clauses * RangeVar - range variable, used in FROM clauses
* *
* Also used to represent table names in utility statements; there, the alias * 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 * recursively to child tables. In some contexts it is also useful to carry
* a TEMP table indication here. * a TEMP table indication here.
*/ */
@ -71,7 +65,7 @@ typedef struct RangeVar
char *catalogname; /* the catalog (database) name, or NULL */ char *catalogname; /* the catalog (database) name, or NULL */
char *schemaname; /* the schema name, or NULL */ char *schemaname; /* the schema name, or NULL */
char *relname; /* the relation/sequence name */ char *relname; /* the relation/sequence name */
InhOption inhOpt; /* expand rel by inheritance? recursively act bool inh; /* expand rel by inheritance? recursively act
* on children? */ * on children? */
char relpersistence; /* see RELPERSISTENCE_* in pg_class.h */ char relpersistence; /* see RELPERSISTENCE_* in pg_class.h */
Alias *alias; /* table alias & optional column aliases */ Alias *alias; /* table alias & optional column aliases */