mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
Expand virtual generated columns in constraint expressions
Virtual generated columns in constraint expressions need to be expanded because the optimizer matches these expressions to qual clauses. Failing to do so can cause us to miss opportunities for constraint exclusion. Author: Richard Guo <guofenglinux@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/204804c0-798f-4c72-bd1f-36116024fda3%40eisentraut.org
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include "parser/parse_relation.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "partitioning/partdesc.h"
|
||||
#include "rewrite/rewriteHandler.h"
|
||||
#include "rewrite/rewriteManip.h"
|
||||
#include "statistics/statistics.h"
|
||||
#include "storage/bufmgr.h"
|
||||
@@ -1482,6 +1483,14 @@ get_relation_constraints(PlannerInfo *root,
|
||||
result = list_concat(result, rel->partition_qual);
|
||||
}
|
||||
|
||||
/*
|
||||
* Expand virtual generated columns in the constraint expressions.
|
||||
*/
|
||||
if (result)
|
||||
result = (List *) expand_generated_columns_in_expr((Node *) result,
|
||||
relation,
|
||||
varno);
|
||||
|
||||
table_close(relation, NoLock);
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user