*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.98 1999/10/30 23:13:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.99 1999/11/01 05:09:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
List *rangeTable,
Query *parseTree)
{
- int i = 1;
- Oid relid;
- HeapTuple htup;
+ int rtindex = 0;
List *lp;
List *qvars,
*tvars;
int32 ok = 1,
aclcheck_result = -1;
char *opstr;
- NameData rname;
+ char *relName = NULL;
char *userName;
-#define CHECK(MODE) pg_aclcheck(rname.data, userName, MODE)
+#define CHECK(MODE) pg_aclcheck(relName, userName, MODE)
userName = GetPgUserName();
{
RangeTblEntry *rte = lfirst(lp);
+ ++rtindex;
+
if (rte->skipAcl)
{
continue;
}
- relid = rte->relid;
- htup = SearchSysCacheTuple(RELOID,
- ObjectIdGetDatum(relid),
- 0, 0, 0);
- if (!HeapTupleIsValid(htup))
- elog(ERROR, "ExecCheckPerms: bogus RT relid: %u", relid);
- StrNCpy(rname.data,
- ((Form_pg_class) GETSTRUCT(htup))->relname.data,
- NAMEDATALEN);
- if (i == resultRelation)
+ relName = rte->relname;
+ if (rtindex == resultRelation)
{ /* this is the result relation */
qvars = pull_varnos(parseTree->qual);
tvars = pull_varnos((Node *) parseTree->targetList);
}
if (!ok)
break;
- ++i;
}
if (!ok)
- elog(ERROR, "%s: %s", rname.data, aclcheck_error_strings[aclcheck_result]);
+ elog(ERROR, "%s: %s", relName, aclcheck_error_strings[aclcheck_result]);
if (parseTree != NULL && parseTree->rowMark != NULL)
{
if (!(rm->info & ROW_ACL_FOR_UPDATE))
continue;
- relid = ((RangeTblEntry *) nth(rm->rti - 1, rangeTable))->relid;
- htup = SearchSysCacheTuple(RELOID,
- ObjectIdGetDatum(relid),
- 0, 0, 0);
- if (!HeapTupleIsValid(htup))
- elog(ERROR, "ExecCheckPerms: bogus RT relid: %u", relid);
- StrNCpy(rname.data,
- ((Form_pg_class) GETSTRUCT(htup))->relname.data,
- NAMEDATALEN);
+ relName = rt_fetch(rm->rti, rangeTable)->relname;
ok = ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK);
opstr = "write";
if (!ok)
- elog(ERROR, "%s: %s", rname.data, aclcheck_error_strings[aclcheck_result]);
+ elog(ERROR, "%s: %s", relName, aclcheck_error_strings[aclcheck_result]);
}
}
}
resultRelationInfo->ri_IndexRelationInfo = NULL;
/*
- * open indices on result relation and save descriptors in the
- * result relation information..
+ * If there are indices on the result relation, open them and save
+ * descriptors in the result relation info, so that we can add new
+ * index entries for the tuples we add/update. We need not do this
+ * for a DELETE, however, since deletion doesn't affect indexes.
*/
- if (operation != CMD_DELETE)
+ if (resultRelationDesc->rd_rel->relhasindex &&
+ operation != CMD_DELETE)
ExecOpenIndices(resultRelationOid, resultRelationInfo);
estate->es_result_relation_info = resultRelationInfo;
foreach(l, parseTree->rowMark)
{
rm = lfirst(l);
- relid = ((RangeTblEntry *) nth(rm->rti - 1, rangeTable))->relid;
+ relid = rt_fetch(rm->rti, rangeTable)->relid;
relation = heap_open(relid, RowShareLock);
if (!(rm->info & ROW_MARK_FOR_UPDATE))
continue;
* XXX rather than having to call setheapoverride(true)
* and then back to false, we should change the arguments
* to heap_open() instead..
+ *
+ * XXX no, we should use commandCounterIncrement...
*/
setheapoverride(true);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.27 1999/10/30 23:13:30 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.28 1999/11/01 05:09:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
AppendState *appendstate;
int nplans;
- List *resultList = NULL;
List *rtable;
List *appendplans;
bool *initialized;
if ((es_rri != (RelationInfo *) NULL) &&
(node->inheritrelid == es_rri->ri_RangeTableIndex))
{
- RelationInfo *rri;
+ List *resultList = NIL;
List *rtentryP;
foreach(rtentryP, rtable)
{
- Oid reloid;
- RangeTblEntry *rtentry = lfirst(rtentryP);
+ RangeTblEntry *rtentry = lfirst(rtentryP);
+ Oid reloid;
+ RelationInfo *rri;
reloid = rtentry->relid;
rri = makeNode(RelationInfo);
rri->ri_IndexRelationDescs = NULL; /* index descs */
rri->ri_IndexRelationInfo = NULL; /* index key info */
+ if (rri->ri_RelationDesc->rd_rel->relhasindex)
+ ExecOpenIndices(reloid, rri);
+
resultList = lcons(rri, resultList);
- ExecOpenIndices(reloid, rri);
}
appendstate->as_result_relation_info_list = resultList;
}