8000 Replace enum InhOption with simple boolean. · postgrespro/postgres@fe591f8 · GitHub
[go: up one dir, main page]

Skip to content
  • Commit fe591f8

    Browse files
    committed
    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 e13486e was in error not to bump catversion.) Follow-on to commit e13486e. Discussion: http://postgr.es/m/CA+TgmoYe+EG7LdYX6pkcNxr4ygkP4+A=jm9o-CPXyOvRiCNwaQ@mail.gmail.com
    1 parent 158df30 commit fe591f8

    File tree

    12 files changed

    +22
    -31
    lines changed

    12 files changed

    +22
    -31
    lines changed

    src/backend/commands/lockcmds.c

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -54,7 +54,7 @@ LockTableCommand(LockStmt *lockstmt)
    5454
    foreach(p, lockstmt->relations)
    5555
    {
    5656
    RangeVar *rv = (RangeVar *) lfirst(p);
    57-
    bool recurse = (rv->inhOpt == INH_YES);
    57+
    bool recurse = rv->inh;
    5858
    Oid reloid;
    5959

    6060
    reloid = RangeVarGetRelidExtended(rv, lockstmt->mode, false,

    src/backend/commands/tablecmds.c

    Lines changed: 5 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1184,7 +1184,7 @@ ExecuteTruncate(TruncateStmt *stmt)
    11841184
    {
    11851185
    RangeVar *rv = lfirst(cell);
    11861186
    Relation rel;
    1187-
    bool recurse = (rv->inhOpt == INH_YES);
    1187+
    bool recurse = rv->inh;
    11881188
    Oid myrelid;
    11891189

    11901190
    rel = heap_openrv(rv, AccessExclusiveLock);
    @@ -2655,7 +2655,7 @@ renameatt(RenameStmt *stmt)
    26552655
    renameatt_internal(relid,
    26562656
    stmt->subname, /* old att name */
    26572657
    stmt->newname, /* new att name */
    2658-
    (stmt->relation->inhOpt == INH_YES), /* recursive? */
    2658+
    stmt->relation->inh, /* recursive? */
    26592659
    false, /* recursing? */
    26602660
    0, /* expected inhcount */
    26612661
    stmt->behavior);
    @@ -2807,7 +2807,8 @@ RenameConstraint(RenameStmt *stmt)
    28072807
    rename_constraint_internal(relid, typid,
    28082808
    stmt->subname,
    28092809
    stmt->newname,
    2810-
    (stmt->relation && stmt->relation->inhOpt == INH_YES), /* recursive? */
    2810+
    (stmt->relation &&
    2811+
    stmt->relation->inh), /* recursive? */
    28112812
    false, /* recursing? */
    28122813
    0 /* expected inhcount */ );
    28132814

    @@ -3049,9 +3050,7 @@ AlterTable(Oid relid, LOCKMODE lockmode, AlterTableStmt *stmt)
    30493050

    30503051
    CheckTableNotInUse(rel, "ALTER TABLE");
    30513052

    3052-
    ATController(stmt,
    3053-
    rel, stmt->cmds, (stmt->relation->inhOpt == INH_YES),
    3054-
    lockmode);
    3053+
    ATController(stmt, rel, stmt->cmds, stmt->relation->inh, lockmode);
    30553054
    }
    30563055

    30573056
    /*

    src/backend/nodes/copyfuncs.c

    Lines changed: 1 addition & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1112,7 +1112,7 @@ _copyRangeVar(const RangeVar *from)
    11121112
    COPY_STRING_FIELD(catalogname);
    11131113
    COPY_STRING_FIELD(schemaname);
    11141114
    COPY_STRING_FIELD(relname);
    1115-
    COPY_SCALAR_FIELD(inhOpt);
    1115+
    COPY_SCALAR_FIELD(inh);
    11161116
    COPY_SCALAR_FIELD(relpersistence);
    11171117
    COPY_NODE_FIELD(alias);
    11181118
    COPY_LOCATION_FIELD(location);
    @@ -4192,7 +4192,6 @@ _copyAlterPolicyStmt(const AlterPolicyStmt *from)
    41924192
    static PartitionSpec *
    41934193
    _copyPartitionSpec(const PartitionSpec *from)
    41944194
    {
    4195-
    41964195
    PartitionSpec *newnode = makeNode(PartitionSpec);
    41974196

    41984197
    COPY_STRING_FIELD(strategy);

    src/backend/nodes/equalfuncs.c

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -108,7 +108,7 @@ _equalRangeVar(const RangeVar *a, const RangeVar *b)
    108108
    COMPARE_STRING_FIELD(catalogname);
    109109
    COMPARE_STRING_FIELD(schemaname);
    110110
    COMPARE_STRING_FIELD(relname);
    111-
    COMPARE_SCALAR_FIELD(inhOpt);
    111+
    COMPARE_SCALAR_FIELD(inh);
    112112
    COMPARE_SCALAR_FIELD(relpersistence);
    113113
    COMPARE_NODE_FIELD(alias);
    114114
    COMPARE_LOCATION_FIELD(location);

    src/backend/nodes/makefuncs.c

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -423,7 +423,7 @@ makeRangeVar(char *schemaname, char *relname, int location)
    423423
    r->catalogname = NULL;
    424424
    r->schemaname = schemaname;
    425425
    r->relname = relname;
    426-
    r->inhOpt = INH_YES;
    426+
    r->inh = true;
    427427
    r->relpersistence = RELPERSISTENCE_PERMANENT;
    428428
    r->alias = NULL;
    429429
    r->location = location;

    src/backend/nodes/outfuncs.c

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -939,7 +939,7 @@ _outRangeVar(StringInfo str, const RangeVar *node)
    939939
    */
    940940
    WRITE_STRING_FIELD(schemaname);
    941941
    WRITE_STRING_FIELD(relname);
    942-
    WRITE_ENUM_FIELD(inhOpt, InhOption);
    942+
    WRITE_BOOL_FIELD(inh);
    943943
    WRITE_CHAR_FIELD(relpersistence);
    944944
    WRITE_NODE_FIELD(alias);
    945945
    WRITE_LOCATION_FIELD(location);

    src/backend/nodes/readfuncs.c

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -449,7 +449,7 @@ _readRangeVar(void)
    449449

    450450
    READ_STRING_FIELD(schemaname);
    451451
    READ_STRING_FIELD(relname);
    452-
    READ_ENUM_FIELD(inhOpt, InhOption);
    452+
    READ_BOOL_FIELD(inh);
    453453
    READ_CHAR_FIELD(relpersistence);
    454454
    READ_NODE_FIELD(alias);
    455455
    READ_LOCATION_FIELD(location);

    src/backend/parser/analyze.c

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -380,7 +380,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
    380380

    381381
    /* set up range table with just the result rel */
    382382
    qry->resultRelation = setTargetTable(pstate, stmt->relation,
    383-
    (stmt->relation->inhOpt == INH_YES),
    383+
    stmt->relation->inh,
    384384
    true,
    385385
    ACL_DELETE);
    386386

    @@ -2177,7 +2177,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
    21772177
    }
    21782178

    21792179
    qry->resultRelation = setTargetTable(pstate, stmt->relation,
    2180-
    (stmt->relation->inhOpt == INH_YES),
    2180+
    stmt->relation->inh,
    21812181
    true,
    21822182
    ACL_UPDATE);
    21832183

    src/backend/parser/gram.y

    Lines changed: 5 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -11250,28 +11250,28 @@ relation_expr:
    1125011250
    {
    1125111251
    /* inheritance query, implicitly */
    1125211252
    $$ = $1;
    11253-
    $$->inhOpt = INH_YES;
    11253+
    $$->inh = true;
    1125411254
    $$->alias = NULL;
    1125511255
    }
    1125611256
    | qualified_name '*'
    1125711257
    {
    11258-
    /* inheritance query */
    11258+
    /* inheritance query, explicitly */
    1125911259
    $$ = $1;
    11260-
    $$->inhOpt = INH_YES;
    11260+
    $$->inh = true;
    1126111261
    $$->alias = NULL;
    1126211262
    }
    1126311263
    | ONLY qualified_name
    1126411264
    {
    1126511265
    /* no inheritance */
    1126611266
    $$ = $2;
    11267-
    $$->inhOpt = INH_NO;
    11267+
    $$->inh = false;
    1126811268
    $$->alias = NULL;
    1126911269
    }
    1127011270
    | ONLY '(' qualified_name ')'
    1127111271
    {
    1127211272
    /* no inheritance, SQL99-style syntax */
    1127311273
    $$ = $3;
    11274-
    $$->inhOpt = INH_NO;
    11274+
    $$->inh = false;
    1127511275
    $$->alias = NULL;
    1127611276
    }
    1127711277
    ;

    src/backend/parser/parse_clause.c

    Lines changed: 1 addition & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -412,8 +412,7 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
    412412
    RangeTblEntry *rte;
    413413

    414414
    /* We need only build a range table entry */
    415-
    rte = addRangeTableEntry(pstate, r, r->alias,
    416-
    (r->inhOpt == INH_YES), true);
    415+
    rte = addRangeTableEntry(pstate, r, r->alias, r->inh, true);
    417416

    418417
    return rte;
    419418
    }

    0 commit comments

    Comments
     (0)
    0