~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/insert_select.test

Removed/replaced a couple DBUG calls

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
drop table if exists t1,t2,t3;
7
7
--enable_warnings
8
8
 
9
 
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
 
9
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
10
10
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
11
 
create table t2 (payoutID int NOT NULL PRIMARY KEY);
 
11
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
12
12
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
13
13
--error ER_DUP_ENTRY
14
14
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
21
21
# test case by Fournier Jocelyn <joc@presence-pc.com>
22
22
#
23
23
 
24
 
CREATE TEMPORARY TABLE `t1` (
25
 
  `numeropost` bigint NOT NULL default '0',
26
 
  `icone` int NOT NULL default '0',
27
 
  `numreponse` bigint NOT NULL auto_increment,
 
24
CREATE TABLE `t1` (
 
25
  `numeropost` bigint(20) unsigned NOT NULL default '0',
 
26
  `icone` tinyint(4) unsigned NOT NULL default '0',
 
27
  `numreponse` bigint(20) unsigned NOT NULL auto_increment,
28
28
  `contenu` text NOT NULL,
29
29
  `pseudo` varchar(50) NOT NULL default '',
30
 
  `date` datetime,
31
 
  `ip` bigint NOT NULL default '0',
32
 
  `signature` int NOT NULL default '0',
 
30
  `date` datetime NOT NULL default '0000-00-00 00:00:00',
 
31
  `ip` bigint(11) NOT NULL default '0',
 
32
  `signature` tinyint(1) unsigned NOT NULL default '0',
33
33
  PRIMARY KEY  (`numeropost`,`numreponse`)
34
34
  ,KEY `ip` (`ip`),
35
35
  KEY `date` (`date`),
37
37
  KEY `numreponse` (`numreponse`)
38
38
) ENGINE=MyISAM;
39
39
 
40
 
CREATE TEMPORARY TABLE `t2` (
41
 
  `numeropost` bigint NOT NULL default '0',
42
 
  `icone` int NOT NULL default '0',
43
 
  `numreponse` bigint NOT NULL auto_increment,
 
40
CREATE TABLE `t2` (
 
41
  `numeropost` bigint(20) unsigned NOT NULL default '0',
 
42
  `icone` tinyint(4) unsigned NOT NULL default '0',
 
43
  `numreponse` bigint(20) unsigned NOT NULL auto_increment,
44
44
  `contenu` text NOT NULL,
45
45
  `pseudo` varchar(50) NOT NULL default '',
46
 
  `date` datetime,
47
 
  `ip` bigint NOT NULL default '0',
48
 
  `signature` int NOT NULL default '0',
 
46
  `date` datetime NOT NULL default '0000-00-00 00:00:00',
 
47
  `ip` bigint(11) NOT NULL default '0',
 
48
  `signature` tinyint(1) unsigned NOT NULL default '0',
49
49
  PRIMARY KEY  (`numeropost`,`numreponse`),
50
50
  KEY `ip` (`ip`),
51
51
  KEY `date` (`date`),
89
89
select * from t1;
90
90
insert into t1 select t2.a from t1,t2;
91
91
select * from t1;
92
 
--error ER_NONUNIQ_TABLE
 
92
--error 1066
93
93
insert into t1 select * from t1,t1;
94
94
drop table t1,t2;
95
95
 
113
113
# Test that caused uninitialized memory access in auto_increment_key update
114
114
#
115
115
 
116
 
CREATE TABLE t1 ( USID INTEGER, ServerID int, 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, NASPort INTEGER, NASPortType INTEGER, ConnectSpeed INTEGER, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER, SessionTime INTEGER, PacketsIn INTEGER, OctetsIn INTEGER, PacketsOut INTEGER, OctetsOut INTEGER, TerminateCause INTEGER, UnauthTime int, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
117
 
CREATE TABLE t2 ( USID INTEGER AUTO_INCREMENT, ServerID int, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER, NASPort INTEGER, NASPortType INTEGER, ConnectSpeed INTEGER, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER, SessionTime INTEGER, PacketsIn INTEGER, OctetsIn INTEGER, PacketsOut INTEGER, OctetsOut INTEGER, TerminateCause INTEGER, UnauthTime int, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
 
116
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);
 
117
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));
118
118
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);
119
119
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;
120
120
drop table t1,t2;
125
125
 
126
126
CREATE TABLE t1(
127
127
 Month date NOT NULL,
128
 
 Type int NOT NULL auto_increment,
129
 
 Field int NOT NULL,
130
 
 Count int NOT NULL,
131
 
 PRIMARY KEY (Type),
 
128
 Type tinyint(3) unsigned NOT NULL auto_increment,
 
129
 Field int(10) unsigned NOT NULL,
 
130
 Count int(10) unsigned NOT NULL,
132
131
 UNIQUE KEY Month (Month,Type,Field)
133
132
);
134
133
          
135
 
insert into t1 Values (20030901, 1, 1, 100);
136
 
insert into t1 Values (20030901, 2, 2, 100);
137
 
insert into t1 Values (20030901, 3, 3, 100);
138
 
insert into t1 Values (20030901, 4, 4, 100);
139
 
insert into t1 Values (20030901, 5, 5, 100);
 
134
insert into t1 Values
 
135
(20030901, 1, 1, 100),
 
136
(20030901, 1, 2, 100),
 
137
(20030901, 2, 1, 100),
 
138
(20030901, 2, 2, 100),
 
139
(20030901, 3, 1, 100);
140
140
 
141
141
select * from t1;
142
142
          
154
154
# BUG#6034 - Error code 124:  Wrong medium type
155
155
#
156
156
CREATE TABLE t1 (
157
 
  ID           int NOT NULL auto_increment,
158
 
  NO           int NOT NULL default '0',
159
 
  SEQ          int NOT NULL default '0',
 
157
  ID           int(11) NOT NULL auto_increment,
 
158
  NO           int(11) NOT NULL default '0',
 
159
  SEQ          int(11) NOT NULL default '0',
160
160
  PRIMARY KEY  (ID),
161
161
  KEY t1$NO    (SEQ,NO)
162
 
);
 
162
) ENGINE=MyISAM;
163
163
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);
164
164
select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
165
165
drop table t1;
194
194
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a + 10;
195
195
 
196
196
#Some error cases
197
 
--error ER_NON_UNIQ_ERROR
 
197
--error 1052
198
198
insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
199
 
--error ER_BAD_FIELD_ERROR
 
199
--error 1054
200
200
insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
201
 
--error ER_BAD_FIELD_ERROR
 
201
--error 1054
202
202
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
203
203
drop table t1,t2,t3;
204
204
 
218
218
create table t1(x int, y int);
219
219
create table t2(x int, z int);
220
220
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x);
221
 
--error ER_BAD_FIELD_ERROR
 
221
--error 1054
222
222
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
223
 
--error ER_BAD_FIELD_ERROR
 
223
--error 1054
224
224
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
225
225
drop table t1,t2; 
226
226
 
235
235
 
236
236
flush status;
237
237
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
238
 
--replace_column 2 #
239
238
show status like 'Handler_read%';
240
239
 
241
240
DROP TABLE t1;
245
244
#
246
245
 
247
246
CREATE TABLE t1 (
248
 
    f1 int NOT NULL auto_increment PRIMARY KEY,
 
247
    f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
249
248
    f2 varchar(100) NOT NULL default ''
250
249
);
251
250
CREATE TABLE t2 (
353
352
--echo #
354
353
create table t1(f1 int);
355
354
insert into t1 values(1),(2),(3);
356
 
create temporary table t2 (key(f1)) engine=myisam select sql_buffer_result f1 from t1;
357
 
check table t2;
 
355
create table t2 (key(f1)) engine=myisam select sql_buffer_result f1 from t1;
 
356
check table t2 extended;
358
357
drop table t1,t2;
359
358
--echo ##################################################################
360
359