diff options
-rw-r--r-- | .bzrignore | 2 | ||||
-rw-r--r-- | client/mysqltest.c | 29 | ||||
-rw-r--r-- | mysql-test/r/3.23/shw000001.result | 5 | ||||
-rw-r--r-- | mysql-test/t/3.23/shw000001.test | 7 | ||||
-rw-r--r-- | sql/sql_show.cc | 9 |
5 files changed, 46 insertions, 6 deletions
diff --git a/.bzrignore b/.bzrignore index 17a5b8b1554..79307b9312c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -274,3 +274,5 @@ mysql-test/var/slave-data/test/choo.frm mysql-test/var/slave-data/test/choo.MYD mysql-test/var/slave-data/test/choo.MYI mysql-test/var/tmp/README +BitKeeper/tmp/bkOF1wtJ +scripts/mysqldumpslow diff --git a/client/mysqltest.c b/client/mysqltest.c index 90080f12e56..3d8b72c5ae4 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -45,7 +45,7 @@ #define PAD_SIZE 128 #define MAX_CONS 1024 #define MAX_INCLUDE_DEPTH 16 - +#define LAZY_GUESS_BUF_SIZE 8192 int record = 0, verbose = 0, silent = 0; const char* record_mode = "r"; @@ -615,7 +615,7 @@ int run_query(MYSQL* mysql, struct query* q) unsigned long* lengths; char* val; int len; - + int guess_result_size; if(q->record_file[0]) { @@ -625,10 +625,29 @@ int run_query(MYSQL* mysql, struct query* q) { if(stat(q->record_file, &info)) die("Error %d on stat of record file '%s'", errno, q->record_file); + /* let the developer be lazy and generate a .reject file + * by touching the the result file and running the test + * in that case, we need a buffer large enough to hold the + * entire rejected result + */ + guess_result_size = (info.st_size ? info.st_size : + LAZY_GUESS_BUF_SIZE) + PAD_SIZE; + /* if we guess wrong, the result will be truncated */ + /* if the master result file is 0 length, the developer */ + /* wants to generate reject file, edit it, and then move into + * the master result location - in this case we should just + * allocate a buffer that is large enough for the kind of result + * that a human would want to examine - hope 8 K is enough + * if this is a real test, the result should be exactly the length + * of the master file if it is correct. If it is wrong and is + * longer, we should be able to tell what is wrong by looking + * at the first "correct" number of bytes + */ if(!(p_res_buf = res_buf = - (char*)malloc(info.st_size + PAD_SIZE))) - die("malloc() failed trying to allocate %d bytes", info.st_size); - res_buf_end = res_buf + info.st_size + PAD_SIZE; + (char*)malloc(guess_result_size))) + die("malloc() failed trying to allocate %d bytes", + guess_result_size); + res_buf_end = res_buf + guess_result_size;; } } diff --git a/mysql-test/r/3.23/shw000001.result b/mysql-test/r/3.23/shw000001.result new file mode 100644 index 00000000000..f38d2f1ef36 --- /dev/null +++ b/mysql-test/r/3.23/shw000001.result @@ -0,0 +1,5 @@ +Table Create Table +test CREATE TABLE `test` ( + `test_set` set('val1','val2','val3') NOT NULL default '', + `name` char(20) default 'O''Brien' +) TYPE=MyISAM COMMENT='it''s a table' diff --git a/mysql-test/t/3.23/shw000001.test b/mysql-test/t/3.23/shw000001.test new file mode 100644 index 00000000000..0abb940d207 --- /dev/null +++ b/mysql-test/t/3.23/shw000001.test @@ -0,0 +1,7 @@ +use test; +drop table if exists test; +create table test ( + test_set set( 'val1', 'val2', 'val3' ) not null default '', + name char(20) default 'O''Brien' + ) comment = 'it\'s a table' ; +@r/3.23/shw000001.result show create table test ; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index eb7e1455297..a9e43198d5a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -732,7 +732,8 @@ store_create_info(THD *thd, TABLE *table, String *packet) type.set(tmp,sizeof(tmp)); field->val_str(&type,&type); packet->append('\''); - packet->append(type.ptr(),type.length()); + if(type.length()) + append_unescaped(packet, type.c_ptr()); packet->append('\''); } else if (field->maybe_null()) @@ -818,6 +819,12 @@ store_create_info(THD *thd, TABLE *table, String *packet) packet->append(" CHECKSUM=1", 11); if (table->db_create_options & HA_OPTION_DELAY_KEY_WRITE) packet->append(" DELAY_KEY_WRITE=1",18); + if(table->comment) + { + packet->append(" COMMENT='", 10); + append_unescaped(packet, table->comment); + packet->append('\''); + } DBUG_RETURN(0); |