Skip to content

Commit

Permalink
MDEV-15789 - mysqlslap use incorrect table def
Browse files Browse the repository at this point in the history
The bug arises when one uses --auto-generate-sql-guid-primary (and
--auto-generate-sql-secondary-indexes) with mysqlslap and also have
sql_mode=STRICT_TRANS_TABLE.

When using this option, mysqlslap should create a column with varchar(36),
but it appears to create it as a varchar(32) only. Then if one has
sql_mode=STRICT_TRANS_TABLES, it throws an error, like:

  mysqlslap: Cannot run query INSERT INTO t1 VALUES (...)
  ERROR : Data too long for column 'id' at row 1

Upstream bug report: BUG#80329.
  • Loading branch information
Chris Calender authored and Sergey Vojtovich committed Jun 7, 2018
1 parent 75b4eb5 commit d9b159a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/mysqlslap.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ build_table_string(void)

if (auto_generate_sql_guid_primary)
{
dynstr_append(&table_string, "id varchar(32) primary key");
dynstr_append(&table_string, "id varchar(36) primary key");

if (num_int_cols || num_char_cols || auto_generate_sql_guid_primary)
dynstr_append(&table_string, ",");
Expand All @@ -855,7 +855,7 @@ build_table_string(void)
if (count) /* Except for the first pass we add a comma */
dynstr_append(&table_string, ",");

if (snprintf(buf, HUGE_STRING_LENGTH, "id%d varchar(32) unique key", count)
if (snprintf(buf, HUGE_STRING_LENGTH, "id%d varchar(36) unique key", count)
> HUGE_STRING_LENGTH)
{
fprintf(stderr, "Memory Allocation error in create table\n");
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/r/mysqlslap.result
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,6 @@ Benchmark
# MDEV-4684 - Enhancement request: --init-command support for mysqlslap
#
DROP TABLE t1;
#
# Bug MDEV-15789 (Upstream: #80329): MYSQLSLAP OPTIONS --AUTO-GENERATE-SQL-GUID-PRIMARY and --AUTO-GENERATE-SQL-SECONDARY-INDEXES DONT WORK
#
8 changes: 8 additions & 0 deletions mysql-test/t/mysqlslap.test
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ DROP DATABASE bug58090;

--exec $MYSQL_SLAP --create-schema=test --init-command="CREATE TABLE t1(a INT)" --silent --concurrency=1 --iterations=1
DROP TABLE t1;

--echo #
--echo # Bug MDEV-15789 (Upstream: #80329): MYSQLSLAP OPTIONS --AUTO-GENERATE-SQL-GUID-PRIMARY and --AUTO-GENERATE-SQL-SECONDARY-INDEXES DONT WORK
--echo #

--exec $MYSQL_SLAP --concurrency=1 --silent --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --create-schema=slap

--exec $MYSQL_SLAP --concurrency=1 --silent --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-secondary-indexes=1 --create-schema=slap

0 comments on commit d9b159a

Please sign in to comment.