Commit graph

620 commits

Author SHA1 Message Date
unknown
fac190a28b Bug#27747 database metadata doesn't return sufficient column default info
added get_field_default_value() function which obtains default value from the field
(used in store_create_info() & get_schema_column_record() functions)


mysql-test/r/alter_table.result:
  result fix
mysql-test/r/create.result:
  result fix
mysql-test/r/ctype_collate.result:
  result fix
mysql-test/r/ctype_recoding.result:
  result fix
mysql-test/r/default.result:
  result fix
mysql-test/r/gis.result:
  result fix
mysql-test/r/grant.result:
  result fix
mysql-test/r/information_schema.result:
  result fix
mysql-test/r/key.result:
  result fix
mysql-test/r/mysql.result:
  result fix
mysql-test/r/ps_1general.result:
  result fix
mysql-test/r/show_check.result:
  result fix
mysql-test/r/sp.result:
  result fix
mysql-test/r/type_enum.result:
  result fix
mysql-test/r/type_ranges.result:
  result fix
mysql-test/t/information_schema.test:
  test case
2007-09-20 13:54:46 +05:00
gluh@mysql.com/eagle.(none)
6b81174cde Bug#27747 database metadata doesn't return sufficient column default info
added get_field_default_value() function which obtains default value from the field
(used in store_create_info() & get_schema_column_record() functions)
2007-09-20 13:54:46 +05:00
unknown
8076d23f41 WL#4030 (Deprecate RENAME DATABASE: replace with ALTER DATABASE <name>
UPGRADE)

Bug 17565 (RENAME DATABASE destroys events)
Bug#28360 (RENAME DATABASE destroys routines)

Removed the
  RENAME DATABASE db1 TO db2
statement.

Implemented the
  ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
statement, which has the same function.


client/mysqlcheck.c:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/create.result:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/query_cache.result:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/renamedb.result:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/sp-code.result:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/sp-error.result:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/r/upgrade.result:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/create.test:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/query_cache.test:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/renamedb.test:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/sp-error.test:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
mysql-test/t/upgrade.test:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/mysql_priv.h:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_lex.h:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_parse.cc:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_prepare.cc:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_yacc.yy:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
sql/sql_db.cc:
    ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
2007-09-10 16:10:37 -06:00
malff@lambda.weblab
18300001c1 WL#4030 (Deprecate RENAME DATABASE: replace with ALTER DATABASE <name>
UPGRADE)

Bug 17565 (RENAME DATABASE destroys events)
Bug#28360 (RENAME DATABASE destroys routines)

Removed the
  RENAME DATABASE db1 TO db2
statement.

Implemented the
  ALTER DATABASE db UPGRADE DATA DIRECTORY NAME
statement, which has the same function.
2007-09-10 16:10:37 -06:00
unknown
217a35d64f Merge gleb.loc:/home/uchum/work/bk/5.1
into  gleb.loc:/home/uchum/work/bk/5.1-opt


mysql-test/r/sp.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/create.result:
  Merge with 5.1 (main).
2007-07-26 05:13:32 +05:00
gshchepa/uchum@gleb.loc
2a1d621d2d Merge gleb.loc:/home/uchum/work/bk/5.1
into  gleb.loc:/home/uchum/work/bk/5.1-opt
2007-07-26 05:13:32 +05:00
unknown
2df3b7b0ea Merge gleb.loc:/home/uchum/work/bk/5.0
into  gleb.loc:/home/uchum/work/bk/5.0-opt


mysql-test/t/create.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/create.result:
  Merge with 5.0 (main).
2007-07-26 03:33:43 +05:00
gshchepa/uchum@gleb.loc
bb22e3667e Merge gleb.loc:/home/uchum/work/bk/5.0
into  gleb.loc:/home/uchum/work/bk/5.0-opt
2007-07-26 03:33:43 +05:00
unknown
21b83ab756 Merge gleb.loc:/home/uchum/work/bk/5.0-opt
into  gleb.loc:/home/uchum/work/bk/5.1-opt


mysql-test/r/having.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/having.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/include/mix1.inc:
  Merge with 5.0-opt.
mysql-test/r/create.result:
  Merge with 5.0-opt.
mysql-test/r/innodb_mysql.result:
  Merge with 5.0-opt.
mysql-test/r/type_enum.result:
  Merge with 5.0-opt.
mysql-test/t/type_enum.test:
  Merge with 5.0-opt.
sql/filesort.cc:
  Merge with 5.0-opt.
sql/sql_base.cc:
  Merge with 5.0-opt.
sql/table.cc:
  Merge with 5.0-opt.
storage/innobase/handler/ha_innodb.cc:
  Merge with 5.0-opt.
2007-07-26 01:23:39 +05:00
gshchepa/uchum@gleb.loc
3595bbb34c Merge gleb.loc:/home/uchum/work/bk/5.0-opt
into  gleb.loc:/home/uchum/work/bk/5.1-opt
2007-07-26 01:23:39 +05:00
unknown
c4d53e31b0 Bug#15130: CREATE .. SELECT was denied to use advantages of the SQL_BIG_RESULT.
When the SQL_BIG_RESULT flag is specified SELECT should store items from the
select list in the filesort data and use them when sending to a client.
The get_addon_fields function is responsible for creating necessary structures
for that. But this function was allowed to do so only for SELECT and
INSERT .. SELECT queries. This makes the SQL_BIG_RESULT useless for
the CREATE .. SELECT queries.

Now the get_addon_fields allows storing select list items in the filesort
data for the CREATE .. SELECT queries.


mysql-test/t/create.test:
  Added a test case for the bug#15130: CREATE .. SELECT was denied to use
  advantages of the SQL_BIG_RESULT.
mysql-test/r/create.result:
  Added a test case for the bug#15130: CREATE .. SELECT was denied to use
  advantages of the SQL_BIG_RESULT.
sql/filesort.cc:
  Bug#15130: CREATE .. SELECT was denied to use advantages of the SQL_BIG_RESULT.
  Now the get_addon_fields allows storing select list items in the filesort
  data for the CREATE .. SELECT queries.
2007-07-24 18:15:44 +04:00
evgen@moonbone.local
fd1a43b080 Bug#15130: CREATE .. SELECT was denied to use advantages of the SQL_BIG_RESULT.
When the SQL_BIG_RESULT flag is specified SELECT should store items from the
select list in the filesort data and use them when sending to a client.
The get_addon_fields function is responsible for creating necessary structures
for that. But this function was allowed to do so only for SELECT and
INSERT .. SELECT queries. This makes the SQL_BIG_RESULT useless for
the CREATE .. SELECT queries.

Now the get_addon_fields allows storing select list items in the filesort
data for the CREATE .. SELECT queries.
2007-07-24 18:15:44 +04:00
unknown
93de616578 A post-merge fix 2007-07-19 19:56:07 +04:00
kostja@bodhi.(none)
7ca9124d2e A post-merge fix 2007-07-19 19:56:07 +04:00
unknown
c0277a1192 A fix and a test case for Bug#26104 Bug on foreign key class constructor.
Fix the typo in the constructor. Cover a semantic check that previously
never worked with a test.


mysql-test/r/create.result:
  Update results (Bug#26104)
mysql-test/r/innodb.result:
  Update results.
mysql-test/t/create.test:
  Add a test case for Bug#26104 Bug on foreign key class constructor
mysql-test/t/innodb.test:
  Return a new error number (MySQL error instead of internal InnoDB error).
sql/sql_class.h:
  A fix for Bug#26104 Bug on foreign key class constructor -- fix
  the typo in the constructor
2007-07-18 16:22:05 +04:00
kostja@bodhi.(none)
9bac763cc1 A fix and a test case for Bug#26104 Bug on foreign key class constructor.
Fix the typo in the constructor. Cover a semantic check that previously
never worked with a test.
2007-07-18 16:22:05 +04:00
unknown
0852b3693f Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  bodhi.(none):/opt/local/work/mysql-5.1-runtime


mysql-test/r/create.result:
  Auto merged
mysql-test/r/events_bugs.result:
  Auto merged
sql/event_data_objects.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/table.cc:
  Auto merged
2007-07-02 01:35:52 +04:00
kostja@bodhi.(none)
6a5ce49d09 Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  bodhi.(none):/opt/local/work/mysql-5.1-runtime
2007-07-02 01:35:52 +04:00
unknown
f9d36194a0 Post-merge fix. 2007-06-30 22:50:14 -07:00
igor@olga.mysql.com
f93f44e739 Post-merge fix. 2007-06-30 22:50:14 -07:00
unknown
405f82d390 Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
    has a non-ascii symbol
  - BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
  - BUG#19443: INFORMATION_SCHEMA does not support charsets properly
  - BUG#21249: Character set of SP-var can be ignored
  - BUG#25212: Character set of string constant is ignored (stored routines)
  - BUG#25221: Character set of string constant is ignored (triggers)

There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
   triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
   inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
   definition;

1. No query-definition-character set.

In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.

The context contains the following data:
  - client character set;
  - connection collation (character set and collation);
  - collation of the owner database;

The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).

2. Wrong mysqldump-output.

The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.

Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).

The solution is
  - to store definition queries in the original character set;
  - to change SHOW CREATE statement to output definition query in the
    binary character set (i.e. without any conversion);
  - introduce SHOW CREATE TRIGGER statement;
  - to dump special statements to switch the context to the original one
    before dumping and restore it afterwards.

Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.

3. INFORMATION_SCHEMA showed non-UTF8 strings

The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.

Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.

This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object.  Specialized SHOW CREATE statements should be
used for this.

The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).

Example:

  - original query:
    CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;

  - UTF8 query (for INFORMATION_SCHEMA):
    CREATE VIEW v1 AS SELECT 'Hello' AS c1;


client/mysqldump.c:
  Set original character set and collation before dumping definition query.
include/my_sys.h:
  Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
  Ignore server-warnings during the test case.
mysql-test/r/create.result:
  Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
  Update result file.
mysql-test/r/events.result:
  Update result file.
mysql-test/r/events_bugs.result:
  Update result file.
mysql-test/r/events_grant.result:
  Update result file.
mysql-test/r/func_in.result:
  Update result file.
mysql-test/r/gis.result:
  Update result file.
mysql-test/r/grant.result:
  Update result file.
mysql-test/r/information_schema.result:
  Update result file.
mysql-test/r/information_schema_db.result:
  Update result file.
mysql-test/r/lowercase_view.result:
  Update result file.
mysql-test/r/mysqldump.result:
  Update result file.
mysql-test/r/ndb_sp.result:
  Update result file.
mysql-test/r/ps.result:
  Update result file.
mysql-test/r/rpl_replicate_do.result:
  Update result file.
mysql-test/r/rpl_sp.result:
  Update result file.
mysql-test/r/rpl_trigger.result:
  Update result file.
mysql-test/r/rpl_view.result:
  Update result file.
mysql-test/r/show_check.result:
  Update result file.
mysql-test/r/skip_grants.result:
  Update result file.
mysql-test/r/sp-destruct.result:
  Update result file.
mysql-test/r/sp-error.result:
  Update result file.
mysql-test/r/sp-security.result:
  Update result file.
mysql-test/r/sp.result:
  Update result file.
mysql-test/r/sql_mode.result:
  Update result file.
mysql-test/r/system_mysql_db.result:
  Update result file.
mysql-test/r/temp_table.result:
  Update result file.
mysql-test/r/trigger-compat.result:
  Update result file.
mysql-test/r/trigger-grant.result:
  Update result file.
mysql-test/r/trigger.result:
  Update result file.
mysql-test/r/view.result:
  Update result file.
mysql-test/r/view_grant.result:
  Update result file.
mysql-test/t/events.test:
  Update test case (new columns added).
mysql-test/t/information_schema.test:
  Update test case (new columns added).
mysql-test/t/show_check.test:
  Test case for SHOW CREATE TRIGGER in prepared statements and
  stored routines.
mysql-test/t/sp-destruct.test:
  Update test case (new columns added).
mysql-test/t/sp.test:
  Update test case (new columns added).
mysql-test/t/view.test:
  Update test.
mysys/charset.c:
  Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
  Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
  Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
  Support new attributes for events.
sql/event_data_objects.h:
  Support new attributes for events.
sql/event_db_repository.cc:
  Support new attributes for events.
sql/event_db_repository.h:
  Support new attributes for events.
sql/events.cc:
  Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
  1. Introduce Object_creation_ctx;
  2. Introduce SHOW CREATE TRIGGER;
  3. Introduce auxilary functions.
sql/sp.cc:
  Add support for new store routines attributes.
sql/sp_head.cc:
  Add support for new store routines attributes.
sql/sp_head.h:
  Add support for new store routines attributes.
sql/sql_lex.cc:
  Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
  1. Generate UTF8-body on parsing/lexing.
  2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
  Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
  Update parse_sql().
sql/sql_prepare.cc:
  Update parse_sql().
sql/sql_show.cc:
  Support new attributes for views
sql/sql_trigger.cc:
  Support new attributes for views
sql/sql_trigger.h:
  Support new attributes for views
sql/sql_view.cc:
  Support new attributes for views
sql/sql_yacc.yy:
  1. Add SHOW CREATE TRIGGER statement.
  2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
  Introduce Object_creation_ctx.
sql/table.h:
  Introduce Object_creation_ctx.
sql/share/errmsg.txt:
  Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
  Aux file for test suite.
mysql-test/include/have_cp1251.inc:
  Aux file for test suite.
mysql-test/include/have_cp866.inc:
  Aux file for test suite.
mysql-test/include/have_koi8r.inc:
  Aux file for test suite.
mysql-test/include/have_utf8.inc:
  Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
  Result file.
mysql-test/r/ddl_i18n_utf8.result:
  Result file.
mysql-test/r/have_cp1251.require:
  Aux file for test suite.
mysql-test/r/have_cp866.require:
  Aux file for test suite.
mysql-test/r/have_koi8r.require:
  Aux file for test suite.
mysql-test/r/have_utf8.require:
  Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
  Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
  Complete utf8 test case for the CS patch.
2007-06-28 21:34:54 +04:00
anozdrin/alik@ibm.
9fae9ef66f Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
    has a non-ascii symbol
  - BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
  - BUG#19443: INFORMATION_SCHEMA does not support charsets properly
  - BUG#21249: Character set of SP-var can be ignored
  - BUG#25212: Character set of string constant is ignored (stored routines)
  - BUG#25221: Character set of string constant is ignored (triggers)

There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
   triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
   inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
   definition;

1. No query-definition-character set.

In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.

The context contains the following data:
  - client character set;
  - connection collation (character set and collation);
  - collation of the owner database;

The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).

2. Wrong mysqldump-output.

The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.

Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).

The solution is
  - to store definition queries in the original character set;
  - to change SHOW CREATE statement to output definition query in the
    binary character set (i.e. without any conversion);
  - introduce SHOW CREATE TRIGGER statement;
  - to dump special statements to switch the context to the original one
    before dumping and restore it afterwards.

Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.

3. INFORMATION_SCHEMA showed non-UTF8 strings

The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.

Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.

This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object.  Specialized SHOW CREATE statements should be
used for this.

The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).

Example:

  - original query:
    CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;

  - UTF8 query (for INFORMATION_SCHEMA):
    CREATE VIEW v1 AS SELECT 'Hello' AS c1;
2007-06-28 21:34:54 +04:00
unknown
0c31d0bbd7 Bug #26642: create index corrupts table definition in .frm
Thanks to Martin Friebe for finding and submitting a fix for this bug!
  
  A table with maximum number of key segments and maximum length key name
  would have a corrupted .frm file, due to an incorrect calculation of the
  complete key length.  Now the key length is computed correctly (I hope) :-)
  
  MyISAM would reject a table with the maximum number of keys and the maximum
  number of key segments in all keys.  It would allow one less than this total
  maximum.  Now MyISAM accepts a table defined with the maximum.  (This is a
  very minor issue.)


myisam/mi_open.c:
  Bug #26642: change >= to > in a comparison (i.e., error 
  only if key_parts_in_table really is greater than 
  MAX_KEY * MAX_KEY_SEG)
mysql-test/r/create.result:
  Bug #26642: test case
mysql-test/t/create.test:
  Bug #26642: test case
sql/table.cc:
  Bug #26642: In create_frm(), fix formula for key_length; 
  it was too small by (keys * 2) bytes
2007-06-27 14:35:49 +03:00
gkodinov/kgeorge@magare.gmz
0b421fad4a Bug #26642: create index corrupts table definition in .frm
Thanks to Martin Friebe for finding and submitting a fix for this bug!
  
  A table with maximum number of key segments and maximum length key name
  would have a corrupted .frm file, due to an incorrect calculation of the
  complete key length.  Now the key length is computed correctly (I hope) :-)
  
  MyISAM would reject a table with the maximum number of keys and the maximum
  number of key segments in all keys.  It would allow one less than this total
  maximum.  Now MyISAM accepts a table defined with the maximum.  (This is a
  very minor issue.)
2007-06-27 14:35:49 +03:00
unknown
0f6047e455 Bug #28842 Different 'duplicate key' error code between 5.0 and 5.1
The patch for WL 1563 added a new duplicate key error message so that the
  key name could be provided instead of the key number. But the error code
  for the new message was used even though that did not need to change.

  This could cause unnecessary problems for applications that used the old
  ER_DUP_ENTRY error code to detect duplicate key errors.


mysql-test/t/auto_increment.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/create.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/create_select_tmp.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/ctype_ucs2_def.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/ctype_utf8.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/delayed.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/heap.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/heap_btree.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/heap_hash.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/innodb.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/insert_select.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/insert_update.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/join_outer.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/key.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/merge.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/myisam.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/ndb_basic.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/ndb_charset.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/ndb_index_unique.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/ndb_insert.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/ndb_replace.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/ndb_update.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/replace.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/rpl_err_ignoredtable.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/rpl_ndb_do_table.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/rpl_row_create_table.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/rpl_sp.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/show_check.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/sp-error.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/sp.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/sp_trans.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/sp_trans_log.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/temp_table.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/type_binary.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/type_bit.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/type_bit_innodb.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/type_blob.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/t/type_varchar.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/r/create.result:
  Update ER_DUP_ENTRY-related error message values
mysql-test/r/rpl_sp.result:
  Update ER_DUP_ENTRY-related error message values
mysql-test/r/sp.result:
  Update ER_DUP_ENTRY-related error message values
mysql-test/include/mix1.inc:
  Update ER_DUP_ENTRY-related error message values
mysql-test/include/mix2.inc:
  Update ER_DUP_ENTRY-related error message values
mysql-test/include/ps_modify.inc:
  Update ER_DUP_ENTRY-related error message values
mysql-test/include/query_cache.inc:
  Update ER_DUP_ENTRY-related error message values
mysql-test/include/varchar.inc:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/binlog_tests/insert_select-binlog.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_auto_increment.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_foreign_key.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_insert_delayed.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_insert_id.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_insert_id_pk.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_loaddata.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_row_basic.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test:
  Update ER_DUP_ENTRY-related error message values
mysql-test/extra/rpl_tests/rpl_trig004.test:
  Update ER_DUP_ENTRY-related error message values
sql/handler.cc:
  Restore use of ER_DUP_ENTRY error code even when ER_DUP_ENTRY_WITH_KEY_NAME
  error message is being used. (Bug #28842)
2007-06-06 10:57:07 -07:00
jimw@rama.(none)
3c93323d28 Bug #28842 Different 'duplicate key' error code between 5.0 and 5.1
The patch for WL 1563 added a new duplicate key error message so that the
  key name could be provided instead of the key number. But the error code
  for the new message was used even though that did not need to change.

  This could cause unnecessary problems for applications that used the old
  ER_DUP_ENTRY error code to detect duplicate key errors.
2007-06-06 10:57:07 -07:00
unknown
11b084102d backport of Bug#11491 Misleading error message if not NULL column set to NULL, SQL mode TRADITIONAL
mysql-test/r/auto_increment.result:
  result fix
mysql-test/r/create.result:
  result fix
mysql-test/r/insert.result:
  result fix
mysql-test/r/insert_select.result:
  result fix
mysql-test/r/insert_update.result:
  result fix
mysql-test/r/key.result:
  result fix
mysql-test/r/null.result:
  result fix
mysql-test/r/null_key.result:
  result fix
mysql-test/r/ps_2myisam.result:
  result fix
mysql-test/r/ps_3innodb.result:
  result fix
mysql-test/r/ps_4heap.result:
  result fix
mysql-test/r/ps_5merge.result:
  result fix
mysql-test/r/ps_6bdb.result:
  result fix
mysql-test/r/ps_7ndb.result:
  result fix
mysql-test/r/strict.result:
  result fix
mysql-test/r/view.result:
  result fix
mysql-test/r/warnings.result:
  result fix
mysql-test/t/strict.test:
  test fix
2007-05-30 17:04:04 +05:00
gluh@mysql.com/eagle.(none)
cdbdc4e745 backport of Bug#11491 Misleading error message if not NULL column set to NULL, SQL mode TRADITIONAL 2007-05-30 17:04:04 +05:00
unknown
206a6bb176 5.1 version of fix for:
Bug #23667 "CREATE TABLE LIKE is not isolated from alteration
              by other connections"
  Bug #18950 "CREATE TABLE LIKE does not obtain LOCK_open"
As well as:
  Bug #25578 "CREATE TABLE LIKE does not require any privileges
              on source table".

The first and the second bugs resulted in various errors and wrong
binary log order when one tried to execute concurrently CREATE TABLE LIKE
statement and DDL statements on source table or DML/DDL statements on its
target table.

The problem was caused by incomplete protection/table-locking against
concurrent statements implemented in mysql_create_like_table() routine.
We solve it by simply implementing such protection in proper way.
Most of actual work for 5.1 was already done by fix for bug 20662 and
preliminary patch changing locking in ALTER TABLE.

The third bug allowed user who didn't have any privileges on table create
its copy and therefore circumvent privilege check for SHOW CREATE TABLE.

This patch solves this problem by adding privilege check, which was missing.

Finally it also removes some duplicated code from mysql_create_like_table()
and thus fixes bug #26869 "TABLE_LIST::table_name_length inconsistent with
TABLE_LIST::table_name".


mysql-test/r/create-big.result:
  Added test coverage for concurrency-related issues with CREATE TABLE LIKE.
mysql-test/r/create.result:
  Adjusted error-code in the test case after refactoring code that
  implements CREATE TABLE ... LIKE.
mysql-test/r/grant2.result:
  Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges
  on source table".
mysql-test/t/create-big.test:
  Added test coverage for concurrency-related issues with CREATE TABLE LIKE.
mysql-test/t/create.test:
  Adjusted error-code in the test case after refactoring code that
  implements CREATE TABLE ... LIKE.
mysql-test/t/disabled.def:
  Recent code changes ensured that CREATE TABLE LIKE statement is properly
  isolated against other statements, so synchronization.test should no
  longer fail (see fix for bug 20662 and preliminary patch for bug 23667
  changing ALTER TABLE locking).
mysql-test/t/grant2.test:
  Added test for bug#25578 "CREATE TABLE LIKE does not require any privileges
  on source table".
sql/handler.h:
  Introduced new flag for HA_CREATE_INFO::options in order to be able to
  distinguish CREATE TABLE ... LIKE from other types of CREATE TABLE.
sql/mysql_priv.h:
  mysql_create_like_table() now takes source table name not as a
  Table_ident object but as regular table list element.
sql/sql_lex.h:
  Removed LEX::like_name member. Now we use special flag in
  LEX::create_info::options for distinguishing CREATE TABLE ... LIKE
  from other types of CREATE TABLE and store name of source table as
  regular element in statement's table list.
sql/sql_parse.cc:
  CREATE TABLE ... LIKE implementation now uses statement's table list
  for storing information about the source table. We also use flag
  in LEX::create_info.options for distinguishing it from other types
  of CREATE TABLE.
  Finally CREATE TABLE ... LIKE now requires the same privileges on
  the source tables as SHOW CREATE TABLE. Moved this privilege check
  to check_show_create_table_access() function.
sql/sql_partition.cc:
  Now we use special flag in LEX::create_info::options for distinguishing
  CREATE TABLE ... LIKE from other types of CREATE TABLE and store name
  of source table as regular element in statement's table list.
sql/sql_table.cc:
  mysql_create_like_table():  
   - Commented and cleaned-up a bit code which is responsible for achieving
     isolation from concurrent statements. Most of actual work was done by
     fix for bug 20662 and preliminary patch changing locking locking in
     ALTER TABLE, so here we do minor things like relaxing locking on
     source table (we don't need lock on it, to have it open is enough) and
     adjusting code to make it more friendly against code implementing I_S.
   - Get rid of duplicated code related to source database/table name
     handling. All these operations are already done in
     st_select_lex::add_table_to_list(), so we achieve the same effect
     by including source table into the statement's table list.
sql/sql_yacc.yy:
  Now we use special flag in LEX::create_info::options for distinguishing
  CREATE TABLE ... LIKE from other types of CREATE TABLE and store name
  of source table as regular element in statement's table list.
2007-05-23 15:26:16 +04:00
dlenev@mockturtle.local
8e8f4c05cc 5.1 version of fix for:
Bug #23667 "CREATE TABLE LIKE is not isolated from alteration
              by other connections"
  Bug #18950 "CREATE TABLE LIKE does not obtain LOCK_open"
As well as:
  Bug #25578 "CREATE TABLE LIKE does not require any privileges
              on source table".

The first and the second bugs resulted in various errors and wrong
binary log order when one tried to execute concurrently CREATE TABLE LIKE
statement and DDL statements on source table or DML/DDL statements on its
target table.

The problem was caused by incomplete protection/table-locking against
concurrent statements implemented in mysql_create_like_table() routine.
We solve it by simply implementing such protection in proper way.
Most of actual work for 5.1 was already done by fix for bug 20662 and
preliminary patch changing locking in ALTER TABLE.

The third bug allowed user who didn't have any privileges on table create
its copy and therefore circumvent privilege check for SHOW CREATE TABLE.

This patch solves this problem by adding privilege check, which was missing.

Finally it also removes some duplicated code from mysql_create_like_table()
and thus fixes bug #26869 "TABLE_LIST::table_name_length inconsistent with
TABLE_LIST::table_name".
2007-05-23 15:26:16 +04:00
unknown
d46c8ce634 Fix for:
Bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT
              with locked tables"
  Bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers"
  Bug #24738 "CREATE TABLE ... SELECT is not isolated properly"
  Bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when
              temporary table exists"

Deadlock occured when one tried to execute CREATE TABLE IF NOT
EXISTS ... SELECT statement under LOCK TABLES which held
read lock on target table.
Attempt to execute the same statement for already existing
target table with triggers caused server crashes.
Also concurrent execution of CREATE TABLE ... SELECT statement
and other statements involving target table suffered from
various races (some of which might've led to deadlocks).
Finally, attempt to execute CREATE TABLE ... SELECT in case
when a temporary table with same name was already present
led to the insertion of data into this temporary table and
creation of empty non-temporary table.
 
All above problems stemmed from the old implementation of CREATE
TABLE ... SELECT in which we created, opened and locked target
table without any special protection in a separate step and not
with the rest of tables used by this statement.
This underminded deadlock-avoidance approach used in server
and created window for races. It also excluded target table
from prelocking causing problems with trigger execution.

The patch solves these problems by implementing new approach to
handling of CREATE TABLE ... SELECT for base tables.
We try to open and lock table to be created at the same time as
the rest of tables used by this statement. If such table does not
exist at this moment we create and place in the table cache special
placeholder for it which prevents its creation or any other usage
by other threads.
We still use old approach for creation of temporary tables.

Note that we have separate fix for 5.0 since there we use slightly
different less intrusive approach.


mysql-test/r/create.result:
  Extended test coverage for CREATE TABLE ... SELECT. In particular added
  tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT
  when temporary table exists" and bug #20662 "Infinite loop in CREATE
  TABLE IF NOT EXISTS ... SELECT with locked tables".
mysql-test/r/trigger.result:
  Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT
  and triggers"
mysql-test/t/create.test:
  Extended test coverage for CREATE TABLE ... SELECT. In particular added
  tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT
  when temporary table exists" and bug #20662 "Infinite loop in CREATE
  TABLE IF NOT EXISTS ... SELECT with locked tables".
mysql-test/t/trigger.test:
  Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT
  and triggers"
sql/lock.cc:
  Now for creation of name-lock placeholder lock_table_name() uses
  auxiliary function table_cache_insert_placeholder().
sql/mysql_priv.h:
  Removed declaration of non-existing build_table_path() routine.
  The former mysql_create_table_internal() was renamed to
  mysql_create_table_no_lock() and now exposed to other modules to
  give them opportunity of creation of tables in cases when name-lock
  is already obtained.
  reopen_name_locked_table() now has 3rd argument which controls linking
  in of table being opened into THD::open_tables (this is useful in
  cases when placeholder used for name-locking is already linked into
  this list).
  Added declaration of auxiliary function table_cache_insert_placeholder()
  which is used for creation of table placeholders for name-locking.
  Added declaration of lock_table_name_if_not_cached() which can be
  used to take an exclusive name-lock on table if there are no records
  for it in table cache.
  Changed signature of unlink_open_table() function to simplify its use
  and make it useful for table placeholders and tables that are only open.
  Added auxiliary drop_open_table() routine.
  Moved declaration of refresh_version to table.h header to make it
  accessible from inline methods of TABLE class.
  MYSQL_OPEN_IGNORE_LOCKED_TABLES flag is no longer used. Instead
  MYSQL_OPEN_TEMPORARY_ONLY option was added.
sql/sql_base.cc:
  Added support for the new approach to the handling of CREATE TABLE
  ... SELECT for base tables.
  
  Now we try to open and lock table to be created at the same time as
  the rest of tables used by this statement. If such table does not
  exist at this moment we create and place in the table cache special
  placeholder for it which prevents its creation or any other usage
  by other threads.
  
  Note significant distinctions of this placeholder from the placeholder
  used for normal name-lock: 1) It is treated like open table by other
  name-locks so it does not allow name-lock taking operations like DROP
  TABLE or RENAME TABLE to proceed. 2) it is linked into THD::open_tables
  list and automatically removed during close_thread_tables() call
    
  open_tables():
    Implemented logic described above. To do this added
    auxiliary check_if_table_exists() function.
    Removed support for MYSQL_OPEN_IGNORE_LOCKED_TABLES option
    which is no longer used.
    Added MYSQL_OPEN_TEMPORARY_ONLY which is used to restrict
    search for temporary tables only.
  close_cached_tables()/close_thread_table()/reopen_tables()/
  close_old_data_files()/table_is_used()/remove_table_from_cache():
    Added support for open placeholders (note that we also use them
    when we need to re-open tables during flush).
  unlink_open_table():
    Changed function signature to simplify its use and to make
    useful for open placeholders and tables which are only
    open and not locked.
  Added auxiliary drop_open_table() routine.
  reopen_name_locked_table():
    Now has 3rd argument which controls linking in of table being
    opened into THD::open_tables (this is useful in cases when
    placeholder used for name-locking is already linked into
    this list).
  Added auxiliary table_cache_insert_placeholder() routine which
  simplifies creation of placeholders used for name-locking.
  Added lock_table_name_if_not_cached() which can be used to take
  an exclusive name-lock on table if there are no records for it
  in table cache.
sql/sql_handler.cc:
  Adjusted mysql_ha_mark_tables_for_reopen() routine to properly
  handle placeholders which now can be linked into open tables
  list.
sql/sql_insert.cc:
  Introduced new approach to handling of base tables in CREATE TABLE
  ... SELECT statement.
  
  Now we try to open and lock table to be created at the same time as
  the rest of tables used by this statement. If such table does not
  exist at this moment we create and place in the table cache special
  placeholder for it which prevents its creation or any other usage
  by other threads. By doing this we avoid races which existed with
  previous approach in which we created, opened and locked target in
  separate step without any special protection.
  This also allows properly calculate prelocking set in cases when
  target table already exists and has some on insert triggers.
  
  Note that we don't employ the same approach for temporary tables
  (this is okay as such tables are unaffected by other threads).
  
  Changed create_table_from_items() and methods of select_create
  class to implement this approach.
sql/sql_parse.cc:
  The new approach to handling of CREATE TABLE ... SELECT for
  base tables assumes that all tables (including table to be
  created) are opened and (or) locked at the same time.
  So in cases when we create base table we have to pass to
  open_and_lock_tables() table list which includes target table.
sql/sql_prepare.cc:
  The new approach to handling of CREATE TABLE ... SELECT for
  base tables assumes that all tables (including table to be
  created) are opened and (or) locked at the same time.
  So in cases when we create base table we have to pass to
  open_and_lock_tables() table list which includes target table.
sql/sql_table.cc:
  Changed mysql_create_table(), mysql_create_like_table() and
  mysql_alter_table() (in rename case) to obtain exclusive name-lock
  on the non-temporary table which is going to be created (to which
  we going to rename). This ensures that not only destination table
  doesn't exist on disk but also that there are no placeholder in 
  table cache for it (i.e. there is no CREATE TABLE ... SELECT operation
  in progress for it). Note that to avoid deadlocks while taking these
  name-locks this code assumes that existence of any record for table in
  table cache (even name-lock) means that table exists. Altough such
  check can lead to false positives these should occur only in case of
  highly concurrent DDL operations on the table and should not break
  binary logging.
  
  Renamed mysql_create_table_internal() to mysql_create_table_no_lock()
  and made it accessible from other files to give them ability to create
  table in situation when name-lock is already obtained or not relevant.
  
  Adjusted calls to reopen_name_locked_table(), which now takes
  extra argument, which controls linking of open table into
  THD::open_tables list.
  
  Removed redundant setting of table's 'version' field before calls
  to close_cached_table(). This function will set it to 0 itself
  anyway.
sql/sql_trigger.cc:
  reopen_name_locked_tables() now has one more argument which controls
  linking of opened table into the THD::open_tables list.
sql/sql_yacc.yy:
  The new approach to handling of CREATE TABLE ... SELECT statement
  for base tables assumes that all tables including table to be
  created are open and (or) locked at the same time. Therefore
  we need to set correct lock for target table.
sql/table.h:
  Moved declaration of refresh_version variable from mysql_priv.h
  to make it accessible from inline methods of TABLE class.
  Renamed TABLE::locked_by_flush member to open_placeholder since
  now it is also used for taking exclusive name-lock and not only
  by flush. 
  Introduced TABLE::is_name_opened() helper method which can be used
  to distinguish TABLE instances corresponding to open tables or
  placeholders for them from closed instances (e.g. due to their old
  version). Also introduced TABLE::needs_reopen_or_name_lock() helper
  which allows to check if TABLE instance corresponds to outdated
  version of table or to name-lock placeholder.
  Introduced TABLE_LIST::create member which marks elements of
  table list corresponds to the table to be created.
  Adjusted TABLE_LIST::placeholder() method to take into account 
  name-lock placeholders for tables to be created (this, for example,
  allows to properly handle such placeholders in lock_tables()).
  Finally, moved currently unused TABLE::open_next/open_prev
  members under ifdef NOT_YET.
mysql-test/r/create_select-big.result:
  New BitKeeper file ``mysql-test/r/create_select-big.result''
mysql-test/t/create_select-big.test:
  New BitKeeper file ``mysql-test/t/create_select-big.test''
2007-05-11 21:51:03 +04:00
dlenev@mockturtle.local
4cafc8eeec Fix for:
Bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT
              with locked tables"
  Bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers"
  Bug #24738 "CREATE TABLE ... SELECT is not isolated properly"
  Bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when
              temporary table exists"

Deadlock occured when one tried to execute CREATE TABLE IF NOT
EXISTS ... SELECT statement under LOCK TABLES which held
read lock on target table.
Attempt to execute the same statement for already existing
target table with triggers caused server crashes.
Also concurrent execution of CREATE TABLE ... SELECT statement
and other statements involving target table suffered from
various races (some of which might've led to deadlocks).
Finally, attempt to execute CREATE TABLE ... SELECT in case
when a temporary table with same name was already present
led to the insertion of data into this temporary table and
creation of empty non-temporary table.
 
All above problems stemmed from the old implementation of CREATE
TABLE ... SELECT in which we created, opened and locked target
table without any special protection in a separate step and not
with the rest of tables used by this statement.
This underminded deadlock-avoidance approach used in server
and created window for races. It also excluded target table
from prelocking causing problems with trigger execution.

The patch solves these problems by implementing new approach to
handling of CREATE TABLE ... SELECT for base tables.
We try to open and lock table to be created at the same time as
the rest of tables used by this statement. If such table does not
exist at this moment we create and place in the table cache special
placeholder for it which prevents its creation or any other usage
by other threads.
We still use old approach for creation of temporary tables.

Note that we have separate fix for 5.0 since there we use slightly
different less intrusive approach.
2007-05-11 21:51:03 +04:00
unknown
c5a8245596 Fix for:
Bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT
              with locked tables"
  Bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers"
  Bug #24738 "CREATE TABLE ... SELECT is not isolated properly"
  Bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when
              temporary table exists"
 
Deadlock occured when one tried to execute CREATE TABLE IF NOT
EXISTS ... SELECT statement under LOCK TABLES which held
read lock on target table.
Attempt to execute the same statement for already existing
target table with triggers caused server crashes.
Also concurrent execution of CREATE TABLE ... SELECT statement
and other statements involving target table suffered from
various races (some of which might've led to deadlocks).
Finally, attempt to execute CREATE TABLE ... SELECT in case
when a temporary table with same name was already present
led to the insertion of data into this temporary table and
creation of empty non-temporary table.
 
All above problems stemmed from the old implementation of CREATE
TABLE ... SELECT in which we created, opened and locked target
table without any special protection in a separate step and not
with the rest of tables used by this statement.
This underminded deadlock-avoidance approach used in server
and created window for races. It also excluded target table
from prelocking causing problems with trigger execution.
  
The patch solves these problems by implementing new approach to
handling of CREATE TABLE ... SELECT for base tables.
We try to open and lock table to be created at the same time as
the rest of tables used by this statement. If such table does not
exist at this moment we create and place in the table cache special
placeholder for it which prevents its creation or any other usage
by other threads.

We still use old approach for creation of temporary tables.

Also note that we decided to postpone introduction of some tests
for concurrent behaviour of CREATE TABLE ... SELECT till 5.1.
The main reason for this is absence in 5.0 ability to set @@debug
variable at runtime, which can be circumvented only by using several
test files with individual .opt files. Since the latter is likely
to slowdown test-suite unnecessary we chose not to push this tests
into 5.0, but run them manually for this version and later push
their optimized version into 5.1


mysql-test/r/create.result:
  Extended test coverage for CREATE TABLE ... SELECT. In particular added
  tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT
  when temporary table exists" and bug #20662 "Infinite loop in CREATE
  TABLE IF NOT EXISTS ... SELECT with locked tables".
mysql-test/r/trigger.result:
  Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT
  and triggers"
mysql-test/t/create.test:
  Extended test coverage for CREATE TABLE ... SELECT. In particular added
  tests for bug #24508 "Inconsistent results of CREATE TABLE ... SELECT
  when temporary table exists" and bug #20662 "Infinite loop in CREATE
  TABLE IF NOT EXISTS ... SELECT with locked tables".
mysql-test/t/trigger.test:
  Added test case for bug #20903 "Crash when using CREATE TABLE .. SELECT
  and triggers"
sql/lock.cc:
  Now for creation of name-lock placeholder in lock_table_name() we use
  auxiliary function table_cache_insert_placeholder().
sql/mysql_priv.h:
  Made build_table_path() function available outside of sql_table.cc file.
  reopen_name_locked_table() now has 3rd argument which controls linking
  in of table being opened into THD::open_tables (this is useful in
  cases when placeholder used for name-locking is already linked into
  this list).
  Added declaration of auxiliary function table_cache_insert_placeholder()
  which is used for creation of table placeholders for name-locking.
  Added declaration of table_cache_has_open_placeholder() function which
  can be used for checking if table cache contains an open placeholder for
  the table and if this placeholder was created by another thread.
  (This function is needed only in 5.0 where we use it in various versions
   of CREATE TABLE in order to protect it from concurrent CREATE TABLE
   ... SELECT operations for the table. Starting from 5.1 we use different
   approach so it is going to be removed there).
  Made close_old_data_files() static within sql_base.cc file. 
  Added auxiliary drop_open_table() routine.
  Moved declaration of refresh_version to table.h header to make it
  accessible from inline methods of TABLE class.
  MYSQL_OPEN_IGNORE_LOCKED_TABLES flag is no longer used. Instead
  MYSQL_OPEN_TEMPORARY_ONLY option was added.
sql/sql_base.cc:
  Added support for the new approach to the handling of CREATE TABLE
  ... SELECT for base tables.
  
  Now we try to open and lock table to be created at the same time as
  the rest of tables used by this statement. If such table does not
  exist at this moment we create and place in the table cache special
  placeholder for it which prevents its creation or any other usage
  by other threads.
  
  Note significant distinctions of this placeholder from the placeholder
  used for normal name-lock: 1) It is treated like open table by other
  name-locks so it does not allow name-lock taking operations like DROP
  TABLE or RENAME TABLE to proceed. 2) it is linked into THD::open_tables
  list and automatically removed during close_thread_tables() call.
  
  open_tables():
    Implemented logic described above. To do this added
    auxiliary check_if_table_exists() function.
    Removed support for MYSQL_OPEN_IGNORE_LOCKED_TABLES option
    which is no longer used.
    Added MYSQL_OPEN_TEMPORARY_ONLY which is used to restrict
    search for temporary tables only.
  close_cached_tables()/close_thread_table()/reopen_tables()/
  close_old_data_files()/table_is_used()/remove_table_from_cache():
    Added support for open placeholders (note that we also use them
    when we need to re-open tables during flush).
  Added auxiliary drop_open_table() routine.
  reopen_name_locked_table():
    Now has 3rd argument which controls linking in of table being
    opened into THD::open_tables (this is useful in cases when
    placeholder used for name-locking is already linked into
    this list).
  Added auxiliary table_cache_insert_placeholder() routine which
  simplifies creation of placeholders used for name-locking.
  Added table_cache_has_open_placeholder() function which can be
  used for checking if table cache contains an open placeholder for
  the table and if this placeholder was created by another thread.
  (This function is needed only in 5.0 where we use it in various versions
   of CREATE TABLE in order to protect it from concurrent CREATE TABLE
   ... SELECT operations for the table. Starting from 5.1 we use different
   approach so it is going to be removed there).
sql/sql_handler.cc:
  Adjusted mysql_ha_mark_tables_for_reopen() routine to properly
  handle placeholders which now can be linked into open tables
  list.
sql/sql_insert.cc:
  Introduced new approach to handling of base tables in CREATE TABLE
  ... SELECT statement.
  
  Now we try to open and lock table to be created at the same time as
  the rest of tables used by this statement. If such table does not
  exist at this moment we create and place in the table cache special
  placeholder for it which prevents its creation or any other usage
  by other threads. By doing this we avoid races which existed with
  previous approach in which we created, opened and locked target in
  separate step without any special protection.
  This also allows properly calculate prelocking set in cases when
  target table already exists and has some on insert triggers.
    
  Note that we don't employ the same approach for temporary tables
  (this is okay as such tables are unaffected by other threads).
  
  Changed create_table_from_items() and select_create methods to
  implement this approach.
sql/sql_parse.cc:
  The new approach to handling of CREATE TABLE ... SELECT for
  base tables assumes that all tables (including table to be
  created) are opened and (or) locked at the same time.
  So in cases when we create base table we have to pass to
  open_and_lock_tables() table list which includes target table.
sql/sql_prepare.cc:
  The new approach to handling of CREATE TABLE ... SELECT for
  base tables assumes that all tables (including table to be
  created) are opened and (or) locked at the same time.
  So in cases when we create base table we have to pass to
  open_and_lock_tables() table list which includes target table.
sql/sql_table.cc:
  Now mysql_create_table_internal(), mysql_create_like_table() and
  mysql_alter_table() not only check that destination table doesn't
  exist on disk but also check that there is no create placeholder
  in table cache for it (i.e. there is no CREATE TABLE ... SELECT
  operation in progress for it). Note that starting from 5.1 we
  use different approach in order to to protect CREATE TABLE ... SELECT
  from concurrent CREATE TABLE (ALTER TABLE ... RENAME) operations,
  the latter simply take name-locks on table before its creation
  (on target table name before renaming).
  
  Also made build_table_path() available from other files and
  asjusted calls to reopen_name_locked_table(), which now takes
  extra argument, which controls linking of open table into
  THD::open_tables list.
sql/sql_trigger.cc:
  reopen_name_locked_tables() now has one more argument which controls
  linking of opened table into the THD::open_tables list.
sql/sql_yacc.yy:
  The new approach to handling of CREATE TABLE ... SELECT statement
  for base tables assumes that all tables including table to be
  created are open and (or) locked at the same time. Therefore
  we need to set correct lock for target table.
sql/table.h:
  Moved declaration of refresh_version variable from mysql_priv.h
  to make it accessible from inline methods of TABLE class. 
  Renamed TABLE::locked_by_flush member to open_placeholder since
  now it is also used for taking exclusive name-lock and not only
  by flush. 
  Introduced TABLE::is_name_opened() helper method which can be used
  to distinguish TABLE instances corresponding to open tables or
  placeholders for them from closed instances (e.g. due to their old
  version). Also introduced TABLE::needs_reopen_or_name_lock() helper
  which allows to check if TABLE instance corresponds to outdated
  version of table or to name-lock placeholder.
  Introduced TABLE_LIST::create member which marks elements of
  table list corresponds to the table to be created.
  Adjusted TABLE_LIST::placeholder() method to take into account 
  name-lock placeholders for tables to be created (this, for example,
  allows to properly handle such placeholders in lock_tables()).
2007-05-11 20:33:13 +04:00
dlenev@mockturtle.local
8b93e52e92 Fix for:
Bug #20662 "Infinite loop in CREATE TABLE IF NOT EXISTS ... SELECT
              with locked tables"
  Bug #20903 "Crash when using CREATE TABLE .. SELECT and triggers"
  Bug #24738 "CREATE TABLE ... SELECT is not isolated properly"
  Bug #24508 "Inconsistent results of CREATE TABLE ... SELECT when
              temporary table exists"
 
Deadlock occured when one tried to execute CREATE TABLE IF NOT
EXISTS ... SELECT statement under LOCK TABLES which held
read lock on target table.
Attempt to execute the same statement for already existing
target table with triggers caused server crashes.
Also concurrent execution of CREATE TABLE ... SELECT statement
and other statements involving target table suffered from
various races (some of which might've led to deadlocks).
Finally, attempt to execute CREATE TABLE ... SELECT in case
when a temporary table with same name was already present
led to the insertion of data into this temporary table and
creation of empty non-temporary table.
 
All above problems stemmed from the old implementation of CREATE
TABLE ... SELECT in which we created, opened and locked target
table without any special protection in a separate step and not
with the rest of tables used by this statement.
This underminded deadlock-avoidance approach used in server
and created window for races. It also excluded target table
from prelocking causing problems with trigger execution.
  
The patch solves these problems by implementing new approach to
handling of CREATE TABLE ... SELECT for base tables.
We try to open and lock table to be created at the same time as
the rest of tables used by this statement. If such table does not
exist at this moment we create and place in the table cache special
placeholder for it which prevents its creation or any other usage
by other threads.

We still use old approach for creation of temporary tables.

Also note that we decided to postpone introduction of some tests
for concurrent behaviour of CREATE TABLE ... SELECT till 5.1.
The main reason for this is absence in 5.0 ability to set @@debug
variable at runtime, which can be circumvented only by using several
test files with individual .opt files. Since the latter is likely
to slowdown test-suite unnecessary we chose not to push this tests
into 5.0, but run them manually for this version and later push
their optimized version into 5.1
2007-05-11 20:33:13 +04:00
unknown
023ae2a040 Merge bk@192.168.21.1:mysql-5.1-opt
into  mysql.com:/d2/hf/mrg/mysql-5.1-opt


client/mysqldump.c:
  Auto merged
mysql-test/r/rpl_packet.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/t/rpl_packet.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_partition.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/share/errmsg.txt:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
storage/innobase/handler/ha_innodb.cc:
  Auto merged
mysql-test/r/create.result:
  SCCS merged
mysql-test/t/create.test:
  merging
mysql-test/t/disabled.def:
  merging
sql/events.cc:
  merging
sql/sql_parse.cc:
  SCCS merged
2007-04-07 14:59:53 +05:00
holyfoot/hf@hfmain.(none)
ce426dd622 Merge bk@192.168.21.1:mysql-5.1-opt
into  mysql.com:/d2/hf/mrg/mysql-5.1-opt
2007-04-07 14:59:53 +05:00
unknown
5f74873349 Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
additional fix(to satisfy Win where CreateFile func does not support the path longer than 260)


mysql-test/r/create.result:
  Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
  additional fix
mysql-test/t/create.test:
  Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
  additional fix
2007-04-04 17:36:58 +05:00
gluh@mysql.com/eagle.(none)
f8fb7a404b Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
additional fix(to satisfy Win where CreateFile func does not support the path longer than 260)
2007-04-04 17:36:58 +05:00
unknown
fe074a726f Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
client/mysqldump.c:
  fixed typo
include/mysql_com.h:
  added new constants SYSTEM_CHARSET_MBMAXLEN, NAME_CHAR_LEN, USERNAME_CHAR_LENGTH
  increased NAME_LEN, USERNAME_LENGTH
mysql-test/r/create.result:
  result fix
mysql-test/r/grant.result:
  result fix
mysql-test/r/mysql.result:
  result fix
mysql-test/r/sp.result:
  result fix
mysql-test/t/create.test:
  test case
mysql-test/t/grant.test:
  test case
sql/events.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/item_strfunc.h:
  fixed calculation of max_length
sql/mysql_priv.h:
  check_string_length function is replaced with check_string_byte_length
  added new function check_string_char_length
sql/sp.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/sp_head.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/sp_head.h:
  changed parameter of 'check_routine_name' function
sql/sql_class.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/share/errmsg.txt:
  increased argument lengths according to new constants
sql/sql_parse.cc:
  removed unnecessary checks
  added function 'check_string_char_length'
sql/sql_plugin.cc:
  check that name is not longer than NAME_CHAR_LEN symbols
sql/sql_show.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/sql_table.cc:
  check that key name is not longer than NAME_LEN symbols
sql/sql_udf.cc:
  check that udf name is not longer than NAME_CHAR_LEN symbols
sql/sql_yacc.yy:
  check that user name is not longer than USERNAME_CHAR_LENGTH symbols
sql/table.cc:
  check that db or table or column name is not longer than NAME_LEN symbols
storage/innobase/handler/ha_innodb.cc:
  removed unnecessary multiplication
tests/mysql_client_test.c:
  NAME_LEN is replaced with NAME_CHAR_LEN
2007-04-03 16:13:27 +05:00
gluh@mysql.com/eagle.(none)
2d47f0cb1b Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte 2007-04-03 16:13:27 +05:00
unknown
f65cb96b60 Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.1
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint


client/client_priv.h:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/mysqldump.result:
  Auto merged
mysql-test/r/rpl_deadlock_innodb.result:
  Auto merged
mysql-test/r/rpl_flushlog_loop.result:
  Auto merged
mysql-test/r/rpl_known_bugs_detection.result:
  Auto merged
mysql-test/r/rpl_ndb_basic.result:
  Auto merged
mysql-test/r/rpl_ndb_extraCol.result:
  Auto merged
mysql-test/r/rpl_ndb_sync.result:
  Auto merged
mysql-test/r/rpl_rbr_to_sbr.result:
  Auto merged
mysql-test/r/rpl_row_inexist_tbl.result:
  Auto merged
mysql-test/r/rpl_row_max_relay_size.result:
  Auto merged
mysql-test/r/rpl_row_tabledefs_2myisam.result:
  Auto merged
mysql-test/r/rpl_row_tabledefs_3innodb.result:
  Auto merged
mysql-test/r/rpl_stm_max_relay_size.result:
  Auto merged
mysql-test/r/rpl_stm_until.result:
  Auto merged
mysql-test/r/sp-code.result:
  Auto merged
mysql-test/r/type_datetime.result:
  Auto merged
mysql-test/t/mysqlbinlog.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/lex.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/gis.result:
  Merge 5.0->5.1
mysql-test/r/rpl_000015.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_change_master.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_loaddata.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_log_pos.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_ndb_log.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_rotate_logs.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_row_log.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_row_log_innodb.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_row_reset_slave.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_row_until.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_server_id1.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_server_id2.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_stm_log.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/r/rpl_stm_reset_slave.result:
  Merge after adding new column to SHOW SLAVE STATUS
mysql-test/t/gis.test:
  Merge 5.0->5.1
2007-04-02 11:15:09 +02:00
msvensson@pilot.blaudden
fc904eaead Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.1
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint
2007-04-02 11:15:09 +02:00
unknown
3378a48698 Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint


mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/type_datetime.result:
  Auto merged
sql/field.h:
  Auto merged
sql/item.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/gis.result:
  SCCS merged
mysql-test/t/gis.test:
  SCCS merged
2007-04-02 10:50:39 +02:00
msvensson@pilot.blaudden
bb9a601829 Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-04-02 10:50:39 +02:00
unknown
74a32b0f2d Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint


mysql-test/t/create.test:
  Auto merged
sql/table.cc:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
mysql-test/mysql-test-run.pl:
  Manual merge
mysql-test/r/create.result:
  Manual merge of revert
2007-04-02 10:45:51 +02:00
msvensson@pilot.blaudden
cbe7c63fc7 Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint
2007-04-02 10:45:51 +02:00
unknown
44d4940fcc Merge pilot.blaudden:/home/msvensson/mysql/mysql-4.1-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint


myisam/mi_open.c:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/create.result:
  SCCS merged
mysql-test/t/create.test:
  SCCS merged
2007-04-02 10:42:08 +02:00
msvensson@pilot.blaudden
cb3091c166 Merge pilot.blaudden:/home/msvensson/mysql/mysql-4.1-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-04-02 10:42:08 +02:00
unknown
0bb2f43d2e Cset exclude: tsmith@siva.hindu.god|ChangeSet|20070328212513|13373
myisam/mi_open.c:
  Exclude
mysql-test/r/create.result:
  Exclude
mysql-test/t/create.test:
  Exclude
sql/table.cc:
  Exclude
2007-04-02 10:39:23 +02:00
msvensson@pilot.blaudden
c731bad918 Cset exclude: tsmith@siva.hindu.god|ChangeSet|20070328212513|13373 2007-04-02 10:39:23 +02:00
unknown
13a2fad97c create.result:
post-merge test result fixup


mysql-test/r/create.result:
  post-merge test result fixup
2007-03-29 13:27:38 +02:00
tsmith@quadxeon.mysql.com
28c6822bf9 create.result:
post-merge test result fixup
2007-03-29 13:27:38 +02:00
unknown
a9ecd2141b Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/50
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/51


mysql-test/t/openssl_1.test:
  Auto merged
sql-common/my_time.c:
  Auto merged
sql/table.cc:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
mysql-test/r/create.result:
  Manual merge
mysql-test/t/create.test:
  Manual merge
2007-03-29 12:58:26 +02:00
tsmith@quadxeon.mysql.com
0b0d2c3258 Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/50
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/51
2007-03-29 12:58:26 +02:00
unknown
e76abb0d89 Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/41
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/50


myisam/mi_open.c:
  Auto merged
sql-common/my_time.c:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/create.result:
  Manual merge
mysql-test/t/create.test:
  Manual merge
2007-03-29 12:52:31 +02:00
tsmith@quadxeon.mysql.com
a7f506db2a Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/41
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/50
2007-03-29 12:52:31 +02:00
unknown
0b72b7f0a4 Bug #26642: create index corrupts table definition in .frm
Thanks to Martin Friebe for finding and submitting a fix for this bug!

A table with maximum number of key segments and maximum length key name
would have a corrupted .frm file, due to an incorrect calculation of the
complete key length.  Now the key length is computed correctly (I hope) :-)

MyISAM would reject a table with the maximum number of keys and the maximum
number of key segments in all keys.  It would allow one less than this total
maximum.  Now MyISAM accepts a table defined with the maximum.  (This is a
very minor issue.)


myisam/mi_open.c:
  change >= to > in a comparison (i.e., error only if key_parts_in_table
  really is greater than MAX_KEY * MAX_KEY_SEG)
mysql-test/r/create.result:
  Add test results for bug #26642 (create index corrupts table definition in .frm)
mysql-test/t/create.test:
  Add test case for bug #26642 (create index corrupts table definition in .frm)
sql/table.cc:
  In create_frm(), fix formula for key_length; it was too small by (keys * 2) bytes
2007-03-28 15:25:13 -06:00
tsmith@siva.hindu.god
ecd22993cf Bug #26642: create index corrupts table definition in .frm
Thanks to Martin Friebe for finding and submitting a fix for this bug!

A table with maximum number of key segments and maximum length key name
would have a corrupted .frm file, due to an incorrect calculation of the
complete key length.  Now the key length is computed correctly (I hope) :-)

MyISAM would reject a table with the maximum number of keys and the maximum
number of key segments in all keys.  It would allow one less than this total
maximum.  Now MyISAM accepts a table defined with the maximum.  (This is a
very minor issue.)
2007-03-28 15:25:13 -06:00
unknown
3aa9cea32f merging 2007-03-23 01:04:31 +04:00
holyfoot/hf@mysql.com/hfmain.(none)
e1044ab5d1 merging 2007-03-23 01:04:31 +04:00
unknown
2c5395eedb Merge mysql.com:/home/hf/work/mrg/mysql-5.0-opt
into  mysql.com:/home/hf/work/mrg/mysql-5.1-opt


mysql-test/r/insert_select.result:
  Auto merged
mysql-test/t/insert_select.test:
  Auto merged
sql/field.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/sql_select.h:
  Auto merged
mysql-test/r/create.result:
  merging
mysql-test/r/temp_table.result:
  SCCS merged
mysql-test/r/type_float.result:
  merging
mysql-test/r/union.result:
  merging
mysql-test/t/temp_table.test:
  merging
2007-03-22 23:59:20 +04:00
holyfoot/hf@hfmain.(none)
81b59fb3cc Merge mysql.com:/home/hf/work/mrg/mysql-5.0-opt
into  mysql.com:/home/hf/work/mrg/mysql-5.1-opt
2007-03-22 23:59:20 +04:00
unknown
aa32336198 Bug #24791: Union with AVG-groups generates wrong results
The problem in this bug is when we create temporary tables. When
temporary tables are created for unions, there is some 
inferrence being carried out regarding the type of the column.
Whenever this column type is inferred to be REAL (i.e. FLOAT or
DOUBLE), MySQL will always try to maintain exact precision, and
if that is not possible (there are hardware limits, since FLOAT
and DOUBLE are stored as approximate values) will switch to
using approximate values. The problem here is that at this point
the information about number of significant digits is not 
available. Furthermore, the number of significant digits should
be increased for the AVG function, however, this was not properly 
handled. There are 4 parts to the problem:

#1: DOUBLE and FLOAT fields don't display their proper display 
lengths in max_display_length(). This is hard-coded as 53 for 
DOUBLE and 24 for FLOAT. Now changed to instead return the 
field_length.

#2: Type holders for temporary tables do not preserve the 
max_length of the Item's from which they are created, and is 
instead reverted to the 53 and 24 from above. This causes 
*all* fields to get non-fixed significant digits.

#3: AVG function does not update max_length (display length)
when updating number of decimals.

#4: The function that switches to non-fixed number of 
significant digits should use DBL_DIG + 2 or FLT_DIG + 2 as 
cut-off values (Since fixed precision does not use the 'e' 
notation)

Of these points, #1 is the controversial one, but this 
change is preferred and has been cleared with Monty. The 
function causes quite a few unit tests to blow up and they had
to b changed, but each one is annotated and motivated. We 
frequently see the magical 53 and 24 give way to more relevant
numbers.


mysql-test/r/create.result:
  bug#24791
  
  changed test result
  
  With the changes made for FLOAT and DOUBLE, the original display
  lengths are now preserved.
mysql-test/r/temp_table.result:
  bug#24791
  
  changed test resullt
  
  Test case added
mysql-test/r/type_float.result:
  bug#24791
  
  changed test result
  
  delta 1: field was originally declared as DOUBLE with no display
  length, so the hardware maximum is chosen rather than 53.
  
  delta 2: fields exceed the maximum precision and thus switch to
  non-fixed significant digits
  
  delta 3: Same as above, number of decmals and significant digits
  was not specified when t3 was created.
mysql-test/t/temp_table.test:
  bug#24791
  
  Test case
sql/field.h:
  bug#24791
  
  The method max_display_length is reimplemented as
  
  uint32 max_display_length() { return field_length; }
  
  in Field_double and Field_float. Since all subclasses of 
  Field_real now have the same implementation of this method, the
  implementation has been moved up the hierarchy to Field_real.
sql/item.cc:
  bug#24791
  
  We switch to a non-fixed number of significant digits
  (by setting decimals=NOT_FIXED_DECIMAL) if the calculated 
  display length is greater than the display length of a value 
  with the maximum precision. These values differ for double and 
  float, obviously.
sql/item_sum.cc:
  bug#24791
  
  We must increase the display length accordinly whenever we 
  change number of decimal places.
2007-03-22 10:56:47 +01:00
mhansson/martin@linux-st28.site
50077b6db9 Bug #24791: Union with AVG-groups generates wrong results
The problem in this bug is when we create temporary tables. When
temporary tables are created for unions, there is some 
inferrence being carried out regarding the type of the column.
Whenever this column type is inferred to be REAL (i.e. FLOAT or
DOUBLE), MySQL will always try to maintain exact precision, and
if that is not possible (there are hardware limits, since FLOAT
and DOUBLE are stored as approximate values) will switch to
using approximate values. The problem here is that at this point
the information about number of significant digits is not 
available. Furthermore, the number of significant digits should
be increased for the AVG function, however, this was not properly 
handled. There are 4 parts to the problem:

#1: DOUBLE and FLOAT fields don't display their proper display 
lengths in max_display_length(). This is hard-coded as 53 for 
DOUBLE and 24 for FLOAT. Now changed to instead return the 
field_length.

#2: Type holders for temporary tables do not preserve the 
max_length of the Item's from which they are created, and is 
instead reverted to the 53 and 24 from above. This causes 
*all* fields to get non-fixed significant digits.

#3: AVG function does not update max_length (display length)
when updating number of decimals.

#4: The function that switches to non-fixed number of 
significant digits should use DBL_DIG + 2 or FLT_DIG + 2 as 
cut-off values (Since fixed precision does not use the 'e' 
notation)

Of these points, #1 is the controversial one, but this 
change is preferred and has been cleared with Monty. The 
function causes quite a few unit tests to blow up and they had
to b changed, but each one is annotated and motivated. We 
frequently see the magical 53 and 24 give way to more relevant
numbers.
2007-03-22 10:56:47 +01:00
unknown
c431ab112d Merge pilot.blaudden:/home/msvensson/mysql/bug20166/my50-bug20166
into  pilot.blaudden:/home/msvensson/mysql/bug20166/my51-bug20166


BitKeeper/etc/ignore:
  auto-union
BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8:
  Auto merged
BitKeeper/deleted/.del-mysql_create_system_tables.sh:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/join.result:
  Auto merged
mysql-test/r/sp-security.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/grant2.test:
  Auto merged
mysql-test/t/init_connect.test:
  Auto merged
mysql-test/t/ndb_basic.test:
  Auto merged
mysql-test/t/ndb_index_ordered.test:
  Auto merged
mysql-test/t/ndb_multi.test:
  Auto merged
scripts/Makefile.am:
  Auto merged
BitKeeper/deleted/.del-init_db.sql~af2dfeabaa348dd7:
  Auto merged
mysql-test/r/mysql_upgrade.result:
  SCCS merged
mysql-test/t/lock_multi.test:
  Use local
mysql-test/t/rpl_temporary.test:
  Use local
mysql-test/Makefile.am:
  Manual merge
scripts/mysql_fix_privilege_tables.sh:
  Manual merge
scripts/mysql_fix_privilege_tables.sql.in:
  Manual merge
scripts/mysql_install_db.sh:
  Manual merge
2007-02-26 14:25:59 +01:00
msvensson@pilot.blaudden
f6e31a2cd1 Merge pilot.blaudden:/home/msvensson/mysql/bug20166/my50-bug20166
into  pilot.blaudden:/home/msvensson/mysql/bug20166/my51-bug20166
2007-02-26 14:25:59 +01:00
unknown
5d4e0417ad Bug#20166 mysql-test-run.pl does not test system privilege tables creation
- Use mysql_system_tables.sql to create MySQL system tables in
   all places where we create them(mysql_install_db, mysql-test-run-pl
   and mysql_fix_privilege_tables.sql)


BitKeeper/deleted/.del-init_db.sql:
  Rename: mysql-test/init_db.sql -> BitKeeper/deleted/.del-init_db.sql
BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8:
  Rename: mysql-test/lib/init_db.sql -> BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8
BitKeeper/deleted/.del-mysql_create_system_tables.sh:
  Rename: scripts/mysql_create_system_tables.sh -> BitKeeper/deleted/.del-mysql_create_system_tables.sh
BitKeeper/etc/ignore:
  Added scripts/mysql_fix_privilege_tables.sql to the ignore list
mysql-test/Makefile.am:
  lib/init_db.sql has been removed
mysql-test/mysql-test-run.pl:
  - Build var/tmp/bootstrap.sql from mysql_system_tables.sql,
  mysql_test_data_timezone.sql and fill_help_tables.sql and use
  it when bootsraping the system tables to use during test.
mysql-test/r/create.result:
  Update result file
mysql-test/r/derived.result:
  Update result file
mysql-test/r/join.result:
  Update result file
mysql-test/r/mysql_upgrade.result:
  Update result file
mysql-test/r/sp-security.result:
  Update result file
mysql-test/t/create.test:
  Add user mysqltest_1 before trying to connect as that user - no
  anon users by default anymore
mysql-test/t/derived.test:
  Add user mysqltest_1 before trying to connect as that user - no
  anon users by default anymore
mysql-test/t/grant2.test:
  Add anonymous users for part of thes that need it.
mysql-test/t/grant_cache.test:
  Add anonymous users for part of thes that need it.
mysql-test/t/init_connect.test:
  Add anonymous users for part of thes that need it.
mysql-test/t/lock_multi.test:
  Add anonymous users for part of thes that need it.
mysql-test/t/ndb_basic.test:
  Connect as "root", blank user will take currently logged in
  username
mysql-test/t/ndb_index_ordered.test:
  Connect as "root", blank user will take currently logged in
  username
mysql-test/t/ndb_multi.test:
  Connect as "root", blank user will take currently logged in
  username
mysql-test/t/overflow.test:
  Connect as root - no anonymous users by default anymore
mysql-test/t/rpl_temporary.test:
  Add anonymous users for the test
mysql-test/t/xa.test:
  Connect as "root", blank user wil pick currently logged in user
scripts/Makefile.am:
  Remove mysql_create_system_tables.sh
  Add mysql_system_tables.sql and mysql_test_data_timezone.sql
  Build mysql_fix_privilege_tables.sql from mysql_system_tables.sql
  and mysql_fix_privilege_tables.sql.in
scripts/mysql_fix_privilege_tables.sh:
  Update message describing what the script does
scripts/mysql_fix_privilege_tables.sql.in:
  Remove the part that creates system tables as that will be added to
  mysql_fix_privileg_tables.sql from mysql_system_tables.sql
  Change all comments to use #
scripts/mysql_install_db.sh:
  Use mysql_system_tables.sql to create the MySQL system tables
  Update comments and indentation
  Add more descriptive comments about --windows switch
  Reduce number of hardcoded names for the SQL files the script
  looks for
mysql-test/include/add_anonymous_users.inc:
  New BitKeeper file ``mysql-test/include/add_anonymous_users.inc''
mysql-test/include/delete_anonymous_users.inc:
  New BitKeeper file ``mysql-test/include/delete_anonymous_users.inc''
scripts/mysql_system_tables.sql:
  New BitKeeper file ``scripts/mysql_system_tables.sql''
scripts/mysql_test_data_timezone.sql:
  New BitKeeper file ``scripts/mysql_test_data_timezone.sql''
2007-02-26 11:49:24 +01:00
msvensson@pilot.blaudden
c550a45522 Bug#20166 mysql-test-run.pl does not test system privilege tables creation
- Use mysql_system_tables.sql to create MySQL system tables in
   all places where we create them(mysql_install_db, mysql-test-run-pl
   and mysql_fix_privilege_tables.sql)
2007-02-26 11:49:24 +01:00
unknown
560049cbfa Change to new (after merge) error numbers
mysql-test/r/create.result:
  Fixed error number
mysql-test/r/rpl_sp.result:
  Fixed error number
mysql-test/r/sp.result:
  Fixed error number
mysql-test/r/view.result:
  Better fix for now() handling
mysql-test/t/ndb_basic.test:
  Use error names instead of numbers
mysql-test/t/ndb_index_unique.test:
  Use error names instead of numbers
mysql-test/t/rpl_skip_error-slave.opt:
  Change to new error number
mysql-test/t/sp.test:
  Change to new error number
mysql-test/t/view.test:
  Better fix for now() handling
2007-01-22 21:19:56 +02:00
monty@mysql.com/narttu.mysql.fi
33f8a2c5d7 Change to new (after merge) error numbers 2007-01-22 21:19:56 +02:00
unknown
b4f80eedf3 Give warnings for unused objects
Changed error message to be compatible with old error file
Added new error message for new DUP_ENTRY syntax


BUILD/SETUP.sh:
  Give warnings for unused objects
mysql-test/extra/binlog_tests/insert_select-binlog.test:
  Changed to use new error message
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
  Changed to use new error message
mysql-test/extra/rpl_tests/rpl_auto_increment.test:
  Changed to use new error message
mysql-test/extra/rpl_tests/rpl_foreign_key.test:
  Changed to use new error message
mysql-test/extra/rpl_tests/rpl_insert_id.test:
  Changed to use new error message
mysql-test/extra/rpl_tests/rpl_insert_id_pk.test:
  Changed to use new error message
mysql-test/extra/rpl_tests/rpl_loaddata.test:
  Changed to use new error message
mysql-test/extra/rpl_tests/rpl_row_basic.test:
  Changed to use new error message
mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test:
  Changed to use new error message
mysql-test/extra/rpl_tests/rpl_trig004.test:
  Changed to use new error message
mysql-test/include/mix1.inc:
  Changed to use new error message
mysql-test/include/mix2.inc:
  Changed to use new error message
mysql-test/include/ps_modify.inc:
  Changed to use new error message
mysql-test/include/query_cache.inc:
  Changed to use new error message
mysql-test/include/varchar.inc:
  Changed to use new error message
mysql-test/r/create.result:
  Changed to use new error message
mysql-test/r/rpl_sp.result:
  Changed to use new error message
mysql-test/r/sp.result:
  Changed to use new error message
mysql-test/r/view.result:
  Changed to use new error message
mysql-test/t/auto_increment.test:
  Changed to use new error message
mysql-test/t/create.test:
  Changed to use new error message
mysql-test/t/create_select_tmp.test:
  Changed to use new error message
mysql-test/t/ctype_utf8.test:
  Changed to use new error message
mysql-test/t/delayed.test:
  Changed to use new error message
mysql-test/t/heap.test:
  Changed to use new error message
mysql-test/t/heap_btree.test:
  Changed to use new error message
mysql-test/t/heap_hash.test:
  Changed to use new error message
mysql-test/t/innodb.test:
  Changed to use new error message
mysql-test/t/insert_select.test:
  Changed to use new error message
mysql-test/t/insert_update.test:
  Changed to use new error message
mysql-test/t/join_outer.test:
  Changed to use new error message
mysql-test/t/key.test:
  Changed to use new error message
mysql-test/t/merge.test:
  Changed to use new error message
mysql-test/t/myisam.test:
  Changed to use new error message
mysql-test/t/ndb_charset.test:
  Changed to use new error message
mysql-test/t/ndb_index_unique.test:
  Changed to use new error message
mysql-test/t/ndb_insert.test:
  Changed to use new error message
mysql-test/t/ndb_replace.test:
  Changed to use new error message
mysql-test/t/ndb_update.test:
  Changed to use new error message
mysql-test/t/replace.test:
  Changed to use new error message
mysql-test/t/rpl_err_ignoredtable.test:
  Changed to use new error message
mysql-test/t/rpl_row_create_table.test:
  Changed to use new error message
mysql-test/t/rpl_skip_error-slave.opt:
  Changed to use new error message
mysql-test/t/rpl_sp.test:
  Changed to use new error message
mysql-test/t/show_check.test:
  Changed to use new error message
mysql-test/t/sp-error.test:
  Changed to use new error message
mysql-test/t/sp.test:
  Changed to use new error message
mysql-test/t/sp_trans.test:
  Changed to use new error message
mysql-test/t/temp_table.test:
  Changed to use new error message
mysql-test/t/type_binary.test:
  Changed to use new error message
mysql-test/t/type_bit.test:
  Changed to use new error message
mysql-test/t/type_bit_innodb.test:
  Changed to use new error message
mysql-test/t/type_blob.test:
  Changed to use new error message
mysql-test/t/type_varchar.test:
  Changed to use new error message
mysql-test/t/view.test:
  Changed to use new error message
sql/handler.cc:
  ER_DUP_ENTRY -> ER_DUP_ENTRY_WITH_KEY_NAME
sql/share/errmsg.txt:
  Changed error message to be compatible with old error file
  Added new error message for new DUP_ENTRY syntax
sql/sql_table.cc:
  ER_DUP_ENTRY -> ER_DUP_ENTRY_WITH_KEY_NAME
sql-bench/example:
  Example file for how to run tests
2007-01-22 18:42:52 +02:00
monty@mysql.com/narttu.mysql.fi
2dcc7110c9 Give warnings for unused objects
Changed error message to be compatible with old error file
Added new error message for new DUP_ENTRY syntax
2007-01-22 18:42:52 +02:00
unknown
15a86d185d Merge neptunus.(none):/home/msvensson/mysql/bug22436/my50-bug22436
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint


mysql-test/r/innodb_mysql.result:
  Auto merged
mysql-test/t/innodb_mysql.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/r/create.result:
  Merge
mysql-test/t/create.test:
  Merge
mysql-test/t/view.test:
  Remove the disable_warnings part as engine=innodb has been removed
2006-10-19 01:01:54 +02:00
msvensson@neptunus.(none)
179c17adfa Merge neptunus.(none):/home/msvensson/mysql/bug22436/my50-bug22436
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2006-10-19 01:01:54 +02:00
unknown
990b106b63 Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into  ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.1-lex-string


BUILD/SETUP.sh:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/events.result:
  Auto merged
mysql-test/r/grant.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/events.test:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/sql_parse.cc:
  remove_escape() function removed. Manual merge.
sql/table.cc:
  Manually merged. Old line removed.
tests/mysql_client_test.c:
  Manually merged. test_status position now last.
sql/sql_parse.cc.rej:
  undefined
sql/table.cc.rej:
  undefined
tests/mysql_client_test.c.rej:
  undefined
2006-10-17 19:54:44 +03:00
jani@ua141d10.elisa.omakaista.fi
8dd0b2d0ae Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into  ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.1-lex-string
2006-10-17 19:54:44 +03:00
unknown
e94087c5dd Changed several char* to LEX_STRING*.
BUILD/SETUP.sh:
  Added check for CCACHE_DISABLE. If set, do not
  use ccache at all.
BUILD/compile-pentium-gcov:
  Moved CCACHE_DISABLE up before going into SETUP.sh.
  
  Added debug_extra_flags to extra_flags.
mysql-test/r/create.result:
  Added tests for incorrect database names.
mysql-test/r/ctype_create.result:
  Added tests for incorrect alter database names.
mysql-test/r/events.result:
  Added tests for incorrect database names.
mysql-test/r/grant.result:
  Output changed to capital letters.
mysql-test/t/alter_table.test:
  Removed extra empty line
mysql-test/t/create.test:
  Added tests for incorrect database names.
mysql-test/t/ctype_create.test:
  Added tests for incorrect name handling
mysql-test/t/events.test:
  Added tests for incorrect database names.
sql/item_timefunc.cc:
  Added dummy case to avoid compiler warning.
sql/mysql_priv.h:
  Changed argument from char pointer to LEX_STRING pointer.
sql/mysqld.cc:
  Added a missing component from struct.
sql/sql_class.h:
  Added function LEX_STRING_make that sets the string and length.
sql/sql_db.cc:
  Changed several char pointers to lex_strings.
sql/sql_lex.cc:
  name is now LEX_STRING
sql/sql_lex.h:
  Changed name to LEX_STRING.
sql/sql_parse.cc:
  Changed several char pointers to lex_strings.
  
  db_length needed a trick, because in old client protocol there
  was an extra char zero added to the string.
  
  check_db_name() now takes LEX_STRING pointer as an argument.
  
  Changed remove_escape() to take LEX_STRING pointer as an argument.
  
  Removed COM_CREATE_DB and COM_DROP_DB. These are obsolete.
sql/sql_table.cc:
  char* -> LEX_STRING*
sql/sql_yacc.yy:
  Changed char* -> LEX_STRING*
sql/table.cc:
  check_db_name() now takes LEX_STRING* as argument instead of char*.
  
  Optimized code a bit.
tests/mysql_client_test.c:
  Added test for (short) status.
  
  After defining out (ifdef) COM_DROP_DB and COM_CREATE_DB
  in mysqld.cc mysql_client_test needed to be informed that
  failing in recognizing these commands is not fatal error
  anymore.
2006-10-16 19:57:33 +03:00
jani@ua141d10.elisa.omakaista.fi
02f29377fd Changed several char* to LEX_STRING*. 2006-10-16 19:57:33 +03:00
unknown
d8d57c77b1 Bug#22436 Four tests require "innodb" to be configured, fail in "classic" build
- Disable warnings when creating the "innodb" tables if it works anyway.
 - Move test that are really innodb dependent to innodb_mysql 


mysql-test/r/create.result:
  Move the innodb dependent test to innodb_mysql.test
mysql-test/r/innodb_mysql.result:
  Move the innodb dependent test to innodb_mysql.test
mysql-test/t/create.test:
  Move the innodb dependent test to innodb_mysql.test
mysql-test/t/innodb_mysql.test:
  Move the innodb dependent test to innodb_mysql.test
mysql-test/t/lock_multi.test:
  Disable warnings while creating the innodb table. If innodb is not available, the table will be created with default engine and thus create a warning. Regardless of this, test output should be the same.
mysql-test/t/sp.test:
  Disable warnings while creating the innodb table. If innodb is not available, the table will be created with default engine and thus create a warning. Regardless of this, test output should be the same.
mysql-test/t/view.test:
  Disable warnings while creating the innodb table. If innodb is not available, the table will be created with default engine and thus create a warning. Regardless of this, test output should be the same.
2006-09-28 15:13:40 +02:00
msvensson@neptunus.(none)
485772e308 Bug#22436 Four tests require "innodb" to be configured, fail in "classic" build
- Disable warnings when creating the "innodb" tables if it works anyway.
 - Move test that are really innodb dependent to innodb_mysql
2006-09-28 15:13:40 +02:00
unknown
379226c2fd merge fixes 2006-09-18 18:30:51 +04:00
gkodinov@dl145s.mysql.com
f1100c007d merge fixes 2006-09-18 18:30:51 +04:00
unknown
0eb5442fd9 Bug #21772: can not name a column 'upgrade' when create a table in version 5.0.24
Upgrade was a reserved word. Unreserve UPGRADE so it can be used in unquoted identifiers.


mysql-test/r/create.result:
  Bug #21772: can not name a column 'upgrade' when create a table in version 5.0.24
   - test case
mysql-test/t/create.test:
  Bug #21772: can not name a column 'upgrade' when create a table in version 5.0.24
   - test case
sql/sql_yacc.yy:
  Bug #21772: can not name a column 'upgrade' when create a table in version 5.0.24
   - unreserve UPGRADE.
2006-09-08 13:10:14 +03:00
gkodinov/kgeorge@macbook.gmz
0f8069bfb0 Bug #21772: can not name a column 'upgrade' when create a table in version 5.0.24
Upgrade was a reserved word. Unreserve UPGRADE so it can be used in unquoted identifiers.
2006-09-08 13:10:14 +03:00
unknown
131f9a71d1 Merge xiphis.org:/home/antony/work2/mysql-5.0-engines
into  xiphis.org:/home/antony/work2/mysql-5.0-merge


mysql-test/r/create.result:
  Auto merged
mysql-test/r/federated.result:
  Auto merged
mysql-test/r/insert_select.result:
  Auto merged
mysql-test/r/ps_2myisam.result:
  Auto merged
mysql-test/r/ps_3innodb.result:
  Auto merged
mysql-test/r/ps_4heap.result:
  Auto merged
mysql-test/r/ps_5merge.result:
  Auto merged
mysql-test/r/ps_6bdb.result:
  Auto merged
mysql-test/r/ps_7ndb.result:
  Auto merged
mysql-test/r/strict.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/r/warnings.result:
  Auto merged
sql/share/errmsg.txt:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
2006-08-14 21:27:36 -07:00
acurtis/antony@xiphis.org/ltantony.xiphis.org
e2d4aa2ca4 Merge xiphis.org:/home/antony/work2/mysql-5.0-engines
into  xiphis.org:/home/antony/work2/mysql-5.0-merge
2006-08-14 21:27:36 -07:00
unknown
a1bd0bd118 BUG#14770 - LOAD DATA INFILE doesn't respect default values for
columns
Fixed confusing warning.

Quoting INSERT section of the manual:
----
Inserting NULL into a column that has been declared NOT NULL. For
multiple-row INSERT statements or INSERT INTO ... SELECT statements, the
column is set to the implicit default value for the column data type. This
is 0 for numeric types, the empty string ('') for string types, and the
"zero" value for date and time types. INSERT INTO ... SELECT statements are
handled the same way as multiple-row inserts because the server does not
examine the result set from the SELECT to see whether it returns a single
row. (For a single-row INSERT, no warning occurs when NULL is inserted into
a NOT NULL column. Instead, the statement fails with an error.)
----
This is also true for LOAD DATA INFILE. For INSERT user can specify
DEFAULT keyword as a value to set column default. There is no similiar
feature available for LOAD DATA INFILE.


mysql-test/r/auto_increment.result:
  Fixed confusing warning.
mysql-test/r/create.result:
  Fixed confusing warning.
mysql-test/r/insert.result:
  Fixed confusing warning.
mysql-test/r/insert_select.result:
  Fixed confusing warning.
mysql-test/r/key.result:
  Fixed confusing warning.
mysql-test/r/null.result:
  Fixed confusing warning.
mysql-test/r/null_key.result:
  Fixed confusing warning.
mysql-test/r/ps_2myisam.result:
  Fixed confusing warning.
mysql-test/r/ps_3innodb.result:
  Fixed confusing warning.
mysql-test/r/ps_4heap.result:
  Fixed confusing warning.
mysql-test/r/ps_5merge.result:
  Fixed confusing warning.
mysql-test/r/ps_6bdb.result:
  Fixed confusing warning.
mysql-test/r/strict.result:
  Fixed confusing warning.
mysql-test/r/view.result:
  Fixed confusing warning.
mysql-test/r/warnings.result:
  Fixed confusing warning.
sql/share/errmsg.txt:
  Fixed confusing warning.
2006-08-02 17:15:50 +05:00
svoj@may.pils.ru
6c6f435b03 BUG#14770 - LOAD DATA INFILE doesn't respect default values for
columns
Fixed confusing warning.

Quoting INSERT section of the manual:
----
Inserting NULL into a column that has been declared NOT NULL. For
multiple-row INSERT statements or INSERT INTO ... SELECT statements, the
column is set to the implicit default value for the column data type. This
is 0 for numeric types, the empty string ('') for string types, and the
"zero" value for date and time types. INSERT INTO ... SELECT statements are
handled the same way as multiple-row inserts because the server does not
examine the result set from the SELECT to see whether it returns a single
row. (For a single-row INSERT, no warning occurs when NULL is inserted into
a NOT NULL column. Instead, the statement fails with an error.)
----
This is also true for LOAD DATA INFILE. For INSERT user can specify
DEFAULT keyword as a value to set column default. There is no similiar
feature available for LOAD DATA INFILE.
2006-08-02 17:15:50 +05:00
unknown
ddb91478e8 Merge sunlight.local:/local_work/tmp_merge-5.0-opt-mysql
into  sunlight.local:/local_work/tmp_merge-5.1-opt-mysql


client/mysql.cc:
  Auto merged
mysql-test/r/date_formats.result:
  Auto merged
mysql-test/r/func_gconcat.result:
  Auto merged
mysql-test/r/func_group.result:
  Auto merged
mysql-test/r/func_str.result:
  Auto merged
mysql-test/r/group_min_max.result:
  Auto merged
BitKeeper/deleted/.del-make_win_src_distribution.sh~f80d8fca44e4e5f1:
  Auto merged
BitKeeper/deleted/.del-mysqld.dsp~ffdbf2d234e23e56:
  Auto merged
BitKeeper/deleted/.del-mysqld_ia64.dsp~7f8cf84d81ee04e2:
  Auto merged
BitKeeper/deleted/.del-mysqldump.dsp~a8bd23547d3fc27e:
  Auto merged
BitKeeper/deleted/.del-mysqldump_ia64.dsp~a2aabe898be35b31:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Auto merged
mysql-test/r/ps_7ndb.result:
  Auto merged
mysql-test/r/type_ranges.result:
  Auto merged
mysql-test/r/udf.result:
  Auto merged
mysql-test/r/union.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/date_formats.test:
  Auto merged
mysql-test/t/func_gconcat.test:
  Auto merged
mysql-test/t/func_group.test:
  Auto merged
mysql-test/t/group_min_max.test:
  Auto merged
mysql-test/t/innodb.test:
  Auto merged
mysql-test/t/innodb_mysql.test:
  Auto merged
mysql-test/t/mysql.test:
  Auto merged
mysql-test/t/select.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_subselect.cc:
  Auto merged
sql/item_subselect.h:
  Auto merged
sql/opt_range.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/time.cc:
  Auto merged
storage/ndb/test/ndbapi/Makefile.am:
  Auto merged
strings/decimal.c:
  Auto merged
mysql-test/r/analyse.result:
  Manual merge
mysql-test/r/bigint.result:
  Manual merge
mysql-test/r/create.result:
  Manual merge
mysql-test/r/information_schema.result:
  Manual merge
mysql-test/r/ps_2myisam.result:
  Manual merge
mysql-test/r/ps_3innodb.result:
  Manual merge
mysql-test/r/ps_4heap.result:
  Manual merge
mysql-test/r/ps_5merge.result:
  Manual merge
mysql-test/r/ps_6bdb.result:
  Manual merge
mysql-test/r/rpl_insert_id.result:
  Manual merge
mysql-test/r/select.result:
  Manual merge
mysql-test/r/sp.result:
  Manual merge
mysql-test/r/subselect.result:
  Manual merge
mysql-test/t/information_schema.test:
  Manual merge
mysql-test/t/rpl_insert_id.test:
  Manual merge
sql/field.h:
  Manual merge
sql/item.cc:
  Manual merge
sql/item.h:
  Manual merge
sql/item_strfunc.h:
  Manual merge
sql/item_sum.cc:
  Manual merge
sql/mysql_priv.h:
  Manual merge
sql/share/errmsg.txt:
  Manual merge
sql/sql_class.h:
  Manual merge
sql/sql_select.cc:
  Manual merge
2006-07-30 00:33:24 +04:00
evgen@sunlight.local
ef4f149536 Merge sunlight.local:/local_work/tmp_merge-5.0-opt-mysql
into  sunlight.local:/local_work/tmp_merge-5.1-opt-mysql
2006-07-30 00:33:24 +04:00
unknown
f171d628c7 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/work/autopush/12185-bug-5.0-opt-mysql


mysql-test/r/create.result:
  Auto merged
mysql-test/t/innodb.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/item.cc:
  Auto merged
mysql-test/r/union.result:
  SCCS merged
mysql-test/t/union.test:
  SCCS merged
2006-07-22 02:15:36 +04:00
evgen@moonbone.local
8540557457 Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  moonbone.local:/work/autopush/12185-bug-5.0-opt-mysql
2006-07-22 02:15:36 +04:00
unknown
35209c68ea Fixed bug#12185: Data type aggregation may produce wrong result
The Item::tmp_table_field_from_field_type() function creates Field_datetime
object instead of Field_timestamp object for timestamp field thus always
changing data type is a tmp table is used.

The Field_blob object constructor which is used in the 
Item::tmp_table_field_from_field_type() is always setting packlength field of
newly created blob to 4. This leads to changing fields data type for example
from the blob to the longblob if a temporary table is used.

The Item::make_string_field() function always converts Field_string objects 
to Field_varstring objects. This leads to changing data type from the 
char/binary to varchar/varbinary.

Added appropriate Field_timestamp object constructor for using in the 
Item::tmp_table_field_from_field_type() function.

Added Field_blob object constructor which sets pack length according to
max_length argument.

The Item::tmp_table_field_from_field_type() function now creates
Field_timestamp object for a timestamp field.

The Item_type_holder::display_length() now returns correct NULL length NULL
length. 

The Item::make_string_field() function now doesn't change Field_string to
Field_varstring in the case of Item_type_holder. 

The Item::tmp_table_field_from_field_type() function now uses the Field_blob
constructor which sets packlength according to max_length.


mysql-test/t/union.test:
  Added test case for bug#12185: Data type aggregation may produce wrong result
  Corrected test case after fix for bug#12185
mysql-test/t/innodb.test:
  Corrected test case after fix for bug#12185
mysql-test/r/union.result:
  Added test case for bug#12185: Data type aggregation may produce wrong result
   Corrected test case after fix for bug#12185
mysql-test/r/innodb.result:
  Corrected test case after fix for bug#12185
mysql-test/r/create.result:
  Corrected the test case after fixing bug#12185
sql/field.h:
  Fixed bug#12185: Data type aggregation may produce wrong result
  Added Field_blob object constructor which sets packlength according to
  max_length argument.
sql/item.cc:
  Fixed bug#12185: Data type aggregation may produce wrong result
  The Item::make_string_field() function now doesn't change Field_string to
  Field_varstring in the case of Item_type_holder.
  The Item::tmp_table_field_from_field_type() function now creates
  Field_timestamp object for a timestamp field.
  The Item::tmp_table_field_from_field_type() function now uses the Field_blob
  constructor which sets packlength according to max_length.
  The Item_type_holder::display_length() now returns correct NULL length NULL
  length.
sql/field.cc:
  Fixed bug#12185: Data type aggregation may produce wrong result
  Added appropriate Field_timestamp object constructor for using in the 
  Item::tmp_table_field_from_field_type() function.
2006-07-22 02:08:00 +04:00
evgen@moonbone.local
c875b8eb93 Fixed bug#12185: Data type aggregation may produce wrong result
The Item::tmp_table_field_from_field_type() function creates Field_datetime
object instead of Field_timestamp object for timestamp field thus always
changing data type is a tmp table is used.

The Field_blob object constructor which is used in the 
Item::tmp_table_field_from_field_type() is always setting packlength field of
newly created blob to 4. This leads to changing fields data type for example
from the blob to the longblob if a temporary table is used.

The Item::make_string_field() function always converts Field_string objects 
to Field_varstring objects. This leads to changing data type from the 
char/binary to varchar/varbinary.

Added appropriate Field_timestamp object constructor for using in the 
Item::tmp_table_field_from_field_type() function.

Added Field_blob object constructor which sets pack length according to
max_length argument.

The Item::tmp_table_field_from_field_type() function now creates
Field_timestamp object for a timestamp field.

The Item_type_holder::display_length() now returns correct NULL length NULL
length. 

The Item::make_string_field() function now doesn't change Field_string to
Field_varstring in the case of Item_type_holder. 

The Item::tmp_table_field_from_field_type() function now uses the Field_blob
constructor which sets packlength according to max_length.
2006-07-22 02:08:00 +04:00
unknown
1e44259440 Fixed bug #19714.
DESCRIBE returned the type BIGINT for a column of a view if the column
was specified by an expression over values of the type INT.
    
E.g. for the view defined as follows:
  CREATE VIEW v1 SELECT COALESCE(f1,f2) FROM t1
DESCRIBE returned type BIGINT for the only column of the view if f1,f2 are
columns of the INT type.
At the same time DESCRIBE returned type INT for the only column of the table
defined by the statement:
  CREATE TABLE t2 SELECT COALESCE(f1,f2) FROM t1.
    
This inconsistency was removed by the patch.

Now the code chooses between INT/BIGINT depending on the
precision of the aggregated column type.
 
Thus both DESCRIBE commands above returns type INT for v1 and t2.
 


mysql-test/r/analyse.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/bigint.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/create.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/olap.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_2myisam.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_3innodb.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_4heap.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_5merge.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_6bdb.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/ps_7ndb.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/sp.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/subselect.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/type_ranges.result:
  Adjusted the results after having fixed bug #19714.
mysql-test/r/view.result:
  Added a test case for bug #19714.
mysql-test/t/view.test:
  Added a test case for bug #19714.
2006-07-13 20:48:26 -07:00
igor@olga.mysql.com
f608064083 Fixed bug #19714.
DESCRIBE returned the type BIGINT for a column of a view if the column
was specified by an expression over values of the type INT.
    
E.g. for the view defined as follows:
  CREATE VIEW v1 SELECT COALESCE(f1,f2) FROM t1
DESCRIBE returned type BIGINT for the only column of the view if f1,f2 are
columns of the INT type.
At the same time DESCRIBE returned type INT for the only column of the table
defined by the statement:
  CREATE TABLE t2 SELECT COALESCE(f1,f2) FROM t1.
    
This inconsistency was removed by the patch.

Now the code chooses between INT/BIGINT depending on the
precision of the aggregated column type.
 
Thus both DESCRIBE commands above returns type INT for v1 and t2.
2006-07-13 20:48:26 -07:00
unknown
df9b4754b7 Merge bodhi.netgear:/opt/local/work/tmp_merge
into  bodhi.netgear:/opt/local/work/mysql-5.1-runtime-merge-with-5.0


mysql-test/r/create.result:
  Auto merged
mysql-test/r/ps.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/ps.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_trigger.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/table.h:
  Auto merged
sql/tztime.cc:
  Auto merged
include/my_sys.h:
  Manual merge (second attempt).
mysql-test/r/bdb.result:
  Manual merge (second attempt).
mysql-test/t/bdb.test:
  Manual merge (second attempt).
mysys/my_malloc.c:
  Manual merge (second attempt).
mysys/safemalloc.c:
  Manual merge (second attempt).
sql/ha_federated.cc:
  Manual merge (second attempt).
sql/log_event.cc:
  Manual merge (second attempt).
sql/set_var.cc:
  Manual merge (second attempt).
sql/set_var.h:
  Manual merge (second attempt).
sql/slave.cc:
  Manual merge (second attempt).
sql/slave.h:
  Manual merge (second attempt).
sql/sql_class.h:
  Manual merge (second attempt).
sql/sql_table.cc:
  Manual merge (second attempt).
sql/sql_udf.cc:
  Manual merge (second attempt).
sql/sql_yacc.yy:
  Manual merge (second attempt).
2006-07-06 22:55:48 +04:00
konstantin@bodhi.netgear
01bc761690 Merge bodhi.netgear:/opt/local/work/tmp_merge
into  bodhi.netgear:/opt/local/work/mysql-5.1-runtime-merge-with-5.0
2006-07-06 22:55:48 +04:00
unknown
d6bcbfbe92 A fix and a test case for
Bug#19022 "Memory bug when switching db during trigger execution"
 Bug#17199 "Problem when view calls function from another database."
 Bug#18444 "Fully qualified stored function names don't work correctly in
            SELECT statements"

 Documentation note: this patch introduces a change in behaviour of prepared
 statements.

 This patch adds a few new invariants with regard to how THD::db should
 be used. These invariants should be preserved in future:

  - one should never refer to THD::db by pointer and always make a deep copy
    (strmake, strdup)
  - one should never compare two databases by pointer, but use strncmp or
    my_strncasecmp
  - TABLE_LIST object table->db should be always initialized in the parser or
    by creator of the object.

    For prepared statements it means that if the current database is changed
    after a statement is prepared, the database that was current at prepare
    remains active. This also means that you can not prepare a statement that
    implicitly refers to the current database if the latter is not set.
    This is not documented, and therefore needs documentation. This is NOT a
    change in behavior for almost all SQL statements except:
     - ALTER TABLE t1 RENAME t2 
     - OPTIMIZE TABLE t1
     - ANALYZE TABLE t1
     - TRUNCATE TABLE t1 --
     until this patch t1 or t2 could be evaluated at the first execution of
     prepared statement. 

     CURRENT_DATABASE() still works OK and is evaluated at every execution
     of prepared statement.

     Note, that in stored routines this is not an issue as the default
     database is the database of the stored procedure and "use" statement
     is prohibited in stored routines.

  This patch makes obsolete the use of check_db_used (it was never used in the
  old code too) and all other places that check for table->db and assign it
  from THD::db if it's NULL, except the parser.

 How this patch was created: THD::{db,db_length} were replaced with a
 LEX_STRING, THD::db. All the places that refer to THD::{db,db_length} were
 manually checked and:
  - if the place uses thd->db by pointer, it was fixed to make a deep copy
  - if a place compared two db pointers, it was fixed to compare them by value
    (via strcmp/my_strcasecmp, whatever was approproate)
 Then this intermediate patch was used to write a smaller patch that does the
 same thing but without a rename.

 TODO in 5.1:
   - remove check_db_used
   - deploy THD::set_db in mysql_change_db

 See also comments to individual files.


mysql-test/r/create.result:
  Modify the result file: a database can never be NULL.
mysql-test/r/ps.result:
  Update test results (Bug#17199 et al)
mysql-test/r/sp.result:
  Update test results (Bug#17199 et al)
mysql-test/t/create.test:
  Update the id of the returned error.
mysql-test/t/ps.test:
  Add test coverage for prepared statements and current database. In scope of
  work on Bug#17199 "Problem when view calls function from another database."
mysql-test/t/sp.test:
  Add a test case for Bug#17199 "Problem when view calls function from another
  database." and Bug#18444 "Fully qualified stored function names don't work
  correctly in SELECT statements". Test a complementary problem.
sql/item_strfunc.cc:
  Touch the code that reads thd->db (cleanup).
sql/log_event.cc:
  While we are at it, replace direct access to thd->db with a method.
  Should simplify future conversion of THD::db to LEX_STRING.
sql/slave.cc:
  While we are at it, replace direct access to thd->db with a method.
  Should simplify future conversion of THD::db to LEX_STRING.
sql/slave.h:
  Remove a declaration for a method that is used only in one module.
sql/sp.cc:
  Rewrite sp_use_new_db: this is a cleanup that I needed in order to understand
  this function and ensure that it has no bugs.
sql/sp.h:
  Add a new declaration for sp_use_new_db (uses LEX_STRINGs) and a comment.
sql/sp_head.cc:
  - drop sp_name_current_db_new - a creator of sp_name class that was used
  when sp_name was created for an identifier without an explicitly initialized
  database. Now we pass thd->db to constructor of sp_name right in the 
  parser.
  - rewrite sp_head::init_strings: name->m_db is always set now
  - use the new variant of sp_use_new_db
  - we don't need to update thd->db with SP MEM_ROOT pointer anymore when
  parsing a stored procedure, as noone will refer to it (yes!)
sql/sp_head.h:
  - remove unneded methods and members
sql/sql_class.h:
  - introduce 3 THD  methods to work with THD::db:
    .set_db to assign the current database
    .reset_db to reset the current database (temporarily) or set it to NULL
    .opt_copy_db_to - to deep-copy thd->db to a pointer if it's not NULL
sql/sql_db.cc:
  While we are at it, replace direct access to thd->db with a method.
  Should simplify future conversion of THD::db to LEX_STRING.
sql/sql_insert.cc:
  - replace checks with asserts: table_list->db must be always set in the parser.
sql/sql_lex.h:
  - add a comment
sql/sql_parse.cc:
  - implement the invariant described in the changeset comment.
  - remove juggling with lex->sphead in SQLCOM_CREATE_PROCEDURE:
    now db_load_routine uses its own LEX object and doesn't damage the main
    LEX.
  - add DBUG_ASSERT(0) to unused "check_db_used"
sql/sql_table.cc:
  - replace a check with an assert (table_ident->db)
sql/sql_trigger.cc:
  While we are at it, replace direct access to thd->db with a method.
  Should simplify future conversion of THD::db to LEX_STRING.
sql/sql_udf.cc:
  - use thd->set_db instead of direct modification of to thd->db
sql/sql_view.cc:
  - replace a check with an assert (view->db)
sql/sql_yacc.yy:
  - make sure that we always copy table->db or name->db or ident->db or
    select_lex->db from thd->db if the former is not set. If thd->db
    is not set but is accessed, return an error.
sql/tztime.cc:
  - be nice, never copy thd->db by pointer.
2006-06-27 00:47:52 +04:00
konstantin@mysql.com
117b76a562 A fix and a test case for
Bug#19022 "Memory bug when switching db during trigger execution"
 Bug#17199 "Problem when view calls function from another database."
 Bug#18444 "Fully qualified stored function names don't work correctly in
            SELECT statements"

 Documentation note: this patch introduces a change in behaviour of prepared
 statements.

 This patch adds a few new invariants with regard to how THD::db should
 be used. These invariants should be preserved in future:

  - one should never refer to THD::db by pointer and always make a deep copy
    (strmake, strdup)
  - one should never compare two databases by pointer, but use strncmp or
    my_strncasecmp
  - TABLE_LIST object table->db should be always initialized in the parser or
    by creator of the object.

    For prepared statements it means that if the current database is changed
    after a statement is prepared, the database that was current at prepare
    remains active. This also means that you can not prepare a statement that
    implicitly refers to the current database if the latter is not set.
    This is not documented, and therefore needs documentation. This is NOT a
    change in behavior for almost all SQL statements except:
     - ALTER TABLE t1 RENAME t2 
     - OPTIMIZE TABLE t1
     - ANALYZE TABLE t1
     - TRUNCATE TABLE t1 --
     until this patch t1 or t2 could be evaluated at the first execution of
     prepared statement. 

     CURRENT_DATABASE() still works OK and is evaluated at every execution
     of prepared statement.

     Note, that in stored routines this is not an issue as the default
     database is the database of the stored procedure and "use" statement
     is prohibited in stored routines.

  This patch makes obsolete the use of check_db_used (it was never used in the
  old code too) and all other places that check for table->db and assign it
  from THD::db if it's NULL, except the parser.

 How this patch was created: THD::{db,db_length} were replaced with a
 LEX_STRING, THD::db. All the places that refer to THD::{db,db_length} were
 manually checked and:
  - if the place uses thd->db by pointer, it was fixed to make a deep copy
  - if a place compared two db pointers, it was fixed to compare them by value
    (via strcmp/my_strcasecmp, whatever was approproate)
 Then this intermediate patch was used to write a smaller patch that does the
 same thing but without a rename.

 TODO in 5.1:
   - remove check_db_used
   - deploy THD::set_db in mysql_change_db

 See also comments to individual files.
2006-06-27 00:47:52 +04:00
unknown
9933c3bd3a Merge mysql.com:/users/lthalmann/bkroot/mysql-5.1-new-rpl
into  mysql.com:/users/lthalmann/bk/MERGE/mysql-5.1-merge


mysql-test/r/binlog_row_mix_innodb_myisam.result:
  Auto merged
mysql-test/r/federated.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/extra/rpl_tests/rpl_ddl.test:
  Auto merged
mysql-test/r/rpl_ddl.result:
  Auto merged
mysql-test/r/sp-error.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/rpl_ndb_charset.result:
  Auto merged
mysql-test/r/type_ranges.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/r/trigger-grant.result:
  Auto merged
mysql-test/t/archive.test:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/federated.test:
  Auto merged
mysql-test/t/innodb.test:
  Auto merged
mysql-test/t/innodb_mysql.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/trigger-grant.test:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/ha_innodb.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
mysql-test/r/create.result:
  Manual merge
mysql-test/r/innodb_mysql.result:
  Manual merge
sql/handler.cc:
  Manual merge
sql/share/errmsg.txt:
  Manual merge
sql/sql_class.h:
  Manual merge
sql/sql_delete.cc:
  Manual merge
sql/sql_insert.cc:
  Manual merge
sql/sql_table.cc:
  Manual merge
2006-06-16 01:15:19 +02:00
lars@mysql.com
5f37fc4a76 Merge mysql.com:/users/lthalmann/bkroot/mysql-5.1-new-rpl
into  mysql.com:/users/lthalmann/bk/MERGE/mysql-5.1-merge
2006-06-16 01:15:19 +02:00
unknown
01d03e7b4b This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),

- New optional handler function introduced: reset()
  This is called after every DML statement to make it easy for a handler to
  statement specific cleanups.
  (The only case it's not called is if force the file to be closed)

- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
  should be moved to handler::reset()

- table->read_set contains a bitmap over all columns that are needed
  in the query.  read_row() and similar functions only needs to read these
  columns
- table->write_set contains a bitmap over all columns that will be updated
  in the query. write_row() and update_row() only needs to update these
  columns.
  The above bitmaps should now be up to date in all context
  (including ALTER TABLE, filesort()).

  The handler is informed of any changes to the bitmap after
  fix_fields() by calling the virtual function
  handler::column_bitmaps_signal(). If the handler does caching of
  these bitmaps (instead of using table->read_set, table->write_set),
  it should redo the caching in this code. as the signal() may be sent
  several times, it's probably best to set a variable in the signal
  and redo the caching on read_row() / write_row() if the variable was
  set.

- Removed the read_set and write_set bitmap objects from the handler class

- Removed all column bit handling functions from the handler class.
  (Now one instead uses the normal bitmap functions in my_bitmap.c instead
  of handler dedicated bitmap functions)

- field->query_id is removed. One should instead instead check
  table->read_set and table->write_set if a field is used in the query.

- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
  handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
  instead use table->read_set to check for which columns to retrieve.

- If a handler needs to call Field->val() or Field->store() on columns
  that are not used in the query, one should install a temporary
  all-columns-used map while doing so. For this, we provide the following
  functions:

  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
  field->val();
  dbug_tmp_restore_column_map(table->read_set, old_map);

  and similar for the write map:

  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
  field->val();
  dbug_tmp_restore_column_map(table->write_set, old_map);

  If this is not done, you will sooner or later hit a DBUG_ASSERT
  in the field store() / val() functions.
  (For not DBUG binaries, the dbug_tmp_restore_column_map() and
  dbug_tmp_restore_column_map() are inline dummy functions and should
  be optimized away be the compiler).

- If one needs to temporary set the column map for all binaries (and not
  just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
  methods) one should use the functions tmp_use_all_columns() and
  tmp_restore_column_map() instead of the above dbug_ variants.

- All 'status' fields in the handler base class (like records,
  data_file_length etc) are now stored in a 'stats' struct. This makes
  it easier to know what status variables are provided by the base
  handler.  This requires some trivial variable names in the extra()
  function.

- New virtual function handler::records().  This is called to optimize
  COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
  (stats.records is not supposed to be an exact value. It's only has to
  be 'reasonable enough' for the optimizer to be able to choose a good
  optimization path).

- Non virtual handler::init() function added for caching of virtual
  constants from engine.

- Removed has_transactions() virtual method. Now one should instead return
  HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
  transactions.

- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
  that is to be used with 'new handler_name()' to allocate the handler
  in the right area.  The xxxx_create_handler() function is also
  responsible for any initialization of the object before returning.

  For example, one should change:

  static handler *myisam_create_handler(TABLE_SHARE *table)
  {
    return new ha_myisam(table);
  }

  ->

  static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
  {
    return new (mem_root) ha_myisam(table);
  }

- New optional virtual function: use_hidden_primary_key().
  This is called in case of an update/delete when
  (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
  but we don't have a primary key. This allows the handler to take precisions
  in remembering any hidden primary key to able to update/delete any
  found row. The default handler marks all columns to be read.

- handler::table_flags() now returns a ulonglong (to allow for more flags).

- New/changed table_flags()
  - HA_HAS_RECORDS	    Set if ::records() is supported
  - HA_NO_TRANSACTIONS	    Set if engine doesn't support transactions
  - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
                            Set if we should mark all primary key columns for
			    read when reading rows as part of a DELETE
			    statement. If there is no primary key,
			    all columns are marked for read.
  - HA_PARTIAL_COLUMN_READ  Set if engine will not read all columns in some
			    cases (based on table->read_set)
 - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
   			    Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
 - HA_DUPP_POS              Renamed to HA_DUPLICATE_POS
 - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
			    Set this if we should mark ALL key columns for
			    read when when reading rows as part of a DELETE
			    statement. In case of an update we will mark
			    all keys for read for which key part changed
			    value.
  - HA_STATS_RECORDS_IS_EXACT
			     Set this if stats.records is exact.
			     (This saves us some extra records() calls
			     when optimizing COUNT(*))
			    

- Removed table_flags()
  - HA_NOT_EXACT_COUNT     Now one should instead use HA_HAS_RECORDS if
			   handler::records() gives an exact count() and
			   HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
  - HA_READ_RND_SAME	   Removed (no one supported this one)

- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()

- Renamed handler::dupp_pos to handler::dup_pos

- Removed not used variable handler::sortkey


Upper level handler changes:

- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
  cache is updated on engine creation time and updated on open.


MySQL level changes (not obvious from the above):

- DBUG_ASSERT() added to check that column usage matches what is set
  in the column usage bit maps. (This found a LOT of bugs in current
  column marking code).

- In 5.1 before, all used columns was marked in read_set and only updated
  columns was marked in write_set. Now we only mark columns for which we
  need a value in read_set.

- Column bitmaps are created in open_binary_frm() and open_table_from_share().
  (Before this was in table.cc)

- handler::table_flags() calls are replaced with handler::ha_table_flags()

- For calling field->val() you must have the corresponding bit set in
  table->read_set. For calling field->store() you must have the
  corresponding bit set in table->write_set. (There are asserts in
  all store()/val() functions to catch wrong usage)

- thd->set_query_id is renamed to thd->mark_used_columns and instead
  of setting this to an integer value, this has now the values:
  MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
  Changed also all variables named 'set_query_id' to mark_used_columns.

- In filesort() we now inform the handler of exactly which columns are needed
  doing the sort and choosing the rows.

- The TABLE_SHARE object has a 'all_set' column bitmap one can use
  when one needs a column bitmap with all columns set.
  (This is used for table->use_all_columns() and other places)

- The TABLE object has 3 column bitmaps:
  - def_read_set     Default bitmap for columns to be read
  - def_write_set    Default bitmap for columns to be written
  - tmp_set          Can be used as a temporary bitmap when needed.
  The table object has also two pointer to bitmaps read_set and write_set
  that the handler should use to find out which columns are used in which way.

- count() optimization now calls handler::records() instead of using
  handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).

- Added extra argument to Item::walk() to indicate if we should also
  traverse sub queries.

- Added TABLE parameter to cp_buffer_from_ref()

- Don't close tables created with CREATE ... SELECT but keep them in
  the table cache. (Faster usage of newly created tables).


New interfaces:

- table->clear_column_bitmaps() to initialize the bitmaps for tables
  at start of new statements.

- table->column_bitmaps_set() to set up new column bitmaps and signal
  the handler about this.

- table->column_bitmaps_set_no_signal() for some few cases where we need
  to setup new column bitmaps but don't signal the handler (as the handler
  has already been signaled about these before). Used for the momement
  only in opt_range.cc when doing ROR scans.

- table->use_all_columns() to install a bitmap where all columns are marked
  as use in the read and the write set.

- table->default_column_bitmaps() to install the normal read and write
  column bitmaps, but not signaling the handler about this.
  This is mainly used when creating TABLE instances.

- table->mark_columns_needed_for_delete(),
  table->mark_columns_needed_for_delete() and
  table->mark_columns_needed_for_insert() to allow us to put additional
  columns in column usage maps if handler so requires.
  (The handler indicates what it neads in handler->table_flags())

- table->prepare_for_position() to allow us to tell handler that it
  needs to read primary key parts to be able to store them in
  future table->position() calls.
  (This replaces the table->file->ha_retrieve_all_pk function)

- table->mark_auto_increment_column() to tell handler are going to update
  columns part of any auto_increment key.

- table->mark_columns_used_by_index() to mark all columns that is part of
  an index.  It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
  it to quickly know that it only needs to read colums that are part
  of the key.  (The handler can also use the column map for detecting this,
  but simpler/faster handler can just monitor the extra() call).

- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
  also mark all columns that is used by the given key.

- table->restore_column_maps_after_mark_index() to restore to default
  column maps after a call to table->mark_columns_used_by_index().

- New item function register_field_in_read_map(), for marking used columns
  in table->read_map. Used by filesort() to mark all used columns

- Maintain in TABLE->merge_keys set of all keys that are used in query.
  (Simplices some optimization loops)

- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
  but the field in the clustered key is not assumed to be part of all index.
  (used in opt_range.cc for faster loops)

-  dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
   tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
   mark all columns as usable.  The 'dbug_' version is primarily intended
   inside a handler when it wants to just call Field:store() & Field::val()
   functions, but don't need the column maps set for any other usage.
   (ie:: bitmap_is_set() is never called)

- We can't use compare_records() to skip updates for handlers that returns
  a partial column set and the read_set doesn't cover all columns in the
  write set. The reason for this is that if we have a column marked only for
  write we can't in the MySQL level know if the value changed or not.
  The reason this worked before was that MySQL marked all to be written
  columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
  bug'.

- open_table_from_share() does not anymore setup temporary MEM_ROOT
  object as a thread specific variable for the handler. Instead we
  send the to-be-used MEMROOT to get_new_handler().
  (Simpler, faster code)



Bugs fixed:

- Column marking was not done correctly in a lot of cases.
  (ALTER TABLE, when using triggers, auto_increment fields etc)
  (Could potentially result in wrong values inserted in table handlers
  relying on that the old column maps or field->set_query_id was correct)
  Especially when it comes to triggers, there may be cases where the
  old code would cause lost/wrong values for NDB and/or InnoDB tables.

- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
  OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
  This allowed me to remove some wrong warnings about:
  "Some non-transactional changed tables couldn't be rolled back"

- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
  (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
  some warnings about
  "Some non-transactional changed tables couldn't be rolled back")

- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
  which could cause delete_table to report random failures.

- Fixed core dumps for some tests when running with --debug

- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
  (This has probably caused us to not properly remove temporary files after
  crash)

- slow_logs was not properly initialized, which could maybe cause
  extra/lost entries in slow log.

- If we get an duplicate row on insert, change column map to read and
  write all columns while retrying the operation. This is required by
  the definition of REPLACE and also ensures that fields that are only
  part of UPDATE are properly handled.  This fixed a bug in NDB and
  REPLACE where REPLACE wrongly copied some column values from the replaced
  row.

- For table handler that doesn't support NULL in keys, we would give an error
  when creating a primary key with NULL fields, even after the fields has been
  automaticly converted to NOT NULL.

- Creating a primary key on a SPATIAL key, would fail if field was not
  declared as NOT NULL.


Cleanups:

- Removed not used condition argument to setup_tables

- Removed not needed item function reset_query_id_processor().

- Field->add_index is removed. Now this is instead maintained in
  (field->flags & FIELD_IN_ADD_INDEX)

- Field->fieldnr is removed (use field->field_index instead)

- New argument to filesort() to indicate that it should return a set of
  row pointers (not used columns). This allowed me to remove some references
  to sql_command in filesort and should also enable us to return column
  results in some cases where we couldn't before.

- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
  bitmap, which allowed me to use bitmap functions instead of looping over
  all fields to create some needed bitmaps. (Faster and smaller code)

- Broke up found too long lines

- Moved some variable declaration at start of function for better code
  readability.

- Removed some not used arguments from functions.
  (setup_fields(), mysql_prepare_insert_check_table())

- setup_fields() now takes an enum instead of an int for marking columns
   usage.

- For internal temporary tables, use handler::write_row(),
  handler::delete_row() and handler::update_row() instead of
  handler::ha_xxxx() for faster execution.

- Changed some constants to enum's and define's.

- Using separate column read and write sets allows for easier checking
  of timestamp field was set by statement.

- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()

- Don't build table->normalized_path as this is now identical to table->path
  (after bar's fixes to convert filenames)

- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
  do comparision with the 'convert-dbug-for-diff' tool.


Things left to do in 5.1:

- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
  row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
  Mats has promised to look into this.

- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
  (I added several test cases for this, but in this case it's better that
  someone else also tests this throughly).
  Lars has promosed to do this.


BitKeeper/etc/ignore:
  added mysys/test_bitmap
include/base64.h:
  Removed my_global.h, as this must be included first in any program
include/heap.h:
  Added heap_reset() (Required by new handler interface)
include/my_base.h:
  Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET).
  HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary
include/my_bitmap.h:
  Remove my_pthread.h (should be included at upper level)
  Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box
  Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp()
  Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void
include/myisam.h:
  Added mi_reset() (Required by new handler interface)
include/myisammrg.h:
  Added myrg_reset() (Required by new handler interface)
include/mysql_com.h:
  Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
  Added testing of CREATE ... SELECT in a mixed environment
  (This found some bugs that Mats is going to fix shortly)
mysql-test/install_test_db.sh:
  Simplify ldata usage
  Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set)
mysql-test/mysql-test-run.pl:
  Added --tmpdir=. to bootstrap
mysql-test/mysql-test-run.sh:
  Use copy instead of INSTALL_DB for master and slave databases.
  (Speeds up startup time a lot!)
  Remove snapshot directories at startup (removes some strange warnings)
mysql-test/r/binlog_row_mix_innodb_myisam.result:
  Added testing of CREATE ... SELECT in a mixed environment
  (This found some bugs that Mats is going to fix shortly)
mysql-test/r/binlog_stm_mix_innodb_myisam.result:
  Added testing of CREATE ... SELECT in a mixed environment
mysql-test/r/create.result:
  Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/r/federated.result:
  Drop some left over tables
  Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/r/func_gconcat.result:
  Enable some disabled tests (converted them slightly to be predictable)
mysql-test/r/func_time.result:
  Added drop of test function
mysql-test/r/innodb_mysql.result:
  Added tests for CREATE ... SELECT
mysql-test/r/insert.result:
  More tests
  Added testing of duplicate columns in insert
mysql-test/r/loaddata.result:
  Added testing LOAD DATA ... SET ...
mysql-test/r/multi_update.result:
  Test multi updates and deletes using primary key and without
mysql-test/r/ndb_index_unique.result:
  Better error message
mysql-test/r/ndb_replace.result:
  New correct result after fixing REPLACE handling with NDB
mysql-test/r/rpl_ddl.result:
  Now we don't get these (wrong) warnings anymore
mysql-test/r/view_grant.result:
  Drop used views
mysql-test/t/create.test:
  Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/t/federated.test:
  Drop some left over tables
  Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/t/func_gconcat.test:
  Enable some disabled tests (converted them slightly to be predictable)
mysql-test/t/func_time.test:
  Added drop of test function
mysql-test/t/innodb_mysql.test:
  Added tests for CREATE ... SELECT
mysql-test/t/insert.test:
  More tests
  Added testing of duplicate columns in insert
mysql-test/t/loaddata.test:
  Added testing LOAD DATA ... SET ...
mysql-test/t/multi_update.test:
  Test multi updates and deletes using primary key and without
mysql-test/t/view_grant.test:
  Drop used views
mysql-test/valgrind.supp:
  Added supression of not needed warnings when printing stack trace
mysys/base64.c:
  Include my_global.h first
mysys/my_bitmap.c:
  Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy()
  Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström)
  Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed.
  Changed how mutex is allocated to make 'bitmap_free()' function simpler.
mysys/thr_lock.c:
  Added 0x before thread pointers (for easier comparison of DBUG traces)
sql/event.cc:
  Ensure 'use_all_columns()' is used for event tables
  Don't print warning that event table is damaged if it doesn't exists.
sql/field.cc:
  Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set
  (Rest of changes are only indentation cleanups)
sql/field.h:
  Removed Field->query_id (replaced by table->read_set and table->write_set)
  Removed Field->fieldnr (use Field->field_index instead)
  Removed Field->add_index (Use Field->flags instead)
  Add Field->part_of_key_not_clustered (for usage in opt_range.cc)
sql/filesort.cc:
  Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set.
  This allowed me to remove checking of sql_command.
  Create a temporary column bitmap for fields that are used by the sorting process.
  Use column bitmaps instead of query_id
sql/ha_berkeley.cc:
  Update to 'newer' table handler interface
sql/ha_berkeley.h:
  Update to 'newer' table handler interface
sql/ha_federated.cc:
  Update to 'newer' table handler interface
  Only read columns that are needed from remote server.
  In case of eq ranges, don't generate two conditions in the WHERE clause
  (this can still be optimized, but would require a bigger code change)
  Use 'simpler to use' XXXX_LEN' macros
  A bit simpler logic in ::write_row() when creating statements.
  In update, only include test of fields actually read.
  (This greatly simplifies the queries sent by the federated engine)
  Similar changes done for delete_row()
sql/ha_federated.h:
  Update to 'newer' table handler interface
  Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc
  Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE
sql/ha_heap.cc:
  Update to 'newer' table handler interface
sql/ha_heap.h:
  Update to 'newer' table handler interface
sql/ha_innodb.cc:
  Update to 'newer' table handler interface
  - Update innobase_create_handler() to new interface
  - Removed HA_NOT_EXACT_COUNT (not needed)
  - Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
  - Prefixed base status variables with 'stats'
  - Use table column bitmaps instead of ha_get_bit_in_read_set()
  - Added ::reset(), with code from ::extra(HA_EXTRA_RESET)
  - Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as
    the table->read_set and table->write_set bitmaps now are accurate
sql/ha_innodb.h:
  Update to 'newer' table handler interface
  - table_flags are now ulonglong
  - Added reset() method
  - Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns.
  - Made build_template() a class function to be able to easier access class variables
sql/ha_myisam.cc:
  Update to 'newer' table handler interface
sql/ha_myisam.h:
  Update to 'newer' table handler interface
sql/ha_myisammrg.cc:
  Update to 'newer' table handler interface
sql/ha_myisammrg.h:
  Update to 'newer' table handler interface
sql/ha_ndbcluster.cc:
  Update to 'newer' table handler interface
  Fixed use_blob_value() to be accurate
  In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map
  Correct dumping of field data with DBUG_DUMP
  Prefix addresses in DBUG_PRINT with 0x
  Fixed usage of not initialized memory
  Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index.
sql/ha_ndbcluster.h:
  Update to 'newer' table handler interface
sql/ha_ndbcluster_binlog.cc:
  Mark usage of all columns in ndbcluster binlog tables
  false -> FALSE, true -> TRUE
  Use table->s->all_set instead of creating a temporary bitmap.
sql/ha_partition.cc:
  Update to 'newer' table handler interface
  Added memroot to initialise_partitions() and related functions to get faster memory allocation.
  partition_create_handler() is now responsible for initialisation of the partition object
  Some trivial optimizations and indentation fixes
  Ensure that table_flags() are up to date
  Removed documentation for removed HA_EXTRA flags
  Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance'
sql/ha_partition.h:
  Update to 'newer' table handler interface
sql/handler.cc:
  create_xxx handler now takes MEMROOT as an argument to simplify memory allocation.
  Much simpler get_new_handler()
  (Initialization of the object is now handled by the create method for the engine)
  Moved all allocation of bitmap handling to the TABLE object (in table.cc)
  Added column_bitmaps_signal() to signal column usage changes.
  Changed binlog_log_row() to use the exiusting all_set bitmap in the table object.
  Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset()
  Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row
sql/handler.h:
  Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS
  Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME
  HA_DUPP_POS -> HA_DUPLICATE_POS
  HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records()
  HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
  Added future row type 'ROW_TYPE_PAGES'
  Added MEM_ROOT to handlerton 'create' function
  Added ha_statistics, a structure for all status variable in the base handler class.
  Moved all status variables in the handler class into a stats structs to improve readability.
  ha_table_flags() is now a cached (not virtual) version of table_flags()
  reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own.
  Renamed dupp_ref to dup_ref
  Renamed not used handler::sortkey
  Moved read_set and write_set to TABLE structure
  handler::init() function added for cacheing of virtual constants from engine.
sql/item.cc:
  Added register_field_in_read_map() for marking used columns in expression.
  This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting.
  Initalize value.cs_info.character_set_client to fix core dump bug with --debug
  set_query_id -> mark_used_columns
  Mark used columns in read_set OR write_set.
sql/item.h:
  Removed reset_query_id_processor() as it's not needed anymore.
  Added register_field_in_read_map()
  Added extra argument to Item::walk() to indicate if we should also
  traverse sub queries.
sql/item_cmpfunc.cc:
  Temporary mark used columns to be read/writable
  Update Item::walk to new interface
sql/item_cmpfunc.h:
  Added extra argument to Item::walk() to indicate if we should also traverse sub queries.
sql/item_func.cc:
  Update Item::walk() to new interface
  table_flags() -> ha_table_flags()
sql/item_func.h:
  Update Item::walk() to new interface
sql/item_row.cc:
  Update Item::walk() to new interface
sql/item_row.h:
  Update Item::walk() to new interface
sql/item_strfunc.h:
  Update Item::walk() to new interface
sql/item_subselect.cc:
  Added Item_subselect::walk()
  (It was a bug it was missing before. Not sure what kind of bugs this could have caused)
sql/item_subselect.h:
  Update Item::walk() to new interface
sql/item_sum.cc:
  Update Item::walk() to new interface
  Updates for new handler interace
sql/item_sum.h:
  Update Item::walk() to new interface
sql/key.cc:
  Updates for new handler interace
sql/log.cc:
  Mark all columns used for log tables
  Split options flag
  Ensured that second argument to trans_register_ha is a bool
sql/log_event.cc:
  Fixed comments to be withing 79 characters
  Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings
  Updates for new handler interface
  Use 0x%lx instead of %p (portability problem)
sql/mysql_priv.h:
  Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback
  Removed not used 'conds' argument to setup_tables
sql/mysqld.cc:
  Indentation fixes and removed old comment
sql/opt_range.cc:
  Update to new handler and bitmap interface.
  Fixed calls to cp_buffer_from_ref() and walk() (new argument).
  Create new temporary bitmaps for ror scans.
  (Needed because of handler changes and to get more accurate column bitmaps than before)
  Remove not needed file->ha_reset() call before file->close().
  Some trivial optimization and indentation fixes.
  Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts.
  
  Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record.
  This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling.
  (This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans)
  
  Optimized bitmap handling in ror scans:
  - Start bitmap at position 0, not 1
  - Use same bitmap size as in TABLE
  - Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table
sql/opt_range.h:
  Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan
  Added temporary column bitmaps used in ROR scans
sql/opt_sum.cc:
  Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS
  Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set.
sql/protocol.cc:
  We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user
sql/records.cc:
  Updates for new handler interface
sql/set_var.cc:
  Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags
sql/share/errmsg.txt:
  Fixed wrong
sql/sp.cc:
  Mark that we are using all columns for the proc table
  Update call to setup_tables() to use new prototype
sql/sp_head.cc:
  Removed QQ comment
sql/spatial.cc:
  Removed wrong QQ comment
sql/sql_acl.cc:
  Mark that we need all columns for acl tables
  Supply memroot to some 'new' calls.
  Indentation fixes
sql/sql_base.cc:
  set_query_id removed
  Ensure we call ha_reset() at end of each statement
  Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set)
  Fixed marking of some columns that was not proplerly marked before
  Maintain in TABLE->merge_keys set of all keys that are used in some way
  Removed not used 'conds' argument from setup_tables()
  Remove not used setting of 'dupp_field' in insert_fields()
  Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
  (This has probably caused us to not properly remove temporary files after crash)
sql/sql_bitmap.h:
  Added is_overlapping()
sql/sql_class.cc:
  Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log.
  set_query_id -> mark_used_columns
  Simpler variable usage in pack_row()  (cleanup)
  Moved some variable declartion at start of function for better code readability
sql/sql_class.h:
  Added enum_mark_columns
  Updated comments
  Renamed dupp_field -> dup_field
  Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE.
  (This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables)
sql/sql_delete.cc:
  Updates to new handler interface
  Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires.
  Call table->prepare_for_position() to tell handler that we are going to call ha_position().
  Removed call to free_io_cache(). (io_cache is now removed in ha_reset()).
  Fixed calls to setup_tables()
sql/sql_do.cc:
  Update call to setup_fields()
sql/sql_handler.cc:
  Tell handler tables to always read all columns.
  Use temporary column map when storing value in field for later index usage
sql/sql_help.cc:
  Makr all used fields to be read
  Update call to setup_fields()
sql/sql_insert.cc:
  Tell handler we are going to update the auto_increment column
  dupp_field -> dup_field
  Set column usage bits for timestamp field.
  Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column()
  Removed not used argument from mysql_prepare_insert_check_table().
  
  If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation.
  This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled.
  This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row.
  
  Setup new bitmaps for delayed insert rows
  Remove reseting of next_number_fields as it will be reset on next call to handler_insert()
  
  Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE.
  The issue was that one should not to reset this flag as it may be set by a previous statement.
  The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional.
  I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done)
  Don't close tables created with CREATE ... SELECT but keep them in the table cache.
  
  Moved out MY_HOOKS from inside function (better readability)
sql/sql_load.cc:
  Update to use new handler and column marking interface
  Update using setup_tables()
sql/sql_olap.cc:
  Update calls to setup_tables
  Use enums instead of constants to setup_fields()
sql/sql_parse.cc:
  Handle OPTION_KEEP_LOG:
  - Set it on CREATE TEMPORARY TABLE / DROP TABLE
  - Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset
  - Don't set it for CREATE ... SELECT (this is handled in select_create class)
  Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset.
  If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands
sql/sql_partition.cc:
  Update walk() usage
  Trivial indentation fixes
sql/sql_plugin.cc:
  Mark all columns as used for plugins
sql/sql_prepare.cc:
  Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly)
  Updates for new handler interface
  Update calls to setup_fields()
sql/sql_repl.cc:
  Indentation fixes
sql/sql_select.cc:
  Update call to setup_tables() and setup_fields()
  Remove some old disabled code
  Update to new hadler interface
  Indentation cleanups
  Added column bitmaps for temporary tables.
  Remove updating of the removed slots in the Field class
  Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps)
  For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution.
sql/sql_select.h:
  Indentaition fixes.
  Install temporary column usage maps when needed
  Added TABLE element to cp_buffer_from_ref()
sql/sql_show.cc:
  Update to new handler interface
  Mark all columns used for internal tables.
  Style fixes.
  Added support for 'future' ROW_TYPE_PAGES.
  Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly.
sql/sql_table.cc:
  Update to new handler interface
  Simple my_snprintf -> strmake()
  Changed some constants to defines
  Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL)
  Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX
  Mark all columns as used for ALTER TABLE
  Style fixes
  Update call to filesort()
sql/sql_trigger.h:
  Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in.
sql/sql_udf.cc:
  Mark all columns as used for udf system table.
sql/sql_union.cc:
  Update call to walk()
  Update to new handler interface
sql/sql_update.cc:
  Remove query_id argument from compare_record()
  Use column bitmaps instead of query_id.
  We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value.
  Update call to setup_fields()
  Using separate column read and write sets allows for easier checking of timestamp field was set by statement.
  Removed call to free_io_cache() as this is now done in ha_reset()
  Call table->mark_columns_needed_for_update() and table->prepare_for_position()
  Style fixes
sql/sql_view.cc:
  Style fixes
sql/table.cc:
  Remove implicitely include 'errno.h'
  Remove code for building normalized path, as this is now identical to 'path'
  Remove field->fieldnr
  Added update of field->part_of_key_not_clustered()
  Create column bitmaps in TABLE and TABLE_SHARE
  Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler()
  Update to new handler interface
  Update call to walk()
  Added new functions:
  - st_table::clear_column_bitmaps()
  - st_table::prepare_for_position()
  - st_table::mark_columns_used_by_index()
  - st_table::restore_column_maps_after_mark_index()
  - st_table::mark_columns_used_by_index_no_reset()
  - st_table::mark_auto_increment_column()
  - st_table::mark_columns_needed_for_delete()
  - st_table::mark_columns_needed_for_update()
  - st_table::mark_columns_needed_for_insert()
sql/table.h:
  Moved column usage bitmaps from handler to TABLE
  Added to TABLE_SHARE all_set and column_bitmap_size
  Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set.
  Declared all new table column bitmap functions
  Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps()
  Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps
  Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val().
sql/tztime.cc:
  Mark all columns as used for timezone tables
storage/archive/ha_archive.cc:
  Update to new handler interface
storage/archive/ha_archive.h:
  Update to new handler interface
storage/blackhole/ha_blackhole.cc:
  Update to new handler interface
storage/blackhole/ha_blackhole.h:
  Update to new handler interface
  removed not needed flag HA_DUPP_POS
storage/csv/ha_tina.cc:
  Update to new handler interface
storage/csv/ha_tina.h:
  Update to new handler interface
storage/example/ha_example.cc:
  Update to new handler interface
storage/example/ha_example.h:
  Update to new handler interface
storage/heap/hp_extra.c:
  Added heap_reset() (Required by new handler interface)
storage/heap/hp_test2.c:
  Use heap_reset()
storage/myisam/ft_boolean_search.c:
  Fixed compiler warning
storage/myisam/mi_extra.c:
  Added mi_reset() (Required by new handler interface)
storage/myisam/mi_search.c:
  Fixed DBUG_PRINT messages to use 0x%lx instead of %lx
storage/myisam/mi_test2.c:
  Use mi_reset()
storage/myisam/myisampack.c:
  Use mi_reset()
storage/myisammrg/myrg_extra.c:
  Added myrg_reset() (Required by new handler interface)
unittest/mysys/base64.t.c:
  Include my_global.h
  Don't include implictely include file 'stdlib.h'
2006-06-04 18:52:22 +03:00
monty@mysql.com
74cc73d461 This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),

- New optional handler function introduced: reset()
  This is called after every DML statement to make it easy for a handler to
  statement specific cleanups.
  (The only case it's not called is if force the file to be closed)

- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
  should be moved to handler::reset()

- table->read_set contains a bitmap over all columns that are needed
  in the query.  read_row() and similar functions only needs to read these
  columns
- table->write_set contains a bitmap over all columns that will be updated
  in the query. write_row() and update_row() only needs to update these
  columns.
  The above bitmaps should now be up to date in all context
  (including ALTER TABLE, filesort()).

  The handler is informed of any changes to the bitmap after
  fix_fields() by calling the virtual function
  handler::column_bitmaps_signal(). If the handler does caching of
  these bitmaps (instead of using table->read_set, table->write_set),
  it should redo the caching in this code. as the signal() may be sent
  several times, it's probably best to set a variable in the signal
  and redo the caching on read_row() / write_row() if the variable was
  set.

- Removed the read_set and write_set bitmap objects from the handler class

- Removed all column bit handling functions from the handler class.
  (Now one instead uses the normal bitmap functions in my_bitmap.c instead
  of handler dedicated bitmap functions)

- field->query_id is removed. One should instead instead check
  table->read_set and table->write_set if a field is used in the query.

- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
  handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
  instead use table->read_set to check for which columns to retrieve.

- If a handler needs to call Field->val() or Field->store() on columns
  that are not used in the query, one should install a temporary
  all-columns-used map while doing so. For this, we provide the following
  functions:

  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
  field->val();
  dbug_tmp_restore_column_map(table->read_set, old_map);

  and similar for the write map:

  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
  field->val();
  dbug_tmp_restore_column_map(table->write_set, old_map);

  If this is not done, you will sooner or later hit a DBUG_ASSERT
  in the field store() / val() functions.
  (For not DBUG binaries, the dbug_tmp_restore_column_map() and
  dbug_tmp_restore_column_map() are inline dummy functions and should
  be optimized away be the compiler).

- If one needs to temporary set the column map for all binaries (and not
  just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
  methods) one should use the functions tmp_use_all_columns() and
  tmp_restore_column_map() instead of the above dbug_ variants.

- All 'status' fields in the handler base class (like records,
  data_file_length etc) are now stored in a 'stats' struct. This makes
  it easier to know what status variables are provided by the base
  handler.  This requires some trivial variable names in the extra()
  function.

- New virtual function handler::records().  This is called to optimize
  COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
  (stats.records is not supposed to be an exact value. It's only has to
  be 'reasonable enough' for the optimizer to be able to choose a good
  optimization path).

- Non virtual handler::init() function added for caching of virtual
  constants from engine.

- Removed has_transactions() virtual method. Now one should instead return
  HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
  transactions.

- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
  that is to be used with 'new handler_name()' to allocate the handler
  in the right area.  The xxxx_create_handler() function is also
  responsible for any initialization of the object before returning.

  For example, one should change:

  static handler *myisam_create_handler(TABLE_SHARE *table)
  {
    return new ha_myisam(table);
  }

  ->

  static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
  {
    return new (mem_root) ha_myisam(table);
  }

- New optional virtual function: use_hidden_primary_key().
  This is called in case of an update/delete when
  (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
  but we don't have a primary key. This allows the handler to take precisions
  in remembering any hidden primary key to able to update/delete any
  found row. The default handler marks all columns to be read.

- handler::table_flags() now returns a ulonglong (to allow for more flags).

- New/changed table_flags()
  - HA_HAS_RECORDS	    Set if ::records() is supported
  - HA_NO_TRANSACTIONS	    Set if engine doesn't support transactions
  - HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
                            Set if we should mark all primary key columns for
			    read when reading rows as part of a DELETE
			    statement. If there is no primary key,
			    all columns are marked for read.
  - HA_PARTIAL_COLUMN_READ  Set if engine will not read all columns in some
			    cases (based on table->read_set)
 - HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
   			    Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
 - HA_DUPP_POS              Renamed to HA_DUPLICATE_POS
 - HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
			    Set this if we should mark ALL key columns for
			    read when when reading rows as part of a DELETE
			    statement. In case of an update we will mark
			    all keys for read for which key part changed
			    value.
  - HA_STATS_RECORDS_IS_EXACT
			     Set this if stats.records is exact.
			     (This saves us some extra records() calls
			     when optimizing COUNT(*))
			    

- Removed table_flags()
  - HA_NOT_EXACT_COUNT     Now one should instead use HA_HAS_RECORDS if
			   handler::records() gives an exact count() and
			   HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
  - HA_READ_RND_SAME	   Removed (no one supported this one)

- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()

- Renamed handler::dupp_pos to handler::dup_pos

- Removed not used variable handler::sortkey


Upper level handler changes:

- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
  cache is updated on engine creation time and updated on open.


MySQL level changes (not obvious from the above):

- DBUG_ASSERT() added to check that column usage matches what is set
  in the column usage bit maps. (This found a LOT of bugs in current
  column marking code).

- In 5.1 before, all used columns was marked in read_set and only updated
  columns was marked in write_set. Now we only mark columns for which we
  need a value in read_set.

- Column bitmaps are created in open_binary_frm() and open_table_from_share().
  (Before this was in table.cc)

- handler::table_flags() calls are replaced with handler::ha_table_flags()

- For calling field->val() you must have the corresponding bit set in
  table->read_set. For calling field->store() you must have the
  corresponding bit set in table->write_set. (There are asserts in
  all store()/val() functions to catch wrong usage)

- thd->set_query_id is renamed to thd->mark_used_columns and instead
  of setting this to an integer value, this has now the values:
  MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
  Changed also all variables named 'set_query_id' to mark_used_columns.

- In filesort() we now inform the handler of exactly which columns are needed
  doing the sort and choosing the rows.

- The TABLE_SHARE object has a 'all_set' column bitmap one can use
  when one needs a column bitmap with all columns set.
  (This is used for table->use_all_columns() and other places)

- The TABLE object has 3 column bitmaps:
  - def_read_set     Default bitmap for columns to be read
  - def_write_set    Default bitmap for columns to be written
  - tmp_set          Can be used as a temporary bitmap when needed.
  The table object has also two pointer to bitmaps read_set and write_set
  that the handler should use to find out which columns are used in which way.

- count() optimization now calls handler::records() instead of using
  handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).

- Added extra argument to Item::walk() to indicate if we should also
  traverse sub queries.

- Added TABLE parameter to cp_buffer_from_ref()

- Don't close tables created with CREATE ... SELECT but keep them in
  the table cache. (Faster usage of newly created tables).


New interfaces:

- table->clear_column_bitmaps() to initialize the bitmaps for tables
  at start of new statements.

- table->column_bitmaps_set() to set up new column bitmaps and signal
  the handler about this.

- table->column_bitmaps_set_no_signal() for some few cases where we need
  to setup new column bitmaps but don't signal the handler (as the handler
  has already been signaled about these before). Used for the momement
  only in opt_range.cc when doing ROR scans.

- table->use_all_columns() to install a bitmap where all columns are marked
  as use in the read and the write set.

- table->default_column_bitmaps() to install the normal read and write
  column bitmaps, but not signaling the handler about this.
  This is mainly used when creating TABLE instances.

- table->mark_columns_needed_for_delete(),
  table->mark_columns_needed_for_delete() and
  table->mark_columns_needed_for_insert() to allow us to put additional
  columns in column usage maps if handler so requires.
  (The handler indicates what it neads in handler->table_flags())

- table->prepare_for_position() to allow us to tell handler that it
  needs to read primary key parts to be able to store them in
  future table->position() calls.
  (This replaces the table->file->ha_retrieve_all_pk function)

- table->mark_auto_increment_column() to tell handler are going to update
  columns part of any auto_increment key.

- table->mark_columns_used_by_index() to mark all columns that is part of
  an index.  It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
  it to quickly know that it only needs to read colums that are part
  of the key.  (The handler can also use the column map for detecting this,
  but simpler/faster handler can just monitor the extra() call).

- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
  also mark all columns that is used by the given key.

- table->restore_column_maps_after_mark_index() to restore to default
  column maps after a call to table->mark_columns_used_by_index().

- New item function register_field_in_read_map(), for marking used columns
  in table->read_map. Used by filesort() to mark all used columns

- Maintain in TABLE->merge_keys set of all keys that are used in query.
  (Simplices some optimization loops)

- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
  but the field in the clustered key is not assumed to be part of all index.
  (used in opt_range.cc for faster loops)

-  dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
   tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
   mark all columns as usable.  The 'dbug_' version is primarily intended
   inside a handler when it wants to just call Field:store() & Field::val()
   functions, but don't need the column maps set for any other usage.
   (ie:: bitmap_is_set() is never called)

- We can't use compare_records() to skip updates for handlers that returns
  a partial column set and the read_set doesn't cover all columns in the
  write set. The reason for this is that if we have a column marked only for
  write we can't in the MySQL level know if the value changed or not.
  The reason this worked before was that MySQL marked all to be written
  columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
  bug'.

- open_table_from_share() does not anymore setup temporary MEM_ROOT
  object as a thread specific variable for the handler. Instead we
  send the to-be-used MEMROOT to get_new_handler().
  (Simpler, faster code)



Bugs fixed:

- Column marking was not done correctly in a lot of cases.
  (ALTER TABLE, when using triggers, auto_increment fields etc)
  (Could potentially result in wrong values inserted in table handlers
  relying on that the old column maps or field->set_query_id was correct)
  Especially when it comes to triggers, there may be cases where the
  old code would cause lost/wrong values for NDB and/or InnoDB tables.

- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
  OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
  This allowed me to remove some wrong warnings about:
  "Some non-transactional changed tables couldn't be rolled back"

- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
  (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
  some warnings about
  "Some non-transactional changed tables couldn't be rolled back")

- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
  which could cause delete_table to report random failures.

- Fixed core dumps for some tests when running with --debug

- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
  (This has probably caused us to not properly remove temporary files after
  crash)

- slow_logs was not properly initialized, which could maybe cause
  extra/lost entries in slow log.

- If we get an duplicate row on insert, change column map to read and
  write all columns while retrying the operation. This is required by
  the definition of REPLACE and also ensures that fields that are only
  part of UPDATE are properly handled.  This fixed a bug in NDB and
  REPLACE where REPLACE wrongly copied some column values from the replaced
  row.

- For table handler that doesn't support NULL in keys, we would give an error
  when creating a primary key with NULL fields, even after the fields has been
  automaticly converted to NOT NULL.

- Creating a primary key on a SPATIAL key, would fail if field was not
  declared as NOT NULL.


Cleanups:

- Removed not used condition argument to setup_tables

- Removed not needed item function reset_query_id_processor().

- Field->add_index is removed. Now this is instead maintained in
  (field->flags & FIELD_IN_ADD_INDEX)

- Field->fieldnr is removed (use field->field_index instead)

- New argument to filesort() to indicate that it should return a set of
  row pointers (not used columns). This allowed me to remove some references
  to sql_command in filesort and should also enable us to return column
  results in some cases where we couldn't before.

- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
  bitmap, which allowed me to use bitmap functions instead of looping over
  all fields to create some needed bitmaps. (Faster and smaller code)

- Broke up found too long lines

- Moved some variable declaration at start of function for better code
  readability.

- Removed some not used arguments from functions.
  (setup_fields(), mysql_prepare_insert_check_table())

- setup_fields() now takes an enum instead of an int for marking columns
   usage.

- For internal temporary tables, use handler::write_row(),
  handler::delete_row() and handler::update_row() instead of
  handler::ha_xxxx() for faster execution.

- Changed some constants to enum's and define's.

- Using separate column read and write sets allows for easier checking
  of timestamp field was set by statement.

- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()

- Don't build table->normalized_path as this is now identical to table->path
  (after bar's fixes to convert filenames)

- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
  do comparision with the 'convert-dbug-for-diff' tool.


Things left to do in 5.1:

- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
  row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
  Mats has promised to look into this.

- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
  (I added several test cases for this, but in this case it's better that
  someone else also tests this throughly).
  Lars has promosed to do this.
2006-06-04 18:52:22 +03:00
unknown
36815fa1ad Bug#16837 (Missing #ifdef cause compile problem --without-row-based-replication):
Added #ifdef's to make code work even when the system is built without
row-based replication.


mysql-test/r/create.result:
  Result change
mysql-test/r/innodb_mysql.result:
  Result change
mysql-test/t/create.test:
  Moving InnoDB specific test to innodb_mysql.test
mysql-test/t/innodb_mysql.test:
  Moving InnoDB-specific test from create.test
mysql-test/t/rpl_rbr_to_sbr.test:
  Test only sensible if we have row-based replication compiled in.
mysql-test/t/rpl_row_basic_8partition.test:
  Test only sensible if we have row-based replication compiled in.
sql/log.cc:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/set_var.cc:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/set_var.h:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/share/errmsg.txt:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/sql_base.cc:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/sql_class.cc:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/sql_class.h:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/sql_insert.cc:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/sql_parse.cc:
  Adding HAVE_ROW_BASED_REPLICATION guards on code to work without
  row-based replication.
sql/sql_table.cc:
  Not running hooks
2006-05-16 11:16:23 +02:00
mats@mysql.com
66766ad596 Bug#16837 (Missing #ifdef cause compile problem --without-row-based-replication):
Added #ifdef's to make code work even when the system is built without
row-based replication.
2006-05-16 11:16:23 +02:00
unknown
659dfdfc07 Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into mysql.com:/home/gluh/MySQL/Merge/5.1-new


mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2006-03-31 13:17:45 +05:00
gluh@mysql.com
486a48d46c Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into mysql.com:/home/gluh/MySQL/Merge/5.1-new
2006-03-31 13:17:45 +05:00
unknown
600a17635e post-merge fix 2006-03-30 09:13:25 +05:00
gluh@eagle.intranet.mysql.r18.ru
70a8f32d81 post-merge fix 2006-03-30 09:13:25 +05:00
unknown
a7431720ce Merge
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
mysql-test/r/create.result:
  SCCS merged
2006-03-30 08:13:28 +05:00
gluh@mysql.com
ea56026e4f Merge 2006-03-30 08:13:28 +05:00
unknown
4af4e1e704 Fix for bug#15316 SET value having comma not correctly handled
disallow the use of comma in SET members


mysql-test/r/create.result:
  Fix for bug#15316 SET value having comma not correctly handled
   test case
mysql-test/t/create.test:
  Fix for bug#15316 SET value having comma not correctly handled
   test case
2006-03-29 19:52:26 +05:00
gluh@eagle.intranet.mysql.r18.ru
2545c7d414 Fix for bug#15316 SET value having comma not correctly handled
disallow the use of comma in SET members
2006-03-29 19:52:26 +05:00
unknown
ccd2742f8e Merge neptunus.(none):/home/msvensson/mysql/bug10460/my51-bug10460
into  neptunus.(none):/home/msvensson/mysql/mysql-5.1


mysql-test/r/bigint.result:
  Auto merged
mysql-test/r/binary.result:
  Auto merged
mysql-test/r/case.result:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/events.result:
  Auto merged
mysql-test/r/heap.result:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/merge.result:
  Auto merged
mysql-test/r/mysqldump.result:
  Auto merged
mysql-test/r/partition.result:
  Auto merged
mysql-test/r/partition_02myisam.result:
  Auto merged
mysql-test/r/partition_mgm_err.result:
  Auto merged
mysql-test/r/show_check.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/subselect.result:
  Auto merged
mysql-test/r/trigger.result:
  Auto merged
mysql-test/r/type_timestamp.result:
  Auto merged
sql/sql_show.cc:
  Auto merged
mysql-test/r/archive_gis.result:
  Merge bug10460
mysql-test/r/bdb_gis.result:
  Merge bug10460
mysql-test/r/func_system.result:
  Merge bug10460
mysql-test/r/innodb_gis.result:
  Merge bug10460
mysql-test/r/ndb_gis.result:
  Merge bug10460
2006-03-06 11:39:36 +01:00
msvensson@neptunus.(none)
40b3222b74 Merge neptunus.(none):/home/msvensson/mysql/bug10460/my51-bug10460
into  neptunus.(none):/home/msvensson/mysql/mysql-5.1
2006-03-06 11:39:36 +01:00
unknown
8f4cec206b Merge zim.(none):/home/brian/mysql/mysql-5.0
into  zim.(none):/home/brian/mysql/dep-5.1


mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2006-02-24 23:31:57 -08:00
brian@zim.(none)
f40705eb9b Merge zim.(none):/home/brian/mysql/mysql-5.0
into  zim.(none):/home/brian/mysql/dep-5.1
2006-02-24 23:31:57 -08:00
unknown
31a7a0d646 Bug#10460 SHOW CREATE TABLE uses inconsistent upper/lower case
mysql-test/r/alter_table.result:
  Update test result
mysql-test/r/analyse.result:
  Update test result
mysql-test/r/archive.result:
  Update test result
mysql-test/r/archive_bitfield.result:
  Update test result
mysql-test/r/archive_gis.result:
  Update test result
mysql-test/r/bdb.result:
  Update test result
mysql-test/r/bdb_gis.result:
  Update test result
mysql-test/r/bigint.result:
  Update test result
mysql-test/r/binary.result:
  Update test result
mysql-test/r/case.result:
  Update test result
mysql-test/r/cast.result:
  Update test result
mysql-test/r/constraints.result:
  Update test result
mysql-test/r/create.result:
  Update test result
mysql-test/r/ctype_collate.result:
  Update test result
mysql-test/r/ctype_create.result:
  Update test result
mysql-test/r/ctype_latin1_de.result:
  Update test result
mysql-test/r/ctype_many.result:
  Update test result
mysql-test/r/ctype_mb.result:
  Update test result
mysql-test/r/ctype_recoding.result:
  Update test result
mysql-test/r/ctype_sjis.result:
  Update test result
mysql-test/r/ctype_tis620.result:
  Update test result
mysql-test/r/ctype_ucs.result:
  Update test result
mysql-test/r/ctype_ujis.result:
  Update test result
mysql-test/r/ctype_utf8.result:
  Update test result
mysql-test/r/default.result:
  Update test result
mysql-test/r/events.result:
  Update test result
mysql-test/r/federated.result:
  Update test result
mysql-test/r/fulltext.result:
  Update test result
mysql-test/r/func_gconcat.result:
  Update test result
mysql-test/r/func_group.result:
  Update test result
mysql-test/r/func_math.result:
  Update test result
mysql-test/r/func_misc.result:
  Update test result
mysql-test/r/func_str.result:
  Update test result
mysql-test/r/func_system.result:
  Update test result
mysql-test/r/gis-rtree.result:
  Update test result
mysql-test/r/heap.result:
  Update test result
mysql-test/r/index_merge_innodb.result:
  Update test result
mysql-test/r/information_schema.result:
  Update test result
mysql-test/r/innodb.result:
  Update test result
mysql-test/r/innodb_gis.result:
  Update test result
mysql-test/r/key.result:
  Update test result
mysql-test/r/merge.result:
  Update test result
mysql-test/r/myisam.result:
  Update test result
mysql-test/r/mysqldump-max.result:
  Update test result
mysql-test/r/mysqldump.result:
  Update test result
mysql-test/r/ndb_bitfield.result:
  Update test result
mysql-test/r/ndb_gis.result:
  Update test result
mysql-test/r/ndb_partition_key.result:
  Update test result
mysql-test/r/null.result:
  Update test result
mysql-test/r/partition.result:
  Update test result
mysql-test/r/partition_02myisam.result:
  Update test result
mysql-test/r/partition_mgm_err.result:
  Update test result
mysql-test/r/partition_range.result:
  Update test result
mysql-test/r/ps_2myisam.result:
  Update test result
mysql-test/r/ps_3innodb.result:
  Update test result
mysql-test/r/ps_4heap.result:
  Update test result
mysql-test/r/ps_5merge.result:
  Update test result
mysql-test/r/ps_6bdb.result:
  Update test result
mysql-test/r/rpl_mixed_ddl_dml.result:
  Update test result
mysql-test/r/rpl_multi_engine.result:
  Update test result
mysql-test/r/rpl_ndb_UUID.result:
  Update test result
mysql-test/r/show_check.result:
  Update test result
mysql-test/r/sp-vars.result:
  Update test result
mysql-test/r/sp.result:
  Update test result
mysql-test/r/sql_mode.result:
  Update test result
mysql-test/r/strict.result:
  Update test result
mysql-test/r/subselect.result:
  Update test result
mysql-test/r/symlink.result:
  Update test result
mysql-test/r/synchronization.result:
  Update test result
mysql-test/r/system_mysql_db.result:
  Update test result
mysql-test/r/temp_table.result:
  Update test result
mysql-test/r/trigger.result:
  Update test result
mysql-test/r/type_binary.result:
  Update test result
mysql-test/r/type_bit.result:
  Update test result
mysql-test/r/type_bit_innodb.result:
  Update test result
mysql-test/r/type_blob.result:
  Update test result
mysql-test/r/type_decimal.result:
  Update test result
mysql-test/r/type_enum.result:
  Update test result
mysql-test/r/type_float.result:
  Update test result
mysql-test/r/type_nchar.result:
  Update test result
mysql-test/r/type_newdecimal.result:
  Update test result
mysql-test/r/type_set.result:
  Update test result
mysql-test/r/type_timestamp.result:
  Update test result
mysql-test/r/type_varchar.result:
  Update test result
mysql-test/r/union.result:
  Update test result
mysql-test/r/user_var.result:
  Update test result
mysql-test/r/variables.result:
  Update test result
sql/sql_show.cc:
  Make ouput from SHOW CREATE TABLE use uppercase for "CHARACTER SET", "COLLATE", "DEFAULT", "ON UPDATE" and "AUTO_INCREMENT"
2006-02-22 10:09:59 +01:00
msvensson@neptunus.(none)
c4b1fb68b4 Bug#10460 SHOW CREATE TABLE uses inconsistent upper/lower case 2006-02-22 10:09:59 +01:00
unknown
71ee8615c3 Fixed bug#17530: Incorrect key truncation on table creation caused server crash.
When a too long field is used for a key, only a prefix part of the field is 
used. Length is reduced to the max key length allowed for storage. But if the
field have a multibyte charset it is possible to break multibyte char
sequence. This leads to the failed assertion in the innodb code and 
server crash when a record is inserted.

The make_prepare_table() now aligns truncated key length to the boundary of
multibyte char.


mysql-test/t/create.test:
  Added test case for bug#17530: Incorrect key truncation on table creation caused server crash.
mysql-test/r/create.result:
  Added test case for bug#17530: Incorrect key truncation on table creation caused server crash.
sql/sql_table.cc:
  Fixed bug#17530: Incorrect key truncation on table creation caused server crash.
  The make_prepare_table() now aligns truncated key length to the boundary of
  multibyte char.
2006-02-21 18:09:32 +03:00
evgen@moonbone.local
e6924206cd Fixed bug#17530: Incorrect key truncation on table creation caused server crash.
When a too long field is used for a key, only a prefix part of the field is 
used. Length is reduced to the max key length allowed for storage. But if the
field have a multibyte charset it is possible to break multibyte char
sequence. This leads to the failed assertion in the innodb code and 
server crash when a record is inserted.

The make_prepare_table() now aligns truncated key length to the boundary of
multibyte char.
2006-02-21 18:09:32 +03:00
unknown
ea14fa9aeb Merge mysql.com:/home/jimw/my/mysql-5.1-13883
into  mysql.com:/home/jimw/my/mysql-5.1-clean


mysql-test/r/create.result:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/key.result:
  Auto merged
mysql-test/r/merge.result:
  Auto merged
mysql-test/r/partition.result:
  Auto merged
mysql-test/r/show_check.result:
  Auto merged
mysql-test/r/symlink.result:
  Auto merged
mysql-test/r/system_mysql_db.result:
  Auto merged
mysql-test/r/type_blob.result:
  Auto merged
sql/sql_show.cc:
  Auto merged
mysql-test/r/rpl_mixed_ddl_dml.result:
  Auto merged
2006-02-17 11:06:05 -08:00
jimw@mysql.com
cdad081fbe Merge mysql.com:/home/jimw/my/mysql-5.1-13883
into  mysql.com:/home/jimw/my/mysql-5.1-clean
2006-02-17 11:06:05 -08:00
unknown
ba0fda4d77 Merge mysql.com:/home/mydev/mysql-5.1
into  mysql.com:/home/mydev/mysql-5.1-wl1563-msg


mysql-test/r/create.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/sp-error.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
sql/handler.cc:
  Auto merged
sql/share/errmsg.txt:
  Auto merged
mysql-test/r/rpl_foreign_key_innodb.result:
  WL#1563 - Modify MySQL to support fast CREATE/DROP INDEX
  Manual merge
2006-02-03 17:57:23 +01:00
ingo@mysql.com
8906937757 Merge mysql.com:/home/mydev/mysql-5.1
into  mysql.com:/home/mydev/mysql-5.1-wl1563-msg
2006-02-03 17:57:23 +01:00
unknown
80abbcd085 Remove extra space in SHOW CREATE TABLE output. (Bug #13883)
mysql-test/r/alter_table.result:
  Update test results
mysql-test/r/archive_bitfield.result:
  Update test results
mysql-test/r/create.result:
  Update test results
mysql-test/r/ctype_tis620.result:
  Update test results
mysql-test/r/gis-rtree.result:
  Update test results
mysql-test/r/index_merge_innodb.result:
  Update test results
mysql-test/r/information_schema.result:
  Update test results
mysql-test/r/innodb.result:
  Update test results
mysql-test/r/key.result:
  Update test results
mysql-test/r/merge.result:
  Update test results
mysql-test/r/partition.result:
  Update test results
mysql-test/r/partition_range.result:
  Update test results
mysql-test/r/rpl000002.result:
  Update test results
mysql-test/r/rpl_multi_engine.result:
  Update test results
mysql-test/r/show_check.result:
  Update test results
mysql-test/r/sql_mode.result:
  Update test results
mysql-test/r/strict.result:
  Update test results
mysql-test/r/symlink.result:
  Update test results
mysql-test/r/system_mysql_db.result:
  Update test results
mysql-test/r/type_blob.result:
  Update test results
sql/sql_show.cc:
  Avoid adding extra space between 'PRIMARY KEY' and key fields in
  SHOW CREATE TABLE output.
2006-02-02 11:39:28 -08:00
jimw@mysql.com
95f1b04929 Remove extra space in SHOW CREATE TABLE output. (Bug #13883) 2006-02-02 11:39:28 -08:00
unknown
9bd6415218 Merge
mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  SCCS merged
2006-01-28 10:37:22 +01:00
joerg@debian.(none)
c81862cc77 Merge 2006-01-28 10:37:22 +01:00
unknown
0369042a09 WL#1563 - Modify MySQL to support fast CREATE/DROP INDEX
Change "duplicate key" message to print key name
instead of key number.
2006-01-23 12:17:05 +01:00
ingo@mysql.com
b6e28c99d0 WL#1563 - Modify MySQL to support fast CREATE/DROP INDEX
Change "duplicate key" message to print key name
instead of key number.
2006-01-23 12:17:05 +01:00
unknown
490fbdb63e Merge a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-4.1
into  a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.0


mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2006-01-16 21:31:22 +02:00
jani@a193-229-222-105.elisa-laajakaista.fi
b948c2941d Merge a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-4.1
into  a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.0
2006-01-16 21:31:22 +02:00
unknown
f41b7bca6c Merge
mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  SCCS merged
2006-01-16 16:21:41 +01:00
andrey@lmy004.
7b2238d484 Merge 2006-01-16 16:21:41 +01:00
unknown
91881b44c3 Merge mysql.com:/home/jimw/my/mysql-5.0-clean
into  mysql.com:/home/jimw/my/mysql-5.1-clean


include/config-win.h:
  Auto merged
mysql-test/r/bdb.result:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/bdb.test:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/ha_federated.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/parse_file.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_handler.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_trigger.cc:
  Auto merged
sql/field.cc:
  Resolve conflict
sql/ha_ndbcluster.cc:
  Resolve conflict
sql/log_event.cc:
  Resolve conflict
2006-01-06 10:42:58 -08:00
jimw@mysql.com
96ae7c2e78 Merge mysql.com:/home/jimw/my/mysql-5.0-clean
into  mysql.com:/home/jimw/my/mysql-5.1-clean
2006-01-06 10:42:58 -08:00
unknown
29fde52802 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0


mysql-test/r/create.result:
  Auto merged
mysql-test/r/trigger.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/trigger.test:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/t/disabled.def:
  Manual merge
sql/mysqld.cc:
  Manual merge
sql/sp_head.cc:
  Manual merge
sql/sql_trigger.cc:
  Manual merge
2006-01-06 01:08:48 +02:00
monty@mysql.com
b0a5ea01ef Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2006-01-06 01:08:48 +02:00
unknown
64206b1850 Review fixes of new pushed code
- Fixed tests
- Optimized new code
- Fixed some unlikely core dumps
- Better bug fixes for:
  - #14397 - OPTIMIZE TABLE with an open HANDLER causes a crash
  - #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null


mysql-test/r/create.result:
  Update results after removing wrong warnings for CREATE ... SELECT
  New tests
mysql-test/r/handler.result:
  Drop used tables
mysql-test/r/kill.result:
  Make test portable
mysql-test/r/mysqlshow.result:
  Drop tables used by previous test
mysql-test/r/trigger.result:
  Reuse old procedure name
mysql-test/r/view.result:
  Extra tests
mysql-test/t/create.test:
  New tests to test fix of removing wrong warnings for CREATE ... SELECT
mysql-test/t/disabled.def:
  Enable 'kill' test (should now be portable)
mysql-test/t/handler.test:
  Drop used tables
mysql-test/t/kill.test:
  Make test portable even if kill doesn't work at once
mysql-test/t/mysqlshow.test:
  Drop tables used by previous test
mysql-test/t/trigger.test:
  Reuse old procedure name
mysql-test/t/view.test:
  Extra tests
sql/field.cc:
  Removed compiler warning
sql/ha_federated.cc:
  my_snprintf -> strmake()
  (Simple optimization)
sql/ha_ndbcluster.cc:
  Indentation cleanups and trival optimization
sql/item.cc:
  Moved save_org_in_field() to item.cc to make it easier to test
  Remove setting of null_value as this is not needed
sql/item.h:
  Moved save_org_in_field() to item.cc to make it easier to test
sql/log_event.cc:
  Remove inline of slave_load_file_stem()
  Added 'extension' parameter to slave_load_file_stem() to get smaller code
  Removed not critical (or needed) DBUG_ASSERT()'s
  Cleaned up usage of slave_load_file_stem() to not depend on constant string lengths
  Indentation fixes
sql/opt_range.cc:
  Moved code from declaration to function body
  (To make it more readable)
sql/parse_file.cc:
  Fixed DBUG_PRINT
sql/sp.cc:
  Simple cleanups
  - Removed not needed {} level
  - Ensure saved variables starts with old_
sql/sp_head.cc:
  Indentation fixes
  Remove core dump when using --debug when m_next_cached_sp == 0
  Fixed compiler warnings
  Trivial optimizations
sql/sp_head.h:
  Changed argument to set_definer() to const
  Added THD argument to recursion_level_error() to avoid call to current_thd
sql/sql_acl.cc:
  Removed not needed test (first_not_own_table is the guard)
sql/sql_base.cc:
  Removed extra empty line
sql/sql_handler.cc:
  Don't test table version in mysql_ha_read() as this is already tested in lock_tables()
  Moved call to insert_fields to be after lock_table() to guard aganst reopen of tables
  (Better fix for Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash)
sql/sql_insert.cc:
  Mark fields that are set in CREATE ... SELECT as used
  (Removed wrong warnings about field not having a default value)
sql/sql_parse.cc:
  Removed not needed test of 'tables' (first_not_own_table is the guard)
  Simplify code
sql/sql_select.cc:
  Use group->field to check if value is null instead of item called by 'save_org_in_field'
  This is a better bug fix for #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null)
sql/sql_trigger.cc:
  Move sql_modes_parameters outside of function
  Indentation fixes
  Fixed compiler warning
  Ensure that thd->lex->query_tables_own_last is set properly before calling check_table_access()
  (This allows us to remove the extra test in check_grant() and check_table_access())
2006-01-06 00:47:49 +02:00
monty@mysql.com
6e22e29de6 Review fixes of new pushed code
- Fixed tests
- Optimized new code
- Fixed some unlikely core dumps
- Better bug fixes for:
  - #14397 - OPTIMIZE TABLE with an open HANDLER causes a crash
  - #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null
2006-01-06 00:47:49 +02:00
unknown
9c7412cae8 WL#1324 table name to file name encoding
- Encoding itself, implemented as a charset
  "filename". Originally planned to use '.'
  as an escape character, but now changed to '@'
  for two reasons: "ls" does not return
  file names starting with '.' considering them
  as a kind of hidden files; some platforms
  do not allow several dots in a file name.
- replacing many calls of my_snprintf() and
  strnxmov() to the new build_table_filename().
- Adding MY_APPEND_EXT mysys flag, to append
  an extention rather that replace it.
- Replacing all numeric constants in fn_format
  flag arguments to their mysys definitions, e.g.
  MY_UNPACK_FILENAME,
- Predictability in several function/methods:
  when a table name can appear with or withot .frm
  extension. Some functions/methods were changed
  so accept names strictly with .frm, other - strictly
  without .frm extensions. Several DBUG_ASSERTs were
  added to check whether an extension is passed.
Many files:
  table name to file name encoding
mysql_priv.h:
  Prototypes for new table name encoding tools.
ctype-utf8.c:
  Implementing "filename" charset for
  table name to file name encoding.
row0mysql.c:
  Fixing table name prefix.
mf_format.c:
  Adding MY_APPEND_EXT processing.
Many files:
  Fixing tests.
my_sys.h:
  Adding new flag to append rather than replace an extension.
m_ctype.h:
  Adding "filename" charset definition.


include/m_ctype.h:
  Adding "filename" charset definition.
include/my_sys.h:
  Adding new flag to append rather than replace an extension.
mysql-test/t/alter_table.test:
  Fixing tests.
mysql-test/t/create.test:
  Fixing tests.
mysql-test/t/show_check.test:
  Fixing tests.
mysql-test/r/alter_table.result:
  Fixing tests.
mysql-test/r/create.result:
  Fixing tests.
mysql-test/r/mysqldump.result:
  Fixing tests.
mysys/mf_format.c:
  Adding MY_APPEND_EXT processing.
sql/discover.cc:
  table name to file name encoding
sql/ha_berkeley.cc:
  table name to file name encoding
sql/ha_innodb.cc:
  table name to file name encoding
sql/ha_myisam.cc:
  table name to file name encoding
sql/ha_myisammrg.cc:
  table name to file name encoding
sql/ha_ndbcluster.cc:
  table name to file name encoding
sql/ha_partition.cc:
  table name to file name encoding
sql/handler.cc:
  table name to file name encoding.
sql/init.cc:
  table name to file name encoding
sql/mysqld.cc:
  table name to file name encoding
sql/parse_file.cc:
  table name to file name encoding
sql/sql_acl.cc:
  table name to file name encoding
sql/sql_base.cc:
  table name to file name encoding
sql/sql_db.cc:
  table name to file name encoding
sql/sql_delete.cc:
  table name to file name encoding
sql/sql_rename.cc:
  table name to file name encoding
sql/sql_show.cc:
  table name to file name encoding
sql/sql_table.cc:
  table name to file name encoding
sql/sql_trigger.cc:
  table name to file name encoding
sql/sql_view.cc:
  table name to file name encoding
sql/strfunc.cc:
  table name to file name encoding
sql/table.cc:
  table name to file name encoding
sql/unireg.cc:
  table name to file name encoding
storage/innobase/row/row0mysql.c:
  Fixing table name prefix.
  ,
storage/myisam/mi_create.c:
  table name to file name encoding
storage/myisam/mi_delete_table.c:
  table name to file name encoding
storage/myisam/mi_open.c:
  table name to file name encoding
storage/myisam/mi_rename.c:
  table name to file name encoding
strings/ctype-utf8.c:
  Implementing "filename" charset for
  table name to file name encoding.
sql/mysql_priv.h:
  Prototypes for new table name encoding tools.
storage/myisammrg/myrg_create.c:
  table name to file name encoding
storage/myisammrg/myrg_open.c:
  table name to file name encoding
2005-12-31 09:01:26 +04:00
bar@mysql.com
6ff211329f WL#1324 table name to file name encoding
- Encoding itself, implemented as a charset
  "filename". Originally planned to use '.'
  as an escape character, but now changed to '@'
  for two reasons: "ls" does not return
  file names starting with '.' considering them
  as a kind of hidden files; some platforms
  do not allow several dots in a file name.
- replacing many calls of my_snprintf() and
  strnxmov() to the new build_table_filename().
- Adding MY_APPEND_EXT mysys flag, to append
  an extention rather that replace it.
- Replacing all numeric constants in fn_format
  flag arguments to their mysys definitions, e.g.
  MY_UNPACK_FILENAME,
- Predictability in several function/methods:
  when a table name can appear with or withot .frm
  extension. Some functions/methods were changed
  so accept names strictly with .frm, other - strictly
  without .frm extensions. Several DBUG_ASSERTs were
  added to check whether an extension is passed.
Many files:
  table name to file name encoding
mysql_priv.h:
  Prototypes for new table name encoding tools.
ctype-utf8.c:
  Implementing "filename" charset for
  table name to file name encoding.
row0mysql.c:
  Fixing table name prefix.
mf_format.c:
  Adding MY_APPEND_EXT processing.
Many files:
  Fixing tests.
my_sys.h:
  Adding new flag to append rather than replace an extension.
m_ctype.h:
  Adding "filename" charset definition.
2005-12-31 09:01:26 +04:00
unknown
0040aff931 BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Extended the unique table check by a check of lock data.
Merge sub-tables cannot be detected by doing name checks only.


mysql-test/r/create.result:
  BUG#5390 - problems with merge tables
  Removed a duplicate test.
mysql-test/r/merge.result:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT
  Added test results.
mysql-test/t/create.test:
  BUG#5390 - problems with merge tables
  Removed a duplicate test.
mysql-test/t/merge.test:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT
  Added tests.
sql/lock.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.1.
  Added a new function to find a duplicate lock in a list of tables.
sql/mysql_priv.h:
  Problem #1: INSERT...SELECT, Version for 5.1.
  Added the thread handle to unique_table().
  Added a declaration for the new function.
sql/sql_base.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.1.
  Added the thread handle to unique_table().
  Added a call to the new mysql_lock_have_duplicate(),
  which needs the thread handle, to unique_table().
sql/sql_delete.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.1.
  Added the thread handle to unique_table().
sql/sql_insert.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.1.
  Added the thread handle to unique_table().
sql/sql_load.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.1.
  Added the thread handle to unique_table().
sql/sql_parse.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.1.
  Added the thread handle to unique_table().
sql/sql_update.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.1.
  Added the thread handle to unique_table().
  Replaced a call to find_table_in_local_list() by
  the newly extended unique_table().
2005-12-22 13:48:00 +01:00
ingo@mysql.com
a04c5adb0b BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.1.
Extended the unique table check by a check of lock data.
Merge sub-tables cannot be detected by doing name checks only.
2005-12-22 13:48:00 +01:00
unknown
5113bdffd0 BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Extended the unique table check by a check of lock data.
Merge sub-tables cannot be detected by doing name checks only.


mysql-test/r/create.result:
  BUG#5390 - problems with merge tables
  Removed a duplicate test.
mysql-test/r/merge.result:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT
  Added test results.
mysql-test/t/create.test:
  BUG#5390 - problems with merge tables
  Removed a duplicate test.
mysql-test/t/merge.test:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT
  Added tests.
sql/lock.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.0.
  Added a new function to find a duplicate lock in a list of tables.
sql/mysql_priv.h:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.0.
  Added the thread handle to unique_table().
  Added a declaration for the new function.
sql/sql_base.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.0.
  Added the thread handle to unique_table().
  Added a call to the new mysql_lock_have_duplicate(),
  which needs the thread handle, to unique_table().
sql/sql_delete.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.0.
  Added the thread handle to unique_table().
sql/sql_insert.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.0.
  Added the thread handle to unique_table().
sql/sql_load.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.0.
  Added the thread handle to unique_table().
sql/sql_parse.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.0.
  Added the thread handle to unique_table().
sql/sql_update.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 5.0.
  Added the thread handle to unique_table().
  Replaced a call to find_table_in_local_list() by
  the newly extended unique_table().
2005-12-20 16:35:05 +01:00
ingo@mysql.com
b0e84cb999 BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Extended the unique table check by a check of lock data.
Merge sub-tables cannot be detected by doing name checks only.
2005-12-20 16:35:05 +01:00
unknown
f6cac54bf6 BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 4.1.
INSERT ... SELECT with the same table on both sides (hidden
below a MERGE table) does now work by buffering the select result.
The duplicate detection works now after open_and_lock_tables() 
on the locks.
I did not find a test case that failed without the change in
sql_update.cc. I made the change anyway as it should in theory
fix a possible MERGE table problem with multi-table update.


libmysqld/ha_blackhole.cc:
  BUG#5390 - problems with merge tables
  No idea, how the symlink change made it into my patch.
mysql-test/r/create.result:
  BUG#5390 - problems with merge tables
  Removed a duplicate test.
mysql-test/r/merge.result:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 4.1.
  Added test results.
mysql-test/t/create.test:
  BUG#5390 - problems with merge tables
  Removed a duplicate test.
mysql-test/t/merge.test:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 4.1.
  Added tests.
sql/lock.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 4.1.
  Added a new function to find a duplicate lock in a list of tables.
sql/mysql_priv.h:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 4.1.
  Added a declaration for the new function.
sql/sql_parse.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 4.1.
  Changed the duplicate tables detection for INSERT ... SELECT
  to use the new function, which does also work for MERGE tables.
sql/sql_update.cc:
  BUG#5390 - problems with merge tables
  Problem #1: INSERT...SELECT, Version for 4.1.
  Changed the duplicate tables detection for UPDATE
  to use the new function, which does also work for MERGE tables.
2005-12-07 19:52:26 +01:00
ingo@mysql.com
5aa315e23a BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 4.1.
INSERT ... SELECT with the same table on both sides (hidden
below a MERGE table) does now work by buffering the select result.
The duplicate detection works now after open_and_lock_tables() 
on the locks.
I did not find a test case that failed without the change in
sql_update.cc. I made the change anyway as it should in theory
fix a possible MERGE table problem with multi-table update.
2005-12-07 19:52:26 +01:00
unknown
c86ba5f5e7 Fix for bug#11491 Misleading error message if not NULL column set to NULL,
SQL mode TRADITIONAL
  Message is chenged from 'ER_WARN_NULL_TO_NOTNULL' to 'ER_BAD_NULL_ERROR'


mysql-test/r/auto_increment.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/create.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/insert.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/insert_select.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/key.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/null.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/null_key.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/ps_2myisam.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/ps_3innodb.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/ps_4heap.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/ps_5merge.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/ps_6bdb.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/ps_7ndb.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/strict.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/view.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/r/warnings.result:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    result change
mysql-test/t/strict.test:
  Fix for bug#11491 Misleading error message if not NULL column set to NULL,
                    SQL mode TRADITIONAL
    test change
2005-12-01 15:30:11 +04:00
gluh@eagle.intranet.mysql.r18.ru
21cc3ae561 Fix for bug#11491 Misleading error message if not NULL column set to NULL,
SQL mode TRADITIONAL
  Message is chenged from 'ER_WARN_NULL_TO_NOTNULL' to 'ER_BAD_NULL_ERROR'
2005-12-01 15:30:11 +04:00
unknown
6c41013ea3 Merge mysql.com:/home/jimw/my/mysql-4.1-14155
into  mysql.com:/home/jimw/my/mysql-5.0-clean


mysql-test/t/create.test:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/create.result:
  Resolve conflict
2005-11-28 10:50:23 -08:00
jimw@mysql.com
99297e44d4 Merge mysql.com:/home/jimw/my/mysql-4.1-14155
into  mysql.com:/home/jimw/my/mysql-5.0-clean
2005-11-28 10:50:23 -08:00
unknown
687b57be8d Fix handling of maximum value for MAX_ROWS on 64-bit platforms. (Bug #14155)
mysql-test/r/create.result:
  Add new results
mysql-test/t/create.test:
  Add regression test
sql/table.cc:
  To cap a value at 2^32-1 on a 64-bit platform, use UINT_MAX32, not
  ~(ulong)0, since a ulong may be 64-bit itself.
2005-11-23 17:05:59 -08:00
jimw@mysql.com
81cb8ad37d Fix handling of maximum value for MAX_ROWS on 64-bit platforms. (Bug #14155) 2005-11-23 17:05:59 -08:00
unknown
18b488d7f9 BUG#14480 post-fix: merge to 5.0 2005-11-09 14:47:58 +03:00
sergefp@mysql.com
c914a03066 BUG#14480 post-fix: merge to 5.0 2005-11-09 14:47:58 +03:00
unknown
168c66736a Merge mysql.com:/home/psergey/mysql-4.1-nov08-push
into mysql.com:/home/psergey/mysql-5.0-oct08-push


mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2005-11-09 10:12:58 +03:00
sergefp@mysql.com
c6a902f20c Merge mysql.com:/home/psergey/mysql-4.1-nov08-push
into mysql.com:/home/psergey/mysql-5.0-oct08-push
2005-11-09 10:12:58 +03:00
unknown
f76ff56512 BUG#14480: post-fix: use the default field value from CREATE list too. 2005-11-09 09:34:46 +03:00
sergefp@mysql.com
f12212f74e BUG#14480: post-fix: use the default field value from CREATE list too. 2005-11-09 09:34:46 +03:00
unknown
eeb99f505d Merge, will need post-merge fixes.
mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2005-11-08 11:22:51 +03:00
sergefp@mysql.com
c5276ebcb0 Merge, will need post-merge fixes. 2005-11-08 11:22:51 +03:00
unknown
467deb4cb7 BUG#14480, attempt2: In CREATE ... SELECT ..., don't count the same field twice
when calculating table->null_fields.


mysql-test/r/create.result:
  Testcase for BUG#14480
mysql-test/t/create.test:
  Testcase for BUG#14480
sql/sql_table.cc:
  BUG#14480: For CREATE ... SELECT ... a field list passed to mysql_prepare_table() contains
  instances of create_field for both create-list and select-list. mysql_prepare_table() 
  matches elements that refer to the same field, and joins them together. When the "join"  
  is performed, both of create_field structures has already been counted in "null_fields". 
  
  This fix makes sure that "null_fields" contains the correct value after two create_field 
  structures have been joined.
2005-11-07 09:23:43 +03:00
sergefp@mysql.com
edd094b194 BUG#14480, attempt2: In CREATE ... SELECT ..., don't count the same field twice
when calculating table->null_fields.
2005-11-07 09:23:43 +03:00
unknown
fdd6daf4b5 BUG#14139 - Merge to 5.0 2005-10-31 09:22:33 +03:00
sergefp@mysql.com
4ad3313cd7 BUG#14139 - Merge to 5.0 2005-10-31 09:22:33 +03:00
unknown
2f6bb04f9e 4.1->5.0 merge
include/config-netware.h:
  Merged
innobase/row/row0ins.c:
  BUG#10511: Per alexi's instructions, the changes in innobase/row/row0ins.c are not 
  propagated to 5.x
mysql-test/r/create.result:
  Auto Merged
mysql-test/t/create.test:
  Auto Merged
sql/field.cc:
  Auto Merged
sql/field.h:
  Manual Merge
sql/sql_table.cc:
  Auto Merged
2005-10-29 02:36:57 +04:00
sergefp@mysql.com
09a4d0c7a7 4.1->5.0 merge 2005-10-29 02:36:57 +04:00
unknown
115bf43602 BUG#14139: When handling "CREATE TABLE(field_X type_spec,...) SELECT smth AS field_X, ...."
avoid multiplying length of field_X by charset->mbmaxlen twice when calculating space 
required for field_X in the new table.


mysql-test/r/create.result:
  Testcase for BUG#14139
mysql-test/t/create.test:
  Testcase for BUG#14139
sql/field.cc:
  BUG#14139: Make create_length_to_internal_length() save length-in-characters in 
  create_field::chars_length.
sql/field.h:
  BUG#14139: Add create_length::chars_length where we save length-in-characters, added comments.
sql/sql_table.cc:
  BUG#14139: When handling "CREATE TABLE(field_X type_spec,...) SELECT smth AS field_X, ...."
  we get two instances of create_field: (1) is occurence of field_X in create list, and (2) is
  in select list. If we figure they both refer to the same field, we "join" them according to
  some rule that is not explicitly specified anywhere.
  When we do this "join", create_field::length already contains length-in-bytes for both, so
  when we transfer field length (in characters) from (1) to (2), use length-in-characters that
  we have saved in create_length::chars_length.
2005-10-26 00:56:17 +04:00
sergefp@mysql.com
2219ada7f6 BUG#14139: When handling "CREATE TABLE(field_X type_spec,...) SELECT smth AS field_X, ...."
avoid multiplying length of field_X by charset->mbmaxlen twice when calculating space 
required for field_X in the new table.
2005-10-26 00:56:17 +04:00
unknown
f147d73c87 Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-4.1
into lmy004.:/work/mysql-4.1-bug12913


mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2005-09-20 06:55:23 +03:00
andrey@lmy004.
72549b13c2 Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-4.1
into lmy004.:/work/mysql-4.1-bug12913
2005-09-20 06:55:23 +03:00
unknown
4d29b85d14 Merged from 4.1 to 5.0. 2005-09-13 01:44:50 +03:00
jani@a193-229-222-105.elisa-laajakaista.fi
e760a58f07 Merged from 4.1 to 5.0. 2005-09-13 01:44:50 +03:00
unknown
8c3423652d Merge a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-4.1
into  a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.0


mysql-test/r/temp_table.result:
  Auto merged
mysql-test/r/warnings.result:
  Auto merged
sql/sql_db.cc:
  Auto merged
client/mysqltest.c:
  Auto merged
mysql-test/t/innodb.test:
  Auto merged
sql/filesort.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/r/create.result:
  Merged from 4.1 to 5.0
mysql-test/r/innodb.result:
  Merged from 4.1 to 5.0
mysql-test/t/create.test:
  Merged from 4.1 to 5.0
sql/item_cmpfunc.cc:
  Merged from 4.1 to 5.0
sql/sql_table.cc:
  Merged from 4.1 to 5.0
2005-09-12 20:18:49 +03:00
jani@a193-229-222-105.elisa-laajakaista.fi
01ce8a8aa9 Merge a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-4.1
into  a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.0
2005-09-12 20:18:49 +03:00
unknown
63080dc200 Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
produce warning for 'create database if not exists' if database exists
  do not update database options in this case  
  produce warning for 'create table if not exists' if table exists



mysql-test/r/create.result:
  Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
    updated test case result
mysql-test/r/temp_table.result:
  Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
    updated test case result
mysql-test/r/warnings.result:
  Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
    updated test case result
mysql-test/t/create.test:
  Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
    test case
sql/sql_db.cc:
  Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
    produce warning for 'create database if not exists' if database exists
    do not update database options in this case
sql/sql_table.cc:
  Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
    produce warning for 'create table if not exists' if table exists
2005-09-12 17:09:19 +05:00
gluh@eagle.intranet.mysql.r18.ru
d9bd3c11e4 Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
produce warning for 'create database if not exists' if database exists
  do not update database options in this case  
  produce warning for 'create table if not exists' if table exists
2005-09-12 17:09:19 +05:00
unknown
11bd1f871a fix for bug#12913
(Simple SQL can crash server or connection)
(not initialized member leads to server crash)


mysql-test/r/create.result:
  result of test for bug #12913
mysql-test/t/create.test:
  test for bug#12913
  (Simple SQL can crash server or connection)
sql/sql_table.cc:
  copy the interval pointer too or a bit later
  dereferencing of this pointer being 0x0 will crash the server
  (see bug #12913)
2005-09-01 00:13:02 +02:00
andrey@lmy004.
f75ac7fb82 fix for bug#12913
(Simple SQL can crash server or connection)
(not initialized member leads to server crash)
2005-09-01 00:13:02 +02:00
unknown
c6b54efea2 create.test, create.result, sql_select.cc, item.cc:
After merge fix for bug #12537


sql/item.cc:
  After merge fix for bug #12537
sql/sql_select.cc:
  After merge fix for bug #12537
mysql-test/r/create.result:
  After merge fix for bug #12537
mysql-test/t/create.test:
  After merge fix for bug #12537
2005-08-31 22:06:34 +04:00
evgen@moonbone.local
41fc00641c create.test, create.result, sql_select.cc, item.cc:
After merge fix for bug #12537
2005-08-31 22:06:34 +04:00
unknown
a1f59825be Manual merged
mysql-test/r/create.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
2005-08-31 21:24:25 +04:00
evgen@moonbone.local
f917803e0c Manual merged 2005-08-31 21:24:25 +04:00
unknown
033faf7256 Fix bug #12537 UNION produces longtext instead of varchar
Item::tmp_table_field_from_field_type() and create_tmp_field_from_item()
was converting string field to blob depending on byte-wise length instead of
character length, which results in converting valid varchar string with
length == 86 to longtext.

Made that functions above take into account max width of character when
converting string fields to blobs.


sql/item.cc:
  Fix bug #12537 UNION produces longtext instead of varchar
  Item::tmp_table_field_from_field_type() now taking into account max char width when creating tmp field for string fields.
sql/sql_select.cc:
  Fix bug #12537 UNION produces longtext instead of varchar
   create_tmp_field_from_item()now taking into account max char width when creating tmp field for string fields.
mysql-test/r/create.result:
  Test case for bug #12537 UNION produces longtext instead of varchar
mysql-test/t/create.test:
  Test case for bug #12537 UNION produces longtext instead of varchar
2005-08-30 16:19:53 +04:00
evgen@moonbone.local
d76f9471cb Fix bug #12537 UNION produces longtext instead of varchar
Item::tmp_table_field_from_field_type() and create_tmp_field_from_item()
was converting string field to blob depending on byte-wise length instead of
character length, which results in converting valid varchar string with
length == 86 to longtext.

Made that functions above take into account max width of character when
converting string fields to blobs.
2005-08-30 16:19:53 +04:00
unknown
01f1a3ac12 Update test results
mysql-test/r/create.result:
  Update error message text
mysql-test/r/query_cache.result:
  Update warnings
2005-08-04 14:38:48 -07:00
jimw@mysql.com
2da798c991 Update test results 2005-08-04 14:38:48 -07:00
unknown
7c17339561 Fix for bug #6859 (after Sanja's review)
Added check which throws ER_WRONG_OBJECT error in case the .frm
doesn't contain a valid table type (e.g. view or trigger)


mysql-test/r/create.result:
  Added test case for bug #6859
mysql-test/t/create.test:
  Add testcase for bug #6850
2005-08-03 07:29:48 +02:00
georg@lmy002.wdf.sap.corp
7251e9dbd8 Fix for bug #6859 (after Sanja's review)
Added check which throws ER_WRONG_OBJECT error in case the .frm
doesn't contain a valid table type (e.g. view or trigger)
2005-08-03 07:29:48 +02:00
unknown
6fd718dfbb Merge mysql.com:/home/jimw/my/mysql-4.1-clean
into  mysql.com:/home/jimw/my/mysql-5.0-clean


mysql-test/r/create.result:
  Auto merged
mysql-test/r/func_str.result:
  Auto merged
mysql-test/t/func_str.test:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
mysql-test/t/create.test:
  Resolve conflict
sql/mysql_priv.h:
  Resolve conflict
sql/table.cc:
  Resolve conflict
sql/unireg.cc:
  Resolve conflict
2005-07-22 12:35:15 -07:00
jimw@mysql.com
49e5636410 Merge mysql.com:/home/jimw/my/mysql-4.1-clean
into  mysql.com:/home/jimw/my/mysql-5.0-clean
2005-07-22 12:35:15 -07:00
unknown
4198410528 Fix error message generated when trying to create a table in a
non-existent database. (Bug #10407)


mysql-test/r/create.result:
  Update results
mysql-test/t/create.test:
  Update error numbers
sql/mysql_priv.h:
  Adjust some other function signature so table and db information
  is passed down into create_frm().
sql/sql_table.cc:
  Check for database not existing after hitting an error when
  copying the .frm file for 'CREATE TABLE ... LIKE ...', and
  pass table and db name into rea_create_table().
sql/table.cc:
  Generate specific error message when .frm creation fails because
  the database does not exist.
sql/unireg.cc:
  Pass database and table name down into create_frm().
2005-07-21 20:08:54 -07:00
jimw@mysql.com
6eae678f56 Fix error message generated when trying to create a table in a
non-existent database. (Bug #10407)
2005-07-21 20:08:54 -07:00
unknown
fec1c6ac67 Merge
BitKeeper/etc/logging_ok:
  auto-union
myisam/mi_check.c:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/innodb_handler.result:
  Auto merged
mysql-test/r/ps_7ndb.result:
  Auto merged
mysql-test/t/create.test:
  Auto merged
sql/set_var.cc:
  Auto merged
mysql-test/r/sql_mode.result:
  SCCS merged
mysql-test/t/sql_mode.test:
  SCCS merged
sql/sql_acl.cc:
  SCCS merged
sql/sql_handler.cc:
  SCCS merged
sql/sql_table.cc:
  SCCS merged
2005-06-09 17:15:06 +01:00
acurtis@xiphis.org
3b8c3bd7e1 Merge 2005-06-09 17:15:06 +01:00
unknown
c995109b69 Bug#11028 Crash on create table like
Report error instead of crashing


mysql-test/r/create.result:
  Test for bug 11028
mysql-test/t/create.test:
  Test for bug 11028
sql/sql_table.cc:
  fix for null db name
2005-06-09 16:06:15 +01:00
acurtis@xiphis.org
304bb0c66d Bug#11028 Crash on create table like
Report error instead of crashing
2005-06-09 16:06:15 +01:00