Commit graph

122 commits

Author SHA1 Message Date
Georgi Kodinov
a21a0b47ca Bug #31145: ALTER TABLE DROP COLUMN, ADD COLUMN crashes (linux) or
freezes (win) the server

The check for equality was assuming the field object is always 
created. If it's not it was de-referencing a NULL pointer.
Fixed to use the data in the create object instead.
2009-12-18 14:00:30 +02:00
Tatiana A. Nurnberg
2fc28dd688 manual merge of Bug#43508 2009-10-09 23:57:43 +02:00
Tatiana A. Nurnberg
798ce98340 Bug#43508: Renaming timestamp or date column triggers table copy
We set up DATE and TIMESTAMP differently in field-creation than we
did in field-MD creation (for CREATE). Admirably, ALTER TABLE
detected this and didn't damage any data, but it did initiate a
full copy/conversion, which we don't really need to do.

Now we describe Field and Create_field the same for those types.
As a result, ALTER TABLE that only changes meta-data (like a
field's name) no longer forces a data-copy when there needn't
be one.


mysql-test/r/alter_table.result:
  0 rows should be affected when a meta-data change is enough ALTER TABLE.
mysql-test/t/alter_table.test:
  add test-case: show that we don't do a full data-copy on ALTER TABLE
  when we don't need to.
sql/field.cc:
  Remove Field_str::compare_str_field_flags() (now in Field/Create_field as
  field_flags_are_binary().
  
  Correct some field-lengths!
sql/field.h:
  Clean-up: use defined constants rather than numeric literals for certain
  field-lengths.
  
  Add enquiry-functions binaryp() to classes Field and Create_field.
  This replaces field.cc's Field_str::compare_str_field_flags().
2009-10-09 14:41:04 +02:00
Davi Arnaut
8d3d35ea57 Bug#45567: Fast ALTER TABLE broken for enum and set
The problem was that appending values to the end of an existing
ENUM or SET column was being treated as table data modification,
preventing a immediately (fast) table alteration that occurs when
only table metadata is being modified.

The cause was twofold: adding a enumeration or set members to the 
end of the list of valid member values was not being considered
a "compatible" table alteration, and for SET columns, the check
was being done upon the max display length and not the underlying
(pack) length of the field.

The solution is to augment the function that checks wether two ENUM
or SET fields are compatible -- by comparing the pack lengths and
performing a limited comparison of the member values.

mysql-test/r/alter_table.result:
  Add test case result for Bug#45567
mysql-test/t/alter_table.test:
  Add test case for Bug#45567
sql/field.cc:
  Check whether two fields can be considered 'equal' for table
  alteration purposes. Fields are equal if they retain the same
  pack length and if new members are added to the end of the list.
sql/field.h:
  Add comment and remove method.
2009-09-29 07:58:42 -03:00
Sergey Glukhov
87f395d1d9 5.0-bugteam->5.1-bugteam merge 2008-12-09 17:31:22 +04:00
Sergey Glukhov
419e053a41 Bug#31291 ALTER TABLE CONVERT TO CHARACTER SET does not change some data types
added ability for TINY[MEDIUM] text fields 
to be converted to greater subtype during
alter if necessary(altered charset)


mysql-test/r/alter_table.result:
  test result
mysql-test/t/alter_table.test:
  test case
sql/sql_table.cc:
  added ability for TINY[MEDIUM] text fields 
  to be converted to greater subtype during
  alter if necessary(altered charset)
2008-12-09 16:38:52 +04:00
Davi Arnaut
d4438c99ff Merge from mysql-5.1-5.1.29-rc into mysql-5.1-bugteam 2008-10-24 11:58:48 -02:00
Ramil Kalimullin
256f41edfe Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1
Problem: mysqld doesn't detect that enum data must be reinserted performing
'ALTER TABLE' in some cases.

Fix: reinsert data altering an enum field if enum values are changed.


mysql-test/r/alter_table.result:
  Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1
    - test result.
mysql-test/t/alter_table.test:
  Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1
    - test case.
sql/field.cc:
  Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1
    - Field_enum::is_equal() introduced, which is called to detect that a field
  is changing by 'ALTER TABLE'.
sql/field.h:
  Fix for bug#23113: Different behavior on altering ENUM fields between 5.0 and 5.1
    - Field_enum::is_equal() introduced, which is called to detect that a field
  is changing by 'ALTER TABLE'.
2008-10-24 13:00:03 +05:00
Sergey Glukhov
1e4f12d65d Bug#39372 "Smart" ALTER TABLE not so smart after all.
The problem was that PACK_KEYS and MAX_ROWS clause in ALTER TABLE did not trigger
table reconstruction.
The fix is to rebuild a table if PACK_KEYS or MAX_ROWS are specified.


mysql-test/r/alter_table.result:
  test result
mysql-test/t/alter_table.test:
  test case
sql/sql_table.cc:
  The problem was that PACK_KEYS and MAX_ROWS clause in ALTER TABLE did not trigger
  table reconstruction.
  The fix is to rebuild a table if PACK_KEYS or MAX_ROWS are specified.
2008-10-09 15:49:13 +05:00
Davi Arnaut
5d237db6f6 Bug#33873: Fast ALTER TABLE doesn't work with multibyte character sets
The problem was that when comparing tables for a possible
fast alter table, the comparison was being performed using
the parsed information and not the final definition.
      
The solution is to use the possible final table layout to
compare if a fast alter is possible or not.

mysql-test/include/mix1.inc:
  Disable test case for Bug 21704 as it hasn't been fixed.
mysql-test/r/alter_table.result:
  Add test case result for Bug#33873
mysql-test/r/innodb_mysql.result:
  Update test case result
mysql-test/t/alter_table.test:
  Add test case for Bug#33873
sql/sql_table.cc:
  Use updated (final) information to compare fields.
2008-06-17 11:12:21 -03:00
unknown
f97155c9f6 Merge mysql.com:/home/svoj/devel/mysql/BUG29957/mysql-5.0-engines
into  mysql.com:/home/svoj/devel/mysql/BUG29957/mysql-5.1-engines


storage/myisam/mi_extra.c:
  Auto merged
mysql-test/r/alter_table.result:
  Manual merge
mysql-test/t/alter_table.test:
  Manual merge
2007-07-27 14:44:31 +05:00
unknown
e92ce5d56c BUG#29957 - alter_table.test fails
INSERT/DELETE/UPDATE followed by ALTER TABLE within LOCK TABLES
may cause table corruption on Windows.

That happens because ALTER TABLE writes outdated shared state
info into index file.

Fixed by removing obsolete workaround.

Affects MyISAM tables on Windows only.


myisam/mi_extra.c:
  On windows when mi_extra(HA_EXTRA_PREPARE_FOR_DELETE) is called,
  we release external lock and close index file. If we're in LOCK
  TABLES, MyISAM state info doesn't get updated until UNLOCK TABLES.
  
  That means when we release external lock and we're in LOCK TABLES,
  we may write outdated state info.
  
  As SQL layer closes all table instances, we do not need this
  workaround anymore.
mysql-test/r/alter_table.result:
  A test case for BUG#29957.
mysql-test/t/alter_table.test:
  A test case for BUG#29957.
2007-07-27 14:30:25 +05:00
unknown
f4caa3025a Merge olga.mysql.com:/home/igor/mysql-5.1
into  olga.mysql.com:/home/igor/mysql-5.1-opt-merge


mysql-test/r/alter_table.result:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/user_var.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/strict.test:
  Auto merged
mysql-test/t/subselect3.test:
  Auto merged
sql/field.h:
  Auto merged
sql/handler.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
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_7ndb.result:
  Manual merge.
sql/sql_table.cc:
  Manual merge.
sql/sql_view.cc:
  Manual merge.
2007-06-03 22:52:02 -07:00
unknown
cfd1e67ae4 Bug#28427: Columns were renamed instead of moving by ALTER TABLE.
To avoid unnecessary work the mysql_alter_table function takes the
list of table fields and applies all changes to it (drops/moves/renames/etc).
Then this function compares the new list and the old one. If the changes
require only .frm to be modified then the actual data isn't copied. To detect
changes all columns attributes but names are compared. When a column has been
moved and has replaced another column with the same attributes except name
the mysql_alter_table function wrongly decides that two fields has been just
renamed. As a result the data from the moved column and from all columns
after it is not copied.

Now the mysql_alter_table function forces table data copying by setting
the need_copy_table flag when it finds a moved column. The flag is set at
the stage when the modified fields are created.



sql/sql_table.cc:
  Bug#28427: Columns were renamed instead of moving by ALTER TABLE.
  Now the mysql_alter_table function forces table data copying by setting
  the need_copy_table flag when it finds a moved column. The flag is set at
  the stage when the modified fields are created.
mysql-test/r/alter_table.result:
  Added a test case for the bug#28427: Columns were renamed instead of moving by ALTER TABLE.
mysql-test/t/alter_table.test:
  Added a test case for the bug#28427: Columns were renamed instead of moving by ALTER TABLE.
2007-06-02 01:21:18 +04:00
unknown
18580a3200 Merge moonbone.local:/mnt/gentoo64/work/bk-trees/mysql-5.0-opt
into  moonbone.local:/mnt/gentoo64/work/test-5.1-opt-mysql


mysql-test/r/func_gconcat.result:
  Auto merged
mysql-test/t/func_gconcat.test:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/table.h:
  Auto merged
mysql-test/r/alter_table.result:
  Manual merge
mysql-test/t/alter_table.test:
  Manual merge
sql/sql_table.cc:
  Manual merge
2007-05-23 13:46:10 +04:00
unknown
f3b78f34e5 Bug#27507: Wrong DATETIME value was allowed by ALTER TABLE in the NO_ZERO_DATE
mode.

When a new DATE/DATETIME field without default value is being added by the
ALTER TABLE the '0000-00-00' value is used as the default one. But it wasn't
checked whether such value was allowed by the set sql mode. Due to this
'0000-00-00' values was allowed for DATE/DATETIME fields even in the
NO_ZERO_DATE mode.

Now the mysql_alter_table() function checks whether the '0000-00-00' value
is allowed for DATE/DATETIME fields by the set sql mode.
The new error_if_not_empty flag is used in the mysql_alter_table() function
to indicate that it should abort if the table being altered isn't empty.
The new new_datetime_field field is used in the mysql_alter_table() function
for error throwing purposes. 
The new error_if_not_empty parameter is added to the copy_data_between_tables()
function to indicate the it should return error if the source table isn't empty.


mysql-test/t/alter_table.test:
  Added a test case for the bug#27507: Wrong DATETIME value was allowed by
  ALTER TABLE in the NO_ZERO_DATE mode.
mysql-test/r/alter_table.result:
  Added a test case for the bug#27507: Wrong DATETIME value was allowed by
  ALTER TABLE in the NO_ZERO_DATE mode.
sql/sql_table.cc:
  Bug#27507: Wrong DATETIME value was allowed by ALTER TABLE in the NO_ZERO_DATE
  mode.
  Now the mysql_alter_table() function checks whether the '0000-00-00' value
  is allowed for DATE/DATETIME fields by the set sql mode.
  The new error_if_not_empty flag is used in the mysql_alter_table() function
  to indicate that it should abort if the table being altered isn't empty.
  The new new_datetime_field field is used in the mysql_alter_table() function
  for error throwing purposes. 
  The new error_if_not_empty parameter is added to the copy_data_between_tables()
  function to indicate the it should return error if the source table isn't empty.
2007-05-22 00:22:53 +04:00
unknown
1a60685cba Patch changing how ALTER TABLE implementation handles table locking
and invalidation in the most general case (non-temporary table and
not simple RENAME or ENABLE/DISABLE KEYS or partitioning command).

See comment for sql/sql_table.cc for more information.

These changes are prerequisite for 5.1 version of fix for bug #23667
"CREATE TABLE LIKE is not isolated from alteration by other connections"


mysql-test/include/mix1.inc:
  Extended coverage for behavior of ALTER TABLE statement under LOCK TABLES,
  which should be consistent across all platforms and for all engines.
mysql-test/r/alter_table-big.result:
  Changed test for bug #25044 to use @@debug and injected sleeps
  infrastructure. Extended test coverage for ALTER TABLE's behavior
  under concurrency.
mysql-test/r/alter_table.result:
  Extended coverage for behavior of ALTER TABLE statement under LOCK TABLES,
  which should be consistent across all platforms and for all engines.
mysql-test/r/innodb_mysql.result:
  Extended coverage for behavior of ALTER TABLE statement under LOCK TABLES,
  which should be consistent across all platforms and for all engines.
mysql-test/t/alter_table-big.test:
  Changed test for bug #25044 to use @@debug and injected sleeps
  infrastructure. Extended test coverage for ALTER TABLE's behavior
  under concurrency.
mysql-test/t/alter_table.test:
  Extended coverage for behavior of ALTER TABLE statement under LOCK TABLES,
  which should be consistent across all platforms and for all engines.
sql/mysql_priv.h:
  Made functions reopen_table() and close_handle_and_leave_table_as_lock()
  available outside of sql_base.cc file.
  Changed close_data_tables() in such way that after closing handler
  for the table it leaves TABLE object for it in table cache not as
  placeholder for ordinary name-lock but as placeholder for an exclusive
  name-lock. Renamed this routine to close_data_files_and_morph_locks().
sql/sql_base.cc:
  Made functions reopen_table() and close_handle_and_leave_table_as_lock()
  available outside of sql_base.cc file.
  Changed close_data_tables() in such way that after closing handler
  for the table it leaves TABLE object for it in table cache not as
  placeholder for ordinary name-lock but as placeholder for an exclusive
  name-lock. Renamed this routine to close_data_files_and_morph_locks().
  Also adjusted it so it can work properly not only in LOCK TABLES mode.
sql/sql_table.cc:
  Changed the way in which ALTER TABLE implementation handles table
  locking and invalidation in the most general case (non-temporary table
  and not simple RENAME or ENABLE/DISABLE KEYS or partitioning command)
  
  Now after preparing new version of the table we:
  1) Wait until all other threads close old version of table.
  2) Close instances of table open by this thread and replace them
     with exclusive name-locks.
  3) Rename the old table to a temp name, rename the new one to the
     old name.
  4) If we are under LOCK TABLES and don't do ALTER TABLE ... RENAME
     we reopen new version of table.
  5) Write statement to the binary log.
  6) If we are under LOCK TABLES and do ALTER TABLE ... RENAME we
     remove name-locks from list of open tables and table cache.
  7) If we are not not under LOCK TABLES we rely on close_thread_tables()
     call to remove name-locks from table cache and list of open table. 
  
  Such approach:
  a) Eliminates possibility for concurrent statement to sneak in and get
     access to the new version of the table before ALTER TABLE gets logged
     into binary log.
  b) Ensures that ALTER TABLE behaves under LOCK TABLES in the same way
     on all platforms and for all engines (in 5.0 this was not true) 
  c) Preserves nice invariant that if table is open in some connection
     there is a guarantee that .FRM file for this table exists and is
     properly named.
2007-05-19 10:49:56 +04:00
unknown
e65d214d33 Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint


mysql-test/r/alter_table.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2007-04-25 13:09:26 +02:00
unknown
5bb54e514f Merge pilot.blaudden:/home/msvensson/mysql/bug25262/my50-bug25262
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint


sql/sql_table.cc:
  Auto merged
mysql-test/r/alter_table.result:
  Merge tests
mysql-test/t/alter_table.test:
  Merge tests
2007-04-25 12:08:39 +02:00
unknown
329514bb02 Merge pilot.blaudden:/home/msvensson/mysql/bug25262/my51-bug25262
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint


mysql-test/r/alter_table.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2007-04-25 11:13:41 +02:00
unknown
c0016e92d7 Merge pilot.blaudden:/home/msvensson/mysql/bug25262/my50-bug25262
into  pilot.blaudden:/home/msvensson/mysql/bug25262/my51-bug25262


mysql-test/r/alter_table.result:
  Manual merge
mysql-test/t/alter_table.test:
  Manual merge
sql/sql_table.cc:
  Manual merge, auto_increment_value variable has moved into "stats"
2007-03-21 18:38:08 +01:00
unknown
6e10a2048d Bug #26794: 5.1 part
It was syntactically correct to define 
 spatial keys over parts of columns (e.g.
 ALTER TABLE t1 ADD x GEOMETRY NOT NULL, 
   ADD SPATIAL KEY (x(32))).
 This may lead to undefined results and/or
 interpretation.
 Fixed by not allowing partial column 
 specification in a SPATIAL index definition.


mysql-test/r/alter_table.result:
  Bug #26794: 5.1 part
   test case
mysql-test/r/gis-rtree.result:
  Bug #26794: 5.1 part
   updated the tests to the new syntax
mysql-test/t/alter_table.test:
  Bug #26794: 5.1 part
   test case
mysql-test/t/gis-rtree.test:
  Bug #26794: 5.1 part
   updated the tests to the new syntax
sql/sql_table.cc:
  Bug #26794: 5.1 part
   Disable defining SPATIAL KEYS with sub-key parts
2007-03-14 12:20:34 +02:00
unknown
a22f257e04 Bug #26794:
Different set of conditions is used to verify
the validity of index definitions over a GEOMETRY
column in ALTER TABLE and CREATE TABLE. 
The difference was on how sub-keys notion validity
is checked.
Fixed by extending the CREATE TABLE condition to
support the cases allowed in ALTER TABLE.
Made the SHOW CREATE TABLE not to display spatial
indexes using the sub-key notion.


mysql-test/r/alter_table.result:
  Bug #26794: test case
mysql-test/r/gis-rtree.result:
  Bug #26794: fixed SHOW CREATE TABLE output.
mysql-test/t/alter_table.test:
  Bug #26794: test case
sql/field.cc:
  Bug #26794: Allow sub-keys for GEOMETRY
sql/sql_show.cc:
  Bug #26794: Don't show sub-key notion 
   in SHOW CREATE TABLE for SPATIAL indexes.
sql/sql_table.cc:
  Bug #26794: Allow sub-keys for GEOMETRY
2007-03-14 11:54:20 +02:00
unknown
d92106135d Merge magare.gmz:/home/kgeorge/mysql/work/B26794-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/work/B26794-5.1-opt


mysql-test/r/gis-rtree.result:
  Auto merged
sql/field.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
mysql-test/r/alter_table.result:
  tests merge
mysql-test/t/alter_table.test:
  tests merge
2007-03-12 17:08:42 +02:00
unknown
bd6aecf3f3 Bug #26794:
Different set of conditions is used to verify
the validity of index definitions over a GEOMETRY
column in ALTER TABLE and CREATE TABLE. 
The difference was on how sub-keys notion validity
is checked.
Fixed by extending the CREATE TABLE condition to
support the cases allowed in ALTER TABLE.
Made the SHOW CREATE TABLE not to display spatial
indexes using the sub-key notion.


mysql-test/r/alter_table.result:
  Bug #26794: test case
mysql-test/r/gis-rtree.result:
  Bug #26794: fixed SHOW CREATE TABLE output.
mysql-test/t/alter_table.test:
  Bug #26794: test case
sql/field.cc:
  Bug #26794: Allow sub-keys for GEOMETRY
sql/sql_show.cc:
  Bug #26794: Don't show sub-key notion 
   in SHOW CREATE TABLE for SPATIAL indexes.
sql/sql_table.cc:
  Bug #26794: Allow sub-keys for GEOMETRY
2007-03-12 16:57:00 +02:00
unknown
9248b580b9 Bug#25262 Auto Increment lost when changing Engine type
- Try to copy the autoincrement value when altering the table


mysql-test/r/alter_table.result:
  Update test result
mysql-test/t/alter_table.test:
  Add test case as described in bug report
sql/sql_table.cc:
  Try to copy the autoincrement value when altering the table
2007-03-01 13:43:04 +01:00
unknown
f99f791790 Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-24562-merge
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-24562-merge


mysql-test/r/alter_table.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-01-18 18:43:11 -07:00
unknown
6c6a2785e9 Manual merge 2007-01-18 18:37:52 -07:00
unknown
65d0e46d71 Merge weblab.(none):/home/marcsql/TREE/mysql-4.1-24562
into  weblab.(none):/home/marcsql/TREE/mysql-5.0-24562-merge


mysql-test/t/alter_table.test:
  Auto merged
2007-01-18 17:02:02 -07:00
unknown
d4ee8cebf3 Bug#24562 (ALTER TABLE ... ORDER BY ... with complex expression asserts)
WL#3681 (ALTER TABLE ORDER BY)

Before this fix, the ALTER TABLE statement implemented an ORDER BY option
with the following characteristics :

1) The order by clause accepts a list of criteria, with optional ASC or
DESC keywords

2) Each criteria can be a general expression, involving operators,
native functions, stored functions, user defined functions, subselects ...

With this fix :

1) has been left unchanged, since it's a de-facto existing feature,
that was already present in the code base and partially covered in the test
suite. Code coverage for ASC and DESC was missing and has been improved.

2) has been changed to limit the kind of criteria that are permissible:
now only a column name is valid.


mysql-test/r/alter_table.result:
  Prevent ALTER TABLE ORDER BY clauses to use general expressions.
mysql-test/t/alter_table.test:
  Prevent ALTER TABLE ORDER BY clauses to use general expressions.
sql/sql_yacc.yy:
  Prevent ALTER TABLE ORDER BY clauses to use general expressions.
2007-01-18 16:53:49 -07:00
unknown
9e46434910 Merge mysql.com:/home/svoj/devel/mysql/BUG23404/mysql-5.0-engines
into  mysql.com:/home/svoj/devel/mysql/BUG23404/mysql-5.1-engines


mysql-test/r/alter_table.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
sql/sql_parse.cc:
  Auto merged
2006-12-13 17:32:40 +04:00
unknown
b9d2627ca1 Merge mysql.com:/home/svoj/devel/mysql/BUG23404/mysql-4.1-engines
into  mysql.com:/home/svoj/devel/mysql/BUG23404/mysql-5.0-engines


mysql-test/r/alter_table.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
sql/sql_parse.cc:
  SCCS merged
2006-12-13 16:29:33 +04:00
unknown
a4ad07b7ea Merge svojtovich@bk-internal.mysql.com:/home/bk/mysql-4.1-engines
into  mysql.com:/home/svoj/devel/mysql/BUG23404/mysql-4.1-engines


mysql-test/r/alter_table.result:
  SCCS merged
mysql-test/t/alter_table.test:
  SCCS merged
2006-12-13 15:53:37 +04:00
unknown
1cb8e4e9c9 BUG#23404 - ROW_FORMAT=FIXED option is lost is an index is added to the
table

ROW_FORMAT option is lost during CREATE/DROP INDEX.

This fix forces CREATE/DROP INDEX to retain ROW_FORMAT by instructing
mysql_alter_table() that ROW_FORMAT is not used during creating/dropping
indexes.


mysql-test/r/alter_table.result:
  A test case for bug#23404.
mysql-test/t/alter_table.test:
  A test case for bug#23404.
sql/sql_parse.cc:
  CREATE/DROP INDEX must not change ROW_FORMAT. Setting create_info.row_type
  to ROW_TYPE_NOT_USED informs mysql_alter_table that ROW_FORMAT was not
  used during alteration, and thus must be retained.
2006-12-07 18:32:40 +04:00
unknown
c275fce7b4 Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-maint
into  example.com:/work/bug22369-v2/my51


mysql-test/r/alter_table.result:
  Auto merged
mysql-test/r/grant.result:
  Auto merged
mysql-test/t/grant.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
mysql-test/t/alter_table.test:
  manual merge
2006-12-04 18:31:24 +01:00
unknown
ab31e4278d Fix for bug#22369: Alter table rename combined
with other alterations causes lost tables

Using RENAME clause combined with other clauses of ALTER TABLE led to
data loss (the data was there but not accessible). This could happen if the
changes do not change the table much. Adding and droppping of fields and
indices was safe. Renaming a column with MODIFY or CHANGE was unsafe operation,
if the actual column didn't change (changing from int to int, which is a noop)
  
Depending on the storage engine (SE) the behavior is different:
1)MyISAM/MEMORY - the ALTER TABLE statement completes
  without any error but next SELECT against the new table fails.
2)InnoDB (and every other transactional table) - The ALTER TABLE statement
  fails. There are the the following files in the db dir -
  `new_table_name.frm` and a temporary table's frm. If the SE is file
  based, then the data and index files will be present but with the old
  names. What happens is that for InnoDB the table is not renamed in the
  internal DDIC.

Fixed by adding additional call to mysql_rename_table() method, which should
not include FRM file rename, because it has been already done during file
names juggling.


mysql-test/r/alter_table.result:
  update result
mysql-test/r/grant.result:
  update result
mysql-test/t/alter_table.test:
  2006/11/29 11:46:23+01:00 andrey@example.com +44 -9
  Error to bug number
      
  Added test case for #22369: Alter table rename combined
  with other alterations causes lost tables
mysql-test/t/grant.test:
  add test for bug#22369 - alter table was missing check
  for DROP_ACL when ALTER_RENAME clause is specified. Synchronise
  with RENAME TABLE DDL.
sql/mysql_priv.h:
  Add a new flag for mysql_rename_table()
sql/sql_parse.cc:
  To be consistent with SQLCOM_RENAME_TABLE, SQLCOM_ALTER_TABLE has
  to check for DROP_ACL if there is ALTER_RENAME flag set.
sql/sql_table.cc:
  ALTER_RENAME, the data and index files weren't renamed in the engine
  but only the FRM was new, when the tables old and new tables are compatible.
  In the chain of FRM renames we add a call to mysql_rename_table() which should
  instruct the engine to rename the table but not rename the FRM.
  This bug was there only in 5.1 branch. 4.1 and 5.0 always do copy data on RENAME
  if there are more clauses than just rename.
2006-12-04 18:22:38 +01:00
unknown
934aa981ad Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-maint
into  example.com:/work/bug24395-v2/my51


mysql-test/t/alter_table.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
2006-12-01 16:27:48 +01:00
unknown
36a983b89a Merge example.com:/work/bug24395-v2/my50
into  example.com:/work/bug24395-v2/my51


mysql-test/r/alter_table.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
storage/myisam/mi_open.c:
  Auto merged
sql/sql_table.cc:
  manual merge
2006-12-01 11:37:33 +01:00
unknown
c429ca8498 Merge example.com:/work/bug24395-v2/my41
into  example.com:/work/bug24395-v2/my50

fix for bug#24395 merged into 5.0


mysql-test/t/alter_table.test:
  Auto merged
myisam/mi_open.c:
  merge into 5.0 by using macroses available in 5.0
mysql-test/r/alter_table.result:
  manual merge
sql/sql_table.cc:
  manual merge
  Added else clause of 
  if (new_table && !new_table->file->is_view)
  This else clauses does keys management on the live table, thus we have
  to force other threads to reopen the table.
2006-11-30 18:36:15 +01:00
unknown
d988576610 Merge shellback.(none):/home/msvensson/mysql/mysql-5.1
into  shellback.(none):/home/msvensson/mysql/mysql-5.1-maint


BitKeeper/etc/ignore:
  auto-union
Makefile.am:
  Auto merged
client/mysql.cc:
  Auto merged
client/mysql_upgrade.c:
  Auto merged
client/mysqltest.c:
  Auto merged
extra/yassl/src/ssl.cpp:
  Auto merged
mysql-test/lib/mtr_report.pl:
  Auto merged
mysql-test/mysql-test-run-shell.sh:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/query_cache.result:
  Auto merged
mysql-test/r/udf.result:
  Auto merged
mysql-test/t/alter_table.test:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/limit.test:
  Auto merged
mysql-test/t/mysql.test:
  Auto merged
mysql-test/t/mysqldump.test:
  Auto merged
mysql-test/t/query_cache.test:
  Auto merged
mysql-test/t/system_mysql_db_fix30020.test:
  Auto merged
mysql-test/t/udf.test:
  Auto merged
mysql-test/t/view_grant.test:
  Auto merged
mysys/Makefile.am:
  Auto merged
scripts/mysql_fix_privilege_tables.sql:
  Auto merged
sql/item.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_handler.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql-common/my_time.c:
  Auto merged
sql/sql_table.cc:
  Auto merged
extra/yassl/taocrypt/include/algebra.hpp:
  Remove fix as it conflicts with "import from yassl" and it's been
  fixed there
sql/ha_ndbcluster.cc:
  Merge fix of warnings
sql/sql_base.cc:
  Merge
2006-11-29 15:44:09 +01:00
unknown
a9173ec999 Fix for bug#24395:
ALTER TABLE DISABLE KEYS doesn't work when modifying the table
  
ENABLE|DISABLE KEYS combined with another ALTER TABLE option, different
than RENAME TO did nothing. Also, if the table had disabled keys
and was ALTER-ed then the end table was with enabled keys.
  
Fixed by checking whether the table had disabled keys and enabling them
in the copied table.


myisam/mi_open.c:
  Extend mi_indexes_are_disabled to implement return value
  2 - Non-unique indexes are disabled
mysql-test/r/alter_table.result:
  update result
mysql-test/t/alter_table.test:
  update test
sql/sql_table.cc:
  When ENABLE|DISABLE index is combined with another option
  different than RENAME TO, we should ENABLE|DISABLE the keys of
  the modified table. Also when modifying we should preserve the
  previous state of the indices.
  (This problem exists in 5.0 and 5.1 but since the codebase has
  diverged, this fix won't automerge, but the fix will be quite
  similar).
2006-11-28 18:27:32 +01:00
unknown
05a2da2c1a Merge example.com:/work/bug24219/my50
into  example.com:/work/bug24219/my51


mysql-test/t/alter_table.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
mysql-test/r/alter_table.result:
  manual merge
2006-11-16 14:16:32 +01:00
unknown
db42257de8 Merge example.com:/work/bug24219/my41
into  example.com:/work/bug24219/my50


mysql-test/t/alter_table.test:
  Auto merged
sql/sql_table.cc:
  manual merge
mysql-test/r/alter_table.result:
  manual merge
2006-11-16 13:46:43 +01:00
unknown
09fc514bd5 Fix for bug#24219 ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash
There was an improper order of doing chained operations.

To the documentor: ENABLE|DISABLE KEYS combined with RENAME TO, and no other
ALTER TABLE clause, leads to server crash independent of the presence of
indices and data in the table.


mysql-test/r/alter_table.result:
  update result
mysql-test/t/alter_table.test:
  add test for bug#24129
sql/sql_table.cc:
  If there is operation on the KEYS, first do it
  and then do a rename if there is such. Or, we will crash because
  the underlying table has changed.
2006-11-16 13:18:37 +01: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
unknown
ce4b9c82da Bug#18775 - Temporary table from alter table visible to other threads
New test cases. Names with umlauts don't compare well on Windows.


mysql-test/r/alter_table.result:
  Bug#18775 - Temporary table from alter table visible to other threads
  New test results
mysql-test/r/backup.result:
  Bug#18775 - Temporary table from alter table visible to other threads
  New test results
mysql-test/t/alter_table.test:
  Bug#18775 - Temporary table from alter table visible to other threads
  New test case. Names with umlauts don't compare well on Windows.
mysql-test/t/backup.test:
  Bug#18775 - Temporary table from alter table visible to other threads
  New test case. Names with umlauts don't compare well on Windows.
2006-08-03 08:12:56 +02:00
unknown
ef976d20c9 Bug#18775 - Temporary table from alter table visible to other threads
Continued implementation of WL#1324 (table name to filename encoding)

The intermediate (not temporary) files of the new table
during ALTER TABLE was visible for SHOW TABLES. These
intermediate files are copies of the original table with
the changes done by ALTER TABLE. After all the data is
copied over from the original table, these files are renamed 
to the original tables file names. So they are not temporary 
files. They persist after ALTER TABLE, but just with another 
name.

In 5.0 the intermediate files are invisible for SHOW TABLES
because all file names beginning with "#sql" were suppressed.

This failed since 5.1.6 because even temporary table names were
converted when making file names from them. The prefix became
converted to "@0023sql". Converting the prefix during SHOW TABLES
would suppress the listing of user tables that start with "#sql".

The solution of the problem is to continue the implementation of
the table name to file name conversion feature. One requirement
is to suppress the conversion for temporary table names.

This change is straightforward for real temporary tables as there
is a function that creates temporary file names.

But the generated path names are located in TMPDIR and have no
relation to the internal table name. This cannot be used for
ALTER TABLE. Its intermediate files need to be in the same
directory as the old table files. And it is necessary to be
able to deduce the same path from the same table name repeatedly.

Consequently the intermediate table files must be handled like normal
tables. Their internal names shall start with tmp_file_prefix
(#sql) and they shall not be converted like normal table names.

I added a flags parameter to all relevant functions that are
called from ALTER TABLE. It is used to suppress the conversion
for the intermediate table files.

The outcome is that the suppression of #sql in SHOW TABLES
works again. It does not suppress user tables as these are
converted to @0023sql on file level.

This patch does also fix ALTER TABLE ... RENAME, which could not 
rename a table with non-ASCII characters in its name.

It does also fix the problem that a user could create a table like
`#sql-xxxx-yyyy`, where xxxx is mysqld's pid and yyyy is the thread
ID of some other thread, which prevented this thread from running 
ALTER TABLE.

Some of the above problems are mentioned in Bug 1405, which can
be closed with this patch.

This patch does also contain some minor fixes for other forgotten
conversions. Still known problems are reported as bugs 21370,
21373, and 21387.


mysql-test/r/alter_table.result:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added test results.
mysql-test/r/backup.result:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added test results.
mysql-test/r/repair.result:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added test results.
mysql-test/t/alter_table.test:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added test cases.
mysql-test/t/backup.test:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added test cases.
mysql-test/t/repair.test:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added a test case.
sql/ha_myisam.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added missing table name mapping calls to backup() and restore().
sql/ha_myisammrg.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/ha_ndbcluster.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/ha_ndbcluster_binlog.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/ha_ndbcluster_binlog.h:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Removed unnecessary check for wrong temp file prefix.
sql/mysql_priv.h:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Extended quick_rm_table(), mysql_rename_table(), and
  build_table_filename() by an flags argument, which can indicate
  temporary table names that should not be converted.
  Added symbolic flag values.
sql/sql_acl.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/sql_base.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Fixed a comment.
  Added DBUG calls.
sql/sql_db.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/sql_delete.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/sql_insert.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/sql_partition.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/sql_rename.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/sql_show.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Reverted the former fix for this bug. tmp_file_prefix is now used
  verbatim in the comparison of file names.
sql/sql_table.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added a check for a tmp_file_prefix file name to
  filename_to_tablename(). These names are now accepted without
  conversion.
  Extended quick_rm_table(), mysql_rename_table(), and
  build_table_filename() by an flags argument, which can indicate
  temporary table names that should not be converted.
  Removed the table to file name conversion from
  build_tmptable_filename().
  Disabled REPAIR TABLE ... USE_FRM for temporary tables.
  Added the forgotten conversion to mysql_alter_table() for the case
  of ALTER TABLE ... RENAME.
  Added comments and DBUG calls.
sql/sql_trigger.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/sql_view.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Added an zero argument for the new 'flags' parameter.
sql/table.cc:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Replaced a literal ".frm" by reg_ext.
  Added DBUG calls.
storage/innobase/row/row0mysql.c:
  Bug#18775 - Temporary table from alter table visible to other threads
  Continued implementation of WL#1324 (table name to filename encoding)
  Changed back the encoded temp file prefix to #sql.
2006-08-02 17:57:06 +02:00
unknown
ad7b956922 Fix, or a workaround for Bug#19386 "Multiple alter causes crashed table"
The problem is that in a MyISAM table the following column
after a varchar field gets corrupted, if varchar field is
extended.

This should be made to work without a copy in the future, but
I'm not sure if this code is ready yet. This fix will force copy
in this case. It will not do any harm to have it here, only makes
alter table a bit slower in this case. If this should work for
MyISAM, then the bug is somewhere else in that code.

Until it works, I propose this as a temporary fix or a workaround.
Test case for the bug has been added.


mysql-test/r/alter_table.result:
  Added test case for Bug#19386: Multiple alter causes crashed table.
mysql-test/t/alter_table.test:
  Added test case for Bug#19386: Multiple alter causes crashed table.
sql/ha_myisam.cc:
  For MyISAM type, if varchar column is extended, it should return not
  compatible for now. In other words, it forces a copy of the table during
  alter table.
2006-05-15 19:41:04 +03:00
unknown
4b4a13a150 Extended test case to check that binary column
actually adds zeroes, not spaces at the end.
2006-03-15 10:14:35 +02:00
unknown
8ba02d7270 Added a test case for Bug#18038 MySQL server corrupts binary columns data 2006-03-15 09:40:30 +02:00