 Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  bug#10466: Datatype "timestamp" displays "YYYYMMDDHHMMSS" irrespective of display sizes.
- Print warning that says display width is not supported for datatype TIMESTAMP, if user tries to create a TIMESTAMP column with display width.
- Use display width for TIMESTAMP only in type_timestamp test to make sure warning is displayed correctly.
mysql-test/include/ps_create.inc:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/alias.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/func_date_add.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/func_str.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/func_time.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/group_by.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/innodb.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_1general.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_2myisam.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_3innodb.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_4heap.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_5merge.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_6bdb.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_7ndb.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/select.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/type_timestamp.result:
When display width is used for a TIMESTAMP column a warning is printed that the display width will be ignored.
mysql-test/r/update.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/alias.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/func_date_add.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/func_str.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/func_time.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/group_by.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/innodb.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/ps.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/ps_4heap.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/ps_5merge.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/select.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/update.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
sql/share/errmsg.txt:
Correct swedish error message
sql/sql_parse.cc:
Print warning if datatype is TIMESTAMP and display width is used.
21 years ago  WL#1264 "Per-thread time zone support infrastructure".
Added basic per-thread time zone functionality (based on public
domain elsie-code). Now user can select current time zone
(from the list of time zones described in system tables).
All NOW-like functions honor this time zone, values of TIMESTAMP
type are interpreted as values in this time zone, so now
our TIMESTAMP type behaves similar to Oracle's TIMESTAMP WITH
LOCAL TIME ZONE (or proper PostgresSQL type).
WL#1266 "CONVERT_TZ() - basic time with time zone conversion
function".
Fixed problems described in Bug #2336 (Different number of warnings
when inserting bad datetime as string or as number). This required
reworking of datetime realted warning hadling (they now generated
at Field object level not in conversion functions).
Optimization: Now Field class descendants use table->in_use member
instead of current_thd macro.
include/my_global.h:
Added macro for reading of 32-bit ints stored in network order from
unaligned memory location.
include/mysqld_error.h:
Added error-code for invalid timestamp warning and error-code
for wrong or unknown time zone specification.
libmysqld/Makefile.am:
Added main per-thread time zone support file to libmysqld
libmysqld/lib_sql.cc:
Added initialization of time zones infrastructure to embedded server.
mysql-test/r/connect.result:
Updated test result since now mysql database contains more
system tables.
mysql-test/r/date_formats.result:
Now when truncation occurs during conversion to datetime value we are producing Warnings
instead of Notes. Also we are giving more clear warnings about this in some cases.
mysql-test/r/func_sapdb.result:
New warnings about truncation occured during conversion to datetime value added due
their better handling.
mysql-test/r/func_time.result:
New warnings about truncation occured during conversion to datetime value added due
their better handling.
mysql-test/r/select.result:
New warnings about truncation occured during conversion to datetime value added due
their better handling. Also tweaked test a bit to made it less ambigious for reader.
mysql-test/r/system_mysql_db.result:
Updated test result because new system tables holding time zone descriptions were
added.
mysql-test/r/timezone.result:
Updated timezone.test to use new system variable which shows system time zone.
Added test of warning which is produced if someone tries to store non-existing (due
falling into spring time-gap) datetime value into TIMESTAMP field.
mysql-test/r/type_datetime.result:
Separated and extended test of values and warnings produced for bad values stored in
DATETTIME fields.
mysql-test/r/type_time.result:
Now we are producing more consistent warning when we are truncating datetime value while
storing it in TIME field.
mysql-test/r/type_timestamp.result:
Separated and extended test of values and warnings produced for bad
values stored in TIMESTAMP fields.
mysql-test/t/select.test:
Updated test to make it less ambigous for reader.
mysql-test/t/timezone.test:
Updated timezone.test to use new system variable which shows system time zone.
Added test of warning which is produced if someone tries to store non-existing (due
falling into spring time-gap) datetime value into TIMESTAMP field.
mysql-test/t/type_datetime.test:
Separated and extended test of values and warnings produced for bad
values stored in DATETTIME fields.
mysql-test/t/type_timestamp.test:
Separated and extended test of values and warnings produced for bad
values stored in TIMESTAMP fields.
scripts/mysql_create_system_tables.sh:
Added creation of tables with time zone descriptions.
Also added descriptions of time zones used in tests.
scripts/mysql_fix_privilege_tables.sql:
Added mysql.time_zone* tables family.
sql/Makefile.am:
Added files implementing time zone support to server, also added
rules for building of mysql_tzinfo_to_sql converter and test_time
test.
sql/field.cc:
Now we are using per-thread time zone for TIMESTAMP <-> whatever conversion.
Fixed generation of warnings for datetime types (DATETIME/TIMESTAMP/DATE/...) and
any other Field to datetime conversion (now we are generating warnings no in lower
level functions like in str_to_TIME() but in Field methods. This allows generate
better and more consistent warnings and to reuse code of str_to_TIME() outside of
server).
Added 3rd parameter to set_warning() method to be able to not increment cut fields
but still produce a warning. Also added set_datetime_warning() family of auxiliary
methods which allow easier generate datetime related warnings.
Also replaced occurences of current_thd with table->in_use member, added
asserts for catching all places there we need to set table->in_use
accordingly. Renamed fix_datetime() function to number_to_TIME() and
moved it to sql/time.cc there it fits better.
sql/field.h:
Added comment about places where we can use table->in_use member
instead of current_thd.
Added 3rd parameter to Field::set_warning() method and set_datetime_warning()
family of methods.
sql/field_conv.cc:
Field::set_warning() method with 2 arguments was replaced with more
generic set_warning() method with 3 arguments.
sql/ha_berkeley.cc:
Now we set table->in_use for temporary tables so we have to use
table->tmp_table for checking if table is temporary.
sql/item.cc:
Replaced calls to str_to_time() and str_to_TIME() funcs with their warning
generating analogs.
sql/item_create.cc:
Added creation of CONVERT_TZ function as FUNC_ARG3.
sql/item_create.h:
Added creation of CONVERT_TZ function as FUNC_ARG3.
sql/item_timefunc.cc:
Added support of per-thread time zone to NOW-like and FROM_UNIXTIME,
UNIX_TIMESTAMP functions.
Added support for CONVERT_TZ function.
Removed call to str_to_timestamp function which caused non-optimal
behavior in certain cases. Replaced calls to str_to_time() function
with its warning generating analog.
sql/item_timefunc.h:
Added support of per-thread time zone to NOW-like and
FROM_UNIXTIME, UNIX_TIMESTAMP functions.
Added support of CONVERT_TZ function.
sql/lex.h:
Added support of CONVERT_TZ function.
sql/log.cc:
Added support for replication of statements depending on time zone.
sql/mysql_priv.h:
Now including headers with per-thread time zone support functions
and classes. Added portable replacement of time_t - my_time_t type.
Added time zone as one of query distinguishing parameters for
query cache.
Fixed declarations of str_to_TIME, str_to_time and
my_system_gmt_sec (former my_gmt_sec) since now they have one more
out parameter which informs about wrong datetime value or data
truncation during conversion.
Added warning generating version of str_to_TIME() and str_to_time()
functions.
Thrown away str_to_datetime/timestamp functions since they are not
needed any longer. Added number_to_TIME function.
sql/mysqld.cc:
Added per-thread time zone support initialization.
Added new startup parameter --default-time-zone.
sql/set_var.cc:
Added support for per-thread time_zone variable.
Renamed old timezone variable to system_time_zone.
sql/set_var.h:
Added support for per-thread time_zone variable.
sql/share/czech/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/danish/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/dutch/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/english/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/estonian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/french/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/german/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/greek/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/hungarian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/italian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/japanese/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/korean/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/norwegian-ny/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/norwegian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/polish/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/portuguese/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/romanian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/russian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/serbian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/slovak/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/spanish/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/swedish/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/ukrainian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/slave.cc:
In order to support replication of statements using time zones in 4.1 we should
ensure that both master and slave have same default time zone.
sql/sql_base.cc:
Now we are setting TABLE::in_use member for all tables (which assume
calls to Field::store or val_ methods).
sql/sql_cache.cc:
Added time zone as one more query distinguishing parameter
for query cache.
sql/sql_class.cc:
Added THD::time_zone_used variable indicating that this query
uses per thread time zone.
sql/sql_class.h:
Added per-thread time zone variable. Added THD::time_zone_used
variable indicating that this query uses per thread time zone
so if this is updating query the time zone should be logged to
binlog.
sql/sql_insert.cc:
We should set TABLE::in_use member pointing to thread which is called
INSERT DELAYED and not to worker thread.
sql/sql_load.cc:
Field::set_warning() now has one more argument now.
sql/sql_parse.cc:
Resetting THD::time_zone_used variable in the end of query
processing.
sql/sql_select.cc:
Now we are setting TABLE::in_use member for all tables (which assume
calls to Field::store or val_ methods).
sql/sql_show.cc:
Now using per thread time zone for extended show tables.
sql/time.cc:
Added support for per-thread time zones for TIMESTAMP type and
reworked generation of warnings for TIMESTAMP and DATETIME types.
(Introduced new TIME_to_timestamp() function. Removed hours
normalisation from former my_gmt_sec() since it was not working
and not used anywhere now, but breaks parameter constness, added
to this function generation of warning if we are falling in spring
time-gap. Removed str_to_timestamp and str_to_datetime functions
which are no longer used. Moved fix_datetime function from
sql/field.cc to this file as number_to_TIME() function. Added
out parameter for str_to_TIME and str_to_time functions which
indicates if value was truncated during conversion, removed direct
generation of warnings from this functions.)
sql/unireg.cc:
Now we are setting TABLE::in_use member for all tables (which assume
calls to Field::store or val_ methods).
BitKeeper/etc/ignore:
Added sql/test_time sql/mysql_tzinfo_to_sql libmysqld/tztime.cc to the ignore list
22 years ago  WL#1264 "Per-thread time zone support infrastructure".
Added basic per-thread time zone functionality (based on public
domain elsie-code). Now user can select current time zone
(from the list of time zones described in system tables).
All NOW-like functions honor this time zone, values of TIMESTAMP
type are interpreted as values in this time zone, so now
our TIMESTAMP type behaves similar to Oracle's TIMESTAMP WITH
LOCAL TIME ZONE (or proper PostgresSQL type).
WL#1266 "CONVERT_TZ() - basic time with time zone conversion
function".
Fixed problems described in Bug #2336 (Different number of warnings
when inserting bad datetime as string or as number). This required
reworking of datetime realted warning hadling (they now generated
at Field object level not in conversion functions).
Optimization: Now Field class descendants use table->in_use member
instead of current_thd macro.
include/my_global.h:
Added macro for reading of 32-bit ints stored in network order from
unaligned memory location.
include/mysqld_error.h:
Added error-code for invalid timestamp warning and error-code
for wrong or unknown time zone specification.
libmysqld/Makefile.am:
Added main per-thread time zone support file to libmysqld
libmysqld/lib_sql.cc:
Added initialization of time zones infrastructure to embedded server.
mysql-test/r/connect.result:
Updated test result since now mysql database contains more
system tables.
mysql-test/r/date_formats.result:
Now when truncation occurs during conversion to datetime value we are producing Warnings
instead of Notes. Also we are giving more clear warnings about this in some cases.
mysql-test/r/func_sapdb.result:
New warnings about truncation occured during conversion to datetime value added due
their better handling.
mysql-test/r/func_time.result:
New warnings about truncation occured during conversion to datetime value added due
their better handling.
mysql-test/r/select.result:
New warnings about truncation occured during conversion to datetime value added due
their better handling. Also tweaked test a bit to made it less ambigious for reader.
mysql-test/r/system_mysql_db.result:
Updated test result because new system tables holding time zone descriptions were
added.
mysql-test/r/timezone.result:
Updated timezone.test to use new system variable which shows system time zone.
Added test of warning which is produced if someone tries to store non-existing (due
falling into spring time-gap) datetime value into TIMESTAMP field.
mysql-test/r/type_datetime.result:
Separated and extended test of values and warnings produced for bad values stored in
DATETTIME fields.
mysql-test/r/type_time.result:
Now we are producing more consistent warning when we are truncating datetime value while
storing it in TIME field.
mysql-test/r/type_timestamp.result:
Separated and extended test of values and warnings produced for bad
values stored in TIMESTAMP fields.
mysql-test/t/select.test:
Updated test to make it less ambigous for reader.
mysql-test/t/timezone.test:
Updated timezone.test to use new system variable which shows system time zone.
Added test of warning which is produced if someone tries to store non-existing (due
falling into spring time-gap) datetime value into TIMESTAMP field.
mysql-test/t/type_datetime.test:
Separated and extended test of values and warnings produced for bad
values stored in DATETTIME fields.
mysql-test/t/type_timestamp.test:
Separated and extended test of values and warnings produced for bad
values stored in TIMESTAMP fields.
scripts/mysql_create_system_tables.sh:
Added creation of tables with time zone descriptions.
Also added descriptions of time zones used in tests.
scripts/mysql_fix_privilege_tables.sql:
Added mysql.time_zone* tables family.
sql/Makefile.am:
Added files implementing time zone support to server, also added
rules for building of mysql_tzinfo_to_sql converter and test_time
test.
sql/field.cc:
Now we are using per-thread time zone for TIMESTAMP <-> whatever conversion.
Fixed generation of warnings for datetime types (DATETIME/TIMESTAMP/DATE/...) and
any other Field to datetime conversion (now we are generating warnings no in lower
level functions like in str_to_TIME() but in Field methods. This allows generate
better and more consistent warnings and to reuse code of str_to_TIME() outside of
server).
Added 3rd parameter to set_warning() method to be able to not increment cut fields
but still produce a warning. Also added set_datetime_warning() family of auxiliary
methods which allow easier generate datetime related warnings.
Also replaced occurences of current_thd with table->in_use member, added
asserts for catching all places there we need to set table->in_use
accordingly. Renamed fix_datetime() function to number_to_TIME() and
moved it to sql/time.cc there it fits better.
sql/field.h:
Added comment about places where we can use table->in_use member
instead of current_thd.
Added 3rd parameter to Field::set_warning() method and set_datetime_warning()
family of methods.
sql/field_conv.cc:
Field::set_warning() method with 2 arguments was replaced with more
generic set_warning() method with 3 arguments.
sql/ha_berkeley.cc:
Now we set table->in_use for temporary tables so we have to use
table->tmp_table for checking if table is temporary.
sql/item.cc:
Replaced calls to str_to_time() and str_to_TIME() funcs with their warning
generating analogs.
sql/item_create.cc:
Added creation of CONVERT_TZ function as FUNC_ARG3.
sql/item_create.h:
Added creation of CONVERT_TZ function as FUNC_ARG3.
sql/item_timefunc.cc:
Added support of per-thread time zone to NOW-like and FROM_UNIXTIME,
UNIX_TIMESTAMP functions.
Added support for CONVERT_TZ function.
Removed call to str_to_timestamp function which caused non-optimal
behavior in certain cases. Replaced calls to str_to_time() function
with its warning generating analog.
sql/item_timefunc.h:
Added support of per-thread time zone to NOW-like and
FROM_UNIXTIME, UNIX_TIMESTAMP functions.
Added support of CONVERT_TZ function.
sql/lex.h:
Added support of CONVERT_TZ function.
sql/log.cc:
Added support for replication of statements depending on time zone.
sql/mysql_priv.h:
Now including headers with per-thread time zone support functions
and classes. Added portable replacement of time_t - my_time_t type.
Added time zone as one of query distinguishing parameters for
query cache.
Fixed declarations of str_to_TIME, str_to_time and
my_system_gmt_sec (former my_gmt_sec) since now they have one more
out parameter which informs about wrong datetime value or data
truncation during conversion.
Added warning generating version of str_to_TIME() and str_to_time()
functions.
Thrown away str_to_datetime/timestamp functions since they are not
needed any longer. Added number_to_TIME function.
sql/mysqld.cc:
Added per-thread time zone support initialization.
Added new startup parameter --default-time-zone.
sql/set_var.cc:
Added support for per-thread time_zone variable.
Renamed old timezone variable to system_time_zone.
sql/set_var.h:
Added support for per-thread time_zone variable.
sql/share/czech/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/danish/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/dutch/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/english/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/estonian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/french/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/german/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/greek/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/hungarian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/italian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/japanese/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/korean/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/norwegian-ny/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/norwegian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/polish/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/portuguese/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/romanian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/russian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/serbian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/slovak/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/spanish/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/swedish/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/share/ukrainian/errmsg.txt:
Added error message for barking when incorrect time zone name or
specifiaction is provided and for warning about invalid TIMESTAMP
values (e.g. falling into the spring time-gap).
sql/slave.cc:
In order to support replication of statements using time zones in 4.1 we should
ensure that both master and slave have same default time zone.
sql/sql_base.cc:
Now we are setting TABLE::in_use member for all tables (which assume
calls to Field::store or val_ methods).
sql/sql_cache.cc:
Added time zone as one more query distinguishing parameter
for query cache.
sql/sql_class.cc:
Added THD::time_zone_used variable indicating that this query
uses per thread time zone.
sql/sql_class.h:
Added per-thread time zone variable. Added THD::time_zone_used
variable indicating that this query uses per thread time zone
so if this is updating query the time zone should be logged to
binlog.
sql/sql_insert.cc:
We should set TABLE::in_use member pointing to thread which is called
INSERT DELAYED and not to worker thread.
sql/sql_load.cc:
Field::set_warning() now has one more argument now.
sql/sql_parse.cc:
Resetting THD::time_zone_used variable in the end of query
processing.
sql/sql_select.cc:
Now we are setting TABLE::in_use member for all tables (which assume
calls to Field::store or val_ methods).
sql/sql_show.cc:
Now using per thread time zone for extended show tables.
sql/time.cc:
Added support for per-thread time zones for TIMESTAMP type and
reworked generation of warnings for TIMESTAMP and DATETIME types.
(Introduced new TIME_to_timestamp() function. Removed hours
normalisation from former my_gmt_sec() since it was not working
and not used anywhere now, but breaks parameter constness, added
to this function generation of warning if we are falling in spring
time-gap. Removed str_to_timestamp and str_to_datetime functions
which are no longer used. Moved fix_datetime function from
sql/field.cc to this file as number_to_TIME() function. Added
out parameter for str_to_TIME and str_to_time functions which
indicates if value was truncated during conversion, removed direct
generation of warnings from this functions.)
sql/unireg.cc:
Now we are setting TABLE::in_use member for all tables (which assume
calls to Field::store or val_ methods).
BitKeeper/etc/ignore:
Added sql/test_time sql/mysql_tzinfo_to_sql libmysqld/tztime.cc to the ignore list
22 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago  Implementation of WL#2486 -
"Process NATURAL and USING joins according to SQL:2003".
* Some of the main problems fixed by the patch:
- in "select *" queries the * expanded correctly according to
ANSI for arbitrary natural/using joins
- natural/using joins are correctly transformed into JOIN ... ON
for any number/nesting of the joins.
- column references are correctly resolved against natural joins
of any nesting and combined with arbitrary other joins.
* This patch also contains a fix for name resolution of items
inside the ON condition of JOIN ... ON - in this case items must
be resolved only against the JOIN operands. To support such
'local' name resolution, the patch introduces a stack of
name resolution contexts used at parse time.
NOTICE:
- This patch is not complete in the sense that
- there are 2 test cases that still do not pass -
one in join.test, one in select.test. Both are marked
with a comment "TODO: WL#2486".
- it does not include a new test specific for the task
mysql-test/include/ps_query.inc:
Adjusted according to standard NATURAL/USING join semantics.,
mysql-test/r/bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/derived.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/errors.result:
The column as a whole cannot be resolved, so different error message.
mysql-test/r/fulltext.result:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/r/fulltext_order_by.result:
More detailed error message.
mysql-test/r/innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/r/insert_select.result:
More detailed error message.
mysql-test/r/join.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/r/join_crash.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_nested.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/join_outer.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/multi_update.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/null_key.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/order_by.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_2myisam.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_3innodb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_4heap.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_5merge.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_6bdb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/ps_7ndb.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/select.result:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one failing test case which is commented with
WL#2486 in the test file.
mysql-test/r/subselect.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/type_ranges.result:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/r/union.result:
More detailed error message.
mysql-test/t/bdb.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/errors.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/fulltext.test:
Adjusted according to standard JOIN ... ON semantics =>
the ON condition can refer only to the join operands.
mysql-test/t/fulltext_order_by.test:
More detailed error message.
mysql-test/t/innodb.test:
Adjusted according to standard NATURAL/USING join semantics.
This test doesn't pass completetly yet!
mysql-test/t/insert_select.test:
More detailed error message.
mysql-test/t/join.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/join_crash.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_nested.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/join_outer.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/null_key.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/order_by.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/select.test:
Adjusted according to standard NATURAL/USING join semantics.
NOTICE: there is one test case that still fails, and it is
commeted out and marked with WL#2486 in the test file.
mysql-test/t/subselect.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/type_ranges.test:
Adjusted according to standard NATURAL/USING join semantics.
mysql-test/t/union.test:
More detailed error message.
sql/item.cc:
- extra parameter to find_field_in_tables
- find_field_in_real_table renamed to find_field_in_table
- fixed comments/typos
sql/item.h:
- added [first | last]_name_resolution_table to class
Name_resolution_context
- commented old code
- standardized formatting
sql/mysql_priv.h:
- refactored the find_field_in_XXX procedures,
- added a new procedure for natural join table references,
- renamed the find_field_in_XXX procedures to clearer names
sql/sp.cc:
- pass the top-most list of the FROM clause to setup_tables
- extra parameter to find_field_in_tables
sql/sql_acl.cc:
- renamed find_field_in_table => find_field_in_table_ref
- extra parameter to find_field_in_table_ref
- commented old code
sql/sql_base.cc:
This file contains the core of the implementation of the processing
of NATURAL/USING joins (WL#2486).
- added many comments to old code
- refactored the group of find_field_in_XXX procedures, and added a
new procedure for natural joins. There is one find_field_in_XXX procedure
per each type of table reference (stored table, merge view, or natural
join); one meta-procedure that selects the correct one depeneding on the
table reference; and one procedure that goes over a list of table
referenes.
- NATURAL/USING joins are processed through the procedures:
mark_common_columns, store_natural_using_join_columns,
store_top_level_join_columns, setup_natural_join_row_types.
The entry point to processing NATURAL/USING joins is the
procedure 'setup_natural_join_row_types'.
- Replaced the specialized Field_iterator_XXX iterators with one
generic iterator over the fields of a table reference.
- Simplified 'insert_fields' and 'setup_conds' due to encapsulation of
the processing of natural joins in a separate set of procedures.
sql/sql_class.h:
- Commented old code.
sql/sql_delete.cc:
- Pass the FROM clause to setup_tables.
sql/sql_help.cc:
- pass the end name resolution table to find_field_in_tables
- adjust the list of tables for name resolution
sql/sql_insert.cc:
- Changed the code that saves and restores the current context to
support the list of tables for name resolution -
context->first_name_resolution_table, and
table_list->next_name_resolution_table.
Needed to support an ugly trick to resolve inserted columns only in
the first table.
- Added Name_resolution_context::[first | last]_name_resolution_table.
- Commented old code
sql/sql_lex.cc:
- set select_lex.parent_lex correctly
- set correct state of the current name resolution context
sql/sql_lex.h:
- Added a stack of name resolution contexts to support local
contexts for JOIN ... ON conditions.
- Commented old code.
sql/sql_load.cc:
- Pass the FROM clause to setup_tables.
sql/sql_olap.cc:
- Pass the FROM clause to setup_tables.
sql/sql_parse.cc:
- correctly set SELECT_LEX::parent_lex
- set the first table of the current name resoltion context
- added support for NATURAL/USING joins
- commented old code
sql/sql_select.cc:
- Pass the FROM clause to setup_tables.
- Pass the end table to find_field_in_tables
- Improved comments
sql/sql_show.cc:
- Set SELECT_LEX::parent_lex.
sql/sql_update.cc:
- Pass the FROM clause to setup_tables.
sql/sql_yacc.yy:
- Added support for a stack of name resolution contexts needed to
implement name resolution for JOIN ... ON. A context is pushed
for each new JOIN ... ON, and popped afterwards.
- Added support for NATURAL/USING joins.
sql/table.cc:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
sql/table.h:
- Added new class Natural_join_column to hide the heterogeneous
representation of column references for stored tables and for
views.
- Added a new list TABLE_LIST::next_name_resolution_table to
support name resolution with NATURAL/USING joins. Also added
other members to TABLE_LIST to support NATURAL/USING joins.
- Added a generic iterator over the fields of table references
of various types - class Field_iterator_table_ref
tests/mysql_client_test.c:
Adjusted according to standard NATURAL JOIN syntax.
21 years ago Bug#6298 (LIMIT #, -1 no longer works to set start with no end limit)
With MySQL 3.23 and 4.0, the syntax 'LIMIT N, -1' is accepted, and returns
all the rows located after row N. This behavior, however, is not the
intended result, and defeats the purpose of LIMIT, which is to constrain
the size of a result set.
With MySQL 4.1 and later, this construct is correctly detected as a syntax
error.
This fix does not change the production code, and only adds a new test case
to improve test coverage in this area, to enforce in the test suite the
intended behavior.
mysql-test/r/select.result:
Enforce that LIMIT N, -1 is illegal.
mysql-test/t/select.test:
Enforce that LIMIT N, -1 is illegal.
19 years ago |
|
drop table if exists t1,t2,t3,t4,t11;drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa;drop view if exists v1;CREATE TABLE t1 (Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL);INSERT INTO t1 VALUES (9410,9412);select period from t1;period9410select * from t1;Period Varor_period9410 9412select t1.* from t1;Period Varor_period9410 9412CREATE TABLE t2 (auto int not null auto_increment,fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,fld3 char(30) DEFAULT '' NOT NULL,fld4 char(35) DEFAULT '' NOT NULL,fld5 char(35) DEFAULT '' NOT NULL,fld6 char(4) DEFAULT '' NOT NULL,UNIQUE fld1 (fld1),KEY fld3 (fld3),PRIMARY KEY (auto));select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";fld3imaginableselect fld3 from t2 where fld3 like "%cultivation" ;fld3cultivationselect t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;fld3 companynrconcoct 58druggists 58engrossing 58Eurydice 58exclaimers 58ferociousness 58hopelessness 58Huey 58imaginable 58judges 58merging 58ostrich 58peering 58Phelps 58presumes 58Ruth 58sentences 58Shylock 58straggled 58synergy 58thanking 58tying 58unlocks 58select fld3,companynr from t2 where companynr = 58 order by fld3;fld3 companynrconcoct 58druggists 58engrossing 58Eurydice 58exclaimers 58ferociousness 58hopelessness 58Huey 58imaginable 58judges 58merging 58ostrich 58peering 58Phelps 58presumes 58Ruth 58sentences 58Shylock 58straggled 58synergy 58thanking 58tying 58unlocks 58select fld3 from t2 order by fld3 desc limit 10;fld3youthfulnessyelpedWotanworkersWittwitchcraftWinsettWillywilledwildcatsselect fld3 from t2 order by fld3 desc limit 5;fld3youthfulnessyelpedWotanworkersWittselect fld3 from t2 order by fld3 desc limit 5,5;fld3witchcraftWinsettWillywilledwildcatsselect t2.fld3 from t2 where fld3 = 'honeysuckle';fld3honeysuckleselect t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';fld3honeysuckleselect t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';fld3honeysuckleselect t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';fld3honeysuckleselect t2.fld3 from t2 where fld3 LIKE 'h%le';fld3honeysuckleselect t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';fld3select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';fld3explain select t2.fld3 from t2 where fld3 = 'honeysuckle';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using indexexplain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using whereexplain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using whereexplain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using indexexplain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using indexexplain select fld3 from t2 ignore index (fld3,not_used);ERROR 42000: Key 'not_used' doesn't exist in table 't2'explain select fld3 from t2 use index (not_used);ERROR 42000: Key 'not_used' doesn't exist in table 't2'select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;fld3honeysucklehonoringexplain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range fld3 fld3 30 NULL 2 Using where; Using indexselect fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;fld1 fld3148504 Colombo068305 Colombo000000 nondecreasingselect fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes';fld1 fld3232605 appendixes1232605 appendixes1232606 appendixes1232607 appendixes1232608 appendixes1232609 appendixesselect fld1 from t2 where fld1=250501 or fld1="250502";fld1250501250502explain select fld1 from t2 where fld1=250501 or fld1="250502";id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range fld1 fld1 4 NULL 2 Using where; Using indexselect fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;fld1250501250502250505250601explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range fld1 fld1 4 NULL 4 Using where; Using indexselect fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';fld1 fld3218401 faithful018007 fanatic228311 fated018017 featherweight218022 feed088303 feminine058004 Fenton038017 fetched018054 fetters208101 fiftieth238007 filial013606 fingerings218008 finishers038205 firearm188505 fitting202301 Fitzpatrick238008 fixedly012001 flanking018103 flint018104 flopping188007 flurried013602 foldout226205 foothill232102 forgivably228306 forthcoming186002 freakish208113 freest231315 freezes036002 funereal226209 furnishings198006 furthermoreselect fld3 from t2 where fld3 like "L%" and fld3 = "ok";fld3select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly");fld3Chantillyselect fld1,fld3 from t2 where fld1 like "25050%";fld1 fld3250501 poisoning250502 Iraqis250503 heaving250504 population250505 bombselect fld1,fld3 from t2 where fld1 like "25050_";fld1 fld3250501 poisoning250502 Iraqis250503 heaving250504 population250505 bombselect distinct companynr from t2;companynr003736505829405365413468select distinct companynr from t2 order by companynr;companynr002934363740415053586568select distinct companynr from t2 order by companynr desc;companynr686558535041403736342900select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";fld3 periodobliterates 9410offload 9410opaquely 9410organizer 9410overestimating 9410overlay 9410select distinct fld3 from t2 where companynr = 34 order by fld3;fld3absenteeaccessedaheadalphabeticAsiaticizationsattitudeayebankruptciesbelaysBlythebombboulevardbulldozescannotcaressingcharcoalchecksummingchessclubroomcolorfulcosycreatorcryingDariusdiffusingdualityEiffelEpiphanyErnestineexplorersexterminatedfamineforkedGershwinsheavingHodgesIraqisItalianizationLagoslandslidelibrettoMajorcamasteringnarrowedoccurredofferersPalestinePeruvianizespharmaceuticpoisoningpopulationPygmalionratsrealestrecordingregimentedretransmittingreviverrousesscarssickersleepwalkstoppedsugarstranslatableunclesunexpecteduprisingsversatilityvestselect distinct fld3 from t2 limit 10;fld3abatesabidingAbrahamabrogatingabsenteeabutaccessedaccruingaccumulatingaccuraciesselect distinct fld3 from t2 having fld3 like "A%" limit 10;fld3abatesabidingAbrahamabrogatingabsenteeabutaccessedaccruingaccumulatingaccuraciesselect distinct substring(fld3,1,3) from t2 where fld3 like "A%";substring(fld3,1,3)abaabiAbrabsabuaccacqacuAdeadjAdladmAdoadsadvaeraffafiaflafoagiaheaimairAldalgaliallalpalramaameammanaandaneAnganiAnnAntapiappaquAraarcArmarrArtAsiaskaspassastattaudAugautaveavoaweayeAztselect distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10;aabaabiAbrabsabuaccacqacuAdeadjselect distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10;substring(fld3,1,3)abaabiAbrabsabuaccacqacuAdeadjselect distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;aabaabiAbrabsabuaccacqacuAdeadjcreate table t3 (period int not null,name char(32) not null,companynr int not null,price double(11,0),price2 double(11,0),key (period),key (name));create temporary table tmp engine = myisam select * from t3;insert into t3 select * from tmp;insert into tmp select * from t3;insert into t3 select * from tmp;insert into tmp select * from t3;insert into t3 select * from tmp;insert into tmp select * from t3;insert into t3 select * from tmp;insert into tmp select * from t3;insert into t3 select * from tmp;insert into tmp select * from t3;insert into t3 select * from tmp;insert into tmp select * from t3;insert into t3 select * from tmp;insert into tmp select * from t3;insert into t3 select * from tmp;insert into tmp select * from t3;insert into t3 select * from tmp;alter table t3 add t2nr int not null auto_increment primary key first;drop table tmp;SET SQL_BIG_TABLES=1;select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10;namnAbraham Abrahamabrogating abrogatingadmonishing admonishingAdolph Adolphafield afieldaging agingammonium ammoniumanalyzable analyzableanimals animalsanimized animizedSET SQL_BIG_TABLES=0;select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10;concat(fld3," ",fld3)Abraham Abrahamabrogating abrogatingadmonishing admonishingAdolph Adolphafield afieldaging agingammonium ammoniumanalyzable analyzableanimals animalsanimized animizedselect distinct fld5 from t2 limit 10;fld5neatSteinbergjarringtinilyballedpersistattainmentsfanaticmeasuresrightfulnessselect distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;fld3 count(*)affixed 1and 1annoyers 1Anthony 1assayed 1assurers 1attendants 1bedlam 1bedpost 1boasted 1SET SQL_BIG_TABLES=1;select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;fld3 count(*)affixed 1and 1annoyers 1Anthony 1assayed 1assurers 1attendants 1bedlam 1bedpost 1boasted 1SET SQL_BIG_TABLES=0;select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10;fld3 repeat("a",length(fld3)) count(*)circus aaaaaa 1cited aaaaa 1Colombo aaaaaaa 1congresswoman aaaaaaaaaaaaa 1contrition aaaaaaaaaa 1corny aaaaa 1cultivation aaaaaaaaaaa 1definiteness aaaaaaaaaaaa 1demultiplex aaaaaaaaaaa 1disappointing aaaaaaaaaaaaa 1select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2;companynr rtrim(space(512+companynr))37 78 101 154 311 447 512 select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3;fld3explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using indexexplain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1;period9410select period from t1 where period=1900;periodselect fld3,period from t1,t2 where fld1 = 011401 order by period;fld3 periodbreaking 9410select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;fld3 periodbreaking 1001explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 const fld1 fld1 4 const 1 1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1 select fld3,period from t2,t1 where companynr*10 = 37*10;fld3 periodbreaking 9410Romans 9410intercepted 9410bewilderingly 9410astound 9410admonishing 9410sumac 9410flanking 9410combed 9410subjective 9410scatterbrain 9410Eulerian 9410Kane 9410overlay 9410perturb 9410goblins 9410annihilates 9410Wotan 9410snatching 9410concludes 9410laterally 9410yelped 9410grazing 9410Baird 9410celery 9410misunderstander 9410handgun 9410foldout 9410mystic 9410succumbed 9410Nabisco 9410fingerings 9410aging 9410afield 9410ammonium 9410boat 9410intelligibility 9410Augustine 9410teethe 9410dreaded 9410scholastics 9410audiology 9410wallet 9410parters 9410eschew 9410quitter 9410neat 9410Steinberg 9410jarring 9410tinily 9410balled 9410persist 9410attainments 9410fanatic 9410measures 9410rightfulness 9410capably 9410impulsive 9410starlet 9410terminators 9410untying 9410announces 9410featherweight 9410pessimist 9410daughter 9410decliner 9410lawgiver 9410stated 9410readable 9410attrition 9410cascade 9410motors 9410interrogate 9410pests 9410stairway 9410dopers 9410testicle 9410Parsifal 9410leavings 9410postulation 9410squeaking 9410contrasted 9410leftover 9410whiteners 9410erases 9410Punjab 9410Merritt 9410Quixotism 9410sweetish 9410dogging 9410scornfully 9410bellow 9410bills 9410cupboard 9410sureties 9410puddings 9410fetters 9410bivalves 9410incurring 9410Adolph 9410pithed 9410Miles 9410trimmings 9410tragedies 9410skulking 9410flint 9410flopping 9410relaxing 9410offload 9410suites 9410lists 9410animized 9410multilayer 9410standardizes 9410Judas 9410vacuuming 9410dentally 9410humanness 9410inch 9410Weissmuller 9410irresponsibly 9410luckily 9410culled 9410medical 9410bloodbath 9410subschema 9410animals 9410Micronesia 9410repetitions 9410Antares 9410ventilate 9410pityingly 9410interdependent 9410Graves 9410neonatal 9410chafe 9410honoring 9410realtor 9410elite 9410funereal 9410abrogating 9410sorters 9410Conley 9410lectured 9410Abraham 9410Hawaii 9410cage 9410hushes 9410Simla 9410reporters 9410Dutchman 9410descendants 9410groupings 9410dissociate 9410coexist 9410Beebe 9410Taoism 9410Connally 9410fetched 9410checkpoints 9410rusting 9410galling 9410obliterates 9410traitor 9410resumes 9410analyzable 9410terminator 9410gritty 9410firearm 9410minima 9410Selfridge 9410disable 9410witchcraft 9410betroth 9410Manhattanize 9410imprint 9410peeked 9410swelling 9410interrelationships 9410riser 9410Gandhian 9410peacock 9410bee 9410kanji 9410dental 9410scarf 9410chasm 9410insolence 9410syndicate 9410alike 9410imperial 9410convulsion 9410railway 9410validate 9410normalizes 9410comprehensive 9410chewing 9410denizen 9410schemer 9410chronicle 9410Kline 9410Anatole 9410partridges 9410brunch 9410recruited 9410dimensions 9410Chicana 9410announced 9410praised 9410employing 9410linear 9410quagmire 9410western 9410relishing 9410serving 9410scheduling 9410lore 9410eventful 9410arteriole 9410disentangle 9410cured 9410Fenton 9410avoidable 9410drains 9410detectably 9410husky 9410impelling 9410undoes 9410evened 9410squeezes 9410destroyer 9410rudeness 9410beaner 9410boorish 9410Everhart 9410encompass 9410mushrooms 9410Alison 9410externally 9410pellagra 9410cult 9410creek 9410Huffman 9410Majorca 9410governing 9410gadfly 9410reassigned 9410intentness 9410craziness 9410psychic 9410squabbled 9410burlesque 9410capped 9410extracted 9410DiMaggio 9410exclamation 9410subdirectory 9410Gothicism 9410feminine 9410metaphysically 9410sanding 9410Miltonism 9410freakish 9410index 9410straight 9410flurried 9410denotative 9410coming 9410commencements 9410gentleman 9410gifted 9410Shanghais 9410sportswriting 9410sloping 9410navies 9410leaflet 9410shooter 9410Joplin 9410babies 9410assails 9410admiring 9410swaying 9410Goldstine 9410fitting 9410Norwalk 9410analogy 9410deludes 9410cokes 9410Clayton 9410exhausts 9410causality 9410sating 9410icon 9410throttles 9410communicants 9410dehydrate 9410priceless 9410publicly 9410incidentals 9410commonplace 9410mumbles 9410furthermore 9410cautioned 9410parametrized 9410registration 9410sadly 9410positioning 9410babysitting 9410eternal 9410hoarder 9410congregates 9410rains 9410workers 9410sags 9410unplug 9410garage 9410boulder 9410specifics 9410Teresa 9410Winsett 9410convenient 9410buckboards 9410amenities 9410resplendent 9410sews 9410participated 9410Simon 9410certificates 9410Fitzpatrick 9410Evanston 9410misted 9410textures 9410save 9410count 9410rightful 9410chaperone 9410Lizzy 9410clenched 9410effortlessly 9410accessed 9410beaters 9410Hornblower 9410vests 9410indulgences 9410infallibly 9410unwilling 9410excrete 9410spools 9410crunches 9410overestimating 9410ineffective 9410humiliation 9410sophomore 9410star 9410rifles 9410dialysis 9410arriving 9410indulge 9410clockers 9410languages 9410Antarctica 9410percentage 9410ceiling 9410specification 9410regimented 9410ciphers 9410pictures 9410serpents 9410allot 9410realized 9410mayoral 9410opaquely 9410hostess 9410fiftieth 9410incorrectly 9410decomposition 9410stranglings 9410mixture 9410electroencephalography 9410similarities 9410charges 9410freest 9410Greenberg 9410tinting 9410expelled 9410warm 9410smoothed 9410deductions 9410Romano 9410bitterroot 9410corset 9410securing 9410environing 9410cute 9410Crays 9410heiress 9410inform 9410avenge 9410universals 9410Kinsey 9410ravines 9410bestseller 9410equilibrium 9410extents 9410relatively 9410pressure 9410critiques 9410befouled 9410rightfully 9410mechanizing 9410Latinizes 9410timesharing 9410Aden 9410embassies 9410males 9410shapelessly 9410mastering 9410Newtonian 9410finishers 9410abates 9410teem 9410kiting 9410stodgy 9410feed 9410guitars 9410airships 9410store 9410denounces 9410Pyle 9410Saxony 9410serializations 9410Peruvian 9410taxonomically 9410kingdom 9410stint 9410Sault 9410faithful 9410Ganymede 9410tidiness 9410gainful 9410contrary 9410Tipperary 9410tropics 9410theorizers 9410renew 9410already 9410terminal 9410Hegelian 9410hypothesizer 9410warningly 9410journalizing 9410nested 9410Lars 9410saplings 9410foothill 9410labeled 9410imperiously 9410reporters 9410furnishings 9410precipitable 9410discounts 9410excises 9410Stalin 9410despot 9410ripeness 9410Arabia 9410unruly 9410mournfulness 9410boom 9410slaughter 9410Sabine 9410handy 9410rural 9410organizer 9410shipyard 9410civics 9410inaccuracy 9410rules 9410juveniles 9410comprised 9410investigations 9410stabilizes 9410seminaries 9410Hunter 9410sporty 9410test 9410weasels 9410CERN 9410tempering 9410afore 9410Galatean 9410techniques 9410error 9410veranda 9410severely 9410Cassites 9410forthcoming 9410guides 9410vanish 9410lied 9410sawtooth 9410fated 9410gradually 9410widens 9410preclude 9410evenhandedly 9410percentage 9410disobedience 9410humility 9410gleaning 9410petted 9410bloater 9410minion 9410marginal 9410apiary 9410measures 9410precaution 9410repelled 9410primary 9410coverings 9410Artemia 9410navigate 9410spatial 9410Gurkha 9410meanwhile 9410Melinda 9410Butterfield 9410Aldrich 9410previewing 9410glut 9410unaffected 9410inmate 9410mineral 9410impending 9410meditation 9410ideas 9410miniaturizes 9410lewdly 9410title 9410youthfulness 9410creak 9410Chippewa 9410clamored 9410freezes 9410forgivably 9410reduce 9410McGovern 9410Nazis 9410epistle 9410socializes 9410conceptions 9410Kevin 9410uncovering 9410chews 9410appendixes 9410appendixes 9410appendixes 9410appendixes 9410appendixes 9410appendixes 9410raining 9410infest 9410compartment 9410minting 9410ducks 9410roped 9410waltz 9410Lillian 9410repressions 9410chillingly 9410noncritical 9410lithograph 9410spongers 9410parenthood 9410posed 9410instruments 9410filial 9410fixedly 9410relives 9410Pandora 9410watering 9410ungrateful 9410secures 9410poison 9410dusted 9410encompasses 9410presentation 9410Kantian 9410select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;fld3 period price price2admonishing 1002 28357832 8723648analyzable 1002 28357832 8723648annihilates 1001 5987435 234724Antares 1002 28357832 8723648astound 1001 5987435 234724audiology 1001 5987435 234724Augustine 1002 28357832 8723648Baird 1002 28357832 8723648bewilderingly 1001 5987435 234724breaking 1001 5987435 234724Conley 1001 5987435 234724dentally 1002 28357832 8723648dissociate 1002 28357832 8723648elite 1001 5987435 234724eschew 1001 5987435 234724Eulerian 1001 5987435 234724flanking 1001 5987435 234724foldout 1002 28357832 8723648funereal 1002 28357832 8723648galling 1002 28357832 8723648Graves 1001 5987435 234724grazing 1001 5987435 234724groupings 1001 5987435 234724handgun 1001 5987435 234724humility 1002 28357832 8723648impulsive 1002 28357832 8723648inch 1001 5987435 234724intelligibility 1001 5987435 234724jarring 1001 5987435 234724lawgiver 1001 5987435 234724lectured 1002 28357832 8723648Merritt 1002 28357832 8723648neonatal 1001 5987435 234724offload 1002 28357832 8723648parters 1002 28357832 8723648pityingly 1002 28357832 8723648puddings 1002 28357832 8723648Punjab 1001 5987435 234724quitter 1002 28357832 8723648realtor 1001 5987435 234724relaxing 1001 5987435 234724repetitions 1001 5987435 234724resumes 1001 5987435 234724Romans 1002 28357832 8723648rusting 1001 5987435 234724scholastics 1001 5987435 234724skulking 1002 28357832 8723648stated 1002 28357832 8723648suites 1002 28357832 8723648sureties 1001 5987435 234724testicle 1002 28357832 8723648tinily 1002 28357832 8723648tragedies 1001 5987435 234724trimmings 1001 5987435 234724vacuuming 1001 5987435 234724ventilate 1001 5987435 234724wallet 1001 5987435 234724Weissmuller 1002 28357832 8723648Wotan 1002 28357832 8723648select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;fld1 fld3 period price price2018201 relaxing 1001 5987435 234724018601 vacuuming 1001 5987435 234724018801 inch 1001 5987435 234724018811 repetitions 1001 5987435 234724create table t4 (companynr tinyint(2) unsigned zerofill NOT NULL default '00',companyname char(30) NOT NULL default '',PRIMARY KEY (companynr),UNIQUE KEY companyname(companyname)) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;companynr companyname00 Unknown29 company 134 company 236 company 337 company 440 company 541 company 650 company 1153 company 758 company 865 company 968 company 10select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;companynr companyname00 Unknown29 company 134 company 236 company 337 company 440 company 541 company 650 company 1153 company 758 company 865 company 968 company 10select * from t1,t1 t12;Period Varor_period Period Varor_period9410 9412 9410 9412select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;fld1 fld1250501 250501250502 250501250503 250501250504 250501250505 250501250501 250502250502 250502250503 250502250504 250502250505 250502250501 250503250502 250503250503 250503250504 250503250505 250503250501 250504250502 250504250503 250504250504 250504250505 250504250501 250505250502 250505250503 250505250504 250505250505 250505insert into t2 (fld1, companynr) values (999999,99);select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;companynr companyname99 NULLselect count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;count(*)1199explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not existsexplain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL NULL NULL NULL NULL 12 1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not existsselect companynr,companyname from t2 left join t4 using (companynr) where companynr is null;companynr companynameselect count(*) from t2 left join t4 using (companynr) where companynr is not null;count(*)1200explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHEREexplain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHEREdelete from t2 where fld1=999999;explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL NULL NULL NULL NULL 12 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using whereexplain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using whereexplain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL NULL NULL NULL NULL 12 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using whereexplain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;companynr companynr37 3641 40explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join bufferselect t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;fld1 companynr fld3 period038008 37 reporters 1008038208 37 Selfridge 1008select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;fld1 companynr fld3 period038008 37 reporters 1008038208 37 Selfridge 1008select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;fld1 companynr fld3 period038008 37 reporters 1008038208 37 Selfridge 1008select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);period9410select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));period9410select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;fld1250501250502250503250505select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606);fld1250502250503select fld1 from t2 where fld1 between 250502 and 250504;fld1250502250503250504select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ;fld3labellabeledlabeledlandslidelaterallyleafletlewdlyLillianluckilyselect count(*) from t1;count(*)1select companynr,count(*),sum(fld1) from t2 group by companynr;companynr count(*) sum(fld1)00 82 1035575329 95 1447329834 70 1778896636 215 2278629637 588 8360209840 37 661838641 52 1281633550 11 159543853 4 79321058 23 225429365 10 228405568 12 3097288select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;companynr count(*)68 1265 1058 2353 450 11select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using whereWarnings:Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where ((`test`.`t2`.`companynr` = 34) and (`test`.`t2`.`fld4` <> ''))select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.708729 95 abut wetness 14473298 152350.5053 8368.5480 70032594.902634 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;companynr t2nr count(price) sum(price) min(price) max(price) avg(price)37 1 1 5987435 5987435 5987435 5987435.000037 2 1 28357832 28357832 28357832 28357832.000037 3 1 39654943 39654943 39654943 39654943.000037 11 1 5987435 5987435 5987435 5987435.000037 12 1 28357832 28357832 28357832 28357832.000037 13 1 39654943 39654943 39654943 39654943.000037 21 1 5987435 5987435 5987435 5987435.000037 22 1 28357832 28357832 28357832 28357832.000037 23 1 39654943 39654943 39654943 39654943.000037 31 1 5987435 5987435 5987435 5987435.0000select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;companynr t2nr count(price) sum(price) min(price) max(price) avg(price)37 1 1 5987435 5987435 5987435 5987435.000037 2 1 28357832 28357832 28357832 28357832.000037 3 1 39654943 39654943 39654943 39654943.000037 11 1 5987435 5987435 5987435 5987435.000037 12 1 28357832 28357832 28357832 28357832.000037 13 1 39654943 39654943 39654943 39654943.000037 21 1 5987435 5987435 5987435 5987435.000037 22 1 28357832 28357832 28357832 28357832.000037 23 1 39654943 39654943 39654943 39654943.000037 31 1 5987435 5987435 5987435 5987435.0000select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ;companynr count(price) sum(price) min(price) max(price) avg(price)37 12543 309394878010 5987435 39654943 24666736.666778 8362 414611089292 726498 98439034 49582766.0000101 4181 3489454238 834598 834598 834598.0000154 4181 4112197254950 983543950 983543950 983543950.0000311 4181 979599938 234298 234298 234298.0000447 4181 9929180954 2374834 2374834 2374834.0000512 4181 3288532102 786542 786542 786542.0000select distinct mod(companynr,10) from t4 group by companynr;mod(companynr,10)094671385select distinct 1 from t4 group by companynr;11select count(distinct fld1) from t2;count(distinct fld1)1199select companynr,count(distinct fld1) from t2 group by companynr;companynr count(distinct fld1)00 8229 9534 7036 21537 58840 3741 5250 1153 458 2365 1068 12select companynr,count(*) from t2 group by companynr;companynr count(*)00 8229 9534 7036 21537 58840 3741 5250 1153 458 2365 1068 12select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr;companynr count(distinct concat(fld1,repeat(65,1000)))00 8229 9534 7036 21537 58840 3741 5250 1153 458 2365 1068 12select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr;companynr count(distinct concat(fld1,repeat(65,200)))00 8229 9534 7036 21537 58840 3741 5250 1153 458 2365 1068 12select companynr,count(distinct floor(fld1/100)) from t2 group by companynr;companynr count(distinct floor(fld1/100))00 4729 3534 1436 6937 10840 1641 1150 953 158 165 168 1select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr;companynr count(distinct concat(repeat(65,1000),floor(fld1/100)))00 4729 3534 1436 6937 10840 1641 1150 953 158 165 168 1select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10;sum(fld1) fld311402 Romansselect name,count(*) from t3 where name='cloakroom' group by name;name count(*)cloakroom 4181select name,count(*) from t3 where name='cloakroom' and price>10 group by name;name count(*)cloakroom 4181select count(*) from t3 where name='cloakroom' and price2=823742;count(*)4181select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name;name count(*)cloakroom 4181select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name;name count(*)extramarital 4181gazer 4181gems 4181Iranizes 4181spates 4181tucked 4181violinist 4181select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;fld3 count(*)spates 4181select companynr|0,companyname from t4 group by 1;companynr|0 companyname0 Unknown29 company 134 company 236 company 337 company 440 company 541 company 650 company 1153 company 758 company 865 company 968 company 10select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname;companynr companyname count(*)29 company 1 9568 company 10 1250 company 11 1134 company 2 7036 company 3 21537 company 4 58840 company 5 3741 company 6 5253 company 7 458 company 8 2365 company 9 1000 Unknown 82select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;fld1 count(*)158402 4181select sum(Period)/count(*) from t1;sum(Period)/count(*)9410.0000select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;companynr count sum diff func37 12543 309394878010 0.0000 46409178 8362 414611089292 0.0000 652236101 4181 3489454238 0.0000 422281154 4181 4112197254950 0.0000 643874311 4181 979599938 0.0000 1300291447 4181 9929180954 0.0000 1868907512 4181 3288532102 0.0000 2140672select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg;companynr avg154 983543950.0000select companynr,count(*) from t2 group by companynr order by 2 desc;companynr count(*)37 58836 21529 9500 8234 7041 5240 3758 2368 1250 1165 1053 4select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc;companynr count(*)41 5258 2368 1250 1165 1053 4select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4;fld4 fld1 count(price) sum(price) min(price) max(price) avg(price)teethe 000001 1 5987435 5987435 5987435 5987435.0000dreaded 011401 1 5987435 5987435 5987435 5987435.0000scholastics 011402 1 28357832 28357832 28357832 28357832.0000audiology 011403 1 39654943 39654943 39654943 39654943.0000wallet 011501 1 5987435 5987435 5987435 5987435.0000parters 011701 1 5987435 5987435 5987435 5987435.0000eschew 011702 1 28357832 28357832 28357832 28357832.0000quitter 011703 1 39654943 39654943 39654943 39654943.0000neat 012001 1 5987435 5987435 5987435 5987435.0000Steinberg 012003 1 39654943 39654943 39654943 39654943.0000balled 012301 1 5987435 5987435 5987435 5987435.0000persist 012302 1 28357832 28357832 28357832 28357832.0000attainments 012303 1 39654943 39654943 39654943 39654943.0000capably 012501 1 5987435 5987435 5987435 5987435.0000impulsive 012602 1 28357832 28357832 28357832 28357832.0000starlet 012603 1 39654943 39654943 39654943 39654943.0000featherweight 012701 1 5987435 5987435 5987435 5987435.0000pessimist 012702 1 28357832 28357832 28357832 28357832.0000daughter 012703 1 39654943 39654943 39654943 39654943.0000lawgiver 013601 1 5987435 5987435 5987435 5987435.0000stated 013602 1 28357832 28357832 28357832 28357832.0000readable 013603 1 39654943 39654943 39654943 39654943.0000testicle 013801 1 5987435 5987435 5987435 5987435.0000Parsifal 013802 1 28357832 28357832 28357832 28357832.0000leavings 013803 1 39654943 39654943 39654943 39654943.0000squeaking 013901 1 5987435 5987435 5987435 5987435.0000contrasted 016001 1 5987435 5987435 5987435 5987435.0000leftover 016201 1 5987435 5987435 5987435 5987435.0000whiteners 016202 1 28357832 28357832 28357832 28357832.0000erases 016301 1 5987435 5987435 5987435 5987435.0000Punjab 016302 1 28357832 28357832 28357832 28357832.0000Merritt 016303 1 39654943 39654943 39654943 39654943.0000sweetish 018001 1 5987435 5987435 5987435 5987435.0000dogging 018002 1 28357832 28357832 28357832 28357832.0000scornfully 018003 1 39654943 39654943 39654943 39654943.0000fetters 018012 1 28357832 28357832 28357832 28357832.0000bivalves 018013 1 39654943 39654943 39654943 39654943.0000skulking 018021 1 5987435 5987435 5987435 5987435.0000flint 018022 1 28357832 28357832 28357832 28357832.0000flopping 018023 1 39654943 39654943 39654943 39654943.0000Judas 018032 1 28357832 28357832 28357832 28357832.0000vacuuming 018033 1 39654943 39654943 39654943 39654943.0000medical 018041 1 5987435 5987435 5987435 5987435.0000bloodbath 018042 1 28357832 28357832 28357832 28357832.0000subschema 018043 1 39654943 39654943 39654943 39654943.0000interdependent 018051 1 5987435 5987435 5987435 5987435.0000Graves 018052 1 28357832 28357832 28357832 28357832.0000neonatal 018053 1 39654943 39654943 39654943 39654943.0000sorters 018061 1 5987435 5987435 5987435 5987435.0000epistle 018062 1 28357832 28357832 28357832 28357832.0000Conley 018101 1 5987435 5987435 5987435 5987435.0000lectured 018102 1 28357832 28357832 28357832 28357832.0000Abraham 018103 1 39654943 39654943 39654943 39654943.0000cage 018201 1 5987435 5987435 5987435 5987435.0000hushes 018202 1 28357832 28357832 28357832 28357832.0000Simla 018402 1 28357832 28357832 28357832 28357832.0000reporters 018403 1 39654943 39654943 39654943 39654943.0000coexist 018601 1 5987435 5987435 5987435 5987435.0000Beebe 018602 1 28357832 28357832 28357832 28357832.0000Taoism 018603 1 39654943 39654943 39654943 39654943.0000Connally 018801 1 5987435 5987435 5987435 5987435.0000fetched 018802 1 28357832 28357832 28357832 28357832.0000checkpoints 018803 1 39654943 39654943 39654943 39654943.0000gritty 018811 1 5987435 5987435 5987435 5987435.0000firearm 018812 1 28357832 28357832 28357832 28357832.0000minima 019101 1 5987435 5987435 5987435 5987435.0000Selfridge 019102 1 28357832 28357832 28357832 28357832.0000disable 019103 1 39654943 39654943 39654943 39654943.0000witchcraft 019201 1 5987435 5987435 5987435 5987435.0000betroth 030501 1 5987435 5987435 5987435 5987435.0000Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000imprint 030503 1 39654943 39654943 39654943 39654943.0000swelling 031901 1 5987435 5987435 5987435 5987435.0000interrelationships 036001 1 5987435 5987435 5987435 5987435.0000riser 036002 1 28357832 28357832 28357832 28357832.0000bee 038001 1 5987435 5987435 5987435 5987435.0000kanji 038002 1 28357832 28357832 28357832 28357832.0000dental 038003 1 39654943 39654943 39654943 39654943.0000railway 038011 1 5987435 5987435 5987435 5987435.0000validate 038012 1 28357832 28357832 28357832 28357832.0000normalizes 038013 1 39654943 39654943 39654943 39654943.0000Kline 038101 1 5987435 5987435 5987435 5987435.0000Anatole 038102 1 28357832 28357832 28357832 28357832.0000partridges 038103 1 39654943 39654943 39654943 39654943.0000recruited 038201 1 5987435 5987435 5987435 5987435.0000dimensions 038202 1 28357832 28357832 28357832 28357832.0000Chicana 038203 1 39654943 39654943 39654943 39654943.0000select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3;companynr fld3 sum(price)512 boat 786542512 capably 786542512 cupboard 786542512 decliner 786542512 descendants 786542512 dopers 786542512 erases 786542512 Micronesia 786542512 Miles 786542512 skies 786542select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr;companynr count(*) min(fld3) max(fld3) sum(price) avg(price)00 1 Omaha Omaha 5987435 5987435.000036 1 dubbed dubbed 28357832 28357832.000037 83 Abraham Wotan 1908978016 22999735.132550 2 scribbled tapestry 68012775 34006387.5000select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1;t3.companynr+0 t2nr fld3 sum(price)37 1 Omaha 598743537 11401 breaking 598743537 11402 Romans 2835783237 11403 intercepted 3965494337 11501 bewilderingly 598743537 11701 astound 598743537 11702 admonishing 2835783237 11703 sumac 3965494337 12001 flanking 598743537 12003 combed 3965494337 12301 Eulerian 598743537 12302 dubbed 2835783237 12303 Kane 3965494337 12501 annihilates 598743537 12602 Wotan 2835783237 12603 snatching 3965494337 12701 grazing 598743537 12702 Baird 2835783237 12703 celery 3965494337 13601 handgun 598743537 13602 foldout 2835783237 13603 mystic 3965494337 13801 intelligibility 598743537 13802 Augustine 2835783237 13803 teethe 3965494337 13901 scholastics 598743537 16001 audiology 598743537 16201 wallet 598743537 16202 parters 2835783237 16301 eschew 598743537 16302 quitter 2835783237 16303 neat 3965494337 18001 jarring 598743537 18002 tinily 2835783237 18003 balled 3965494337 18012 impulsive 2835783237 18013 starlet 3965494337 18021 lawgiver 598743537 18022 stated 2835783237 18023 readable 3965494337 18032 testicle 2835783237 18033 Parsifal 3965494337 18041 Punjab 598743537 18042 Merritt 2835783237 18043 Quixotism 3965494337 18051 sureties 598743537 18052 puddings 2835783237 18053 tapestry 3965494337 18061 trimmings 598743537 18062 humility 2835783237 18101 tragedies 598743537 18102 skulking 2835783237 18103 flint 3965494337 18201 relaxing 598743537 18202 offload 2835783237 18402 suites 2835783237 18403 lists 3965494337 18601 vacuuming 598743537 18602 dentally 2835783237 18603 humanness 3965494337 18801 inch 598743537 18802 Weissmuller 2835783237 18803 irresponsibly 3965494337 18811 repetitions 598743537 18812 Antares 2835783237 19101 ventilate 598743537 19102 pityingly 2835783237 19103 interdependent 3965494337 19201 Graves 598743537 30501 neonatal 598743537 30502 scribbled 2835783237 30503 chafe 3965494337 31901 realtor 598743537 36001 elite 598743537 36002 funereal 2835783237 38001 Conley 598743537 38002 lectured 2835783237 38003 Abraham 3965494337 38011 groupings 598743537 38012 dissociate 2835783237 38013 coexist 3965494337 38101 rusting 598743537 38102 galling 2835783237 38103 obliterates 3965494337 38201 resumes 598743537 38202 analyzable 2835783237 38203 terminator 39654943select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008;sum(price)234298select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1;fld1 sum(price)038008 234298explain select fld3 from t2 where 1>2 or 2>3;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHEREexplain select fld3 from t2 where fld1=fld1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502;companynr fld134 25050134 250502select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502;companynr fld134 25050134 250502select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000;companynr count sum00 82 1035575329 95 1447329834 70 1778896637 588 8360209841 52 12816335select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ;companynr0029343741select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40;companynr companyname count(*)68 company 10 1250 company 11 1140 company 5 3741 company 6 5253 company 7 458 company 8 2365 company 9 10select count(*) from t2;count(*)1199select count(*) from t2 where fld1 < 098024;count(*)387select min(fld1) from t2 where fld1>= 098024;min(fld1)98024select max(fld1) from t2 where fld1>= 098024;max(fld1)1232609select count(*) from t3 where price2=76234234;count(*)4181select count(*) from t3 where companynr=512 and price2=76234234;count(*)4181explain select min(fld1),max(fld1),count(*) from t2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized awayselect min(fld1),max(fld1),count(*) from t2;min(fld1) max(fld1) count(*)0 1232609 1199select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742;min(t2nr) max(t2nr)2115 2115select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78;count(*) min(t2nr) max(t2nr)4181 4 41804select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20;t2nr count(*)9 119 129 139 149 159 169 179 189 199 1109 1119 1129 1139 1149 1159 1169 1179 1189 1199 1select max(t2nr) from t3 where price=983543950;max(t2nr)41807select t1.period from t3 = t1 limit 1;period1001select t1.period from t1 as t1 limit 1;period9410select t1.period as "Nuvarande period" from t1 as t1 limit 1;Nuvarande period9410select period as ok_period from t1 limit 1;ok_period9410select period as ok_period from t1 group by ok_period limit 1;ok_period9410select 1+1 as summa from t1 group by summa limit 1;summa2select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;Nuvarande period9410show tables;Tables_in_testt1t2t3t4show tables from test like "s%";Tables_in_test (s%)show tables from test like "t?";Tables_in_test (t?)show full columns from t2;Field Type Collation Null Key Default Extra Privileges Commentauto int(11) NULL NO PRI NULL auto_increment # fld1 int(6) unsigned zerofill NULL NO UNI 000000 # companynr tinyint(2) unsigned zerofill NULL NO 00 # fld3 char(30) latin1_swedish_ci NO MUL # fld4 char(35) latin1_swedish_ci NO # fld5 char(35) latin1_swedish_ci NO # fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 'f%';Field Type Collation Null Key Default Extra Privileges Commentfld1 int(6) unsigned zerofill NULL NO UNI 000000 # fld3 char(30) latin1_swedish_ci NO MUL # fld4 char(35) latin1_swedish_ci NO # fld5 char(35) latin1_swedish_ci NO # fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%';Field Type Collation Null Key Default Extra Privileges Commentshow keys from t2;Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Commentt2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE t2 1 fld3 1 fld3 A NULL NULL NULL BTREE drop table t4, t3, t2, t1;DO 1;DO benchmark(100,1+1),1,1;do default;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1do foobar;ERROR 42S22: Unknown column 'foobar' in 'field list'CREATE TABLE t1 (id mediumint(8) unsigned NOT NULL auto_increment,pseudo varchar(35) NOT NULL default '',PRIMARY KEY (id),UNIQUE KEY pseudo (pseudo));INSERT INTO t1 (pseudo) VALUES ('test');INSERT INTO t1 (pseudo) VALUES ('test1');SELECT 1 as rnd1 from t1 where rand() > 2;rnd1DROP TABLE t1;CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM;INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM;INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;gvid the_success the_fail the_size the_timeWarnings:Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;gvid the_success the_fail the_size the_timeDROP TABLE t1,t2;create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0');INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093);select wss_type from t1 where wss_type ='102935229216544106';wss_typeselect wss_type from t1 where wss_type ='102935229216544105';wss_typeselect wss_type from t1 where wss_type ='102935229216544104';wss_typeselect wss_type from t1 where wss_type ='102935229216544093';wss_type102935229216544093select wss_type from t1 where wss_type =102935229216544093;wss_type102935229216544093drop table t1;select 1+2,"aaaa",3.13*2.0 into @a,@b,@c;select @a;@a3select @b;@baaaaselect @c;@c6.260create table t1 (a int not null auto_increment primary key);insert into t1 values ();insert into t1 values ();insert into t1 values ();select * from (t1 as t2 left join t1 as t3 using (a)), t1;a a1 12 13 11 22 23 21 32 33 3select * from t1, (t1 as t2 left join t1 as t3 using (a));a a1 12 13 11 22 23 21 32 33 3select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1;a a1 12 13 11 22 23 21 32 33 3select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a));a a1 12 13 11 22 23 21 32 33 3select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1;a a1 22 23 21 32 33 3select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;a a2 13 12 23 22 33 3select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a );a123select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a );a123select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1;a a1 21 32 22 33 23 3select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;a a1 NULL2 12 22 33 13 23 3select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a );a123select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a );a123select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;a123select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));a123select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;a aNULL 11 22 23 21 32 33 3select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;a a2 13 12 23 22 33 3select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );a123select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a );a123select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1;a123select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a));a123select * from t1 natural join (t1 as t2 left join t1 as t3 using (a));a123select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;a123drop table t1;CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) ENGINE=MyISAM;INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522);CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=MyISAM;INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522);select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5;aa id t2_id id2 8299 2517 25173 8301 2518 25184 8302 2519 25195 8303 2520 25206 8304 2521 2521drop table t1,t2;create table t1 (id1 int NOT NULL);create table t2 (id2 int NOT NULL);create table t3 (id3 int NOT NULL);create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4));insert into t1 values (1);insert into t1 values (2);insert into t2 values (1);insert into t4 values (1,1);explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3left join t4 on id3 = id4 where id2 = 1 or id4 = 1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t3 system NULL NULL NULL NULL 0 const row not found1 SIMPLE t4 const id4 NULL NULL NULL 1 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using whereselect * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3left join t4 on id3 = id4 where id2 = 1 or id4 = 1;id1 id2 id3 id4 id441 1 NULL NULL NULLdrop table t1,t2,t3,t4;create table t1(s varchar(10) not null);create table t2(s varchar(10) not null primary key);create table t3(s varchar(10) not null primary key);insert into t1 values ('one\t'), ('two\t');insert into t2 values ('one\r'), ('two\t');insert into t3 values ('one '), ('two\t');select * from t1 where s = 'one';sselect * from t2 where s = 'one';sselect * from t3 where s = 'one';sone select * from t1,t2 where t1.s = t2.s;s stwo two select * from t2,t3 where t2.s = t3.s;s stwo two drop table t1, t2, t3;create table t1 (a integer, b integer, index(a), index(b));create table t2 (c integer, d integer, index(c), index(d));insert into t1 values (1,2), (2,2), (3,2), (4,2);insert into t2 values (1,3), (2,3), (3,4), (4,4);explain select * from t1 left join t2 on a=c where d in (4);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ref c,d d 5 const 2 Using where1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join bufferselect * from t1 left join t2 on a=c where d in (4);a b c d3 2 3 44 2 4 4explain select * from t1 left join t2 on a=c where d = 4;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ref c,d d 5 const 2 Using where1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where; Using join bufferselect * from t1 left join t2 on a=c where d = 4;a b c d3 2 3 44 2 4 4drop table t1, t2;CREATE TABLE t1 (i int(11) NOT NULL default '0',c char(10) NOT NULL default '',PRIMARY KEY (i),UNIQUE KEY c (c)) ENGINE=MyISAM;INSERT INTO t1 VALUES (1,'a');INSERT INTO t1 VALUES (2,'b');INSERT INTO t1 VALUES (3,'c');EXPLAIN SELECT i FROM t1 WHERE i=1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using indexDROP TABLE t1;CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t2 ref a a 23 test.t1.a 2 EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t2 ref a a 23 test.t1.a 2 DROP TABLE t1, t2;CREATE TABLE t1 ( city char(30) );INSERT INTO t1 VALUES ('London');INSERT INTO t1 VALUES ('Paris');SELECT * FROM t1 WHERE city='London';cityLondonSELECT * FROM t1 WHERE city='london';cityLondonEXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using whereSELECT * FROM t1 WHERE city='London' AND city='london';cityLondonEXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using whereSELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';cityLondonDROP TABLE t1;create table t1 (a int(11) unsigned, b int(11) unsigned);insert into t1 values (1,0), (1,1), (1,2);select a-b from t1 order by 1;a-b0118446744073709551615select a-b , (a-b < 0) from t1 order by 1;a-b (a-b < 0)0 01 018446744073709551615 0select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;d (a-b >= 0) b1 1 00 1 118446744073709551615 1 2select cast((a - b) as unsigned) from t1 order by 1;cast((a - b) as unsigned)0118446744073709551615drop table t1;create table t1 (a int(11));select all all * from t1;aselect distinct distinct * from t1;aselect all distinct * from t1;ERROR HY000: Incorrect usage of ALL and DISTINCTselect distinct all * from t1;ERROR HY000: Incorrect usage of ALL and DISTINCTdrop table t1;CREATE TABLE t1 (kunde_intern_id int(10) unsigned NOT NULL default '0',kunde_id int(10) unsigned NOT NULL default '0',FK_firma_id int(10) unsigned NOT NULL default '0',aktuell enum('Ja','Nein') NOT NULL default 'Ja',vorname varchar(128) NOT NULL default '',nachname varchar(128) NOT NULL default '',geloescht enum('Ja','Nein') NOT NULL default 'Nein',firma varchar(128) NOT NULL default '');INSERT INTO t1 VALUES (3964,3051,1,'Ja','Vorname1','1Nachname','Nein','Print Schau XXXX'),(3965,3051111,1,'Ja','Vorname1111','1111Nachname','Nein','Print Schau XXXX');SELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname, geloescht FROM t1WHERE((( '' != '' AND firma LIKE CONCAT('%', '', '%'))OR(vorname LIKE CONCAT('%', 'Vorname1', '%') AND nachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND 'xxxx' != ''))AND(aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2));kunde_id FK_firma_id aktuell vorname nachname geloeschtSELECT kunde_id ,FK_firma_id ,aktuell, vorname, nachname,geloescht FROM t1WHERE((aktuell = 'Ja' AND geloescht = 'Nein' AND FK_firma_id = 2)AND(( '' != '' AND firma LIKE CONCAT('%', '', '%') )OR( vorname LIKE CONCAT('%', 'Vorname1', '%') ANDnachname LIKE CONCAT('%', '1Nachname', '%') AND 'Vorname1' != '' AND'xxxx' != '')));kunde_id FK_firma_id aktuell vorname nachname geloeschtSELECT COUNT(*) FROM t1 WHERE ( 0 OR (vorname LIKE '%Vorname1%' AND nachname LIKE '%1Nachname%' AND 1)) AND FK_firma_id = 2;COUNT(*)0drop table t1;CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));INSERT INTO t1 VALUES (0x8000000000000000);SELECT b FROM t1 WHERE b=0x8000000000000000;b9223372036854775808DROP TABLE t1;CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);INSERT INTO `t2` VALUES (0,'READ');CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);INSERT INTO `t3` VALUES (1,'fs');select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);id name gid uid ident level1 fs NULL NULL 0 READdrop table t1,t2,t3;CREATE TABLE t1 (acct_id int(11) NOT NULL default '0',profile_id smallint(6) default NULL,UNIQUE KEY t1$acct_id (acct_id),KEY t1$profile_id (profile_id));INSERT INTO t1 VALUES (132,17),(133,18);CREATE TABLE t2 (profile_id smallint(6) default NULL,queue_id int(11) default NULL,seq int(11) default NULL,KEY t2$queue_id (queue_id));INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);CREATE TABLE t3 (id int(11) NOT NULL default '0',qtype int(11) default NULL,seq int(11) default NULL,warn_lvl int(11) default NULL,crit_lvl int(11) default NULL,rr1 tinyint(4) NOT NULL default '0',rr2 int(11) default NULL,default_queue tinyint(4) NOT NULL default '0',KEY t3$qtype (qtype),KEY t3$id (id));INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0),(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0);SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q WHERE (pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND (pq.queue_id = q.id) AND (q.rr1 <> 1);COUNT(*)4drop table t1,t2,t3;create table t1 (f1 int);insert into t1 values (1),(NULL);create table t2 (f2 int, f3 int, f4 int);create index idx1 on t2 (f4);insert into t2 values (1,2,3),(2,4,6);select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3)from t2 C where A.f4 = C.f4) or A.f3 IS NULL;f21NULLdrop table t1,t2;create table t2 (a tinyint unsigned);create index t2i on t2(a);insert into t2 values (0), (254), (255);explain select * from t2 where a > -1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index t2i t2i 2 NULL 3 Using where; Using indexselect * from t2 where a > -1;a0254255drop table t2;CREATE TABLE t1 (a int, b int, c int);INSERT INTO t1SELECT 50, 3, 3 FROM DUALWHERE NOT EXISTS(SELECT * FROM t1 WHERE a = 50 AND b = 3);SELECT * FROM t1;a b c50 3 3INSERT INTO t1SELECT 50, 3, 3 FROM DUALWHERE NOT EXISTS(SELECT * FROM t1 WHERE a = 50 AND b = 3);select found_rows();found_rows()0SELECT * FROM t1;a b c50 3 3select count(*) from t1;count(*)1select found_rows();found_rows()1select count(*) from t1 limit 2,3;count(*)select found_rows();found_rows()0select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3;count(*)select found_rows();found_rows()1DROP TABLE t1;CREATE TABLE t1 (a INT, b INT);(SELECT a, b AS c FROM t1) ORDER BY c+1;a c(SELECT a, b AS c FROM t1) ORDER BY b+1;a cSELECT a, b AS c FROM t1 ORDER BY c+1;a cSELECT a, b AS c FROM t1 ORDER BY b+1;a cdrop table t1;create table t1(f1 int, f2 int);create table t2(f3 int);select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,1));f1select f1 from t1,t2 where f1=f2 and (f1,NULL) = ((1,1));f1select f1 from t1,t2 where f1=f2 and (f1,f2) = ((1,NULL));f1insert into t1 values(1,1),(2,null);insert into t2 values(2);select * from t1,t2 where f1=f3 and (f1,f2) = (2,null);f1 f2 f3select * from t1,t2 where f1=f3 and (f1,f2) <=> (2,null);f1 f2 f32 NULL 2drop table t1,t2;create table t1 (f1 int not null auto_increment primary key, f2 varchar(10));create table t11 like t1;insert into t1 values(1,""),(2,"");show table status like 't1%';Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Commentt1 MyISAM 10 Dynamic 2 20 X X X X X X X X latin1_swedish_ci NULL t11 MyISAM 10 Dynamic 0 0 X X X X X X X X latin1_swedish_ci NULL select 123 as a from t1 where f1 is null;adrop table t1,t11;CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL, UNIQUE idx (a,b) );INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4);CREATE TABLE t2 ( a INT NOT NULL, b INT NOT NULL, e INT );INSERT INTO t2 VALUES ( 1,10,1), (1,10,2), (1,11,1), (1,11,2), (1,2,1), (1,2,2),(1,2,3);SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOINt1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;a b c d1 2 1 11 2 2 11 2 3 11 10 21 11 2SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOINt1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t1.a, t1.b, c;a b c d1 10 41 2 1 11 2 2 11 2 3 1SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2 LEFT JOINt1 ON t2.a = t1.a AND t2.b = t1.b GROUP BY t2.a, t2.b, c;a b c d1 2 1 11 2 2 11 2 3 11 10 21 11 2SELECT t2.a, t2.b, IF(t1.b IS NULL,'',e) AS c, COUNT(*) AS d FROM t2,t1WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c;a b c d1 2 1 11 2 2 11 2 3 1DROP TABLE IF EXISTS t1, t2;create table t1 (f1 int primary key, f2 int);create table t2 (f3 int, f4 int, primary key(f3,f4));insert into t1 values (1,1);insert into t2 values (1,1),(1,2);select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1;count(f2) >01drop table t1,t2;create table t1 (f1 int,f2 int);insert into t1 values(1,1);create table t2 (f3 int, f4 int, primary key(f3,f4));insert into t2 values(1,1);select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2));f1 f21 1drop table t1,t2;CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c));insert into t1 values (1,0,0),(2,0,0);CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a));insert into t2 values (1,'',''), (2,'','');CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b));insert into t3 values (1,1),(1,2);explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2 where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and t2.b like '%%' order by t2.b limit 0,1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref b,c b 5 const 1 Using where; Using temporary; Using filesort1 SIMPLE t3 index PRIMARY,a,b PRIMARY 8 NULL 2 Using index; Using join buffer1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Range checked for each record (index map: 0x1)DROP TABLE t1,t2,t3;CREATE TABLE t1 (a int, INDEX idx(a));INSERT INTO t1 VALUES (2), (3), (1);EXPLAIN SELECT * FROM t1 IGNORE INDEX (idx);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 3 EXPLAIN SELECT * FROM t1 IGNORE INDEX (a);ERROR 42000: Key 'a' doesn't exist in table 't1'EXPLAIN SELECT * FROM t1 FORCE INDEX (a);ERROR 42000: Key 'a' doesn't exist in table 't1'DROP TABLE t1;CREATE TABLE t1 (a int, b int);INSERT INTO t1 VALUES (1,1), (2,1), (4,10);CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b));INSERT INTO t2 VALUES (1,NULL), (2,10);ALTER TABLE t1 ENABLE KEYS;EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index b b 5 NULL 2 Using index1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join bufferSELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;a b a b1 NULL 1 11 NULL 2 11 NULL 4 102 10 4 10EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 index b b 5 NULL 2 Using index1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join bufferSELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;a b a b1 NULL 1 11 NULL 2 11 NULL 4 102 10 4 10DROP TABLE IF EXISTS t1,t2;CREATE TABLE t1 (key1 float default NULL, UNIQUE KEY key1 (key1));CREATE TABLE t2 (key2 float default NULL, UNIQUE KEY key2 (key2));INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);explain select max(key1) from t1 where key1 <= 0.6158;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized awayexplain select max(key2) from t2 where key2 <= 1.6158;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized awayexplain select min(key1) from t1 where key1 >= 0.3762;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized awayexplain select min(key2) from t2 where key2 >= 1.3762;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized awayexplain select max(key1), min(key2) from t1, t2where key1 <= 0.6158 and key2 >= 1.3762;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized awayexplain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized awayexplain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized awayselect max(key1) from t1 where key1 <= 0.6158;max(key1)0.615800023078918select max(key2) from t2 where key2 <= 1.6158;max(key2)1.61580002307892select min(key1) from t1 where key1 >= 0.3762;min(key1)0.376199990510941select min(key2) from t2 where key2 >= 1.3762;min(key2)1.37619996070862select max(key1), min(key2) from t1, t2where key1 <= 0.6158 and key2 >= 1.3762;max(key1) min(key2)0.615800023078918 1.37619996070862select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;max(key1)0.615800023078918select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;min(key1)0.376199990510941DROP TABLE t1,t2;CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);INSERT INTO t1 VALUES (10);SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01')1 1 1 1DROP TABLE t1;create table t1(a bigint unsigned, b bigint);insert into t1 values (0xfffffffffffffffff, 0xfffffffffffffffff), (0x10000000000000000, 0x10000000000000000), (0x8fffffffffffffff, 0x8fffffffffffffff);Warnings:Warning 1264 Out of range value for column 'a' at row 1Warning 1264 Out of range value for column 'b' at row 1Warning 1264 Out of range value for column 'a' at row 2Warning 1264 Out of range value for column 'b' at row 2Warning 1264 Out of range value for column 'b' at row 3select hex(a), hex(b) from t1;hex(a) hex(b)FFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFF8FFFFFFFFFFFFFFF 7FFFFFFFFFFFFFFFdrop table t1;CREATE TABLE t1 (c0 int);CREATE TABLE t2 (c0 int);INSERT INTO t1 VALUES(@@connect_timeout);INSERT INTO t2 VALUES(@@connect_timeout);SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout);c0 c0X XDROP TABLE t1, t2;End of 4.1 testsCREATE TABLE t1 ( K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', F2I4 int(11) NOT NULL default '0' ) ENGINE=MyISAM DEFAULT CHARSET=latin1;INSERT INTO t1 VALUES ('W%RT', '0100', 1), ('W-RT', '0100', 1), ('WART', '0100', 1), ('WART', '0200', 1), ('WERT', '0100', 2), ('WORT','0200', 2), ('WT', '0100', 2), ('W_RT', '0100', 2), ('WaRT', '0100', 3), ('WART', '0300', 3), ('WRT' , '0400', 3), ('WURM', '0500', 3), ('W%T', '0600', 4), ('WA%T', '0700', 4), ('WA_T', '0800', 4);SELECT K2C4, K4N4, F2I4 FROM t1WHERE K2C4 = 'WART' AND (F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200'));K2C4 K4N4 F2I4WART 0200 1SELECT K2C4, K4N4, F2I4 FROM t1WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200');K2C4 K4N4 F2I4WART 0100 1WART 0200 1WART 0300 3DROP TABLE t1;create table t1 (a int, b int);create table t2 like t1;select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1;aselect t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1;aselect x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1;a a adrop table t1,t2;create table t1 (s1 varchar(5));insert into t1 values ('Wall');select min(s1) from t1 group by s1 with rollup;min(s1)WallWalldrop table t1;create table t1 (s1 int) engine=myisam;insert into t1 values (0);select avg(distinct s1) from t1 group by s1 with rollup;avg(distinct s1)0.00000.0000drop table t1;create table t1 (s1 int);insert into t1 values (null),(1);select distinct avg(s1) as x from t1 group by s1 with rollup;xNULL1.0000drop table t1;CREATE TABLE t1 (a int);CREATE TABLE t2 (a int);INSERT INTO t1 VALUES (1), (2), (3), (4), (5);INSERT INTO t2 VALUES (2), (4), (6);SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a;a24EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join bufferEXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ALL NULL NULL NULL NULL 3 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where; Using join bufferDROP TABLE t1,t2;select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 016 16 2 2create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null);create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4));insert into t1 values (" 2", 2);insert into t2 values (" 2", " one "),(" 2", " two ");select * from t1 left join t2 on f1 = f3;f1 f2 f3 f4 2 2 2 one 2 2 2 two drop table t1,t2;create table t1 (empnum smallint, grp int);create table t2 (empnum int, name char(5));insert into t1 values(1,1);insert into t2 values(1,'bob');create view v1 as select * from t2 inner join t1 using (empnum);select * from v1;empnum name grp1 bob 1drop table t1,t2;drop view v1;create table t1 (pk int primary key, b int);create table t2 (pk int primary key, c int);select pk from t1 inner join t2 using (pk);pkdrop table t1,t2;create table t1 (s1 int, s2 char(5), s3 decimal(10));create view v1 as select s1, s2, 'x' as s3 from t1;select * from t1 natural join v1;s1 s2 s3insert into t1 values (1,'x',5);select * from t1 natural join v1;s1 s2 s3Warnings:Warning 1292 Truncated incorrect DOUBLE value: 'x'drop table t1;drop view v1;create table t1(a1 int);create table t2(a2 int);insert into t1 values(1),(2);insert into t2 values(1),(2);create view v2 (c) as select a1 from t1;select * from t1 natural left join t2;a1 a21 11 22 12 2select * from t1 natural right join t2;a2 a11 11 22 12 2select * from v2 natural left join t2;c a21 11 22 12 2select * from v2 natural right join t2;a2 c1 11 22 12 2drop table t1, t2;drop view v2;create table t1 (a int(10), t1_val int(10));create table t2 (b int(10), t2_val int(10));create table t3 (a int(10), b int(10));insert into t1 values (1,1),(2,2);insert into t2 values (1,1),(2,2),(3,3);insert into t3 values (1,1),(2,1),(3,1),(4,1);select * from t1 natural join t2 natural join t3;a b t1_val t2_val1 1 1 12 1 2 1select * from t1 natural join t3 natural join t2;b a t1_val t2_val1 1 1 11 2 2 1drop table t1, t2, t3;DO IFNULL(NULL, NULL);SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL);CAST(IFNULL(NULL, NULL) AS DECIMAL)NULLSELECT ABS(IFNULL(NULL, NULL));ABS(IFNULL(NULL, NULL))NULLSELECT IFNULL(NULL, NULL);IFNULL(NULL, NULL)NULLSET @OLD_SQL_MODE12595=@@SQL_MODE, @@SQL_MODE='';SHOW LOCAL VARIABLES LIKE 'SQL_MODE';Variable_name Valuesql_mode CREATE TABLE BUG_12595(a varchar(100));INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an");SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%';ahakan%SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*';ahakan%SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**';ERROR HY000: Incorrect arguments to ESCAPESELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE '';ahakan%hakankSELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '';aSELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c;aha%anSELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%';aha%anSELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\';aha%anSELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|';aha%anSET @@SQL_MODE='NO_BACKSLASH_ESCAPES';SHOW LOCAL VARIABLES LIKE 'SQL_MODE';Variable_name Valuesql_mode NO_BACKSLASH_ESCAPESSELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%';aSELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*';ahakan%SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**';ERROR HY000: Incorrect arguments to ESCAPESELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\';ERROR HY000: Incorrect arguments to ESCAPESELECT * FROM BUG_12595 WHERE a LIKE 'hakan%' ESCAPE '';ERROR HY000: Incorrect arguments to ESCAPESELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE 0x5c;aha%anSELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '|';aha%anSELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n';ERROR HY000: Incorrect arguments to ESCAPESET @@SQL_MODE=@OLD_SQL_MODE12595;DROP TABLE BUG_12595;create table t1 (a char(1));create table t2 (a char(1));insert into t1 values ('a'),('b'),('c');insert into t2 values ('b'),('c'),('d');select a from t1 natural join t2;abcselect * from t1 natural join t2 where a = 'b';abdrop table t1, t2;CREATE TABLE t1 (`id` TINYINT);CREATE TABLE t2 (`id` TINYINT);CREATE TABLE t3 (`id` TINYINT);INSERT INTO t1 VALUES (1),(2),(3);INSERT INTO t2 VALUES (2);INSERT INTO t3 VALUES (3);SELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id);ERROR 23000: Column 'id' in from clause is ambiguousSELECT t1.id,t3.id FROM t1 JOIN t2 ON (t2.notacolumn=t1.id) LEFT JOIN t3 USING (id);ERROR 23000: Column 'id' in from clause is ambiguousSELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id);ERROR 23000: Column 'id' in from clause is ambiguousSELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id);ERROR 23000: Column 'id' in from clause is ambiguousdrop table t1, t2, t3;create table t1 (a int(10),b int(10));create table t2 (a int(10),b int(10));insert into t1 values (1,10),(2,20),(3,30);insert into t2 values (1,10);select * from t1 inner join t2 using (A);a b b1 10 10select * from t1 inner join t2 using (a);a b b1 10 10drop table t1, t2;create table t1 (a int, c int);create table t2 (b int);create table t3 (b int, a int);create table t4 (c int);insert into t1 values (1,1);insert into t2 values (1);insert into t3 values (1,1);insert into t4 values (1);select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a);a c b b a1 1 1 1 1select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a);ERROR 42S22: Unknown column 't1.a' in 'on clause'select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c);a c b b a c1 1 1 1 1 1select * from t1 join t2 join t4 using (c);c a b1 1 1drop table t1, t2, t3, t4;create table t1(x int, y int);create table t2(x int, y int);create table t3(x int, primary key(x));insert into t1 values (1, 1), (2, 1), (3, 1), (4, 3), (5, 6), (6, 6);insert into t2 values (1, 1), (2, 1), (3, 3), (4, 6), (5, 6);insert into t3 values (1), (2), (3), (4), (5);select t1.x, t3.x from t1, t2, t3 where t1.x = t2.x and t3.x >= t1.y and t3.x <= t2.y;x x1 12 13 13 23 34 34 44 5drop table t1,t2,t3;create table t1 (id char(16) not null default '', primary key (id));insert into t1 values ('100'),('101'),('102');create table t2 (id char(16) default null);insert into t2 values (1);create view v1 as select t1.id from t1;create view v2 as select t2.id from t2;create view v3 as select (t1.id+2) as id from t1 natural left join t2;select t1.id from t1 left join v2 using (id);id100101102select t1.id from v2 right join t1 using (id);id100101102select t1.id from t1 left join v3 using (id);id100101102select * from t1 left join v2 using (id);id100101102select * from v2 right join t1 using (id);id100101102select * from t1 left join v3 using (id);id100101102select v1.id from v1 left join v2 using (id);id100101102select v1.id from v2 right join v1 using (id);id100101102select v1.id from v1 left join v3 using (id);id100101102select * from v1 left join v2 using (id);id100101102select * from v2 right join v1 using (id);id100101102select * from v1 left join v3 using (id);id100101102drop table t1, t2;drop view v1, v2, v3;create table t1 (id int(11) not null default '0');insert into t1 values (123),(191),(192);create table t2 (id char(16) character set utf8 not null);insert into t2 values ('58013'),('58014'),('58015'),('58016');create table t3 (a_id int(11) not null, b_id char(16) character set utf8);insert into t3 values (123,null),(123,null),(123,null),(123,null),(123,null),(123,'58013');select count(*)from t1 inner join (t3 left join t2 on t2.id = t3.b_id) on t1.id = t3.a_id;count(*)6select count(*)from t1 inner join (t2 right join t3 on t2.id = t3.b_id) on t1.id = t3.a_id;count(*)6drop table t1,t2,t3;create table t1 (a int);create table t2 (b int);create table t3 (c int);select * from t1 join t2 join t3 on (t1.a=t3.c);a b cselect * from t1 join t2 left join t3 on (t1.a=t3.c);a b cselect * from t1 join t2 right join t3 on (t1.a=t3.c);a b cselect * from t1 join t2 straight_join t3 on (t1.a=t3.c);a b cdrop table t1, t2 ,t3;create table t1(f1 int, f2 date);insert into t1 values(1,'2005-01-01'),(2,'2005-09-01'),(3,'2005-09-30'),(4,'2005-10-01'),(5,'2005-12-30');select * from t1 where f2 >= 0 order by f2;f1 f21 2005-01-012 2005-09-013 2005-09-304 2005-10-015 2005-12-30select * from t1 where f2 >= '0000-00-00' order by f2;f1 f21 2005-01-012 2005-09-013 2005-09-304 2005-10-015 2005-12-30select * from t1 where f2 >= '2005-09-31' order by f2;f1 f24 2005-10-015 2005-12-30select * from t1 where f2 >= '2005-09-3a' order by f2;f1 f23 2005-09-304 2005-10-015 2005-12-30Warnings:Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1select * from t1 where f2 <= '2005-09-31' order by f2;f1 f21 2005-01-012 2005-09-013 2005-09-30select * from t1 where f2 <= '2005-09-3a' order by f2;f1 f21 2005-01-012 2005-09-01Warnings:Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 1drop table t1;create table t1 (f1 int, f2 int);insert into t1 values (1, 30), (2, 20), (3, 10);create algorithm=merge view v1 as select f1, f2 from t1;create algorithm=merge view v2 (f2, f1) as select f1, f2 from t1;create algorithm=merge view v3 as select t1.f1 as f2, t1.f2 as f1 from t1;select t1.f1 as x1, f1 from t1 order by t1.f1;x1 f11 12 23 3select v1.f1 as x1, f1 from v1 order by v1.f1;x1 f11 12 23 3select v2.f1 as x1, f1 from v2 order by v2.f1;x1 f110 1020 2030 30select v3.f1 as x1, f1 from v3 order by v3.f1;x1 f110 1020 2030 30select f1, f2, v1.f1 as x1 from v1 order by v1.f1;f1 f2 x11 30 12 20 23 10 3select f1, f2, v2.f1 as x1 from v2 order by v2.f1;f1 f2 x110 3 1020 2 2030 1 30select f1, f2, v3.f1 as x1 from v3 order by v3.f1;f1 f2 x110 3 1020 2 2030 1 30drop table t1;drop view v1, v2, v3;CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a));CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a));CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32),PRIMARY KEY(key_a,key_b));INSERT INTO t1 VALUES (0,'');INSERT INTO t1 VALUES (1,'i');INSERT INTO t1 VALUES (2,'j');INSERT INTO t1 VALUES (3,'k');INSERT INTO t2 VALUES (1,'r');INSERT INTO t2 VALUES (2,'s');INSERT INTO t2 VALUES (3,'t');INSERT INTO t3 VALUES (1,5,'x');INSERT INTO t3 VALUES (1,6,'y');INSERT INTO t3 VALUES (2,5,'xx');INSERT INTO t3 VALUES (2,6,'yy');INSERT INTO t3 VALUES (2,7,'zz');INSERT INTO t3 VALUES (3,5,'xxx');SELECT t2.key_a,foo FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_aINNER JOIN t3 ON t1.key_a = t3.key_aWHERE t2.key_a=2 and key_b=5;key_a foo2 xxEXPLAIN SELECT t2.key_a,foo FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_aINNER JOIN t3 ON t1.key_a = t3.key_aWHERE t2.key_a=2 and key_b=5;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1 SELECT t2.key_a,foo FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_aINNER JOIN t3 ON t1.key_a = t3.key_aWHERE t2.key_a=2 and key_b=5;key_a foo2 xxEXPLAIN SELECT t2.key_a,foo FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_aINNER JOIN t3 ON t1.key_a = t3.key_aWHERE t2.key_a=2 and key_b=5;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1 DROP TABLE t1,t2,t3;create table t1 (f1 int);insert into t1 values(1),(2);create table t2 (f2 int, f3 int, key(f2));insert into t2 values(1,1),(2,2);create table t3 (f4 int not null);insert into t3 values (2),(2),(2);select f1,(select count(*) from t2,t3 where f2=f1 and f3=f4) as count from t1;f1 count1 02 3drop table t1,t2,t3;create table t1 (f1 int unique);create table t2 (f2 int unique);create table t3 (f3 int unique);insert into t1 values(1),(2);insert into t2 values(1),(2);insert into t3 values(1),(NULL);select * from t3 where f3 is null;f3NULLselect t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1;f21drop table t1,t2,t3;create table t1(f1 char, f2 char not null);insert into t1 values(null,'a');create table t2 (f2 char not null);insert into t2 values('b');select * from t1 left join t2 on f1=t2.f2 where t1.f2='a';f1 f2 f2NULL a NULLdrop table t1,t2;select * from (select * left join t on f1=f2) tt;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on f1=f2) tt' at line 1CREATE TABLE t1 (sku int PRIMARY KEY, pr int);CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255));INSERT INTO t1 VALUES(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10);INSERT INTO t2 VALUES (10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'),(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh');SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.prFROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);sku sppr name sku pr20 10 bbb 10 1020 10 bbb 20 10EXPLAINSELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.prFROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using whereDROP TABLE t1,t2;CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL);INSERT t1 SET i = 0;UPDATE t1 SET i = -1;Warnings:Warning 1264 Out of range value for column 'i' at row 1SELECT * FROM t1;i0UPDATE t1 SET i = CAST(i - 1 AS SIGNED);Warnings:Warning 1264 Out of range value for column 'i' at row 1SELECT * FROM t1;i0UPDATE t1 SET i = i - 1;Warnings:Warning 1264 Out of range value for column 'i' at row 1SELECT * FROM t1;i255DROP TABLE t1;create table t1 (a int);insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);create table t2 (a int, b int, c int, e int, primary key(a,b,c));insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C;analyze table t2;Table Op Msg_type Msg_texttest.t2 analyze status OKselect 'In next EXPLAIN, B.rows must be exactly 10:' Z;ZIn next EXPLAIN, B.rows must be exactly 10:explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE A range PRIMARY PRIMARY 12 NULL 4 Using where1 SIMPLE B ref PRIMARY PRIMARY 8 const,test.A.e 10 drop table t1, t2;CREATE TABLE t1 (a int PRIMARY KEY, b int, INDEX(b));INSERT INTO t1 VALUES (1, 3), (9,4), (7,5), (4,5), (6,2),(3,1), (5,1), (8,9), (2,2), (0,9);CREATE TABLE t2 (c int, d int, f int, INDEX(c,f));INSERT INTO t2 VALUES(1,0,0), (1,0,1), (2,0,0), (2,0,1), (3,0,0), (4,0,1),(5,0,0), (5,0,1), (6,0,0), (0,0,1), (7,0,0), (7,0,1),(0,0,0), (0,0,1), (8,0,0), (8,0,1), (9,0,0), (9,0,1);EXPLAINSELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using where1 SIMPLE t2 ref c c 5 test.t1.a 2 Using whereEXPLAINSELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using where1 SIMPLE t2 ref c c 5 test.t1.a 2 Using whereDROP TABLE t1, t2;create table t1 (a int unsigned not null auto_increment primary key,b bit not null,c bit not null);create table t2 (a int unsigned not null auto_increment primary key,b bit not null,c int unsigned not null,d varchar(50));insert into t1 (b,c) values (0,1), (0,1);insert into t2 (b,c) values (0,1);select t1.a, t1.b + 0, t1.c + 0, t2.a, t2.b + 0, t2.c, t2.dfrom t1 left outer join t2 on t1.a = t2.c and t2.b <> 1where t1.b <> 1 order by t1.a;a t1.b + 0 t1.c + 0 a t2.b + 0 c d1 0 1 1 0 1 NULL2 0 1 NULL NULL NULL NULLdrop table t1,t2;SELECT 0.9888889889 * 1.011111411911;0.9888889889 * 1.0111114119110.9998769417899202067879prepare stmt from 'select 1 as " a "';Warnings:Warning 1466 Leading spaces are removed from name ' a 'execute stmt;a 1CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL);INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);CREATE TABLE t2 (c int NOT NULL, INDEX idx(c));INSERT INTO t2 VALUES(1), (1), (1), (1), (1), (1), (1), (1),(2), (2), (2), (2),(3), (3),(4);EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 ref idx idx 4 const 7 Using indexEXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 ref idx idx 4 const 1 Using indexDROP TABLE t1, t2;CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int);INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2);CREATE TABLE t2 (b int, c INT, INDEX idx1(b));INSERT INTO t2 VALUES (2,1), (3,2);CREATE TABLE t3 (d int, e int, INDEX idx1(d));INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50);EXPLAINSELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.idWHERE t1.id=2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 const idx1 NULL NULL NULL 1 1 SIMPLE t3 ref idx1 idx1 5 const 3 Using whereSELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.idWHERE t1.id=2;id a b c d e2 NULL NULL NULL 2 102 NULL NULL NULL 2 202 NULL NULL NULL 2 402 NULL NULL NULL 2 50DROP TABLE t1,t2,t3;create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int,c7 int, c8 int, c9 int, fulltext key (`c1`));select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 from t1 where c9=1 order by c2, c2;match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8drop table t1;CREATE TABLE t1 (pk varchar(10) PRIMARY KEY, fk varchar(16));CREATE TABLE t2 (pk varchar(16) PRIMARY KEY, fk varchar(10));INSERT INTO t1 VALUES('d','dddd'), ('i','iii'), ('a','aa'), ('b','bb'), ('g','gg'), ('e','eee'), ('c','cccc'), ('h','hhh'), ('j','jjj'), ('f','fff');INSERT INTO t2 VALUES('jjj', 'j'), ('cc','c'), ('ccc','c'), ('aaa', 'a'), ('jjjj','j'),('hhh','h'), ('gg','g'), ('fff','f'), ('ee','e'), ('ffff','f'),('bbb','b'), ('ff','f'), ('cccc','c'), ('dddd','d'), ('jj','j'),('aaaa','a'), ('bb','b'), ('eeee','e'), ('aa','a'), ('hh','h');EXPLAIN SELECT t2.* FROM t1 JOIN t2 ON t2.fk=t1.pkWHERE t2.fk < 'c' AND t2.pk=t1.fk;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range PRIMARY PRIMARY 12 NULL 3 Using where1 SIMPLE t2 eq_ref PRIMARY PRIMARY 18 test.t1.fk 1 Using whereEXPLAIN SELECT t2.* FROM t1 JOIN t2 ON t2.fk=t1.pk WHERE t2.fk BETWEEN 'a' AND 'b' AND t2.pk=t1.fk;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range PRIMARY PRIMARY 12 NULL 2 Using where1 SIMPLE t2 eq_ref PRIMARY PRIMARY 18 test.t1.fk 1 Using whereEXPLAIN SELECT t2.* FROM t1 JOIN t2 ON t2.fk=t1.pk WHERE t2.fk IN ('a','b') AND t2.pk=t1.fk;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range PRIMARY PRIMARY 12 NULL 2 Using where1 SIMPLE t2 eq_ref PRIMARY PRIMARY 18 test.t1.fk 1 Using whereDROP TABLE t1,t2;CREATE TABLE t1 (a int, b varchar(20) NOT NULL, PRIMARY KEY(a));CREATE TABLE t2 (a int, b varchar(20) NOT NULL,PRIMARY KEY (a), UNIQUE KEY (b));INSERT INTO t1 VALUES (1,'a'),(2,'b'),(3,'c');INSERT INTO t2 VALUES (1,'a'),(2,'b'),(3,'c');EXPLAIN SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.b=t1.b WHERE t1.a=3;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 const b b 22 const 1 Using indexDROP TABLE t1,t2;CREATE TABLE t1(id int PRIMARY KEY, b int, e int);CREATE TABLE t2(i int, a int, INDEX si(i), INDEX ai(a));CREATE TABLE t3(a int PRIMARY KEY, c char(4), INDEX ci(c));INSERT INTO t1 VALUES (1,10,19), (2,20,22), (4,41,42), (9,93,95), (7, 77,79),(6,63,67), (5,55,58), (3,38,39), (8,81,89);INSERT INTO t2 VALUES(21,210), (41,410), (82,820), (83,830), (84,840),(65,650), (51,510), (37,370), (94,940), (76,760),(22,220), (33,330), (40,400), (95,950), (38,380),(67,670), (88,880), (57,570), (96,960), (97,970);INSERT INTO t3 VALUES(210,'bb'), (950,'ii'), (400,'ab'), (500,'ee'), (220,'gg'),(440,'gg'), (310,'eg'), (380,'ee'), (840,'bb'), (830,'ff'),(230,'aa'), (960,'ii'), (410,'aa'), (510,'ee'), (290,'bb'),(450,'gg'), (320,'dd'), (390,'hh'), (850,'jj'), (860,'ff');EXPLAINSELECT t3.a FROM t1,t2 FORCE INDEX (si),t3WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e AND t3.a=t2.a AND t3.c IN ('bb','ee');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 4 Using where1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using whereEXPLAINSELECT t3.a FROM t1,t2,t3WHERE t1.id = 8 AND t2.i BETWEEN t1.b AND t1.e ANDt3.a=t2.a AND t3.c IN ('bb','ee') ;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 4 Using where1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using whereEXPLAIN SELECT t3.a FROM t1,t2 FORCE INDEX (si),t3WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a ANDt3.c IN ('bb','ee');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using where1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using whereEXPLAIN SELECT t3.a FROM t1,t2,t3WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a ANDt3.c IN ('bb','ee');id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using where1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using whereDROP TABLE t1,t2,t3;CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int);CREATE TABLE t2 ( f11 int PRIMARY KEY );INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0);INSERT INTO t2 VALUES (62);SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1;f1 f2 f3 f4 f5 f6 checked_out f111 1 1 0 0 0 0 NULLDROP TABLE t1, t2;DROP TABLE IF EXISTS t1;CREATE TABLE t1(a int);INSERT into t1 values (1), (2), (3);SELECT * FROM t1 LIMIT 2, -1;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1DROP TABLE t1;CREATE TABLE t1 (ID_with_null int NULL,ID_better int NOT NULL,INDEX idx1 (ID_with_null),INDEX idx2 (ID_better));INSERT INTO t1 VALUES (1,1), (2,1), (null,3), (null,3), (null,3), (null,3);INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID_with_null IS NULL;SELECT COUNT(*) FROM t1 WHERE ID_with_null IS NULL;COUNT(*)128SELECT COUNT(*) FROM t1 WHERE ID_better=1;COUNT(*)2EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereDROP INDEX idx1 ON t1;CREATE UNIQUE INDEX idx1 ON t1(ID_with_null);EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID_with_null IS NULL;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereDROP TABLE t1;CREATE TABLE t1 (ID1_with_null int NULL,ID2_with_null int NULL,ID_better int NOT NULL,INDEX idx1 (ID1_with_null, ID2_with_null),INDEX idx2 (ID_better));INSERT INTO t1 VALUES (1,1,1), (2,2,1), (3,null,3), (null,3,3), (null,null,3),(3,null,3), (null,3,3), (null,null,3), (3,null,3), (null,3,3), (null,null,3);INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID1_with_null IS NULL;INSERT INTO t1 SELECT * FROM t1 WHERE ID2_with_null IS NULL;SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null=3;COUNT(*)24SELECT COUNT(*) FROM t1 WHERE ID1_with_null=3 AND ID2_with_null IS NULL;COUNT(*)24SELECT COUNT(*) FROM t1 WHERE ID1_with_null IS NULL AND ID2_with_null IS NULL;COUNT(*)192SELECT COUNT(*) FROM t1 WHERE ID_better=1;COUNT(*)2EXPLAIN SELECT * FROM t1WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereEXPLAIN SELECT * FROM t1WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereEXPLAIN SELECT * FROM t1WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereDROP INDEX idx1 ON t1;CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);EXPLAIN SELECT * FROM t1WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereEXPLAIN SELECT * FROM t1WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereEXPLAIN SELECT * FROM t1WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereEXPLAIN SELECT * FROM t1WHERE ID_better=1 AND ID1_with_null IS NULL AND (ID2_with_null=1 OR ID2_with_null=2);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using whereDROP TABLE t1;CREATE TABLE t1 (a INT, ts TIMESTAMP, KEY ts(ts));INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00");ANALYZE TABLE t1;Table Op Msg_type Msg_texttest.t1 analyze status OKCREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a));INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00");INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2;ANALYZE TABLE t2;Table Op Msg_type Msg_texttest.t2 analyze status OKEXPLAINSELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30AND t1.ts BETWEEN t2.dt1 AND t2.dt2AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t1 range ts ts 4 NULL 1 Using whereWarnings:Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30AND t1.ts BETWEEN t2.dt1 AND t2.dt2AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";a ts a dt1 dt230 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00Warnings:Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1DROP TABLE t1,t2;create table t1 (a bigint unsigned);insert into t1 values(if(1, 9223372036854775808, 1)),(case when 1 then 9223372036854775808 else 1 end),(coalesce(9223372036854775808, 1));select * from t1;a922337203685477580892233720368547758089223372036854775808drop table t1;create table t1 selectif(1, 9223372036854775808, 1) i,case when 1 then 9223372036854775808 else 1 end c,coalesce(9223372036854775808, 1) co;show create table t1;Table Create Tablet1 CREATE TABLE `t1` ( `i` decimal(19,0) NOT NULL DEFAULT '0', `c` decimal(19,0) NOT NULL DEFAULT '0', `co` decimal(19,0) NOT NULL DEFAULT '0') ENGINE=MyISAM DEFAULT CHARSET=latin1drop table t1;select if(1, cast(1111111111111111111 as unsigned), 1) i,case when 1 then cast(1111111111111111111 as unsigned) else 1 end c,coalesce(cast(1111111111111111111 as unsigned), 1) co;i c co1111111111111111111 1111111111111111111 1111111111111111111CREATE TABLE t1 (name varchar(255));CREATE TABLE t2 (name varchar(255), n int, KEY (name(3)));INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa');INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3);INSERT INTO t2 VALUES (concat('cc ', 0x06), 4);INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7);SELECT * FROM t2;name nbb 1aa 2cc 3cc 4cc 5bb 6cc 7SELECT * FROM t2 ORDER BY name;name naa 2bb 1bb 6cc 4cc 3cc 5cc 7SELECT name, LENGTH(name), n FROM t2 ORDER BY name;name LENGTH(name) naa 2 2bb 2 1bb 3 6cc 4 4cc 5 3cc 2 5cc 3 7EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ref name name 6 const 3 Using whereSELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';name LENGTH(name) ncc 5 3cc 2 5cc 3 7EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range name name 6 NULL 3 Using whereSELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';name LENGTH(name) ncc 5 3cc 4 4cc 2 5cc 3 7EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesortSELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;name LENGTH(name) ncc 4 4cc 5 3cc 2 5cc 3 7EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t2 ref name name 6 test.t1.name 2 SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;name name nccc NULL NULLbb bb 1bb bb 6cc cc 3cc cc 5cc cc 7aa aa 2aa aa 2DROP TABLE t1,t2;CREATE TABLE t1 (name text);CREATE TABLE t2 (name text, n int, KEY (name(3)));INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa');INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3);INSERT INTO t2 VALUES (concat('cc ', 0x06), 4);INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7);SELECT * FROM t2;name nbb 1aa 2cc 3cc 4cc 5bb 6cc 7SELECT * FROM t2 ORDER BY name;name naa 2bb 1bb 6cc 4cc 3cc 5cc 7SELECT name, LENGTH(name), n FROM t2 ORDER BY name;name LENGTH(name) naa 2 2bb 2 1bb 3 6cc 4 4cc 5 3cc 2 5cc 3 7EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 ref name name 6 const 3 Using whereSELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';name LENGTH(name) ncc 5 3cc 2 5cc 3 7EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range name name 6 NULL 3 Using whereSELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';name LENGTH(name) ncc 5 3cc 4 4cc 2 5cc 3 7EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesortSELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;name LENGTH(name) ncc 4 4cc 5 3cc 2 5cc 3 7EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 5 1 SIMPLE t2 ref name name 6 test.t1.name 2 SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;name name nccc NULL NULLbb bb 1bb bb 6cc cc 3cc cc 5cc cc 7aa aa 2aa aa 2DROP TABLE t1,t2;CREATE TABLE t1 (access_id int NOT NULL default '0',name varchar(20) default NULL,rank int NOT NULL default '0',KEY idx (access_id));CREATE TABLE t2 (faq_group_id int NOT NULL default '0',faq_id int NOT NULL default '0',access_id int default NULL,UNIQUE KEY idx1 (faq_id),KEY idx2 (faq_group_id,faq_id));INSERT INTO t1 VALUES (1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4);INSERT INTO t2 VALUES(261,265,1),(490,494,1);SELECT t2.faq_id FROM t1 INNER JOIN t2 IGNORE INDEX (idx1)ON (t1.access_id = t2.access_id)LEFT JOIN t2 tON (t.faq_group_id = t2.faq_group_id ANDfind_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4'))WHEREt2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);faq_id265SELECT t2.faq_id FROM t1 INNER JOIN t2ON (t1.access_id = t2.access_id)LEFT JOIN t2 tON (t.faq_group_id = t2.faq_group_id ANDfind_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4'))WHEREt2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);faq_id265DROP TABLE t1,t2;CREATE TABLE t1 (a INT, b INT, KEY inx (b,a));INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7);EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2ON ( f1.b=f2.b AND f1.a<f2.a ) WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using indexDROP TABLE t1;CREATE TABLE t1 (c1 INT, c2 INT);INSERT INTO t1 VALUES (1,11), (2,22), (2,22);EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))))) > 0;id select_type table type possible_keys key key_len ref rows Extra1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where31 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used32 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables usedEXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0;ERROR HY000: Too high level of nesting for selectDROP TABLE t1;CREATE TABLE t1 (c1 int(11) NOT NULL AUTO_INCREMENT,c2 varchar(1000) DEFAULT NULL,c3 bigint(20) DEFAULT NULL,c4 bigint(20) DEFAULT NULL,PRIMARY KEY (c1));EXPLAIN EXTENDED SELECT join_2.c1 FROM t1 AS join_0, t1 AS join_1, t1 AS join_2, t1 AS join_3, t1 AS join_4, t1 AS join_5, t1 AS join_6, t1 AS join_7WHERE join_0.c1=join_1.c1 AND join_1.c1=join_2.c1 AND join_2.c1=join_3.c1 AND join_3.c1=join_4.c1 AND join_4.c1=join_5.c1 AND join_5.c1=join_6.c1 AND join_6.c1=join_7.c1 OR join_0.c2 < '?' AND join_1.c2 < '?' ANDjoin_2.c2 > '?' ANDjoin_2.c2 < '!' ANDjoin_3.c2 > '?' AND join_4.c2 = '?' AND join_5.c2 <> '?' ANDjoin_6.c2 <> '?' AND join_7.c2 >= '?' ANDjoin_0.c1=join_1.c1 AND join_1.c1=join_2.c1 AND join_2.c1=join_3.c1 ANDjoin_3.c1=join_4.c1 AND join_4.c1=join_5.c1 AND join_5.c1=join_6.c1 AND join_6.c1=join_7.c1GROUP BY join_3.c1,join_2.c1,join_7.c1,join_1.c1,join_0.c1;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tablesWarnings:Note 1003 select NULL AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where 0 group by NULL,NULL,NULL,NULL,NULLSHOW WARNINGS;Level Code MessageNote 1003 select NULL AS `c1` from `test`.`t1` `join_0` join `test`.`t1` `join_1` join `test`.`t1` `join_2` join `test`.`t1` `join_3` join `test`.`t1` `join_4` join `test`.`t1` `join_5` join `test`.`t1` `join_6` join `test`.`t1` `join_7` where 0 group by NULL,NULL,NULL,NULL,NULLDROP TABLE t1;SELECT 1 AS ` `;
1Warnings:Warning 1474 Name ' ' has become ''SELECT 1 AS ` `;
1Warnings:Warning 1474 Name ' ' has become ''SELECT 1 AS ` x`;x1Warnings:Warning 1466 Leading spaces are removed from name ' x'CREATE VIEW v1 AS SELECT 1 AS ``;ERROR 42000: Incorrect column name ''CREATE VIEW v1 AS SELECT 1 AS ` `;ERROR 42000: Incorrect column name ' 'CREATE VIEW v1 AS SELECT 1 AS ` `;ERROR 42000: Incorrect column name ' 'CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `);ERROR 42000: Incorrect column name ' 'CREATE VIEW v1 AS SELECT 1 AS ` x`;Warnings:Warning 1466 Leading spaces are removed from name ' x'SELECT `x` FROM v1;x1ALTER VIEW v1 AS SELECT 1 AS ` `;ERROR 42000: Incorrect column name ' 'DROP VIEW v1;select str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' and '2007/10/20 00:00:00 GMT';str_to_date('2007-10-09','%Y-%m-%d') between '2007/10/01 00:00:00 GMT' and '2007/10/20 00:00:00 GMT'1Warnings:Warning 1292 Truncated incorrect datetime value: '2007/10/01 00:00:00 GMT'Warning 1292 Truncated incorrect datetime value: '2007/10/20 00:00:00 GMT'select str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6';str_to_date('2007-10-09','%Y-%m-%d') > '2007/10/01 00:00:00 GMT-6'1Warnings:Warning 1292 Truncated incorrect date value: '2007/10/01 00:00:00 GMT-6'select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'1Warnings:Warning 1292 Truncated incorrect date value: '2007/10/2000:00:00 GMT-6'select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'1Warnings:Warning 1292 Truncated incorrect date value: '2007-10-1 00:00:00 GMT-6'select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6';str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 x00:00:00 GMT-6'1Warnings:Warning 1292 Truncated incorrect date value: '2007-10-01 x00:00:00 GMT-6'select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6';str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:00:00 GMT-6'1Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:00:00 GMT-6'select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6';str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 00:x00:00 GMT-6'1Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-01 00:x00:00 GMT-6'select str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6';str_to_date('2007-10-01','%Y-%m-%d %H:%i:%s') = '2007-10-01 x12:34:56 GMT-6'1Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-01 x12:34:56 GMT-6'select str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';str_to_date('2007-10-01 12:34:00','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'1Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6'select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6';str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34x:56 GMT-6'0Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34x:56 GMT-6'select str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56';str_to_date('2007-10-01 12:34:56','%Y-%m-%d %H:%i:%s') = '2007-10-01 12:34:56'1select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00';str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-01 12:00:00'0select str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00';str_to_date('2007-10-01 12','%Y-%m-%d %H') = '2007-10-01 12:00:00'1select str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00';str_to_date('2007-10-01 12:34','%Y-%m-%d %H') = '2007-10-01 12:00:00'1Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-01 12:34'select str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34';str_to_date('2007-02-30 12:34','%Y-%m-%d %H:%i') = '2007-02-30 12:34'1select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'1select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' and '2007/10/20 00:00:00';str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01 00:00:00' and '2007/10/20 00:00:00'1set SQL_MODE=TRADITIONAL;select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'0Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'0Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'0Warnings:Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34:00'select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' and '2007/10/20';str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01' and '2007/10/20'0Warnings:Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1set SQL_MODE=DEFAULT;select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'1Warnings:Warning 1292 Truncated incorrect datetime value: ''select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'0select str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34';str_to_date('','%Y-%m-%d %H:%i') = '2007-10-01 12:34'0select str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34';str_to_date(NULL,'%Y-%m-%d %H:%i') = '2007-10-01 12:34'NULLselect str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''0Warnings:Warning 1292 Truncated incorrect datetime value: ''select str_to_date('1','%Y-%m-%d') = '1';str_to_date('1','%Y-%m-%d') = '1'0Warnings:Warning 1292 Truncated incorrect date value: '1'select str_to_date('1','%Y-%m-%d') = '1';str_to_date('1','%Y-%m-%d') = '1'0Warnings:Warning 1292 Truncated incorrect date value: '1'select str_to_date('','%Y-%m-%d') = '';str_to_date('','%Y-%m-%d') = ''0Warnings:Warning 1292 Truncated incorrect date value: ''select str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL;str_to_date('1000-01-01','%Y-%m-%d') between '0000-00-00' and NULL0select str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00';str_to_date('1000-01-01','%Y-%m-%d') between NULL and '2000-00-00'0select str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL;str_to_date('1000-01-01','%Y-%m-%d') between NULL and NULL0CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL, c22 INT DEFAULT NULL, KEY(c21, c22));CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0, c32 INT DEFAULT NULL, c33 INT NOT NULL, c34 INT UNSIGNED DEFAULT 0,KEY (c33, c34, c32));INSERT INTO t1 values (),(),(),(),();INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b;INSERT INTO t3 VALUES (1, 1, 1, 0), (2, 2, 0, 0), (3, 3, 1, 0), (4, 4, 0, 0), (5, 5, 1, 0);SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND t3.c33 = 1 AND t2.c22 in (1, 3) ORDER BY c32;c32113355SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND t3.c33 = 1 AND t2.c22 in (1, 3) ORDER BY c32 DESC;c32553311DROP TABLE t1, t2, t3;
## Bug#30736: Row Size Too Large Error Creating a Table and# Inserting Data.#DROP TABLE IF EXISTS t1;DROP TABLE IF EXISTS t2;
CREATE TABLE t1(c1 DECIMAL(10, 2),c2 FLOAT);
INSERT INTO t1 VALUES (0, 1), (2, 3), (4, 5);
CREATE TABLE t2(c3 DECIMAL(10, 2))SELECTc1 * c2 AS c3FROM t1;
SELECT * FROM t1;c1 c20.00 12.00 34.00 5
SELECT * FROM t2;c30.006.0020.00
DROP TABLE t1;DROP TABLE t2;
CREATE TABLE t1 (c1 BIGINT NOT NULL);INSERT INTO t1 (c1) VALUES (1);SELECT * FROM t1 WHERE c1 > NULL + 1;c1DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY);INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0');SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar');afoo0DROP TABLE t1;CREATE TABLE t1 (a INT, b INT);CREATE TABLE t2 (a INT, c INT, KEY(a));INSERT INTO t1 VALUES (1, 1), (2, 2);INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),(2, 1), (2, 2), (2, 3), (2, 4), (2, 5),(3, 1), (3, 2), (3, 3), (3, 4), (3, 5),(4, 1), (4, 2), (4, 3), (4, 4), (4, 5);FLUSH STATUS;SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3;b12SHOW STATUS LIKE 'Handler_read%';Variable_name ValueHandler_read_first 0Handler_read_key 2Handler_read_next 0Handler_read_prev 0Handler_read_rnd 0Handler_read_rnd_next 6DROP TABLE t1, t2;CREATE TABLE t1 (f1 bigint(20) NOT NULL default '0',f2 int(11) NOT NULL default '0',f3 bigint(20) NOT NULL default '0',f4 varchar(255) NOT NULL default '',PRIMARY KEY (f1),KEY key1 (f4),KEY key2 (f2));CREATE TABLE t2 (f1 int(11) NOT NULL default '0',f2 enum('A1','A2','A3') NOT NULL default 'A1',f3 int(11) NOT NULL default '0',PRIMARY KEY (f1),KEY key1 (f3));CREATE TABLE t3 (f1 bigint(20) NOT NULL default '0',f2 datetime NOT NULL default '1980-01-01 00:00:00',PRIMARY KEY (f1));insert into t1 values (1, 1, 1, 'abc');insert into t1 values (2, 1, 2, 'def');insert into t1 values (3, 1, 2, 'def');insert into t2 values (1, 'A1', 1);insert into t3 values (1, '1980-01-01');SELECT a.f3, cr.f4, count(*) countFROM t2 aSTRAIGHT_JOIN t1 cr ON cr.f2 = a.f1LEFT JOIN(t1 cr2JOIN t3 ae2 ON cr2.f3 = ae2.f1) ON a.f1 = cr2.f2 AND ae2.f2 < now() - INTERVAL 7 DAY ANDcr.f4 = cr2.f4GROUP BY a.f3, cr.f4;f3 f4 count1 abc 11 def 2drop table t1, t2, t3;CREATE TABLE t1 (a INT KEY, b INT);INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using whereWarnings:Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using whereWarnings:Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2DROP TABLE t1;## Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when # forcing a spatial index#CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a));INSERT INTO t1 VALUES(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')),(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'));EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 2 1 SIMPLE t2 ALL a NULL NULL NULL 2 SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;11111EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 2 1 SIMPLE t2 ALL a NULL NULL NULL 2 SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);11111DROP TABLE t1;## Bug #48291 : crash with row() operator,select into @var, and # subquery returning multiple rows#CREATE TABLE t1(a INT);INSERT INTO t1 VALUES (2),(3);# Should not crashSELECT 1 FROM t1 WHERE a <> 1 AND NOTROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1))INTO @var0;ERROR 21000: Subquery returns more than 1 rowDROP TABLE t1;## Bug #48458: simple query tries to allocate enormous amount of# memory#CREATE TABLE t1(a INT NOT NULL, b YEAR);INSERT INTO t1 VALUES ();Warnings:Warning 1364 Field 'a' doesn't have a default valueCREATE TABLE t2(c INT);# Should not err out because of out-of-memorySELECT 1 FROM t2 JOIN t1 ON 1=1WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a);1DROP TABLE t1,t2;## Bug #49199: Optimizer handles incorrectly: # field='const1' AND field='const2' in some cases
CREATE TABLE t1(a DATETIME NOT NULL);INSERT INTO t1 VALUES('2001-01-01');SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';a2001-01-01 00:00:00EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings:Note 1003 select '2001-01-01 00:00:00' AS `a` from `test`.`t1` where 1DROP TABLE t1;CREATE TABLE t1(a DATE NOT NULL);INSERT INTO t1 VALUES('2001-01-01');SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';a2001-01-01EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings:Note 1003 select '2001-01-01' AS `a` from `test`.`t1` where 1DROP TABLE t1;CREATE TABLE t1(a TIMESTAMP NOT NULL);INSERT INTO t1 VALUES('2001-01-01');SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';a2001-01-01 00:00:00EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a='2001-01-01 00:00:00';id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings:Note 1003 select '2001-01-01 00:00:00' AS `a` from `test`.`t1` where 1DROP TABLE t1;CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL);INSERT INTO t1 VALUES('2001-01-01', '2001-01-01');SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00';a b2001-01-01 00:00:00 2001-01-01EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00';id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings:Note 1003 select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 1DROP TABLE t1;CREATE TABLE t1(a DATETIME NOT NULL, b VARCHAR(20) NOT NULL);INSERT INTO t1 VALUES('2001-01-01', '2001-01-01');SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00';a bEXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01' AND a=b AND b='2001-01-01 00:00:00';id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tablesWarnings:Note 1003 select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 0SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01';a b2001-01-01 00:00:00 2001-01-01EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='2001-01-01 00:00:00' AND a=b AND b='2001-01-01';id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings:Note 1003 select '2001-01-01 00:00:00' AS `a`,'2001-01-01' AS `b` from `test`.`t1` where 1DROP TABLE t1;CREATE TABLE t1(a DATETIME NOT NULL, b DATE NOT NULL);INSERT INTO t1 VALUES('2001-01-01', '2001-01-01');SELECT x.a, y.a, z.a FROM t1 x JOIN t1 y ON x.a=y.a JOIN t1 z ON y.a=z.a WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00';a a a2001-01-01 00:00:00 2001-01-01 00:00:00 2001-01-01 00:00:00EXPLAIN EXTENDED SELECT x.a, y.a, z.a FROM t1 x JOIN t1 y ON x.a=y.a JOIN t1 z ON y.a=z.a WHERE x.a='2001-01-01' AND z.a='2001-01-01 00:00:00';id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE x system NULL NULL NULL NULL 1 100.00 1 SIMPLE y system NULL NULL NULL NULL 1 100.00 1 SIMPLE z system NULL NULL NULL NULL 1 100.00 Warnings:Note 1003 select '2001-01-01 00:00:00' AS `a`,'2001-01-01 00:00:00' AS `a`,'2001-01-01 00:00:00' AS `a` from `test`.`t1` `x` join `test`.`t1` `y` join `test`.`t1` `z` where 1DROP TABLE t1;## Bug #49897: crash in ptr_compare when char(0) NOT NULL # column is used for ORDER BY#SET @old_sort_buffer_size= @@session.sort_buffer_size;SET @@sort_buffer_size= 40000;CREATE TABLE t1(a CHAR(0) NOT NULL);INSERT INTO t1 VALUES (0), (0), (0);INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12;INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12;INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12;EXPLAIN SELECT a FROM t1 ORDER BY a;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 SELECT a FROM t1 ORDER BY a;DROP TABLE t1;CREATE TABLE t1(a CHAR(0) NOT NULL, b CHAR(0) NOT NULL, c int);INSERT INTO t1 VALUES (0, 0, 0), (0, 0, 2), (0, 0, 1);INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12;INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12;INSERT INTO t1 SELECT t11.a, t11.b, t11.c FROM t1 t11, t1 t12;EXPLAIN SELECT a FROM t1 ORDER BY a LIMIT 5;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 SELECT a FROM t1 ORDER BY a LIMIT 5;a
EXPLAIN SELECT * FROM t1 ORDER BY a, b LIMIT 5;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 SELECT * FROM t1 ORDER BY a, b LIMIT 5;a b c 0 2 1 0 2EXPLAIN SELECT * FROM t1 ORDER BY a, b, c LIMIT 5;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 Using filesortSELECT * FROM t1 ORDER BY a, b, c LIMIT 5;a b c 0 0 0 0 0EXPLAIN SELECT * FROM t1 ORDER BY c, a LIMIT 5;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ALL NULL NULL NULL NULL 24492 Using filesortSELECT * FROM t1 ORDER BY c, a LIMIT 5;a b c 0 0 0 0 0SET @@sort_buffer_size= @old_sort_buffer_size;DROP TABLE t1;End of 5.0 testscreate table t1(a INT, KEY (a));INSERT INTO t1 VALUES (1),(2),(3),(4),(5);SELECT a FROM t1 ORDER BY a LIMIT 2;a12SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296;a345SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297;a345DROP TABLE t1;CREATE TABLE A (date_key date);CREATE TABLE C (pk int,int_nokey int,int_key int,date_key date NOT NULL,date_nokey date,varchar_key varchar(1));INSERT INTO C VALUES (1,1,1,'0000-00-00',NULL,NULL),(1,1,1,'0000-00-00',NULL,NULL);SELECT 1 FROM C WHERE pk > ANY (SELECT 1 FROM C);1SELECT COUNT(DISTINCT 1) FROM C WHERE date_key = (SELECT 1 FROM A WHERE C.date_key IS NULL) GROUP BY pk;COUNT(DISTINCT 1)SELECT date_nokey FROM C WHERE int_key IN (SELECT 1 FROM A) HAVING date_nokey = '10:41:7' ORDER BY date_key;date_nokeyWarnings:Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1DROP TABLE A,C;CREATE TABLE t1 (a INT NOT NULL, b INT);INSERT INTO t1 VALUES (1, 1);EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings:Note 1003 select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;a b1 1DROP TABLE t1;CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL);EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not foundWarnings:Note 1003 select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not foundWarnings:Note 1003 select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20;id select_type table type possible_keys key key_len ref rows filtered Extra1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not foundWarnings:Note 1003 select NULL AS `a`,NULL AS `b`,NULL AS `c` from `test`.`t1` where 1DROP TABLE t1;## Bug#45266: Uninitialized variable lead to an empty result.#drop table if exists A,AA,B,BB;CREATE TABLE `A` (`pk` int(11) NOT NULL AUTO_INCREMENT,`date_key` date NOT NULL,`date_nokey` date NOT NULL,`datetime_key` datetime NOT NULL,`int_nokey` int(11) NOT NULL,`time_key` time NOT NULL,`time_nokey` time NOT NULL,PRIMARY KEY (`pk`),KEY `date_key` (`date_key`),KEY `time_key` (`time_key`),KEY `datetime_key` (`datetime_key`));CREATE TABLE `AA` (`pk` int(11) NOT NULL AUTO_INCREMENT,`int_nokey` int(11) NOT NULL,`time_key` time NOT NULL,KEY `time_key` (`time_key`),PRIMARY KEY (`pk`));CREATE TABLE `B` (`date_nokey` date NOT NULL,`date_key` date NOT NULL,`time_key` time NOT NULL,`datetime_nokey` datetime NOT NULL,`varchar_key` varchar(1) NOT NULL,KEY `date_key` (`date_key`),KEY `time_key` (`time_key`),KEY `varchar_key` (`varchar_key`));INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x');CREATE TABLE `BB` (`pk` int(11) NOT NULL AUTO_INCREMENT,`int_nokey` int(11) NOT NULL,`date_key` date NOT NULL,`varchar_nokey` varchar(1) NOT NULL,`date_nokey` date NOT NULL,PRIMARY KEY (`pk`),KEY `date_key` (`date_key`));INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18');SELECT table1 . `pk` AS field1 FROM (BB AS table1 INNER JOIN (AA AS table2 STRAIGHT_JOIN A AS table3 ON ( table3 . `date_key` = table2 . `pk` ))ON ( table3 . `datetime_key` = table2 . `int_nokey` ))WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`)GROUP BY field1 ;field1SELECT table3 .`date_key` field1FROMB table1 LEFT JOIN B table3 JOIN(BB table6 JOIN A table7 ON table6 .`varchar_nokey`)ON table6 .`int_nokey` ON table6 .`date_key` WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1;field1NULLSELECT table4 . `time_nokey` AS field1 FROM (AA AS table1 CROSS JOIN (AA AS table2 STRAIGHT_JOIN (B AS table3 STRAIGHT_JOIN A AS table4 ON ( table4 . `date_key` = table3 . `time_key` ))ON ( table4 . `pk` = table3 . `date_nokey` ))ON ( table4 . `time_key` = table3 . `datetime_nokey` ))WHERE ( table4 . `time_key` < table1 . `time_key` ANDtable1 . `int_nokey` != 'f')GROUP BY field1 ORDER BY field1 , field1;field1SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2;field200:05:4815:13:38drop table A,AA,B,BB;#end of test for bug#45266# # BUG#48052: Valgrind warning - uninitialized value in init_read_record()# CREATE TABLE t1 (pk int(11) NOT NULL,i int(11) DEFAULT NULL,v varchar(1) DEFAULT NULL,PRIMARY KEY (pk));INSERT INTO t1 VALUES (2,7,'m');INSERT INTO t1 VALUES (3,9,'m');SELECT vFROM t1WHERE NOT pk > 0 HAVING v <= 't' ORDER BY pk;vDROP TABLE t1;## Bug#49489 Uninitialized cache led to a wrong result.#CREATE TABLE t1(c1 DOUBLE(5,4));INSERT INTO t1 VALUES (9.1234);SELECT * FROM t1 WHERE c1 < 9.12345;c19.1234DROP TABLE t1;# End of test for bug#49489.## Bug #49517: Inconsistent behavior while using # NULLable BIGINT and INT columns in comparison#CREATE TABLE t1(a BIGINT UNSIGNED NOT NULL, b BIGINT NULL, c INT NULL);INSERT INTO t1 VALUES(105, NULL, NULL);SELECT * FROM t1 WHERE b < 102;a b cSELECT * FROM t1 WHERE c < 102;a b cSELECT * FROM t1 WHERE 102 < b;a b cSELECT * FROM t1 WHERE 102 < c;a b cDROP TABLE t1;End of 5.1 tests
|