aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2017-10-12 17:23:47 +0200
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2017-10-12 17:23:47 +0200
commite9ef11ac8bb2acc2d2462fc17ec3291a959589e7 (patch)
tree3945717c789948171cd0f85d0995fe64baf54d48 /src
parent360fd1a7b2fe779cc9e696b813b12f6a8e83b558 (diff)
downloadpostgresql-e9ef11ac8bb2acc2d2462fc17ec3291a959589e7.tar.gz
postgresql-e9ef11ac8bb2acc2d2462fc17ec3291a959589e7.zip
Infer functional dependency past RelabelType
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/statistics/dependencies.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c
index 2e7c0ad6ba6..9756fb83c0c 100644
--- 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;