~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/r/type_varchar.result

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1, t2;
 
2
create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text);
 
3
show create table t1;
 
4
Table   Create Table
 
5
t1      CREATE TABLE `t1` (
 
6
  `v` varchar(30) DEFAULT NULL,
 
7
  `c` varchar(3) DEFAULT NULL,
 
8
  `e` enum('abc','def','ghi') DEFAULT NULL,
 
9
  `t` text
 
10
) ENGINE=DEFAULT
 
11
insert into t1 values ('abc', 'de', 'ghi', 'jkl');
 
12
insert into t1 values ('abc ', 'de ', 'ghi', 'jkl ');
 
13
insert into t1 values ('abc    ', 'd  ', 'ghi', 'jkl    ');
 
14
select length(v),length(c),length(e),length(t) from t1;
 
15
length(v)       length(c)       length(e)       length(t)
 
16
3       2       3       3
 
17
4       3       3       4
 
18
7       3       3       7
 
19
drop table t1;
 
20
create table t1 (v varchar(20));
 
21
insert into t1 values('a ');
 
22
select v='a' from t1;
 
23
v='a'
 
24
1
 
25
select binary v='a' from t1;
 
26
binary v='a'
 
27
0
 
28
select binary v='a ' from t1;
 
29
binary v='a '
 
30
1
 
31
insert into t1 values('a');
 
32
alter table t1 add primary key (v);
 
33
ERROR 23000: Duplicate entry 'a' for key 'PRIMARY'
 
34
drop table t1;
 
35
create table t1 (v varbinary(20));
 
36
insert into t1 values('a');
 
37
insert into t1 values('a ');
 
38
alter table t1 add primary key (v);
 
39
drop table t1;
 
40
create table t1 (v varchar(254), index (v));
 
41
Warnings:
 
42
Warning 1071    Specified key was too long; max key length is 767 bytes
 
43
insert into t1 values ("This is a test ");
 
44
insert into t1 values ("Some sample data");
 
45
insert into t1 values (" garbage ");
 
46
insert into t1 values (" This is a test ");
 
47
insert into t1 values ("This is a test");
 
48
insert into t1 values ("Hello world");
 
49
insert into t1 values ("Foo bar");
 
50
insert into t1 values ("This is a test");
 
51
insert into t1 values ("MySQL varchar test");
 
52
insert into t1 values ("test MySQL varchar");
 
53
insert into t1 values ("This is a long string to have some random length data included");
 
54
insert into t1 values ("Short string");
 
55
insert into t1 values ("VSS");
 
56
insert into t1 values ("Some samples");
 
57
insert into t1 values ("Bar foo");
 
58
insert into t1 values ("Bye");
 
59
select * from t1 where v like 'This is a test' order by v;
 
60
v
 
61
This is a test
 
62
This is a test
 
63
select * from t1 where v='This is a test' order by v;
 
64
v
 
65
This is a test 
 
66
This is a test
 
67
This is a test
 
68
select * from t1 where v like 'S%' order by v;
 
69
v
 
70
Short string
 
71
Some sample data
 
72
Some samples
 
73
explain select * from t1 where v like 'This is a test' order by v;
 
74
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
75
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
76
explain select * from t1 where v='This is a test' order by v;
 
77
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
78
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
79
explain select * from t1 where v like 'S%' order by v;
 
80
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
81
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
82
alter table t1 change v v varchar(255);
 
83
select * from t1 where v like 'This is a test' order by v;
 
84
v
 
85
This is a test
 
86
This is a test
 
87
select * from t1 where v='This is a test' order by v;
 
88
v
 
89
This is a test 
 
90
This is a test
 
91
This is a test
 
92
select * from t1 where v like 'S%' order by v;
 
93
v
 
94
Short string
 
95
Some sample data
 
96
Some samples
 
97
explain select * from t1 where v like 'This is a test' order by v;
 
98
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
99
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
100
explain select * from t1 where v='This is a test' order by v;
 
101
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
102
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
103
explain select * from t1 where v like 'S%' order by v;
 
104
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
105
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
106
alter table t1 change v v varchar(256);
 
107
select * from t1 where v like 'This is a test' order by v;
 
108
v
 
109
This is a test
 
110
This is a test
 
111
select * from t1 where v='This is a test' order by v;
 
112
v
 
113
This is a test 
 
114
This is a test
 
115
This is a test
 
116
select * from t1 where v like 'S%' order by v;
 
117
v
 
118
Short string
 
119
Some sample data
 
120
Some samples
 
121
explain select * from t1 where v like 'This is a test' order by v;
 
122
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
123
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
124
explain select * from t1 where v='This is a test' order by v;
 
125
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
126
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
127
explain select * from t1 where v like 'S%' order by v;
 
128
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
129
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
130
alter table t1 change v v varchar(257);
 
131
select * from t1 where v like 'This is a test' order by v;
 
132
v
 
133
This is a test
 
134
This is a test
 
135
select * from t1 where v='This is a test' order by v;
 
136
v
 
137
This is a test 
 
138
This is a test
 
139
This is a test
 
140
select * from t1 where v like 'S%' order by v;
 
141
v
 
142
Short string
 
143
Some sample data
 
144
Some samples
 
145
explain select * from t1 where v like 'This is a test' order by v;
 
146
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
147
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
148
explain select * from t1 where v='This is a test' order by v;
 
149
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
150
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
151
explain select * from t1 where v like 'S%' order by v;
 
152
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
153
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
154
alter table t1 change v v varchar(258);
 
155
select * from t1 where v like 'This is a test' order by v;
 
156
v
 
157
This is a test
 
158
This is a test
 
159
select * from t1 where v='This is a test' order by v;
 
160
v
 
161
This is a test 
 
162
This is a test
 
163
This is a test
 
164
select * from t1 where v like 'S%' order by v;
 
165
v
 
166
Short string
 
167
Some sample data
 
168
Some samples
 
169
explain select * from t1 where v like 'This is a test' order by v;
 
170
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
171
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
172
explain select * from t1 where v='This is a test' order by v;
 
173
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
174
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
175
explain select * from t1 where v like 'S%' order by v;
 
176
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
177
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
178
alter table t1 change v v varchar(259);
 
179
select * from t1 where v like 'This is a test' order by v;
 
180
v
 
181
This is a test
 
182
This is a test
 
183
select * from t1 where v='This is a test' order by v;
 
184
v
 
185
This is a test 
 
186
This is a test
 
187
This is a test
 
188
select * from t1 where v like 'S%' order by v;
 
189
v
 
190
Short string
 
191
Some sample data
 
192
Some samples
 
193
explain select * from t1 where v like 'This is a test' order by v;
 
194
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
195
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
196
explain select * from t1 where v='This is a test' order by v;
 
197
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
198
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
199
explain select * from t1 where v like 'S%' order by v;
 
200
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
201
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
202
alter table t1 change v v varchar(258);
 
203
select * from t1 where v like 'This is a test' order by v;
 
204
v
 
205
This is a test
 
206
This is a test
 
207
select * from t1 where v='This is a test' order by v;
 
208
v
 
209
This is a test 
 
210
This is a test
 
211
This is a test
 
212
select * from t1 where v like 'S%' order by v;
 
213
v
 
214
Short string
 
215
Some sample data
 
216
Some samples
 
217
explain select * from t1 where v like 'This is a test' order by v;
 
218
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
219
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
220
explain select * from t1 where v='This is a test' order by v;
 
221
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
222
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
223
explain select * from t1 where v like 'S%' order by v;
 
224
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
225
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
226
alter table t1 change v v varchar(257);
 
227
select * from t1 where v like 'This is a test' order by v;
 
228
v
 
229
This is a test
 
230
This is a test
 
231
select * from t1 where v='This is a test' order by v;
 
232
v
 
233
This is a test 
 
234
This is a test
 
235
This is a test
 
236
select * from t1 where v like 'S%' order by v;
 
237
v
 
238
Short string
 
239
Some sample data
 
240
Some samples
 
241
explain select * from t1 where v like 'This is a test' order by v;
 
242
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
243
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
244
explain select * from t1 where v='This is a test' order by v;
 
245
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
246
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
247
explain select * from t1 where v like 'S%' order by v;
 
248
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
249
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
250
alter table t1 change v v varchar(256);
 
251
select * from t1 where v like 'This is a test' order by v;
 
252
v
 
253
This is a test
 
254
This is a test
 
255
select * from t1 where v='This is a test' order by v;
 
256
v
 
257
This is a test 
 
258
This is a test
 
259
This is a test
 
260
select * from t1 where v like 'S%' order by v;
 
261
v
 
262
Short string
 
263
Some sample data
 
264
Some samples
 
265
explain select * from t1 where v like 'This is a test' order by v;
 
266
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
267
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
268
explain select * from t1 where v='This is a test' order by v;
 
269
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
270
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
271
explain select * from t1 where v like 'S%' order by v;
 
272
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
273
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
274
alter table t1 change v v varchar(255);
 
275
select * from t1 where v like 'This is a test' order by v;
 
276
v
 
277
This is a test
 
278
This is a test
 
279
select * from t1 where v='This is a test' order by v;
 
280
v
 
281
This is a test 
 
282
This is a test
 
283
This is a test
 
284
select * from t1 where v like 'S%' order by v;
 
285
v
 
286
Short string
 
287
Some sample data
 
288
Some samples
 
289
explain select * from t1 where v like 'This is a test' order by v;
 
290
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
291
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
292
explain select * from t1 where v='This is a test' order by v;
 
293
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
294
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
295
explain select * from t1 where v like 'S%' order by v;
 
296
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
297
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
298
alter table t1 change v v varchar(254);
 
299
select * from t1 where v like 'This is a test' order by v;
 
300
v
 
301
This is a test
 
302
This is a test
 
303
select * from t1 where v='This is a test' order by v;
 
304
v
 
305
This is a test 
 
306
This is a test
 
307
This is a test
 
308
select * from t1 where v like 'S%' order by v;
 
309
v
 
310
Short string
 
311
Some sample data
 
312
Some samples
 
313
explain select * from t1 where v like 'This is a test' order by v;
 
314
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
315
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
316
explain select * from t1 where v='This is a test' order by v;
 
317
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
318
1       SIMPLE  t1      ref     v       v       767     const   3       Using where
 
319
explain select * from t1 where v like 'S%' order by v;
 
320
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
321
1       SIMPLE  t1      range   v       v       767     NULL    3       Using where; Using filesort
 
322
alter table t1 change v v varchar(253);
 
323
alter table t1 change v v varchar(254), drop key v;
 
324
alter table t1 change v v varchar(300), add key (v(10));
 
325
select * from t1 where v like 'This is a test' order by v;
 
326
v
 
327
This is a test
 
328
This is a test
 
329
select * from t1 where v='This is a test' order by v;
 
330
v
 
331
This is a test 
 
332
This is a test
 
333
This is a test
 
334
Warnings:
 
335
Warning 1265    Data truncated for column 'v' at row 1
 
336
select * from t1 where v like 'S%' order by v;
 
337
v
 
338
Short string
 
339
Some sample data
 
340
Some samples
 
341
explain select * from t1 where v like 'This is a test' order by v;
 
342
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
343
1       SIMPLE  t1      range   v       v       43      NULL    4       Using where; Using filesort
 
344
explain select * from t1 where v='This is a test' order by v;
 
345
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
346
1       SIMPLE  t1      ref     v       v       43      const   4       Using where
 
347
Warnings:
 
348
Warning 1265    Data truncated for column 'v' at row 1
 
349
explain select * from t1 where v like 'S%' order by v;
 
350
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
351
1       SIMPLE  t1      range   v       v       43      NULL    3       Using where; Using filesort
 
352
drop table t1;
 
353
create table t1 (pkcol varchar(16), othercol varchar(16), primary key (pkcol));
 
354
insert into t1 values ('test', 'something');
 
355
update t1 set othercol='somethingelse' where pkcol='test';
 
356
select * from t1;
 
357
pkcol   othercol
 
358
test    somethingelse
 
359
drop table t1;
 
360
create table t1 (a int, b varchar(12));
 
361
insert into t1 values (1, 'A'), (22, NULL);
 
362
create table t2 (a int);
 
363
insert into t2 values (22), (22);
 
364
select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a 
 
365
group by t1.b, t1.a;
 
366
a       b       min(t1.b)
 
367
22      NULL    NULL
 
368
drop table t1, t2;
 
369
create table t1 (f1 varchar(6500));
 
370
create index index1 on t1(f1(10));
 
371
show create table t1;
 
372
Table   Create Table
 
373
t1      CREATE TABLE `t1` (
 
374
  `f1` varchar(6500) DEFAULT NULL,
 
375
  KEY `index1` (`f1`(10))
 
376
) ENGINE=DEFAULT
 
377
alter table t1 modify f1 varchar(255);
 
378
show create table t1;
 
379
Table   Create Table
 
380
t1      CREATE TABLE `t1` (
 
381
  `f1` varchar(255) DEFAULT NULL,
 
382
  KEY `index1` (`f1`(10))
 
383
) ENGINE=DEFAULT
 
384
alter table t1 modify f1 tinytext;
 
385
show create table t1;
 
386
Table   Create Table
 
387
t1      CREATE TABLE `t1` (
 
388
  `f1` text,
 
389
  KEY `index1` (`f1`(10))
 
390
) ENGINE=DEFAULT
 
391
drop table t1;
 
392
DROP TABLE IF EXISTS t1;
 
393
CREATE TABLE t1(f1 VARCHAR(100) DEFAULT 'test');
 
394
INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
 
395
DROP TABLE IF EXISTS t1;
 
396
CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test');
 
397
INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
 
398
DROP TABLE IF EXISTS t1;
 
399
drop table if exists t1, t2, t3;
 
400
create table t3 (
 
401
id int,
 
402
en varchar(255),
 
403
cz varchar(255)
 
404
);
 
405
insert into t3 (id, en, cz) values 
 
406
(1,'en string 1','cz string 1'),
 
407
(2,'en string 2','cz string 2'),
 
408
(3,'en string 3','cz string 3');
 
409
create table t1 ( 
 
410
id int,
 
411
name_id int
 
412
);
 
413
insert into t1 (id, name_id) values (1,1), (2,3), (3,3);
 
414
create table t2 (id int);
 
415
insert into t2 (id) values (1), (2), (3);
 
416
select t1.*, t2.id, t3.en, t3.cz from t1 left join t2 on t1.id=t2.id
 
417
left join t3 on t1.id=t3.id order by t3.id;
 
418
Catalog Database        Table   Table_alias     Column  Column_alias    Type    Length  Max length      Is_null Flags   Decimals        Charsetnr
 
419
def     test    t1      t1      id      id      1       11      1       Y       32768   0       63
 
420
def     test    t1      t1      name_id name_id 1       11      1       Y       32768   0       63
 
421
def     test    t2      t2      id      id      1       11      1       Y       32768   0       63
 
422
def     test    t3      t3      en      en      8       1020    11      Y       0       0       45
 
423
def     test    t3      t3      cz      cz      8       1020    11      Y       0       0       45
 
424
id      name_id id      en      cz
 
425
1       1       1       en string 1     cz string 1
 
426
2       3       2       en string 2     cz string 2
 
427
3       3       3       en string 3     cz string 3
 
428
drop table t1, t2, t3;
 
429
CREATE TABLE t1 (a varchar(2));
 
430
INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t');
 
431
SELECT a,(a + 0) FROM t1 ORDER BY a;
 
432
a       (a + 0)
 
433
10      10
 
434
1a      1
 
435
30      30
 
436
50      50
 
437
60      60
 
438
t       0
 
439
SELECT a,(a DIV 2) FROM t1 ORDER BY a;
 
440
a       (a DIV 2)
 
441
10      5
 
442
1a      0
 
443
30      15
 
444
50      25
 
445
60      30
 
446
t       0
 
447
DROP TABLE t1;