git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 360fd1a)
Infer functional dependency past RelabelType
2017年10月12日 15:23:47 +0000 (17:23 +0200)
2017年10月12日 15:23:47 +0000 (17:23 +0200)
Vars hidden within a RelabelType would not be detected as compatible
with some functional dependency. Repair by properly ignoring the
RelabelType.

Author: David Rowley
Reviewed-by: Tomas Vondra
Discussion: https://postgr.es/m/CAKJS1f-y-UEy=rsBXynBOgiW1fKMr_LVoYSGL9QOc36mLEC-ww@mail.gmail.com


diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c
index 2e7c0ad6ba61403eed83f8166711f7ac23556e86..9756fb83c0c855481be992b41b59fa0d8a806836 100644 (file)
--- a/src/backend/statistics/dependencies.c
+++ b/src/backend/statistics/dependencies.c
@@ -792,6 +792,14 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum)
var = (varonleft) ? linitial(expr->args) : lsecond(expr->args);
+ /*
+ * We may ignore any RelabelType node above the operand. (There won't
+ * be more than one, since eval_const_expressions() has been applied
+ * already.)
+ */
+ if (IsA(var, RelabelType))
+ var = (Var *) ((RelabelType *) var)->arg;
+
/* We only support plain Vars for now */
if (!IsA(var, Var))
return false;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /