提交 a11fa012 编写于 作者: H Heikki Linnakangas

Revert gpdb-refactored snippet to upstream version.

While it might make sense to extract this duplicated code to a function,
let's rather avoid the difference from upstream.
上级 aabed49f
......@@ -64,7 +64,6 @@ static void expandTupleDesc(TupleDesc tupdesc, Alias *eref,
static int specialAttNum(const char *attname);
static void warnAutoRange(ParseState *pstate, RangeVar *relation);
static bool get_attisdropped(Oid relid, int attnum);
/*
* refnameRangeTblEntry
......@@ -2115,36 +2114,6 @@ bogus:
return "*BOGUS*";
}
static bool get_attisdropped(Oid relid, int attnum)
{
HeapTuple tp;
Form_pg_attribute att_tup;
bool result = false;
cqContext *pcqCtx;
/* SELECT attisdropped FROM pg_attribute */
pcqCtx = caql_beginscan(
NULL,
cql("SELECT * FROM pg_attribute "
" WHERE attrelid = :1 "
" AND attnum = :2 ",
ObjectIdGetDatum(relid),
Int16GetDatum(attnum)));
tp = caql_getnext(pcqCtx);
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, relid);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
result = att_tup->attisdropped;
caql_endscan(pcqCtx);
return (result);
}
/*
* get_rte_attribute_type
* Get attribute type information from a RangeTblEntry
......@@ -2318,7 +2287,22 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
{
case RTE_RELATION:
{
result = get_attisdropped(rte->relid, attnum);
/*
* Plain relation RTE --- get the attribute's catalog entry
*/
HeapTuple tp;
Form_pg_attribute att_tup;
tp = SearchSysCache(ATTNUM,
ObjectIdGetDatum(rte->relid),
Int16GetDatum(attnum),
0, 0);
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, rte->relid);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
result = att_tup->attisdropped;
ReleaseSysCache(tp);
}
break;
case RTE_SUBQUERY:
......@@ -2360,7 +2344,19 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
*
* Same as ordinary relation RTE
*/
result = get_attisdropped(funcrelid, attnum);
HeapTuple tp;
Form_pg_attribute att_tup;
tp = SearchSysCache(ATTNUM,
ObjectIdGetDatum(funcrelid),
Int16GetDatum(attnum),
0, 0);
if (!HeapTupleIsValid(tp)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
attnum, funcrelid);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
result = att_tup->attisdropped;
ReleaseSysCache(tp);
}
else
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册