~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/group_by.test

  • Committer: Monty Taylor
  • Date: 2008-10-20 08:48:34 UTC
  • mfrom: (520.1.22 drizzle)
  • Revision ID: monty@inaugust.com-20081020084834-xpb3w01vkcp55o02
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#
16
16
 
17
17
CREATE TABLE t1 (
18
 
  spID int(10),
19
 
  userID int(10),
20
 
  score int(5),
 
18
  spID int,
 
19
  userID int,
 
20
  score int,
21
21
  lsg char(40),
22
22
  date date
23
23
);
28
28
INSERT INTO t1 VALUES (3,3,3,'','0000-00-00');
29
29
 
30
30
CREATE TABLE t2 (
31
 
  userID int(10) NOT NULL auto_increment,
 
31
  userID int NOT NULL auto_increment,
32
32
  niName char(15),
33
33
  passwd char(8),
34
34
  mail char(50),
61
61
#
62
62
 
63
63
CREATE TABLE t1 (
64
 
  PID int(10) NOT NULL auto_increment,
 
64
  PID int NOT NULL auto_increment,
65
65
  payDate date DEFAULT '0000-00-00' NOT NULL,
66
66
  recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
67
 
  URID int(10) DEFAULT '0' NOT NULL,
68
 
  CRID int(10) DEFAULT '0' NOT NULL,
69
 
  amount int(10) DEFAULT '0' NOT NULL,
70
 
  operator int(10),
 
67
  URID int DEFAULT '0' NOT NULL,
 
68
  CRID int DEFAULT '0' NOT NULL,
 
69
  amount int DEFAULT '0' NOT NULL,
 
70
  operator int,
71
71
  method enum('unknown','cash','dealer','check','card','lazy','delayed','test') DEFAULT 'unknown' NOT NULL,
72
 
  DIID int(10),
 
72
  DIID int,
73
73
  reason char(1) binary DEFAULT '' NOT NULL,
74
 
  code_id int(10),
75
 
  qty mediumint(8) DEFAULT '0' NOT NULL,
 
74
  code_id int,
 
75
  qty int DEFAULT '0' NOT NULL,
76
76
  PRIMARY KEY (PID),
77
77
  KEY URID (URID),
78
78
  KEY reason (reason),
93
93
#
94
94
 
95
95
CREATE TABLE t1 (
96
 
  cid mediumint(9) NOT NULL auto_increment,
 
96
  cid int NOT NULL auto_increment,
97
97
  firstname varchar(32) DEFAULT '' NOT NULL,
98
98
  surname varchar(32) DEFAULT '' NOT NULL,
99
99
  PRIMARY KEY (cid)
102
102
INSERT INTO t1 VALUES (2,'Another','Gent');
103
103
 
104
104
CREATE TABLE t2 (
105
 
  call_id mediumint(8) NOT NULL auto_increment,
106
 
  contact_id mediumint(8) DEFAULT '0' NOT NULL,
 
105
  call_id int NOT NULL auto_increment,
 
106
  contact_id int DEFAULT '0' NOT NULL,
107
107
  PRIMARY KEY (call_id),
108
108
  KEY contact_id (contact_id)
109
109
);
124
124
unlock tables;
125
125
drop table t1;
126
126
 
127
 
#
128
 
# Test of group by bug in bugzilla
129
 
#
130
 
 
131
 
CREATE TABLE t1 (
132
 
  bug_id mediumint(9) NOT NULL auto_increment,
133
 
  groupset bigint(20) DEFAULT '0' NOT NULL,
134
 
  assigned_to mediumint(9) DEFAULT '0' NOT NULL,
135
 
  bug_file_loc text,
136
 
  bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL,
137
 
  bug_status enum('','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
138
 
  creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
139
 
  delta_ts timestamp,
140
 
  short_desc mediumtext,
141
 
  long_desc mediumtext,
142
 
  op_sys enum('All','Windows 3.1','Windows 95','Windows 98','Windows NT','Windows 2000','Linux','other') DEFAULT 'All' NOT NULL,
143
 
  priority enum('P1','P2','P3','P4','P5') DEFAULT 'P1' NOT NULL,
144
 
  product varchar(64) DEFAULT '' NOT NULL,
145
 
  rep_platform enum('All','PC','VTD-8','Other'),
146
 
  reporter mediumint(9) DEFAULT '0' NOT NULL,
147
 
  version varchar(16) DEFAULT '' NOT NULL,
148
 
  component varchar(50) DEFAULT '' NOT NULL,
149
 
  resolution enum('','FIXED','INVALID','WONTFIX','LATER','REMIND','DUPLICATE','WORKSFORME') DEFAULT '' NOT NULL,
150
 
  target_milestone varchar(20) DEFAULT '' NOT NULL,
151
 
  qa_contact mediumint(9) DEFAULT '0' NOT NULL,
152
 
  status_whiteboard mediumtext NOT NULL,
153
 
  votes mediumint(9) DEFAULT '0' NOT NULL,
154
 
  PRIMARY KEY (bug_id),
155
 
  KEY assigned_to (assigned_to),
156
 
  KEY creation_ts (creation_ts),
157
 
  KEY delta_ts (delta_ts),
158
 
  KEY bug_severity (bug_severity),
159
 
  KEY bug_status (bug_status),
160
 
  KEY op_sys (op_sys),
161
 
  KEY priority (priority),
162
 
  KEY product (product),
163
 
  KEY reporter (reporter),
164
 
  KEY version (version),
165
 
  KEY component (component),
166
 
  KEY resolution (resolution),
167
 
  KEY target_milestone (target_milestone),
168
 
  KEY qa_contact (qa_contact),
169
 
  KEY votes (votes)
170
 
);
171
 
 
172
 
INSERT INTO t1 VALUES (1,0,0,'','normal','','2000-02-10 09:25:12',20000321114747,'','','Linux','P1','TestProduct','PC',3,'other','TestComponent','','M1',0,'',0);
173
 
INSERT INTO t1 VALUES (9,0,0,'','enhancement','','2000-03-10 11:49:36',20000321114747,'','','All','P5','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
174
 
INSERT INTO t1 VALUES (10,0,0,'','enhancement','','2000-03-10 18:10:16',20000321114747,'','','All','P4','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
175
 
INSERT INTO t1 VALUES (7,0,0,'','critical','','2000-03-09 10:50:21',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
176
 
INSERT INTO t1 VALUES (6,0,0,'','normal','','2000-03-09 10:42:44',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
177
 
INSERT INTO t1 VALUES (8,0,0,'','major','','2000-03-09 11:32:14',20000321114747,'','','All','P3','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
178
 
INSERT INTO t1 VALUES (5,0,0,'','enhancement','','2000-03-09 10:38:59',20000321114747,'','','All','P5','CCC/CCCCCC','PC',5,'7.00','Administration','','',0,'',0);
179
 
INSERT INTO t1 VALUES (4,0,0,'','normal','','2000-03-08 18:32:14',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent2','','',0,'',0);
180
 
INSERT INTO t1 VALUES (3,0,0,'','normal','','2000-03-08 18:30:52',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
181
 
INSERT INTO t1 VALUES (2,0,0,'','enhancement','','2000-03-08 18:24:51',20000321114747,'','','All','P2','TestProduct','Other',4,'other','TestComponent2','','',0,'',0);
182
 
INSERT INTO t1 VALUES (11,0,0,'','blocker','','2000-03-13 09:43:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
183
 
INSERT INTO t1 VALUES (12,0,0,'','normal','','2000-03-13 16:14:31',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
184
 
INSERT INTO t1 VALUES (13,0,0,'','normal','','2000-03-15 16:20:44',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
185
 
INSERT INTO t1 VALUES (14,0,0,'','blocker','','2000-03-15 18:13:47',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
186
 
INSERT INTO t1 VALUES (15,0,0,'','minor','','2000-03-16 18:03:28',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
187
 
INSERT INTO t1 VALUES (16,0,0,'','normal','','2000-03-16 18:33:41',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
188
 
INSERT INTO t1 VALUES (17,0,0,'','normal','','2000-03-16 18:34:18',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
189
 
INSERT INTO t1 VALUES (18,0,0,'','normal','','2000-03-16 18:34:56',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
190
 
INSERT INTO t1 VALUES (19,0,0,'','enhancement','','2000-03-16 18:35:34',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
191
 
INSERT INTO t1 VALUES (20,0,0,'','enhancement','','2000-03-16 18:36:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
192
 
INSERT INTO t1 VALUES (21,0,0,'','enhancement','','2000-03-16 18:37:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
193
 
INSERT INTO t1 VALUES (22,0,0,'','enhancement','','2000-03-16 18:38:16',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
194
 
INSERT INTO t1 VALUES (23,0,0,'','normal','','2000-03-16 18:58:12',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
195
 
INSERT INTO t1 VALUES (24,0,0,'','normal','','2000-03-17 11:08:10',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
196
 
INSERT INTO t1 VALUES (25,0,0,'','normal','','2000-03-17 11:10:45',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
197
 
INSERT INTO t1 VALUES (26,0,0,'','normal','','2000-03-17 11:15:47',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
198
 
INSERT INTO t1 VALUES (27,0,0,'','normal','','2000-03-17 17:45:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
199
 
INSERT INTO t1 VALUES (28,0,0,'','normal','','2000-03-20 09:51:45',20000321114747,'','','Windows NT','P2','TestProduct','PC',8,'other','TestComponent','','',0,'',0);
200
 
INSERT INTO t1 VALUES (29,0,0,'','normal','','2000-03-20 11:15:09',20000321114747,'','','All','P5','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
201
 
CREATE TABLE t2 (
202
 
  value tinytext,
203
 
  program varchar(64),
204
 
  initialowner tinytext NOT NULL,
205
 
  initialqacontact tinytext NOT NULL,
206
 
  description mediumtext NOT NULL
207
 
);
208
 
 
209
 
INSERT INTO t2 VALUES ('TestComponent','TestProduct','id0001','','');
210
 
INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - conversion','AAAAA','id0001','','');
211
 
INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - generic','AAAAA','id0001','','');
212
 
INSERT INTO t2 VALUES ('TestComponent2','TestProduct','id0001','','');
213
 
INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - eeeeeeeee','AAAAA','id0001','','');
214
 
INSERT INTO t2 VALUES ('kkkkkkkkkkk lllllllllll','AAAAA','id0001','','');
215
 
INSERT INTO t2 VALUES ('Test Procedures','AAAAA','id0001','','');
216
 
INSERT INTO t2 VALUES ('Documentation','AAAAA','id0003','','');
217
 
INSERT INTO t2 VALUES ('DDDDDDDDD','CCC/CCCCCC','id0002','','');
218
 
INSERT INTO t2 VALUES ('Eeeeeeee Lite','CCC/CCCCCC','id0002','','');
219
 
INSERT INTO t2 VALUES ('Eeeeeeee Full','CCC/CCCCCC','id0002','','');
220
 
INSERT INTO t2 VALUES ('Administration','CCC/CCCCCC','id0002','','');
221
 
INSERT INTO t2 VALUES ('Distribution','CCC/CCCCCC','id0002','','');
222
 
INSERT INTO t2 VALUES ('Setup','CCC/CCCCCC','id0002','','');
223
 
INSERT INTO t2 VALUES ('Unspecified','CCC/CCCCCC','id0002','','');
224
 
INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','','');
225
 
INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','','');
226
 
select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA";
227
 
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value;
228
 
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2);
229
 
 
230
 
drop table t1,t2;
 
127
# Test needs to be rewritten
 
128
##
 
129
## Test of group by bug in bugzilla
 
130
##
 
131
#
 
132
#CREATE TABLE t1 (
 
133
#  bug_id int NOT NULL auto_increment,
 
134
#  groupset bigint DEFAULT '0' NOT NULL,
 
135
#  assigned_to int DEFAULT '0' NOT NULL,
 
136
#  bug_file_loc text,
 
137
#  bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL,
 
138
#  bug_status enum('','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
 
139
#  creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
 
140
#  delta_ts timestamp,
 
141
#  short_desc mediumtext,
 
142
#  long_desc mediumtext,
 
143
#  op_sys enum('All','Windows 3.1','Windows 95','Windows 98','Windows NT','Windows 2000','Linux','other') DEFAULT 'All' NOT NULL,
 
144
#  priority enum('P1','P2','P3','P4','P5') DEFAULT 'P1' NOT NULL,
 
145
#  product varchar(64) DEFAULT '' NOT NULL,
 
146
#  rep_platform enum('All','PC','VTD-8','Other'),
 
147
#  reporter int DEFAULT '0' NOT NULL,
 
148
#  version varchar(16) DEFAULT '' NOT NULL,
 
149
#  component varchar(50) DEFAULT '' NOT NULL,
 
150
#  resolution enum('','FIXED','INVALID','WONTFIX','LATER','REMIND','DUPLICATE','WORKSFORME') DEFAULT '' NOT NULL,
 
151
#  target_milestone varchar(20) DEFAULT '' NOT NULL,
 
152
#  qa_contact int DEFAULT '0' NOT NULL,
 
153
#  status_whiteboard mediumtext NOT NULL,
 
154
#  votes int DEFAULT '0' NOT NULL,
 
155
#  PRIMARY KEY (bug_id),
 
156
#  KEY assigned_to (assigned_to),
 
157
#  KEY creation_ts (creation_ts),
 
158
#  KEY delta_ts (delta_ts),
 
159
#  KEY bug_severity (bug_severity),
 
160
#  KEY bug_status (bug_status),
 
161
#  KEY op_sys (op_sys),
 
162
#  KEY priority (priority),
 
163
#  KEY product (product),
 
164
#  KEY reporter (reporter),
 
165
#  KEY version (version),
 
166
#  KEY component (component),
 
167
#  KEY resolution (resolution),
 
168
#  KEY target_milestone (target_milestone),
 
169
#  KEY qa_contact (qa_contact),
 
170
#  KEY votes (votes)
 
171
#);
 
172
#
 
173
#--error 1265
 
174
#INSERT INTO t1 VALUES (1,0,0,'','normal','','2000-02-10 09:25:12',20000321114747,'','','Linux','P1','TestProduct','PC',3,'other','TestComponent','','M1',0,'',0);
 
175
#INSERT INTO t1 VALUES (9,0,0,'','enhancement','','2000-03-10 11:49:36',20000321114747,'','','All','P5','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
 
176
#INSERT INTO t1 VALUES (10,0,0,'','enhancement','','2000-03-10 18:10:16',20000321114747,'','','All','P4','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
 
177
#INSERT INTO t1 VALUES (7,0,0,'','critical','','2000-03-09 10:50:21',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
 
178
#INSERT INTO t1 VALUES (6,0,0,'','normal','','2000-03-09 10:42:44',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
 
179
#INSERT INTO t1 VALUES (8,0,0,'','major','','2000-03-09 11:32:14',20000321114747,'','','All','P3','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
 
180
#INSERT INTO t1 VALUES (5,0,0,'','enhancement','','2000-03-09 10:38:59',20000321114747,'','','All','P5','CCC/CCCCCC','PC',5,'7.00','Administration','','',0,'',0);
 
181
#INSERT INTO t1 VALUES (4,0,0,'','normal','','2000-03-08 18:32:14',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent2','','',0,'',0);
 
182
#INSERT INTO t1 VALUES (3,0,0,'','normal','','2000-03-08 18:30:52',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
 
183
#INSERT INTO t1 VALUES (2,0,0,'','enhancement','','2000-03-08 18:24:51',20000321114747,'','','All','P2','TestProduct','Other',4,'other','TestComponent2','','',0,'',0);
 
184
#INSERT INTO t1 VALUES (11,0,0,'','blocker','','2000-03-13 09:43:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
 
185
#INSERT INTO t1 VALUES (12,0,0,'','normal','','2000-03-13 16:14:31',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
 
186
#INSERT INTO t1 VALUES (13,0,0,'','normal','','2000-03-15 16:20:44',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
 
187
#INSERT INTO t1 VALUES (14,0,0,'','blocker','','2000-03-15 18:13:47',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
 
188
#INSERT INTO t1 VALUES (15,0,0,'','minor','','2000-03-16 18:03:28',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
 
189
#INSERT INTO t1 VALUES (16,0,0,'','normal','','2000-03-16 18:33:41',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
 
190
#INSERT INTO t1 VALUES (17,0,0,'','normal','','2000-03-16 18:34:18',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
 
191
#INSERT INTO t1 VALUES (18,0,0,'','normal','','2000-03-16 18:34:56',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
 
192
#INSERT INTO t1 VALUES (19,0,0,'','enhancement','','2000-03-16 18:35:34',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
 
193
#INSERT INTO t1 VALUES (20,0,0,'','enhancement','','2000-03-16 18:36:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
 
194
#INSERT INTO t1 VALUES (21,0,0,'','enhancement','','2000-03-16 18:37:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
 
195
#INSERT INTO t1 VALUES (22,0,0,'','enhancement','','2000-03-16 18:38:16',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
 
196
#INSERT INTO t1 VALUES (23,0,0,'','normal','','2000-03-16 18:58:12',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
 
197
#INSERT INTO t1 VALUES (24,0,0,'','normal','','2000-03-17 11:08:10',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
 
198
#INSERT INTO t1 VALUES (25,0,0,'','normal','','2000-03-17 11:10:45',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
 
199
#INSERT INTO t1 VALUES (26,0,0,'','normal','','2000-03-17 11:15:47',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
 
200
#INSERT INTO t1 VALUES (27,0,0,'','normal','','2000-03-17 17:45:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
 
201
#INSERT INTO t1 VALUES (28,0,0,'','normal','','2000-03-20 09:51:45',20000321114747,'','','Windows NT','P2','TestProduct','PC',8,'other','TestComponent','','',0,'',0);
 
202
#INSERT INTO t1 VALUES (29,0,0,'','normal','','2000-03-20 11:15:09',20000321114747,'','','All','P5','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
 
203
#CREATE TABLE t2 (
 
204
#  value text,
 
205
#  program varchar(64),
 
206
#  initialowner text NOT NULL,
 
207
#  initialqacontact text NOT NULL,
 
208
#  description text NOT NULL
 
209
#);
 
210
#
 
211
#INSERT INTO t2 VALUES ('TestComponent','TestProduct','id0001','','');
 
212
#INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - conversion','AAAAA','id0001','','');
 
213
#INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - generic','AAAAA','id0001','','');
 
214
#INSERT INTO t2 VALUES ('TestComponent2','TestProduct','id0001','','');
 
215
#INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - eeeeeeeee','AAAAA','id0001','','');
 
216
#INSERT INTO t2 VALUES ('kkkkkkkkkkk lllllllllll','AAAAA','id0001','','');
 
217
#INSERT INTO t2 VALUES ('Test Procedures','AAAAA','id0001','','');
 
218
#INSERT INTO t2 VALUES ('Documentation','AAAAA','id0003','','');
 
219
#INSERT INTO t2 VALUES ('DDDDDDDDD','CCC/CCCCCC','id0002','','');
 
220
#INSERT INTO t2 VALUES ('Eeeeeeee Lite','CCC/CCCCCC','id0002','','');
 
221
#INSERT INTO t2 VALUES ('Eeeeeeee Full','CCC/CCCCCC','id0002','','');
 
222
#INSERT INTO t2 VALUES ('Administration','CCC/CCCCCC','id0002','','');
 
223
#INSERT INTO t2 VALUES ('Distribution','CCC/CCCCCC','id0002','','');
 
224
#INSERT INTO t2 VALUES ('Setup','CCC/CCCCCC','id0002','','');
 
225
#INSERT INTO t2 VALUES ('Unspecified','CCC/CCCCCC','id0002','','');
 
226
#INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','','');
 
227
#INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','','');
 
228
#select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA";
 
229
#select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value;
 
230
#select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2);
 
231
#
 
232
#drop table t1,t2;
231
233
 
232
234
#
233
235
# Problem with functions and group functions when no matching rows
244
246
# Test GROUP BY DESC
245
247
 
246
248
CREATE TABLE t1 (
247
 
  spID int(10),
248
 
  userID int(10),
249
 
  score int(5),
 
249
  spID int,
 
250
  userID int,
 
251
  score int,
250
252
  key (spid),
251
253
  key (score)
252
254
);
288
290
SELECT binary a FROM t1 GROUP BY 1;
289
291
SELECT binary a,count(*) FROM t1 GROUP BY 1;
290
292
# Do the same tests with MyISAM temporary tables
291
 
SET SQL_BIG_TABLES=1;
292
293
SELECT a FROM t1 GROUP BY a;
293
294
SELECT a,count(*) FROM t1 GROUP BY a;
294
295
SELECT a FROM t1 GROUP BY binary a;
295
296
SELECT a,count(*) FROM t1 GROUP BY binary a;
296
297
SELECT binary a FROM t1 GROUP BY 1;
297
298
SELECT binary a,count(*) FROM t1 GROUP BY 1;
298
 
SET SQL_BIG_TABLES=0;
299
299
drop table t1;
300
300
 
301
301
#
348
348
#
349
349
 
350
350
CREATE TABLE t1 (
351
 
  pid int(11) NOT NULL default '0',
352
 
  c1id int(11) default NULL,
353
 
  c2id int(11) default NULL,
354
 
  value int(11) NOT NULL default '0',
 
351
  pid int NOT NULL default '0',
 
352
  c1id int default NULL,
 
353
  c2id int default NULL,
 
354
  value int NOT NULL default '0',
355
355
  UNIQUE KEY pid2 (pid,c1id,c2id),
356
356
  UNIQUE KEY pid (pid,value)
357
357
) ENGINE=MyISAM;
359
359
INSERT INTO t1 VALUES (1, 1, NULL, 1),(1, 2, NULL, 2),(1, NULL, 3, 3),(1, 4, NULL, 4),(1, 5, NULL, 5);
360
360
 
361
361
CREATE TABLE t2 (
362
 
  id int(11) NOT NULL default '0',
 
362
  id int NOT NULL default '0',
363
363
  active enum('Yes','No') NOT NULL default 'Yes',
364
364
  PRIMARY KEY  (id)
365
365
) ENGINE=MyISAM;
367
367
INSERT INTO t2 VALUES (1, 'Yes'),(2, 'No'),(4, 'Yes'),(5, 'No');
368
368
 
369
369
CREATE TABLE t3 (
370
 
  id int(11) NOT NULL default '0',
 
370
  id int NOT NULL default '0',
371
371
  active enum('Yes','No') NOT NULL default 'Yes',
372
372
  PRIMARY KEY  (id)
373
373
);
389
389
create table t1 (a blob null);
390
390
insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(""),(""),(""),("b");
391
391
select a,count(*) from t1 group by a;
392
 
set option sql_big_tables=1;
393
392
select a,count(*) from t1 group by a;
394
393
drop table t1;
395
394
 
439
438
# NULL is used.
440
439
#
441
440
CREATE TABLE t1 (
442
 
  userid int(10),
443
 
  score int(5),
 
441
  userid int,
 
442
  score int,
444
443
  key (score)
445
444
);
446
445
INSERT INTO t1 VALUES (1,1),(2,2),(1,1),(3,3),(3,3),(3,3),(3,3),(3,3);
451
450
EXPLAIN SELECT userid,count(*) FROM t1 GROUP BY userid DESC;
452
451
DROP TABLE t1;
453
452
CREATE TABLE t1 (
454
 
  i int(11) default NULL,
455
 
  j int(11) default NULL
 
453
  i int default NULL,
 
454
  j int default NULL
456
455
);
457
456
INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5);
458
457
SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
502
501
  d varchar(100) NOT NULL,
503
502
  primary key (a,b(132),c,d),
504
503
  key a (a,b)
505
 
) charset=utf8;
 
504
);
506
505
 
507
506
insert into t2 select 
508
507
   x3.a,  -- 3
520
519
# Test for BUG#9298 "Wrong handling of int4 columns in GROUP functions"
521
520
# (the actual problem was with protocol code, not GROUP BY)
522
521
create table t1 (b int4 not null);
523
 
insert into t1 values(3000000000);
 
522
insert into t1 values(300000);
524
523
select * from t1;
525
524
select min(b) from t1;
526
525
drop table t1;
637
636
# returns empty
638
637
639
638
CREATE TABLE t1 (
640
 
    f1 int(10) NOT NULL auto_increment primary key,
 
639
    f1 int NOT NULL auto_increment primary key,
641
640
    f2 varchar(100) NOT NULL default ''
642
641
);
643
642
CREATE TABLE t2 (