summaryrefslogtreecommitdiff
path: root/sql/json_table.h
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2021-04-12 16:43:45 +0300
committerAlexey Botchkov <holyfoot@askmonty.org>2021-04-21 10:21:46 +0400
commit6bac48d0cfab649b82d4223e2a5fb6f7419bf6a1 (patch)
treea331f17cfe05678d745fa45427b9a76ad824a67c /sql/json_table.h
parent4a10dd0253192bf84d8fe3e246d427eaf93ff376 (diff)
downloadmariadb-git-6bac48d0cfab649b82d4223e2a5fb6f7419bf6a1.tar.gz
MDEV-25381: JSON_TABLE: ER_WRONG_OUTER_JOIN upon query with LEFT and RIGHT joins and view
Table_function_json_table::m_dep_tables attempts to cache the value of m_json->used_tables(), poorly. Remove the cache and use the value directly.
Diffstat (limited to 'sql/json_table.h')
-rw-r--r--sql/json_table.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/sql/json_table.h b/sql/json_table.h
index 90fc667731f..04b0e6c07d2 100644
--- a/sql/json_table.h
+++ b/sql/json_table.h
@@ -208,8 +208,16 @@ public:
st_select_lex *new_parent, bool merge);
void update_used_tables() { m_json->update_used_tables(); }
- table_map used_tables() const { return m_dep_tables; }
- bool join_cache_allowed() const { return !m_dep_tables; }
+ table_map used_tables() const { return m_json->used_tables(); }
+ bool join_cache_allowed() const
+ {
+ /*
+ Can use join cache when we have an outside reference.
+ If there's dependency on any other table or randomness,
+ cannot use it.
+ */
+ return !(used_tables() & ~OUTER_REF_TABLE_BIT);
+ }
void get_estimates(ha_rows *out_rows,
double *scan_time, double *startup_cost);
@@ -242,13 +250,6 @@ private:
/* Context to be used for resolving the first argument. */
Name_resolution_context *m_context;
- /*
- the JSON argument can be taken from other tables.
- We have to mark these tables as dependent so the
- mask of these dependent tables is calculated in ::setup().
- */
- table_map m_dep_tables;
-
/* Current NESTED PATH level being parsed */
Json_table_nested_path *cur_parent;