Commit 7cf8285b authored by monty@mysql.com's avatar monty@mysql.com

After merge fixes

Add support for warnings for prepare of prepared statements
Fixed test to work with --ps-protocol
Fixed some test results
parent 3c6d5e43
......@@ -1864,13 +1864,14 @@ void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
{
uchar *pos;
uint field_count, param_count;
uint field_count, param_count, packet_length;
MYSQL_DATA *fields_data;
DBUG_ENTER("read_prepare_result");
mysql= mysql->last_used_con;
if (net_safe_read(mysql) == packet_error)
if ((packet_length=net_safe_read(mysql)) == packet_error)
DBUG_RETURN(1);
mysql->warning_count= 0;
pos= (uchar*) mysql->net.read_pos;
stmt->stmt_id= uint4korr(pos+1); pos+= 5;
......@@ -1878,6 +1879,8 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
field_count= uint2korr(pos); pos+= 2;
/* Number of placeholders in the statement */
param_count= uint2korr(pos); pos+= 2;
if (packet_length >= 12)
mysql->warning_count= uint2korr(pos+1);
if (param_count != 0)
{
......@@ -1894,7 +1897,6 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT))
mysql->server_status|= SERVER_STATUS_IN_TRANS;
mysql->extra_info= net_field_length_ll(&pos);
if (!(fields_data= (*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0,7)))
DBUG_RETURN(1);
if (!(stmt->fields= unpack_fields(fields_data,&stmt->mem_root,
......@@ -1902,9 +1904,10 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt)
mysql->server_capabilities)))
DBUG_RETURN(1);
}
stmt->field_count= (uint) field_count;
stmt->field_count= field_count;
stmt->param_count= (ulong) param_count;
mysql->warning_count= 0;
DBUG_PRINT("exit",("field_count: %u param_count: %u warning_count: %u",
field_count, param_count, (uint) mysql->warning_count));
DBUG_RETURN(0);
}
......
......@@ -63,4 +63,8 @@ a0
select 'a' union select concat('a', -0.0);
a
a
good
a0.0
select 'a' union select concat('a', -0.0000);
a
a
a0.0000
drop table if exists t1,t2,t3,t4;
drop table if exists t1_1,t1_2,t9_1,t9_2;
drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa;
drop view if exists v1;
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
......
......@@ -1433,7 +1433,8 @@ insert into v1 values (1) on duplicate key update a=2;
insert into v1 values (1) on duplicate key update a=2;
ERROR HY000: CHECK OPTION failed 'test.v1'
insert ignore into v1 values (1) on duplicate key update a=2;
ERROR HY000: CHECK OPTION failed 'test.v1'
Warnings:
Error 1369 CHECK OPTION failed 'test.v1'
select * from t1;
a
1
......
......@@ -273,8 +273,8 @@ create table t3 like t1;
show create table t3;
select * from t3;
# Disable PS becasue of @@warning_count
--disable_ps_protocol
create table if not exists t3 like t1;
--disable_ps_protocol
select @@warning_count;
--enable_ps_protocol
create temporary table t3 like t2;
......
......@@ -32,9 +32,7 @@ create table t2 (grp int, a bigint unsigned, c char(10));
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
# REPLACE ... SELECT doesn't yet work with PS
--disable_ps_protocol
replace into t2 select grp, a, c from t1 limit 2,1;
--enable_ps_protocol
select * from t2;
drop table t1,t2;
......
......@@ -271,7 +271,10 @@ select date_add(date,INTERVAL "1" QUARTER) from t1;
select timestampadd(MINUTE, 1, date) from t1;
select timestampadd(WEEK, 1, date) from t1;
select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
# Prepared statements doesn't support FRAC_SECOND yet
--disable_ps_protocol
select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1;
--enable_ps_protocol
select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;
select timestampdiff(YEAR, '2002-05-01', '2001-01-01') as a;
......
......@@ -280,7 +280,11 @@ insert into t1 values (1),(2),(3);
select count(*) from t1 group by s1 having s1 is null;
# prepared statements prints warnings too early
--disable_ps_protocol
select s1*0 as s1 from t1 group by s1 having s1 <> 0;
--enable_ps_protocol
# ANSI requires: 3 rows
# MySQL returns: 0 rows - because of GROUP BY name resolution
......
......@@ -136,9 +136,7 @@ insert into t2 values (2,"t2:2"), (3,"t2:3");
insert into t1 select * from t2;
select * from t1;
# REPLACE .. SELECT is not yet supported by PS
--disable_ps_protocol
replace into t1 select * from t2;
--enable_ps_protocol
select * from t1;
drop table t1,t2;
......
......@@ -1789,7 +1789,10 @@ CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned defa
INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);
CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);
# Disable PS becasue we get more warnings from PS than from normal execution
--disable_ps_protocol
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
--enable_ps_protocol
# Testing the same select with NULL's instead of invalid datetime values
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
DROP TABLE t1,t2;
......
......@@ -944,7 +944,7 @@ select fun(2.3, 3, 5)|
insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
# These don't work yet.
# Disable PS because double's give a bit different values
--disable_ps_protocol
select * from t2 where s = append("a", "b")|
select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)|
......
#
# This is the test for mysql_fix_privilege_tables
#
# Note: If this test fails, don't be confused about the errors reported
# by mysql-test-run; This shows warnings from generated by
# mysql_fix_system_tables which should be ignored.
# Instead, concentrate on the errors in r/system_mysql_db.reject
--disable_warnings
drop table if exists t1,t1aa,t2aa;
--enable_warnings
-- disable_result_log
-- disable_query_log
......
......@@ -53,6 +53,7 @@ select @a;
drop trigger t1.trg;
drop table t1;
# PS doesn't work with multi-row statements
--disable_ps_protocol
# Before update trigger
# (In future we will achieve this via proper error handling in triggers)
......
......@@ -17,10 +17,8 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7;
CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
show columns from t1;
# PS doesn't give errors on prepare yet
--disable_ps_protocol
CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000));
CREATE TABLE t4 (c varchar(65530) character set utf8 not null);
--enable_ps_protocol
show columns from t2;
create table t3 (a long, b long byte);
show create TABLE t3;
......
......@@ -5,9 +5,6 @@
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6;
--enable_warnings
# PS doesn't work correctly with found_rows: to be fixed
--disable_ps_protocol
CREATE TABLE t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
......@@ -30,9 +27,12 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b;
explain extended (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
(select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2;
# PS doesn't work correctly with found_rows: to be fixed
--disable_ps_protocol
select found_rows();
select sql_calc_found_rows a,b from t1 union all select a,b from t2 limit 2;
select found_rows();
--enable_ps_protocol
#
# Test some error conditions with UNION
......@@ -210,15 +210,27 @@ insert into t2 values (3),(4),(5);
# Test global limits
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2) LIMIT 1;
# PS doesn't work correctly with found_rows: to be fixed
--disable_ps_protocol
select found_rows();
--enable_ps_protocol
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2) LIMIT 2;
# PS doesn't work correctly with found_rows: to be fixed
--disable_ps_protocol
select found_rows();
--enable_ps_protocol
# Test cases where found_rows() should return number of returned rows
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2);
# PS doesn't work correctly with found_rows: to be fixed
--disable_ps_protocol
select found_rows();
--enable_ps_protocol
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1);
# PS doesn't work correctly with found_rows: to be fixed
--disable_ps_protocol
select found_rows();
--enable_ps_protocol
# This used to work in 4.0 but not anymore in 4.1
--error 1064
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
......@@ -226,9 +238,15 @@ select found_rows();
# In these case found_rows() should work
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2;
# PS doesn't work correctly with found_rows: to be fixed
--disable_ps_protocol
select found_rows();
--disable_ps_protocol
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION all SELECT * FROM t2 LIMIT 2;
# PS doesn't work correctly with found_rows: to be fixed
--disable_ps_protocol
select found_rows();
--disable_ps_protocol
# The following examples will not be exact
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2;
......
......@@ -14,6 +14,9 @@ delete from mysql.tables_priv where user like 'mysqltest\_%';
delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges;
# Limits doesn't work with prepared statements (yet)
--disable_ps_protocol
# Test of MAX_QUERIES_PER_HOUR limit
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2;
connect (mqph, localhost, mysqltest_1,,);
......@@ -149,6 +152,7 @@ disconnect muca2;
disconnect muca3;
set global max_user_connections= 0;
drop user mysqltest_1@localhost;
--enable_ps_protocol
# Final cleanup
drop table t1;
......@@ -1394,7 +1394,6 @@ create view v1 as select * from t1 where a < 2 with check option;
insert into v1 values (1) on duplicate key update a=2;
-- error 1369
insert into v1 values (1) on duplicate key update a=2;
-- error 1369
insert ignore into v1 values (1) on duplicate key update a=2;
select * from t1;
drop view v1;
......
......@@ -26,9 +26,8 @@ show warnings limit 1;
drop database if exists not_exists_db;
show count(*) warnings;
create table t1(id int);
# PS doesn't give warnings on prepare
--disable_ps_protocol
create table if not exists t1(id int);
--disable_ps_protocol
select @@warning_count;
--enable_ps_protocol
drop table t1;
......@@ -96,12 +95,9 @@ drop table t1;
# Test for deprecated TYPE= syntax
#
# PS doesn't give warnings on prepare
--disable_ps_protocol
create table t1 (id int) type=heap;
alter table t1 type=myisam;
drop table t1;
--enable_ps_protocol
#
# Test for deprecated table_type variable
......
......@@ -45,3 +45,6 @@ dist-hook:
-rm -rf `find $(distdir) -type d -name SCCS`
windoze-dsp:
# Don't update the files from bitkeeper
%::SCCS/s.%
......@@ -2282,6 +2282,7 @@ void ha_ndbcluster::print_results()
break;
}
case NdbDictionary::Column::Undefined:
case NdbDictionary::Column::Bit:
fprintf(DBUG_FILE, "Unknown type: %d", col->getType());
break;
}
......
......@@ -2578,8 +2578,8 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
*/
thd->net.pkt_nr = net->pkt_nr;
}
if (mysql_load(thd, &ex, &tables, field_list, handle_dup, ignore, net != 0,
TL_WRITE, 0))
if (mysql_load(thd, &ex, &tables, field_list, handle_dup, ignore,
net != 0, TL_WRITE))
thd->query_error = 1;
if (thd->cuted_fields)
{
......
......@@ -229,9 +229,8 @@ typedef struct st_copy_info {
/* for INSERT ... UPDATE */
List<Item> *update_fields;
List<Item> *update_values;
/* for VIEW ... WITH CHECK OPTION */
/* for VIEW ... WITH CHECK OPTION */
TABLE_LIST *view;
bool ignore;
} COPY_INFO;
......
......@@ -283,7 +283,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
to NULL.
*/
thd->count_cuted_fields= ((values_list.elements == 1 &&
duplic != DUP_IGNORE) ?
!ignore) ?
CHECK_FIELD_ERROR_FOR_NULL :
CHECK_FIELD_WARN);
thd->cuted_fields = 0L;
......@@ -306,7 +306,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
table->file->start_bulk_insert(values_list.elements);
thd->no_trans_update= 0;
thd->abort_on_warning= (duplic != DUP_IGNORE &&
thd->abort_on_warning= (!ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
......@@ -1758,7 +1758,8 @@ bool mysql_insert_select_prepare(THD *thd)
select_insert::select_insert(TABLE_LIST *table_list_par, TABLE *table_par,
List<Item> *fields_par,
List<Item> *update_fields, List<Item> *update_values,
List<Item> *update_fields,
List<Item> *update_values,
enum_duplicates duplic,
bool ignore_check_option_errors)
:table_list(table_list_par), table(table_par), fields(fields_par),
......@@ -1805,12 +1806,11 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
restore_record(table,default_values); // Get empty record
table->next_number_field=table->found_next_number_field;
thd->cuted_fields=0;
if (info.ignore ||
info.handle_duplicates == DUP_REPLACE)
if (info.ignore || info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
table->file->start_bulk_insert((ha_rows) 0);
thd->no_trans_update= 0;
thd->abort_on_warning= (info.handle_duplicates != DUP_IGNORE &&
thd->abort_on_warning= (!info.ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
......@@ -1856,9 +1856,7 @@ bool select_insert::send_data(List<Item> &values)
DBUG_RETURN(1);
if (table_list) // Not CREATE ... SELECT
{
switch (table_list->view_check_option(thd,
thd->lex->duplicates ==
DUP_IGNORE)) {
switch (table_list->view_check_option(thd, info.ignore)) {
case VIEW_CHECK_SKIP:
DBUG_RETURN(0);
case VIEW_CHECK_ERROR:
......@@ -2010,12 +2008,11 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
restore_record(table,default_values); // Get empty record
thd->cuted_fields=0;
if (info.ignore ||
info.handle_duplicates == DUP_REPLACE)
if (info.ignore || info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
table->file->start_bulk_insert((ha_rows) 0);
thd->no_trans_update= 0;
thd->abort_on_warning= (info.handle_duplicates != DUP_IGNORE &&
thd->abort_on_warning= (!info.ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
......
......@@ -298,7 +298,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
table->copy_blobs=1;
thd->no_trans_update= 0;
thd->abort_on_warning= (handle_duplicates != DUP_IGNORE &&
thd->abort_on_warning= (!ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
......
......@@ -150,13 +150,18 @@ find_prepared_statement(THD *thd, ulong id, const char *where)
static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
{
NET *net= &stmt->thd->net;
char buff[9];
char buff[12];
uint tmp;
DBUG_ENTER("send_prep_stmt");
buff[0]= 0; /* OK packet indicator */
int4store(buff+1, stmt->id);
int2store(buff+5, columns);
int2store(buff+7, stmt->param_count);
buff[9]= 0; // Guard against a 4.1 client
tmp= min(stmt->thd->total_warn_count, 65535);
int2store(buff+10, tmp);
/*
Send types and names of placeholders to the client
XXX: fix this nasty upcast from List<Item_param> to List<Item>
......
......@@ -118,7 +118,6 @@ int mysql_update(THD *thd,
bool using_limit= limit != HA_POS_ERROR;
bool safe_update= thd->options & OPTION_SAFE_UPDATES;
bool used_key_is_modified, transactional_table, log_delayed;
bool ignore_err= (thd->lex->duplicates == DUP_IGNORE);
int res;
int error=0;
uint used_index;
......@@ -395,7 +394,7 @@ int mysql_update(THD *thd,
transactional_table= table->file->has_transactions();
thd->no_trans_update= 0;
thd->abort_on_warning= test(handle_duplicates != DUP_IGNORE &&
thd->abort_on_warning= test(!ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
......@@ -415,7 +414,7 @@ int mysql_update(THD *thd,
if (compare_record(table, query_id))
{
if ((res= table_list->view_check_option(thd, ignore_err)) !=
if ((res= table_list->view_check_option(thd, ignore)) !=
VIEW_CHECK_OK)
{
found--;
......@@ -850,7 +849,8 @@ bool mysql_multi_update(THD *thd,
multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list,
TABLE_LIST *leaves_list,
List<Item> *field_list, List<Item> *value_list,
enum enum_duplicates handle_duplicates_arg, bool ignore_arg)
enum enum_duplicates handle_duplicates_arg,
bool ignore_arg)
:all_tables(table_list), leaves(leaves_list), update_tables(0),
thd(thd_arg), tmp_tables(0), updated(0), found(0), fields(field_list),
values(value_list), table_count(0), copy_field(0),
......@@ -1143,7 +1143,6 @@ multi_update::~multi_update()
bool multi_update::send_data(List<Item> &not_used_values)
{
TABLE_LIST *cur_table;
bool ignore_err= (thd->lex->duplicates == DUP_IGNORE);
DBUG_ENTER("multi_update::send_data");
for (cur_table= update_tables; cur_table; cur_table= cur_table->next_local)
......@@ -1178,7 +1177,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
if (compare_record(table, thd->query_id))
{
int error;
if ((error= cur_table->view_check_option(thd, ignore_err)) !=
if ((error= cur_table->view_check_option(thd, ignore)) !=
VIEW_CHECK_OK)
{
found--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment