diff --git a/mysql-test/r/ps_11bugs.result b/mysql-test/r/ps_11bugs.result index 2aa0df6a4310ddc57238e4a827d8efa99dd5006b..0f942f6ba784c52ef8ab844b3adb69fbebad641f 100644 --- a/mysql-test/r/ps_11bugs.result +++ b/mysql-test/r/ps_11bugs.result @@ -19,3 +19,110 @@ set @arg1= 'abc'; execute st_1180 using @arg1; session_id drop table test_select; +drop table if exists tab_many_null; +Warnings: +Note 1051 Unknown table 'tab_many_null' +create table tab_many_null ( +c_01 char(6), c_02 integer, c_03 real, c_04 int(3), c_05 varchar(20), +c_06 date, c_07 char(1), c_08 real, c_09 int(11), c_10 time, +c_11 char(6), c_12 integer, c_13 real, c_14 int(3), c_15 varchar(20), +c_16 date, c_17 char(1), c_18 real, c_19 int(11), c_20 text); +prepare st_1644 from 'insert into tab_many_null values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; +set @arg01= 'row_1'; +set @arg02= 1; +set @arg03= 1.1; +set @arg04= 111; +set @arg05= 'row_one'; +set @arg06= '2004-10-12'; +set @arg07= '1'; +set @arg08= 1.1; +set @arg09= '100100100'; +set @arg10= '12:34:56'; +set @arg11= 'row_1'; +set @arg12= 1; +set @arg13= 1.1; +set @arg14= 111; +set @arg15= 'row_one'; +set @arg16= '2004-10-12'; +set @arg17= '1'; +set @arg18= 1.1; +set @arg19= '100100100'; +set @arg20= '12:34:56'; +execute st_1644 using @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg09, @arg10, +@arg11, @arg12, @arg13, @arg14, @arg15, @arg16, @arg17, @arg18, @arg19, @arg20; +set @arg01= NULL; +set @arg02= NULL; +set @arg03= NULL; +set @arg04= NULL; +set @arg05= NULL; +set @arg06= NULL; +set @arg07= NULL; +set @arg08= NULL; +set @arg09= NULL; +set @arg10= NULL; +set @arg11= NULL; +set @arg12= NULL; +set @arg13= NULL; +set @arg14= NULL; +set @arg15= NULL; +set @arg16= NULL; +set @arg17= NULL; +set @arg18= NULL; +set @arg19= NULL; +set @arg20= NULL; +execute st_1644 using @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg09, @arg10, +@arg11, @arg12, @arg13, @arg14, @arg15, @arg16, @arg17, @arg18, @arg19, @arg20; +set @arg01= 'row_3'; +set @arg02= 3; +set @arg03= 3.3; +set @arg04= 333; +set @arg05= 'row_three'; +set @arg06= '2004-10-12'; +set @arg07= '3'; +set @arg08= 3.3; +set @arg09= '300300300'; +set @arg10= '12:34:56'; +set @arg11= 'row_3'; +set @arg12= 3; +set @arg13= 3.3; +set @arg14= 333; +set @arg15= 'row_three'; +set @arg16= '2004-10-12'; +set @arg17= '3'; +set @arg18= 3.3; +set @arg19= '300300300'; +set @arg20= '12:34:56'; +execute st_1644 using @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg09, @arg10, +@arg11, @arg12, @arg13, @arg14, @arg15, @arg16, @arg17, @arg18, @arg19, @arg20; +select * from tab_many_null; +c_01 c_02 c_03 c_04 c_05 c_06 c_07 c_08 c_09 c_10 c_11 c_12 c_13 c_14 c_15 c_16 c_17 c_18 c_19 c_20 +row_1 1 1.1 111 row_one 2004-10-12 1 1.1 100100100 12:34:56 row_1 1 1.1 111 row_one 2004-10-12 1 1.1 100100100 12:34:56 +NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +row_3 3 3.3 333 row_three 2004-10-12 3 3.3 300300300 12:34:56 row_3 3 3.3 333 row_three 2004-10-12 3 3.3 300300300 12:34:56 +drop table tab_many_null; +drop table if exists table1, table2; +Warnings: +Note 1051 Unknown table 'table1' +Note 1051 Unknown table 'table2' +create table table1( +cola varchar(50) not null, +colb varchar(8) not null, +colc varchar(12) not null, +cold varchar(2) not null, +primary key (cola, colb, cold)); +create table table2( +cola varchar(50) not null, +colb varchar(8) not null, +colc varchar(2) not null, +cold float, +primary key (cold)); +insert into table1 values ('aaaa', 'yyyy', 'yyyy-dd-mm', 'R'); +insert into table2 values ('aaaa', 'yyyy', 'R', 203), ('bbbb', 'zzzz', 'C', 201); +prepare st_1676 from 'select a.cola, a.colb, a.cold from table1 a, table2 b where a.cola = ? and a.colb = ? and a.cold = ? and b.cola = a.cola and b.colb = a.colb and b.colc = a.cold'; +set @arg0= "aaaa"; +set @arg1= "yyyy"; +set @arg2= "R"; +execute st_1676 using @arg0, @arg1, @arg2; +cola colb cold +aaaa yyyy R +drop table table1, table2; diff --git a/mysql-test/t/ps_11bugs.test b/mysql-test/t/ps_11bugs.test index 53afc8b5a78513ef6eaa6d96bf2bf3156c6f122f..f62d91bc2b6b37ec34cd041c8452e5fe3e213731 100644 --- a/mysql-test/t/ps_11bugs.test +++ b/mysql-test/t/ps_11bugs.test @@ -3,6 +3,10 @@ # Prepared Statements # # re-testing bug DB entries # # # +# The bugs are reported as "closed". # +# Command sequences taken from bug report. # +# No other test contains the bug# as comment. # +# # ############################################### use test; @@ -30,3 +34,100 @@ set @arg1= 'abc'; execute st_1180 using @arg1; drop table test_select; + +# end of bug#1180 + + +# bug#1644: Insertion of more than 3 NULL columns with parameter binding fails + +# Using prepared statements, insertion of more than three columns with NULL +# values fails to insert additional NULLS. After the third column NULLS will +# be inserted into the database as zeros. +# First insert four columns of a value (i.e. 22) to verify binding is working +# correctly. Then Bind to each columns bind parameter an is_null value of 1. +# Then insert four more columns of integers, just for sanity. +# A subsequent select on the server will result in this: +# mysql> select * from foo_dfr; +# +------+------+------+------+ +# | col1 | col2 | col3 | col4 | +# +------+------+------+------+ +# | 22 | 22 | 22 | 22 | +# | NULL | NULL | NULL | 0 | +# | 88 | 88 | 88 | 88 | +# +------+------+------+------+ + +# Test is extended to more columns - code stores bit vector in bytes. + +drop table if exists tab_many_null; + +create table tab_many_null ( + c_01 char(6), c_02 integer, c_03 real, c_04 int(3), c_05 varchar(20), + c_06 date, c_07 char(1), c_08 real, c_09 int(11), c_10 time, + c_11 char(6), c_12 integer, c_13 real, c_14 int(3), c_15 varchar(20), + c_16 date, c_17 char(1), c_18 real, c_19 int(11), c_20 text); +# Do not use "timestamp" type, because it has a non-NULL default as of 4.1.2 + +prepare st_1644 from 'insert into tab_many_null values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; + +set @arg01= 'row_1'; set @arg02= 1; set @arg03= 1.1; set @arg04= 111; set @arg05= 'row_one'; +set @arg06= '2004-10-12'; set @arg07= '1'; set @arg08= 1.1; set @arg09= '100100100'; set @arg10= '12:34:56'; +set @arg11= 'row_1'; set @arg12= 1; set @arg13= 1.1; set @arg14= 111; set @arg15= 'row_one'; +set @arg16= '2004-10-12'; set @arg17= '1'; set @arg18= 1.1; set @arg19= '100100100'; set @arg20= '12:34:56'; +execute st_1644 using @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg09, @arg10, + @arg11, @arg12, @arg13, @arg14, @arg15, @arg16, @arg17, @arg18, @arg19, @arg20; + +set @arg01= NULL; set @arg02= NULL; set @arg03= NULL; set @arg04= NULL; set @arg05= NULL; +set @arg06= NULL; set @arg07= NULL; set @arg08= NULL; set @arg09= NULL; set @arg10= NULL; +set @arg11= NULL; set @arg12= NULL; set @arg13= NULL; set @arg14= NULL; set @arg15= NULL; +set @arg16= NULL; set @arg17= NULL; set @arg18= NULL; set @arg19= NULL; set @arg20= NULL; +execute st_1644 using @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg09, @arg10, + @arg11, @arg12, @arg13, @arg14, @arg15, @arg16, @arg17, @arg18, @arg19, @arg20; + +set @arg01= 'row_3'; set @arg02= 3; set @arg03= 3.3; set @arg04= 333; set @arg05= 'row_three'; +set @arg06= '2004-10-12'; set @arg07= '3'; set @arg08= 3.3; set @arg09= '300300300'; set @arg10= '12:34:56'; +set @arg11= 'row_3'; set @arg12= 3; set @arg13= 3.3; set @arg14= 333; set @arg15= 'row_three'; +set @arg16= '2004-10-12'; set @arg17= '3'; set @arg18= 3.3; set @arg19= '300300300'; set @arg20= '12:34:56'; +execute st_1644 using @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg09, @arg10, + @arg11, @arg12, @arg13, @arg14, @arg15, @arg16, @arg17, @arg18, @arg19, @arg20; + +select * from tab_many_null; + +drop table tab_many_null; + +# end of bug#1644 + + +# bug#1677: Prepared statement two-table join returns no rows when one is expected + +drop table if exists table1, table2; + +create table table1( + cola varchar(50) not null, + colb varchar(8) not null, + colc varchar(12) not null, + cold varchar(2) not null, + primary key (cola, colb, cold)); + +create table table2( + cola varchar(50) not null, + colb varchar(8) not null, + colc varchar(2) not null, + cold float, + primary key (cold)); + +insert into table1 values ('aaaa', 'yyyy', 'yyyy-dd-mm', 'R'); + +insert into table2 values ('aaaa', 'yyyy', 'R', 203), ('bbbb', 'zzzz', 'C', 201); + +prepare st_1676 from 'select a.cola, a.colb, a.cold from table1 a, table2 b where a.cola = ? and a.colb = ? and a.cold = ? and b.cola = a.cola and b.colb = a.colb and b.colc = a.cold'; + +set @arg0= "aaaa"; +set @arg1= "yyyy"; +set @arg2= "R"; + +execute st_1676 using @arg0, @arg1, @arg2; + +drop table table1, table2; + +# end of bug#1676 +