1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä
2021-04-21 07:58:42 +03:00
33 changed files with 675 additions and 127 deletions

View File

@ -1,6 +1,6 @@
/*
Copyright (c) 2002, 2011, Oracle and/or its affiliates.
Copyright (c) 2010, 2020, MariaDB
Copyright (c) 2010, 2021, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -596,6 +596,32 @@ bool mysql_derived_init(THD *thd, LEX *lex, TABLE_LIST *derived)
}
/**
@brief
Prevent name resolution out of context of ON expressions in derived tables
@param
join_list list of tables used in from list of a derived
@details
The function sets the Name_resolution_context::outer_context to NULL
for all ON expressions contexts in the given join list. It does this
recursively for all nested joins the list contains.
*/
static void nullify_outer_context_for_on_clauses(List<TABLE_LIST>& join_list)
{
List_iterator<TABLE_LIST> li(join_list);
while (TABLE_LIST *table= li++)
{
if (table->on_context)
table->on_context->outer_context= NULL;
if (table->nested_join)
nullify_outer_context_for_on_clauses(table->nested_join->join_list);
}
}
/*
Create temporary table structure (but do not fill it)
@ -760,7 +786,12 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
/* prevent name resolving out of derived table */
for (SELECT_LEX *sl= first_select; sl; sl= sl->next_select())
{
// Prevent it for the WHERE clause
sl->context.outer_context= 0;
// And for ON clauses, if there are any
nullify_outer_context_for_on_clauses(*sl->join_list);
if (!derived->is_with_table_recursive_reference() ||
(!derived->with->with_anchor &&
!derived->with->is_with_prepared_anchor()))