[Maria-developers] MDEV-17399: JSON_TABLE: Odd code in table.cc:create_view_field ?
Hi Alexey, What does the code quoted below do? I don't recall seeing it on previous review iterations. In any case, * It needs a comment about why such special handling is needed. * It needs test coverage - I have reverted these changes and didn't see any test to fail?
diff --git a/sql/table.cc b/sql/table.cc index 4f65dbd65f4..9c205fc4be6 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -6722,6 +6722,8 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, LEX_CSTRING *name) { bool save_wrapper= thd->lex->first_select_lex()->no_wrap_view_item; + bool *wrapper_to_set= thd->lex->current_select ? + &thd->lex->current_select->no_wrap_view_item : &save_wrapper; Item *field= *field_ref; DBUG_ENTER("create_view_field");
@@ -6737,17 +6739,17 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, }
DBUG_ASSERT(field); - thd->lex->current_select->no_wrap_view_item= TRUE; + *wrapper_to_set= TRUE; if (!field->is_fixed()) { if (field->fix_fields(thd, field_ref)) { - thd->lex->current_select->no_wrap_view_item= save_wrapper; + *wrapper_to_set= save_wrapper; DBUG_RETURN(0); } field= *field_ref; } - thd->lex->current_select->no_wrap_view_item= save_wrapper; + *wrapper_to_set= save_wrapper; if (save_wrapper) { DBUG_RETURN(field);
BR Sergei -- Sergei Petrunia, Software Developer MariaDB Corporation | Skype: sergefp | Blog: http://petrunia.net
Well i should have removed those changes after i did the last version of the check for table dependencies. Now we never set the thd->current_select to the 0. So that part wrapper_to_set part deleted. Best regards. HF On Fri, Mar 12, 2021 at 1:35 AM Sergey Petrunia <sergey@mariadb.com> wrote:
Hi Alexey,
What does the code quoted below do? I don't recall seeing it on previous review iterations.
In any case, * It needs a comment about why such special handling is needed. * It needs test coverage - I have reverted these changes and didn't see any test to fail?
diff --git a/sql/table.cc b/sql/table.cc index 4f65dbd65f4..9c205fc4be6 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -6722,6 +6722,8 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, LEX_CSTRING *name) { bool save_wrapper= thd->lex->first_select_lex()->no_wrap_view_item; + bool *wrapper_to_set= thd->lex->current_select ? + &thd->lex->current_select->no_wrap_view_item : &save_wrapper; Item *field= *field_ref; DBUG_ENTER("create_view_field");
@@ -6737,17 +6739,17 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, }
DBUG_ASSERT(field); - thd->lex->current_select->no_wrap_view_item= TRUE; + *wrapper_to_set= TRUE; if (!field->is_fixed()) { if (field->fix_fields(thd, field_ref)) { - thd->lex->current_select->no_wrap_view_item= save_wrapper; + *wrapper_to_set= save_wrapper; DBUG_RETURN(0); } field= *field_ref; } - thd->lex->current_select->no_wrap_view_item= save_wrapper; + *wrapper_to_set= save_wrapper; if (save_wrapper) { DBUG_RETURN(field);
BR Sergei -- Sergei Petrunia, Software Developer MariaDB Corporation | Skype: sergefp | Blog: http://petrunia.net
participants (2)
-
Alexey Botchkov
-
Sergey Petrunia