mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 15:50:51 +03:00 
			
		
		
		
	BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/triggers/post-commit: Auto merged Docs/Support/texi2html: Auto merged Makefile.am: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged client/mysqldump.c: Auto merged include/my_base.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/my_time.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/buf/buf0buf.c: Auto merged innobase/include/row0mysql.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/examples/Makefile.am: Auto merged myisam/mi_check.c: Auto merged mysql-test/include/ps_modify.inc: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/alter_table.result: Auto merged mysql-test/r/auto_increment.result: Auto merged mysql-test/r/bdb.result: Auto merged mysql-test/r/ctype_latin1_de.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_if.result: Auto merged mysql-test/t/derived.test: Auto merged mysql-test/t/insert.test: merge with 4.1 Fixed test case to not use 'if exists' when it shouldn't mysql-test/t/range.test: merge with 4.1 Added missing drop table sql/ha_ndbcluster.cc: merge with 4.1 Simple optimization: use max() instead of ? : sql/item_func.cc: merge with 4.1 (Added back old variable names for easier merges) sql/opt_range.cc: merge with 4.1 Removed argument 'parent_alloc' from QUICK_RANGE_SELECT as this was not used Added assert if using QUICK_GROUP_MIN_MAX_SELECT with parent_alloc as the init() function can't handle this Changed back get_quick_select_for_ref() to use it's own alloc root becasue this function may be called several times for one query sql/sql_handler.cc: merge with 4.1 change variable 'err' to 'error' as same function had a label named 'err' sql/sql_update.cc: Use multi-update code from 5.0 instead of 4.1 We will fix the locking code shortly in 5.0 to be faster than in 4.1
		
			
				
	
	
		
			344 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			344 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| drop table if exists t1;
 | |
| drop table if exists t2;
 | |
| SET SQL_WARNINGS=1;
 | |
| create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
 | |
| insert into t1 values (1,1),(NULL,3),(NULL,4);
 | |
| delete from t1 where a=4;
 | |
| insert into t1 values (NULL,5),(NULL,6);
 | |
| select * from t1;
 | |
| a	b
 | |
| 1	1
 | |
| 3	3
 | |
| 5	5
 | |
| 6	6
 | |
| delete from t1 where a=6;
 | |
| replace t1 values (3,1);
 | |
| ALTER TABLE t1 add c int;
 | |
| replace t1 values (3,3,3);
 | |
| insert into t1 values (NULL,7,7);
 | |
| update t1 set a=8,b=b+1,c=c+1 where a=7;
 | |
| insert into t1 values (NULL,9,9);
 | |
| select * from t1;
 | |
| a	b	c
 | |
| 1	1	NULL
 | |
| 3	3	3
 | |
| 5	5	NULL
 | |
| 8	8	8
 | |
| 9	9	9
 | |
| drop table t1;
 | |
| create table t1 (
 | |
| skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
 | |
| sval char(20)
 | |
| );
 | |
| insert into t1 values (NULL, "hello");
 | |
| insert into t1 values (NULL, "hey");
 | |
| select * from t1;
 | |
| skey	sval
 | |
| 1	hello
 | |
| 2	hey
 | |
| select _rowid,t1._rowid,skey,sval from t1;
 | |
| _rowid	_rowid	skey	sval
 | |
| 1	1	1	hello
 | |
| 2	2	2	hey
 | |
| drop table t1;
 | |
| create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b));
 | |
| insert into t1 values ("a",1),("b",2),("a",2),("c",1);
 | |
| insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
 | |
| insert into t1 (a) values ("a"),("b"),("c"),("d");
 | |
| insert into t1 (a) values ('k'),('d');
 | |
| insert into t1 (a) values ("a");
 | |
| insert into t1 values ("d",last_insert_id());
 | |
| select * from t1;
 | |
| a	b
 | |
| a	1
 | |
| a	2
 | |
| a	3
 | |
| a	4
 | |
| a	5
 | |
| b	2
 | |
| b	3
 | |
| b	4
 | |
| c	1
 | |
| c	2
 | |
| c	3
 | |
| d	1
 | |
| d	2
 | |
| d	5
 | |
| e	1
 | |
| k	1
 | |
| drop table t1;
 | |
| create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ordid), index(ord,ordid));
 | |
| insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
 | |
| select * from t1;
 | |
| ordid	ord
 | |
| 1	sdj
 | |
| 2	sdj
 | |
| drop table t1;
 | |
| create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid));
 | |
| insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
 | |
| select * from t1;
 | |
| ordid	ord
 | |
| 1	abc
 | |
| 2	abc
 | |
| 3	abc
 | |
| 1	sdj
 | |
| 2	sdj
 | |
| 3	sdj
 | |
| 1	zzz
 | |
| drop table t1;
 | |
| create table t1 (sid char(5), id int(2) NOT NULL auto_increment, key(sid,  id));
 | |
| create table t2 (sid char(20), id int(2));
 | |
| insert into t2 values ('skr',NULL),('skr',NULL),('test',NULL);
 | |
| insert into t1 select * from t2;
 | |
| select * from t1;
 | |
| sid	id
 | |
| skr	1
 | |
| skr	2
 | |
| test	1
 | |
| drop table t1,t2;
 | |
| create table t1 (a int not null primary key auto_increment);
 | |
| insert into t1 values (0);
 | |
| update t1 set a=0;
 | |
| select * from t1;
 | |
| a
 | |
| 0
 | |
| check table t1;
 | |
| Table	Op	Msg_type	Msg_text
 | |
| test.t1	check	warning	Found row where the auto_increment column has the value 0
 | |
| test.t1	check	status	OK
 | |
| drop table t1;
 | |
| create table t1 (a int not null auto_increment primary key);
 | |
| insert into t1 values (NULL);
 | |
| insert into t1 values (-1);
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 1
 | |
| insert into t1 values (NULL);
 | |
| select * from t1;
 | |
| a
 | |
| -1
 | |
| 1
 | |
| 2
 | |
| drop table t1;
 | |
| create table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
 | |
| insert into t1 values (NULL);
 | |
| insert into t1 values (-1);
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 1
 | |
| insert into t1 values (NULL);
 | |
| select * from t1;
 | |
| a
 | |
| 1
 | |
| -1
 | |
| 2
 | |
| drop table t1;
 | |
| create table t1 (i tinyint unsigned not null auto_increment primary key);
 | |
| insert into t1 set i = 254;
 | |
| insert into t1 set i = null;
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 255
 | |
| explain extended select last_insert_id();
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 | |
| 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 | |
| Warnings:
 | |
| Note	1003	select sql_no_cache last_insert_id() AS `last_insert_id()`
 | |
| insert into t1 set i = 254;
 | |
| ERROR 23000: Duplicate entry '254' for key 1
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 255
 | |
| insert into t1 set i = null;
 | |
| ERROR 23000: Duplicate entry '255' for key 1
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 0
 | |
| drop table t1;
 | |
| create table t1 (i tinyint unsigned not null auto_increment, key (i));
 | |
| insert into t1 set i = 254;
 | |
| insert into t1 set i = null;
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 255
 | |
| insert into t1 set i = null;
 | |
| Warnings:
 | |
| Warning	1264	Out of range value adjusted for column 'i' at row 1
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 255
 | |
| drop table t1;
 | |
| create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b));
 | |
| insert into t1 values (NULL, 10);
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 1
 | |
| insert into t1 values (NULL, 15);
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 2
 | |
| insert into t1 values (NULL, 10);
 | |
| ERROR 23000: Duplicate entry '10' for key 2
 | |
| select last_insert_id();
 | |
| last_insert_id()
 | |
| 0
 | |
| drop table t1;
 | |
| create table t1(a int auto_increment,b int null,primary key(a));
 | |
| SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
 | |
| insert into t1(a,b)values(NULL,1);
 | |
| insert into t1(a,b)values(200,2);
 | |
| insert into t1(a,b)values(0,3);
 | |
| insert into t1(b)values(4);
 | |
| insert into t1(b)values(5);
 | |
| insert into t1(b)values(6);
 | |
| insert into t1(b)values(7);
 | |
| select * from t1 order by b;
 | |
| a	b
 | |
| 1	1
 | |
| 200	2
 | |
| 0	3
 | |
| 201	4
 | |
| 202	5
 | |
| 203	6
 | |
| 204	7
 | |
| alter table t1 modify b mediumint;
 | |
| select * from t1 order by b;
 | |
| a	b
 | |
| 1	1
 | |
| 200	2
 | |
| 0	3
 | |
| 201	4
 | |
| 202	5
 | |
| 203	6
 | |
| 204	7
 | |
| create table t2 (a int);
 | |
| insert t2 values (1),(2);
 | |
| alter table t2 add b int auto_increment primary key;
 | |
| select * from t2;
 | |
| a	b
 | |
| 1	1
 | |
| 2	2
 | |
| drop table t2;
 | |
| delete from t1 where a=0;
 | |
| update t1 set a=0 where b=5;
 | |
| select * from t1 order by b;
 | |
| a	b
 | |
| 1	1
 | |
| 200	2
 | |
| 201	4
 | |
| 0	5
 | |
| 203	6
 | |
| 204	7
 | |
| delete from t1 where a=0;
 | |
| update t1 set a=NULL where b=6;
 | |
| Warnings:
 | |
| Warning	1263	Column set to default value; NULL supplied to NOT NULL column 'a' at row 4
 | |
| update t1 set a=300 where b=7;
 | |
| SET SQL_MODE='';
 | |
| insert into t1(a,b)values(NULL,8);
 | |
| insert into t1(a,b)values(400,9);
 | |
| insert into t1(a,b)values(0,10);
 | |
| insert into t1(b)values(11);
 | |
| insert into t1(b)values(12);
 | |
| insert into t1(b)values(13);
 | |
| insert into t1(b)values(14);
 | |
| select * from t1 order by b;
 | |
| a	b
 | |
| 1	1
 | |
| 200	2
 | |
| 201	4
 | |
| 0	6
 | |
| 300	7
 | |
| 301	8
 | |
| 400	9
 | |
| 401	10
 | |
| 402	11
 | |
| 403	12
 | |
| 404	13
 | |
| 405	14
 | |
| delete from t1 where a=0;
 | |
| update t1 set a=0 where b=12;
 | |
| select * from t1 order by b;
 | |
| a	b
 | |
| 1	1
 | |
| 200	2
 | |
| 201	4
 | |
| 300	7
 | |
| 301	8
 | |
| 400	9
 | |
| 401	10
 | |
| 402	11
 | |
| 0	12
 | |
| 404	13
 | |
| 405	14
 | |
| delete from t1 where a=0;
 | |
| update t1 set a=NULL where b=13;
 | |
| Warnings:
 | |
| Warning	1263	Column set to default value; NULL supplied to NOT NULL column 'a' at row 9
 | |
| update t1 set a=500 where b=14;
 | |
| select * from t1 order by b;
 | |
| a	b
 | |
| 1	1
 | |
| 200	2
 | |
| 201	4
 | |
| 300	7
 | |
| 301	8
 | |
| 400	9
 | |
| 401	10
 | |
| 402	11
 | |
| 0	13
 | |
| 500	14
 | |
| drop table t1;
 | |
| create table t1 (a bigint);
 | |
| insert into t1 values (1), (2), (3), (NULL), (NULL);
 | |
| alter table t1 modify a bigint not null auto_increment primary key;
 | |
| select * from t1;
 | |
| a
 | |
| 1
 | |
| 2
 | |
| 3
 | |
| 4
 | |
| 5
 | |
| drop table t1;
 | |
| create table t1 (a bigint);
 | |
| insert into t1 values (1), (2), (3), (0), (0);
 | |
| alter table t1 modify a bigint not null auto_increment primary key;
 | |
| select * from t1;
 | |
| a
 | |
| 1
 | |
| 2
 | |
| 3
 | |
| 4
 | |
| 5
 | |
| drop table t1;
 | |
| create table t1 (a bigint);
 | |
| insert into t1 values (0), (1), (2), (3);
 | |
| set sql_mode=NO_AUTO_VALUE_ON_ZERO;
 | |
| alter table t1 modify a bigint not null auto_increment primary key;
 | |
| set sql_mode= '';
 | |
| select * from t1;
 | |
| a
 | |
| 0
 | |
| 1
 | |
| 2
 | |
| 3
 | |
| drop table t1;
 | |
| create table t1 (a int auto_increment primary key , b int null);
 | |
| set sql_mode=NO_AUTO_VALUE_ON_ZERO;
 | |
| insert into t1 values (0,1),(1,2),(2,3);
 | |
| select * from t1;
 | |
| a	b
 | |
| 0	1
 | |
| 1	2
 | |
| 2	3
 | |
| set sql_mode= '';
 | |
| alter table t1 modify b varchar(255);
 | |
| insert into t1 values (0,4);
 | |
| select * from t1;
 | |
| a	b
 | |
| 0	1
 | |
| 1	2
 | |
| 2	3
 | |
| 3	4
 | |
| drop table t1;
 |