mirror of https://github.com/citusdata/citus.git
Update CopyGetAttnums with latest from PostgreSQL
This function was recently modified to use the TupleDescAttr wrapper, which abstracts away recent changes to TupleDesc.pull/1633/head
parent
91d9b41822
commit
6a020b5adc
|
@ -3257,16 +3257,13 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
|
||||||
if (attnamelist == NIL)
|
if (attnamelist == NIL)
|
||||||
{
|
{
|
||||||
/* Generate default column list */
|
/* Generate default column list */
|
||||||
Form_pg_attribute *attr = tupDesc->attrs;
|
|
||||||
int attr_count = tupDesc->natts;
|
int attr_count = tupDesc->natts;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < attr_count; i++)
|
for (i = 0; i < attr_count; i++)
|
||||||
{
|
{
|
||||||
if (attr[i]->attisdropped)
|
if (TupleDescAttr(tupDesc, i)->attisdropped)
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
attnums = lappend_int(attnums, i + 1);
|
attnums = lappend_int(attnums, i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3285,41 +3282,35 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
|
||||||
attnum = InvalidAttrNumber;
|
attnum = InvalidAttrNumber;
|
||||||
for (i = 0; i < tupDesc->natts; i++)
|
for (i = 0; i < tupDesc->natts; i++)
|
||||||
{
|
{
|
||||||
if (tupDesc->attrs[i]->attisdropped)
|
Form_pg_attribute att = TupleDescAttr(tupDesc, i);
|
||||||
{
|
|
||||||
|
if (att->attisdropped)
|
||||||
continue;
|
continue;
|
||||||
}
|
if (namestrcmp(&(att->attname), name) == 0)
|
||||||
if (namestrcmp(&(tupDesc->attrs[i]->attname), name) == 0)
|
|
||||||
{
|
{
|
||||||
attnum = tupDesc->attrs[i]->attnum;
|
attnum = att->attnum;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attnum == InvalidAttrNumber)
|
if (attnum == InvalidAttrNumber)
|
||||||
{
|
{
|
||||||
if (rel != NULL)
|
if (rel != NULL)
|
||||||
{
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||||
errmsg("column \"%s\" of relation \"%s\" does not exist",
|
errmsg("column \"%s\" of relation \"%s\" does not exist",
|
||||||
name, RelationGetRelationName(rel))));
|
name, RelationGetRelationName(rel))));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||||
errmsg("column \"%s\" does not exist",
|
errmsg("column \"%s\" does not exist",
|
||||||
name)));
|
name)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* Check for duplicates */
|
/* Check for duplicates */
|
||||||
if (list_member_int(attnums, attnum))
|
if (list_member_int(attnums, attnum))
|
||||||
{
|
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_DUPLICATE_COLUMN),
|
(errcode(ERRCODE_DUPLICATE_COLUMN),
|
||||||
errmsg("column \"%s\" specified more than once",
|
errmsg("column \"%s\" specified more than once",
|
||||||
name)));
|
name)));
|
||||||
}
|
|
||||||
attnums = lappend_int(attnums, attnum);
|
attnums = lappend_int(attnums, attnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue