Commit 74fbeabb authored by sasha@mysql.sashanet.com's avatar sasha@mysql.sashanet.com
Browse files

client/mysqltest.c

    generate a bigger reject file ( full in most cases) if the master result file is 0 length
sql/sql_show.cc
    fixed 3 bugs in SHOW CREATE TABLE

New test case shw000001 for SHOW CREATE TABLE bugs
parent 4f91d5b5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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
+24 −5
Original line number Diff line number Diff line
@@ -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;;
	}
    } 	

+5 −0
Original line number Diff line number Diff line
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'	
+7 −0
Original line number Diff line number Diff line
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 ;
+8 −1
Original line number Diff line number Diff line
@@ -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);