mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
added warning about external fields resolving to EXPLAIN command
(SCRUM) (WL#1053)
This commit is contained in:
@ -287,4 +287,5 @@
|
||||
#define ER_CANT_AGGREGATE_3COLLATIONS 1268
|
||||
#define ER_CANT_AGGREGATE_NCOLLATIONS 1269
|
||||
#define ER_VARIABLE_IS_NOT_STRUCT 1270
|
||||
#define ER_ERROR_MESSAGES 271
|
||||
#define ER_WARN_FIELD_RESOLVED 1271
|
||||
#define ER_ERROR_MESSAGES 272
|
||||
|
@ -42,6 +42,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1271 Field or reference 'a' of SELECT #3 was resolved in SELECT #1
|
||||
Note 1271 Field or reference '.a' of SELECT #3 was resolved in SELECT #1
|
||||
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
1
|
||||
1
|
||||
@ -207,6 +210,8 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 3
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
|
||||
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
Warnings:
|
||||
Note 1271 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1
|
||||
select * from t3 where exists (select * from t2 where t2.b=t3.a);
|
||||
a
|
||||
7
|
||||
@ -286,6 +291,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1
|
||||
3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where
|
||||
Warnings:
|
||||
Note 1271 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1271 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1
|
||||
select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
|
||||
ERROR 21000: Subselect returns more than 1 record
|
||||
create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
|
||||
@ -301,6 +309,8 @@ explain select * from t6 where exists (select * from t7 where uq = clinic_uq);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1
|
||||
Warnings:
|
||||
Note 1271 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1
|
||||
select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
|
||||
ERROR 23000: Column: 'a' in field list is ambiguous
|
||||
drop table if exists t1,t2,t3;
|
||||
@ -808,6 +818,7 @@ explain select (select a+1) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
Warnings:
|
||||
Note 1271 Field or reference 'a' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1247 Select 2 was reduced during optimisation
|
||||
select (select a+1) from t1;
|
||||
(select a+1)
|
||||
|
25
sql/item.cc
25
sql/item.cc
@ -23,7 +23,8 @@
|
||||
#include <m_ctype.h>
|
||||
#include "my_dir.h"
|
||||
|
||||
static void mark_as_dependent(SELECT_LEX *last, SELECT_LEX *current,
|
||||
static void mark_as_dependent(THD *thd,
|
||||
SELECT_LEX *last, SELECT_LEX *current,
|
||||
Item_ident *item);
|
||||
|
||||
/*****************************************************************************
|
||||
@ -810,17 +811,29 @@ bool Item_ref_null_helper::get_date(TIME *ltime, bool fuzzydate)
|
||||
|
||||
SYNOPSIS
|
||||
mark_as_dependent()
|
||||
thd - thread handler
|
||||
last - select from which current item depend
|
||||
current - current select
|
||||
item - item which should be marked
|
||||
*/
|
||||
|
||||
static void mark_as_dependent(SELECT_LEX *last, SELECT_LEX *current,
|
||||
static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
|
||||
Item_ident *item)
|
||||
{
|
||||
// store pointer on SELECT_LEX from wich item is dependent
|
||||
item->depended_from= last;
|
||||
current->mark_as_dependent(last);
|
||||
if (thd->lex.describe)
|
||||
{
|
||||
char warn_buff[MYSQL_ERRMSG_SIZE];
|
||||
sprintf(warn_buff, ER(ER_WARN_FIELD_RESOLVED),
|
||||
(item->db_name?item->db_name:""), (item->db_name?".":""),
|
||||
(item->table_name?item->table_name:""), (item->table_name?".":""),
|
||||
item->field_name,
|
||||
current->select_number, last->select_number);
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||
ER_WARN_FIELD_RESOLVED, warn_buff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -902,12 +915,12 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
|
||||
if (rf->fix_fields(thd, tables, ref) || rf->check_cols(1))
|
||||
return 1;
|
||||
|
||||
mark_as_dependent(last, cursel, rf);
|
||||
mark_as_dependent(thd, last, cursel, rf);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mark_as_dependent(last, cursel, this);
|
||||
mark_as_dependent(thd, last, cursel, this);
|
||||
if (last->having_fix_field)
|
||||
{
|
||||
Item_ref *rf;
|
||||
@ -1379,7 +1392,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
|
||||
Item_field* fld;
|
||||
if (!((*reference)= fld= new Item_field(tmp)))
|
||||
return 1;
|
||||
mark_as_dependent(last, thd->lex.current_select, fld);
|
||||
mark_as_dependent(thd, last, thd->lex.current_select, fld);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@ -1390,7 +1403,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
|
||||
"forward reference in item list");
|
||||
return -1;
|
||||
}
|
||||
mark_as_dependent(last, thd->lex.current_select,
|
||||
mark_as_dependent(thd, last, thd->lex.current_select,
|
||||
this);
|
||||
ref= last->ref_pointer_array + counter;
|
||||
}
|
||||
|
@ -276,3 +276,4 @@ v/*
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -270,3 +270,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -278,3 +278,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -272,3 +272,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -272,3 +272,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -267,3 +267,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -276,3 +276,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -267,3 +267,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -269,3 +269,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -267,3 +267,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -269,3 +269,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -267,3 +267,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -269,3 +269,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -269,3 +269,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -271,3 +271,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -267,3 +267,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -271,3 +271,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -269,3 +269,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"<22><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '%-.64s%s%-.64s%s%-.64s' <20><> SELECT<43> #%d <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> SELECT<43> #%d",
|
||||
|
@ -263,3 +263,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -275,3 +275,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -268,3 +268,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -267,3 +267,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d",
|
||||
|
@ -272,3 +272,4 @@
|
||||
"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'",
|
||||
"Illegal mix of collations for operation '%s'",
|
||||
"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)",
|
||||
"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '%-.64s%s%-.64s%s%-.64s' <20><> SELECT<43> #%d <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> SELECT<43> #%d",
|
||||
|
Reference in New Issue
Block a user