In commit
8b08f7d4820f 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
e093dcdd285, but should have been removed
in commit
5f173040e3), 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.
lockmode = stmt->concurrent ? ShareUpdateExclusiveLock : ShareLock;
rel = heap_open(relationId, lockmode);
- relationId = RelationGetRelid(rel);
namespaceId = RelationGetNamespace(rel);
/* Ensure that it makes sense to index this kind of relation */
elog(ERROR, "cannot convert whole-row table reference");
childStmt->idxname = NULL;
- childStmt->relationId = childRelid;
+ childStmt->relation = NULL;
DefineIndex(childRelid, childStmt,
InvalidOid, /* no predefined OID */
indexRelationId, /* this is our child */
*/
/* Open and lock the parent heap relation */
- rel = heap_openrv(stmt->relation, ShareUpdateExclusiveLock);
+ rel = heap_open(relationId, ShareUpdateExclusiveLock);
/* And the target index relation */
indexRelation = index_open(indexRelationId, RowExclusiveLock);
COPY_STRING_FIELD(idxname);
COPY_NODE_FIELD(relation);
- COPY_SCALAR_FIELD(relationId);
COPY_STRING_FIELD(accessMethod);
COPY_STRING_FIELD(tableSpace);
COPY_NODE_FIELD(indexParams);
{
COMPARE_STRING_FIELD(idxname);
COMPARE_NODE_FIELD(relation);
- COMPARE_SCALAR_FIELD(relationId);
COMPARE_STRING_FIELD(accessMethod);
COMPARE_STRING_FIELD(tableSpace);
COMPARE_NODE_FIELD(indexParams);
WRITE_STRING_FIELD(idxname);
WRITE_NODE_FIELD(relation);
- WRITE_OID_FIELD(relationId);
WRITE_STRING_FIELD(accessMethod);
WRITE_STRING_FIELD(tableSpace);
WRITE_NODE_FIELD(indexParams);
n->concurrent = $4;
n->idxname = $5;
n->relation = $7;
- n->relationId = InvalidOid;
n->accessMethod = $8;
n->indexParams = $10;
n->indexIncludingParams = $12;
n->concurrent = $4;
n->idxname = $8;
n->relation = $10;
- n->relationId = InvalidOid;
n->accessMethod = $11;
n->indexParams = $13;
n->indexIncludingParams = $15;
/* Begin building the IndexStmt */
index = makeNode(IndexStmt);
index->relation = heapRel;
- index->relationId = heapRelid;
index->accessMethod = pstrdup(NameStr(amrec->amname));
if (OidIsValid(idxrelrec->reltablespace))
index->tableSpace = get_tablespace_name(idxrelrec->reltablespace);
NodeTag type;
char *idxname; /* name of new index, or NULL for default */
RangeVar *relation; /* relation to build index on */
- Oid relationId; /* OID of relation to build index on */
char *accessMethod; /* name of access method (eg. btree) */
char *tableSpace; /* tablespace, or NULL for default */
List *indexParams; /* columns to index: a list of IndexElem */