mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Fix for pg_restore_attribute_stats().
Use RelationGetIndexExpressions() rather than rd_indexprs directly. Author: Corey Huinker <corey.huinker@gmail.com>
This commit is contained in:
@ -480,12 +480,28 @@ attribute_statistics_update(FunctionCallInfo fcinfo, int elevel)
|
|||||||
static Node *
|
static Node *
|
||||||
get_attr_expr(Relation rel, int attnum)
|
get_attr_expr(Relation rel, int attnum)
|
||||||
{
|
{
|
||||||
if ((rel->rd_rel->relkind == RELKIND_INDEX
|
List *index_exprs;
|
||||||
|| (rel->rd_rel->relkind == RELKIND_PARTITIONED_INDEX))
|
ListCell *indexpr_item;
|
||||||
&& (rel->rd_indexprs != NIL)
|
|
||||||
&& (rel->rd_index->indkey.values[attnum - 1] == 0))
|
/* relation is not an index */
|
||||||
{
|
if (rel->rd_rel->relkind != RELKIND_INDEX &&
|
||||||
ListCell *indexpr_item = list_head(rel->rd_indexprs);
|
rel->rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
index_exprs = RelationGetIndexExpressions(rel);
|
||||||
|
|
||||||
|
/* index has no expressions to give */
|
||||||
|
if (index_exprs == NIL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The index attnum points directly to a relation attnum, then it's no an
|
||||||
|
* expression attribute.
|
||||||
|
*/
|
||||||
|
if (rel->rd_index->indkey.values[attnum - 1] != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
indexpr_item = list_head(rel->rd_indexprs);
|
||||||
|
|
||||||
for (int i = 0; i < attnum - 1; i++)
|
for (int i = 0; i < attnum - 1; i++)
|
||||||
if (rel->rd_index->indkey.values[i] == 0)
|
if (rel->rd_index->indkey.values[i] == 0)
|
||||||
@ -496,8 +512,6 @@ get_attr_expr(Relation rel, int attnum)
|
|||||||
|
|
||||||
return (Node *) lfirst(indexpr_item);
|
return (Node *) lfirst(indexpr_item);
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Derive type information from the attribute.
|
* Derive type information from the attribute.
|
||||||
|
Reference in New Issue
Block a user