After merge fixes.

Note that mix_innodb_myisam_binlog and union fails after this patch (Will be fixed shortly by maintaners of this code)


client/mysql.cc:
  After merge fix
include/mysql.h:
  Some additions to MYSQL_BIND for cleaner prepared statement code
libmysql/libmysql.c:
  mysql_prepare_result -> mysql_get_metadata()
  Added test for offset overflow when using mysql_fetch_column()
  Cleaned up mysql_fetch_column()
  Optimized fetch_result() usage
mysql-test/r/func_group.result:
  Updated results after merge
mysql-test/r/func_test.result:
  Updated results after merge
mysql-test/r/grant.result:
  Updated results after merge
mysql-test/r/loaddata.result:
  Updated results after merge
mysql-test/r/lowercase_table.result:
  Updated results after merge
mysql-test/r/mix_innodb_myisam_binlog.result:
  Updated results after merge (note that this is still not correct; Need patch to mysqld to fix this properly)
mysql-test/r/myisam.result:
  Updated results after merge
mysql-test/r/range.result:
  Updated results after merge
mysql-test/r/rpl_loaddata.result:
  Updated results after merge
mysql-test/r/rpl_loaddata_rule_m.result:
  Updated results after merge
mysql-test/r/rpl_loaddata_rule_s.result:
  Updated results after merge
mysql-test/r/rpl_log.result:
  Updated results after merge
mysql-test/r/union.result:
  Updated results after merge
mysql-test/t/lowercase_table.test:
  Update after merge
mysql-test/t/myisam.test:
  Update after merge
mysql-test/t/union.test:
  Update after merge
sql-bench/compare-results.sh:
  Fix for now output format
sql/field.h:
  Added is_null_in_record() to make ha_innodb.cc code more general
sql/ha_innodb.cc:
  Removed some functions that uses inernal (private) MySQL information
sql/item_cmpfunc.cc:
  After merge fix
sql/log_event.cc:
  After merge fix; (Some code should be checked by Guilhem)
sql/opt_range.cc:
  Simple optimzation and after merge fixes
sql/slave.cc:
  After merge fix
sql/sql_acl.cc:
  After merge fix + code cleanup
sql/sql_select.cc:
  After merge fix
sql/sql_show.cc:
  After merge fix
sql/sql_table.cc:
  After merge fix
  Cleanup of mysql_checksum_table()
sql/sql_union.cc:
  After merge fixes.
  Note that after this the union test still fails; Will be fixed shortly...
tests/client_test.c:
  mysql_prepare_result() -> mysql_get_metadata()
This commit is contained in:
unknown 2003-09-11 19:06:23 +03:00
parent c9d1bdfac3
commit dd0d199ebe
32 changed files with 259 additions and 434 deletions

View file

@ -1812,7 +1812,6 @@ print_field_types(MYSQL_RES *result)
while ((field = mysql_fetch_field(result)))
{
tee_fprintf(PAGER,"Catalog: '%s'\nDatabase: '%s'\nTable: '%s'\nName: '%s'\nType: %d\nLength: %d\nMax length: %d\nIs_null: %d\nFlags: %d\nDecimals: %d\n\n",
tee_fprintf(PAGER,"'%s.%s.%s.%s' %d %d %d %d %d\n",
field->catalog, field->db, field->table, field->name,
(int) field->type,
field->length, field->max_length,

View file

@ -499,10 +499,12 @@ typedef struct st_mysql_bind
/* Following are for internal use. Set by mysql_bind_param */
unsigned char *inter_buffer; /* for the current data position */
unsigned long offset; /* offset position for char/binary fetch */
unsigned long internal_length; /* Used if length is 0 */
unsigned int param_number; /* For null count and error messages */
my_bool long_data_used; /* If used with mysql_send_long_data */
my_bool binary_data; /* data buffer is binary */
my_bool null_field; /* NULL data cache flag */
my_bool internal_is_null; /* Used if is_null is 0 */
void (*store_param_func)(NET *net, struct st_mysql_bind *param);
void (*fetch_result)(struct st_mysql_bind *, unsigned char **row);
} MYSQL_BIND;
@ -572,13 +574,13 @@ my_bool STDCALL mysql_rollback(MYSQL * mysql);
my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
int STDCALL mysql_fetch(MYSQL_STMT *stmt);
int STDCALL mysql_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
my_ulonglong column,
unsigned int column,
unsigned long offset);
my_bool STDCALL mysql_send_long_data(MYSQL_STMT *stmt,
unsigned int param_number,
const char *data,
unsigned long length);
MYSQL_RES *STDCALL mysql_prepare_result(MYSQL_STMT *stmt);
MYSQL_RES *STDCALL mysql_get_metadata(MYSQL_STMT *stmt);
MYSQL_RES *STDCALL mysql_param_result(MYSQL_STMT *stmt);
my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);

View file

@ -1715,10 +1715,10 @@ unsigned int alloc_stmt_fields(MYSQL_STMT *stmt)
*/
MYSQL_RES * STDCALL
mysql_prepare_result(MYSQL_STMT *stmt)
mysql_get_metadata(MYSQL_STMT *stmt)
{
MYSQL_RES *result;
DBUG_ENTER("mysql_prepare_result");
DBUG_ENTER("mysql_get_metadata");
if (!stmt->field_count || !stmt->fields)
{
@ -1758,7 +1758,6 @@ mysql_param_result(MYSQL_STMT *stmt)
}
/********************************************************************
Prepare-execute, and param handling
*********************************************************************/
@ -1773,6 +1772,7 @@ static void store_param_type(NET *net, uint type)
net->write_pos+=2;
}
/****************************************************************************
Functions to store parameter data from a prepared statement.
@ -1788,7 +1788,6 @@ static void store_param_type(NET *net, uint type)
1 Error (Can't alloc net->buffer)
****************************************************************************/
static void store_param_tinyint(NET *net, MYSQL_BIND *param)
{
*(net->write_pos++)= (uchar) *param->buffer;
@ -2085,8 +2084,6 @@ my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt)
static my_bool int_is_null_true= 1; /* Used for MYSQL_TYPE_NULL */
static my_bool int_is_null_false= 0;
static my_bool int_is_null_dummy;
static unsigned long param_length_is_dummy;
/*
Setup the parameter data buffers from application
@ -2422,7 +2419,10 @@ static void send_data_long(MYSQL_BIND *param, longlong value)
char tmp[22]; /* Enough for longlong */
uint length= (uint)(longlong10_to_str(value,(char *)tmp,10)-tmp);
ulong copy_length= min((ulong)length-param->offset, param->buffer_length);
memcpy(buffer, (char *)tmp+param->offset, copy_length);
if ((long) copy_length < 0)
copy_length=0;
else
memcpy(buffer, (char *)tmp+param->offset, copy_length);
*param->length= length;
if (copy_length != param->buffer_length)
@ -2470,7 +2470,10 @@ static void send_data_double(MYSQL_BIND *param, double value)
char tmp[128];
uint length= my_sprintf(tmp,(tmp,"%g",value));
ulong copy_length= min((ulong)length-param->offset, param->buffer_length);
memcpy(buffer, (char *)tmp+param->offset, copy_length);
if ((long) copy_length < 0)
copy_length=0;
else
memcpy(buffer, (char *)tmp+param->offset, copy_length);
*param->length= length;
if (copy_length != param->buffer_length)
@ -2535,15 +2538,19 @@ static void send_data_str(MYSQL_BIND *param, char *value, uint length)
case MYSQL_TYPE_BLOB:
*param->length= length;
length= min(length-param->offset, param->buffer_length);
memcpy(buffer, value+param->offset, length);
if ((long) length > 0)
memcpy(buffer, value+param->offset, length);
break;
default:
*param->length= length;
length= min(length-param->offset, param->buffer_length);
memcpy(buffer, value+param->offset, length);
if ((long) length < 0)
length= 0;
else
memcpy(buffer, value+param->offset, length);
if (length != param->buffer_length)
buffer[length]= '\0';
}
}
}
@ -2605,15 +2612,16 @@ static void send_data_time(MYSQL_BIND *param, MYSQL_TIME ltime,
/* Fetch data to buffers */
static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row,
my_bool field_is_unsigned)
static void fetch_results(MYSQL_BIND *param, MYSQL_FIELD *field, uchar **row)
{
ulong length;
enum enum_field_types field_type= field->type;
switch (field_type) {
case MYSQL_TYPE_TINY:
{
char value= (char) **row;
uint field_is_unsigned= (field->flags & UNSIGNED_FLAG);
longlong data= ((field_is_unsigned) ? (longlong) (unsigned char) value:
(longlong) value);
send_data_long(param,data);
@ -2624,6 +2632,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row,
case MYSQL_TYPE_YEAR:
{
short value= sint2korr(*row);
uint field_is_unsigned= (field->flags & UNSIGNED_FLAG);
longlong data= ((field_is_unsigned) ? (longlong) (unsigned short) value:
(longlong) value);
send_data_long(param,data);
@ -2633,6 +2642,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row,
case MYSQL_TYPE_LONG:
{
long value= sint4korr(*row);
uint field_is_unsigned= (field->flags & UNSIGNED_FLAG);
longlong data= ((field_is_unsigned) ? (longlong) (unsigned long) value:
(longlong) value);
send_data_long(param,data);
@ -2781,24 +2791,6 @@ static void fetch_result_str(MYSQL_BIND *param, uchar **row)
*row+= length;
}
static uint default_binary_field_length(uint field_type)
{
switch(field_type) {
case MYSQL_TYPE_TINY:
return 1;
case MYSQL_TYPE_SHORT:
return 2;
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_FLOAT:
return 4;
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_DOUBLE:
return 8;
default:
return 0;
}
}
/*
Setup the bind buffers for resultset processing
@ -2838,10 +2830,10 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
This is to make the excute code easier
*/
if (!param->is_null)
param->is_null= &int_is_null_dummy;
param->is_null= &param->internal_is_null;
if (!param->length)
param->length= &param_length_is_dummy;
param->length= &param->internal_length;
param->param_number= param_count++;
param->offset= 0;
@ -2945,10 +2937,7 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row)
if (field->type == bind->buffer_type)
(*bind->fetch_result)(bind, &row);
else
{
my_bool field_is_unsigned= (field->flags & UNSIGNED_FLAG) ? 1: 0;
fetch_results(bind, field->type, &row, field_is_unsigned);
}
fetch_results(bind, field, &row);
}
if (!((bit<<=1) & 255))
{
@ -2970,8 +2959,8 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
uchar *row;
DBUG_ENTER("mysql_fetch");
stmt->last_fetched_column= 0; /* reset */
if (stmt->result_buffered) /* buffered */
stmt->last_fetched_column= 0; /* reset */
if (stmt->result_buffered) /* buffered */
{
MYSQL_RES *res;
@ -2986,7 +2975,7 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
row= (uchar *)res->data_cursor->data;
res->data_cursor= res->data_cursor->next;
}
else /* un-buffered */
else /* un-buffered */
{
if (packet_error == net_safe_read(mysql))
{
@ -3012,107 +3001,55 @@ no_data:
/*
Fetch only specified column data to buffers
Fetch datat for one specified column data
SYNOPSIS
mysql_fetch_column()
stmt Prepared statement handler
bind Where date should be placed. Should be filled in as
when calling mysql_bind_param()
column Column to fetch (first column is 0)
ulong offset Offset in result data (to fetch blob in pieces)
This is normally 0
RETURN
0 ok
1 error
*/
int STDCALL mysql_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind,
my_ulonglong icol,
ulong offset)
uint column, ulong offset)
{
uchar *row;
my_bool null_data;
MYSQL_BIND *param= stmt->bind+column;
DBUG_ENTER("mysql_fetch_column");
if (!(row= stmt->current_row))
if (!stmt->current_row)
goto no_data;
#ifdef CHECK_EXTRA_ARGUMENTS
if (!bind || icol >= stmt->field_count)
if (column >= stmt->field_count)
{
set_stmt_errmsg(stmt, "Invalid column descriptor or offset",1,
unknown_sqlstate);
set_stmt_errmsg(stmt, "Invalid column descriptor",1, unknown_sqlstate);
DBUG_RETURN(1);
}
#endif
/* column '0' == first column */
if (stmt->res_buffers)
{
/*
Already buffers are parsed and cached to stmt->bind
during mysql_fetch() call.
*/
MYSQL_BIND *param= stmt->bind+icol;
null_data= param->null_field;
row= param->inter_buffer;
}
else
{
if (stmt->last_fetched_column == icol+1)
{
/*
Data buffer is already parsed during the last call, get
the cached information
*/
if (!stmt->last_fetched_buffer)
null_data= 1;
else
{
null_data= 0;
row= stmt->last_fetched_buffer;
}
}
else
{
/*
Advance the data buffer to icol position and cache
the information for subsequent calls
*/
uint bit= icol > 6 ? 1 : 4;
stmt->last_fetched_column= icol+1;
if (row[icol/8] & (bit << icol & 7))
{
stmt->last_fetched_buffer= 0;
null_data= 1;
}
else
{
uint length, i;
null_data= 0;
row+= (stmt->field_count+9)/8; /* skip null bits */
for (i=0; i < icol; i++)
{
if (!(length= default_binary_field_length((uint)(stmt->fields[i].
type))))
length= net_field_length(&row);
row+= length;
}
stmt->last_fetched_buffer= row;
}
}
}
if (null_data)
if (param->null_field)
{
if (bind->is_null)
*bind->is_null= 1;
}
else
{
MYSQL_FIELD *field= stmt->fields+icol;
my_bool field_is_unsigned= (field->flags & UNSIGNED_FLAG) ? 1: 0;
MYSQL_FIELD *field= stmt->fields+column;
uchar *row= param->inter_buffer;
bind->offset= offset;
if (bind->is_null)
*bind->is_null= 0;
if (bind->length) /* Set the length if non char/binary types */
*bind->length= default_binary_field_length(field->type);
*bind->length= *param->length;
else
bind->length= &param_length_is_dummy;
fetch_results(bind, field->type, &row, field_is_unsigned);
bind->length= &param->internal_length; /* Needed for fetch_result() */
fetch_results(bind, field, &row);
}
DBUG_RETURN(0);

View file

@ -551,7 +551,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain
select min(a1) from t1 where a1 between a3 and 'KKK';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 14 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 14 Using where
explain
select min(a4) from t1 where (a4 + 0.01) between 0.07 and 0.08;
id select_type table type possible_keys key key_len ref rows Extra

View file

@ -1,4 +1,4 @@
DROP TABLE IF EXISTS t1,t2;
drop table if exists t1,t2;
select 0=0,1>0,1>=1,1<0,1<=0,1!=0,strcmp("abc","abcd"),strcmp("b","a"),strcmp("a","a") ;
0=0 1>0 1>=1 1<0 1<=0 1!=0 strcmp("abc","abcd") strcmp("b","a") strcmp("a","a")
1 1 1 0 0 1 -1 1 0
@ -125,10 +125,10 @@ ERROR HY000: Illegal mix of collations (koi8r_general_ci,EXPLICIT) and (koi8r_bi
select _koi8r'a' LIKE _latin1'A';
ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'like'
CREATE TABLE t1 ( faq_group_id int(11) NOT NULL default '0', faq_id int(11) NOT NULL default '0', title varchar(240) default NULL, keywords text, description longblob, solution longblob, status tinyint(4) NOT NULL default '0', access_id smallint(6) default NULL, lang_id smallint(6) NOT NULL default '0', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime default NULL, last_access datetime default NULL, last_notify datetime default NULL, solved_count int(11) NOT NULL default '0', static_solved int(11) default NULL, solved_1 int(11) default NULL, solved_2 int(11) default NULL, solved_3 int(11) default NULL, solved_4 int(11) default NULL, solved_5 int(11) default NULL, expires datetime default NULL, notes text, assigned_to smallint(6) default NULL, assigned_group smallint(6) default NULL, last_edited_by smallint(6) default NULL, orig_ref_no varchar(15) binary default NULL, c$fundstate smallint(6) default NULL, c$contributor smallint(6) default NULL, UNIQUE KEY t1$faq_id (faq_id), KEY t1$group_id$faq_id (faq_group_id,faq_id), KEY t1$c$fundstate (c$fundstate) ) TYPE=MyISAM;
INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','<as-html>\r\n<table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n <td width=\"97%\">\r\n <h3><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000000\">How \r\n To</font><!-- #BeginEditable \"CS_troubleshoot_question\" --><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><font color=\"#000000\">: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected. </font></font><!-- #EndEditable --></h3>\r\n </td>\r\n </tr>\r\n</table>','<as-html>\r\n <table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n \r\n<td width=\"97%\"><!-- #BeginEditable \"CS_troubleshoot_answer\" --> \r\n \r\n<p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">1. Select \r\n the <i>On/Setup</i> button to access the DynaVox Setup Menu.<br>\r\n 2. Select <b>Button Features.</b><br>\r\n 3. Below the <b>OK</b> button is the <b>Usage Counts</b> button.<br>\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.<br>\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.<br>\r\n c. Select the <b>Usage Counts</b> Option Ring once and it will toggle \r\n to the alternative option.<br>\r\n 4. Once the correct setting has been chosen, select <b>OK</b> to leave the <i>Button \r\n Features</i> menu.<br>\r\n 5. Select <b>OK</b> out of the <i>Setup</i> menu and return to the communication \r\n page.</font></p>\r\n <p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">For \r\n further information on <i>Usage Counts,</i> see the <i>Button Features \r\n Menu Entry</i> in the DynaVox/DynaMyte Reference Manual.</font></p>\r\n<!-- #EndEditable --></td>\r\n </tr>\r\n</table>',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL);
CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, rank smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,'Everyone',2),(2,'Help',3),(3,'Customer Support',1);
SELECT f_acc.rank, a1.rank, a2.rank FROM t1 LEFT JOIN t1 f1 ON (f1.access_id=1 AND f1.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a1 ON (a1.access_id = f1.access_id) LEFT JOIN t1 f2 ON (f2.access_id=3 AND f2.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a2 ON (a2.access_id = f2.access_id), t2 f_acc WHERE LEAST(a1.rank,a2.rank) = f_acc.rank;
INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','<as-html>\r\n<table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n <td width=\"97%\">\r\n <h3><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000000\">How \r\n To</font><!-- #BeginEditable \"CS_troubleshoot_question\" --><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><font color=\"#000000\">: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected. </font></font><!-- #EndEditable --></h3>\r\n </td>\r\n </tr>\r\n</table>','<as-html>\r\n <table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n \r\n<td width=\"97%\"><!-- #BeginEditable \"CS_troubleshoot_answer\" --> \r\n \r\n<p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">1. Select \r\n the <i>On/Setup</i> button to access the DynaVox Setup Menu.<br>\r\n 2. Select <b>Button Features.</b><br>\r\n 3. Below the <b>OK</b> button is the <b>Usage Counts</b> button.<br>\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.<br>\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.<br>\r\n c. Select the <b>Usage Counts</b> Option Ring once and it will toggle \r\n to the alternative option.<br>\r\n 4. Once the correct setting has been chosen, select <b>OK</b> to leave the <i>Button \r\n Features</i> menu.<br>\r\n 5. Select <b>OK</b> out of the <i>Setup</i> menu and return to the communication \r\n page.</font></p>\r\n <p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">For \r\n further information on <i>Usage Counts,</i> see the <i>Button Features \r\n Menu Entry</i> in the DynaVox/DynaMyte Reference Manual.</font></p>\r\n<!-- #EndEditable --></td>\r\n </tr>\r\n</table>',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL);
CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, rank smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,'Everyone',2),(2,'Help',3),(3,'Customer Support',1);
SELECT f_acc.rank, a1.rank, a2.rank FROM t1 LEFT JOIN t1 f1 ON (f1.access_id=1 AND f1.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a1 ON (a1.access_id = f1.access_id) LEFT JOIN t1 f2 ON (f2.access_id=3 AND f2.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a2 ON (a2.access_id = f2.access_id), t2 f_acc WHERE LEAST(a1.rank,a2.rank) = f_acc.rank;
rank rank rank
2 2 NULL
DROP TABLE t1,t2;

View file

@ -145,7 +145,7 @@ show grants for drop_user@localhost;
Grants for drop_user@localhost
GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION
GRANT ALL PRIVILEGES ON `test`.* TO 'drop_user'@'localhost' WITH GRANT OPTION
GRANT SELECT (a) ON `test`.`t1` TO 'drop_user'@'localhost'
GRANT USAGE ON `test`.`t1` TO 'drop_user'@'localhost'
revoke all privileges, grant from drop_user@localhost;
show grants for drop_user@localhost;
Grants for drop_user@localhost

View file

@ -30,6 +30,8 @@ NULL 2003-03-03 2003-03-03 NULL
drop table t1;
create table t1 (a text, b text);
load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
Warnings:
Warning 1260 Record count is fewer than the column count at row 3
select concat('|',a,'|'), concat('|',b,'|') from t1;
concat('|',a,'|') concat('|',b,'|')
|Field A| |Field B|

View file

@ -13,7 +13,8 @@ SELECT T2.id from t1 as T2 LIMIT 1;
id
1
SELECT T2.id from t1 as t2 LIMIT 1;
Unknown table 'T2' in field list
id
1
RENAME TABLE T1 TO T2;
ALTER TABLE T2 ADD new_col int not null;
ALTER TABLE T2 RENAME T3;

View file

@ -8,10 +8,10 @@ insert into tm select * from ti;
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; BEGIN
master-bin.001 119 Query 1 79 use test; insert into ti values(1)
master-bin.001 178 Query 1 79 use test; insert into tm select * from ti
master-bin.001 244 Query 1 244 use test; COMMIT
master-bin.000001 79 Query 1 79 use ; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(1)
master-bin.000001 178 Query 1 79 use ; insert into tm select * from ti
master-bin.000001 244 Query 1 244 use ; COMMIT
delete from ti;
delete from tm;
reset master;
@ -22,10 +22,10 @@ rollback;
Warning: Some non-transactional changed tables couldn't be rolled back
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; BEGIN
master-bin.001 119 Query 1 79 use test; insert into ti values(2)
master-bin.001 178 Query 1 79 use test; insert into tm select * from ti
master-bin.001 244 Query 1 244 use test; ROLLBACK
master-bin.000001 79 Query 1 79 use ; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(2)
master-bin.000001 178 Query 1 79 use ; insert into tm select * from ti
master-bin.000001 244 Query 1 244 use ; ROLLBACK
delete from ti;
delete from tm;
reset master;
@ -39,13 +39,13 @@ Warning: Some non-transactional changed tables couldn't be rolled back
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; BEGIN
master-bin.001 119 Query 1 79 use test; insert into ti values(3)
master-bin.001 178 Query 1 79 use test; savepoint my_savepoint
master-bin.001 235 Query 1 79 use test; insert into ti values(4)
master-bin.001 294 Query 1 79 use test; insert into tm select * from ti
master-bin.001 360 Query 1 79 use test; rollback to savepoint my_savepoint
master-bin.001 429 Query 1 429 use test; COMMIT
master-bin.000001 79 Query 1 79 use ; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(3)
master-bin.000001 178 Query 1 79 use ; savepoint my_savepoint
master-bin.000001 235 Query 1 79 use ; insert into ti values(4)
master-bin.000001 294 Query 1 79 use ; insert into tm select * from ti
master-bin.000001 360 Query 1 79 use ; rollback to savepoint my_savepoint
master-bin.000001 429 Query 1 429 use ; COMMIT
delete from ti;
delete from tm;
reset master;
@ -64,14 +64,14 @@ a
7
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; BEGIN
master-bin.001 119 Query 1 79 use test; insert into ti values(5)
master-bin.001 178 Query 1 79 use test; savepoint my_savepoint
master-bin.001 235 Query 1 79 use test; insert into ti values(6)
master-bin.001 294 Query 1 79 use test; insert into tm select * from ti
master-bin.001 360 Query 1 79 use test; rollback to savepoint my_savepoint
master-bin.001 429 Query 1 79 use test; insert into ti values(7)
master-bin.001 488 Query 1 488 use test; COMMIT
master-bin.000001 79 Query 1 79 use ; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(5)
master-bin.000001 178 Query 1 79 use ; savepoint my_savepoint
master-bin.000001 235 Query 1 79 use ; insert into ti values(6)
master-bin.000001 294 Query 1 79 use ; insert into tm select * from ti
master-bin.000001 360 Query 1 79 use ; rollback to savepoint my_savepoint
master-bin.000001 429 Query 1 79 use ; insert into ti values(7)
master-bin.000001 488 Query 1 488 use ; COMMIT
delete from ti;
delete from tm;
reset master;
@ -86,10 +86,10 @@ get_lock("a",10)
1
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; BEGIN
master-bin.001 119 Query 1 79 use test; insert into ti values(8)
master-bin.001 178 Query 1 79 use test; insert into tm select * from ti
master-bin.001 244 Query 1 244 use test; ROLLBACK
master-bin.000001 79 Query 1 79 use ; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(8)
master-bin.000001 178 Query 1 79 use ; insert into tm select * from ti
master-bin.000001 244 Query 1 244 use ; ROLLBACK
delete from ti;
delete from tm;
reset master;
@ -97,8 +97,8 @@ insert into ti values(9);
insert into tm select * from ti;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; insert into ti values(9)
master-bin.001 138 Query 1 138 use test; insert into tm select * from ti
master-bin.000001 79 Query 1 79 use ; insert into ti values(9)
master-bin.000001 138 Query 1 138 use ; insert into tm select * from ti
delete from ti;
delete from tm;
reset master;
@ -107,17 +107,17 @@ begin;
insert into tm select * from ti;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; insert into ti values(10)
master-bin.001 139 Query 1 139 use test; insert into tm select * from ti
master-bin.000001 79 Query 1 79 use ; insert into ti values(10)
master-bin.000001 139 Query 1 139 use ; insert into tm select * from ti
insert into ti values(11);
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; insert into ti values(10)
master-bin.001 139 Query 1 139 use test; insert into tm select * from ti
master-bin.001 205 Query 1 205 use test; BEGIN
master-bin.001 245 Query 1 205 use test; insert into ti values(11)
master-bin.001 305 Query 1 305 use test; COMMIT
master-bin.000001 79 Query 1 79 use ; insert into ti values(10)
master-bin.000001 139 Query 1 139 use ; insert into tm select * from ti
master-bin.000001 205 Query 1 205 use ; BEGIN
master-bin.000001 245 Query 1 205 use ; insert into ti values(11)
master-bin.000001 305 Query 1 305 use ; COMMIT
alter table tm type=INNODB;
delete from ti;
delete from tm;
@ -128,10 +128,10 @@ insert into tm select * from ti;
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; BEGIN
master-bin.001 119 Query 1 79 use test; insert into ti values(12)
master-bin.001 179 Query 1 79 use test; insert into tm select * from ti
master-bin.001 245 Query 1 245 use test; COMMIT
master-bin.000001 79 Query 1 79 use ; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(12)
master-bin.000001 179 Query 1 79 use ; insert into tm select * from ti
master-bin.000001 245 Query 1 245 use ; COMMIT
delete from ti;
delete from tm;
reset master;
@ -153,9 +153,9 @@ rollback to savepoint my_savepoint;
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; BEGIN
master-bin.001 119 Query 1 79 use test; insert into ti values(14)
master-bin.001 179 Query 1 179 use test; COMMIT
master-bin.000001 79 Query 1 79 use ; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(14)
master-bin.000001 179 Query 1 179 use ; COMMIT
delete from ti;
delete from tm;
reset master;
@ -173,8 +173,8 @@ a
18
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 79 Query 1 79 use test; BEGIN
master-bin.001 119 Query 1 79 use test; insert into ti values(16)
master-bin.001 179 Query 1 79 use test; insert into ti values(18)
master-bin.001 239 Query 1 239 use test; COMMIT
master-bin.000001 79 Query 1 79 use ; BEGIN
master-bin.000001 119 Query 1 79 use ; insert into ti values(16)
master-bin.000001 179 Query 1 79 use ; insert into ti values(18)
master-bin.000001 239 Query 1 239 use ; COMMIT
drop table ti,tm;

View file

@ -290,6 +290,12 @@ update t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
delete from t1 where i8=1;
select i1,i2 from t1;
i1 i2
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
CREATE TABLE `t1` (
`post_id` mediumint(8) unsigned NOT NULL auto_increment,

View file

@ -230,27 +230,27 @@ create table t1 (x int, y int, index(x), index(y));
insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9);
update t1 set y=x;
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 7 and t1.y+0;
table type possible_keys key key_len ref rows Extra
t1 ref y y 5 const 1 Using where
t2 range x x 5 NULL 4 Using where
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref y y 5 const 1 Using where
1 SIMPLE t2 range x x 5 NULL 4 Using where
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 7 and t2.x <= t1.y+0;
table type possible_keys key key_len ref rows Extra
t1 ref y y 5 const 1 Using where
t2 range x x 5 NULL 4 Using where
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref y y 5 const 1 Using where
1 SIMPLE t2 range x x 5 NULL 4 Using where
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1;
table type possible_keys key key_len ref rows Extra
t1 ref y y 5 const 1 Using where
t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 1)
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref y y 5 const 1 Using where
1 SIMPLE t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 1)
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1;
table type possible_keys key key_len ref rows Extra
t1 ref y y 5 const 1 Using where
t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 1)
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref y y 5 const 1 Using where
1 SIMPLE t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 1)
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
table type possible_keys key key_len ref rows Extra
t1 ref y y 5 const 1 Using where
t2 ALL x NULL NULL NULL 9 Using where
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref y y 5 const 1 Using where
1 SIMPLE t2 ALL x NULL NULL NULL 9 Using where
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
table type possible_keys key key_len ref rows Extra
t1 ref y y 5 const 1 Using where
t2 range x x 5 NULL 2 Using where
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref y y 5 const 1 Using where
1 SIMPLE t2 range x x 5 NULL 2 Using where
drop table t1;

View file

@ -22,7 +22,7 @@ day id category name
2003-04-22 2416 a bbbbb
show master status;
File Position Binlog_do_db Binlog_ignore_db
slave-bin.001 964
slave-bin.000001 964
drop table t1;
drop table t2;
drop table t3;

View file

@ -1,9 +1,9 @@
slave stop;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
start slave;
reset master;
create database test2;
create table t1(a int, b int, unique(b));

View file

@ -1,9 +1,9 @@
slave stop;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
start slave;
reset master;
create table t1(a int, b int, unique(b));
load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;

View file

@ -12,7 +12,10 @@ create table t1(n int not null auto_increment primary key);
insert into t1 values (NULL);
drop table t1;
create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1 ignore 1 lines;
select count(*) from t1;
count(*)
69
drop table t1;
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
@ -81,16 +84,16 @@ slave-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL)
slave-bin.000001 263 Query 1 263 use `test`; drop table t1
slave-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null)
slave-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581
slave-bin.000001 1065 Exec_load 1 1056 ;file_id=1
slave-bin.000001 1088 Query 1 1079 use `test`; drop table t1
slave-bin.000001 1136 Query 1 4 use `test`; create table t5 (a int)
slave-bin.000001 1194 Query 1 62 use `test`; drop table t5
slave-bin.000001 1065 Exec_load 1 1065 ;file_id=1
slave-bin.000001 1088 Query 1 1088 use `test`; drop table t1
slave-bin.000001 1136 Query 1 1136 use `test`; create table t5 (a int)
slave-bin.000001 1194 Query 1 1194 use `test`; drop table t5
slave-bin.000001 1242 Rotate 2 1242 slave-bin.000002;pos=4
show binlog events in 'slave-bin.000002' from 4;
Log_name Pos Event_type Server_id Orig_log_pos Info
slave-bin.000002 4 Query 1 110 use `test`; create table t1 (n int)
slave-bin.000002 62 Query 1 168 use `test`; insert into t1 values (1)
slave-bin.000002 122 Query 1 228 use `test`; drop table t1
slave-bin.000002 4 Query 1 4 use `test`; create table t1 (n int)
slave-bin.000002 62 Query 1 62 use `test`; insert into t1 values (1)
slave-bin.000002 122 Query 1 122 use `test`; drop table t1
show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key
127.0.0.1 root MASTER_PORT 1 master-bin.000002 276 slave-relay-bin.000003 214 master-bin.000002 Yes Yes 0 0 276 214 No

View file

@ -348,11 +348,7 @@ select found_rows();
found_rows()
4
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
a
1
select found_rows();
found_rows()
4
ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2;
a
1
@ -435,7 +431,7 @@ a
3
3
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
Wrong usage/placement of 'SQL_CALC_FOUND_ROWS'
ERROR 42000: Wrong usage/placement of 'SQL_CALC_FOUND_ROWS'
drop table t1,t2;
CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM;
INSERT INTO t1 (id) VALUES("1");

View file

@ -11,7 +11,7 @@ INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
SELECT * FROM t1;
SELECT T1.id from T1 LIMIT 1;
SELECT T2.id from t1 as T2 LIMIT 1;
--error 1109
# This gave an error in 4.0, but it's fixed in 4.1
SELECT T2.id from t1 as t2 LIMIT 1;
RENAME TABLE T1 TO T2;
ALTER TABLE T2 ADD new_col int not null;

View file

@ -299,7 +299,7 @@ update t1 set b=repeat('a',256);
update t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0;
check table t1;
delete from t1 where i8=1;
select * from t1;
select i1,i2 from t1;
check table t1;
drop table t1;

View file

@ -212,8 +212,10 @@ select found_rows();
select found_rows();
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1);
select found_rows();
# This used to work in 4.0 but not anymore in 4.1
--error 1149
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
select found_rows();
#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;

View file

@ -93,7 +93,7 @@ foreach (@ARGV)
}
elsif (/Comments:\s+(.+)/i) {
$tot{$prog}{'comments'} = $1;
} elsif (/^(\S+):\s*(estimated\s|)total\stime:\s+([\d.]+)\s+(wallclock\s|)secs/i)
} elsif (/^(\S+):.*(estimated\s|)total\stime:\s+([\d.]+)\s+(wallclock\s|)secs/i)
{
$tmp = $1; $tmp =~ s/://;
$tot{$prog}{$tmp} = [ $3, (length($2) ? "+" : "")];

View file

@ -125,6 +125,13 @@ public:
{ return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : table->null_row; }
inline bool is_real_null(uint row_offset=0)
{ return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : 0; }
inline bool is_null_in_record(const uchar *record)
{
if (!null_ptr)
return 0;
return test(record[(uint) (null_ptr - (uchar*) table->record[0])] &
null_bit);
}
inline void set_null(int row_offset=0)
{ if (null_ptr) null_ptr[row_offset]|= null_bit; }
inline void set_notnull(int row_offset=0)

View file

@ -1540,82 +1540,6 @@ ha_innobase::close(void)
DBUG_RETURN(0);
}
/* The following accessor functions should really be inside MySQL code! */
/******************************************************************
Gets field offset for a field in a table. */
inline
uint
get_field_offset(
/*=============*/
/* out: offset */
TABLE* table, /* in: MySQL table object */
Field* field) /* in: MySQL field object */
{
return((uint) (field->ptr - (char*) table->record[0]));
}
/******************************************************************
Checks if a field in a record is SQL NULL. Uses the record format
information in table to track the null bit in record. */
inline
uint
field_in_record_is_null(
/*====================*/
/* out: 1 if NULL, 0 otherwise */
TABLE* table, /* in: MySQL table object */
Field* field, /* in: MySQL field object */
char* record) /* in: a row in MySQL format */
{
int null_offset;
if (!field->null_ptr) {
return(0);
}
null_offset = (uint) ((char*) field->null_ptr
- (char*) table->record[0]);
if (record[null_offset] & field->null_bit) {
return(1);
}
return(0);
}
/******************************************************************
Sets a field in a record to SQL NULL. Uses the record format
information in table to track the null bit in record. */
inline
void
set_field_in_record_to_null(
/*========================*/
TABLE* table, /* in: MySQL table object */
Field* field, /* in: MySQL field object */
char* record) /* in: a row in MySQL format */
{
int null_offset;
null_offset = (uint) ((char*) field->null_ptr
- (char*) table->record[0]);
record[null_offset] = record[null_offset] | field->null_bit;
}
/******************************************************************
Resets SQL NULL bits in a record to zero. */
inline
void
reset_null_bits(
/*============*/
TABLE* table, /* in: MySQL table object */
char* record) /* in: a row in MySQL format */
{
bzero(record, table->null_bytes);
}
extern "C" {
/*****************************************************************
InnoDB uses this function is to compare two data fields for which the
@ -1825,11 +1749,10 @@ ha_innobase::store_key_val_for_row(
blob_data = row_mysql_read_blob_ref(&blob_len,
(byte*) (record
+ (ulint)get_field_offset(table, field)),
+ (ulint) field->offset()),
(ulint) field->pack_length());
ut_a(get_field_offset(table, field)
== key_part->offset);
ut_a(field->offset() == key_part->offset);
if (blob_len > key_part->length) {
blob_len = key_part->length;
}
@ -2009,9 +1932,7 @@ build_template(
templ->mysql_null_bit_mask = 0;
}
templ->mysql_col_offset = (ulint)
get_field_offset(table, field);
templ->mysql_col_offset = (ulint) field->offset();
templ->mysql_col_len = (ulint) field->pack_length();
templ->type = get_innobase_type_from_mysql_type(field);
templ->is_unsigned = (ulint) (field->flags & UNSIGNED_FLAG);
@ -2348,8 +2269,8 @@ calc_row_difference(
/* goto skip_field;
}*/
o_ptr = (byte*) old_row + get_field_offset(table, field);
n_ptr = (byte*) new_row + get_field_offset(table, field);
o_ptr = (byte*) old_row + field->offset();
n_ptr = (byte*) new_row + field->offset();
o_len = field->pack_length();
n_len = field->pack_length();
@ -2374,13 +2295,11 @@ calc_row_difference(
}
if (field->null_ptr) {
if (field_in_record_is_null(table, field,
(char*) old_row)) {
if (field->is_null_in_record((uchar*) old_row)) {
o_len = UNIV_SQL_NULL;
}
if (field_in_record_is_null(table, field,
(char*) new_row)) {
if (field->is_null_in_record((uchar*) new_row)) {
n_len = UNIV_SQL_NULL;
}
}

View file

@ -1459,7 +1459,7 @@ void Item_func_in::fix_length_and_dec()
DBUG_ASSERT(0);
return;
}
if (array && !(current_thd->fatal_error)) // If not EOM
if (array && !(current_thd->is_fatal_error)) // If not EOM
{
uint j=0;
for (uint i=1 ; i < arg_count ; i++)

View file

@ -912,18 +912,6 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
DBUG_PRINT("query",("%s",thd->query));
mysql_parse(thd, thd->query, q_len);
/*
Set a flag if we are inside an transaction so that we can restart
the transaction from the start if we are killed
This will only be done if we are supporting transactional tables
in the slave.
*/
if (!strcmp(thd->query,"BEGIN"))
rli->inside_transaction= opt_using_transactions;
else if (!(strcmp(thd->query,"COMMIT") && strcmp(thd->query,"ROLLBACK")))
rli->inside_transaction=0;
/*
If we expected a non-zero error code, and we don't get the same error
code, and none of them should be ignored.
@ -1771,7 +1759,7 @@ Fatal error running LOAD DATA INFILE on table '%s'. Default database: '%s'",
void Rotate_log_event::pack_info(Protocol *protocol)
{
char buf1[256], buf[22];
String tmp(buf1, sizeof(buf1));
String tmp(buf1, sizeof(buf1), log_cs);
tmp.length(0);
tmp.append(new_log_ident, ident_len);
tmp.append(";pos=");
@ -1896,16 +1884,19 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
pthread_mutex_lock(&rli->data_lock);
#ifdef TO_BE_CHECKED_BY_GUILHEM
if (rli->inside_transaction)
{
slave_print_error(rli, 0,
"there is an unfinished transaction in the relay log \
(could find neither COMMIT nor ROLLBACK in the relay log); it could be that \
the master died while writing the transaction to its binary log. Now the slave \
is rolling back the transaction.");
"\
There is an unfinished transaction in the relay log (could find neither \
COMMIT nor ROLLBACK in the relay log); It could be that the master died while \
writing the transaction to its binary log. Now the slave is rolling back the \
transaction.");
pthread_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1);
}
#endif
memcpy(log_name, new_log_ident, ident_len+1);
rli->group_master_log_pos = pos;

View file

@ -618,6 +618,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables,
SEL_TREE *tree;
KEY_PART *key_parts;
PARAM param;
THD *thd= current_thd;
/* set up parameter that is passed to all functions */
param.baseflag=basflag;
@ -628,13 +629,13 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables,
param.keys=0;
param.mem_root= &alloc;
current_thd->no_errors=1; // Don't warn about NULL
thd->no_errors=1; // Don't warn about NULL
init_sql_alloc(&alloc,2048,0);
if (!(param.key_parts = (KEY_PART*) alloc_root(&alloc,
sizeof(KEY_PART)*
head->key_parts)))
{
current_thd->no_errors=0;
thd->no_errors=0;
free_root(&alloc,MYF(0)); // Return memory & allocator
DBUG_RETURN(0); // Can't use range
}
@ -736,7 +737,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables,
}
free_root(&alloc,MYF(0)); // Return memory & allocator
my_pthread_setspecific_ptr(THR_MALLOC,old_root);
current_thd->no_errors=0;
thd->no_errors=0;
}
DBUG_EXECUTE("info",print_quick(quick,needed_reg););
/*
@ -764,7 +765,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
while ((item=li++))
{
SEL_TREE *new_tree=get_mm_tree(param,item);
if(current_thd->fatal_error)
if (current_thd->is_fatal_error)
DBUG_RETURN(0); // out of memory
tree=tree_and(param,tree,new_tree);
if (tree && tree->type == SEL_TREE::IMPOSSIBLE)

View file

@ -2963,7 +2963,6 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
restarts replication from a non-transactional statement (with CHANGE
MASTER).
*/
rli->inside_transaction= 0;
/* Wake up master_pos_wait() */
pthread_mutex_unlock(&rli->data_lock);
DBUG_PRINT("info",("Signaling possibly waiting master_pos_wait() functions"));

View file

@ -532,36 +532,13 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b)
/*
Prepare crypted scramble to be sent to the client
*/
Seek ACL entry for a user, check password, SSL cypher, and if
everything is OK, update THD user data and USER_RESOURCES struct.
void prepare_scramble(THD *thd, ACL_USER *acl_user,char* prepared_scramble)
{
/* Binary password format to be used for generation*/
char bin_password[SCRAMBLE41_LENGTH];
/* Generate new long scramble for the thread */
create_random_string(SCRAMBLE41_LENGTH,&thd->rand,thd->scramble);
thd->scramble[SCRAMBLE41_LENGTH]=0;
/* Get binary form, First 4 bytes of prepared scramble is salt */
get_hash_and_password(acl_user->salt,acl_user->pversion,prepared_scramble,
(unsigned char*) bin_password);
/* Store "*" as identifier for old passwords */
if (!acl_user->pversion)
prepared_scramble[0]='*';
/* Finally encrypt password to get prepared scramble */
password_crypt(thd->scramble, prepared_scramble+4, bin_password,
SCRAMBLE41_LENGTH);
}
/*
Seek ACL entry for a user, check password, SSL cypher, and if
everything is OK, update THD user data and USER_RESOURCES struct.
IMPLEMENTATION
This function does not check if the user has any sensible privileges:
only user's existence and validity is checked.
Note, that entire operation is protected by acl_cache_lock.
IMPLEMENTATION
This function does not check if the user has any sensible privileges:
only user's existence and validity is checked.
Note, that entire operation is protected by acl_cache_lock.
SYNOPSIS
acl_getroot()
@ -578,7 +555,7 @@ void prepare_scramble(THD *thd, ACL_USER *acl_user,char* prepared_scramble)
SCRAMBLE_LENGTH_323, SCRAMBLE_LENGTH
'thd' and 'mqh' are updated on success; other params are IN.
RETURN VALUE
RETURN VALUE
0 success: thd->priv_user, thd->priv_host, thd->master_access, mqh are
updated
1 user not found or authentification failure
@ -616,29 +593,29 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh,
for (uint i=0 ; i < acl_users.elements ; i++)
{
ACL_USER *acl_user= dynamic_element(&acl_users,i,ACL_USER*);
if (!acl_user->user || !strcmp(thd->user, acl_user->user))
ACL_USER *acl_user_tmp= dynamic_element(&acl_users,i,ACL_USER*);
if (!acl_user_tmp->user || !strcmp(thd->user, acl_user_tmp->user))
{
if (compare_hostname(&acl_user->host, thd->host, thd->ip))
if (compare_hostname(&acl_user_tmp->host, thd->host, thd->ip))
{
/* check password: it should be empty or valid */
if (passwd_len == acl_user->salt_len)
if (passwd_len == acl_user_tmp->salt_len)
{
if (acl_user->salt_len == 0 ||
acl_user->salt_len == SCRAMBLE_LENGTH &&
check_scramble(passwd, thd->scramble, acl_user->salt) == 0 ||
if (acl_user_tmp->salt_len == 0 ||
acl_user_tmp->salt_len == SCRAMBLE_LENGTH &&
check_scramble(passwd, thd->scramble, acl_user_tmp->salt) == 0 ||
check_scramble_323(passwd, thd->scramble,
(ulong *) acl_user->salt) == 0)
(ulong *) acl_user_tmp->salt) == 0)
{
acl_user= acl_user;
acl_user= acl_user_tmp;
res= 0;
}
}
else if (passwd_len == SCRAMBLE_LENGTH &&
acl_user->salt_len == SCRAMBLE_LENGTH_323)
acl_user_tmp->salt_len == SCRAMBLE_LENGTH_323)
res= -1;
else if (passwd_len == SCRAMBLE_LENGTH_323 &&
acl_user->salt_len == SCRAMBLE_LENGTH)
acl_user_tmp->salt_len == SCRAMBLE_LENGTH)
res= 2;
/* linear search complete: */
break;
@ -2472,7 +2449,7 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
{
my_printf_error(ER_WRONG_USAGE, ER(ER_WRONG_USAGE), MYF(0),
"DB GRANT","GLOBAL PRIVILEGES");
result= 1;
result= -1;
}
}
}
@ -3113,7 +3090,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
protocol->store(global.ptr(),global.length(),global.charset());
if (protocol->write())
{
error=-1;
error= -1;
goto end;
}
}
@ -3171,7 +3148,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
protocol->store(db.ptr(),db.length(),db.charset());
if (protocol->write())
{
error=-1;
error= -1;
goto end;
}
}
@ -3421,7 +3398,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
{
if (!(acl_user= check_acl_user(user_name, &counter)))
{
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'",
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; No such user",
user_name->user.str,
user_name->host.str);
result= -1;
@ -3429,7 +3406,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
}
if ((acl_user->access & ~0))
{
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'",
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Global privileges exists",
user_name->user.str,
user_name->host.str);
result= -1;
@ -3452,7 +3429,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
}
if (counter != acl_dbs.elements)
{
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'",
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Database privileges exists",
user_name->user.str,
user_name->host.str);
result= -1;
@ -3475,7 +3452,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
}
if (counter != column_priv_hash.records)
{
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'",
sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Table privileges exists",
user_name->user.str,
user_name->host.str);
result= -1;

View file

@ -1414,6 +1414,7 @@ JOIN::exec()
curr_join->group_list : curr_join->order,
curr_join->select_limit, unit->select_limit_cnt))
DBUG_VOID_RETURN;
}
}
curr_join->having= curr_join->tmp_having;
thd->proc_info="Sending data";

View file

@ -1035,7 +1035,7 @@ static void append_directory(THD *thd, String *packet, const char *dir_type,
const char *filename)
{
uint length;
if (filename && !(thd->sql_mode & MODE_NO_DIR_IN_CREATE))
if (filename && !(thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
{
length= dirname_length(filename);
packet->append(' ');

View file

@ -916,7 +916,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
thd->proc_info="creating table";
if (thd->sql_mode & MODE_NO_DIR_IN_CREATE)
if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
create_info->data_file_name= create_info->index_file_name= 0;
create_info->table_options=db_options;
@ -2597,7 +2597,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
DBUG_RETURN(error > 0 ? -1 : 0);
}
int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
{
TABLE_LIST *table;
List<Item> field_list;
@ -2612,24 +2613,23 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
if (protocol->send_fields(&field_list, 1))
DBUG_RETURN(-1);
for (table = tables; table; table = table->next)
for (table= tables; table; table= table->next)
{
char table_name[NAME_LEN*2+2];
char* db = (table->db) ? table->db : thd->db;
bool fatal_error=0;
bool fatal_error= 0;
TABLE *t;
strxmov(table_name,db ? db : "",".",table->real_name,NullS);
t=table->table = open_ltable(thd, table, TL_READ_NO_INSERT);
#ifdef EMBEDDED_LIBRARY
thd->net.last_errno= 0; // these errors shouldn't get client
#endif
strxmov(table_name, table->db ,".", table->real_name, NullS);
t= table->table= open_ltable(thd, table, TL_READ_NO_INSERT);
thd->clear_error(); // these errors shouldn't get client
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
if (!t)
{
/* Table didn't exist */
protocol->store_null();
thd->net.last_error[0]=0;
}
@ -2641,45 +2641,42 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
!(check_opt->flags & T_EXTEND))
protocol->store((ulonglong)t->file->checksum());
else if (!(t->file->table_flags() & HA_HAS_CHECKSUM) &&
check_opt->flags & T_QUICK)
(check_opt->flags & T_QUICK))
protocol->store_null();
else
{
/* calculating table's checksum */
ha_checksum crc=0;
ha_checksum crc= 0;
if (t->file->rnd_init(1))
protocol->store_null();
else
{
while (!t->file->rnd_next(t->record[0]))
{
ha_checksum row_crc=0;
ha_checksum row_crc= 0;
if (t->record[0] != t->field[0]->ptr)
row_crc=my_checksum(row_crc, t->record[0],
t->field[0]->ptr - t->record[0]);
row_crc= my_checksum(row_crc, t->record[0],
t->field[0]->ptr - t->record[0]);
for (uint i=0; i < t->fields; i++ )
for (uint i= 0; i < t->fields; i++ )
{
Field *f=t->field[i];
Field *f= t->field[i];
if (f->type() == FIELD_TYPE_BLOB)
{
String tmp;
f->val_str(&tmp,&tmp);
row_crc=my_checksum(row_crc, tmp.ptr(), tmp.length());
row_crc= my_checksum(row_crc, tmp.ptr(), tmp.length());
}
else
row_crc=my_checksum(row_crc, f->ptr, f->pack_length());
row_crc= my_checksum(row_crc, f->ptr, f->pack_length());
}
crc+=row_crc;
crc+= row_crc;
}
protocol->store((ulonglong)crc);
}
}
#ifdef EMBEDDED_LIBRARY
thd->net.last_errno= 0; // these errors shouldn't get client
#endif
thd->clear_error();
close_thread_tables(thd);
table->table=0; // For query cache
}
@ -2689,6 +2686,7 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
send_eof(thd);
DBUG_RETURN(0);
err:
close_thread_tables(thd); // Shouldn't be needed
if (table)

View file

@ -262,23 +262,8 @@ int st_select_lex_unit::exec()
res= sl->join->reinit();
else
{
/* Don't use offset for the last union if there is no braces */
if (sl != lex_sl)
{
offset_limit_cnt= sl->offset_limit;
select_limit_cnt= sl->select_limit+sl->offset_limit;
}
else
{
offset_limit_cnt= 0;
/*
We can't use LIMIT at this stage if we are using ORDER BY for the
whole query
*/
select_limit_cnt= HA_POS_ERROR;
if (! sl->order_list.first)
select_limit_cnt= sl->select_limit+sl->offset_limit;
}
offset_limit_cnt= sl->offset_limit;
select_limit_cnt= sl->select_limit+sl->offset_limit;
if (select_limit_cnt < sl->select_limit)
select_limit_cnt= HA_POS_ERROR; // no limit
@ -297,10 +282,10 @@ int st_select_lex_unit::exec()
sl->options|= found_rows_for_union;
}
/*
As far as union share table space we should reassign table map,
which can be spoiled by 'prepare' of JOIN of other UNION parts
if it use same tables
/*
As far as union share table space we should reassign table map,
which can be spoiled by 'prepare' of JOIN of other UNION parts
if it use same tables
*/
uint tablenr=0;
for (TABLE_LIST *table_list= (TABLE_LIST*) sl->table_list.first;

View file

@ -412,7 +412,7 @@ uint my_process_stmt_result(MYSQL_STMT *stmt)
my_bool is_null[MAX_RES_FIELDS];
int rc, i;
if (!(result= mysql_prepare_result(stmt))) /* No meta info */
if (!(result= mysql_get_metadata(stmt))) /* No meta info */
{
while (!mysql_fetch(stmt))
row_count++;
@ -1017,7 +1017,7 @@ static void test_prepare_field_result()
verify_param_count(stmt,1);
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
my_print_result_metadata(result);
@ -1765,7 +1765,6 @@ static void test_bug1115()
MYSQL_BIND bind[1];
ulong length[1];
char szData[11];
int nData=1;
myheader("test_bug1115");
@ -3728,7 +3727,7 @@ static void test_prepare_resultset()
verify_param_count(stmt,0);
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
my_print_result_metadata(result);
mysql_stmt_close(stmt);
@ -5926,7 +5925,7 @@ static void test_field_misc()
rc = mysql_execute(stmt);
mystmt(stmt,rc);
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
myassert(1 == my_process_stmt_result(stmt));
@ -5967,7 +5966,7 @@ static void test_field_misc()
stmt = mysql_prepare(mysql, "SELECT @@table_type", 30);
mystmt_init(stmt);
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
rc = mysql_execute(stmt);
@ -5987,7 +5986,7 @@ static void test_field_misc()
stmt = mysql_prepare(mysql, "SELECT @@max_error_count", 30);
mystmt_init(stmt);
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
rc = mysql_execute(stmt);
@ -6007,7 +6006,7 @@ static void test_field_misc()
stmt = mysql_prepare(mysql, "SELECT @@max_allowed_packet", 30);
mystmt_init(stmt);
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
rc = mysql_execute(stmt);
@ -6027,7 +6026,7 @@ static void test_field_misc()
stmt = mysql_prepare(mysql, "SELECT @@sql_warnings", 30);
mystmt_init(stmt);
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
rc = mysql_execute(stmt);
@ -6418,7 +6417,7 @@ static void test_explain_bug()
myassert( 2 == my_process_stmt_result(stmt));
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
fprintf(stdout, "\n total fields in the result: %d",
@ -6454,7 +6453,7 @@ static void test_explain_bug()
myassert( 1 == my_process_stmt_result(stmt));
result = mysql_prepare_result(stmt);
result = mysql_get_metadata(stmt);
mytest(result);
fprintf(stdout, "\n total fields in the result: %d",
@ -7255,7 +7254,7 @@ static void test_mem_overun()
rc = mysql_execute(stmt);
mystmt(stmt,rc);
field_res = mysql_prepare_result(stmt);
field_res = mysql_get_metadata(stmt);
mytest(field_res);
fprintf(stdout,"\n total fields : %d", mysql_num_fields(field_res));
@ -7611,7 +7610,7 @@ static void test_ts()
stmt = mysql_prepare(mysql,"SELECT * FROM test_ts",50);
mystmt_init(stmt);
prep_res = mysql_prepare_result(stmt);
prep_res = mysql_get_metadata(stmt);
mytest(prep_res);
rc = mysql_execute(stmt);