Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e439c6f

Browse files
committed
Remove some useless code
In commit 8b08f7d I added member relationId to IndexStmt struct. I'm now not sure why; DefineIndex doesn't need it, since the relation OID is passed as a separate argument anyway. Remove it. Also remove a redundant assignment to the relationId argument (it wasn't redundant when added by commit e093dcd, but should have been removed in commit 5f17304), and use relationId instead of stmt->relation when locking the relation in the second phase of CREATE INDEX CONCURRENTLY, which is not only confusing but it means we resolve the name twice for no reason.
1 parent b2edbbd commit e439c6f

File tree

7 files changed

+2
-10
lines changed

7 files changed

+2
-10
lines changed

src/backend/commands/indexcmds.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ DefineIndex(Oid relationId,
415415
lockmode = stmt->concurrent ? ShareUpdateExclusiveLock : ShareLock;
416416
rel = heap_open(relationId, lockmode);
417417

418-
relationId = RelationGetRelid(rel);
419418
namespaceId = RelationGetNamespace(rel);
420419

421420
/* Ensure that it makes sense to index this kind of relation */
@@ -1032,7 +1031,7 @@ DefineIndex(Oid relationId,
10321031
elog(ERROR, "cannot convert whole-row table reference");
10331032

10341033
childStmt->idxname = NULL;
1035-
childStmt->relationId = childRelid;
1034+
childStmt->relation = NULL;
10361035
DefineIndex(childRelid, childStmt,
10371036
InvalidOid, /* no predefined OID */
10381037
indexRelationId, /* this is our child */
@@ -1154,7 +1153,7 @@ DefineIndex(Oid relationId,
11541153
*/
11551154

11561155
/* Open and lock the parent heap relation */
1157-
rel = heap_openrv(stmt->relation, ShareUpdateExclusiveLock);
1156+
rel = heap_open(relationId, ShareUpdateExclusiveLock);
11581157

11591158
/* And the target index relation */
11601159
indexRelation = index_open(indexRelationId, RowExclusiveLock);

src/backend/nodes/copyfuncs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3442,7 +3442,6 @@ _copyIndexStmt(const IndexStmt *from)
34423442

34433443
COPY_STRING_FIELD(idxname);
34443444
COPY_NODE_FIELD(relation);
3445-
COPY_SCALAR_FIELD(relationId);
34463445
COPY_STRING_FIELD(accessMethod);
34473446
COPY_STRING_FIELD(tableSpace);
34483447
COPY_NODE_FIELD(indexParams);

src/backend/nodes/equalfuncs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,6 @@ _equalIndexStmt(const IndexStmt *a, const IndexStmt *b)
13251325
{
13261326
COMPARE_STRING_FIELD(idxname);
13271327
COMPARE_NODE_FIELD(relation);
1328-
COMPARE_SCALAR_FIELD(relationId);
13291328
COMPARE_STRING_FIELD(accessMethod);
13301329
COMPARE_STRING_FIELD(tableSpace);
13311330
COMPARE_NODE_FIELD(indexParams);

src/backend/nodes/outfuncs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,6 @@ _outIndexStmt(StringInfo str, const IndexStmt *node)
26112611

26122612
WRITE_STRING_FIELD(idxname);
26132613
WRITE_NODE_FIELD(relation);
2614-
WRITE_OID_FIELD(relationId);
26152614
WRITE_STRING_FIELD(accessMethod);
26162615
WRITE_STRING_FIELD(tableSpace);
26172616
WRITE_NODE_FIELD(indexParams);

src/backend/parser/gram.y

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7338,7 +7338,6 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name
73387338
n->concurrent = $4;
73397339
n->idxname = $5;
73407340
n->relation = $7;
7341-
n->relationId = InvalidOid;
73427341
n->accessMethod = $8;
73437342
n->indexParams = $10;
73447343
n->indexIncludingParams = $12;
@@ -7366,7 +7365,6 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name
73667365
n->concurrent = $4;
73677366
n->idxname = $8;
73687367
n->relation = $10;
7369-
n->relationId = InvalidOid;
73707368
n->accessMethod = $11;
73717369
n->indexParams = $13;
73727370
n->indexIncludingParams = $15;

src/backend/parser/parse_utilcmd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,6 @@ generateClonedIndexStmt(RangeVar *heapRel, Oid heapRelid, Relation source_idx,
13131313
/* Begin building the IndexStmt */
13141314
index = makeNode(IndexStmt);
13151315
index->relation = heapRel;
1316-
index->relationId = heapRelid;
13171316
index->accessMethod = pstrdup(NameStr(amrec->amname));
13181317
if (OidIsValid(idxrelrec->reltablespace))
13191318
index->tableSpace = get_tablespace_name(idxrelrec->reltablespace);

src/include/nodes/parsenodes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2726,7 +2726,6 @@ typedef struct IndexStmt
27262726
NodeTag type;
27272727
char *idxname; /* name of new index, or NULL for default */
27282728
RangeVar *relation; /* relation to build index on */
2729-
Oid relationId; /* OID of relation to build index on */
27302729
char *accessMethod; /* name of access method (eg. btree) */
27312730
char *tableSpace; /* tablespace, or NULL for default */
27322731
List *indexParams; /* columns to index: a list of IndexElem */

0 commit comments

Comments
 (0)