4 #include "my_compare.h"
7 - /* defines used by heap-funktions */
8 +/* Define index limits to be identical to MyISAM ones for compatibility. */
10 +#if MAX_INDEXES > HA_MAX_POSSIBLE_KEY
11 +#define HP_MAX_KEY HA_MAX_POSSIBLE_KEY /* Max allowed keys */
13 +#define HP_MAX_KEY MAX_INDEXES /* Max allowed keys */
16 +#define HP_MAX_KEY_LENGTH 1000 /* Max length in bytes */
18 +/* defines used by heap-funktions */
20 #define HP_MAX_LEVELS 4 /* 128^5 records is enough */
21 #define HP_PTRS_IN_NOD 128
23 uint (*get_key_length)(struct st_hp_keydef *keydef, const uchar *key);
26 -typedef struct st_heap_share
27 +typedef struct st_heap_columndef /* column information */
29 + int16 type; /* en_fieldtype */
30 + uint32 length; /* length of field */
31 + uint32 offset; /* Offset to position in row */
32 + uint8 null_bit; /* If column may be 0 */
33 + uint16 null_pos; /* position for null marker */
34 + uint8 length_bytes; /* length of the size, 1 o 2 bytes */
37 +typedef struct st_heap_dataspace /* control data for data space */
40 + /* Total chunks ever allocated in this dataspace */
42 + uint del_chunk_count; /* Deleted chunks count */
43 + uchar *del_link; /* Link to last deleted chunk */
44 + uint chunk_length; /* Total length of one chunk */
45 + /* Length of payload that will be placed into one chunk */
46 + uint chunk_dataspace_length;
47 + /* Offset of the status flag relative to the chunk start */
49 + /* Offset of the linking pointer relative to the chunk start */
51 + /* Test whether records have variable size and so "next" pointer */
52 + uint is_variable_size;
53 + /* Total size allocated within this data space */
54 + ulonglong total_data_length;
57 +typedef struct st_heap_share
60 + HP_COLUMNDEF *column_defs;
61 + /* Describes "block", which contains actual records */
62 + HP_DATASPACE recordspace;
63 ulong min_records,max_records; /* Params to open */
64 - ulonglong data_length,index_length,max_table_size;
65 + ulonglong index_length, max_table_size;
66 uint key_stat_version; /* version to indicate insert/delete */
67 - uint records; /* records */
68 - uint blength; /* records rounded up to 2^n */
69 - uint deleted; /* Deleted records in database */
70 - uint reclength; /* Length of one record */
71 + uint records; /* Actual record (row) count */
72 + uint blength; /* used_chunk_count rounded up to 2^n */
74 + Length of record's fixed part, which contains keys and always fits into the
77 + uint fixed_data_length;
78 + uint fixed_column_count; /* Number of columns stored in fixed_data_length */
80 uint keys,max_key_length;
82 uint currently_disabled_keys; /* saved value from "keys" when disabled */
84 - uchar *del_link; /* Link to next block with del. rec */
85 char * name; /* Name of "memory-file" */
90 uint auto_key_type; /* real type of the auto key segment */
91 ulonglong auto_increment;
92 + uint blobs; /* Number of blobs in table */
95 struct st_hp_hash_info;
99 struct st_hp_hash_info *current_hash_ptr;
100 - ulong current_record,next_block;
101 + ulong current_record;
103 int mode; /* Mode of file (READONLY..) */
104 uint opt_flag,update;
106 my_bool implicit_emptied;
109 + uchar *blob_buffer; /* Temporary buffer used to return BLOB values */
110 + uint blob_size; /* Current blob_buffer size */
111 + uint blob_offset; /* Current offset in blob_buffer */
116 open_count to 1. Is only looked at if not internal_table.
120 + HP_COLUMNDEF *columndef;
121 + uint fixed_key_fieldnr;
122 + uint fixed_data_size;
123 + uint keys_memory_size;
124 + uint max_chunk_size;
129 /* Prototypes for heap-functions */
131 extern int heap_scan(register HP_INFO *info, uchar *record);
132 extern int heap_delete(HP_INFO *info,const uchar *buff);
133 extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag);
134 -extern int heap_create(const char *name,
135 - HP_CREATE_INFO *create_info, HP_SHARE **share,
136 - my_bool *created_new_share);
137 +extern int heap_create(const char *name, HP_CREATE_INFO *create_info,
138 + HP_SHARE **res, my_bool *created_new_share);
139 extern int heap_delete_table(const char *name);
140 extern void heap_drop_table(HP_INFO *info);
141 extern int heap_extra(HP_INFO *info,enum ha_extra_function function);
142 --- a/mysql-test/r/create.result
143 +++ b/mysql-test/r/create.result
145 create table t1 (b char(0) not null, index(b));
146 ERROR 42000: The used storage engine can't index column 'b'
147 create table t1 (a int not null,b text) engine=heap;
148 -ERROR 42000: The used table type doesn't support BLOB/TEXT columns
149 drop table if exists t1;
151 -Note 1051 Unknown table 't1'
152 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) engine=heap;
153 ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
154 create table not_existing_database.test (a int);
155 --- a/mysql-test/r/ctype_utf8mb4_heap.result
156 +++ b/mysql-test/r/ctype_utf8mb4_heap.result
157 @@ -1124,6 +1124,8 @@
158 a varchar(255) NOT NULL default '',
160 ) ENGINE=heap DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
162 +Warning 1071 Specified key was too long; max key length is 1000 bytes
163 insert into t1 values (_utf8mb4 0xe880bd);
164 insert into t1 values (_utf8mb4 0x5b);
165 select hex(a) from t1;
166 @@ -1162,6 +1164,8 @@
168 Note 1051 Unknown table 't1'
169 CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=heap DEFAULT CHARSET=utf8mb4;
171 +Warning 1071 Specified key was too long; max key length is 1000 bytes
172 INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̀ˆbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
173 INSERT INTO t1 VALUES('uu');
175 --- a/mysql-test/t/create.test
176 +++ b/mysql-test/t/create.test
178 drop table if exists t1,t2;
180 create table t1 (b char(0) not null, index(b));
182 +# BLOB/TEXT fields are now supported by HEAP
183 create table t1 (a int not null,b text) engine=heap;
184 drop table if exists t1;
186 --- a/storage/heap/CMakeLists.txt
187 +++ b/storage/heap/CMakeLists.txt
190 hp_delete.c hp_extra.c hp_hash.c hp_info.c hp_open.c hp_panic.c
191 hp_rename.c hp_rfirst.c hp_rkey.c hp_rlast.c hp_rnext.c hp_rprev.c
192 + hp_dspace.c hp_record.c
193 hp_rrnd.c hp_rsame.c hp_scan.c hp_static.c hp_update.c hp_write.c)
195 MYSQL_ADD_PLUGIN(heap ${HEAP_SOURCES} STORAGE_ENGINE MANDATORY RECOMPILE_FOR_EMBEDDED)
196 --- a/storage/heap/_check.c
197 +++ b/storage/heap/_check.c
202 - ulong records=0, deleted=0, pos, next_block;
203 + ulong records= 0, deleted= 0, chunk_count= 0, pos, next_block;
204 HP_SHARE *share=info->s;
205 HP_INFO save_info= *info; /* Needed because scan_init */
206 DBUG_ENTER("heap_check_heap");
209 if (pos < next_block)
211 - info->current_ptr+= share->block.recbuffer;
212 + info->current_ptr+= share->recordspace.block.recbuffer;
216 - next_block+= share->block.records_in_block;
217 - if (next_block >= share->records+share->deleted)
218 + next_block+= share->recordspace.block.records_in_block;
219 + if (next_block >= share->recordspace.chunk_count)
221 - next_block= share->records+share->deleted;
222 - if (pos >= next_block)
223 - break; /* End of file */
224 + next_block= share->recordspace.chunk_count;
225 + if (pos >= next_block)
226 + break; /* End of file */
229 hp_find_record(info,pos);
231 - if (!info->current_ptr[share->reclength])
232 + switch (get_chunk_status(&share->recordspace, info->current_ptr)) {
233 + case CHUNK_STATUS_DELETED:
238 + case CHUNK_STATUS_ACTIVE:
242 + case CHUNK_STATUS_LINKED:
246 + DBUG_PRINT("error",
247 + ("Unknown record status: Record: 0x%lx Status %lu",
248 + (long) info->current_ptr,
249 + (ulong) get_chunk_status(&share->recordspace,
250 + info->current_ptr)));
256 - if (records != share->records || deleted != share->deleted)
258 - DBUG_PRINT("error",("Found rows: %lu (%lu) deleted %lu (%lu)",
259 - records, (ulong) share->records,
260 - deleted, (ulong) share->deleted));
261 + /* TODO: verify linked chunks (no orphans, no cycles, no bad links) */
263 + if (records != share->records ||
264 + chunk_count != share->recordspace.chunk_count ||
265 + deleted != share->recordspace.del_chunk_count)
267 + DBUG_PRINT("error",
268 + ("Found rows: %lu (%lu) total chunks %lu (%lu) deleted chunks "
270 + records, (ulong) share->records,
271 + chunk_count, (ulong) share->recordspace.chunk_count,
272 + deleted, (ulong) share->recordspace.del_chunk_count));
279 memcpy(&recpos, key + (*keydef->get_key_length)(keydef,key), sizeof(uchar*));
280 - key_length= hp_rb_make_key(keydef, info->recbuf, recpos, 0);
281 + key_length= hp_rb_make_key(keydef, info->recbuf, recpos, 0, TRUE);
282 if (ha_key_cmp(keydef->seg, (uchar*) info->recbuf, (uchar*) key,
283 key_length, SEARCH_FIND | SEARCH_SAME, not_used))
285 --- a/storage/heap/_rectest.c
286 +++ b/storage/heap/_rectest.c
289 DBUG_ENTER("hp_rectest");
291 - if (memcmp(info->current_ptr,old,(size_t) info->s->reclength))
292 + if (hp_process_record_data_to_chunkset(info->s, old,
296 DBUG_RETURN((my_errno=HA_ERR_RECORD_CHANGED)); /* Record have changed */
298 --- a/storage/heap/ha_heap.cc
299 +++ b/storage/heap/ha_heap.cc
302 rc= heap_create(name, &create_info, &internal_share, &created_new_share);
303 my_free(create_info.keydef);
304 + my_free(create_info.columndef);
310 if (table->key_info[i].algorithm == HA_KEY_ALG_BTREE)
311 btree_keys.set_bit(i);
313 + Reset per-key block size specification so they are not shown
314 + in SHOW CREATE TABLE.
316 + table->key_info[i].block_size= 0;
317 + table->key_info[i].flags&= ~HA_USES_BLOCK_SIZE;
325 +enum row_type ha_heap::get_row_type() const
327 + if (file->s->recordspace.is_variable_size)
328 + return ROW_TYPE_DYNAMIC;
330 + return ROW_TYPE_FIXED;
333 int ha_heap::extra(enum ha_extra_function operation)
335 @@ -646,23 +660,70 @@
336 heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table,
337 HP_CREATE_INFO *hp_create_info)
339 - uint key, parts, mem_per_row= 0, keys= table_arg->s->keys;
340 + uint key, parts, mem_per_row_keys= 0, keys= table_arg->s->keys;
341 uint auto_key= 0, auto_key_type= 0;
343 + uint fixed_key_fieldnr = 0, fixed_data_size = 0, next_field_pos = 0;
344 + uint column_idx, column_count= table_arg->s->fields;
345 + HP_COLUMNDEF *columndef;
348 TABLE_SHARE *share= table_arg->s;
349 bool found_real_auto_increment= 0;
352 bzero(hp_create_info, sizeof(*hp_create_info));
354 + if (!(columndef= (HP_COLUMNDEF*) my_malloc(column_count *
355 + sizeof(HP_COLUMNDEF),
359 + for (column_idx= 0; column_idx < column_count; column_idx++)
361 + Field* field= *(table_arg->field + column_idx);
362 + HP_COLUMNDEF* column= columndef + column_idx;
363 + column->type= (uint16) field->type();
364 + column->length= field->pack_length();
365 + column->offset= field->offset(table_arg->record[0]);
367 + if (field->null_bit)
369 + column->null_bit= field->null_bit;
370 + column->null_pos= (uint) (field->null_ptr -
371 + (uchar*) table_arg->record[0]);
375 + column->null_bit= 0;
376 + column->null_pos= 0;
379 + if (field->type() == MYSQL_TYPE_VARCHAR)
381 + column->length_bytes= (uint8) (((Field_varstring *) field)->length_bytes);
383 + else if (field->type() == MYSQL_TYPE_BLOB)
386 + column->length_bytes= (uint8)
387 + (((Field_blob *) field)->pack_length_no_ptr());
391 + column->length_bytes= 0;
395 for (key= parts= 0; key < keys; key++)
396 parts+= table_arg->key_info[key].key_parts;
398 if (!(keydef= (HP_KEYDEF*) my_malloc(keys * sizeof(HP_KEYDEF) +
399 parts * sizeof(HA_KEYSEG),
402 + my_free((uchar *) columndef);
405 seg= reinterpret_cast<HA_KEYSEG*>(keydef + keys);
406 for (key= 0; key < keys; key++)
408 @@ -678,11 +739,11 @@
409 case HA_KEY_ALG_UNDEF:
410 case HA_KEY_ALG_HASH:
411 keydef[key].algorithm= HA_KEY_ALG_HASH;
412 - mem_per_row+= sizeof(char*) * 2; // = sizeof(HASH_INFO)
413 + mem_per_row_keys+= sizeof(char*) * 2; // = sizeof(HASH_INFO)
415 case HA_KEY_ALG_BTREE:
416 keydef[key].algorithm= HA_KEY_ALG_BTREE;
417 - mem_per_row+=sizeof(TREE_ELEMENT)+pos->key_length+sizeof(char*);
418 + mem_per_row_keys+=sizeof(TREE_ELEMENT)+pos->key_length+sizeof(char*);
421 DBUG_ASSERT(0); // cannot happen
423 seg->length= (uint) key_part->length;
424 seg->flag= key_part->key_part_flag;
426 + next_field_pos= seg->start;
427 + if (field->type() == MYSQL_TYPE_VARCHAR)
429 + Field *orig_field= *(table_arg->field + key_part->field->field_index);
430 + next_field_pos+= orig_field->pack_length();
434 + next_field_pos+= seg->length;
436 if (field->flags & (ENUM_FLAG | SET_FLAG))
437 seg->charset= &my_charset_bin;
441 auto_key_type= field->key_type();
444 + switch (seg->type) {
445 + case HA_KEYTYPE_SHORT_INT:
446 + case HA_KEYTYPE_LONG_INT:
447 + case HA_KEYTYPE_FLOAT:
448 + case HA_KEYTYPE_DOUBLE:
449 + case HA_KEYTYPE_USHORT_INT:
450 + case HA_KEYTYPE_ULONG_INT:
451 + case HA_KEYTYPE_LONGLONG:
452 + case HA_KEYTYPE_ULONGLONG:
453 + case HA_KEYTYPE_INT24:
454 + case HA_KEYTYPE_UINT24:
455 + case HA_KEYTYPE_INT8:
456 + seg->flag|= HA_SWAP_KEY;
458 + case HA_KEYTYPE_VARBINARY1:
459 + /* Case-insensitiveness is handled in coll->hash_sort */
460 + seg->type= HA_KEYTYPE_VARTEXT1;
462 + case HA_KEYTYPE_VARTEXT1:
463 + keydef[key].flag|= HA_VAR_LENGTH_KEY;
464 + /* Save number of bytes used to store length */
465 + if (seg->flag & HA_BLOB_PART)
466 + seg->bit_start= field->pack_length() - share->blob_ptr_size;
470 + case HA_KEYTYPE_VARBINARY2:
471 + /* Case-insensitiveness is handled in coll->hash_sort */
473 + case HA_KEYTYPE_VARTEXT2:
474 + keydef[key].flag|= HA_VAR_LENGTH_KEY;
475 + /* Save number of bytes used to store length */
476 + if (seg->flag & HA_BLOB_PART)
477 + seg->bit_start= field->pack_length() - share->blob_ptr_size;
481 + Make future comparison simpler by only having to check for
484 + seg->type= HA_KEYTYPE_VARTEXT1;
490 + if (next_field_pos > fixed_data_size)
492 + fixed_data_size= next_field_pos;
496 + if (field->field_index >= fixed_key_fieldnr)
499 + Do not use seg->fieldnr as it's not reliable in case of temp tables
501 + fixed_key_fieldnr= field->field_index + 1;
505 - mem_per_row+= MY_ALIGN(share->reclength + 1, sizeof(char*));
507 + if (fixed_data_size < share->null_bytes)
509 + /* Make sure to include null fields regardless of the presense of keys */
510 + fixed_data_size = share->null_bytes;
513 if (table_arg->found_next_number_field)
515 keydef[share->next_number_index].flag|= HA_AUTO_KEY;
516 @@ -745,16 +882,19 @@
517 hp_create_info->max_table_size=current_thd->variables.max_heap_table_size;
518 hp_create_info->with_auto_increment= found_real_auto_increment;
519 hp_create_info->internal_table= internal_table;
521 - max_rows= (ha_rows) (hp_create_info->max_table_size / mem_per_row);
522 - if (share->max_rows && share->max_rows < max_rows)
523 - max_rows= share->max_rows;
525 - hp_create_info->max_records= (ulong) max_rows;
526 + hp_create_info->max_chunk_size= share->key_block_size;
527 + hp_create_info->is_dynamic= (share->row_type == ROW_TYPE_DYNAMIC);
528 + hp_create_info->columns= column_count;
529 + hp_create_info->columndef= columndef;
530 + hp_create_info->fixed_key_fieldnr= fixed_key_fieldnr;
531 + hp_create_info->fixed_data_size= fixed_data_size;
532 + hp_create_info->max_records= (ulong) share->max_rows;
533 hp_create_info->min_records= (ulong) share->min_rows;
534 hp_create_info->keys= share->keys;
535 hp_create_info->reclength= share->reclength;
536 + hp_create_info->keys_memory_size= mem_per_row_keys;
537 hp_create_info->keydef= keydef;
538 + hp_create_info->blobs= blobs;
543 create_info->auto_increment_value - 1 : 0);
544 error= heap_create(name, &hp_create_info, &internal_share, &created);
545 my_free(hp_create_info.keydef);
546 + my_free(hp_create_info.columndef);
547 DBUG_ASSERT(file == 0);
551 table->file->info(HA_STATUS_AUTO);
552 if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
553 create_info->auto_increment_value= stats.auto_increment_value;
554 + if (!(create_info->used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE))
556 + if (file->s->recordspace.is_variable_size)
557 + create_info->key_block_size= file->s->recordspace.chunk_length;
559 + create_info->key_block_size= 0;
563 void ha_heap::get_auto_increment(ulonglong offset, ulonglong increment,
564 --- a/storage/heap/ha_heap.h
565 +++ b/storage/heap/ha_heap.h
567 return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
570 - /* Rows also use a fixed-size format */
571 - enum row_type get_row_type() const { return ROW_TYPE_FIXED; }
572 + enum row_type get_row_type() const;
573 const char **bas_ext() const;
574 ulonglong table_flags() const
576 - return (HA_FAST_KEY_READ | HA_NO_BLOBS | HA_NULL_IN_KEY |
577 + return (HA_FAST_KEY_READ | HA_NULL_IN_KEY |
578 HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
579 HA_REC_NOT_IN_SEQ | HA_CAN_INSERT_DELAYED | HA_NO_TRANSACTIONS |
580 HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT);
582 HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR);
584 const key_map *keys_to_use_for_scanning() { return &btree_keys; }
585 - uint max_supported_keys() const { return MAX_KEY; }
586 - uint max_supported_key_part_length() const { return MAX_KEY_LENGTH; }
587 + uint max_supported_keys() const { return HP_MAX_KEY; }
588 + uint max_supported_key_length() const { return HP_MAX_KEY_LENGTH; }
589 + uint max_supported_key_part_length() const { return HP_MAX_KEY_LENGTH; }
591 { return (double) (stats.records+stats.deleted) / 20.0+10; }
592 double read_time(uint index, uint ranges, ha_rows rows)
593 --- a/storage/heap/heapdef.h
594 +++ b/storage/heap/heapdef.h
596 #define HP_MIN_RECORDS_IN_BLOCK 16
597 #define HP_MAX_RECORDS_IN_BLOCK 8192
599 +/* this chunk has been deleted and can be reused */
600 +#define CHUNK_STATUS_DELETED 0
601 +/* this chunk represents the first part of a live record */
602 +#define CHUNK_STATUS_ACTIVE 1
603 +/* this chunk is a continuation from another chunk (part of chunkset) */
604 +#define CHUNK_STATUS_LINKED 2
606 /* Some extern variables */
608 extern LIST *heap_open_list,*heap_share_list;
610 #define hp_find_hash(A,B) ((HASH_INFO*) hp_find_block((A),(B)))
612 /* Find pos for record and update it in info->current_ptr */
613 -#define hp_find_record(info,pos) (info)->current_ptr= hp_find_block(&(info)->s->block,pos)
614 +#define hp_find_record(info,pos) \
615 + (info)->current_ptr= hp_find_block(&(info)->s->recordspace.block,pos)
617 +#define get_chunk_status(info,ptr) (ptr[(info)->offset_status])
619 +#define get_chunk_count(info,rec_length) \
620 + ((rec_length + (info)->chunk_dataspace_length - 1) / \
621 + (info)->chunk_dataspace_length)
623 typedef struct st_hp_hash_info
627 extern void hp_make_key(HP_KEYDEF *keydef,uchar *key,const uchar *rec);
628 extern uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
629 - const uchar *rec, uchar *recpos);
630 + const uchar *rec, uchar *recpos, my_bool packed);
631 extern uint hp_rb_key_length(HP_KEYDEF *keydef, const uchar *key);
632 extern uint hp_rb_null_key_length(HP_KEYDEF *keydef, const uchar *key);
633 extern uint hp_rb_var_key_length(HP_KEYDEF *keydef, const uchar *key);
635 extern void hp_clear_keys(HP_SHARE *info);
636 extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
637 key_part_map keypart_map);
638 +extern uint hp_calc_blob_length(uint length, const uchar *pos);
640 +/* Chunkset management (alloc/free/encode/decode) functions */
641 +extern uchar *hp_allocate_chunkset(HP_DATASPACE *info, uint chunk_count);
642 +extern int hp_reallocate_chunkset(HP_DATASPACE *info, uint chunk_count,
644 +extern void hp_free_chunks(HP_DATASPACE *info, uchar *pos);
645 +extern void hp_clear_dataspace(HP_DATASPACE *info);
647 +extern uint hp_get_encoded_data_length(HP_SHARE *info, const uchar *record,
648 + uint *chunk_count);
649 +extern void hp_copy_record_data_to_chunkset(HP_SHARE *info, const uchar *record,
651 +extern int hp_extract_record(HP_INFO *info, uchar *record, const uchar *pos);
652 +extern uint hp_process_record_data_to_chunkset(HP_SHARE *info,
653 + const uchar *record, uchar *pos,
656 extern mysql_mutex_t THR_LOCK_heap;
658 --- a/storage/heap/hp_clear.c
659 +++ b/storage/heap/hp_clear.c
662 DBUG_ENTER("hp_clear");
664 - if (info->block.levels)
665 - (void) hp_free_level(&info->block,info->block.levels,info->block.root,
667 - info->block.levels=0;
668 + hp_clear_dataspace(&info->recordspace);
670 - info->records= info->deleted= 0;
671 - info->data_length= 0;
681 HP_SHARE *share= info->s;
683 - if (share->data_length || share->index_length)
684 + if (share->recordspace.total_data_length || share->index_length)
685 error= HA_ERR_CRASHED;
687 if (share->currently_disabled_keys)
688 --- a/storage/heap/hp_close.c
689 +++ b/storage/heap/hp_close.c
691 heap_open_list=list_delete(heap_open_list,&info->open_list);
692 if (!--info->s->open_count && info->s->delete_on_close)
693 hp_free(info->s); /* Table was deleted */
694 + if (info->blob_buffer)
696 + my_free(info->blob_buffer);
701 --- a/storage/heap/hp_create.c
702 +++ b/storage/heap/hp_create.c
704 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
707 +#include <mysql_com.h>
708 +#include <mysqld_error.h>
710 static int keys_compare(heap_rb_param *param, uchar *key1, uchar *key2);
711 -static void init_block(HP_BLOCK *block,uint reclength,ulong min_records,
712 +static void init_block(HP_BLOCK *block,uint chunk_length, ulong min_records,
715 +#define FIXED_REC_OVERHEAD (sizeof(uchar))
716 +#define VARIABLE_REC_OVERHEAD (sizeof(uchar **) + sizeof(uchar))
718 +/* Minimum size that a chunk can take, 12 bytes on 32bit, 24 bytes on 64bit */
719 +#define VARIABLE_MIN_CHUNK_SIZE \
720 + ((sizeof(uchar **) + VARIABLE_REC_OVERHEAD + sizeof(uchar **) - 1) & \
721 + ~(sizeof(uchar **) - 1))
723 /* Create a heap table */
725 int heap_create(const char *name, HP_CREATE_INFO *create_info,
727 uint keys= create_info->keys;
728 ulong min_records= create_info->min_records;
729 ulong max_records= create_info->max_records;
730 + ulong max_rows_for_stated_memory;
731 DBUG_ENTER("heap_create");
733 if (!create_info->internal_table)
738 + uint chunk_dataspace_length, chunk_length, is_variable_size;
739 + uint fixed_data_length, fixed_column_count;
741 DBUG_PRINT("info",("Initializing new table"));
744 + if (create_info->max_chunk_size)
746 + uint configured_chunk_size= create_info->max_chunk_size;
748 + /* User requested variable-size records, let's see if they're possible */
750 + if (configured_chunk_size < create_info->fixed_data_size)
753 + The resulting chunk_size cannot be smaller than fixed data part
754 + at the start of the first chunk which allows faster copying
755 + with a single memcpy().
757 + my_error(ER_CANT_USE_OPTION_HERE, MYF(0), "key_block_size");
761 + if (reclength > configured_chunk_size + VARIABLE_REC_OVERHEAD ||
762 + create_info->blobs > 0)
765 + Allow variable size only if we're saving some space, i.e.
766 + if a fixed-size record would take more space than variable-size
767 + one plus the variable-size overhead.
768 + There has to be at least one field after indexed fields.
769 + Note that NULL bits are already included in key_part_size.
771 + is_variable_size= 1;
772 + chunk_dataspace_length= configured_chunk_size;
776 + /* max_chunk_size is near the full reclength, let's use fixed size */
777 + is_variable_size= 0;
778 + chunk_dataspace_length= reclength;
781 + else if ((create_info->is_dynamic && reclength >
782 + 256 + VARIABLE_REC_OVERHEAD)
783 + || create_info->blobs > 0)
786 + User asked for dynamic records - use 256 as the chunk size, if that
787 + will may save some memory. Otherwise revert to fixed size format.
789 + if ((create_info->fixed_data_size + VARIABLE_REC_OVERHEAD) > 256)
790 + chunk_dataspace_length= create_info->fixed_data_size;
792 + chunk_dataspace_length= 256 - VARIABLE_REC_OVERHEAD;
794 + is_variable_size= 1;
799 + If max_chunk_size is not specified, put the whole record in one chunk
801 + is_variable_size= 0;
802 + chunk_dataspace_length= reclength;
805 + if (is_variable_size)
807 + /* Check whether we have any variable size records past key data */
808 + uint has_variable_fields= 0;
810 + fixed_data_length= create_info->fixed_data_size;
811 + fixed_column_count= create_info->fixed_key_fieldnr;
813 + for (i= create_info->fixed_key_fieldnr; i < create_info->columns; i++)
815 + HP_COLUMNDEF *column= create_info->columndef + i;
816 + if ((column->type == MYSQL_TYPE_VARCHAR &&
817 + (column->length - column->length_bytes) >= 32) ||
818 + column->type == MYSQL_TYPE_BLOB)
821 + The field has to be either blob or >= 5.0.3 true VARCHAR
822 + and have substantial length.
823 + TODO: do we want to calculate minimum length?
825 + has_variable_fields= 1;
829 + if (has_variable_fields)
834 + if ((column->offset + column->length) <= chunk_dataspace_length)
836 + /* Still no variable-size columns, add one fixed-length */
837 + fixed_column_count= i + 1;
838 + fixed_data_length= column->offset + column->length;
842 + if (!has_variable_fields && create_info->blobs == 0)
845 + There is no need to use variable-size records without variable-size
847 + Reset sizes if it's not variable size anymore.
849 + is_variable_size= 0;
850 + chunk_dataspace_length= reclength;
851 + fixed_data_length= reclength;
852 + fixed_column_count= create_info->columns;
857 + fixed_data_length= reclength;
858 + fixed_column_count= create_info->columns;
862 - We have to store sometimes uchar* del_link in records,
863 - so the record length should be at least sizeof(uchar*)
864 + We store uchar* del_link inside the data area of deleted records,
865 + so the data length should be at least sizeof(uchar*)
867 - set_if_bigger(reclength, sizeof (uchar*));
869 + set_if_bigger(chunk_dataspace_length, sizeof (uchar **));
871 + if (is_variable_size)
873 + chunk_length= chunk_dataspace_length + VARIABLE_REC_OVERHEAD;
877 + chunk_length= chunk_dataspace_length + FIXED_REC_OVERHEAD;
880 + /* Align chunk length to the next pointer */
881 + chunk_length= (uint) (chunk_length + sizeof(uchar **) - 1) &
882 + ~(sizeof(uchar **) - 1);
884 for (i= key_segs= max_length= 0, keyinfo= keydef; i < keys; i++, keyinfo++)
886 bzero((char*) &keyinfo->block,sizeof(keyinfo->block));
888 keyinfo->rb_tree.size_of_element++;
890 switch (keyinfo->seg[j].type) {
891 - case HA_KEYTYPE_SHORT_INT:
892 - case HA_KEYTYPE_LONG_INT:
893 - case HA_KEYTYPE_FLOAT:
894 - case HA_KEYTYPE_DOUBLE:
895 - case HA_KEYTYPE_USHORT_INT:
896 - case HA_KEYTYPE_ULONG_INT:
897 - case HA_KEYTYPE_LONGLONG:
898 - case HA_KEYTYPE_ULONGLONG:
899 - case HA_KEYTYPE_INT24:
900 - case HA_KEYTYPE_UINT24:
901 - case HA_KEYTYPE_INT8:
902 - keyinfo->seg[j].flag|= HA_SWAP_KEY;
904 case HA_KEYTYPE_VARBINARY1:
905 - /* Case-insensitiveness is handled in coll->hash_sort */
906 - keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1;
908 case HA_KEYTYPE_VARTEXT1:
909 - keyinfo->flag|= HA_VAR_LENGTH_KEY;
911 - /* Save number of bytes used to store length */
912 - keyinfo->seg[j].bit_start= 1;
914 case HA_KEYTYPE_VARBINARY2:
915 - /* Case-insensitiveness is handled in coll->hash_sort */
917 case HA_KEYTYPE_VARTEXT2:
918 - keyinfo->flag|= HA_VAR_LENGTH_KEY;
920 - /* Save number of bytes used to store length */
921 - keyinfo->seg[j].bit_start= 2;
923 - Make future comparison simpler by only having to check for
926 - keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1;
930 @@ -133,13 +245,34 @@
932 if (!(share= (HP_SHARE*) my_malloc((uint) sizeof(HP_SHARE)+
933 keys*sizeof(HP_KEYDEF)+
934 + (create_info->columns *
935 + sizeof(HP_COLUMNDEF)) +
936 key_segs*sizeof(HA_KEYSEG),
939 - share->keydef= (HP_KEYDEF*) (share + 1);
942 + Max_records is used for estimating block sizes and for enforcement.
943 + Calculate the very maximum number of rows (if everything was one chunk)
944 + and then take either that value or configured max_records (pick smallest
947 + max_rows_for_stated_memory= (ha_rows) (create_info->max_table_size /
948 + (create_info->keys_memory_size +
950 + max_records = ((max_records && max_records < max_rows_for_stated_memory) ?
951 + max_records : max_rows_for_stated_memory);
953 + share->column_defs= (HP_COLUMNDEF*) (share + 1);
954 + memcpy(share->column_defs, create_info->columndef,
955 + (size_t) (sizeof(create_info->columndef[0]) *
956 + create_info->columns));
958 + share->keydef= (HP_KEYDEF*) (share->column_defs + create_info->columns);
959 share->key_stat_version= 1;
960 keyseg= (HA_KEYSEG*) (share->keydef + keys);
961 - init_block(&share->block, reclength + 1, min_records, max_records);
962 + init_block(&share->recordspace.block, chunk_length, min_records,
965 memcpy(share->keydef, keydef, (size_t) (sizeof(keydef[0]) * keys));
966 for (i= 0, keyinfo= share->keydef; i < keys; i++, keyinfo++)
967 @@ -177,16 +310,36 @@
968 share->min_records= min_records;
969 share->max_records= max_records;
970 share->max_table_size= create_info->max_table_size;
971 - share->data_length= share->index_length= 0;
972 - share->reclength= reclength;
973 + share->index_length= 0;
976 share->max_key_length= max_length;
977 + share->column_count= create_info->columns;
979 share->auto_key= create_info->auto_key;
980 share->auto_key_type= create_info->auto_key_type;
981 share->auto_increment= create_info->auto_increment;
982 share->create_time= (long) time((time_t*) 0);
984 + share->fixed_data_length= fixed_data_length;
985 + share->fixed_column_count= fixed_column_count;
986 + share->blobs= create_info->blobs;
988 + share->recordspace.chunk_length= chunk_length;
989 + share->recordspace.chunk_dataspace_length= chunk_dataspace_length;
990 + share->recordspace.is_variable_size= is_variable_size;
991 + share->recordspace.total_data_length= 0;
993 + if (is_variable_size) {
994 + share->recordspace.offset_link= chunk_dataspace_length;
995 + share->recordspace.offset_status= share->recordspace.offset_link +
998 + /* Make it likely to fail if anyone uses this offset */
999 + share->recordspace.offset_link= 1 << 22;
1000 + share->recordspace.offset_status= chunk_dataspace_length;
1003 /* Must be allocated separately for rename to work */
1004 if (!(share->name= my_strdup(name,MYF(0))))
1007 param->search_flag, not_used);
1010 -static void init_block(HP_BLOCK *block, uint reclength, ulong min_records,
1011 +static void init_block(HP_BLOCK *block, uint chunk_length, ulong min_records,
1014 uint i,recbuffer,records_in_block;
1015 @@ -236,7 +389,12 @@
1016 max_records= max(min_records,max_records);
1018 max_records= 1000; /* As good as quess as anything */
1019 - recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
1021 + We want to start each chunk at 8 bytes boundary, round recbuffer to the
1024 + recbuffer= (uint) (chunk_length + sizeof(uchar**) - 1) &
1025 + ~(sizeof(uchar**) - 1);
1026 records_in_block= max_records / 10;
1027 if (records_in_block < 10 && max_records)
1028 records_in_block= 10;
1029 --- a/storage/heap/hp_delete.c
1030 +++ b/storage/heap/hp_delete.c
1033 HP_SHARE *share=info->s;
1034 HP_KEYDEF *keydef, *end, *p_lastinx;
1035 + uint rec_length, chunk_count;
1037 DBUG_ENTER("heap_delete");
1038 DBUG_PRINT("enter",("info: 0x%lx record: 0x%lx", (long) info, (long) record));
1041 DBUG_RETURN(my_errno); /* Record changed */
1044 + rec_length = hp_get_encoded_data_length(share, record, &chunk_count);
1046 if ( --(share->records) < share->blength >> 1) share->blength>>=1;
1047 pos=info->current_ptr;
1052 info->update=HA_STATE_DELETED;
1053 - *((uchar**) pos)=share->del_link;
1054 - share->del_link=pos;
1055 - pos[share->reclength]=0; /* Record deleted */
1057 + hp_free_chunks(&share->recordspace, pos);
1058 info->current_hash_ptr=0;
1059 #if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
1060 DBUG_EXECUTE("check_heap",heap_check_heap(info, 0););
1062 info->last_pos= NULL; /* For heap_rnext/heap_rprev */
1064 custom_arg.keyseg= keyinfo->seg;
1065 - custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos);
1066 + custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos,
1068 custom_arg.search_flag= SEARCH_SAME;
1069 old_allocated= keyinfo->rb_tree.allocated;
1070 res= tree_delete(&keyinfo->rb_tree, info->recbuf, custom_arg.key_length,
1072 blength=share->blength;
1073 if (share->records+1 == blength)
1076 lastpos=hp_find_hash(&keyinfo->block,share->records);
1080 +++ b/storage/heap/hp_dspace.c
1082 +/* Copyright (C) 2000-2002 MySQL AB
1083 + Copyright (C) 2008 eBay, Inc
1085 + This program is free software; you can redistribute it and/or modify
1086 + it under the terms of the GNU General Public License as published by
1087 + the Free Software Foundation; version 2 of the License.
1089 + This program is distributed in the hope that it will be useful,
1090 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1091 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1092 + GNU General Public License for more details.
1094 + You should have received a copy of the GNU General Public License
1095 + along with this program; if not, write to the Free Software
1096 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1099 + Implements various base dataspace-related functions - allocate, free, clear
1102 +#include "heapdef.h"
1106 + MySQL Heap tables keep data in arrays of fixed-size chunks.
1107 + These chunks are organized into two groups of HP_BLOCK structures:
1108 + - group1 contains indexes, with one HP_BLOCK per key
1109 + (part of HP_KEYDEF)
1110 + - group2 contains record data, with single HP_BLOCK
1111 + for all records, referenced by HP_SHARE.recordspace.block
1113 + While columns used in index are usually small, other columns
1114 + in the table may need to accomodate larger data. Typically,
1115 + larger data is placed into VARCHAR or BLOB columns. With actual
1116 + sizes varying, Heap Engine has to support variable-sized records
1117 + in memory. Heap Engine implements the concept of dataspace
1118 + (HP_DATASPACE), which incorporates HP_BLOCK for the record data,
1119 + and adds more information for managing variable-sized records.
1121 + Variable-size records are stored in multiple "chunks",
1122 + which means that a single record of data (database "row") can
1123 + consist of multiple chunks organized into one "set". HP_BLOCK
1124 + contains chunks. In variable-size format, one record
1125 + is represented as one or many chunks, depending on the actual
1126 + data, while in fixed-size mode, one record is always represented
1127 + as one chunk. The index structures would always point to the first
1128 + chunk in the chunkset.
1130 + At the time of table creation, Heap Engine attempts to find out if
1131 + variable-size records are desired. A user can request
1132 + variable-size records by providing either row_type=dynamic or
1133 + key_block_size=NNN table create option. Heap Engine will check
1134 + whether key_block_size provides enough space in the first chunk
1135 + to keep all null bits and columns that are used in indexes.
1136 + If key_block_size is too small, table creation will be aborted
1137 + with an error. Heap Engine will revert to fixed-size allocation
1138 + mode if key_block_size provides no memory benefits (if the
1139 + fixed-size record would always be shorter then the first chunk
1140 + in the chunkset with the specified key_block_size).
1142 + In order to improve index search performance, Heap Engine needs
1143 + to keep all null flags and all columns used as keys inside
1144 + the first chunk of a chunkset. In particular, this means that
1145 + all columns used as keys should be defined first in the table
1146 + creation SQL. The length of data used by null bits and key columns
1147 + is stored as fixed_data_length inside HP_SHARE. fixed_data_length
1148 + will extend past last key column if more fixed-length fields can
1149 + fit into the first chunk.
1151 + Variable-size records are necessary only in the presence of
1152 + variable-size columns. Heap Engine will be looking for BLOB
1153 + columns or VARCHAR columns, which declare length of 32 or more. If
1154 + no such columns are found, table will be switched to fixed-size
1155 + format. You should always try to put such columns at the end of
1156 + the table definition.
1158 + Whenever data is being inserted or updated in the table
1159 + Heap Engine will calculate how many chunks are necessary.
1160 + For insert operations, Heap Engine allocates new chunkset in
1161 + the recordspace. For update operations it will modify length of
1162 + the existing chunkset, unlinking unnecessary chunks at the end,
1163 + or allocating and adding more if larger length is necessary.
1165 + When writing data to chunks or copying data back to record,
1166 + fixed-size columns are copied in their full format. VARCHARs and
1167 + BLOBs are copied based on their actual length. Any NULL values
1168 + after fixed_data_length are skipped.
1170 + The allocation and contents of the actual chunks varies between
1171 + fixed and variable-size modes. Total chunk length is always
1172 + aligned to the next sizeof(uchar*). Here is the format of
1174 + uchar[] - sizeof=chunk_dataspace_length, but at least
1175 + sizeof(uchar*) bytes. Keeps actual data or pointer
1176 + to the next deleted chunk.
1177 + chunk_dataspace_length equals to full record length
1178 + uchar - status field (1 means "in use", 0 means "deleted")
1180 + Variable-size chunk uses different format:
1181 + uchar[] - sizeof=chunk_dataspace_length, but at least
1182 + sizeof(uchar*) bytes. Keeps actual data or pointer
1183 + to the next deleted chunk.
1184 + chunk_dataspace_length is set according to table
1185 + setup (key_block_size)
1186 + uchar* - pointer to the next chunk in this chunkset,
1187 + or NULL for the last chunk
1188 + uchar - status field (1 means "first", 0 means "deleted",
1191 + When allocating a new chunkset of N chunks, Heap Engine will try
1192 + to allocate chunks one-by-one, linking them as they become
1193 + allocated. Allocation of a single chunk will attempt to reuse
1194 + a deleted (freed) chunk. If no free chunks are available,
1195 + it will attempt to allocate a new area inside HP_BLOCK.
1196 + Freeing chunks will place them at the front of free list
1197 + referenced by del_link in HP_DATASPACE. The newly freed chunk
1198 + will contain reference to the previously freed chunk in its first
1199 + sizeof(uchar*) of the payload space.
1201 + Here is open issues:
1202 + - It is not very nice to require people to keep key columns
1203 + at the beginning of the table creation SQL. There are three
1204 + proposed resolutions:
1205 + a. Leave it as is. It's a reasonable limitation
1206 + b. Add new HA_KEEP_KEY_COLUMNS_TO_FRONT flag to handler.h and
1207 + make table.cpp align columns when it creates the table
1208 + c. Make HeapEngine reorder columns in the chunk data, so that
1209 + key columns go first. Add parallel HA_KEYSEG structures
1210 + to distinguish positions in record vs. positions in
1211 + the first chunk. Copy all data field-by-field rather than
1212 + using single memcpy unless DBA kept key columns to
1214 + - heap_check_heap needs verify linked chunks, looking for
1215 + issues such as orphans, cycles, and bad links. However,
1216 + Heap Engine today does not do similar things even for
1218 + - In a more sophisticated implementation, some space can
1219 + be saved even with all fixed-size columns if many of them
1220 + have NULL value, as long as these columns are not used
1222 + - In variable-size format status should be moved to lower
1223 + bits of the "next" pointer. Pointer is always aligned
1224 + to sizeof(byte*), which is at least 4, leaving 2 lower
1225 + bits free. This will save 8 bytes per chunk
1226 + on 64-bit platform.
1227 + - As we do not want to modify FRM format or to add new SQL
1228 + keywords, KEY_BLOCK_SIZE option of "CREATE TABLE" is reused
1229 + to specify block size for Heap Engine tables.
1230 + - since all key columns must fit in the first chunk, having keys
1231 + on BLOB columns is currently impossible. This limitation is
1232 + relatively easiy to remove in future.
1235 +static uchar *hp_allocate_one_chunk(HP_DATASPACE *info);
1241 + Frees memory and zeros-out any relevant counters in the dataspace
1243 + @param info the dataspace to clear
1246 +void hp_clear_dataspace(HP_DATASPACE *info)
1248 + if (info->block.levels)
1250 + hp_free_level(&info->block,info->block.levels,info->block.root,
1253 + info->block.levels= 0;
1254 + info->del_chunk_count= info->chunk_count= 0;
1255 + info->del_link= 0;
1256 + info->total_data_length= 0;
1261 + Allocate or reallocate a chunkset in the dataspace
1263 + Attempts to allocate a new chunkset or change the size of an existing chunkset
1265 + @param info the hosting dataspace
1266 + @param chunk_count the number of chunks that we expect as the result
1267 + @param existing_set non-null value asks function to resize existing
1268 + chunkset, return value would point to this set
1270 + @return Pointer to the first chunk in the new or updated chunkset, or NULL
1274 +static uchar *hp_allocate_variable_chunkset(HP_DATASPACE *info,
1276 + uchar *existing_set)
1278 + int alloc_count= chunk_count, i;
1279 + uchar *first_chunk= 0, *curr_chunk= 0, *prev_chunk= 0;
1280 + uchar *last_existing_chunk= 0;
1282 + DBUG_ASSERT(alloc_count);
1286 + first_chunk= existing_set;
1288 + curr_chunk= existing_set;
1289 + while (curr_chunk && alloc_count)
1291 + prev_chunk= curr_chunk;
1292 + curr_chunk= *((uchar **) (curr_chunk + info->offset_link));
1301 + We came through all chunks and there is more left, let's truncate the
1304 + *((uchar **) (prev_chunk + info->offset_link))= NULL;
1305 + hp_free_chunks(info, curr_chunk);
1308 + return first_chunk;
1311 + last_existing_chunk= prev_chunk;
1315 + We can reach this point only if we're allocating new chunkset or more chunks
1319 + for (i= 0; i < alloc_count; i++)
1321 + curr_chunk= hp_allocate_one_chunk(info);
1324 + /* no space in the current block */
1326 + if (last_existing_chunk)
1328 + /* Truncate whatever was added at the end of the existing chunkset */
1329 + prev_chunk= last_existing_chunk;
1330 + curr_chunk= *((uchar **)(prev_chunk + info->offset_link));
1331 + *((uchar **)(prev_chunk + info->offset_link))= NULL;
1332 + hp_free_chunks(info, curr_chunk);
1334 + else if (first_chunk)
1336 + /* free any chunks previously allocated */
1337 + hp_free_chunks(info, first_chunk);
1343 + /* mark as if this chunk is last in the chunkset */
1344 + *((uchar **) (curr_chunk + info->offset_link))= 0;
1348 + /* tie them into a linked list */
1349 + *((uchar **) (prev_chunk + info->offset_link))= curr_chunk;
1350 + /* Record linked from active */
1351 + curr_chunk[info->offset_status]= CHUNK_STATUS_LINKED;
1355 + /* Record active */
1356 + curr_chunk[info->offset_status]= CHUNK_STATUS_ACTIVE;
1361 + first_chunk= curr_chunk;
1364 + prev_chunk= curr_chunk;
1367 + return first_chunk;
1372 + Allocate a new chunkset in the dataspace
1374 + Attempts to allocate a new chunkset
1376 + @param info the hosting dataspace
1377 + @param chunk_count the number of chunks that we expect as the result
1379 + @return Pointer to the first chunk in the new or updated chunkset, or NULL if
1383 +uchar *hp_allocate_chunkset(HP_DATASPACE *info, uint chunk_count)
1387 + DBUG_ENTER("hp_allocate_chunks");
1389 + if (info->is_variable_size)
1391 + result = hp_allocate_variable_chunkset(info, chunk_count, NULL);
1395 + result= hp_allocate_one_chunk(info);
1398 + result[info->offset_status]= CHUNK_STATUS_ACTIVE;
1401 + DBUG_RETURN(result);
1404 + DBUG_RETURN(result);
1409 + Reallocate an existing chunkset in the dataspace
1411 + Attempts to change the size of an existing chunkset
1413 + @param info the hosting dataspace
1414 + @param chunk_count the number of chunks that we expect as the result
1415 + @param pos pointer to the existing chunkset
1417 + @return Error code or zero if successful
1420 +int hp_reallocate_chunkset(HP_DATASPACE *info, uint chunk_count, uchar *pos)
1422 + DBUG_ENTER("hp_reallocate_chunks");
1424 + if (!info->is_variable_size)
1426 + /* Update should never change chunk_count in fixed-size mode */
1427 + my_errno= HA_ERR_WRONG_COMMAND;
1431 + /* Reallocate never moves the first chunk */
1432 + if (!hp_allocate_variable_chunkset(info, chunk_count, pos))
1433 + DBUG_RETURN(my_errno);
1440 + Allocate a single chunk in the dataspace
1442 + Attempts to allocate a new chunk or reuse one from deleted list
1444 + @param info the hosting dataspace
1446 + @return Pointer to the chunk, or NULL if unsuccessful
1449 +static uchar *hp_allocate_one_chunk(HP_DATASPACE *info)
1451 + uchar *curr_chunk;
1455 + if (info->del_link)
1457 + curr_chunk= info->del_link;
1458 + info->del_link= *((uchar **) curr_chunk);
1459 + info->del_chunk_count--;
1461 + DBUG_PRINT("hp_allocate_one_chunk",
1462 + ("Used old position: 0x%lx",(long) curr_chunk));
1463 + return curr_chunk;
1466 + block_pos= (info->chunk_count % info->block.records_in_block);
1469 + if (hp_get_new_block(&info->block, &length))
1471 + /* no space in the current block */
1475 + info->total_data_length+= length;
1478 + info->chunk_count++;
1479 + curr_chunk= ((uchar *) info->block.level_info[0].last_blocks +
1480 + block_pos * info->block.recbuffer);
1482 + DBUG_PRINT("hp_allocate_one_chunk",
1483 + ("Used new position: 0x%lx", (long) curr_chunk));
1485 + return curr_chunk;
1490 + Free a list of chunks
1492 + Reclaims all chunks linked by the pointer,
1493 + which could be the whole chunkset or a part of an existing chunkset
1495 + @param info the hosting dataspace
1496 + @param pos pointer to the head of the chunkset
1499 +void hp_free_chunks(HP_DATASPACE *info, uchar *pos)
1501 + uchar *curr_chunk= pos;
1503 + while (curr_chunk)
1505 + info->del_chunk_count++;
1506 + *((uchar **) curr_chunk)= info->del_link;
1507 + info->del_link= curr_chunk;
1509 + curr_chunk[info->offset_status]= CHUNK_STATUS_DELETED;
1511 + DBUG_PRINT("hp_free_chunks",("Freed position: 0x%lx", (long) curr_chunk));
1513 + if (!info->is_variable_size)
1518 + /* Delete next chunk in this chunkset */
1519 + curr_chunk= *((uchar **)(curr_chunk + info->offset_link));
1522 --- a/storage/heap/hp_extra.c
1523 +++ b/storage/heap/hp_extra.c
1525 info->current_record= (ulong) ~0L;
1526 info->current_hash_ptr=0;
1528 - info->next_block=0;
1532 --- a/storage/heap/hp_hash.c
1533 +++ b/storage/heap/hp_hash.c
1534 @@ -336,16 +336,26 @@
1536 CHARSET_INFO *cs= seg->charset;
1537 uint pack_length= seg->bit_start;
1538 - uint length= (pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos));
1539 + uint length= hp_calc_blob_length(pack_length, pos);
1541 + if (seg->flag & HA_BLOB_PART)
1543 + memcpy(&pos, pos + pack_length, sizeof(char *));
1547 + pos+= pack_length;
1550 if (cs->mbmaxlen > 1)
1553 - char_length= my_charpos(cs, pos + pack_length,
1554 - pos + pack_length + length,
1555 + char_length= my_charpos(cs, pos,
1557 seg->length/cs->mbmaxlen);
1558 set_if_smaller(length, char_length);
1560 - cs->coll->hash_sort(cs, pos+pack_length, length, &nr, &nr2);
1561 + cs->coll->hash_sort(cs, pos, length, &nr, &nr2);
1565 @@ -545,18 +555,18 @@
1566 uint char_length1, char_length2;
1567 uint pack_length= seg->bit_start;
1568 CHARSET_INFO *cs= seg->charset;
1569 - if (pack_length == 1)
1571 - char_length1= (uint) *(uchar*) pos1++;
1572 - char_length2= (uint) *(uchar*) pos2++;
1576 + char_length1= hp_calc_blob_length(pack_length, pos1);
1577 + char_length2= hp_calc_blob_length(pack_length, pos2);
1578 + pos1+= pack_length;
1579 + pos2+= pack_length;
1581 + if (seg->flag & HA_BLOB_PART)
1583 - char_length1= uint2korr(pos1);
1584 - char_length2= uint2korr(pos2);
1587 + memcpy(&pos1, pos1, sizeof(char *));
1588 + memcpy(&pos2, pos2, sizeof(char *));
1591 if (cs->mbmaxlen > 1)
1593 uint safe_length1= char_length1;
1594 @@ -668,6 +678,34 @@
1599 + Returns a BLOB length stored in the specified number of bytes at the
1600 + specified location.
1602 + @param length the number of bytes used to store length
1603 + @param pos pointer to length bytes
1605 + @return Length of BLOB data.
1608 +uint hp_calc_blob_length(uint bytes, const uchar *pos)
1612 + return (uint) *pos;
1614 + return uint2korr(pos);
1616 + return uint3korr(pos);
1618 + return uint4korr(pos);
1623 + return 0; /* Impossible */
1626 /* Copy a key from a record to a keybuffer */
1628 void hp_make_key(HP_KEYDEF *keydef, uchar *key, const uchar *rec)
1629 @@ -678,18 +716,37 @@
1631 CHARSET_INFO *cs= seg->charset;
1632 uint char_length= seg->length;
1633 - uchar *pos= (uchar*) rec + seg->start;
1634 + const uchar *pos= rec + seg->start;
1636 *key++= test(rec[seg->null_pos] & seg->null_bit);
1637 - if (cs->mbmaxlen > 1)
1639 + if (seg->flag & HA_BLOB_PART)
1641 - char_length= my_charpos(cs, pos, pos + seg->length,
1642 - char_length / cs->mbmaxlen);
1643 - set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */
1644 + uint tmp_length= hp_calc_blob_length(seg->bit_start, pos);
1645 + uint length= min(seg->length, tmp_length);
1647 + memcpy(&pos, rec + seg->bit_start, sizeof(char *));
1648 + if (cs->mbmaxlen > 1)
1650 + char_length= my_charpos(cs, pos, pos + seg->length,
1651 + char_length / cs->mbmaxlen);
1652 + set_if_smaller(char_length, length); /* QQ: ok to remove? */
1654 + store_key_length_inc(key, char_length);
1656 - if (seg->type == HA_KEYTYPE_VARTEXT1)
1657 - char_length+= seg->bit_start; /* Copy also length */
1658 - memcpy(key,rec+seg->start,(size_t) char_length);
1661 + if (cs->mbmaxlen > 1)
1663 + char_length= my_charpos(cs, pos, pos + seg->length,
1664 + char_length / cs->mbmaxlen);
1665 + set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */
1667 + if (seg->type == HA_KEYTYPE_VARTEXT1)
1668 + char_length+= seg->bit_start; /* Copy also length */
1671 + memcpy(key, pos, (size_t) char_length);
1679 -uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
1680 - const uchar *rec, uchar *recpos)
1681 +uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
1682 + const uchar *rec, uchar *recpos, my_bool packed)
1684 uchar *start_key= key;
1685 HA_KEYSEG *seg, *endseg;
1686 @@ -772,6 +829,29 @@
1690 + else if (seg->flag & HA_BLOB_PART)
1692 + uchar *pos= (uchar*) rec + seg->start;
1693 + uint tmp_length= hp_calc_blob_length(seg->bit_start, pos);
1694 + uint length= min(seg->length, tmp_length);
1695 + CHARSET_INFO *cs= seg->charset;
1696 + char_length= seg->length / cs->mbmaxlen;
1698 + /* check_one_rb_key() calls hp_rb_make_key() for already packed records */
1701 + memcpy(&pos, pos + seg->bit_start, sizeof(char *));
1705 + pos+= seg->bit_start;
1707 + FIX_LENGTH(cs, pos, length, char_length);
1708 + store_key_length_inc(key, char_length);
1709 + memcpy(key, pos, (size_t) char_length);
1710 + key+= char_length;
1714 char_length= seg->length;
1715 if (seg->charset->mbmaxlen > 1)
1716 --- a/storage/heap/hp_info.c
1717 +++ b/storage/heap/hp_info.c
1720 DBUG_ENTER("heap_info");
1721 x->records = info->s->records;
1722 - x->deleted = info->s->deleted;
1723 - x->reclength = info->s->reclength;
1724 - x->data_length = info->s->data_length;
1725 + x->deleted = info->s->recordspace.del_chunk_count;
1727 + if (info->s->recordspace.is_variable_size)
1729 + if (info->s->records)
1730 + x->reclength = (uint) (info->s->recordspace.total_data_length /
1731 + (ulonglong) info->s->records);
1733 + x->reclength = info->s->recordspace.chunk_length;
1737 + x->reclength = info->s->recordspace.chunk_dataspace_length;
1740 + x->data_length = info->s->recordspace.total_data_length;
1741 x->index_length = info->s->index_length;
1742 x->max_records = info->s->max_records;
1743 x->errkey = info->errkey;
1744 --- a/storage/heap/hp_open.c
1745 +++ b/storage/heap/hp_open.c
1748 info->opt_flag= READ_CHECK_USED; /* Check when changing */
1750 - DBUG_PRINT("exit",("heap: 0x%lx reclength: %d records_in_block: %d",
1751 - (long) info, share->reclength,
1752 - share->block.records_in_block));
1753 + DBUG_PRINT("exit",("heap: 0x%lx chunk_length: %d records_in_block: %d",
1754 + (long) info, share->recordspace.chunk_length,
1755 + share->recordspace.block.records_in_block));
1760 +++ b/storage/heap/hp_record.c
1762 +/* Copyright (C) 2000-2002 MySQL AB
1763 + Copyright (C) 2008 eBay, Inc
1765 + This program is free software; you can redistribute it and/or modify
1766 + it under the terms of the GNU General Public License as published by
1767 + the Free Software Foundation; version 2 of the License.
1769 + This program is distributed in the hope that it will be useful,
1770 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1771 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1772 + GNU General Public License for more details.
1774 + You should have received a copy of the GNU General Public License
1775 + along with this program; if not, write to the Free Software
1776 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1779 + Implements various base record-related functions, such as encode and decode
1783 +#include "heapdef.h"
1784 +#include <mysql_com.h>
1787 + Calculate size of the record for the purpose of storing in chunks
1789 + Walk through the fields of the record and calculates the exact space
1790 + needed in chunks as well the the total chunk count
1792 + @param info the hosting table
1793 + @param record the record in standard unpacked format
1794 + @param[out] chunk_count the number of chunks needed for this record
1796 + @return The size of the required storage in bytes
1799 +uint hp_get_encoded_data_length(HP_SHARE *info, const uchar *record,
1800 + uint *chunk_count)
1802 + uint i, dst_offset;
1804 + dst_offset= info->fixed_data_length;
1806 + if (!info->recordspace.is_variable_size)
1808 + /* Nothing more to copy */
1810 + return dst_offset;
1813 + for (i= info->fixed_column_count; i < info->column_count; i++)
1815 + uint src_offset, length;
1817 + HP_COLUMNDEF *column= info->column_defs + i;
1819 + if (column->null_bit)
1821 + if (record[column->null_pos] & column->null_bit)
1823 + /* Skip all NULL values */
1828 + src_offset= column->offset;
1829 + if (column->type == MYSQL_TYPE_VARCHAR)
1833 + /* >= 5.0.3 true VARCHAR */
1835 + pack_length= column->length_bytes;
1836 + length= pack_length + (pack_length == 1 ?
1837 + (uint) *(uchar *) (record + src_offset) :
1838 + uint2korr(record + src_offset));
1840 + else if (column->type == MYSQL_TYPE_BLOB)
1842 + uint pack_length= column->length_bytes;
1844 + length= pack_length + hp_calc_blob_length(pack_length,
1845 + record + src_offset);
1849 + length= column->length;
1852 + dst_offset+= length;
1855 + *chunk_count= get_chunk_count(&info->recordspace, dst_offset);
1857 + return dst_offset;
1861 +#if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
1862 +static void dump_chunk(HP_SHARE *info, const uchar *curr_chunk)
1865 + fprintf(stdout, "Chunk dump at 0x%lx: ", (long) curr_chunk);
1866 + for (i= 0; i < info->recordspace.chunk_dataspace_length; i++)
1868 + uint b= *((uchar *)(curr_chunk + i));
1871 + fprintf(stdout, "0");
1873 + fprintf(stdout, "%lx ", (long) b);
1875 + fprintf(stdout, ". Next = 0x%lx, Status = %d\n",
1876 + (long) (*((uchar **) (curr_chunk + info->recordspace.offset_link))),
1877 + (uint) (*((uchar *) (curr_chunk + info->recordspace.offset_status))));
1882 + Stores data from packed field into the preallocated chunkset,
1883 + or performs data comparison
1885 + @param info the hosting table
1886 + @param data the field data in packed format
1887 + @param length the field data length
1888 + @param pos_ptr the target chunkset
1889 + @param off_ptr the pointer to the offset within the current chunkset
1890 + @param is_compare flag indicating whether we should compare data or store
1893 + @return Status of comparison
1894 + @retval non-zero if comparison found data differences
1895 + @retval zero otherwise
1899 +hp_process_field_data_to_chunkset(HP_SHARE *info, const uchar *data,
1900 + uint length, uchar **pos_ptr, uint *off_ptr,
1904 + uchar *curr_chunk= *pos_ptr;
1905 + uint dst_offset= *off_ptr;
1908 + while (length > 0)
1911 + to_copy= info->recordspace.chunk_dataspace_length - dst_offset;
1914 + /* Jump to the next chunk */
1915 +#if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
1916 + dump_chunk(info, curr_chunk);
1918 + curr_chunk= *((uchar **) (curr_chunk + info->recordspace.offset_link));
1923 + to_copy= min(length, to_copy);
1927 + if (memcmp(curr_chunk + dst_offset, data, (size_t) to_copy))
1934 + memcpy(curr_chunk + dst_offset, data, (size_t) to_copy);
1938 + dst_offset+= to_copy;
1945 + *pos_ptr= curr_chunk;
1946 + *off_ptr= dst_offset;
1952 + Encodes or compares record
1954 + Copies data from original unpacked record into the preallocated chunkset,
1955 + or performs data comparison
1957 + @param info the hosting table
1958 + @param record the record in standard unpacked format
1959 + @param pos the target chunkset
1960 + @param is_compare flag indicating whether we should compare data or store
1963 + @return Status of comparison
1964 + @retval non-zero if comparison fond data differences
1965 + @retval zero otherwise
1968 +uint hp_process_record_data_to_chunkset(HP_SHARE *info, const uchar *record,
1969 + uchar *pos, uint is_compare)
1971 + uint i, dst_offset;
1972 + uchar *curr_chunk= pos;
1976 + if (memcmp(curr_chunk, record, (size_t) info->fixed_data_length))
1983 + memcpy(curr_chunk, record, (size_t) info->fixed_data_length);
1986 + if (!info->recordspace.is_variable_size)
1988 + /* Nothing more to copy */
1992 + dst_offset= info->fixed_data_length;
1994 + for (i= info->fixed_column_count; i < info->column_count; i++)
1997 + const uchar *data;
1999 + HP_COLUMNDEF *column= info->column_defs + i;
2001 + if (column->null_bit)
2003 + if (record[column->null_pos] & column->null_bit)
2005 + /* Skip all NULL values */
2010 + data= record + column->offset;
2011 + if (column->type == MYSQL_TYPE_VARCHAR)
2015 + /* >= 5.0.3 true VARCHAR */
2017 + /* Make sure to copy length indicator and actuals string bytes */
2018 + pack_length= column->length_bytes;
2019 + length= pack_length + (pack_length == 1 ? (uint) *data : uint2korr(data));
2021 + else if (column->type == MYSQL_TYPE_BLOB)
2025 + pack_length= column->length_bytes;
2026 + /* Just want to store the length, so not interested in the return code */
2027 + (void) hp_process_field_data_to_chunkset(info, data, pack_length,
2028 + &curr_chunk, &dst_offset, 0);
2029 + length= hp_calc_blob_length(pack_length, data);
2030 + memcpy(&data, data + pack_length, sizeof(char *));
2034 + length= column->length;
2037 + if (hp_process_field_data_to_chunkset(info, data, length, &curr_chunk,
2038 + &dst_offset, is_compare))
2044 +#if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
2045 + dump_chunk(info, curr_chunk);
2053 + Stores record in the heap table chunks
2055 + Copies data from original unpacked record into the preallocated chunkset
2057 + @param info the hosting table
2058 + @param record the record in standard unpacked format
2059 + @param pos the target chunkset
2062 +void hp_copy_record_data_to_chunkset(HP_SHARE *info, const uchar *record,
2065 + DBUG_ENTER("hp_copy_record_data_to_chunks");
2067 + hp_process_record_data_to_chunkset(info, record, pos, 0);
2074 + Macro to switch curr_chunk to the next chunk in the chunkset and reset
2077 +#if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
2078 +#define SWITCH_TO_NEXT_CHUNK_FOR_READ(share, curr_chunk, src_offset) \
2080 + curr_chunk= *((uchar**) (curr_chunk + share->recordspace.offset_link)); \
2082 + dump_chunk(share, curr_chunk); \
2085 +#define SWITCH_TO_NEXT_CHUNK_FOR_READ(share, curr_chunk, src_offset) \
2087 + curr_chunk= *((uchar**) (curr_chunk + share->recordspace.offset_link)); \
2093 + Copies record data from storage to unpacked record format
2095 + Copies data from chunkset into its original unpacked record
2097 + @param info the hosting table
2098 + @param[out] record the target record in standard unpacked format
2099 + @param pos the source chunkset
2101 + @return Status of conversion
2103 + @retval 1 out of memory
2106 +int hp_extract_record(HP_INFO *info, uchar *record, const uchar *pos)
2108 + uint i, src_offset;
2109 + const uchar *curr_chunk= pos;
2110 + HP_SHARE *share= info->s;
2111 + uint *rec_offsets= NULL;
2112 + uint *buf_offsets= NULL;
2114 + uint init_offset= share->blobs * sizeof(uint) * 2;
2116 + DBUG_ENTER("hp_extract_record");
2118 +#if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
2119 + if (share->recordspace.is_variable_size)
2121 + dump_chunk(share, curr_chunk);
2125 + memcpy(record, curr_chunk, (size_t) share->fixed_data_length);
2127 + if (!share->recordspace.is_variable_size)
2129 + /* Nothing more to copy */
2133 + /* Reserve space for rec_offsets and buf_offsets.*/
2134 + info->blob_offset= init_offset;
2135 + src_offset= share->fixed_data_length;
2137 + for (i= share->fixed_column_count; i < share->column_count; i++)
2139 + uint length, is_null= 0;
2142 + HP_COLUMNDEF *column= share->column_defs + i;
2144 + if (column->null_bit)
2146 + if (record[column->null_pos] & column->null_bit)
2154 + /* TODO: is memset really needed? */
2155 + memset(record + column->offset, 0, column->length);
2159 + to= record + column->offset;
2160 + if (column->type == MYSQL_TYPE_VARCHAR || column->type == MYSQL_TYPE_BLOB)
2162 + uint pack_length, i;
2165 + pack_length= column->length_bytes;
2167 + for (i= 0; i < pack_length; i++)
2169 + if (src_offset == share->recordspace.chunk_dataspace_length)
2171 + SWITCH_TO_NEXT_CHUNK_FOR_READ(share, curr_chunk, src_offset);
2173 + *to++= curr_chunk[src_offset++];
2176 + We copy byte-by-byte and then use hp_calc_blob_length to combine bytes
2177 + in the right order.
2179 + length= hp_calc_blob_length(pack_length, tmp);
2181 + if (column->type == MYSQL_TYPE_BLOB && length == 0)
2184 + Store a zero pointer for zero-length BLOBs because the server
2185 + relies on that (see Field_blob::val_*().
2187 + *(uchar **) to= 0;
2189 + else if (column->type == MYSQL_TYPE_BLOB && length > 0)
2191 + uint newsize= info->blob_offset + length;
2193 + DBUG_ASSERT(share->blobs > 0);
2195 + Make sure we have enough space in blob_buffer and store the pointer
2196 + to this blob in record.
2198 + if (info->blob_size < newsize)
2201 + ptr= my_realloc(info->blob_buffer, newsize, MYF(MY_ALLOW_ZERO_PTR));
2207 + if (info->blob_buffer == NULL)
2209 + memset(ptr, 0, init_offset);
2211 + info->blob_buffer= ptr;
2212 + info->blob_size= newsize;
2215 + rec_offsets= (uint *) info->blob_buffer;
2216 + buf_offsets= rec_offsets + share->blobs;
2218 + rec_offsets[nblobs]= (uint) (to - record);
2219 + buf_offsets[nblobs]= info->blob_offset;
2222 + /* Change 'to' so blob data is copied into blob_buffer */
2223 + to= info->blob_buffer + info->blob_offset;
2224 + info->blob_offset= newsize;
2229 + length= column->length;
2232 + while (length > 0)
2236 + to_copy= share->recordspace.chunk_dataspace_length - src_offset;
2239 + SWITCH_TO_NEXT_CHUNK_FOR_READ(share, curr_chunk, src_offset);
2240 + to_copy= share->recordspace.chunk_dataspace_length;
2243 + to_copy= min(length, to_copy);
2245 + memcpy(to, curr_chunk + src_offset, (size_t) to_copy);
2246 + src_offset+= to_copy;
2252 + /* Store pointers to blob data in record */
2253 + for (i= 0; i < nblobs; i++)
2255 + *(uchar **) (record + rec_offsets[i]) = info->blob_buffer + buf_offsets[i];
2260 --- a/storage/heap/hp_rfirst.c
2261 +++ b/storage/heap/hp_rfirst.c
2263 memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos),
2265 info->current_ptr = pos;
2266 - memcpy(record, pos, (size_t)share->reclength);
2267 + if (hp_extract_record(info, record, pos))
2269 + DBUG_RETURN(my_errno);
2272 If we're performing index_first on a table that was taken from
2273 table cache, info->lastkey_len is initialized to previous query.
2274 --- a/storage/heap/hp_rkey.c
2275 +++ b/storage/heap/hp_rkey.c
2277 if (!(keyinfo->flag & HA_NOSAME))
2278 memcpy(info->lastkey, key, (size_t) keyinfo->length);
2280 - memcpy(record, pos, (size_t) share->reclength);
2281 + if (hp_extract_record(info, record, pos))
2283 + DBUG_RETURN(my_errno);
2285 info->update= HA_STATE_AKTIV;
2288 --- a/storage/heap/hp_rlast.c
2289 +++ b/storage/heap/hp_rlast.c
2291 memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos),
2293 info->current_ptr = pos;
2294 - memcpy(record, pos, (size_t)share->reclength);
2295 + if (hp_extract_record(info, record, pos))
2297 + DBUG_RETURN(my_errno);
2299 info->update = HA_STATE_AKTIV;
2302 --- a/storage/heap/hp_rnext.c
2303 +++ b/storage/heap/hp_rnext.c
2304 @@ -109,7 +109,10 @@
2305 my_errno=HA_ERR_END_OF_FILE;
2306 DBUG_RETURN(my_errno);
2308 - memcpy(record,pos,(size_t) share->reclength);
2309 + if (hp_extract_record(info, record, pos))
2311 + DBUG_RETURN(my_errno);
2313 info->update=HA_STATE_AKTIV | HA_STATE_NEXT_FOUND;
2316 --- a/storage/heap/hp_rprev.c
2317 +++ b/storage/heap/hp_rprev.c
2319 my_errno=HA_ERR_END_OF_FILE;
2320 DBUG_RETURN(my_errno);
2322 - memcpy(record,pos,(size_t) share->reclength);
2323 + if (hp_extract_record(info, record, pos))
2325 + DBUG_RETURN(my_errno);
2327 info->update=HA_STATE_AKTIV | HA_STATE_PREV_FOUND;
2330 --- a/storage/heap/hp_rrnd.c
2331 +++ b/storage/heap/hp_rrnd.c
2334 DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
2336 - if (!info->current_ptr[share->reclength])
2337 + if (get_chunk_status(&share->recordspace, info->current_ptr) !=
2338 + CHUNK_STATUS_ACTIVE)
2340 + /* treat deleted and linked chunks as deleted */
2341 info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
2342 DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
2344 info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
2345 - memcpy(record,info->current_ptr,(size_t) share->reclength);
2346 + if (hp_extract_record(info, record, info->current_ptr))
2348 + DBUG_RETURN(my_errno);
2350 DBUG_PRINT("exit", ("found record at 0x%lx", (long) info->current_ptr));
2351 info->current_hash_ptr=0; /* Can't use rnext */
2355 pos= ++info->current_record;
2356 if (pos % share->block.records_in_block && /* Quick next record */
2357 - pos < share->records+share->deleted &&
2358 - (info->update & HA_STATE_PREV_FOUND))
2359 + pos < share->used_chunk_count + share->deleted_chunk_count &&
2360 + (info->update & HA_STATE_PREV_FOUND))
2362 - info->current_ptr+=share->block.recbuffer;
2363 + info->current_ptr+= share->block.recbufferlen;
2368 info->current_record=pos;
2370 - if (pos >= share->records+share->deleted)
2371 + if (pos >= share->used_chunk_count + share->deleted_chunk_count)
2374 DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
2376 hp_find_record(info, pos);
2379 - if (!info->current_ptr[share->reclength])
2380 + if (GET_CHUNK_STATUS(info, info->current_ptr) != CHUNK_STATUS_ACTIVE)
2382 + /* treat deleted and linked chunks as deleted */
2383 info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
2384 DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
2386 info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
2387 - memcpy(record,info->current_ptr,(size_t) share->reclength);
2388 + if (hp_extract_record(info, record, info->current_ptr))
2390 + DBUG_RETURN(my_errno);
2392 DBUG_PRINT("exit",("found record at 0x%lx",info->current_ptr));
2393 info->current_hash_ptr=0; /* Can't use rnext */
2395 --- a/storage/heap/hp_rsame.c
2396 +++ b/storage/heap/hp_rsame.c
2398 DBUG_ENTER("heap_rsame");
2401 - if (info->current_ptr[share->reclength])
2402 + if (get_chunk_status(&share->recordspace, info->current_ptr) ==
2403 + CHUNK_STATUS_ACTIVE)
2405 if (inx < -1 || inx >= (int) share->keys)
2408 DBUG_RETURN(my_errno);
2411 - memcpy(record,info->current_ptr,(size_t) share->reclength);
2412 + if (hp_extract_record(info, record, info->current_ptr))
2414 + DBUG_RETURN(my_errno);
2419 + /* treat deleted and linked chunks as deleted */
2423 DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
2424 --- a/storage/heap/hp_scan.c
2425 +++ b/storage/heap/hp_scan.c
2428 info->current_record= (ulong) ~0L; /* No current record */
2430 - info->next_block=0;
2435 DBUG_ENTER("heap_scan");
2437 pos= ++info->current_record;
2438 - if (pos < info->next_block)
2439 + if (pos >= share->recordspace.chunk_count)
2441 - info->current_ptr+=share->block.recbuffer;
2443 + DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
2447 - info->next_block+=share->block.records_in_block;
2448 - if (info->next_block >= share->records+share->deleted)
2450 - info->next_block= share->records+share->deleted;
2451 - if (pos >= info->next_block)
2454 - DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
2457 - hp_find_record(info, pos);
2459 - if (!info->current_ptr[share->reclength])
2461 + hp_find_record(info, pos);
2463 + if (get_chunk_status(&share->recordspace, info->current_ptr) !=
2464 + CHUNK_STATUS_ACTIVE)
2466 - DBUG_PRINT("warning",("Found deleted record"));
2467 + DBUG_PRINT("warning",("Found deleted record or secondary chunk"));
2468 info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
2469 DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
2471 info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
2472 - memcpy(record,info->current_ptr,(size_t) share->reclength);
2473 + if (hp_extract_record(info, record, info->current_ptr))
2475 + DBUG_RETURN(my_errno);
2477 info->current_hash_ptr=0; /* Can't use read_next */
2480 --- a/storage/heap/hp_test1.c
2481 +++ b/storage/heap/hp_test1.c
2483 #include <my_global.h>
2485 #include <m_string.h>
2486 +#include <mysql_com.h>
2489 static int get_options(int argc, char *argv[]);
2491 uchar record[128],key[32];
2492 const char *filename;
2493 HP_KEYDEF keyinfo[10];
2494 + HP_COLUMNDEF columndef[2];
2495 HA_KEYSEG keyseg[4];
2496 HP_CREATE_INFO hp_create_info;
2497 HP_SHARE *tmp_share;
2499 hp_create_info.reclength= 30;
2500 hp_create_info.max_records= (ulong) flag*100000L;
2501 hp_create_info.min_records= 10UL;
2502 + hp_create_info.columns= 2;
2503 + hp_create_info.columndef= columndef;
2504 + hp_create_info.fixed_key_fieldnr= 30;
2505 + hp_create_info.fixed_data_size= sizeof(char*) * 2;
2507 keyinfo[0].keysegs=1;
2508 keyinfo[0].seg=keyseg;
2510 keyinfo[0].seg[0].null_bit= 0;
2511 keyinfo[0].flag = HA_NOSAME;
2513 + memset(columndef, 0, 2 * sizeof(HP_COLUMNDEF));
2514 + columndef[0].type= MYSQL_TYPE_STRING;
2515 + columndef[0].offset= 1;
2516 + columndef[0].length= 6;
2517 + columndef[1].type= MYSQL_TYPE_STRING;
2518 + columndef[1].offset= 7;
2519 + columndef[1].length= 23;
2522 bzero((uchar*) flags,sizeof(flags));
2524 printf("- Creating heap-file\n");
2525 - if (heap_create(filename, &hp_create_info, &tmp_share, &unused) ||
2526 + if (heap_create(filename, &hp_create_info,
2527 + &tmp_share, &unused) ||
2528 !(file= heap_open(filename, 2)))
2530 printf("- Writing records:s\n");
2531 --- a/storage/heap/hp_test2.c
2532 +++ b/storage/heap/hp_test2.c
2535 #include "heapdef.h" /* Because of hp_find_block */
2537 +#include <mysql_com.h>
2539 #define MAX_RECORDS 100000
2544 uint write_count,update,opt_delete,check2,dupp_keys,found_key;
2545 + uint mem_per_keys;
2548 unsigned long key_check;
2550 HP_SHARE *tmp_share;
2551 HP_KEYDEF keyinfo[MAX_KEYS];
2552 HA_KEYSEG keyseg[MAX_KEYS*5];
2553 + HP_COLUMNDEF columndef[4];
2554 HEAP_PTR UNINIT_VAR(position);
2555 HP_CREATE_INFO hp_create_info;
2556 CHARSET_INFO *cs= &my_charset_latin1;
2558 get_options(argc,argv);
2560 bzero(&hp_create_info, sizeof(hp_create_info));
2561 - hp_create_info.max_table_size= 1024L*1024L;
2562 + hp_create_info.max_table_size= 1024L*1024L*1024L;
2563 hp_create_info.keys= keys;
2564 hp_create_info.keydef= keyinfo;
2565 hp_create_info.reclength= reclength;
2566 hp_create_info.max_records= (ulong) flag*100000L;
2567 hp_create_info.min_records= (ulong) recant/2;
2568 + hp_create_info.columns= 4;
2569 + hp_create_info.columndef= columndef;
2570 + hp_create_info.fixed_key_fieldnr= 4;
2571 + hp_create_info.fixed_data_size= 39;
2573 write_count=update=opt_delete=0;
2575 @@ -118,11 +125,30 @@
2576 keyinfo[3].seg[0].null_pos=38;
2577 keyinfo[3].seg[0].charset=cs;
2579 + memset(columndef, 0, 4 * sizeof(HP_COLUMNDEF));
2580 + columndef[0].type= MYSQL_TYPE_STRING;
2581 + columndef[0].offset= 0;
2582 + columndef[0].length= 6;
2583 + columndef[1].type= MYSQL_TYPE_STRING;
2584 + columndef[1].offset= 7;
2585 + columndef[1].length= 6;
2586 + columndef[2].type= MYSQL_TYPE_STRING;
2587 + columndef[2].offset= 12;
2588 + columndef[2].length= 8;
2589 + columndef[3].type= MYSQL_TYPE_TINY;
2590 + columndef[3].offset= 37;
2591 + columndef[3].length= 1;
2592 + columndef[3].null_bit= 1;
2593 + columndef[3].null_pos= 38;
2595 + mem_per_keys= (sizeof(char*) * 2) * 4;
2597 bzero((char*) key1,sizeof(key1));
2598 bzero((char*) key3,sizeof(key3));
2600 printf("- Creating heap-file\n");
2601 - if (heap_create(filename, &hp_create_info, &tmp_share, &unused) ||
2602 + if (heap_create(filename, &hp_create_info,
2603 + &tmp_share, &unused) ||
2604 !(file= heap_open(filename, 2)))
2606 signal(SIGINT,endprog);
2607 --- a/storage/heap/hp_write.c
2608 +++ b/storage/heap/hp_write.c
2613 -static uchar *next_free_record_pos(HP_SHARE *info);
2614 static HASH_INFO *hp_find_free_hash(HP_SHARE *info, HP_BLOCK *block,
2618 HP_KEYDEF *keydef, *end;
2620 HP_SHARE *share=info->s;
2621 + uint rec_length, chunk_count;
2623 DBUG_ENTER("heap_write");
2625 if (info->mode & O_RDONLY)
2627 DBUG_RETURN(my_errno=EACCES);
2630 - if (!(pos=next_free_record_pos(share)))
2632 + if ((share->records >= share->max_records && share->max_records) ||
2633 + (share->recordspace.total_data_length + share->index_length >=
2634 + share->max_table_size))
2636 + my_errno= HA_ERR_RECORD_FILE_FULL;
2637 + DBUG_RETURN(my_errno);
2640 + rec_length= hp_get_encoded_data_length(share, record, &chunk_count);
2642 + if (!(pos= hp_allocate_chunkset(&share->recordspace, chunk_count)))
2643 DBUG_RETURN(my_errno);
2650 - memcpy(pos,record,(size_t) share->reclength);
2651 - pos[share->reclength]=1; /* Mark record as not deleted */
2652 + hp_copy_record_data_to_chunkset(share, record, pos);
2654 if (++share->records == share->blength)
2655 share->blength+= share->blength;
2656 info->current_ptr=pos;
2662 - *((uchar**) pos)=share->del_link;
2663 - share->del_link=pos;
2664 - pos[share->reclength]=0; /* Record deleted */
2665 + hp_free_chunks(&share->recordspace, pos);
2667 DBUG_RETURN(my_errno);
2672 custom_arg.keyseg= keyinfo->seg;
2673 - custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos);
2674 + custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos,
2676 if (keyinfo->flag & HA_NOSAME)
2678 custom_arg.search_flag= SEARCH_FIND | SEARCH_UPDATE;
2679 @@ -129,42 +139,6 @@
2683 - /* Find where to place new record */
2685 -static uchar *next_free_record_pos(HP_SHARE *info)
2690 - DBUG_ENTER("next_free_record_pos");
2692 - if (info->del_link)
2694 - pos=info->del_link;
2695 - info->del_link= *((uchar**) pos);
2697 - DBUG_PRINT("exit",("Used old position: 0x%lx",(long) pos));
2700 - if (!(block_pos=(info->records % info->block.records_in_block)))
2702 - if ((info->records > info->max_records && info->max_records) ||
2703 - (info->data_length + info->index_length >= info->max_table_size))
2705 - my_errno=HA_ERR_RECORD_FILE_FULL;
2706 - DBUG_RETURN(NULL);
2708 - if (hp_get_new_block(&info->block,&length))
2709 - DBUG_RETURN(NULL);
2710 - info->data_length+=length;
2712 - DBUG_PRINT("exit",("Used new position: 0x%lx",
2713 - (long) ((uchar*) info->block.level_info[0].last_blocks+
2714 - block_pos * info->block.recbuffer)));
2715 - DBUG_RETURN((uchar*) info->block.level_info[0].last_blocks+
2716 - block_pos*info->block.recbuffer);
2721 Write a hash-key to the hash-index
2722 --- a/storage/heap/hp_update.c
2723 +++ b/storage/heap/hp_update.c
2726 #include "heapdef.h"
2728 -int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new)
2729 +int heap_update(HP_INFO *info, const uchar *old_record, const uchar *new_record)
2731 HP_KEYDEF *keydef, *end, *p_lastinx;
2733 my_bool auto_key_changed= 0;
2734 HP_SHARE *share= info->s;
2735 + uint old_length, new_length;
2736 + uint old_chunk_count, new_chunk_count;
2738 DBUG_ENTER("heap_update");
2741 pos=info->current_ptr;
2743 - if (info->opt_flag & READ_CHECK_USED && hp_rectest(info,old))
2744 + if (info->opt_flag & READ_CHECK_USED && hp_rectest(info, old_record))
2745 DBUG_RETURN(my_errno); /* Record changed */
2747 + old_length = hp_get_encoded_data_length(share, old_record, &old_chunk_count);
2748 + new_length = hp_get_encoded_data_length(share, new_record, &new_chunk_count);
2750 + if (new_chunk_count > old_chunk_count)
2752 + /* extend the old chunkset size as necessary, but do not shrink yet */
2753 + if (hp_reallocate_chunkset(&share->recordspace, new_chunk_count, pos))
2755 + DBUG_RETURN(my_errno); /* Out of memory or table space */
2759 if (--(share->records) < share->blength >> 1) share->blength>>= 1;
2762 p_lastinx= share->keydef + info->lastinx;
2763 for (keydef= share->keydef, end= keydef + share->keys; keydef < end; keydef++)
2765 - if (hp_rec_key_cmp(keydef, old, heap_new, 0))
2766 + if (hp_rec_key_cmp(keydef, old_record, new_record, 0))
2768 - if ((*keydef->delete_key)(info, keydef, old, pos, keydef == p_lastinx) ||
2769 - (*keydef->write_key)(info, keydef, heap_new, pos))
2770 + if ((*keydef->delete_key)(info, keydef, old_record, pos,
2771 + keydef == p_lastinx) ||
2772 + (*keydef->write_key)(info, keydef, new_record, pos))
2774 if (share->auto_key == (uint) (keydef - share->keydef + 1))
2775 auto_key_changed= 1;
2779 - memcpy(pos,heap_new,(size_t) share->reclength);
2780 + hp_copy_record_data_to_chunkset(share, new_record, pos);
2781 if (++(share->records) == share->blength) share->blength+= share->blength;
2783 + if (new_chunk_count < old_chunk_count)
2785 + /* Shrink the chunkset to its new size */
2786 + hp_reallocate_chunkset(&share->recordspace, new_chunk_count, pos);
2789 #if !defined(DBUG_OFF) && defined(EXTRA_HEAP_DEBUG)
2790 DBUG_EXECUTE("check_heap",heap_check_heap(info, 0););
2792 if (auto_key_changed)
2793 - heap_update_auto_increment(info, heap_new);
2794 + heap_update_auto_increment(info, new_record);
2799 if (keydef->algorithm == HA_KEY_ALG_BTREE)
2801 /* we don't need to delete non-inserted key from rb-tree */
2802 - if ((*keydef->write_key)(info, keydef, old, pos))
2803 + if ((*keydef->write_key)(info, keydef, old_record, pos))
2805 if (++(share->records) == share->blength)
2806 share->blength+= share->blength;
2809 while (keydef >= share->keydef)
2811 - if (hp_rec_key_cmp(keydef, old, heap_new, 0))
2812 + if (hp_rec_key_cmp(keydef, old_record, new_record, 0))
2814 - if ((*keydef->delete_key)(info, keydef, heap_new, pos, 0) ||
2815 - (*keydef->write_key)(info, keydef, old, pos))
2816 + if ((*keydef->delete_key)(info, keydef, new_record, pos, 0) ||
2817 + (*keydef->write_key)(info, keydef, old_record, pos))
2823 if (++(share->records) == share->blength)
2824 share->blength+= share->blength;
2826 + if (new_chunk_count > old_chunk_count)
2828 + /* Shrink the chunkset to its original size */
2829 + hp_reallocate_chunkset(&share->recordspace, old_chunk_count, pos);
2832 DBUG_RETURN(my_errno);
2835 +++ b/mysql-test/r/percona_heap_blob.result
2837 +SET @old_default_storage_engine=@@default_storage_engine;
2838 +SET default_storage_engine=MEMORY;
2839 +drop table if exists t1,t2,t3,t4,t5,t6,t7;
2840 +CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
2841 +show columns from t1;
2842 +Field Type Null Key Default Extra
2845 +c tinyblob YES NULL
2846 +d mediumtext YES NULL
2847 +e longtext YES NULL
2848 +CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000));
2850 +Note 1246 Converting column 'b' from VARBINARY to BLOB
2851 +Note 1246 Converting column 'c' from VARCHAR to TEXT
2852 +CREATE TABLE t4 (c varchar(65530) character set utf8 not null);
2854 +Note 1246 Converting column 'c' from VARCHAR to TEXT
2855 +show columns from t2;
2856 +Field Type Null Key Default Extra
2857 +a char(255) YES NULL
2858 +b mediumblob YES NULL
2859 +c longtext YES NULL
2860 +create table t3 (a long, b long byte);
2861 +show create TABLE t3;
2863 +t3 CREATE TABLE `t3` (
2866 +) ENGINE=MEMORY DEFAULT CHARSET=latin1
2867 +show create TABLE t4;
2869 +t4 CREATE TABLE `t4` (
2870 + `c` mediumtext CHARACTER SET utf8 NOT NULL
2871 +) ENGINE=MEMORY DEFAULT CHARSET=latin1
2872 +drop table t1,t2,t3,t4;
2873 +CREATE TABLE t1 (a char(257) default "hello");
2874 +ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
2875 +CREATE TABLE t2 (a char(256));
2876 +ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
2877 +CREATE TABLE t1 (a varchar(70000) default "hello");
2878 +ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
2879 +CREATE TABLE t2 (a blob default "hello");
2880 +ERROR 42000: BLOB/TEXT column 'a' can't have a default value
2881 +drop table if exists t1,t2;
2882 +create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
2883 +insert into t1 values (null,"a","A");
2884 +insert into t1 values (null,"bbb","BBB");
2885 +insert into t1 values (null,"ccc","CCC");
2886 +select last_insert_id();
2889 +select * from t1,t1 as t2;
2895 +2 bbb BBB 2 bbb BBB
2896 +3 ccc CCC 2 bbb BBB
2898 +2 bbb BBB 3 ccc CCC
2899 +3 ccc CCC 3 ccc CCC
2901 +create table t1 (a text);
2902 +insert into t1 values ('where');
2903 +update t1 set a='Where';
2908 +create table t1 (t text,c char(10),b blob, d varbinary(10));
2909 +insert into t1 values (NULL,NULL,NULL,NULL);
2910 +insert into t1 values ("","","","");
2911 +insert into t1 values ("hello","hello","hello","hello");
2912 +insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
2913 +insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
2914 +insert into t1 values ("a","a","a","a");
2915 +insert into t1 values (1,1,1,1);
2916 +insert into t1 values (NULL,NULL,NULL,NULL);
2917 +update t1 set c="",b=null where c="1";
2918 +lock tables t1 READ;
2919 +show full fields from t1;
2920 +Field Type Collation Null Key Default Extra Privileges Comment
2921 +t text latin1_swedish_ci YES NULL #
2922 +c char(10) latin1_swedish_ci YES NULL #
2923 +b blob NULL YES NULL #
2924 +d varbinary(10) NULL YES NULL #
2925 +lock tables t1 WRITE;
2926 +show full fields from t1;
2927 +Field Type Collation Null Key Default Extra Privileges Comment
2928 +t text latin1_swedish_ci YES NULL #
2929 +c char(10) latin1_swedish_ci YES NULL #
2930 +b blob NULL YES NULL #
2931 +d varbinary(10) NULL YES NULL #
2933 +select t from t1 where t like "hello";
2937 +select c from t1 where c like "hello";
2941 +select b from t1 where b like "hello";
2944 +select d from t1 where d like "hello";
2947 +select c from t1 having c like "hello";
2951 +select d from t1 having d like "hello";
2954 +select t from t1 where t like "%HELLO%";
2959 +select c from t1 where c like "%HELLO%";
2964 +select b from t1 where b like "%HELLO%";
2968 +select d from t1 where d like "%HELLO%";
2972 +select c from t1 having c like "%HELLO%";
2977 +select d from t1 having d like "%HELLO%";
2981 +select d from t1 having d like "%HE%LLO%";
2985 +select t from t1 order by t;
2995 +select c from t1 order by c;
3005 +select b from t1 order by b;
3015 +select d from t1 order by d;
3025 +select distinct t from t1;
3033 +select distinct b from t1;
3041 +select distinct t from t1 order by t;
3049 +select distinct b from t1 order by b;
3057 +select t from t1 group by t;
3065 +select b from t1 group by b;
3073 +set option sql_big_tables=1;
3074 +select distinct t from t1;
3082 +select distinct b from t1;
3090 +select distinct t from t1 order by t;
3098 +select distinct b from t1 order by b;
3106 +select distinct c from t1;
3113 +select distinct d from t1;
3122 +select distinct c from t1 order by c;
3129 +select distinct d from t1 order by d;
3138 +select c from t1 group by c;
3145 +select d from t1 group by d;
3154 +set option sql_big_tables=0;
3155 +select distinct * from t1;
3157 +NULL NULL NULL NULL
3159 +hello hello hello hello
3160 +HELLO HELLO HELLO HELLO
3161 +HELLO MY HELLO MY HELLO MY HELLO MY
3164 +select t,count(*) from t1 group by t;
3172 +select b,count(*) from t1 group by b;
3180 +select c,count(*) from t1 group by c;
3187 +select d,count(*) from t1 group by d;
3198 +t1_id bigint(21) NOT NULL auto_increment,
3199 +_field_72 varchar(128) DEFAULT '' NOT NULL,
3200 +_field_95 varchar(32),
3201 +_field_115 tinyint(4) DEFAULT '0' NOT NULL,
3202 +_field_122 tinyint(4) DEFAULT '0' NOT NULL,
3203 +_field_126 tinyint(4),
3204 +_field_134 tinyint(4),
3205 +PRIMARY KEY (t1_id),
3206 +UNIQUE _field_72 (_field_72),
3207 +KEY _field_115 (_field_115),
3208 +KEY _field_122 (_field_122)
3210 +INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
3211 +INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
3212 +INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
3214 +seq_0_id bigint(21) DEFAULT '0' NOT NULL,
3215 +seq_1_id bigint(21) DEFAULT '0' NOT NULL,
3216 +PRIMARY KEY (seq_0_id,seq_1_id)
3218 +INSERT INTO t2 VALUES (1,1);
3219 +INSERT INTO t2 VALUES (2,1);
3220 +INSERT INTO t2 VALUES (2,2);
3222 +t3_id bigint(21) NOT NULL auto_increment,
3223 +_field_131 varchar(128),
3224 +_field_133 tinyint(4) DEFAULT '0' NOT NULL,
3225 +_field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
3226 +_field_137 tinyint(4),
3227 +_field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
3229 +_field_142 tinyint(4) DEFAULT '0' NOT NULL,
3230 +_field_145 tinyint(4) DEFAULT '0' NOT NULL,
3231 +_field_148 tinyint(4) DEFAULT '0' NOT NULL,
3232 +PRIMARY KEY (t3_id),
3233 +KEY _field_133 (_field_133),
3234 +KEY _field_135 (_field_135),
3235 +KEY _field_139 (_field_139),
3236 +KEY _field_142 (_field_142),
3237 +KEY _field_145 (_field_145),
3238 +KEY _field_148 (_field_148)
3240 +INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
3241 +INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0);
3243 +seq_0_id bigint(21) DEFAULT '0' NOT NULL,
3244 +seq_1_id bigint(21) DEFAULT '0' NOT NULL,
3245 +PRIMARY KEY (seq_0_id,seq_1_id)
3247 +INSERT INTO t4 VALUES (1,1);
3248 +INSERT INTO t4 VALUES (2,1);
3250 +t5_id bigint(21) NOT NULL auto_increment,
3251 +_field_149 tinyint(4),
3252 +_field_156 varchar(128) DEFAULT '' NOT NULL,
3253 +_field_157 varchar(128) DEFAULT '' NOT NULL,
3254 +_field_158 varchar(128) DEFAULT '' NOT NULL,
3255 +_field_159 varchar(128) DEFAULT '' NOT NULL,
3256 +_field_160 varchar(128) DEFAULT '' NOT NULL,
3257 +_field_161 varchar(128) DEFAULT '' NOT NULL,
3258 +PRIMARY KEY (t5_id),
3259 +KEY _field_156 (_field_156),
3260 +KEY _field_157 (_field_157),
3261 +KEY _field_158 (_field_158),
3262 +KEY _field_159 (_field_159),
3263 +KEY _field_160 (_field_160),
3264 +KEY _field_161 (_field_161)
3266 +INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
3267 +INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
3269 +seq_0_id bigint(21) DEFAULT '0' NOT NULL,
3270 +seq_1_id bigint(21) DEFAULT '0' NOT NULL,
3271 +PRIMARY KEY (seq_0_id,seq_1_id)
3273 +INSERT INTO t6 VALUES (1,1);
3274 +INSERT INTO t6 VALUES (1,2);
3275 +INSERT INTO t6 VALUES (2,2);
3277 +t7_id bigint(21) NOT NULL auto_increment,
3278 +_field_143 tinyint(4),
3279 +_field_165 varchar(32),
3280 +_field_166 smallint(6) DEFAULT '0' NOT NULL,
3281 +PRIMARY KEY (t7_id),
3282 +KEY _field_166 (_field_166)
3284 +INSERT INTO t7 VALUES (1,0,'High',1);
3285 +INSERT INTO t7 VALUES (2,0,'Medium',2);
3286 +INSERT INTO t7 VALUES (3,0,'Low',3);
3287 +select replace(t3._field_140, "\r","^M"),t3_id,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), replace(min(t3._field_140), "\r","^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
3288 +replace(t3._field_140, "\r","^M") t3_id min(t3._field_131) min(t3._field_135) min(t3._field_139) min(t3._field_137) min(link_alias_142._field_165) min(link_alias_133._field_72) min(t3._field_145) min(link_alias_148._field_156) replace(min(t3._field_140), "\r","^M") t3_id
3291 +1 1 test job 1 0000-00-00 00:00:00 1999-02-25 22:43:32 0 High admin 0 tomato test^M
3294 +drop table t1,t2,t3,t4,t5,t6,t7;
3295 +create table t1 (a blob);
3296 +insert into t1 values ("empty"),("");
3297 +select a,reverse(a) from t1;
3302 +create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default '');
3304 +Warning 1101 BLOB/TEXT column 'imagem' can't have a default value
3305 +insert into t1 (id) values (1);
3307 +charset(load_file('../../std_data/words.dat')),
3308 +collation(load_file('../../std_data/words.dat')),
3309 +coercibility(load_file('../../std_data/words.dat'));
3310 +charset(load_file('../../std_data/words.dat')) collation(load_file('../../std_data/words.dat')) coercibility(load_file('../../std_data/words.dat'))
3312 +explain extended select
3313 +charset(load_file('MYSQLTEST_VARDIR/std_data/words.dat')),
3314 +collation(load_file('MYSQLTEST_VARDIR/std_data/words.dat')),
3315 +coercibility(load_file('MYSQLTEST_VARDIR/std_data/words.dat'));
3316 +id select_type table type possible_keys key key_len ref rows filtered Extra
3317 +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
3319 +Note 1003 select charset(load_file('MYSQLTEST_VARDIR/std_data/words.dat')) AS `charset(load_file('MYSQLTEST_VARDIR/std_data/words.dat'))`,collation(load_file('MYSQLTEST_VARDIR/std_data/words.dat')) AS `collation(load_file('MYSQLTEST_VARDIR/std_data/words.dat'))`,coercibility(load_file('MYSQLTEST_VARDIR/std_data/words.dat')) AS `coercibility(load_file('MYSQLTEST_VARDIR/std_data/words.dat'))`
3320 +update t1 set imagem=load_file('MYSQLTEST_VARDIR/std_data/words.dat') where id=1;
3321 +select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1;
3322 +if(imagem is null, "ERROR", "OK") length(imagem)
3325 +create table t1 select load_file('MYSQLTEST_VARDIR/std_data/words.dat') l;
3326 +show full fields from t1;
3327 +Field Type Collation Null Key Default Extra Privileges Comment
3328 +l longblob NULL YES NULL #
3330 +create table t1 (id integer primary key auto_increment, txt text not null);
3331 +insert into t1 (txt) values ('Chevy ');
3332 +select * from t1 where txt='Chevy';
3335 +select * from t1 where txt='Chevy ';
3338 +select * from t1 where txt='Chevy ' or txt='Chevy';
3341 +select * from t1 where txt='Chevy' or txt='Chevy ';
3344 +select * from t1 where id='1' or id='2';
3347 +insert into t1 (txt) values('Ford');
3348 +select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
3352 +select * from t1 where txt='Chevy' or txt='Chevy ';
3355 +select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
3358 +select * from t1 where txt in ('Chevy ','Chevy');
3361 +select * from t1 where txt in ('Chevy');
3364 +select * from t1 where txt between 'Chevy' and 'Chevy';
3367 +select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
3370 +select * from t1 where txt between 'Chevy' and 'Chevy ';
3373 +select * from t1 where txt < 'Chevy ';
3375 +select * from t1 where txt <= 'Chevy';
3378 +select * from t1 where txt > 'Chevy';
3381 +select * from t1 where txt >= 'Chevy';
3386 +create table t1 (id integer primary key auto_increment, txt text);
3387 +insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
3388 +select * from t1 where txt='Chevy' or txt is NULL;
3393 +explain select * from t1 where txt='Chevy' or txt is NULL;
3394 +id select_type table type possible_keys key key_len ref rows Extra
3395 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
3396 +select * from t1 where txt='Chevy ';
3400 +select * from t1 where txt='Chevy ' or txt='Chevy';
3404 +select * from t1 where txt='Chevy' or txt='Chevy ';
3408 +select * from t1 where id='1' or id='2';
3412 +insert into t1 (txt) values('Ford');
3413 +select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
3418 +select * from t1 where txt='Chevy' or txt='Chevy ';
3422 +select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
3426 +select * from t1 where txt in ('Chevy ','Chevy');
3430 +select * from t1 where txt in ('Chevy');
3434 +select * from t1 where txt between 'Chevy' and 'Chevy';
3438 +select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
3442 +select * from t1 where txt between 'Chevy' and 'Chevy ';
3446 +select * from t1 where txt < 'Chevy ';
3448 +select * from t1 where txt < 'Chevy ' or txt is NULL;
3451 +select * from t1 where txt <= 'Chevy';
3455 +select * from t1 where txt > 'Chevy';
3458 +select * from t1 where txt >= 'Chevy';
3463 +alter table t1 modify column txt blob;
3464 +explain select * from t1 where txt='Chevy' or txt is NULL;
3465 +id select_type table type possible_keys key key_len ref rows Extra
3466 +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
3467 +select * from t1 where txt='Chevy' or txt is NULL;
3471 +explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
3472 +id select_type table type possible_keys key key_len ref rows Extra
3473 +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using filesort
3474 +select * from t1 where txt='Chevy' or txt is NULL order by txt;
3479 +CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY (i));
3480 +INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,'');
3481 +select max(i) from t1 where c = '';
3485 +CREATE table t1 (a blob);
3486 +insert into t1 values ('b'),('a\0'),('a'),('a '),('aa'),(NULL);
3487 +select hex(a) from t1 order by a;
3495 +select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
3503 +alter table t1 modify a varbinary(5);
3504 +select hex(a) from t1 order by a;
3512 +select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
3520 +alter table t1 modify a char(5);
3521 +select hex(a) from t1 order by a;
3529 +select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
3537 +alter table t1 modify a binary(5);
3538 +select hex(a) from t1 order by a;
3546 +select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
3555 +create table t1 (a text default '');
3557 +Warning 1101 BLOB/TEXT column 'a' can't have a default value
3558 +show create table t1;
3560 +t1 CREATE TABLE `t1` (
3562 +) ENGINE=MEMORY DEFAULT CHARSET=latin1
3563 +insert into t1 values (default);
3568 +set @@sql_mode='TRADITIONAL';
3569 +create table t1 (a text default '');
3570 +ERROR 42000: BLOB/TEXT column 'a' can't have a default value
3572 +CREATE TABLE t (c TEXT CHARSET ASCII);
3573 +INSERT INTO t (c) VALUES (REPEAT('1',65537));
3575 +Warning 1265 Data truncated for column 'c' at row 1
3576 +INSERT INTO t (c) VALUES (REPEAT('2',65536));
3578 +Warning 1265 Data truncated for column 'c' at row 1
3579 +INSERT INTO t (c) VALUES (REPEAT('3',65535));
3580 +SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
3581 +LENGTH(c) CHAR_LENGTH(c)
3586 +drop table if exists b15776;
3587 +create table b15776 (data blob(2147483647));
3589 +create table b15776 (data blob(-1));
3590 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
3591 +create table b15776 (data blob(2147483648));
3593 +create table b15776 (data blob(4294967294));
3595 +create table b15776 (data blob(4294967295));
3597 +create table b15776 (data blob(4294967296));
3598 +ERROR 42000: Display width out of range for column 'data' (max = 4294967295)
3599 +CREATE TABLE b15776 (a blob(2147483647), b blob(2147483648), c blob(4294967295), a1 text(2147483647), b1 text(2147483648), c1 text(4294967295) );
3600 +show columns from b15776;
3601 +Field Type Null Key Default Extra
3602 +a longblob YES NULL
3603 +b longblob YES NULL
3604 +c longblob YES NULL
3605 +a1 longtext YES NULL
3606 +b1 longtext YES NULL
3607 +c1 longtext YES NULL
3609 +CREATE TABLE b15776 (a blob(4294967296));
3610 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3611 +CREATE TABLE b15776 (a text(4294967296));
3612 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3613 +CREATE TABLE b15776 (a blob(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
3614 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3615 +CREATE TABLE b15776 (a text(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
3616 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3617 +CREATE TABLE b15776 (a int(0));
3618 +INSERT INTO b15776 values (NULL), (1), (42), (654);
3619 +SELECT * from b15776 ORDER BY a;
3626 +CREATE TABLE b15776 (a int(-1));
3627 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
3628 +CREATE TABLE b15776 (a int(255));
3630 +CREATE TABLE b15776 (a int(256));
3631 +ERROR 42000: Display width out of range for column 'a' (max = 255)
3632 +CREATE TABLE b15776 (data blob(-1));
3633 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
3634 +CREATE TABLE b15776 (a char(2147483647));
3635 +ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
3636 +CREATE TABLE b15776 (a char(2147483648));
3637 +ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
3638 +CREATE TABLE b15776 (a char(4294967295));
3639 +ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
3640 +CREATE TABLE b15776 (a char(4294967296));
3641 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3642 +CREATE TABLE b15776 (a year(4294967295));
3643 +INSERT INTO b15776 VALUES (42);
3644 +SELECT * FROM b15776;
3648 +CREATE TABLE b15776 (a year(4294967296));
3649 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3650 +CREATE TABLE b15776 (a year(0));
3652 +CREATE TABLE b15776 (a year(-2));
3653 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1
3654 +CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
3655 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3656 +CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
3657 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3658 +CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
3659 +ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
3660 +CREATE TABLE b15776 select cast(null as char(4294967295));
3661 +show columns from b15776;
3662 +Field Type Null Key Default Extra
3663 +cast(null as char(4294967295)) char(0) YES NULL
3665 +CREATE TABLE b15776 select cast(null as nchar(4294967295));
3666 +show columns from b15776;
3667 +Field Type Null Key Default Extra
3668 +cast(null as nchar(4294967295)) char(0) YES NULL
3670 +CREATE TABLE b15776 select cast(null as binary(4294967295));
3671 +show columns from b15776;
3672 +Field Type Null Key Default Extra
3673 +cast(null as binary(4294967295)) binary(0) YES NULL
3675 +explain select cast(1 as char(4294967295));
3676 +id select_type table type possible_keys key key_len ref rows Extra
3677 +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
3678 +explain select cast(1 as nchar(4294967295));
3679 +id select_type table type possible_keys key key_len ref rows Extra
3680 +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
3681 +explain select cast(1 as binary(4294967295));
3682 +id select_type table type possible_keys key key_len ref rows Extra
3683 +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
3684 +explain select cast(1 as char(4294967296));
3685 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3686 +explain select cast(1 as nchar(4294967296));
3687 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3688 +explain select cast(1 as binary(4294967296));
3689 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3690 +explain select cast(1 as decimal(-1));
3691 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
3692 +explain select cast(1 as decimal(64, 30));
3693 +id select_type table type possible_keys key key_len ref rows Extra
3694 +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
3695 +explain select cast(1 as decimal(64, 999999999999999999999999999999));
3696 +Got one of the listed errors
3697 +explain select cast(1 as decimal(4294967296));
3698 +Got one of the listed errors
3699 +explain select cast(1 as decimal(999999999999999999999999999999999999));
3700 +Got one of the listed errors
3701 +explain select convert(1, char(4294967295));
3702 +id select_type table type possible_keys key key_len ref rows Extra
3703 +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
3704 +explain select convert(1, char(4294967296));
3705 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3706 +explain select convert(1, char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
3707 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3708 +explain select convert(1, nchar(4294967295));
3709 +id select_type table type possible_keys key key_len ref rows Extra
3710 +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
3711 +explain select convert(1, nchar(4294967296));
3712 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3713 +explain select convert(1, nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
3714 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3715 +explain select convert(1, binary(4294967295));
3716 +id select_type table type possible_keys key key_len ref rows Extra
3717 +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
3718 +explain select convert(1, binary(4294967296));
3719 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3720 +explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
3721 +ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
3723 +CREATE TABLE t1(id INT NOT NULL);
3724 +CREATE TABLE t2(id INT NOT NULL, c TEXT NOT NULL);
3725 +INSERT INTO t1 VALUES (1);
3726 +INSERT INTO t2 VALUES (1, '');
3727 +UPDATE t2 SET c = REPEAT('1', 70000);
3729 +Warning 1265 Data truncated for column 'c' at row 1
3730 +SELECT LENGTH(c) FROM t2;
3733 +UPDATE t1 LEFT JOIN t2 USING(id) SET t2.c = REPEAT('1', 70000) WHERE t1.id = 1;
3735 +Warning 1265 Data truncated for column 'c' at row 1
3736 +SELECT LENGTH(c) FROM t2;
3740 +# Bug #52160: crash and inconsistent results when grouping
3741 +# by a function and column
3742 +CREATE FUNCTION f1() RETURNS TINYBLOB RETURN 1;
3743 +CREATE TABLE t1(a CHAR(1));
3744 +INSERT INTO t1 VALUES ('0'), ('0');
3745 +SELECT COUNT(*) FROM t1 GROUP BY f1(), a;
3750 +SET default_storage_engine=@old_default_storage_engine;
3751 +SET @old_max_heap_table_size = @@global.max_heap_table_size;
3752 +SET @old_max_allowed_packet = @@global.max_allowed_packet;
3753 +SET GLOBAL max_heap_table_size = 18 * 1024 * 1024;
3754 +SET GLOBAL max_allowed_packet = 24 * 1024 * 1024;
3755 +drop table if exists t1;
3756 +CREATE TABLE t1 (data LONGBLOB) ENGINE=memory;
3757 +INSERT INTO t1 (data) VALUES (NULL);
3758 +UPDATE t1 set data=repeat('a',18*1024*1024);
3759 +select length(data) from t1;
3762 +delete from t1 where left(data,1)='a';
3764 +INSERT INTO t1 (data) VALUES (repeat('a',1*1024*1024));
3765 +INSERT INTO t1 (data) VALUES (repeat('b',16*1024*1024-1024));
3766 +delete from t1 where left(data,1)='b';
3767 +UPDATE t1 set data=repeat('c',17*1024*1024);
3768 +delete from t1 where left(data,1)='c';
3769 +INSERT INTO t1 set data=repeat('a',18*1024*1024);
3770 +select length(data) from t1;
3773 +alter table t1 modify data blob;
3774 +select length(data) from t1;
3778 +CREATE TABLE t1 (data BLOB) ENGINE=myisam;
3779 +INSERT INTO t1 (data) VALUES (NULL);
3780 +UPDATE t1 set data=repeat('a',18*1024*1024);
3782 +Warning 1265 Data truncated for column 'data' at row 1
3783 +select length(data) from t1;
3787 +SET GLOBAL max_allowed_packet = @old_max_allowed_packet;
3788 +SET GLOBAL max_heap_table_size = @old_max_heap_table_size;
3790 +++ b/mysql-test/r/percona_heap_bug783366.result
3792 +drop table if exists t1;
3794 +f1 VARCHAR ( 128 ) ,
3796 +PRIMARY KEY ( f2 ( 2 ) , f1 )
3798 +ENGINE=HEAP KEY_BLOCK_SIZE = 512;
3799 +INSERT IGNORE INTO t1 VALUES ( 'te' , 'm') , ( NULL , 'think' );
3801 +Warning 1048 Column 'f1' cannot be null
3802 +INSERT IGNORE INTO t1 VALUES ( 'te' , 'm') , ( NULL , 'think' );
3804 +Warning 1048 Column 'f1' cannot be null
3807 +++ b/mysql-test/r/percona_heap_bug783451.result
3809 +DROP TABLE IF EXISTS local_1_1;
3810 +CREATE TABLE IF NOT EXISTS local_1_1 ( f1 VARCHAR ( 32 ) NOT NULL , f2 VARCHAR ( 128 ) NOT NULL DEFAULT 'cboepfaobilcchabvglgjdbynog' , f3 VARCHAR ( 32 ) NOT NULL , f4 VARBINARY ( 32 ) NOT NULL , f5 VARBINARY ( 1024 ) DEFAULT 'ycboepfao' , KEY ( f1 /* ( 2 ) */ , f2 /* ( 2 ) */ ) ) ENGINE=HEAP KEY_BLOCK_SIZE = 512;
3811 +INSERT IGNORE INTO local_1_1 VALUES ( REPEAT( 'ervydbimvmbqmsowdbsa' , 1 ) , 'v' , NULL , NULL , REPEAT( 'mervydbimvmbqms' , 5 ) ) , ( 'p' , 6 , 'n' , REPEAT( 'imervydbimvmbqmsowdbs' , 4 ) , 'do' ) , ( NULL , NULL , REPEAT( 'himervydbimvmbqmsowdbsaybudvwaamvhempuublmia' , 6 ) , REPEAT('X', POW(2, 20) * 2) , REPEAT('X', POW(2, 20) * 2) ) , ( REPEAT('X', POW(2, 20) * 2) , REPEAT( 'Y' , 763 ) , NULL , REPEAT('X', POW(2, 20) * 2) , NULL ) , ( REPEAT('X', POW(2, 20) * 2) , 'time' , 'how' , 2 , REPEAT( 'Y' , 107 ) ) , ( REPEAT( 'hyshimervydbimvmbqmsowdbsaybud' , 5 ) , 2 , 8 , NULL , REPEAT('X', POW(2, 20) * 2) ) , ( 'come' , NULL , 'i' , NULL , REPEAT('X', POW(2, 20) * 2) );
3813 +Warning 1048 Column 'f3' cannot be null
3814 +Warning 1048 Column 'f4' cannot be null
3815 +Warning 1265 Data truncated for column 'f4' at row 2
3816 +Warning 1048 Column 'f1' cannot be null
3817 +Warning 1048 Column 'f2' cannot be null
3818 +Warning 1265 Data truncated for column 'f3' at row 3
3819 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3820 +Warning 1048 Column 'f4' cannot be null
3821 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3822 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3823 +Warning 1048 Column 'f1' cannot be null
3824 +Warning 1265 Data truncated for column 'f2' at row 4
3825 +Warning 1048 Column 'f3' cannot be null
3826 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3827 +Warning 1048 Column 'f4' cannot be null
3828 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3829 +Warning 1048 Column 'f1' cannot be null
3830 +Warning 1265 Data truncated for column 'f1' at row 6
3831 +Warning 1048 Column 'f4' cannot be null
3832 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3833 +Warning 1048 Column 'f2' cannot be null
3834 +Warning 1048 Column 'f4' cannot be null
3835 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3836 +INSERT IGNORE INTO local_1_1 VALUES ( 'ok' , NULL , REPEAT( 'Y' , 651 ) , 2 , 5 ) , ( REPEAT( 'zylcdzkfrqpihyshimervydbimvmbqmsowdbsaybu' , 3 ) , REPEAT( 'Y' , 282 ) , REPEAT( 'X' , 0 ) , REPEAT( 'Y' , 369 ) , 'g' ) , ( 'think' , REPEAT('X', POW(2, 20) * 2), NULL , NULL , REPEAT('X', POW(2, 20) * 2) ) , ( REPEAT( 'Y' , 468 ) , REPEAT( 'dfvbrzylcd' , 6 ) , REPEAT( 'Y' , 264 ) , NULL , 'c' ) , ( NULL , NULL , REPEAT( 'srdfvbrzylcdzkfrqpihyshimervydbimvmbqms' , 0 ) , REPEAT( 'Y' , 244 ) , 7 ) , ( REPEAT( 'Y' , 0 ) , 'how' , 'going' , 'q' , NULL );
3838 +Warning 1048 Column 'f2' cannot be null
3839 +Warning 1265 Data truncated for column 'f3' at row 1
3840 +Warning 1265 Data truncated for column 'f1' at row 2
3841 +Warning 1265 Data truncated for column 'f2' at row 2
3842 +Warning 1265 Data truncated for column 'f4' at row 2
3843 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3844 +Warning 1048 Column 'f2' cannot be null
3845 +Warning 1048 Column 'f3' cannot be null
3846 +Warning 1048 Column 'f4' cannot be null
3847 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3848 +Warning 1265 Data truncated for column 'f1' at row 4
3849 +Warning 1265 Data truncated for column 'f3' at row 4
3850 +Warning 1048 Column 'f4' cannot be null
3851 +Warning 1048 Column 'f1' cannot be null
3852 +Warning 1048 Column 'f2' cannot be null
3853 +Warning 1265 Data truncated for column 'f4' at row 5
3854 +INSERT IGNORE INTO local_1_1 VALUES ( REPEAT('X', POW(2, 20) * 2) , NULL , NULL , NULL , REPEAT('X', POW(2, 20) * 2) ) , ( REPEAT('X', POW(2, 20) * 2) , NULL , REPEAT('X', POW(2, 20) * 2) , 'this' , 'e' ) , ( NULL , 'think' , NULL , 'were' , NULL ) , ( 9 , 'l' , 'c' , 3 , REPEAT( 'geysrdfvbrzylcdzkfrqpihyshimervydbi' , 5 ) ) , ( NULL , NULL , NULL , 'h' , 'w' );
3856 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3857 +Warning 1048 Column 'f1' cannot be null
3858 +Warning 1048 Column 'f2' cannot be null
3859 +Warning 1048 Column 'f3' cannot be null
3860 +Warning 1048 Column 'f4' cannot be null
3861 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3862 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3863 +Warning 1048 Column 'f1' cannot be null
3864 +Warning 1048 Column 'f2' cannot be null
3865 +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated
3866 +Warning 1048 Column 'f3' cannot be null
3867 +Warning 1048 Column 'f1' cannot be null
3868 +Warning 1048 Column 'f3' cannot be null
3869 +Warning 1048 Column 'f1' cannot be null
3870 +Warning 1048 Column 'f2' cannot be null
3871 +Warning 1048 Column 'f3' cannot be null
3872 +INSERT IGNORE INTO local_1_1 SELECT * FROM local_1_1;
3873 +INSERT IGNORE INTO local_1_1 SELECT * FROM local_1_1;
3874 +UPDATE local_1_1 SET f5 = REPEAT ('X', 215566);
3876 +Warning 1265 Data truncated for column 'f5' at row 1
3877 +Warning 1265 Data truncated for column 'f5' at row 2
3878 +Warning 1265 Data truncated for column 'f5' at row 3
3879 +Warning 1265 Data truncated for column 'f5' at row 4
3880 +Warning 1265 Data truncated for column 'f5' at row 5
3881 +Warning 1265 Data truncated for column 'f5' at row 6
3882 +Warning 1265 Data truncated for column 'f5' at row 7
3883 +Warning 1265 Data truncated for column 'f5' at row 8
3884 +Warning 1265 Data truncated for column 'f5' at row 9
3885 +Warning 1265 Data truncated for column 'f5' at row 10
3886 +Warning 1265 Data truncated for column 'f5' at row 11
3887 +Warning 1265 Data truncated for column 'f5' at row 12
3888 +Warning 1265 Data truncated for column 'f5' at row 13
3889 +Warning 1265 Data truncated for column 'f5' at row 14
3890 +Warning 1265 Data truncated for column 'f5' at row 15
3891 +Warning 1265 Data truncated for column 'f5' at row 16
3892 +Warning 1265 Data truncated for column 'f5' at row 17
3893 +Warning 1265 Data truncated for column 'f5' at row 18
3894 +Warning 1265 Data truncated for column 'f5' at row 19
3895 +Warning 1265 Data truncated for column 'f5' at row 20
3896 +Warning 1265 Data truncated for column 'f5' at row 21
3897 +Warning 1265 Data truncated for column 'f5' at row 22
3898 +Warning 1265 Data truncated for column 'f5' at row 23
3899 +Warning 1265 Data truncated for column 'f5' at row 24
3900 +Warning 1265 Data truncated for column 'f5' at row 25
3901 +Warning 1265 Data truncated for column 'f5' at row 26
3902 +Warning 1265 Data truncated for column 'f5' at row 27
3903 +Warning 1265 Data truncated for column 'f5' at row 28
3904 +Warning 1265 Data truncated for column 'f5' at row 29
3905 +Warning 1265 Data truncated for column 'f5' at row 30
3906 +Warning 1265 Data truncated for column 'f5' at row 31
3907 +Warning 1265 Data truncated for column 'f5' at row 32
3908 +Warning 1265 Data truncated for column 'f5' at row 33
3909 +Warning 1265 Data truncated for column 'f5' at row 34
3910 +Warning 1265 Data truncated for column 'f5' at row 35
3911 +Warning 1265 Data truncated for column 'f5' at row 36
3912 +Warning 1265 Data truncated for column 'f5' at row 37
3913 +Warning 1265 Data truncated for column 'f5' at row 38
3914 +Warning 1265 Data truncated for column 'f5' at row 39
3915 +Warning 1265 Data truncated for column 'f5' at row 40
3916 +Warning 1265 Data truncated for column 'f5' at row 41
3917 +Warning 1265 Data truncated for column 'f5' at row 42
3918 +Warning 1265 Data truncated for column 'f5' at row 43
3919 +Warning 1265 Data truncated for column 'f5' at row 44
3920 +Warning 1265 Data truncated for column 'f5' at row 45
3921 +Warning 1265 Data truncated for column 'f5' at row 46
3922 +Warning 1265 Data truncated for column 'f5' at row 47
3923 +Warning 1265 Data truncated for column 'f5' at row 48
3924 +Warning 1265 Data truncated for column 'f5' at row 49
3925 +Warning 1265 Data truncated for column 'f5' at row 50
3926 +Warning 1265 Data truncated for column 'f5' at row 51
3927 +Warning 1265 Data truncated for column 'f5' at row 52
3928 +Warning 1265 Data truncated for column 'f5' at row 53
3929 +Warning 1265 Data truncated for column 'f5' at row 54
3930 +Warning 1265 Data truncated for column 'f5' at row 55
3931 +Warning 1265 Data truncated for column 'f5' at row 56
3932 +Warning 1265 Data truncated for column 'f5' at row 57
3933 +Warning 1265 Data truncated for column 'f5' at row 58
3934 +Warning 1265 Data truncated for column 'f5' at row 59
3935 +Warning 1265 Data truncated for column 'f5' at row 60
3936 +Warning 1265 Data truncated for column 'f5' at row 61
3937 +Warning 1265 Data truncated for column 'f5' at row 62
3938 +Warning 1265 Data truncated for column 'f5' at row 63
3939 +Warning 1265 Data truncated for column 'f5' at row 64
3940 +DROP TABLE local_1_1;
3942 +++ b/mysql-test/r/percona_heap_bug784464.result
3944 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
3945 +PRIMARY KEY (f1)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3946 +SHOW TABLE STATUS LIKE 't1';
3947 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3948 +t1 MEMORY 10 Fixed 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC
3950 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
3951 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=33 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3952 +ERROR 42000: Incorrect usage/placement of 'key_block_size'
3953 +SHOW TABLE STATUS LIKE 't1';
3954 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3955 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
3956 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=34 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3957 +SHOW TABLE STATUS LIKE 't1';
3958 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3959 +t1 MEMORY 10 Dynamic 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=34
3961 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
3962 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=123 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3963 +SHOW TABLE STATUS LIKE 't1';
3964 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3965 +t1 MEMORY 10 Dynamic 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=123
3967 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
3968 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=1000 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3969 +SHOW TABLE STATUS LIKE 't1';
3970 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3971 +t1 MEMORY 10 Fixed 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=1000
3973 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
3974 +PRIMARY KEY (f1)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3975 +SHOW TABLE STATUS LIKE 't1';
3976 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3977 +t1 MEMORY 10 Fixed 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC
3979 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
3980 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=33 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3981 +ERROR 42000: Incorrect usage/placement of 'key_block_size'
3982 +SHOW TABLE STATUS LIKE 't1';
3983 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3984 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
3985 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=34 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3986 +SHOW TABLE STATUS LIKE 't1';
3987 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3988 +t1 MEMORY 10 Dynamic 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=34
3990 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
3991 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=121 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3992 +SHOW TABLE STATUS LIKE 't1';
3993 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
3994 +t1 MEMORY 10 Dynamic 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=121
3996 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
3997 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=1000 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
3998 +SHOW TABLE STATUS LIKE 't1';
3999 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
4000 +t1 MEMORY 10 Fixed 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=1000
4003 +++ b/mysql-test/r/percona_heap_bug784464_32bit.result
4005 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
4006 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=124 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
4007 +SHOW TABLE STATUS LIKE 't1';
4008 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
4009 +t1 MEMORY 10 Dynamic 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=124
4011 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
4012 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=122 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
4013 +SHOW TABLE STATUS LIKE 't1';
4014 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
4015 +t1 MEMORY 10 Dynamic 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=122
4018 +++ b/mysql-test/r/percona_heap_bug784464_64bit.result
4020 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
4021 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=124 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
4022 +SHOW TABLE STATUS LIKE 't1';
4023 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
4024 +t1 MEMORY 10 Fixed 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=124
4026 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
4027 +PRIMARY KEY (f1)) KEY_BLOCK_SIZE=122 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
4028 +SHOW TABLE STATUS LIKE 't1';
4029 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
4030 +t1 MEMORY 10 Fixed 0 X 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC KEY_BLOCK_SIZE=122
4033 +++ b/mysql-test/r/percona_heap_bug784468.result
4035 +CREATE TABLE t1 ( f1 VARCHAR(30)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
4036 +SHOW TABLE STATUS LIKE 't1';
4037 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
4038 +t1 MEMORY 10 Fixed 0 32 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC
4040 +CREATE TABLE t1 ( f1 VARCHAR(31)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
4041 +SHOW TABLE STATUS LIKE 't1';
4042 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
4043 +t1 MEMORY 10 Fixed 0 33 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC
4045 +CREATE TABLE t1 ( f1 VARCHAR(32)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
4046 +SHOW TABLE STATUS LIKE 't1';
4047 +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
4048 +t1 MEMORY 10 Fixed 0 34 0 X 0 0 NULL X X NULL latin1_swedish_ci NULL row_format=DYNAMIC
4051 +++ b/mysql-test/r/percona_heap_bug788544.result
4053 +CREATE TABLE t1 (f2 VARCHAR (32), f4 LONGBLOB, f5 TEXT) ENGINE=HEAP;
4054 +INSERT INTO t1 VALUES ('a', NULL, NULL),
4055 +('b' , REPEAT('a' , 593338), REPEAT('a', 800));
4056 +UPDATE t1 SET f2 = 'c' WHERE f4 = 'd';
4057 +SELECT LENGTH(f2), LENGTH(f4), LENGTH(f5) FROM t1;
4058 +LENGTH(f2) LENGTH(f4) LENGTH(f5)
4063 +++ b/mysql-test/r/percona_heap_bug788576.result
4065 +CREATE TABLE t1 (f1 VARCHAR (32), f2 VARCHAR (128), f3 VARBINARY (128),
4066 +f4 VARBINARY (512), f5 VARBINARY (1024),
4067 +KEY (f2(1))) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
4068 +INSERT IGNORE INTO t1 VALUES (2, NULL, 6, REPEAT('glugcgqk', 5), 'look'),
4069 +(REPEAT( 'kglugcgqkin', 6), 'if', 'was', NULL, NULL),
4070 +(NULL, NULL, NULL, NULL, 7);
4072 +Warning 1265 Data truncated for column 'f1' at row 2
4075 +2 NULL 6 glugcgqkglugcgqkglugcgqkglugcgqkglugcgqk look
4076 +kglugcgqkinkglugcgqkinkglugcgqki if was NULL NULL
4077 +NULL NULL NULL NULL 7
4078 +DELETE FROM t1 WHERE f5 <=> NULL;
4081 +2 NULL 6 glugcgqkglugcgqkglugcgqkglugcgqkglugcgqk look
4082 +NULL NULL NULL NULL 7
4085 +++ b/mysql-test/r/percona_heap_bug788722.result
4087 +CREATE TABLE IF NOT EXISTS local_1_1 (f1 VARCHAR (32) NOT NULL,
4088 +f2 VARCHAR (128) NOT NULL,
4094 +) ENGINE=HEAP ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE = 2048;
4095 +INSERT IGNORE INTO local_1_1 VALUES
4096 +(REPEAT('egqeqfxwaejpqixuvvtentruyqadxiybjdfqjspfbyjdjczrrwjnagkzsoagatqookhsgtrvvbxacppljfzaseidqggxvuirm' , 5), NULL, NULL, NULL, REPEAT('hegqeqfxwaejpqixuvvtentruyqadxiy', 1)),
4097 +('you', NULL, 0, REPEAT("X", 2048) , 0);
4099 +Warning 1265 Data truncated for column 'f1' at row 1
4100 +Warning 1048 Column 'f2' cannot be null
4101 +Warning 1048 Column 'f3' cannot be null
4102 +Warning 1048 Column 'f2' cannot be null
4103 +INSERT IGNORE INTO local_1_1 SELECT * FROM local_1_1;
4104 +DROP TABLE local_1_1;
4106 +++ b/mysql-test/r/percona_heap_bug789131.result
4108 +CREATE TABLE t1 (f1 VARCHAR (128), f2 VARCHAR (128), f3 VARBINARY (512),
4109 +f4 TEXT (65525), f5 VARCHAR (128), KEY (f1(1))) ENGINE=HEAP;
4110 +INSERT IGNORE INTO t1 VALUES
4111 +( 'o' , "" , NULL , "" , 0 ) ,
4112 +(NULL, "" , "" , "" , 'f' ) ;
4113 +INSERT IGNORE INTO t1 SELECT * FROM t1;
4116 +++ b/mysql-test/r/percona_heap_var.result
4118 +drop table if exists t1;
4119 +set @@session.max_heap_table_size=16*1024*1024;
4120 +create table t1 (a int not null, b varchar(400), c int, primary key (a), key (c)) engine=heap comment="testing heaps" key_block_size=128;
4121 +ERROR 42000: Incorrect usage/placement of 'key_block_size'
4122 +create table t1 (a int not null, b int, c varchar(400), primary key (a), key (b)) engine=heap comment="testing heaps" key_block_size=4;
4123 +ERROR 42000: Incorrect usage/placement of 'key_block_size'
4124 +create table t1 (a int not null, b int, c varchar(400), d varchar(400), primary key (a), key (b)) engine=heap comment="testing heaps" key_block_size=24;
4125 +show table status like "t1";
4140 +Collation latin1_swedish_ci
4142 +Create_options KEY_BLOCK_SIZE=24
4143 +Comment testing heaps
4144 +insert into t1 values (1,1,'012',NULL), (2,2,'0123456789',NULL), (3,3,'012345678901234567890123456789',NULL), (4,4,NULL,'0123456789012345678901234567890123456789012345678901234567890123456789');
4148 +2 2 0123456789 NULL
4149 +3 3 012345678901234567890123456789 NULL
4150 +4 4 NULL 0123456789012345678901234567890123456789012345678901234567890123456789
4151 +delete from t1 where a = 3;
4155 +2 2 0123456789 NULL
4156 +4 4 NULL 0123456789012345678901234567890123456789012345678901234567890123456789
4157 +insert into t1 values (5,5,NULL,'0123'), (6,6,NULL,'0123');
4161 +2 2 0123456789 NULL
4164 +4 4 NULL 0123456789012345678901234567890123456789012345678901234567890123456789
4165 +update t1 set c = '012345678901234567890123456789' where a = 2;
4169 +2 2 012345678901234567890123456789 NULL
4172 +4 4 NULL 0123456789012345678901234567890123456789012345678901234567890123456789
4173 +update t1 set c = '0123456789' where a = 2;
4177 +2 2 0123456789 NULL
4180 +4 4 NULL 0123456789012345678901234567890123456789012345678901234567890123456789
4181 +insert into t1 values (7,7,'0123',NULL), (8,8,'0123',NULL);
4185 +2 2 0123456789 NULL
4188 +4 4 NULL 0123456789012345678901234567890123456789012345678901234567890123456789
4191 +show table status like "t1";
4206 +Collation latin1_swedish_ci
4208 +Create_options KEY_BLOCK_SIZE=24
4209 +Comment testing heaps
4210 +alter table t1 key_block_size = 0;
4211 +show table status like "t1";
4226 +Collation latin1_swedish_ci
4229 +Comment testing heaps
4230 +alter table t1 row_format = dynamic;
4231 +show table status like "t1";
4246 +Collation latin1_swedish_ci
4248 +Create_options row_format=DYNAMIC KEY_BLOCK_SIZE=X
4249 +Comment testing heaps
4250 +alter table t1 key_block_size = 128, max_rows = 10001;
4251 +show table status like "t1";
4266 +Collation latin1_swedish_ci
4268 +Create_options max_rows=10001 row_format=DYNAMIC KEY_BLOCK_SIZE=128
4269 +Comment testing heaps
4273 +2 2 0123456789 NULL
4276 +4 4 NULL 0123456789012345678901234567890123456789012345678901234567890123456789
4282 +call mtr.add_suppression("The table 't1' is full");
4283 +select count(*) from t1;
4286 +insert into t1 values (100000,100000,NULL,'0123'), (100000,100000,NULL,'0123');
4287 +ERROR HY000: The table 't1' is full
4288 +show table status like "t1";
4303 +Collation latin1_swedish_ci
4305 +Create_options max_rows=10001 row_format=DYNAMIC KEY_BLOCK_SIZE=128
4306 +Comment testing heaps
4307 +select count(*) from t1;
4310 +set @@session.max_heap_table_size=default;
4313 +++ b/mysql-test/t/percona_heap_blob.test
4315 +########################################################################
4316 +# Test blobs with the HEAP/MEMORY storage engine
4317 +########################################################################
4319 +########################################################################
4320 +# Modified tests from type_blob.test
4321 +########################################################################
4323 +SET @old_default_storage_engine=@@default_storage_engine;
4324 +SET default_storage_engine=MEMORY;
4330 +drop table if exists t1,t2,t3,t4,t5,t6,t7;
4335 +# Check syntax for creating BLOB/TEXT
4338 +CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
4339 +show columns from t1;
4340 +# PS doesn't give errors on prepare yet
4341 +CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000));
4342 +CREATE TABLE t4 (c varchar(65530) character set utf8 not null);
4343 +show columns from t2;
4344 +create table t3 (a long, b long byte);
4345 +show create TABLE t3;
4346 +show create TABLE t4;
4347 +drop table t1,t2,t3,t4;
4350 +# Check errors with blob
4354 +CREATE TABLE t1 (a char(257) default "hello");
4356 +CREATE TABLE t2 (a char(256));
4358 +CREATE TABLE t1 (a varchar(70000) default "hello");
4360 +CREATE TABLE t2 (a blob default "hello");
4362 +# Safety to be able to continue with other tests if above fails
4364 +drop table if exists t1,t2;
4368 +# test of full join with blob
4371 +create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
4372 +insert into t1 values (null,"a","A");
4373 +insert into t1 values (null,"bbb","BBB");
4374 +insert into t1 values (null,"ccc","CCC");
4375 +select last_insert_id();
4376 +select * from t1,t1 as t2;
4381 +# Test of changing TEXT column
4384 +create table t1 (a text);
4385 +insert into t1 values ('where');
4386 +update t1 set a='Where';
4391 +# test of blob, text, char and varbinary
4393 +create table t1 (t text,c char(10),b blob, d varbinary(10));
4394 +insert into t1 values (NULL,NULL,NULL,NULL);
4395 +insert into t1 values ("","","","");
4396 +insert into t1 values ("hello","hello","hello","hello");
4397 +insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
4398 +insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
4399 +insert into t1 values ("a","a","a","a");
4400 +insert into t1 values (1,1,1,1);
4401 +insert into t1 values (NULL,NULL,NULL,NULL);
4402 +update t1 set c="",b=null where c="1";
4404 +lock tables t1 READ;
4405 +# We mask out the Privileges column because it differs for embedded server
4406 +--replace_column 8 #
4407 +show full fields from t1;
4408 +lock tables t1 WRITE;
4409 +--replace_column 8 #
4410 +show full fields from t1;
4413 +select t from t1 where t like "hello";
4414 +select c from t1 where c like "hello";
4415 +select b from t1 where b like "hello";
4416 +select d from t1 where d like "hello";
4417 +select c from t1 having c like "hello";
4418 +select d from t1 having d like "hello";
4419 +select t from t1 where t like "%HELLO%";
4420 +select c from t1 where c like "%HELLO%";
4421 +select b from t1 where b like "%HELLO%";
4422 +select d from t1 where d like "%HELLO%";
4423 +select c from t1 having c like "%HELLO%";
4424 +select d from t1 having d like "%HELLO%";
4425 +select d from t1 having d like "%HE%LLO%";
4426 +select t from t1 order by t;
4427 +select c from t1 order by c;
4428 +select b from t1 order by b;
4429 +select d from t1 order by d;
4430 +select distinct t from t1;
4431 +select distinct b from t1;
4432 +select distinct t from t1 order by t;
4433 +select distinct b from t1 order by b;
4434 +select t from t1 group by t;
4435 +select b from t1 group by b;
4436 +set option sql_big_tables=1;
4437 +select distinct t from t1;
4438 +select distinct b from t1;
4439 +select distinct t from t1 order by t;
4440 +select distinct b from t1 order by b;
4441 +select distinct c from t1;
4442 +select distinct d from t1;
4443 +select distinct c from t1 order by c;
4444 +select distinct d from t1 order by d;
4445 +select c from t1 group by c;
4446 +select d from t1 group by d;
4447 +set option sql_big_tables=0;
4448 +select distinct * from t1;
4449 +select t,count(*) from t1 group by t;
4450 +select b,count(*) from t1 group by b;
4451 +select c,count(*) from t1 group by c;
4452 +select d,count(*) from t1 group by d;
4457 +# Test of join with blobs and min
4461 + t1_id bigint(21) NOT NULL auto_increment,
4462 + _field_72 varchar(128) DEFAULT '' NOT NULL,
4463 + _field_95 varchar(32),
4464 + _field_115 tinyint(4) DEFAULT '0' NOT NULL,
4465 + _field_122 tinyint(4) DEFAULT '0' NOT NULL,
4466 + _field_126 tinyint(4),
4467 + _field_134 tinyint(4),
4468 + PRIMARY KEY (t1_id),
4469 + UNIQUE _field_72 (_field_72),
4470 + KEY _field_115 (_field_115),
4471 + KEY _field_122 (_field_122)
4475 +INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
4476 +INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
4477 +INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
4481 + seq_0_id bigint(21) DEFAULT '0' NOT NULL,
4482 + seq_1_id bigint(21) DEFAULT '0' NOT NULL,
4483 + PRIMARY KEY (seq_0_id,seq_1_id)
4487 +INSERT INTO t2 VALUES (1,1);
4488 +INSERT INTO t2 VALUES (2,1);
4489 +INSERT INTO t2 VALUES (2,2);
4492 + t3_id bigint(21) NOT NULL auto_increment,
4493 + _field_131 varchar(128),
4494 + _field_133 tinyint(4) DEFAULT '0' NOT NULL,
4495 + _field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
4496 + _field_137 tinyint(4),
4497 + _field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
4499 + _field_142 tinyint(4) DEFAULT '0' NOT NULL,
4500 + _field_145 tinyint(4) DEFAULT '0' NOT NULL,
4501 + _field_148 tinyint(4) DEFAULT '0' NOT NULL,
4502 + PRIMARY KEY (t3_id),
4503 + KEY _field_133 (_field_133),
4504 + KEY _field_135 (_field_135),
4505 + KEY _field_139 (_field_139),
4506 + KEY _field_142 (_field_142),
4507 + KEY _field_145 (_field_145),
4508 + KEY _field_148 (_field_148)
4512 +INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
4513 +INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0);
4517 + seq_0_id bigint(21) DEFAULT '0' NOT NULL,
4518 + seq_1_id bigint(21) DEFAULT '0' NOT NULL,
4519 + PRIMARY KEY (seq_0_id,seq_1_id)
4523 +INSERT INTO t4 VALUES (1,1);
4524 +INSERT INTO t4 VALUES (2,1);
4527 + t5_id bigint(21) NOT NULL auto_increment,
4528 + _field_149 tinyint(4),
4529 + _field_156 varchar(128) DEFAULT '' NOT NULL,
4530 + _field_157 varchar(128) DEFAULT '' NOT NULL,
4531 + _field_158 varchar(128) DEFAULT '' NOT NULL,
4532 + _field_159 varchar(128) DEFAULT '' NOT NULL,
4533 + _field_160 varchar(128) DEFAULT '' NOT NULL,
4534 + _field_161 varchar(128) DEFAULT '' NOT NULL,
4535 + PRIMARY KEY (t5_id),
4536 + KEY _field_156 (_field_156),
4537 + KEY _field_157 (_field_157),
4538 + KEY _field_158 (_field_158),
4539 + KEY _field_159 (_field_159),
4540 + KEY _field_160 (_field_160),
4541 + KEY _field_161 (_field_161)
4545 +INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
4546 +INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
4549 + seq_0_id bigint(21) DEFAULT '0' NOT NULL,
4550 + seq_1_id bigint(21) DEFAULT '0' NOT NULL,
4551 + PRIMARY KEY (seq_0_id,seq_1_id)
4554 +INSERT INTO t6 VALUES (1,1);
4555 +INSERT INTO t6 VALUES (1,2);
4556 +INSERT INTO t6 VALUES (2,2);
4559 + t7_id bigint(21) NOT NULL auto_increment,
4560 + _field_143 tinyint(4),
4561 + _field_165 varchar(32),
4562 + _field_166 smallint(6) DEFAULT '0' NOT NULL,
4563 + PRIMARY KEY (t7_id),
4564 + KEY _field_166 (_field_166)
4568 +INSERT INTO t7 VALUES (1,0,'High',1);
4569 +INSERT INTO t7 VALUES (2,0,'Medium',2);
4570 +INSERT INTO t7 VALUES (3,0,'Low',3);
4572 +select replace(t3._field_140, "\r","^M"),t3_id,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), replace(min(t3._field_140), "\r","^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
4574 +drop table t1,t2,t3,t4,t5,t6,t7;
4577 +# Test of reverse with empty blob
4580 +create table t1 (a blob);
4581 +insert into t1 values ("empty"),("");
4582 +select a,reverse(a) from t1;
4586 +# Bug when blob is updated
4589 +create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default '');
4590 +insert into t1 (id) values (1);
4591 +# We have to clean up the path in the results for safe comparison
4593 + charset(load_file('../../std_data/words.dat')),
4594 + collation(load_file('../../std_data/words.dat')),
4595 + coercibility(load_file('../../std_data/words.dat'));
4596 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
4597 +eval explain extended select
4598 + charset(load_file('$MYSQLTEST_VARDIR/std_data/words.dat')),
4599 + collation(load_file('$MYSQLTEST_VARDIR/std_data/words.dat')),
4600 + coercibility(load_file('$MYSQLTEST_VARDIR/std_data/words.dat'));
4601 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
4602 +eval update t1 set imagem=load_file('$MYSQLTEST_VARDIR/std_data/words.dat') where id=1;
4603 +select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1;
4605 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
4606 +eval create table t1 select load_file('$MYSQLTEST_VARDIR/std_data/words.dat') l;
4607 +# We mask out the Privileges column because it differs for embedded server
4608 +--replace_column 8 #
4609 +show full fields from t1;
4613 +# Test blob's with end space (Bug #1651)
4614 +# This is a bit changed since we now have true varchar
4617 +create table t1 (id integer primary key auto_increment, txt text not null);
4618 +insert into t1 (txt) values ('Chevy ');
4619 +select * from t1 where txt='Chevy';
4620 +select * from t1 where txt='Chevy ';
4621 +select * from t1 where txt='Chevy ' or txt='Chevy';
4622 +select * from t1 where txt='Chevy' or txt='Chevy ';
4623 +select * from t1 where id='1' or id='2';
4624 +insert into t1 (txt) values('Ford');
4625 +select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
4626 +select * from t1 where txt='Chevy' or txt='Chevy ';
4627 +select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
4628 +select * from t1 where txt in ('Chevy ','Chevy');
4629 +select * from t1 where txt in ('Chevy');
4630 +select * from t1 where txt between 'Chevy' and 'Chevy';
4631 +select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
4632 +select * from t1 where txt between 'Chevy' and 'Chevy ';
4633 +select * from t1 where txt < 'Chevy ';
4634 +select * from t1 where txt <= 'Chevy';
4635 +select * from t1 where txt > 'Chevy';
4636 +select * from t1 where txt >= 'Chevy';
4639 +create table t1 (id integer primary key auto_increment, txt text);
4640 +insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
4641 +select * from t1 where txt='Chevy' or txt is NULL;
4642 +explain select * from t1 where txt='Chevy' or txt is NULL;
4643 +select * from t1 where txt='Chevy ';
4644 +select * from t1 where txt='Chevy ' or txt='Chevy';
4645 +select * from t1 where txt='Chevy' or txt='Chevy ';
4646 +select * from t1 where id='1' or id='2';
4647 +insert into t1 (txt) values('Ford');
4648 +select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
4649 +select * from t1 where txt='Chevy' or txt='Chevy ';
4650 +select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
4651 +select * from t1 where txt in ('Chevy ','Chevy');
4652 +select * from t1 where txt in ('Chevy');
4653 +select * from t1 where txt between 'Chevy' and 'Chevy';
4654 +select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
4655 +select * from t1 where txt between 'Chevy' and 'Chevy ';
4656 +select * from t1 where txt < 'Chevy ';
4657 +select * from t1 where txt < 'Chevy ' or txt is NULL;
4658 +select * from t1 where txt <= 'Chevy';
4659 +select * from t1 where txt > 'Chevy';
4660 +select * from t1 where txt >= 'Chevy';
4661 +alter table t1 modify column txt blob;
4662 +explain select * from t1 where txt='Chevy' or txt is NULL;
4663 +select * from t1 where txt='Chevy' or txt is NULL;
4664 +explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
4665 +select * from t1 where txt='Chevy' or txt is NULL order by txt;
4668 +CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY (i));
4669 +INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,'');
4670 +select max(i) from t1 where c = '';
4676 +# Test that blob's and varbinary are sorted according to length
4679 +CREATE table t1 (a blob);
4680 +insert into t1 values ('b'),('a\0'),('a'),('a '),('aa'),(NULL);
4681 +select hex(a) from t1 order by a;
4682 +select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
4683 +alter table t1 modify a varbinary(5);
4684 +select hex(a) from t1 order by a;
4685 +select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
4686 +alter table t1 modify a char(5);
4687 +select hex(a) from t1 order by a;
4688 +select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
4689 +alter table t1 modify a binary(5);
4690 +select hex(a) from t1 order by a;
4691 +select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
4695 +# Bug #19489: Inconsistent support for DEFAULT in TEXT columns
4697 +create table t1 (a text default '');
4698 +show create table t1;
4699 +insert into t1 values (default);
4702 +set @@sql_mode='TRADITIONAL';
4703 +--error ER_BLOB_CANT_HAVE_DEFAULT
4704 +create table t1 (a text default '');
4708 +# Bug #32282: TEXT silently truncates when value is exactly 65536 bytes
4711 +CREATE TABLE t (c TEXT CHARSET ASCII);
4712 +INSERT INTO t (c) VALUES (REPEAT('1',65537));
4713 +INSERT INTO t (c) VALUES (REPEAT('2',65536));
4714 +INSERT INTO t (c) VALUES (REPEAT('3',65535));
4715 +SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
4717 +# Bug#15776: 32-bit signed int used for length of blob
4718 +# """LONGBLOB: A BLOB column with a maximum length of 4,294,967,295 or 4GB."""
4720 +# Conditions should be in this order:
4721 +# A size is not in the allowed bounds.
4722 +# If the type is char-ish AND size is within the max blob size:
4723 +# raise ER_TOO_BIG_FIELDLENGTH (suggest using BLOB)
4724 +# If size is too small:
4725 +# raise ER_PARSE_ERROR
4726 +# raise ER_TOO_BIG_DISPLAYWIDTH
4728 +# BLOB and TEXT types
4730 +drop table if exists b15776;
4732 +create table b15776 (data blob(2147483647));
4734 +--error ER_PARSE_ERROR
4735 +create table b15776 (data blob(-1));
4736 +create table b15776 (data blob(2147483648));
4738 +create table b15776 (data blob(4294967294));
4740 +create table b15776 (data blob(4294967295));
4742 +--error ER_TOO_BIG_DISPLAYWIDTH
4743 +create table b15776 (data blob(4294967296));
4745 +CREATE TABLE b15776 (a blob(2147483647), b blob(2147483648), c blob(4294967295), a1 text(2147483647), b1 text(2147483648), c1 text(4294967295) );
4746 +show columns from b15776;
4749 +--error ER_TOO_BIG_DISPLAYWIDTH
4750 +CREATE TABLE b15776 (a blob(4294967296));
4751 +--error ER_TOO_BIG_DISPLAYWIDTH
4752 +CREATE TABLE b15776 (a text(4294967296));
4753 +--error ER_TOO_BIG_DISPLAYWIDTH
4754 +CREATE TABLE b15776 (a blob(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
4755 +--error ER_TOO_BIG_DISPLAYWIDTH
4756 +CREATE TABLE b15776 (a text(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
4759 +# "Another extension is supported by MySQL for optionally specifying the
4760 +# display width of integer data types in parentheses following the base keyword
4761 +# for the type (for example, INT(4)). This optional display width is used to
4762 +# display integer values having a width less than the width specified for the
4763 +# column by left-padding them with spaces." § Numeric Types
4764 +CREATE TABLE b15776 (a int(0)); # 0 is special case, means default size
4765 +INSERT INTO b15776 values (NULL), (1), (42), (654);
4766 +SELECT * from b15776 ORDER BY a;
4768 +--error ER_PARSE_ERROR
4769 +CREATE TABLE b15776 (a int(-1));
4770 +CREATE TABLE b15776 (a int(255));
4772 +--error ER_TOO_BIG_DISPLAYWIDTH
4773 +CREATE TABLE b15776 (a int(256));
4774 +--error ER_PARSE_ERROR
4775 +CREATE TABLE b15776 (data blob(-1));
4779 +--error ER_TOO_BIG_FIELDLENGTH
4780 +CREATE TABLE b15776 (a char(2147483647));
4781 +--error ER_TOO_BIG_FIELDLENGTH
4782 +CREATE TABLE b15776 (a char(2147483648));
4783 +--error ER_TOO_BIG_FIELDLENGTH
4784 +CREATE TABLE b15776 (a char(4294967295));
4785 +# Even BLOB won't hold
4786 +--error ER_TOO_BIG_DISPLAYWIDTH
4787 +CREATE TABLE b15776 (a char(4294967296));
4790 +# Other numeric-ish types
4791 +## For year, widths not "2" or "4" are silently rewritten to "4". But
4792 +## When we complain about it, we say that the max is 255. We may be
4793 +## talking about different things. It's confusing.
4794 +CREATE TABLE b15776 (a year(4294967295));
4795 +INSERT INTO b15776 VALUES (42);
4796 +SELECT * FROM b15776;
4798 +--error ER_TOO_BIG_DISPLAYWIDTH
4799 +CREATE TABLE b15776 (a year(4294967296));
4800 +CREATE TABLE b15776 (a year(0)); # 0 is special case, means default size
4802 +--error ER_PARSE_ERROR
4803 +CREATE TABLE b15776 (a year(-2));
4806 +# We've already tested the case, but this should visually show that
4807 +# widths that are too large to be interpreted cause DISPLAYWIDTH errors.
4808 +--error ER_TOO_BIG_DISPLAYWIDTH
4809 +CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
4810 +--error ER_TOO_BIG_DISPLAYWIDTH
4811 +CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
4812 +--error ER_TOO_BIG_DISPLAYWIDTH
4813 +CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
4815 +## Do not select, too much memory needed.
4816 +CREATE TABLE b15776 select cast(null as char(4294967295));
4817 +show columns from b15776;
4819 +CREATE TABLE b15776 select cast(null as nchar(4294967295));
4820 +show columns from b15776;
4822 +CREATE TABLE b15776 select cast(null as binary(4294967295));
4823 +show columns from b15776;
4826 +explain select cast(1 as char(4294967295));
4827 +explain select cast(1 as nchar(4294967295));
4828 +explain select cast(1 as binary(4294967295));
4830 +--error ER_TOO_BIG_DISPLAYWIDTH
4831 +explain select cast(1 as char(4294967296));
4832 +--error ER_TOO_BIG_DISPLAYWIDTH
4833 +explain select cast(1 as nchar(4294967296));
4834 +--error ER_TOO_BIG_DISPLAYWIDTH
4835 +explain select cast(1 as binary(4294967296));
4837 +--error ER_PARSE_ERROR
4838 +explain select cast(1 as decimal(-1));
4839 +explain select cast(1 as decimal(64, 30));
4840 +# It's not as important which errors are raised for these, since the
4841 +# limit is nowhere near 2**32. We may fix these eventually to take
4842 +# 4294967295 and still reject it because it's greater than 64 or 30,
4843 +# but that's not a high priority and the parser needn't worry about
4844 +# such a weird case.
4845 +--error ER_TOO_BIG_SCALE,ER_PARSE_ERROR
4846 +explain select cast(1 as decimal(64, 999999999999999999999999999999));
4847 +--error ER_TOO_BIG_PRECISION,ER_PARSE_ERROR
4848 +explain select cast(1 as decimal(4294967296));
4849 +--error ER_TOO_BIG_PRECISION,ER_PARSE_ERROR
4850 +explain select cast(1 as decimal(999999999999999999999999999999999999));
4852 +explain select convert(1, char(4294967295));
4853 +--error ER_TOO_BIG_DISPLAYWIDTH
4854 +explain select convert(1, char(4294967296));
4855 +--error ER_TOO_BIG_DISPLAYWIDTH
4856 +explain select convert(1, char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
4857 +explain select convert(1, nchar(4294967295));
4858 +--error ER_TOO_BIG_DISPLAYWIDTH
4859 +explain select convert(1, nchar(4294967296));
4860 +--error ER_TOO_BIG_DISPLAYWIDTH
4861 +explain select convert(1, nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
4862 +explain select convert(1, binary(4294967295));
4863 +--error ER_TOO_BIG_DISPLAYWIDTH
4864 +explain select convert(1, binary(4294967296));
4865 +--error ER_TOO_BIG_DISPLAYWIDTH
4866 +explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
4868 +--echo End of 5.0 tests
4871 +# Bug #33969: Updating a text field via a left join
4874 +CREATE TABLE t1(id INT NOT NULL);
4875 +CREATE TABLE t2(id INT NOT NULL, c TEXT NOT NULL);
4877 +INSERT INTO t1 VALUES (1);
4878 +INSERT INTO t2 VALUES (1, '');
4880 +UPDATE t2 SET c = REPEAT('1', 70000);
4881 +SELECT LENGTH(c) FROM t2;
4883 +UPDATE t1 LEFT JOIN t2 USING(id) SET t2.c = REPEAT('1', 70000) WHERE t1.id = 1;
4884 +SELECT LENGTH(c) FROM t2;
4888 +--echo # Bug #52160: crash and inconsistent results when grouping
4889 +--echo # by a function and column
4891 +CREATE FUNCTION f1() RETURNS TINYBLOB RETURN 1;
4893 +CREATE TABLE t1(a CHAR(1));
4894 +INSERT INTO t1 VALUES ('0'), ('0');
4896 +SELECT COUNT(*) FROM t1 GROUP BY f1(), a;
4903 +SET default_storage_engine=@old_default_storage_engine;
4906 +########################################################################
4907 +# Modified test from myisam-blob.test
4908 +########################################################################
4910 +SET @old_max_heap_table_size = @@global.max_heap_table_size;
4911 +SET @old_max_allowed_packet = @@global.max_allowed_packet;
4912 +SET GLOBAL max_heap_table_size = 18 * 1024 * 1024;
4913 +SET GLOBAL max_allowed_packet = 24 * 1024 * 1024;
4915 +connect(con1, localhost, root,,);
4919 +drop table if exists t1;
4922 +# Bug #2159 (Problem with update of blob to > 16M)
4924 +CREATE TABLE t1 (data LONGBLOB) ENGINE=memory;
4925 +INSERT INTO t1 (data) VALUES (NULL);
4926 +UPDATE t1 set data=repeat('a',18*1024*1024);
4927 +select length(data) from t1;
4928 +delete from t1 where left(data,1)='a';
4930 +INSERT INTO t1 (data) VALUES (repeat('a',1*1024*1024));
4931 +INSERT INTO t1 (data) VALUES (repeat('b',16*1024*1024-1024));
4932 +delete from t1 where left(data,1)='b';
4934 +# now we have two blocks in the table, first is a 1M record and second is
4935 +# a 16M delete block.
4937 +UPDATE t1 set data=repeat('c',17*1024*1024);
4938 +delete from t1 where left(data,1)='c';
4940 +INSERT INTO t1 set data=repeat('a',18*1024*1024);
4941 +select length(data) from t1;
4942 +alter table t1 modify data blob;
4943 +select length(data) from t1;
4946 +CREATE TABLE t1 (data BLOB) ENGINE=myisam;
4947 +INSERT INTO t1 (data) VALUES (NULL);
4948 +UPDATE t1 set data=repeat('a',18*1024*1024);
4949 +select length(data) from t1;
4953 +connection default;
4955 +SET GLOBAL max_allowed_packet = @old_max_allowed_packet;
4956 +SET GLOBAL max_heap_table_size = @old_max_heap_table_size;
4958 +++ b/mysql-test/t/percona_heap_bug783366.test
4961 +# Test for bug lp:783366
4965 +drop table if exists t1;
4969 + f1 VARCHAR ( 128 ) ,
4970 + f2 VARCHAR ( 32 ),
4971 + PRIMARY KEY ( f2 ( 2 ) , f1 )
4973 +ENGINE=HEAP KEY_BLOCK_SIZE = 512;
4974 +INSERT IGNORE INTO t1 VALUES ( 'te' , 'm') , ( NULL , 'think' );
4975 +INSERT IGNORE INTO t1 VALUES ( 'te' , 'm') , ( NULL , 'think' );
4980 +++ b/mysql-test/t/percona_heap_bug783451.test
4982 +# Testcase for the bug https://bugs.launchpad.net/percona-projects-qa/+bug/783451
4983 +# With dynamic row format in HEAP and the UPDATE statement that significantly
4984 +# increases the data size, the table scan in-progress desyncs its table position state.
4985 +# Run with Valgrind if it does not crash for you.
4987 +DROP TABLE IF EXISTS local_1_1;
4989 +CREATE TABLE IF NOT EXISTS local_1_1 ( f1 VARCHAR ( 32 ) NOT NULL , f2 VARCHAR ( 128 ) NOT NULL DEFAULT 'cboepfaobilcchabvglgjdbynog' , f3 VARCHAR ( 32 ) NOT NULL , f4 VARBINARY ( 32 ) NOT NULL , f5 VARBINARY ( 1024 ) DEFAULT 'ycboepfao' , KEY ( f1 /* ( 2 ) */ , f2 /* ( 2 ) */ ) ) ENGINE=HEAP KEY_BLOCK_SIZE = 512;
4990 +INSERT IGNORE INTO local_1_1 VALUES ( REPEAT( 'ervydbimvmbqmsowdbsa' , 1 ) , 'v' , NULL , NULL , REPEAT( 'mervydbimvmbqms' , 5 ) ) , ( 'p' , 6 , 'n' , REPEAT( 'imervydbimvmbqmsowdbs' , 4 ) , 'do' ) , ( NULL , NULL , REPEAT( 'himervydbimvmbqmsowdbsaybudvwaamvhempuublmia' , 6 ) , REPEAT('X', POW(2, 20) * 2) , REPEAT('X', POW(2, 20) * 2) ) , ( REPEAT('X', POW(2, 20) * 2) , REPEAT( 'Y' , 763 ) , NULL , REPEAT('X', POW(2, 20) * 2) , NULL ) , ( REPEAT('X', POW(2, 20) * 2) , 'time' , 'how' , 2 , REPEAT( 'Y' , 107 ) ) , ( REPEAT( 'hyshimervydbimvmbqmsowdbsaybud' , 5 ) , 2 , 8 , NULL , REPEAT('X', POW(2, 20) * 2) ) , ( 'come' , NULL , 'i' , NULL , REPEAT('X', POW(2, 20) * 2) );
4991 +INSERT IGNORE INTO local_1_1 VALUES ( 'ok' , NULL , REPEAT( 'Y' , 651 ) , 2 , 5 ) , ( REPEAT( 'zylcdzkfrqpihyshimervydbimvmbqmsowdbsaybu' , 3 ) , REPEAT( 'Y' , 282 ) , REPEAT( 'X' , 0 ) , REPEAT( 'Y' , 369 ) , 'g' ) , ( 'think' , REPEAT('X', POW(2, 20) * 2), NULL , NULL , REPEAT('X', POW(2, 20) * 2) ) , ( REPEAT( 'Y' , 468 ) , REPEAT( 'dfvbrzylcd' , 6 ) , REPEAT( 'Y' , 264 ) , NULL , 'c' ) , ( NULL , NULL , REPEAT( 'srdfvbrzylcdzkfrqpihyshimervydbimvmbqms' , 0 ) , REPEAT( 'Y' , 244 ) , 7 ) , ( REPEAT( 'Y' , 0 ) , 'how' , 'going' , 'q' , NULL );
4992 +INSERT IGNORE INTO local_1_1 VALUES ( REPEAT('X', POW(2, 20) * 2) , NULL , NULL , NULL , REPEAT('X', POW(2, 20) * 2) ) , ( REPEAT('X', POW(2, 20) * 2) , NULL , REPEAT('X', POW(2, 20) * 2) , 'this' , 'e' ) , ( NULL , 'think' , NULL , 'were' , NULL ) , ( 9 , 'l' , 'c' , 3 , REPEAT( 'geysrdfvbrzylcdzkfrqpihyshimervydbi' , 5 ) ) , ( NULL , NULL , NULL , 'h' , 'w' );
4994 +INSERT IGNORE INTO local_1_1 SELECT * FROM local_1_1;
4995 +INSERT IGNORE INTO local_1_1 SELECT * FROM local_1_1;
4996 +UPDATE local_1_1 SET f5 = REPEAT ('X', 215566);
4997 +DROP TABLE local_1_1;
4999 +++ b/mysql-test/t/percona_heap_bug784464.test
5002 +# Bug #784464: Silent conversion from Dynamic to Fixed row_format for certain
5003 +# values of key_block_size.
5004 +# Also see percona_heap_bug784464_32bit and percona_heap_bug784464_64bit tests.
5007 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
5008 + PRIMARY KEY (f1)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5009 +--replace_column 6 X 8 X 12 X 13 X
5010 +SHOW TABLE STATUS LIKE 't1';
5013 +--error ER_CANT_USE_OPTION_HERE
5014 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
5015 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=33 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5016 +--replace_column 12 X 13 X
5017 +SHOW TABLE STATUS LIKE 't1';
5019 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
5020 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=34 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5021 +--replace_column 6 X 8 X 12 X 13 X
5022 +SHOW TABLE STATUS LIKE 't1';
5025 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
5026 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=123 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5027 +--replace_column 6 X 8 X 12 X 13 X
5028 +SHOW TABLE STATUS LIKE 't1';
5031 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
5032 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=1000 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5033 +--replace_column 6 X 8 X 12 X 13 X
5034 +SHOW TABLE STATUS LIKE 't1';
5037 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
5038 + PRIMARY KEY (f1)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5039 +--replace_column 6 X 8 X 12 X 13 X
5040 +SHOW TABLE STATUS LIKE 't1';
5043 +--error ER_CANT_USE_OPTION_HERE
5044 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
5045 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=33 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5046 +--replace_column 12 X 13 X
5047 +SHOW TABLE STATUS LIKE 't1';
5049 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
5050 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=34 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5051 +--replace_column 6 X 8 X 12 X 13 X
5052 +SHOW TABLE STATUS LIKE 't1';
5055 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
5056 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=121 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5057 +--replace_column 6 X 8 X 12 X 13 X
5058 +SHOW TABLE STATUS LIKE 't1';
5061 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
5062 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=1000 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5063 +--replace_column 6 X 8 X 12 X 13 X
5064 +SHOW TABLE STATUS LIKE 't1';
5068 +++ b/mysql-test/t/percona_heap_bug784464_32bit.test
5070 +# 32-bit platform specific parts of tests for LP bug #784464
5072 +--source include/have_32bit.inc
5074 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
5075 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=124 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5076 +--replace_column 6 X 8 X 12 X 13 X
5077 +SHOW TABLE STATUS LIKE 't1';
5080 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
5081 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=122 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5082 +--replace_column 6 X 8 X 12 X 13 X
5083 +SHOW TABLE STATUS LIKE 't1';
5086 +++ b/mysql-test/t/percona_heap_bug784464_64bit.test
5088 +# 64-bit platform specific parts of tests for LP bug #784464
5090 +--source include/have_64bit.inc
5092 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(32), f3 VARCHAR(32), f4 VARCHAR(32),
5093 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=124 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5094 +--replace_column 6 X 8 X 12 X 13 X
5095 +SHOW TABLE STATUS LIKE 't1';
5098 +CREATE TABLE t1 (f1 VARCHAR(32), f2 VARCHAR(96),
5099 + PRIMARY KEY (f1)) KEY_BLOCK_SIZE=122 ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5100 +--replace_column 6 X 8 X 12 X 13 X
5101 +SHOW TABLE STATUS LIKE 't1';
5104 +++ b/mysql-test/t/percona_heap_bug784468.test
5107 +# Bug #784468: Tables with VARCHAR(<31) are created as row_format = Fixed
5110 +CREATE TABLE t1 ( f1 VARCHAR(30)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5111 +--replace_column 8 X 12 X 13 X
5112 +SHOW TABLE STATUS LIKE 't1';
5115 +CREATE TABLE t1 ( f1 VARCHAR(31)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5116 +--replace_column 8 X 12 X 13 X
5117 +SHOW TABLE STATUS LIKE 't1';
5120 +CREATE TABLE t1 ( f1 VARCHAR(32)) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5121 +--replace_column 8 X 12 X 13 X
5122 +SHOW TABLE STATUS LIKE 't1';
5126 +++ b/mysql-test/t/percona_heap_bug788544.test
5129 +# Bug #788544: Valgrind warnings/crash in mysql-55-eb-blobs in
5130 +# hp_extract_record / hp_process_field_data_to_chunkset
5133 +CREATE TABLE t1 (f2 VARCHAR (32), f4 LONGBLOB, f5 TEXT) ENGINE=HEAP;
5135 +INSERT INTO t1 VALUES ('a', NULL, NULL),
5136 + ('b' , REPEAT('a' , 593338), REPEAT('a', 800));
5138 +UPDATE t1 SET f2 = 'c' WHERE f4 = 'd';
5140 +SELECT LENGTH(f2), LENGTH(f4), LENGTH(f5) FROM t1;
5144 +++ b/mysql-test/t/percona_heap_bug788576.test
5147 +# Bug #788576: Second crash in hp_movelink with mysql-55-eb
5150 +CREATE TABLE t1 (f1 VARCHAR (32), f2 VARCHAR (128), f3 VARBINARY (128),
5151 + f4 VARBINARY (512), f5 VARBINARY (1024),
5152 + KEY (f2(1))) ENGINE=HEAP ROW_FORMAT=DYNAMIC;
5154 +INSERT IGNORE INTO t1 VALUES (2, NULL, 6, REPEAT('glugcgqk', 5), 'look'),
5155 + (REPEAT( 'kglugcgqkin', 6), 'if', 'was', NULL, NULL),
5156 + (NULL, NULL, NULL, NULL, 7);
5160 +DELETE FROM t1 WHERE f5 <=> NULL;
5166 +++ b/mysql-test/t/percona_heap_bug788722.test
5169 +# Bug #788722: Second valgrind warning around hp_extract_record in mysql-55-eb-blobs
5172 +CREATE TABLE IF NOT EXISTS local_1_1 (f1 VARCHAR (32) NOT NULL,
5173 + f2 VARCHAR (128) NOT NULL,
5179 +) ENGINE=HEAP ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE = 2048;
5181 +INSERT IGNORE INTO local_1_1 VALUES
5182 + (REPEAT('egqeqfxwaejpqixuvvtentruyqadxiybjdfqjspfbyjdjczrrwjnagkzsoagatqookhsgtrvvbxacppljfzaseidqggxvuirm' , 5), NULL, NULL, NULL, REPEAT('hegqeqfxwaejpqixuvvtentruyqadxiy', 1)),
5183 + ('you', NULL, 0, REPEAT("X", 2048) , 0);
5185 +INSERT IGNORE INTO local_1_1 SELECT * FROM local_1_1;
5187 +DROP TABLE local_1_1;
5189 +++ b/mysql-test/t/percona_heap_bug789131.test
5192 +# Bug #789131: Valgrind warning in MyISAM in mysql-55-eb-blobs
5195 +CREATE TABLE t1 (f1 VARCHAR (128), f2 VARCHAR (128), f3 VARBINARY (512),
5196 + f4 TEXT (65525), f5 VARCHAR (128), KEY (f1(1))) ENGINE=HEAP;
5198 +INSERT IGNORE INTO t1 VALUES
5199 + ( 'o' , "" , NULL , "" , 0 ) ,
5200 + (NULL, "" , "" , "" , 'f' ) ;
5202 +INSERT IGNORE INTO t1 SELECT * FROM t1;
5205 \ No newline at end of file
5207 +++ b/mysql-test/t/percona_heap_var.test
5210 +# Test heap tables with variable-sized records.
5214 +drop table if exists t1;
5217 +set @@session.max_heap_table_size=16*1024*1024;
5220 +create table t1 (a int not null, b varchar(400), c int, primary key (a), key (c)) engine=heap comment="testing heaps" key_block_size=128;
5223 +create table t1 (a int not null, b int, c varchar(400), primary key (a), key (b)) engine=heap comment="testing heaps" key_block_size=4;
5225 +create table t1 (a int not null, b int, c varchar(400), d varchar(400), primary key (a), key (b)) engine=heap comment="testing heaps" key_block_size=24;
5227 +--replace_column 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
5228 +--query_vertical show table status like "t1"
5230 +insert into t1 values (1,1,'012',NULL), (2,2,'0123456789',NULL), (3,3,'012345678901234567890123456789',NULL), (4,4,NULL,'0123456789012345678901234567890123456789012345678901234567890123456789');
5233 +delete from t1 where a = 3;
5236 +insert into t1 values (5,5,NULL,'0123'), (6,6,NULL,'0123');
5239 +update t1 set c = '012345678901234567890123456789' where a = 2;
5242 +update t1 set c = '0123456789' where a = 2;
5245 +insert into t1 values (7,7,'0123',NULL), (8,8,'0123',NULL);
5248 +--replace_column 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
5249 +--query_vertical show table status like "t1"
5250 +alter table t1 key_block_size = 0;
5251 +--replace_column 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
5252 +--query_vertical show table status like "t1"
5253 +alter table t1 row_format = dynamic;
5254 +--replace_column 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
5255 +--replace_regex /KEY_BLOCK_SIZE=[[:digit:]]+/KEY_BLOCK_SIZE=X/
5256 +--query_vertical show table status like "t1"
5257 +alter table t1 key_block_size = 128, max_rows = 10001;
5258 +--replace_column 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
5259 +--query_vertical show table status like "t1"
5268 +call mtr.add_suppression("The table 't1' is full");
5275 + eval insert into t1 values ($1,$1,$1,$1);
5282 +select count(*) from t1;
5285 +insert into t1 values (100000,100000,NULL,'0123'), (100000,100000,NULL,'0123');
5287 +--replace_column 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
5288 +--query_vertical show table status like "t1"
5289 +select count(*) from t1;
5291 +set @@session.max_heap_table_size=default;