From 007a1895458851d7fd0f4eeebfe17a5e48d1e88a Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Thu, 6 Feb 2025 08:50:41 +0100 Subject: [PATCH] copy expression deps more carefully Signed-off-by: Andres Taylor --- go/vt/vtgate/semantics/semantic_table.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/go/vt/vtgate/semantics/semantic_table.go b/go/vt/vtgate/semantics/semantic_table.go index 0227ee04137..299ef431abe 100644 --- a/go/vt/vtgate/semantics/semantic_table.go +++ b/go/vt/vtgate/semantics/semantic_table.go @@ -190,13 +190,15 @@ var ErrNotSingleTable = vterrors.VT13001("should only be used for single tables" // CopyDependencies copies the dependencies from one expression into the other func (st *SemTable) CopyDependencies(from, to sqlparser.Expr) { - if ValidAsMapKey(to) { - st.Recursive[to] = st.RecursiveDeps(from) - st.Direct[to] = st.DirectDeps(from) - if ValidAsMapKey(from) { - if typ, found := st.ExprTypes[from]; found { - st.ExprTypes[to] = typ - } + if ValidAsMapKey(to) && ValidAsMapKey(from) { + if ts, ok := st.Recursive[from]; ok { + st.Recursive[to] = ts + } + if ts, ok := st.Direct[from]; ok { + st.Direct[to] = ts + } + if typ, found := st.ExprTypes[from]; found { + st.ExprTypes[to] = typ } } }