mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
10e2581f4d
mysql-test/r/innodb.result: Auto merged BitKeeper/deleted/.del-select.result.es~240635f6a3f1a079: Auto merged BitKeeper/deleted/.del-type_float.result.es~a5533e4118eadc04: Auto merged BitKeeper/deleted/.del-type_ranges.result.es~bb77517f4c9dc978: Auto merged mysql-test/r/type_float.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/connect.test: Auto merged mysql-test/t/grant2.test: Auto merged mysql-test/t/grant_cache.test: Auto merged mysql-test/t/innodb.test: Auto merged mysql-test/t/mix_innodb_myisam_binlog.test: Auto merged mysql-test/t/mysqlbinlog.test: Auto merged mysql-test/t/mysqlbinlog2.test: Auto merged mysql-test/t/mysqldump.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/select.test: Auto merged mysql-test/t/show_check.test: Auto merged mysql-test/t/system_mysql_db_fix.test: Auto merged mysql-test/t/type_blob.test: Auto merged mysql-test/t/type_float.test: Auto merged mysql-test/t/variables.test: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged mysql-test/mysql-test-run.sh: Merge mysql-test/r/alter_table.result: Update results mysql-test/r/ctype_ucs.result: Update results mysql-test/r/grant.result: Update results mysql-test/r/insert_select.result: Update results mysql-test/r/ps_1general.result: Update results mysql-test/r/select.result: Update results mysql-test/r/timezone2.result: Update results mysql-test/r/type_blob.result: Update results mysql-test/r/type_ranges.result: Update results mysql-test/r/user_var.result: Update results mysql-test/t/ctype_ucs.test: Merge mysql-test/t/grant.test: Merge mysql-test/t/insert_select.test: Merge mysql-test/t/timezone2.test: Merge mysql-test/t/type_ranges.test: Merge mysql-test/t/user_var.test: Merge
166 lines
6.5 KiB
Text
166 lines
6.5 KiB
Text
#
|
|
# Problem with INSERT ... SELECT
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t1,t2;
|
|
--enable_warnings
|
|
|
|
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
|
|
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
|
|
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
|
|
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
|
|
--error 1062
|
|
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
|
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
|
select * from t2;
|
|
drop table t1,t2;
|
|
|
|
#
|
|
# bug in bulk insert optimization
|
|
# test case by Fournier Jocelyn <joc@presence-pc.com>
|
|
#
|
|
|
|
CREATE TABLE `t1` (
|
|
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
|
`icone` tinyint(4) unsigned NOT NULL default '0',
|
|
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
|
`contenu` text NOT NULL,
|
|
`pseudo` varchar(50) NOT NULL default '',
|
|
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
|
`ip` bigint(11) NOT NULL default '0',
|
|
`signature` tinyint(1) unsigned NOT NULL default '0',
|
|
PRIMARY KEY (`numeropost`,`numreponse`)
|
|
,KEY `ip` (`ip`),
|
|
KEY `date` (`date`),
|
|
KEY `pseudo` (`pseudo`),
|
|
KEY `numreponse` (`numreponse`)
|
|
) ENGINE=MyISAM;
|
|
|
|
CREATE TABLE `t2` (
|
|
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
|
`icone` tinyint(4) unsigned NOT NULL default '0',
|
|
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
|
`contenu` text NOT NULL,
|
|
`pseudo` varchar(50) NOT NULL default '',
|
|
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
|
`ip` bigint(11) NOT NULL default '0',
|
|
`signature` tinyint(1) unsigned NOT NULL default '0',
|
|
PRIMARY KEY (`numeropost`,`numreponse`),
|
|
KEY `ip` (`ip`),
|
|
KEY `date` (`date`),
|
|
KEY `pseudo` (`pseudo`),
|
|
KEY `numreponse` (`numreponse`)
|
|
) ENGINE=MyISAM;
|
|
|
|
INSERT INTO t2
|
|
(numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES
|
|
(9,1,56,'test','joce','2001-07-25 13:50:53'
|
|
,3649052399,0);
|
|
|
|
|
|
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
|
SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM t2
|
|
WHERE numeropost=9 ORDER BY numreponse ASC;
|
|
|
|
show variables like '%bulk%';
|
|
|
|
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
|
SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2
|
|
WHERE numeropost=9 ORDER BY numreponse ASC;
|
|
|
|
DROP TABLE t1,t2;
|
|
|
|
#
|
|
# Test of insert ... select from same table
|
|
#
|
|
|
|
create table t1 (a int not null);
|
|
create table t2 (a int not null);
|
|
insert into t1 values (1);
|
|
insert into t1 values (a+2);
|
|
insert into t1 values (a+3);
|
|
insert into t1 values (4),(a+5);
|
|
insert into t1 select * from t1;
|
|
select * from t1;
|
|
insert into t1 select * from t1 as t2;
|
|
select * from t1;
|
|
insert into t2 select * from t1 as t2;
|
|
select * from t1;
|
|
insert into t1 select t2.a from t1,t2;
|
|
select * from t1;
|
|
--error 1066
|
|
insert into t1 select * from t1,t1;
|
|
drop table t1,t2;
|
|
|
|
#
|
|
# test replace ... select
|
|
#
|
|
|
|
create table t1 (a int not null primary key, b char(10));
|
|
create table t2 (a int not null, b char(10));
|
|
insert into t1 values (1,"t1:1"),(3,"t1:3");
|
|
insert into t2 values (2,"t2:2"), (3,"t2:3");
|
|
--error 1062
|
|
insert into t1 select * from t2;
|
|
select * from t1;
|
|
# REPLACE .. SELECT is not yet supported by PS
|
|
replace into t1 select * from t2;
|
|
select * from t1;
|
|
drop table t1,t2;
|
|
|
|
#
|
|
# Test that caused uninitialized memory access in auto_increment_key update
|
|
#
|
|
|
|
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
|
|
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
|
|
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
|
|
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
|
|
drop table t1,t2;
|
|
|
|
#
|
|
# Another problem from Bug #2012
|
|
#
|
|
|
|
CREATE TABLE t1(
|
|
Month date NOT NULL,
|
|
Type tinyint(3) unsigned NOT NULL auto_increment,
|
|
Field int(10) unsigned NOT NULL,
|
|
Count int(10) unsigned NOT NULL,
|
|
UNIQUE KEY Month (Month,Type,Field)
|
|
);
|
|
|
|
insert into t1 Values
|
|
(20030901, 1, 1, 100),
|
|
(20030901, 1, 2, 100),
|
|
(20030901, 2, 1, 100),
|
|
(20030901, 2, 2, 100),
|
|
(20030901, 3, 1, 100);
|
|
|
|
select * from t1;
|
|
|
|
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
|
|
|
|
create table t2(No int not null, Field int not null, Count int not null);
|
|
|
|
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
|
|
|
|
select * from t2;
|
|
|
|
drop table t1, t2;
|
|
|
|
#
|
|
# BUG#6034 - Error code 124: Wrong medium type
|
|
#
|
|
CREATE TABLE t1 (
|
|
ID int(11) NOT NULL auto_increment,
|
|
NO int(11) NOT NULL default '0',
|
|
SEQ int(11) NOT NULL default '0',
|
|
PRIMARY KEY (ID),
|
|
KEY t1$NO (SEQ,NO)
|
|
) ENGINE=MyISAM;
|
|
INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1);
|
|
select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
|
|
drop table t1;
|
|
|