Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e9ef11a

Browse files
committed
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
1 parent 360fd1a commit e9ef11a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/backend/statistics/dependencies.c

+8
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,14 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum)
792792

793793
var = (varonleft) ? linitial(expr->args) : lsecond(expr->args);
794794

795+
/*
796+
* We may ignore any RelabelType node above the operand. (There won't
797+
* be more than one, since eval_const_expressions() has been applied
798+
* already.)
799+
*/
800+
if (IsA(var, RelabelType))
801+
var = (Var *) ((RelabelType *) var)->arg;
802+
795803
/* We only support plain Vars for now */
796804
if (!IsA(var, Var))
797805
return false;

0 commit comments

Comments
 (0)