Review of code pushed since last 5.0 pull:

Ensure that ccache is also used for C programs
mysql: Ensure that 'delimiter' works the same way in batch mode as in normal mode
mysqldump: Change to use ;; (instead of //) as a stored procedure/trigger delimiter
Fixed test cases by adding missing DROP's and rename views to be of type 'v#'
Removed MY_UNIX_PATH from fn_format()
Removed current_db_used from TABLE_LIST
Removed usage of 'current_thd' in Item_splocal
Removed some compiler warnings
A bit faster longlong2str code



BUILD/FINISH.sh:
  Ensure that ccache is also used for C programs
BUILD/SETUP.sh:
  Ensure that ccache is also used for C programs
client/mysql.cc:
  More debugging
  Ensure that 'delimiter' works the same way in batch mode as in normal mode.
  Compare 'delimiter' command case-insensitive.
  The above fixes the delimiter bugs so that we can now use ;; as a trigger/SP function delimiter in mysqldump.
client/mysqldump.c:
  Indentation fixes
  Use ;; as a delmimiter for stored procedures and triggers instead of //
client/mysqltest.c:
  Indentation fixes
include/my_sys.h:
  Remove not needed MY_UNIX_PATH parameter
mysql-test/r/alter_table.result:
  Better to reuse mysqltest database (test didn't properly delete mysqltest1 at start)
mysql-test/r/func_str.result:
  More testing of CONV() (to ensure that longlong2str() works correctly)
mysql-test/r/information_schema.result:
  Drop all used tables and views
  Rename view tables to 'v#' to ensure that if this test fails, not a lot of other test fails
mysql-test/r/information_schema_inno.result:
  Drop all used tables
mysql-test/r/multi_statement.result:
  Drop used tables
mysql-test/r/mysql.result:
  Add error messages to result
mysql-test/r/mysqldump.result:
  ;; is now used as SP/trigger delimiter
mysql-test/r/mysqlshow.result:
  Drop used tables
mysql-test/r/temp_table.result:
  Drop used views
  Rename views to v#
mysql-test/t/alter_table.test:
  Better to reuse mysqltest database (test didn't properly delete mysqltest1 at start)
mysql-test/t/func_str.test:
  More testing of CONV() (to ensure that longlong2str() works correctly)
mysql-test/t/information_schema.test:
  Drop all used tables and views
  Rename view tables to 'v#' to ensure that if this test fails, not a lot of other test fails
mysql-test/t/information_schema_inno.test:
  Drop all used tables
mysql-test/t/multi_statement.test:
  Drop used tables
mysql-test/t/mysql.test:
  Add error messages to result
mysql-test/t/mysqlshow.test:
  Drop used tables
mysql-test/t/temp_table.test:
  Drop used views
  Rename views to v#
mysys/mf_format.c:
  Remove not needed MY_UNIX_PATH parameter
  (This goes against how fn_format() is supposed to work and also conflicts with other options like MY_RETURN_REAL_PATH)
sql/ha_federated.cc:
  Removed extra empty line
sql/item.cc:
  Use 'str_value' instead of 'str_value_ptr' to hold result for Item_splocal
  Remove some calls to 'thd' in Item_splocal by making 'thd' a class variable
  One doesn't have to set 'null_value' when calling 'is_null()'
sql/item.h:
  Add THD as a class variable to Item_splocal
  Use 'str_value' instead of 'str_value_ptr' to hold temp result
  Fixed bug in Item_hex when used in CAST()
sql/item_func.cc:
  Optimize new code
sql/log_event.cc:
  Move 'to_unix_path()' out of fn_format()
sql/opt_range.cc:
  Simplify code
sql/sp_head.cc:
  Ensure that Item_splocal has thd set before we call '->this_item()'
sql/sql_class.cc:
  Return error if Statement::insert() fails in either hash_insert()
sql/sql_parse.cc:
  Remove 'current_db_used' as we can trivially check if db table qualifier was used without this.
  Simplify code
sql/sql_prepare.cc:
  Use enum instead of const int, to avoid ugly code for VC++
sql/structs.h:
  Remove compiler warnings when using STRING_WITH_LEN() with constant strings.
sql/table.cc:
  Fixed indentation
sql/table.h:
  Remove not needed current_db_used
strings/decimal.c:
  Simplify code
strings/longlong2str-x86.s:
  A bit faster longlong2str.
  (Took some ideas from Peter Gulutzan's code)
strings/my_strtoll10.c:
  Simplify code for MetroWerks compiler
This commit is contained in:
unknown 2005-10-06 17:54:43 +03:00
parent b34d5bd247
commit c807724f36
40 changed files with 384 additions and 366 deletions

View File

@ -14,7 +14,7 @@ path=`dirname $0`
if [ -z "$just_clean" ] if [ -z "$just_clean" ]
then then
commands="$commands commands="$commands
CFLAGS=\"$cflags\" CXX=\"$CXX\" CXXFLAGS=\"$cxxflags\" CXXLDFLAGS=\"$CXXLDFLAGS\" \ CC=\"$CC\" CFLAGS=\"$cflags\" CXX=\"$CXX\" CXXFLAGS=\"$cxxflags\" CXXLDFLAGS=\"$CXXLDFLAGS\" \
$configure" $configure"
fi fi

View File

@ -98,6 +98,10 @@ else
make=make make=make
fi fi
if test -z "$CC" ; then
CC=gcc
fi
if test -z "$CXX" ; then if test -z "$CXX" ; then
CXX=gcc CXX=gcc
fi fi

View File

@ -320,7 +320,7 @@ static void initialize_readline (char *name);
static void fix_history(String *final_command); static void fix_history(String *final_command);
#endif #endif
static COMMANDS *find_command (char *name,char cmd_name); static COMMANDS *find_command(char *name,char cmd_name);
static bool add_line(String &buffer,char *line,char *in_string, static bool add_line(String &buffer,char *line,char *in_string,
bool *ml_comment); bool *ml_comment);
static void remove_cntrl(String &buffer); static void remove_cntrl(String &buffer);
@ -1085,10 +1085,12 @@ static int read_and_execute(bool interactive)
} }
static COMMANDS *find_command (char *name,char cmd_char) static COMMANDS *find_command(char *name,char cmd_char)
{ {
uint len; uint len;
char *end; char *end;
DBUG_ENTER("find_command");
DBUG_PRINT("enter",("name: '%s' char: %d", name ? name : "NULL", cmd_char));
if (!name) if (!name)
{ {
@ -1100,12 +1102,16 @@ static COMMANDS *find_command (char *name,char cmd_char)
while (my_isspace(charset_info,*name)) while (my_isspace(charset_info,*name))
name++; name++;
/* /*
As special case we allow row that starts with word delimiter If there is an \\g in the row or if the row has a delimiter but
to be able to change delimiter if someone has delimiter 'delimiter'. this is not a delimiter command, let add_line() take care of
parsing the row and calling find_command()
*/ */
if (strstr(name, "\\g") || (strstr(name, delimiter) && if (strstr(name, "\\g") || (strstr(name, delimiter) &&
strncmp(name, "delimiter", 9))) strlen(name) >= 9 &&
return ((COMMANDS *) 0); my_strnncoll(charset_info,(uchar*) name,
9,
(const uchar*) "delimiter", 9)))
DBUG_RETURN((COMMANDS *) 0);
if ((end=strcont(name," \t"))) if ((end=strcont(name," \t")))
{ {
len=(uint) (end - name); len=(uint) (end - name);
@ -1121,15 +1127,18 @@ static COMMANDS *find_command (char *name,char cmd_char)
for (uint i= 0; commands[i].name; i++) for (uint i= 0; commands[i].name; i++)
{ {
if (commands[i].func && if (commands[i].func &&
((name && ((name &&
!my_strnncoll(charset_info,(uchar*)name,len, !my_strnncoll(charset_info,(uchar*)name,len,
(uchar*)commands[i].name,len) && (uchar*)commands[i].name,len) &&
!commands[i].name[len] && !commands[i].name[len] &&
(!end || (end && commands[i].takes_params))) || (!end || (end && commands[i].takes_params))) ||
!name && commands[i].cmd_char == cmd_char)) !name && commands[i].cmd_char == cmd_char))
return (&commands[i]); {
DBUG_PRINT("exit",("found command: %s", commands[i].name));
DBUG_RETURN(&commands[i]);
}
} }
return ((COMMANDS *) 0); DBUG_RETURN((COMMANDS *) 0);
} }
@ -1140,15 +1149,16 @@ static bool add_line(String &buffer,char *line,char *in_string,
char buff[80], *pos, *out; char buff[80], *pos, *out;
COMMANDS *com; COMMANDS *com;
bool need_space= 0; bool need_space= 0;
DBUG_ENTER("add_line");
if (!line[0] && buffer.is_empty()) if (!line[0] && buffer.is_empty())
return 0; DBUG_RETURN(0);
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
if (status.add_to_history && line[0] && not_in_history(line)) if (status.add_to_history && line[0] && not_in_history(line))
add_history(line); add_history(line);
#endif #endif
#ifdef USE_MB #ifdef USE_MB
char *strend=line+(uint) strlen(line); char *end_of_line=line+(uint) strlen(line);
#endif #endif
for (pos=out=line ; (inchar= (uchar) *pos) ; pos++) for (pos=out=line ; (inchar= (uchar) *pos) ; pos++)
@ -1157,13 +1167,14 @@ static bool add_line(String &buffer,char *line,char *in_string,
buffer.is_empty()) buffer.is_empty())
continue; continue;
#ifdef USE_MB #ifdef USE_MB
int l; int length;
if (use_mb(charset_info) && if (use_mb(charset_info) &&
(l = my_ismbchar(charset_info, pos, strend))) { (length= my_ismbchar(charset_info, pos, end_of_line)))
while (l--) {
*out++ = *pos++; while (length--)
pos--; *out++ = *pos++;
continue; pos--;
continue;
} }
#endif #endif
if (!*ml_comment && inchar == '\\') if (!*ml_comment && inchar == '\\')
@ -1183,7 +1194,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
const String tmp(line,(uint) (out-line), charset_info); const String tmp(line,(uint) (out-line), charset_info);
buffer.append(tmp); buffer.append(tmp);
if ((*com->func)(&buffer,pos-1) > 0) if ((*com->func)(&buffer,pos-1) > 0)
return 1; // Quit DBUG_RETURN(1); // Quit
if (com->takes_params) if (com->takes_params)
{ {
for (pos++ ; for (pos++ ;
@ -1201,29 +1212,40 @@ static bool add_line(String &buffer,char *line,char *in_string,
{ {
sprintf(buff,"Unknown command '\\%c'.",inchar); sprintf(buff,"Unknown command '\\%c'.",inchar);
if (put_info(buff,INFO_ERROR) > 0) if (put_info(buff,INFO_ERROR) > 0)
return 1; DBUG_RETURN(1);
*out++='\\'; *out++='\\';
*out++=(char) inchar; *out++=(char) inchar;
continue; continue;
} }
} }
else if (!*ml_comment && !*in_string &&
else if (!*ml_comment && (*pos == *delimiter && (*pos == *delimiter && is_prefix(pos + 1, delimiter + 1) ||
is_prefix(pos + 1, delimiter + 1)) && buffer.length() == 0 && (out - line) >= 9 &&
!*in_string) !my_strcasecmp(charset_info, line, "delimiter")))
{ {
uint old_delimiter_length= delimiter_length; uint old_delimiter_length= delimiter_length;
if (out != line) if (out != line)
buffer.append(line, (uint) (out - line)); // Add this line buffer.append(line, (uint) (out - line)); // Add this line
if ((com= find_command(buffer.c_ptr(), 0))) if ((com= find_command(buffer.c_ptr(), 0)))
{ {
if (com->func == com_delimiter)
{
/*
Delimiter wants the get rest of the given line as argument to
allow one to change ';' to ';;' and back
*/
char *end= strend(pos);
buffer.append(pos, (uint) (end - pos));
/* Ensure pos will point at \0 after the pos+= below */
pos= end - old_delimiter_length + 1;
}
if ((*com->func)(&buffer, buffer.c_ptr()) > 0) if ((*com->func)(&buffer, buffer.c_ptr()) > 0)
return 1; // Quit DBUG_RETURN(1); // Quit
} }
else else
{ {
if (com_go(&buffer, 0) > 0) // < 0 is not fatal if (com_go(&buffer, 0) > 0) // < 0 is not fatal
return 1; DBUG_RETURN(1);
} }
buffer.length(0); buffer.length(0);
out= line; out= line;
@ -1275,9 +1297,9 @@ static bool add_line(String &buffer,char *line,char *in_string,
if (buffer.length() + length >= buffer.alloced_length()) if (buffer.length() + length >= buffer.alloced_length())
buffer.realloc(buffer.length()+length+IO_SIZE); buffer.realloc(buffer.length()+length+IO_SIZE);
if (!(*ml_comment) && buffer.append(line,length)) if (!(*ml_comment) && buffer.append(line,length))
return 1; DBUG_RETURN(1);
} }
return 0; DBUG_RETURN(0);
} }
/***************************************************************** /*****************************************************************

View File

@ -1188,23 +1188,25 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
This function has logic to print the appropriate syntax depending on whether This function has logic to print the appropriate syntax depending on whether
this is a procedure or functions this is a procedure or functions
RETURN 0 succes, 1 if error RETURN
0 Success
1 Error
*/ */
static uint dump_routines_for_db (char *db) static uint dump_routines_for_db(char *db)
{ {
char query_buff[512]; char query_buff[512];
const char *routine_type[]={"FUNCTION", "PROCEDURE"}; const char *routine_type[]= {"FUNCTION", "PROCEDURE"};
char db_name_buff[NAME_LEN*2+3], name_buff[NAME_LEN*2+3], *routine_name; char db_name_buff[NAME_LEN*2+3], name_buff[NAME_LEN*2+3];
char *routine_name;
int i; int i;
FILE *sql_file = md_result_file; FILE *sql_file= md_result_file;
MYSQL_RES *routine_res, *routine_list_res; MYSQL_RES *routine_res, *routine_list_res;
MYSQL_ROW row, routine_list_row; MYSQL_ROW row, routine_list_row;
DBUG_ENTER("dump_routines_for_db"); DBUG_ENTER("dump_routines_for_db");
DBUG_PRINT("enter", ("db: '%s'", db));
mysql_real_escape_string(sock, db_name_buff, db, strlen(db)); mysql_real_escape_string(sock, db_name_buff, db, strlen(db));
DBUG_PRINT("enter", ("db: '%s'", db_name_buff));
/* nice comments */ /* nice comments */
if (opt_comments) if (opt_comments)
@ -1217,10 +1219,10 @@ static uint dump_routines_for_db (char *db)
if (lock_tables) if (lock_tables)
mysql_query(sock, "LOCK TABLES mysql.proc READ"); mysql_query(sock, "LOCK TABLES mysql.proc READ");
fprintf(sql_file, "DELIMITER //\n"); fprintf(sql_file, "DELIMITER ;;\n");
/* 0, retrieve and dump functions, 1, procedures */ /* 0, retrieve and dump functions, 1, procedures */
for (i=0; i <= 1; i++) for (i= 0; i <= 1; i++)
{ {
my_snprintf(query_buff, sizeof(query_buff), my_snprintf(query_buff, sizeof(query_buff),
"SHOW %s STATUS WHERE Db = '%s'", "SHOW %s STATUS WHERE Db = '%s'",
@ -1232,18 +1234,18 @@ static uint dump_routines_for_db (char *db)
if (mysql_num_rows(routine_list_res)) if (mysql_num_rows(routine_list_res))
{ {
while((routine_list_row= mysql_fetch_row(routine_list_res))) while ((routine_list_row= mysql_fetch_row(routine_list_res)))
{ {
DBUG_PRINT("info", ("retrieving CREATE %s for %s", routine_type[i], DBUG_PRINT("info", ("retrieving CREATE %s for %s", routine_type[i],
name_buff)); name_buff));
routine_name=quote_name(routine_list_row[1], name_buff, 0); routine_name= quote_name(routine_list_row[1], name_buff, 0);
my_snprintf(query_buff, sizeof(query_buff), "SHOW CREATE %s %s", my_snprintf(query_buff, sizeof(query_buff), "SHOW CREATE %s %s",
routine_type[i], routine_name); routine_type[i], routine_name);
if (mysql_query_with_error_report(sock, &routine_res, query_buff)) if (mysql_query_with_error_report(sock, &routine_res, query_buff))
DBUG_RETURN(1); DBUG_RETURN(1);
while ((row=mysql_fetch_row(routine_res))) while ((row= mysql_fetch_row(routine_res)))
{ {
/* /*
if the user has EXECUTE privilege he see routine names, but NOT the if the user has EXECUTE privilege he see routine names, but NOT the
@ -1254,16 +1256,18 @@ static uint dump_routines_for_db (char *db)
if (strlen(row[2])) if (strlen(row[2]))
{ {
if (opt_drop) if (opt_drop)
fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */ //\n", fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;;\n",
routine_type[i], routine_name); routine_type[i], routine_name);
/* /*
we need to change sql_mode only for the CREATE PROCEDURE/FUNCTION we need to change sql_mode only for the CREATE
otherwise we may need to re-quote routine_name PROCEDURE/FUNCTION otherwise we may need to re-quote routine_name
*/; */;
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/ //\n", fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\"*/;;\n",
row[1] /* sql_mode */); row[1] /* sql_mode */);
fprintf(sql_file, "/*!50003 %s */ //\n", row[2]); fprintf(sql_file, "/*!50003 %s */;;\n", row[2]);
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/ //\n"); fprintf(sql_file,
"/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/"
";;\n");
} }
} /* end of routine printing */ } /* end of routine printing */
} /* end of list of routines */ } /* end of list of routines */
@ -1741,7 +1745,6 @@ static void dump_triggers_for_table (char *table, char *db)
char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3]; char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
char query_buff[512]; char query_buff[512];
FILE *sql_file = md_result_file; FILE *sql_file = md_result_file;
DBUG_ENTER("dump_triggers_for_table"); DBUG_ENTER("dump_triggers_for_table");
DBUG_PRINT("enter", ("db: %s, table: %s", db, table)); DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
result_table= quote_name(table, table_buff, 1); result_table= quote_name(table, table_buff, 1);
@ -1759,11 +1762,11 @@ static void dump_triggers_for_table (char *table, char *db)
} }
if (mysql_num_rows(result)) if (mysql_num_rows(result))
fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\ fprintf(sql_file, "\n/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n\
DELIMITER //;\n"); DELIMITER ;;\n");
while ((row=mysql_fetch_row(result))) while ((row=mysql_fetch_row(result)))
{ {
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\" */ //\n\ fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n\
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s */ //\n\n", /*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s */;;\n\n",
row[6], /* sql_mode */ row[6], /* sql_mode */
quote_name(row[0], name_buff, 0), /* Trigger */ quote_name(row[0], name_buff, 0), /* Trigger */
row[4], /* Timing */ row[4], /* Timing */
@ -1773,8 +1776,8 @@ DELIMITER //;\n");
} }
if (mysql_num_rows(result)) if (mysql_num_rows(result))
fprintf(sql_file, fprintf(sql_file,
"DELIMITER ;//\n\ "DELIMITER ;\n"
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;"); "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n");
mysql_free_result(result); mysql_free_result(result);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -1800,10 +1803,10 @@ static char *add_load_option(char *ptr,const char *object,
/* /*
** Allow the user to specify field terminator strings like: Allow the user to specify field terminator strings like:
** "'", "\", "\\" (escaped backslash), "\t" (tab), "\n" (newline) "'", "\", "\\" (escaped backslash), "\t" (tab), "\n" (newline)
** This is done by doubleing ' and add a end -\ if needed to avoid This is done by doubling ' and add a end -\ if needed to avoid
** syntax errors from the SQL parser. syntax errors from the SQL parser.
*/ */
static char *field_escape(char *to,const char *from,uint length) static char *field_escape(char *to,const char *from,uint length)

View File

@ -135,7 +135,8 @@ typedef struct
long code; long code;
} st_error; } st_error;
static st_error global_error[] = { static st_error global_error[] =
{
#include <mysqld_ername.h> #include <mysqld_ername.h>
{ 0, 0 } { 0, 0 }
}; };
@ -210,7 +211,8 @@ static int ps_match_re(char *);
static char *ps_eprint(int); static char *ps_eprint(int);
static void ps_free_reg(void); static void ps_free_reg(void);
static const char *embedded_server_groups[] = { static const char *embedded_server_groups[]=
{
"server", "server",
"embedded", "embedded",
"mysqltest_SERVER", "mysqltest_SERVER",
@ -1273,7 +1275,7 @@ int do_modify_var(struct st_query *query, const char *name,
if (*p != '$') if (*p != '$')
die("First argument to %s must be a variable (start with $)", name); die("First argument to %s must be a variable (start with $)", name);
v= var_get(p, &p, 1, 0); v= var_get(p, &p, 1, 0);
switch (operator){ switch (operator) {
case DO_DEC: case DO_DEC:
v->int_val--; v->int_val--;
break; break;

View File

@ -98,7 +98,6 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_RETURN_REAL_PATH 32 /* return full path for file */ #define MY_RETURN_REAL_PATH 32 /* return full path for file */
#define MY_SAFE_PATH 64 /* Return NULL if too long path */ #define MY_SAFE_PATH 64 /* Return NULL if too long path */
#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */ #define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */
#define MY_UNIX_PATH 256 /* convert path to UNIX format */
/* My seek flags */ /* My seek flags */
#define MY_SEEK_SET 0 #define MY_SEEK_SET 0

View File

@ -541,16 +541,16 @@ create table t1 ( a timestamp );
alter table t1 add unique ( a(1) ); alter table t1 add unique ( a(1) );
ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys
drop table t1; drop table t1;
create database mysqltest1; create database mysqltest;
create table t1 (c1 int); create table t1 (c1 int);
alter table t1 rename mysqltest1.t1; alter table t1 rename mysqltest.t1;
drop table t1; drop table t1;
ERROR 42S02: Unknown table 't1' ERROR 42S02: Unknown table 't1'
alter table mysqltest1.t1 rename t1; alter table mysqltest.t1 rename t1;
drop table t1; drop table t1;
create table t1 (c1 int); create table t1 (c1 int);
use mysqltest1; use mysqltest;
drop database mysqltest1; drop database mysqltest;
alter table test.t1 rename t1; alter table test.t1 rename t1;
ERROR 3D000: No database selected ERROR 3D000: No database selected
alter table test.t1 rename test.t1; alter table test.t1 rename test.t1;

View File

@ -818,6 +818,9 @@ lpad(12345, 5, "#")
SELECT conv(71, 10, 36), conv('1Z', 36, 10); SELECT conv(71, 10, 36), conv('1Z', 36, 10);
conv(71, 10, 36) conv('1Z', 36, 10) conv(71, 10, 36) conv('1Z', 36, 10)
1Z 71 1Z 71
SELECT conv(71, 10, 37), conv('1Z', 37, 10), conv(0,1,10),conv(0,0,10), conv(0,-1,10);
conv(71, 10, 37) conv('1Z', 37, 10) conv(0,1,10) conv(0,0,10) conv(0,-1,10)
NULL NULL NULL NULL NULL
create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8; create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb'); insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8; create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;

View File

@ -1,4 +1,5 @@
DROP TABLE IF EXISTS t0,t1,t2,t3,t5; DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
DROP VIEW IF EXISTS v1;
show variables where variable_name like "skip_show_database"; show variables where variable_name like "skip_show_database";
Variable_name Value Variable_name Value
skip_show_database OFF skip_show_database OFF
@ -638,8 +639,8 @@ use test;
create function sub1(i int) returns int create function sub1(i int) returns int
return i+1; return i+1;
create table t1(f1 int); create table t1(f1 int);
create view t2 (c) as select f1 from t1; create view v2 (c) as select f1 from t1;
create view t3 (c) as select sub1(1); create view v3 (c) as select sub1(1);
create table t4(f1 int, KEY f1_key (f1)); create table t4(f1 int, KEY f1_key (f1));
drop table t1; drop table t1;
drop function sub1; drop function sub1;
@ -647,29 +648,29 @@ select table_name from information_schema.views
where table_schema='test'; where table_schema='test';
table_name table_name
Warnings: Warnings:
Warning 1356 View 'test.t2' references invalid table(s) or column(s) or function(s) Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s)
Warning 1356 View 'test.t3' references invalid table(s) or column(s) or function(s) Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s)
select table_name from information_schema.views select table_name from information_schema.views
where table_schema='test'; where table_schema='test';
table_name table_name
Warnings: Warnings:
Warning 1356 View 'test.t2' references invalid table(s) or column(s) or function(s) Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s)
Warning 1356 View 'test.t3' references invalid table(s) or column(s) or function(s) Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s)
select column_name from information_schema.columns select column_name from information_schema.columns
where table_schema='test'; where table_schema='test';
column_name column_name
f1 f1
Warnings: Warnings:
Warning 1356 View 'test.t2' references invalid table(s) or column(s) or function(s) Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s)
Warning 1356 View 'test.t3' references invalid table(s) or column(s) or function(s) Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s)
select index_name from information_schema.statistics where table_schema='test'; select index_name from information_schema.statistics where table_schema='test';
index_name index_name
f1_key f1_key
select constraint_name from information_schema.table_constraints select constraint_name from information_schema.table_constraints
where table_schema='test'; where table_schema='test';
constraint_name constraint_name
drop view t2; drop view v2;
drop view t3; drop view v3;
drop table t4; drop table t4;
select * from information_schema.table_names; select * from information_schema.table_names;
ERROR 42S02: Unknown table 'table_names' in information_schema ERROR 42S02: Unknown table 'table_names' in information_schema

View File

@ -1,4 +1,4 @@
DROP TABLE IF EXISTS t1,t2; DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id, id), CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id, id),
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE, FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,

View File

@ -1,3 +1,4 @@
DROP TABLE IF EXISTS t1;
select 1; select 1;
1 1
1 1

View File

@ -1,6 +1,7 @@
drop table if exists t1; drop table if exists t1;
create table t1(a int); create table t1(a int);
insert into t1 values(1); insert into t1 values(1);
ERROR at line 9: DELIMITER must be followed by a 'delimiter' character or string
Test default delimiter ; Test default delimiter ;
a a

View File

@ -1828,31 +1828,32 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; /*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER //; DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="" */ // /*!50003 SET SESSION SQL_MODE="" */;;
/*!50003 CREATE TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW /*!50003 CREATE TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW
begin begin
if new.a > 10 then if new.a > 10 then
set new.a := 10; set new.a := 10;
set new.a := 11; set new.a := 11;
end if; end if;
end */ // end */;;
/*!50003 SET SESSION SQL_MODE="" */ // /*!50003 SET SESSION SQL_MODE="" */;;
/*!50003 CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1` FOR EACH ROW begin /*!50003 CREATE TRIGGER `trg2` BEFORE UPDATE ON `t1` FOR EACH ROW begin
if old.a % 2 = 0 then set new.b := 12; end if; if old.a % 2 = 0 then set new.b := 12; end if;
end */ // end */;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */ // /*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */;;
/*!50003 CREATE TRIGGER `trg3` AFTER UPDATE ON `t1` FOR EACH ROW /*!50003 CREATE TRIGGER `trg3` AFTER UPDATE ON `t1` FOR EACH ROW
begin begin
if new.a = -1 then if new.a = -1 then
set @fired:= "Yes"; set @fired:= "Yes";
end if; end if;
end */ // end */;;
DELIMITER ;// DELIMITER ;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;DROP TABLE IF EXISTS `t2`; /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`a` int(11) default NULL `a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@ -1864,17 +1865,18 @@ UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */; /*!40000 ALTER TABLE `t2` ENABLE KEYS */;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/; /*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER //; DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */ // /*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER" */;;
/*!50003 CREATE TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW /*!50003 CREATE TRIGGER `trg4` BEFORE INSERT ON `t2` FOR EACH ROW
begin begin
if new.a > 10 then if new.a > 10 then
set @fired:= "No"; set @fired:= "No";
end if; end if;
end */ // end */;;
DELIMITER ;// DELIMITER ;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */; /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
@ -2036,37 +2038,37 @@ LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1),(2),(3),(4),(5); INSERT INTO `t1` VALUES (1),(2),(3),(4),(5);
UNLOCK TABLES; UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DELIMITER // DELIMITER ;;
/*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */ // /*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */;;
/*!50003 SET SESSION SQL_MODE=""*/ // /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11) /*!50003 CREATE FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11)
RETURN a+b */ // RETURN a+b */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/ // /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */ // /*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */;;
/*!50003 SET SESSION SQL_MODE=""*/ // /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1) /*!50003 CREATE FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1)
begin begin
set f1= concat( 'hello', f1 ); set f1= concat( 'hello', f1 );
return f1; return f1;
end */ // end */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/ // /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `a'b` */ // /*!50003 DROP PROCEDURE IF EXISTS `a'b` */;;
/*!50003 SET SESSION SQL_MODE="REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI"*/ // /*!50003 SET SESSION SQL_MODE="REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI"*/;;
/*!50003 CREATE PROCEDURE "a'b"() /*!50003 CREATE PROCEDURE "a'b"()
select 1 */ // select 1 */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/ // /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc1` */ // /*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc1` */;;
/*!50003 SET SESSION SQL_MODE=""*/ // /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT) /*!50003 CREATE PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT)
BEGIN SELECT a+b INTO c; end */ // BEGIN SELECT a+b INTO c; end */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/ // /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc2` */ // /*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc2` */;;
/*!50003 SET SESSION SQL_MODE=""*/ // /*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE PROCEDURE `bug9056_proc2`(OUT a INT) /*!50003 CREATE PROCEDURE `bug9056_proc2`(OUT a INT)
BEGIN BEGIN
select sum(id) from t1 into a; select sum(id) from t1 into a;
END */ // END */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/ // /*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
DELIMITER ; DELIMITER ;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

View File

@ -1,3 +1,4 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (1),(2),(3);
CREATE TABLE t2 (a int, b int); CREATE TABLE t2 (a int, b int);

View File

@ -1,4 +1,5 @@
drop table if exists t1,t2; drop table if exists t1,t2;
drop view if exists v1;
CREATE TABLE t1 (c int not null, d char (10) not null); CREATE TABLE t1 (c int not null, d char (10) not null);
insert into t1 values(1,""),(2,"a"),(3,"b"); insert into t1 values(1,""),(2,"a"),(3,"b");
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null); CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
@ -99,32 +100,32 @@ Variable_name Value
Created_tmp_disk_tables 0 Created_tmp_disk_tables 0
Created_tmp_tables 2 Created_tmp_tables 2
drop table t1; drop table t1;
create temporary table t1 as select 'This is temp. table' A; create temporary table v1 as select 'This is temp. table' A;
create view t1 as select 'This is view' A; create view v1 as select 'This is view' A;
select * from t1; select * from v1;
A A
This is temp. table This is temp. table
show create table t1; show create table v1;
Table Create Table Table Create Table
t1 CREATE TEMPORARY TABLE `t1` ( v1 CREATE TEMPORARY TABLE `v1` (
`A` varchar(19) NOT NULL default '' `A` varchar(19) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
show create view t1; show create view v1;
View Create View View Create View
t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `t1` AS select _latin1'This is view' AS `A` v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'This is view' AS `A`
drop view t1; drop view v1;
select * from t1; select * from v1;
A A
This is temp. table This is temp. table
create view t1 as select 'This is view again' A; create view v1 as select 'This is view again' A;
select * from t1; select * from v1;
A A
This is temp. table This is temp. table
drop table t1; drop table v1;
select * from t1; select * from v1;
A A
This is view again This is view again
drop view t1; drop view v1;
create table t1 (a int, b int, index(a), index(b)); create table t1 (a int, b int, index(a), index(b));
create table t2 (c int auto_increment, d varchar(255), primary key (c)); create table t2 (c int auto_increment, d varchar(255), primary key (c));
insert into t1 values (3,1),(3,2); insert into t1 values (3,1),(3,2);

View File

@ -373,24 +373,24 @@ drop table t1;
# Bug#11493 - Alter table rename to default database does not work without # Bug#11493 - Alter table rename to default database does not work without
# db name qualifying # db name qualifying
# #
create database mysqltest1; create database mysqltest;
create table t1 (c1 int); create table t1 (c1 int);
# Move table to other database. # Move table to other database.
alter table t1 rename mysqltest1.t1; alter table t1 rename mysqltest.t1;
# Assure that it has moved. # Assure that it has moved.
--error 1051 --error 1051
drop table t1; drop table t1;
# Move table back. # Move table back.
alter table mysqltest1.t1 rename t1; alter table mysqltest.t1 rename t1;
# Assure that it is back. # Assure that it is back.
drop table t1; drop table t1;
# Now test for correct message if no database is selected. # Now test for correct message if no database is selected.
# Create t1 in 'test'. # Create t1 in 'test'.
create table t1 (c1 int); create table t1 (c1 int);
# Change to other db. # Change to other db.
use mysqltest1; use mysqltest;
# Drop the current db. This de-selects any db. # Drop the current db. This de-selects any db.
drop database mysqltest1; drop database mysqltest;
# Now test for correct message. # Now test for correct message.
--error 1046 --error 1046
alter table test.t1 rename t1; alter table test.t1 rename t1;

View File

@ -467,6 +467,7 @@ SELECT lpad(12345, 5, "#");
# #
SELECT conv(71, 10, 36), conv('1Z', 36, 10); SELECT conv(71, 10, 36), conv('1Z', 36, 10);
SELECT conv(71, 10, 37), conv('1Z', 37, 10), conv(0,1,10),conv(0,0,10), conv(0,-1,10);
# #
# Bug in SUBSTRING when mixed with CONCAT and ORDER BY (Bug #3089) # Bug in SUBSTRING when mixed with CONCAT and ORDER BY (Bug #3089)

View File

@ -5,7 +5,8 @@
# show databases # show databases
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t0,t1,t2,t3,t5; DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
DROP VIEW IF EXISTS v1;
--enable_warnings --enable_warnings
@ -364,8 +365,8 @@ use test;
create function sub1(i int) returns int create function sub1(i int) returns int
return i+1; return i+1;
create table t1(f1 int); create table t1(f1 int);
create view t2 (c) as select f1 from t1; create view v2 (c) as select f1 from t1;
create view t3 (c) as select sub1(1); create view v3 (c) as select sub1(1);
create table t4(f1 int, KEY f1_key (f1)); create table t4(f1 int, KEY f1_key (f1));
drop table t1; drop table t1;
drop function sub1; drop function sub1;
@ -378,8 +379,8 @@ where table_schema='test';
select index_name from information_schema.statistics where table_schema='test'; select index_name from information_schema.statistics where table_schema='test';
select constraint_name from information_schema.table_constraints select constraint_name from information_schema.table_constraints
where table_schema='test'; where table_schema='test';
drop view t2; drop view v2;
drop view t3; drop view v3;
drop table t4; drop table t4;
# #

View File

@ -1,6 +1,6 @@
-- source include/have_innodb.inc -- source include/have_innodb.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1,t2; DROP TABLE IF EXISTS t1,t2,t3;
--enable_warnings --enable_warnings
# #

View File

@ -1,6 +1,10 @@
# PS doesn't support multi-statements # PS doesn't support multi-statements
--disable_ps_protocol --disable_ps_protocol
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
select 1; select 1;
delimiter ||||; delimiter ||||;
select 2; select 2;

View File

@ -14,7 +14,7 @@ create table t1(a int);
insert into t1 values(1); insert into t1 values(1);
# Test delimiters # Test delimiters
--exec $MYSQL test < "./t/mysql_delimiter.sql" --exec $MYSQL test 2>&1 < "./t/mysql_delimiter.sql"
--disable_query_log --disable_query_log
# Test delimiter : supplied on the command line # Test delimiter : supplied on the command line

View File

@ -1,6 +1,10 @@
# Can't run test of external client with embedded server # Can't run test of external client with embedded server
-- source include/not_embedded.inc -- source include/not_embedded.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
# #
## Bug #5036 mysqlshow is missing a column ## Bug #5036 mysqlshow is missing a column
# #

View File

@ -4,6 +4,7 @@
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
drop view if exists v1;
--enable_warnings --enable_warnings
CREATE TABLE t1 (c int not null, d char (10) not null); CREATE TABLE t1 (c int not null, d char (10) not null);
@ -91,18 +92,18 @@ show status like "created_tmp%tables";
drop table t1; drop table t1;
# Fix for BUG#8921: Check that temporary table is ingored by view commands. # Fix for BUG#8921: Check that temporary table is ingored by view commands.
create temporary table t1 as select 'This is temp. table' A; create temporary table v1 as select 'This is temp. table' A;
create view t1 as select 'This is view' A; create view v1 as select 'This is view' A;
select * from t1; select * from v1;
show create table t1; show create table v1;
show create view t1; show create view v1;
drop view t1; drop view v1;
select * from t1; select * from v1;
create view t1 as select 'This is view again' A; create view v1 as select 'This is view again' A;
select * from t1; select * from v1;
drop table t1; drop table v1;
select * from t1; select * from v1;
drop view t1; drop view v1;
# Bug #8497: tmpdir with extra slashes would cause failures # Bug #8497: tmpdir with extra slashes would cause failures
# #

View File

@ -17,13 +17,12 @@
#include "mysys_priv.h" #include "mysys_priv.h"
#include <m_string.h> #include <m_string.h>
/* /*
Formats a filename with possible replace of directory of extension Formats a filename with possible replace of directory of extension
Function can handle the case where 'to' == 'name' Function can handle the case where 'to' == 'name'
For a description of the flag values, consult my_sys.h For a description of the flag values, consult my_sys.h
The arguments should be in unix format. The arguments should be in unix format.
*/ */
my_string fn_format(my_string to, const char *name, const char *dir, my_string fn_format(my_string to, const char *name, const char *dir,
const char *extension, uint flag) const char *extension, uint flag)
@ -54,8 +53,7 @@ my_string fn_format(my_string to, const char *name, const char *dir,
pack_dirname(dev,dev); /* Put in ./.. and ~/.. */ pack_dirname(dev,dev); /* Put in ./.. and ~/.. */
if (flag & MY_UNPACK_FILENAME) if (flag & MY_UNPACK_FILENAME)
(void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */ (void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */
if (flag & MY_UNIX_PATH)
to_unix_path(dev); /* Fix to MySQL representation */
if ((pos= (char*) strchr(name,FN_EXTCHAR)) != NullS) if ((pos= (char*) strchr(name,FN_EXTCHAR)) != NullS)
{ {
if ((flag & MY_REPLACE_EXT) == 0) /* If we should keep old ext */ if ((flag & MY_REPLACE_EXT) == 0) /* If we should keep old ext */

View File

@ -1315,7 +1315,6 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
query.append(FEDERATED_FROM); query.append(FEDERATED_FROM);
query.append(FEDERATED_BTICK); query.append(FEDERATED_BTICK);
if (!(share= (FEDERATED_SHARE *) if (!(share= (FEDERATED_SHARE *)
my_multi_malloc(MYF(MY_WME), my_multi_malloc(MYF(MY_WME),
&share, sizeof(*share), &share, sizeof(*share),

View File

@ -817,9 +817,12 @@ String *Item_splocal::val_str(String *sp)
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed);
Item *it= this_item(); Item *it= this_item();
String *ret= it->val_str(sp); String *res= it->val_str(sp);
null_value= it->null_value; null_value= it->null_value;
if (!res)
return NULL;
/* /*
This way we mark returned value of val_str as const, This way we mark returned value of val_str as const,
so that various functions (e.g. CONCAT) won't try to so that various functions (e.g. CONCAT) won't try to
@ -836,12 +839,11 @@ String *Item_splocal::val_str(String *sp)
Item_param class contain some more details on the topic. Item_param class contain some more details on the topic.
*/ */
if (!ret) if (res != &str_value)
return NULL; str_value.set(res->ptr(), res->length(), res->charset());
else
str_value_ptr.set(ret->ptr(), ret->length(), res->mark_as_const();
ret->charset()); return &str_value;
return &str_value_ptr;
} }
@ -858,17 +860,13 @@ my_decimal *Item_splocal::val_decimal(my_decimal *decimal_value)
bool Item_splocal::is_null() bool Item_splocal::is_null()
{ {
Item *it= this_item(); Item *it= this_item();
bool ret= it->is_null(); return it->is_null();
null_value= it->null_value;
return ret;
} }
Item * Item *
Item_splocal::this_item() Item_splocal::this_item()
{ {
THD *thd= current_thd;
return thd->spcont->get_item(m_offset); return thd->spcont->get_item(m_offset);
} }
@ -882,25 +880,23 @@ Item_splocal::this_item_addr(THD *thd, Item **addr)
Item * Item *
Item_splocal::this_const_item() const Item_splocal::this_const_item() const
{ {
THD *thd= current_thd;
return thd->spcont->get_item(m_offset); return thd->spcont->get_item(m_offset);
} }
Item::Type Item::Type
Item_splocal::type() const Item_splocal::type() const
{ {
THD *thd= current_thd; if (thd && thd->spcont)
if (thd->spcont)
return thd->spcont->get_item(m_offset)->type(); return thd->spcont->get_item(m_offset)->type();
return NULL_ITEM; // Anything but SUBSELECT_ITEM return NULL_ITEM; // Anything but SUBSELECT_ITEM
} }
bool Item_splocal::fix_fields(THD *, Item **) bool Item_splocal::fix_fields(THD *thd_arg, Item **ref)
{ {
Item *it= this_item(); Item *it;
thd= thd_arg; // Must be set before this_item()
it= this_item();
DBUG_ASSERT(it->fixed); DBUG_ASSERT(it->fixed);
max_length= it->max_length; max_length= it->max_length;
decimals= it->decimals; decimals= it->decimals;
@ -927,6 +923,7 @@ void Item_splocal::print(String *str)
/***************************************************************************** /*****************************************************************************
Item_name_const methods Item_name_const methods
*****************************************************************************/ *****************************************************************************/
double Item_name_const::val_real() double Item_name_const::val_real()
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed);
@ -965,9 +962,7 @@ my_decimal *Item_name_const::val_decimal(my_decimal *decimal_value)
bool Item_name_const::is_null() bool Item_name_const::is_null()
{ {
bool ret= value_item->is_null(); return value_item->is_null();
null_value= value_item->null_value;
return ret;
} }
Item::Type Item_name_const::type() const Item::Type Item_name_const::type() const
@ -976,7 +971,7 @@ Item::Type Item_name_const::type() const
} }
bool Item_name_const::fix_fields(THD *thd, Item **) bool Item_name_const::fix_fields(THD *thd, Item **ref)
{ {
char buf[128]; char buf[128];
String *item_name; String *item_name;
@ -2776,7 +2771,7 @@ int Item_copy_string::save_in_field(Field *field, bool no_conversions)
*/ */
/* ARGSUSED */ /* ARGSUSED */
bool Item::fix_fields(THD *thd, Item ** ref) bool Item::fix_fields(THD *thd, Item **ref)
{ {
// We do not check fields which are fixed during construction // We do not check fields which are fixed during construction
@ -4758,8 +4753,7 @@ String *Item_ref::val_str(String* tmp)
bool Item_ref::is_null() bool Item_ref::is_null()
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed);
(void) (*ref)->val_int_result(); return (*ref)->is_null();
return (*ref)->null_value;
} }

View File

@ -718,13 +718,7 @@ class Item_splocal : public Item
public: public:
LEX_STRING m_name; LEX_STRING m_name;
THD *thd;
/*
Buffer, pointing to the string value of the item. We need it to
protect internal buffer from changes. See comment to analogous
member in Item_param for more details.
*/
String str_value_ptr;
/* /*
Position of this reference to SP variable in the statement (the Position of this reference to SP variable in the statement (the
@ -736,10 +730,10 @@ public:
Value of 0 means that this object doesn't corresponding to reference to Value of 0 means that this object doesn't corresponding to reference to
SP variable in query text. SP variable in query text.
*/ */
int pos_in_query; uint pos_in_query;
Item_splocal(LEX_STRING name, uint offset, int pos_in_q=0) Item_splocal(LEX_STRING name, uint offset, uint pos_in_q=0)
: m_offset(offset), m_name(name), pos_in_query(pos_in_q) : m_offset(offset), m_name(name), thd(0), pos_in_query(pos_in_q)
{ {
maybe_null= TRUE; maybe_null= TRUE;
} }
@ -1502,6 +1496,7 @@ public:
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
int save_in_field(Field *field, bool no_conversions); int save_in_field(Field *field, bool no_conversions);
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum Item_result cast_to_int_type() const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
// to prevent drop fixed flag (no need parent cleanup call) // to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {} void cleanup() {}

View File

@ -2015,7 +2015,6 @@ String *Item_func_min_max::val_str(String *str)
{ {
String *res; String *res;
LINT_INIT(res); LINT_INIT(res);
null_value= 0;
for (uint i=0; i < arg_count ; i++) for (uint i=0; i < arg_count ; i++)
{ {
if (i == 0) if (i == 0)
@ -2030,14 +2029,11 @@ String *Item_func_min_max::val_str(String *str)
if ((cmp_sign < 0 ? cmp : -cmp) < 0) if ((cmp_sign < 0 ? cmp : -cmp) < 0)
res=res2; res=res2;
} }
else
res= 0;
} }
if ((null_value= args[i]->null_value)) if ((null_value= args[i]->null_value))
break; return 0;
} }
if (res) // If !NULL res->set_charset(collation.collation);
res->set_charset(collation.collation);
return res; return res;
} }
case ROW_RESULT: case ROW_RESULT:
@ -2054,7 +2050,6 @@ double Item_func_min_max::val_real()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
double value=0.0; double value=0.0;
null_value= 0;
for (uint i=0; i < arg_count ; i++) for (uint i=0; i < arg_count ; i++)
{ {
if (i == 0) if (i == 0)
@ -2076,7 +2071,6 @@ longlong Item_func_min_max::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
longlong value=0; longlong value=0;
null_value= 0;
for (uint i=0; i < arg_count ; i++) for (uint i=0; i < arg_count ; i++)
{ {
if (i == 0) if (i == 0)
@ -2097,21 +2091,21 @@ longlong Item_func_min_max::val_int()
my_decimal *Item_func_min_max::val_decimal(my_decimal *dec) my_decimal *Item_func_min_max::val_decimal(my_decimal *dec)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
my_decimal tmp_buf, *tmp, *res= NULL; my_decimal tmp_buf, *tmp, *res;
null_value= 0; LINT_INIT(res);
for (uint i=0; i < arg_count ; i++) for (uint i=0; i < arg_count ; i++)
{ {
if (i == 0) if (i == 0)
res= args[i]->val_decimal(dec); res= args[i]->val_decimal(dec);
else else
{ {
tmp= args[i]->val_decimal(&tmp_buf); tmp= args[i]->val_decimal(&tmp_buf); // Zero if NULL
if (args[i]->null_value) if (tmp && (my_decimal_cmp(tmp, res) * cmp_sign) < 0)
res= 0;
else if ((my_decimal_cmp(tmp, res) * cmp_sign) < 0)
{ {
if (tmp == &tmp_buf) if (tmp == &tmp_buf)
{ {
/* Move value out of tmp_buf as this will be reused on next loop */
my_decimal2decimal(tmp, dec); my_decimal2decimal(tmp, dec);
res= dec; res= dec;
} }
@ -2120,7 +2114,10 @@ my_decimal *Item_func_min_max::val_decimal(my_decimal *dec)
} }
} }
if ((null_value= args[i]->null_value)) if ((null_value= args[i]->null_value))
{
res= 0;
break; break;
}
} }
return res; return res;
} }

View File

@ -121,8 +121,9 @@ static char *pretty_print_str(char *packet, char *str, int len)
static inline char* slave_load_file_stem(char*buf, uint file_id, static inline char* slave_load_file_stem(char*buf, uint file_id,
int event_server_id) int event_server_id)
{ {
fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME);
MY_UNPACK_FILENAME | MY_UNIX_PATH); to_unix_path(buf);
buf = strend(buf); buf = strend(buf);
buf = int10_to_str(::server_id, buf, 10); buf = int10_to_str(::server_id, buf, 10);
*buf++ = '-'; *buf++ = '-';

View File

@ -7039,19 +7039,15 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/ */
if (thd->query_id == cur_field->query_id) if (thd->query_id == cur_field->query_id)
{ {
bool is_covered= FALSE;
KEY_PART_INFO *key_part= cur_index_info->key_part; KEY_PART_INFO *key_part= cur_index_info->key_part;
KEY_PART_INFO *key_part_end= key_part + cur_index_info->key_parts; KEY_PART_INFO *key_part_end= key_part + cur_index_info->key_parts;
for (; key_part != key_part_end ; key_part++) for (;;)
{ {
if (key_part->field == cur_field) if (key_part->field == cur_field)
{
is_covered= TRUE;
break; break;
} if (++key_part == key_part_end)
goto next_index; // Field was not part of key
} }
if (!is_covered)
goto next_index;
} }
} }
} }

View File

@ -779,6 +779,7 @@ static bool subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
splocal < sp_vars_uses.back(); splocal++) splocal < sp_vars_uses.back(); splocal++)
{ {
Item *val; Item *val;
(*splocal)->thd= thd; // fix_fields() is not yet done
/* append the text between sp ref occurences */ /* append the text between sp ref occurences */
res|= qbuf.append(cur + prev_pos, (*splocal)->pos_in_query - prev_pos); res|= qbuf.append(cur + prev_pos, (*splocal)->pos_in_query - prev_pos);
prev_pos= (*splocal)->pos_in_query + (*splocal)->m_name.length; prev_pos= (*splocal)->pos_in_query + (*splocal)->m_name.length;

View File

@ -1709,15 +1709,19 @@ Statement_map::Statement_map() :
int Statement_map::insert(Statement *statement) int Statement_map::insert(Statement *statement)
{ {
int rc= my_hash_insert(&st_hash, (byte *) statement); int res= my_hash_insert(&st_hash, (byte *) statement);
if (res)
return res;
if (statement->name.str) if (statement->name.str)
{ {
if ((rc= my_hash_insert(&names_hash, (byte*)statement))) if ((res= my_hash_insert(&names_hash, (byte*)statement)))
{
hash_delete(&st_hash, (byte*)statement); hash_delete(&st_hash, (byte*)statement);
return res;
}
} }
if (rc == 0) last_found_statement= statement;
last_found_statement= statement; return res;
return rc;
} }

View File

@ -4483,7 +4483,8 @@ end_with_restore_list:
command[thd->lex->create_view_mode].length); command[thd->lex->create_view_mode].length);
view_store_options(thd, first_table, &buff); view_store_options(thd, first_table, &buff);
buff.append("VIEW ", 5); buff.append("VIEW ", 5);
if (!first_table->current_db_used) /* Test if user supplied a db (ie: we did not use thd->db) */
if (first_table->db != thd->db && first_table->db[0])
{ {
append_identifier(thd, &buff, first_table->db, append_identifier(thd, &buff, first_table->db,
first_table->db_length); first_table->db_length);
@ -4808,7 +4809,6 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
bool db_is_pattern= test(want_access & GRANT_ACL); bool db_is_pattern= test(want_access & GRANT_ACL);
#endif #endif
ulong dummy; ulong dummy;
const char *db_name;
DBUG_ENTER("check_access"); DBUG_ENTER("check_access");
DBUG_PRINT("enter",("db: %s want_access: %lu master_access: %lu", DBUG_PRINT("enter",("db: %s want_access: %lu master_access: %lu",
db ? db : "", want_access, thd->master_access)); db ? db : "", want_access, thd->master_access));
@ -4826,11 +4826,11 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
DBUG_RETURN(TRUE); /* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */
} }
db_name= db ? db : thd->db;
if (schema_db) if (schema_db)
{ {
if (want_access & ~(SELECT_ACL | EXTRA_ACL)) if (want_access & ~(SELECT_ACL | EXTRA_ACL))
{ {
const char *db_name= db ? db : thd->db;
if (!no_errors) if (!no_errors)
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
thd->priv_user, thd->priv_host, db_name); thd->priv_user, thd->priv_host, db_name);
@ -6084,14 +6084,12 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
{ {
ptr->db= thd->db; ptr->db= thd->db;
ptr->db_length= thd->db_length; ptr->db_length= thd->db_length;
ptr->current_db_used= 1;
} }
else else
{ {
/* The following can't be "" as we may do 'casedn_str()' on it */ /* The following can't be "" as we may do 'casedn_str()' on it */
ptr->db= empty_c_string; ptr->db= empty_c_string;
ptr->db_length= 0; ptr->db_length= 0;
ptr->current_db_used= 1;
} }
if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute()) if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
ptr->db= thd->strdup(ptr->db); ptr->db= thd->strdup(ptr->db);
@ -7398,15 +7396,13 @@ bool default_view_definer(THD *thd, st_lex_user *definer)
{ {
definer->user.str= thd->priv_user; definer->user.str= thd->priv_user;
definer->user.length= strlen(thd->priv_user); definer->user.length= strlen(thd->priv_user);
if (*thd->priv_host != 0) if (!*thd->priv_host)
{
definer->host.str= thd->priv_host;
definer->host.length= strlen(thd->priv_host);
}
else
{ {
my_error(ER_NO_VIEW_USER, MYF(0)); my_error(ER_NO_VIEW_USER, MYF(0));
return TRUE; return TRUE;
} }
definer->host.str= thd->priv_host;
definer->host.length= strlen(thd->priv_host);
return FALSE; return FALSE;
} }

View File

@ -88,6 +88,11 @@ When one supplies long data for a placeholder:
class Prepared_statement: public Statement class Prepared_statement: public Statement
{ {
public: public:
enum flag_values
{
IS_IN_USE= 1
};
THD *thd; THD *thd;
Protocol *protocol; Protocol *protocol;
Item_param **param_array; Item_param **param_array;
@ -116,19 +121,8 @@ public:
bool execute(String *expanded_query, bool open_cursor); bool execute(String *expanded_query, bool open_cursor);
/* Destroy this statement */ /* Destroy this statement */
bool deallocate(); bool deallocate();
/* Possible values of flags */
#if defined(_MSC_VER) && _MSC_VER < 1300
static const int IS_IN_USE;
#else
static const int IS_IN_USE= 1;
#endif
}; };
/* VC6 can't handle initializing in declaration */
#if defined(_MSC_VER) && _MSC_VER < 1300
const int Prepared_statement::IS_IN_USE= 1;
#endif
/****************************************************************************** /******************************************************************************
Implementation Implementation
@ -1830,7 +1824,7 @@ static void cleanup_stmt_and_thd_after_use(Statement *stmt, THD *thd)
void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length) void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length)
{ {
Prepared_statement *stmt= new Prepared_statement(thd, &thd->protocol_prep); Prepared_statement *stmt= new Prepared_statement(thd, &thd->protocol_prep);
bool rc; bool error;
DBUG_ENTER("mysql_stmt_prepare"); DBUG_ENTER("mysql_stmt_prepare");
DBUG_PRINT("prep_query", ("%s", packet)); DBUG_PRINT("prep_query", ("%s", packet));
@ -1853,12 +1847,12 @@ void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length)
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),QUERY_PRIOR); my_pthread_setprio(pthread_self(),QUERY_PRIOR);
rc= stmt->prepare(packet, packet_length); error= stmt->prepare(packet, packet_length);
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),WAIT_PRIOR); my_pthread_setprio(pthread_self(),WAIT_PRIOR);
if (rc) if (error)
{ {
/* Statement map deletes statement on erase */ /* Statement map deletes statement on erase */
thd->stmt_map.erase(stmt); thd->stmt_map.erase(stmt);
@ -1900,7 +1894,7 @@ static const char *get_dynamic_sql_string(LEX *lex, uint *query_len)
CHARSET_INFO *to_cs= thd->variables.collation_connection; CHARSET_INFO *to_cs= thd->variables.collation_connection;
bool needs_conversion; bool needs_conversion;
user_var_entry *entry; user_var_entry *entry;
String *pstr= &str; String *var_value= &str;
uint32 unused, len; uint32 unused, len;
/* /*
Convert @var contents to string in connection character set. Although Convert @var contents to string in connection character set. Although
@ -1914,13 +1908,13 @@ static const char *get_dynamic_sql_string(LEX *lex, uint *query_len)
&& entry->value) && entry->value)
{ {
my_bool is_var_null; my_bool is_var_null;
pstr= entry->val_str(&is_var_null, &str, NOT_FIXED_DEC); var_value= entry->val_str(&is_var_null, &str, NOT_FIXED_DEC);
/* /*
NULL value of variable checked early as entry->value so here NULL value of variable checked early as entry->value so here
we can't get NULL in normal conditions we can't get NULL in normal conditions
*/ */
DBUG_ASSERT(!is_var_null); DBUG_ASSERT(!is_var_null);
if (!pstr) if (!var_value)
goto end; goto end;
} }
else else
@ -1932,22 +1926,25 @@ static const char *get_dynamic_sql_string(LEX *lex, uint *query_len)
str.set("NULL", 4, &my_charset_latin1); str.set("NULL", 4, &my_charset_latin1);
} }
needs_conversion= String::needs_conversion(pstr->length(), needs_conversion= String::needs_conversion(var_value->length(),
pstr->charset(), to_cs, &unused); var_value->charset(), to_cs,
&unused);
len= needs_conversion ? pstr->length() * to_cs->mbmaxlen : pstr->length(); len= (needs_conversion ? var_value->length() * to_cs->mbmaxlen :
var_value->length());
if (!(query_str= alloc_root(thd->mem_root, len+1))) if (!(query_str= alloc_root(thd->mem_root, len+1)))
goto end; goto end;
if (needs_conversion) if (needs_conversion)
{ {
uint dummy_errors; uint dummy_errors;
len= copy_and_convert(query_str, len, to_cs, pstr->ptr(), pstr->length(), len= copy_and_convert(query_str, len, to_cs, var_value->ptr(),
pstr->charset(), &dummy_errors); var_value->length(), var_value->charset(),
&dummy_errors);
} }
else else
memcpy(query_str, pstr->ptr(), pstr->length()); memcpy(query_str, var_value->ptr(), var_value->length());
query_str[len]= '\0'; query_str[len]= '\0'; // Safety (mostly for debug)
*query_len= len; *query_len= len;
} }
else else
@ -1997,10 +1994,9 @@ void mysql_sql_stmt_prepare(THD *thd)
Prepared_statement *stmt; Prepared_statement *stmt;
const char *query; const char *query;
uint query_len; uint query_len;
DBUG_ENTER("mysql_sql_stmt_prepare"); DBUG_ENTER("mysql_sql_stmt_prepare");
DBUG_ASSERT(thd->protocol == &thd->protocol_simple); DBUG_ASSERT(thd->protocol == &thd->protocol_simple);
if ((stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name))) if ((stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
{ {
/* /*
@ -2182,7 +2178,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
uchar *packet_end= (uchar *) packet + packet_length - 1; uchar *packet_end= (uchar *) packet + packet_length - 1;
#endif #endif
Prepared_statement *stmt; Prepared_statement *stmt;
bool rc; bool error;
DBUG_ENTER("mysql_stmt_execute"); DBUG_ENTER("mysql_stmt_execute");
packet+= 9; /* stmt_id + 5 bytes of flags */ packet+= 9; /* stmt_id + 5 bytes of flags */
@ -2217,11 +2213,11 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
#endif #endif
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),QUERY_PRIOR); my_pthread_setprio(pthread_self(),QUERY_PRIOR);
rc= stmt->execute(&expanded_query, error= stmt->execute(&expanded_query,
test(flags & (ulong) CURSOR_TYPE_READ_ONLY)); test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(), WAIT_PRIOR); my_pthread_setprio(pthread_self(), WAIT_PRIOR);
if (rc) if (error)
goto err; goto err;
mysql_log.write(thd, COM_STMT_EXECUTE, "[%lu] %s", stmt->id, thd->query); mysql_log.write(thd, COM_STMT_EXECUTE, "[%lu] %s", stmt->id, thd->query);
@ -2263,9 +2259,7 @@ void mysql_sql_stmt_execute(THD *thd)
LEX_STRING *name= &lex->prepared_stmt_name; LEX_STRING *name= &lex->prepared_stmt_name;
/* Query text for binary, general or slow log, if any of them is open */ /* Query text for binary, general or slow log, if any of them is open */
String expanded_query; String expanded_query;
DBUG_ENTER("mysql_sql_stmt_execute"); DBUG_ENTER("mysql_sql_stmt_execute");
DBUG_PRINT("info", ("EXECUTE: %.*s\n", name->length, name->str)); DBUG_PRINT("info", ("EXECUTE: %.*s\n", name->length, name->str));
if (!(stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name))) if (!(stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
@ -2412,7 +2406,6 @@ void mysql_stmt_close(THD *thd, char *packet)
/* There is always space for 4 bytes in packet buffer */ /* There is always space for 4 bytes in packet buffer */
ulong stmt_id= uint4korr(packet); ulong stmt_id= uint4korr(packet);
Prepared_statement *stmt; Prepared_statement *stmt;
DBUG_ENTER("mysql_stmt_close"); DBUG_ENTER("mysql_stmt_close");
if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_close"))) if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_close")))
@ -2422,7 +2415,7 @@ void mysql_stmt_close(THD *thd, char *packet)
The only way currently a statement can be deallocated when it's The only way currently a statement can be deallocated when it's
in use is from within Dynamic SQL. in use is from within Dynamic SQL.
*/ */
DBUG_ASSERT(! (stmt->flags & Prepared_statement::IS_IN_USE)); DBUG_ASSERT(! (stmt->flags & (uint) Prepared_statement::IS_IN_USE));
(void) stmt->deallocate(); (void) stmt->deallocate();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -2466,7 +2459,7 @@ void mysql_sql_stmt_close(THD *thd)
mysql_stmt_get_longdata() mysql_stmt_get_longdata()
thd Thread handle thd Thread handle
packet String to append packet String to append
packet_length Length of string packet_length Length of string (including end \0)
DESCRIPTION DESCRIPTION
Get a part of a long data. To make the protocol efficient, we are Get a part of a long data. To make the protocol efficient, we are
@ -2483,13 +2476,12 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length)
Prepared_statement *stmt; Prepared_statement *stmt;
Item_param *param; Item_param *param;
char *packet_end= packet + packet_length - 1; char *packet_end= packet + packet_length - 1;
DBUG_ENTER("mysql_stmt_get_longdata"); DBUG_ENTER("mysql_stmt_get_longdata");
statistic_increment(thd->status_var.com_stmt_send_long_data, &LOCK_status); statistic_increment(thd->status_var.com_stmt_send_long_data, &LOCK_status);
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
/* Minimal size of long data packet is 6 bytes */ /* Minimal size of long data packet is 6 bytes */
if ((ulong) (packet_end - packet) < MYSQL_LONG_DATA_HEADER) if (packet_length <= MYSQL_LONG_DATA_HEADER)
{ {
my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_send_long_data"); my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_send_long_data");
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -2542,7 +2534,7 @@ Prepared_statement::Prepared_statement(THD *thd_arg, Protocol *protocol_arg)
param_array(0), param_array(0),
param_count(0), param_count(0),
last_errno(0), last_errno(0),
flags(IS_IN_USE) flags((uint) IS_IN_USE)
{ {
*last_error= '\0'; *last_error= '\0';
} }
@ -2676,7 +2668,7 @@ bool Prepared_statement::set_name(LEX_STRING *name_arg)
bool Prepared_statement::prepare(const char *packet, uint packet_len) bool Prepared_statement::prepare(const char *packet, uint packet_len)
{ {
bool rc; bool error;
Statement stmt_backup; Statement stmt_backup;
Query_arena *old_stmt_arena; Query_arena *old_stmt_arena;
DBUG_ENTER("Prepared_statement::prepare"); DBUG_ENTER("Prepared_statement::prepare");
@ -2707,7 +2699,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
lex->safe_to_cache_query= FALSE; lex->safe_to_cache_query= FALSE;
lex->stmt_prepare_mode= TRUE; lex->stmt_prepare_mode= TRUE;
rc= yyparse((void *)thd) || thd->is_fatal_error || error= yyparse((void *)thd) || thd->is_fatal_error ||
thd->net.report_error || init_param_array(this); thd->net.report_error || init_param_array(this);
/* /*
While doing context analysis of the query (in check_prepared_statement) While doing context analysis of the query (in check_prepared_statement)
@ -2731,10 +2723,10 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
*/ */
DBUG_ASSERT(thd->free_list == NULL); DBUG_ASSERT(thd->free_list == NULL);
if (rc == 0) if (error == 0)
rc= check_prepared_statement(this, name.str != 0); error= check_prepared_statement(this, name.str != 0);
if (rc && thd->lex->sphead) if (error && thd->lex->sphead)
{ {
delete thd->lex->sphead; delete thd->lex->sphead;
thd->lex->sphead= NULL; thd->lex->sphead= NULL;
@ -2745,14 +2737,14 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
thd->restore_backup_statement(this, &stmt_backup); thd->restore_backup_statement(this, &stmt_backup);
thd->stmt_arena= old_stmt_arena; thd->stmt_arena= old_stmt_arena;
if (rc == 0) if (error == 0)
{ {
setup_set_params(); setup_set_params();
init_stmt_after_parse(lex); init_stmt_after_parse(lex);
state= Query_arena::PREPARED; state= Query_arena::PREPARED;
flags&= ~IS_IN_USE; flags&= ~ (uint) IS_IN_USE;
} }
DBUG_RETURN(rc); DBUG_RETURN(error);
} }
/* /*
@ -2774,6 +2766,10 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
Preconditions, postconditions. Preconditions, postconditions.
------------------------------ ------------------------------
See the comment for Prepared_statement::prepare(). See the comment for Prepared_statement::prepare().
RETURN
FALSE ok
TRUE Error
*/ */
bool Prepared_statement::execute(String *expanded_query, bool open_cursor) bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
@ -2781,7 +2777,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
Statement stmt_backup; Statement stmt_backup;
Query_arena *old_stmt_arena; Query_arena *old_stmt_arena;
Item *old_free_list; Item *old_free_list;
bool rc= 1; bool error= TRUE;
statistic_increment(thd->status_var.com_stmt_execute, &LOCK_status); statistic_increment(thd->status_var.com_stmt_execute, &LOCK_status);
@ -2791,13 +2787,11 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
my_message(last_errno, last_error, MYF(0)); my_message(last_errno, last_error, MYF(0));
return 1; return 1;
} }
if (flags & IS_IN_USE) if (flags & (uint) IS_IN_USE)
{ {
my_error(ER_PS_NO_RECURSION, MYF(0)); my_error(ER_PS_NO_RECURSION, MYF(0));
return 1; return 1;
} }
/* In case the command has a call to SP which re-uses this statement name */
flags|= IS_IN_USE;
if (cursor && cursor->is_open()) if (cursor && cursor->is_open())
close_cursor(); close_cursor();
@ -2891,11 +2885,11 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
if (state == Query_arena::PREPARED) if (state == Query_arena::PREPARED)
state= Query_arena::EXECUTED; state= Query_arena::EXECUTED;
rc= 0; error= FALSE;
error: error:
thd->lock_id= &thd->main_lock_id; thd->lock_id= &thd->main_lock_id;
flags&= ~IS_IN_USE; flags&= ~ (uint) IS_IN_USE;
return rc; return error;
} }
@ -2905,7 +2899,7 @@ bool Prepared_statement::deallocate()
{ {
/* We account deallocate in the same manner as mysql_stmt_close */ /* We account deallocate in the same manner as mysql_stmt_close */
statistic_increment(thd->status_var.com_stmt_close, &LOCK_status); statistic_increment(thd->status_var.com_stmt_close, &LOCK_status);
if (flags & IS_IN_USE) if (flags & (uint) IS_IN_USE)
{ {
my_error(ER_PS_NO_RECURSION, MYF(0)); my_error(ER_PS_NO_RECURSION, MYF(0));
return TRUE; return TRUE;

View File

@ -20,7 +20,7 @@
struct st_table; struct st_table;
class Field; class Field;
#define STRING_WITH_LEN(X) X, (sizeof(X)-1) #define STRING_WITH_LEN(X) ((char*) X), (sizeof(X)-1)
typedef struct st_lex_string typedef struct st_lex_string
{ {

View File

@ -287,7 +287,8 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
keynames=(char*) key_part; keynames=(char*) key_part;
strpos+= (strmov(keynames, (char *) strpos) - keynames)+1; strpos+= (strmov(keynames, (char *) strpos) - keynames)+1;
share->null_bytes= null_pos - (uchar*) outparam->null_flags + (null_bit_pos + 7) / 8; share->null_bytes= ((uint) (null_pos - (uchar*) outparam->null_flags) +
(null_bit_pos + 7) / 8);
share->reclength = uint2korr((head+16)); share->reclength = uint2korr((head+16));
if (*(head+26) == 1) if (*(head+26) == 1)

View File

@ -582,8 +582,6 @@ typedef struct st_table_list
bool compact_view_format; /* Use compact format for SHOW CREATE VIEW */ bool compact_view_format; /* Use compact format for SHOW CREATE VIEW */
/* view where processed */ /* view where processed */
bool where_processed; bool where_processed;
/* db part was not defined in table definition */
bool current_db_used;
/* FRMTYPE_ERROR if any type is acceptable */ /* FRMTYPE_ERROR if any type is acceptable */
enum frm_type_enum required_type; enum frm_type_enum required_type;
char timestamp_buffer[20]; /* buffer for timestamp (19+1) */ char timestamp_buffer[20]; /* buffer for timestamp (19+1) */

View File

@ -2018,7 +2018,7 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to)
if (to->buf < buf1) if (to->buf < buf1)
{ {
dec1 *cur_d= to->buf; dec1 *cur_d= to->buf;
for (; d_to_move; d_to_move--, cur_d++, buf1++) for (; d_to_move--; cur_d++, buf1++)
*cur_d= *buf1; *cur_d= *buf1;
} }
return error; return error;

View File

@ -26,95 +26,88 @@
.type longlong2str_with_dig_vector,@function .type longlong2str_with_dig_vector,@function
longlong2str_with_dig_vector: longlong2str_with_dig_vector:
subl $80,%esp subl $80,%esp # Temporary buffer for up to 64 radix-2 digits
pushl %ebp pushl %ebp
pushl %esi pushl %esi
pushl %edi pushl %edi
pushl %ebx pushl %ebx
movl 100(%esp),%esi # Lower part of val movl 100(%esp),%esi # esi = Lower part of val
movl 112(%esp),%ebx # Radix movl 112(%esp),%ebx # ebx = Radix
movl 104(%esp),%ebp # Higher part of val movl 104(%esp),%ebp # ebp = Higher part of val
movl %ebx,%eax movl 108(%esp),%edi # edi = dst
movl 108(%esp),%edi # get dst
testl %eax,%eax
jge .L144
addl $36,%eax testl %ebx,%ebx
cmpl $34,%eax jge .L144 # Radix was positive
ja .Lerror # Wrong radix negl %ebx # Change radix to positive
testl %ebp,%ebp testl %ebp,%ebp # Test if given value is negative
jge .L146 jge .L144
movb $45,(%edi) # Add sign movb $45,(%edi) # Add sign
incl %edi # Change sign of val incl %edi # Change sign of val
negl %esi negl %esi
adcl $0,%ebp adcl $0,%ebp
negl %ebp negl %ebp
.L146:
negl %ebx # Change radix to positive .L144: # Test that radix is between 2 and 36
jmp .L148 movl %ebx, %eax
.align 4 addl $-2,%eax # Test that radix is between 2 and 36
.L144:
addl $-2,%eax
cmpl $34,%eax cmpl $34,%eax
ja .Lerror # Radix in range ja .Lerror # Radix was not in range
.L148:
movl %esi,%eax # Test if zero (for easy loop)
orl %ebp,%eax
jne .L150
movb $48,(%edi)
incl %edi
jmp .L10_end
.align 4
.L150:
leal 92(%esp),%ecx # End of buffer leal 92(%esp),%ecx # End of buffer
movl %edi, 108(%esp) # Store possible modified dest movl %edi, 108(%esp) # Store possible modified dest
movl 116(%esp), %edi # dig_vec_upper movl 116(%esp), %edi # dig_vec_upper
jmp .L155 testl %ebp,%ebp # Test if value > 0xFFFFFFFF
.align 4 jne .Llongdiv
cmpl %ebx, %esi # Test if <= radix, for easy loop
movl %esi, %eax # Value in eax (for Llow)
jae .Llow
.L153: # Value is one digit (negative or positive)
# val is stored in in ebp:esi movb (%eax,%edi),%bl
movl 108(%esp),%edi # get dst
movb %bl,(%edi)
incl %edi # End null here
jmp .L10_end
movl %ebp,%eax # High part of value .Llongdiv:
# Value in ebp:esi. div the high part by the radix,
# then div remainder + low part by the radix.
movl %ebp,%eax # edx=0,eax=high(from ebp)
xorl %edx,%edx xorl %edx,%edx
decl %ecx
divl %ebx divl %ebx
movl %eax,%ebp movl %eax,%ebp # edx=result of last, eax=low(from esi)
movl %esi,%eax movl %esi,%eax
divl %ebx divl %ebx
decl %ecx movl %eax,%esi # ebp:esi = quotient
movl %eax,%esi # quotent in ebp:esi movb (%edx,%edi),%dl # Store result number in temporary buffer
movb (%edx,%edi),%al # al is faster than dl
movb %al,(%ecx) # store value in buff
.align 4
.L155:
testl %ebp,%ebp testl %ebp,%ebp
ja .L153 movb %dl,(%ecx) # store value in buff
testl %esi,%esi # rest value ja .Llongdiv # (Higher part of val still > 0)
jl .L153
je .L160 # Ready
movl %esi,%eax
.align 4 .align 4
.Llow: # Do rest with integer precision
.L154: # Do rest with integer precision # Value in 0:eax. div 0 + low part by the radix.
cltd xorl %edx,%edx
divl %ebx
decl %ecx decl %ecx
divl %ebx
movb (%edx,%edi),%dl # bh is always zero as ebx=radix < 36 movb (%edx,%edi),%dl # bh is always zero as ebx=radix < 36
testl %eax,%eax testl %eax,%eax
movb %dl,(%ecx) movb %dl,(%ecx)
jne .L154 jne .Llow
.L160: .L160:
movl 108(%esp),%edi # get dst movl 108(%esp),%edi # get dst
.L10_mov: .Lcopy_end:
movl %ecx,%esi leal 92(%esp),%esi # End of buffer
leal 92(%esp),%ecx # End of buffer .Lmov: # mov temporary buffer to result (%ecx -> %edi)
subl %esi,%ecx movb (%ecx), %al
rep movb %al, (%edi)
movsb incl %ecx
incl %edi
cmpl %ecx,%esi
jne .Lmov
.L10_end: .L10_end:
movl %edi,%eax # Pointer to end null movl %edi,%eax # Pointer to end null
@ -166,21 +159,23 @@ longlong10_to_str:
negl %esi # Change sign of val (ebp:esi) negl %esi # Change sign of val (ebp:esi)
adcl $0,%ebp adcl $0,%ebp
negl %ebp negl %ebp
.align 4
.L10_10: .L10_10:
leal 92(%esp),%ecx # End of buffer leal 92(%esp),%ecx # End of buffer
movl %esi,%eax # Test if zero (for easy loop) testl %ebp,%ebp # Test if value > 0xFFFFFFFF
orl %ebp,%eax jne .L10_longdiv
jne .L10_30 # Not zero cmpl $10, %esi # Test if <= radix, for easy loop
movl %esi, %ebx # Value in eax (for L10_low)
jae .L10_low
# Here when value is zero # Value is one digit (negative or positive)
movb $48,(%edi) addb $48, %bl
movb %bl,(%edi)
incl %edi incl %edi
jmp .L10_end jmp .L10_end
.align 4 .align 4
.L10_20: .L10_longdiv:
# val is stored in in ebp:esi # val is stored in in ebp:esi
movl %ebp,%eax # High part of value movl %ebp,%eax # High part of value
xorl %edx,%edx xorl %edx,%edx
@ -195,17 +190,15 @@ longlong10_to_str:
.L10_30: .L10_30:
testl %ebp,%ebp testl %ebp,%ebp
ja .L10_20 ja .L10_longdiv
testl %esi,%esi # rest value
jl .L10_20 # Unsigned, do ulonglong div once more
je .L10_mov # Ready
movl %esi,%ebx # Move val to %ebx movl %esi,%ebx # Move val to %ebx
.L10_low:
# The following code uses some tricks to change division by 10 to # The following code uses some tricks to change division by 10 to
# multiplication and shifts # multiplication and shifts
movl $0xcccccccd,%esi movl $0xcccccccd,%esi
.L10_40: .L10_40: # Divide %ebx with 10
movl %ebx,%eax movl %ebx,%eax
mull %esi mull %esi
decl %ecx decl %ecx
@ -218,7 +211,7 @@ longlong10_to_str:
movl %edx,%ebx movl %edx,%ebx
testl %ebx,%ebx testl %ebx,%ebx
jne .L10_40 jne .L10_40
jmp .L10_mov # Shared end with longlong10_to_str jmp .Lcopy_end # Shared end with longlong2str
.L10end: .L10end:
.size longlong10_to_str,.L10end-longlong10_to_str .size longlong10_to_str,.L10end-longlong10_to_str

View File

@ -21,8 +21,8 @@
#undef ULONGLONG_MAX #undef ULONGLONG_MAX
/* Needed under MetroWerks Compiler, since MetroWerks compiler does not properly handle a constant expression containing a mod operator */ /* Needed under MetroWerks Compiler, since MetroWerks compiler does not properly handle a constant expression containing a mod operator */
#if defined(__NETWARE__) && defined(__MWERKS__) #if defined(__NETWARE__) && defined(__MWERKS__)
ulonglong tmp; static ulonglong ulonglong_max= ~(ulonglong) 0;
#define ULONGLONG_MAX (tmp =(~(ulonglong) 0)) #define ULONGLONG_MAX ulonglong_max
#else #else
#define ULONGLONG_MAX (~(ulonglong) 0) #define ULONGLONG_MAX (~(ulonglong) 0)
#endif /* __NETWARE__ && __MWERKS__ */ #endif /* __NETWARE__ && __MWERKS__ */