mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
Fix error reporting for index expressions of prohibited types.
If CheckAttributeType() threw an error about the datatype of an
index expression column, it would report an empty column name,
which is pretty unhelpful and certainly not the intended behavior.
I (tgl) evidently broke this in commit cfc5008a5
, by not noticing
that the column's attname was used above where I'd placed the
assignment of it.
In HEAD and v12, this is trivially fixable by moving up the
assignment of attname. Before v12 the code is a bit more messy;
to avoid doing substantial refactoring, I took the lazy way out
and just put in two copies of the assignment code.
Report and patch by Amit Langote. Back-patch to all supported
branches.
Discussion: https://postgr.es/m/CA+HiwqFA+BGyBFimjiYXXMa2Hc3fcL0+OJOyzUNjhU4NCa_XXw@mail.gmail.com
This commit is contained in:
@@ -368,6 +368,14 @@ ConstructTupleDescriptor(Relation heapRelation,
|
||||
*/
|
||||
memcpy(to, from, ATTRIBUTE_FIXED_PART_SIZE);
|
||||
|
||||
/*
|
||||
* Set the attribute name as specified by caller.
|
||||
*/
|
||||
if (colnames_item == NULL) /* shouldn't happen */
|
||||
elog(ERROR, "too few entries in colnames list");
|
||||
namestrcpy(&to->attname, (const char *) lfirst(colnames_item));
|
||||
colnames_item = lnext(colnames_item);
|
||||
|
||||
/*
|
||||
* Fix the stuff that should not be the same as the underlying
|
||||
* attr
|
||||
@@ -392,6 +400,14 @@ ConstructTupleDescriptor(Relation heapRelation,
|
||||
|
||||
MemSet(to, 0, ATTRIBUTE_FIXED_PART_SIZE);
|
||||
|
||||
/*
|
||||
* Set the attribute name as specified by caller.
|
||||
*/
|
||||
if (colnames_item == NULL) /* shouldn't happen */
|
||||
elog(ERROR, "too few entries in colnames list");
|
||||
namestrcpy(&to->attname, (const char *) lfirst(colnames_item));
|
||||
colnames_item = lnext(colnames_item);
|
||||
|
||||
if (indexpr_item == NULL) /* shouldn't happen */
|
||||
elog(ERROR, "too few entries in indexprs list");
|
||||
indexkey = (Node *) lfirst(indexpr_item);
|
||||
@@ -445,14 +461,6 @@ ConstructTupleDescriptor(Relation heapRelation,
|
||||
*/
|
||||
to->attrelid = InvalidOid;
|
||||
|
||||
/*
|
||||
* Set the attribute name as specified by caller.
|
||||
*/
|
||||
if (colnames_item == NULL) /* shouldn't happen */
|
||||
elog(ERROR, "too few entries in colnames list");
|
||||
namestrcpy(&to->attname, (const char *) lfirst(colnames_item));
|
||||
colnames_item = lnext(colnames_item);
|
||||
|
||||
/*
|
||||
* Check the opclass and index AM to see if either provides a keytype
|
||||
* (overriding the attribute type). Opclass (if exists) takes
|
||||
|
Reference in New Issue
Block a user