diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-12-02 18:05:29 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-12-02 18:05:29 -0500 |
commit | ce76c0ba53e4bd0daf3db7a703671b27797b7244 (patch) | |
tree | 920ca4a5cc36e169181e12cc3880f2295f28e17a /src/backend/utils/adt/selfuncs.c | |
parent | 4526951d564a7eed512b4a0ac3b5893e0a115690 (diff) | |
download | postgresql-ce76c0ba53e4bd0daf3db7a703671b27797b7244.tar.gz postgresql-ce76c0ba53e4bd0daf3db7a703671b27797b7244.zip |
Add a reverse-translation column number array to struct AppendRelInfo.
This provides for cheaper mapping of child columns back to parent
columns. The one existing use-case in examine_simple_variable()
would hardly justify this by itself; but an upcoming bug fix will
make use of this array in a mainstream code path, and it seems
likely that we'll find other uses for it as we continue to build
out the partitioning infrastructure.
Discussion: https://postgr.es/m/12424.1575168015@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils/adt/selfuncs.c')
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 35dbd728ecf..ff02b5aafab 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -4769,29 +4769,17 @@ examine_simple_variable(PlannerInfo *root, Var *var, root)->rtekind == RTE_RELATION) { int parent_varattno; - ListCell *l; - parent_varattno = 1; found = false; - foreach(l, appinfo->translated_vars) - { - Var *childvar = lfirst_node(Var, l); - - /* Ignore dropped attributes of the parent. */ - if (childvar != NULL && - varattno == childvar->varattno) - { - found = true; - break; - } - parent_varattno++; - } - - if (!found) - break; + if (varattno <= 0 || varattno > appinfo->num_child_cols) + break; /* safety check */ + parent_varattno = appinfo->parent_colnos[varattno - 1]; + if (parent_varattno == 0) + break; /* Var is local to child */ varno = appinfo->parent_relid; varattno = parent_varattno; + found = true; /* If the parent is itself a child, continue up. */ appinfo = root->append_rel_array[varno]; |