summaryrefslogtreecommitdiffstats
path: root/sql/sql_derived.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 13:22:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 13:22:53 +0000
commit347c164c35eddab388009470e6848cb361ac93f8 (patch)
tree2c0c44eac690f510bb0a35b2a13b36d606b77b6b /sql/sql_derived.cc
parentReleasing progress-linux version 1:10.11.7-4~progress7.99u1. (diff)
downloadmariadb-347c164c35eddab388009470e6848cb361ac93f8.tar.xz
mariadb-347c164c35eddab388009470e6848cb361ac93f8.zip
Merging upstream version 1:10.11.8.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r--sql/sql_derived.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index afcbb7f8..de5a1f63 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -1217,8 +1217,12 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
(derived->alias.str ? derived->alias.str : "<NULL>"),
derived->get_unit()));
- if (unit->executed && !unit->uncacheable && !unit->describe &&
- !derived_is_recursive)
+ /*
+ Only fill derived tables once, unless the derived table is dependent in
+ which case we will delete all of its rows and refill it below.
+ */
+ if (unit->executed && !(unit->uncacheable & UNCACHEABLE_DEPENDENT) &&
+ !unit->describe && !derived_is_recursive)
DBUG_RETURN(FALSE);
/*check that table creation passed without problems. */
DBUG_ASSERT(derived->table && derived->table->is_created());
@@ -1233,7 +1237,9 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
/* Execute the query that specifies the derived table by a foreign engine */
res= derived->pushdown_derived->execute();
unit->executed= true;
+ if (res)
DBUG_RETURN(res);
+ goto after_exec;
}
if (unit->executed && !derived_is_recursive &&
@@ -1275,6 +1281,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
}
else
{
+ DBUG_ASSERT(!unit->executed || (unit->uncacheable & UNCACHEABLE_DEPENDENT));
SELECT_LEX *first_select= unit->first_select();
unit->set_limit(unit->global_parameters());
if (unit->lim.is_unlimited())
@@ -1294,6 +1301,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
derived_result, unit, first_select);
}
+ after_exec:
if (!res && !derived_is_recursive)
{
if (derived_result->flush())