1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-05 13:16:09 +03:00

Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.1

into  eel.(none):/home/jonas/src/mysql-5.1-push


storage/ndb/tools/Makefile.am:
  Auto merged
storage/ndb/tools/ndb_condig.cpp:
  Auto merged
This commit is contained in:
unknown
2005-09-07 14:53:59 +02:00
32 changed files with 536 additions and 275 deletions

View File

@@ -481,9 +481,10 @@ my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
static void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, static void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
int len); int len);
static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val); static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
static int normal_handle_error(const char *query, struct st_query *q, static int handle_error(const char *query, struct st_query *q,
MYSQL *mysql, DYNAMIC_STRING *ds); unsigned int err_errno, const char *err_error,
static int normal_handle_no_error(struct st_query *q); const char *err_sqlstate, DYNAMIC_STRING *ds);
static int handle_no_error(struct st_query *q);
static void do_eval(DYNAMIC_STRING* query_eval, const char *query) static void do_eval(DYNAMIC_STRING* query_eval, const char *query)
{ {
@@ -2071,11 +2072,12 @@ int connect_n_handle_errors(struct st_query *q, MYSQL* con, const char* host,
if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0, if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
CLIENT_MULTI_STATEMENTS)) CLIENT_MULTI_STATEMENTS))
{ {
error= normal_handle_error("connect", q, con, ds); error= handle_error("connect", q, mysql_errno(con), mysql_error(con),
mysql_sqlstate(con), ds);
*create_conn= 0; *create_conn= 0;
goto err; goto err;
} }
else if (normal_handle_no_error(q)) else if (handle_no_error(q))
{ {
/* /*
Fail if there was no error but we expected it. Fail if there was no error but we expected it.
@@ -2380,8 +2382,10 @@ int read_line(char *buf, int size)
if (feof(cur_file->file)) if (feof(cur_file->file))
{ {
found_eof: found_eof:
if (cur_file->file != stdin) if (cur_file->file != stdin){
my_fclose(cur_file->file, MYF(0)); my_fclose(cur_file->file, MYF(0));
cur_file->file= 0;
}
my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
cur_file->file_name= 0; cur_file->file_name= 0;
lineno--; lineno--;
@@ -2755,10 +2759,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
argument= buff; argument= buff;
} }
fn_format(buff, argument, "", "", 4); fn_format(buff, argument, "", "", 4);
DBUG_ASSERT(cur_file->file == 0); DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
if (!(cur_file->file= if (!(cur_file->file=
my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME)))) my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
die("Could not open %s: errno = %d", argument, errno); die("Could not open %s: errno = %d", buff, errno);
cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
break; break;
} }
case 'm': case 'm':
@@ -2961,8 +2966,6 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res)
static int run_query_normal(MYSQL *mysql, struct st_query *q, int flags); static int run_query_normal(MYSQL *mysql, struct st_query *q, int flags);
static int run_query_stmt (MYSQL *mysql, struct st_query *q, int flags); static int run_query_stmt (MYSQL *mysql, struct st_query *q, int flags);
static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds); static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds);
static int run_query_stmt_handle_error(char *query, struct st_query *q,
MYSQL_STMT *stmt, DYNAMIC_STRING *ds);
static void run_query_display_metadata(MYSQL_FIELD *field, uint num_fields, static void run_query_display_metadata(MYSQL_FIELD *field, uint num_fields,
DYNAMIC_STRING *ds); DYNAMIC_STRING *ds);
@@ -3046,12 +3049,13 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags)
(!(last_result= res= mysql_store_result(mysql)) && (!(last_result= res= mysql_store_result(mysql)) &&
mysql_field_count(mysql))) mysql_field_count(mysql)))
{ {
if (normal_handle_error(query, q, mysql, ds)) if (handle_error(query, q, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), ds))
error= 1; error= 1;
goto end; goto end;
} }
if (normal_handle_no_error(q)) if (handle_no_error(q))
{ {
error= 1; error= 1;
goto end; goto end;
@@ -3166,14 +3170,15 @@ end:
/* /*
Handle errors which occurred after execution of conventional (non-prepared) Handle errors which occurred after execution
statement.
SYNOPSIS SYNOPSIS
normal_handle_error() handle_error()
query - query string query - query string
q - query context q - query context
mysql - connection through which query was sent to server err_errno - error number
err_error - error message
err_sqlstate - sql state
ds - dynamic string which is used for output buffer ds - dynamic string which is used for output buffer
NOTE NOTE
@@ -3185,35 +3190,35 @@ end:
1 - Some other error was expected. 1 - Some other error was expected.
*/ */
static int normal_handle_error(const char *query, struct st_query *q, static int handle_error(const char *query, struct st_query *q,
MYSQL *mysql, DYNAMIC_STRING *ds) unsigned int err_errno, const char *err_error,
const char* err_sqlstate, DYNAMIC_STRING *ds)
{ {
uint i; uint i;
DBUG_ENTER("normal_handle_error"); DBUG_ENTER("handle_error");
if (q->require_file) if (q->require_file)
abort_not_supported_test(); abort_not_supported_test();
if (q->abort_on_error) if (q->abort_on_error)
die("query '%s' failed: %d: %s", query, die("query '%s' failed: %d: %s", query,
mysql_errno(mysql), mysql_error(mysql)); err_errno, err_error);
else
{
for (i= 0 ; (uint) i < q->expected_errors ; i++) for (i= 0 ; (uint) i < q->expected_errors ; i++)
{ {
if (((q->expected_errno[i].type == ERR_ERRNO) && if (((q->expected_errno[i].type == ERR_ERRNO) &&
(q->expected_errno[i].code.errnum == mysql_errno(mysql))) || (q->expected_errno[i].code.errnum == err_errno)) ||
((q->expected_errno[i].type == ERR_SQLSTATE) && ((q->expected_errno[i].type == ERR_SQLSTATE) &&
(strcmp(q->expected_errno[i].code.sqlstate, mysql_sqlstate(mysql)) == 0))) (strcmp(q->expected_errno[i].code.sqlstate, err_sqlstate) == 0)))
{ {
if (q->expected_errors == 1) if (q->expected_errors == 1)
{ {
/* Only log error if there is one possible error */ /* Only log error if there is one possible error */
dynstr_append_mem(ds, "ERROR ", 6); dynstr_append_mem(ds, "ERROR ", 6);
replace_dynstr_append(ds, mysql_sqlstate(mysql)); replace_dynstr_append(ds, err_sqlstate);
dynstr_append_mem(ds, ": ", 2); dynstr_append_mem(ds, ": ", 2);
replace_dynstr_append(ds, mysql_error(mysql)); replace_dynstr_append(ds, err_error);
dynstr_append_mem(ds,"\n",1); dynstr_append_mem(ds,"\n",1);
} }
/* Don't log error if we may not get an error */ /* Don't log error if we may not get an error */
@@ -3229,20 +3234,20 @@ static int normal_handle_error(const char *query, struct st_query *q,
DBUG_PRINT("info",("i: %d expected_errors: %d", i, q->expected_errors)); DBUG_PRINT("info",("i: %d expected_errors: %d", i, q->expected_errors));
dynstr_append_mem(ds, "ERROR ",6); dynstr_append_mem(ds, "ERROR ",6);
replace_dynstr_append(ds, mysql_sqlstate(mysql)); replace_dynstr_append(ds, err_sqlstate);
dynstr_append_mem(ds, ": ", 2); dynstr_append_mem(ds, ": ", 2);
replace_dynstr_append(ds, mysql_error(mysql)); replace_dynstr_append(ds, err_error);
dynstr_append_mem(ds, "\n", 1); dynstr_append_mem(ds, "\n", 1);
if (i) if (i)
{ {
if (q->expected_errno[0].type == ERR_ERRNO) if (q->expected_errno[0].type == ERR_ERRNO)
verbose_msg("query '%s' failed with wrong errno %d instead of %d...", verbose_msg("query '%s' failed with wrong errno %d instead of %d...",
q->query, mysql_errno(mysql), q->query, err_errno,
q->expected_errno[0].code.errnum); q->expected_errno[0].code.errnum);
else else
verbose_msg("query '%s' failed with wrong sqlstate %s instead of %s...", verbose_msg("query '%s' failed with wrong sqlstate %s instead of %s...",
q->query, mysql_sqlstate(mysql), q->query, err_sqlstate,
q->expected_errno[0].code.sqlstate); q->expected_errno[0].code.sqlstate);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@@ -3251,19 +3256,17 @@ static int normal_handle_error(const char *query, struct st_query *q,
If we do not abort on error, failure to run the query does not fail the If we do not abort on error, failure to run the query does not fail the
whole test case. whole test case.
*/ */
verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql), verbose_msg("query '%s' failed: %d: %s", q->query, err_errno,
mysql_error(mysql)); err_error);
DBUG_RETURN(0); DBUG_RETURN(0);
}
return 0; /* Keep compiler happy */
} }
/* /*
Handle absence of errors after execution of convetional statement. Handle absence of errors after execution
SYNOPSIS SYNOPSIS
normal_handle_error() handle_no_error()
q - context of query q - context of query
RETURN VALUE RETURN VALUE
@@ -3271,9 +3274,9 @@ static int normal_handle_error(const char *query, struct st_query *q,
1 - Some error was expected from this query. 1 - Some error was expected from this query.
*/ */
static int normal_handle_no_error(struct st_query *q) static int handle_no_error(struct st_query *q)
{ {
DBUG_ENTER("normal_handle_no_error"); DBUG_ENTER("handle_no_error");
if (q->expected_errno[0].type == ERR_ERRNO && if (q->expected_errno[0].type == ERR_ERRNO &&
q->expected_errno[0].code.errnum != 0) q->expected_errno[0].code.errnum != 0)
@@ -3367,17 +3370,17 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
{ {
if (q->abort_on_error) if (q->abort_on_error)
{ {
die("unable to prepare statement '%s': " die("query '%s' failed: %d: %s", query,
"%s (mysql_stmt_errno=%d returned=%d)", mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
query,
mysql_stmt_error(stmt), mysql_stmt_errno(stmt), err);
} }
else else
{ {
/* /*
Preparing is part of normal execution and some errors may be expected Preparing is part of normal execution and some errors may be expected
*/ */
error= run_query_stmt_handle_error(query, q, stmt, ds); error= handle_error(query, q, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
ds);
goto end; goto end;
} }
} }
@@ -3410,7 +3413,9 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
else else
{ {
/* We got an error, maybe expected */ /* We got an error, maybe expected */
error= run_query_stmt_handle_error(query, q, stmt, ds); error= handle_error(query, q, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
ds);
goto end; goto end;
} }
} }
@@ -3446,18 +3451,16 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags)
else else
{ {
/* We got an error, maybe expected */ /* We got an error, maybe expected */
error= run_query_stmt_handle_error(query, q, stmt, ds); error= handle_error(query, q, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt),
ds);
goto end; goto end;
} }
} }
/* If we got here the statement was both executed and read succeesfully */ /* If we got here the statement was both executed and read succeesfully */
if (handle_no_error(q))
if (q->expected_errno[0].type == ERR_ERRNO &&
q->expected_errno[0].code.errnum != 0)
{ {
verbose_msg("query '%s' succeeded - should have failed with errno %d...",
q->query, q->expected_errno[0].code.errnum);
error= 1; error= 1;
goto end; goto end;
} }
@@ -3737,71 +3740,6 @@ static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds)
} }
static int run_query_stmt_handle_error(char *query, struct st_query *q,
MYSQL_STMT *stmt, DYNAMIC_STRING *ds)
{
if (q->require_file) /* FIXME don't understand this one */
{
abort_not_supported_test();
}
if (q->abort_on_error)
die("query '%s' failed: %d: %s", query,
mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
else
{
int i;
for (i=0 ; (uint) i < q->expected_errors ; i++)
{
if (((q->expected_errno[i].type == ERR_ERRNO) &&
(q->expected_errno[i].code.errnum == mysql_stmt_errno(stmt))) ||
((q->expected_errno[i].type == ERR_SQLSTATE) &&
(strcmp(q->expected_errno[i].code.sqlstate,
mysql_stmt_sqlstate(stmt)) == 0)))
{
if (i == 0 && q->expected_errors == 1)
{
/* Only log error if there is one possible error */
dynstr_append_mem(ds,"ERROR ",6);
replace_dynstr_append(ds, mysql_stmt_sqlstate(stmt));
dynstr_append_mem(ds, ": ", 2);
replace_dynstr_append(ds,mysql_stmt_error(stmt));
dynstr_append_mem(ds,"\n",1);
}
/* Don't log error if we may not get an error */
else if (q->expected_errno[0].type == ERR_SQLSTATE ||
(q->expected_errno[0].type == ERR_ERRNO &&
q->expected_errno[0].code.errnum != 0))
dynstr_append(ds,"Got one of the listed errors\n");
return 0; /* Ok */
}
}
DBUG_PRINT("info",("i: %d expected_errors: %d", i,
q->expected_errors));
dynstr_append_mem(ds, "ERROR ",6);
replace_dynstr_append(ds, mysql_stmt_sqlstate(stmt));
dynstr_append_mem(ds,": ",2);
replace_dynstr_append(ds, mysql_stmt_error(stmt));
dynstr_append_mem(ds,"\n",1);
if (i)
{
verbose_msg("query '%s' failed with wrong errno %d instead of %d...",
q->query, mysql_stmt_errno(stmt), q->expected_errno[0]);
return 1; /* Error */
}
verbose_msg("query '%s' failed: %d: %s", q->query, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt));
/*
if we do not abort on error, failure to run the query does
not fail the whole test case
*/
return 0;
}
return 0;
}
/****************************************************************************\ /****************************************************************************\
* Functions to match SQL statements that can be prepared * Functions to match SQL statements that can be prepared
\****************************************************************************/ \****************************************************************************/
@@ -3898,6 +3836,22 @@ void get_query_type(struct st_query* q)
q->type != Q_DISABLE_PARSING) q->type != Q_DISABLE_PARSING)
q->type= Q_COMMENT; q->type= Q_COMMENT;
} }
else if (q->type == Q_COMMENT_WITH_COMMAND &&
q->query[q->first_word_len-1] == ';')
{
/*
Detect comment with command using extra delimiter
Ex --disable_query_log;
^ Extra delimiter causing the command
to be skipped
*/
save= q->query[q->first_word_len-1];
q->query[q->first_word_len-1]= 0;
type= find_type(q->query, &command_typelib, 1+2);
q->query[q->first_word_len-1]= save;
if (type > 0)
die("Extra delimiter \";\" found");
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -4025,9 +3979,8 @@ int main(int argc, char **argv)
embedded_server_args, embedded_server_args,
(char**) embedded_server_groups)) (char**) embedded_server_groups))
die("Can't initialize MySQL server"); die("Can't initialize MySQL server");
if (cur_file == file_stack) if (cur_file == file_stack && cur_file->file == 0)
{ {
DBUG_ASSERT(cur_file->file == 0);
cur_file->file= stdin; cur_file->file= stdin;
cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME)); cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME));
} }

View File

@@ -6,7 +6,7 @@ AC_DEFUN([MYSQL_CHECK_FEDERATED], [
AC_ARG_WITH([federated-storage-engine], AC_ARG_WITH([federated-storage-engine],
[ [
--with-federated-storage-engine --with-federated-storage-engine
Enable the MySQL Storage Engine], Enable the MySQL Federated Storage Engine],
[federateddb="$withval"], [federateddb="$withval"],
[federateddb=no]) [federateddb=no])
AC_MSG_CHECKING([for MySQL federated storage engine]) AC_MSG_CHECKING([for MySQL federated storage engine])

View File

@@ -38,7 +38,7 @@ $(top_builddir)/include/mysqld_ername.h: $(top_builddir)/include/mysqld_error.h
$(top_builddir)/include/sql_state.h: $(top_builddir)/include/mysqld_error.h $(top_builddir)/include/sql_state.h: $(top_builddir)/include/mysqld_error.h
bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \ bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \
resolve_stack_dump mysql_waitpid innochecksum resolve_stack_dump mysql_waitpid # innochecksum
noinst_PROGRAMS = charset2html noinst_PROGRAMS = charset2html
# Don't update the files from bitkeeper # Don't update the files from bitkeeper

View File

@@ -28,14 +28,11 @@
#define mySTL_HELPERS_HPP #define mySTL_HELPERS_HPP
#include <stdlib.h> #include <stdlib.h>
#include <new> // placement new
#ifdef __IBMCPP__
/* /*
Workaround for the lack of operator new(size_t, void*) Workaround for the lack of operator new(size_t, void*)
in IBM VA C++ 6.0 in IBM VA C++ 6.0
Also used as a workaround to avoid including <new>
*/ */
struct Dummy {}; struct Dummy {};
@@ -45,9 +42,6 @@
} }
typedef Dummy* yassl_pointer; typedef Dummy* yassl_pointer;
#else
typedef void* yassl_pointer;
#endif
namespace mySTL { namespace mySTL {

View File

@@ -164,7 +164,7 @@ void list<T>::push_front(T t)
{ {
void* mem = malloc(sizeof(node)); void* mem = malloc(sizeof(node));
if (!mem) abort(); if (!mem) abort();
node* add = new (mem) node(t); node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t);
if (head_) { if (head_) {
add->next_ = head_; add->next_ = head_;
@@ -210,7 +210,7 @@ void list<T>::push_back(T t)
{ {
void* mem = malloc(sizeof(node)); void* mem = malloc(sizeof(node));
if (!mem) abort(); if (!mem) abort();
node* add = new (mem) node(t); node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t);
if (tail_) { if (tail_) {
tail_->next_ = add; tail_->next_ = add;

View File

@@ -24,7 +24,6 @@
#include "runtime.hpp" #include "runtime.hpp"
#include "misc.hpp" #include "misc.hpp"
#include <new> // for NewHandler
void* operator new(size_t sz, TaoCrypt::new_t) void* operator new(size_t sz, TaoCrypt::new_t)

View File

@@ -1,4 +1,4 @@
--require r/lowercase0.require --require r/lowercase0.require
--disable_query_log; --disable_query_log
show variables like "lower_case_%"; show variables like "lower_case_%";
--enable_query_log; --enable_query_log

View File

@@ -0,0 +1,2 @@
echo Output from mysqltest-x.inc;

View File

@@ -0,0 +1,48 @@
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;
start slave;
stop slave;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
DROP TABLE IF EXISTS federated.archive_table;
CREATE TABLE federated.archive_table (
`id` int(4) NOT NULL,
`name` varchar(54) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`id` int(4) NOT NULL,
`name` varchar(54) default NULL,
PRIMARY KEY (`id`)
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/archive_table';
INSERT INTO federated.t1 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t1 (id, name) VALUES (2, 'bar');
SELECT * FROM federated.t1;
id name
1 foo
2 bar
DELETE FROM federated.t1 WHERE id = 1;
ERROR HY000: There was a problem processing the query on the foreign data source. Data source error: ': 1031 : Table storage engine for 'archive_table' doesn't have t'
SELECT * FROM federated.t1;
id name
1 foo
2 bar
UPDATE federated.t1 SET name='baz' WHERE id = 1;
ERROR HY000: There was a problem processing the query on the foreign data source. Data source error: ': 1031 : Table storage engine for 'archive_table' doesn't have t'
SELECT * FROM federated.t1;
id name
1 foo
2 bar
DROP TABLE federated.t1;
DROP TABLE federated.archive_table;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;

View File

@@ -165,3 +165,8 @@ drop table t1;
select abs(-2) * -2; select abs(-2) * -2;
abs(-2) * -2 abs(-2) * -2
-4 -4
create table t1 (i int);
insert into t1 values (1);
select rand(i) from t1;
ERROR HY000: Incorrect arguments to RAND
drop table t1;

View File

@@ -152,6 +152,7 @@ mysqltest: At line 1: End of line junk detected: "6"
mysqltest: At line 1: End of line junk detected: "6" mysqltest: At line 1: End of line junk detected: "6"
mysqltest: At line 1: Missing delimiter mysqltest: At line 1: Missing delimiter
mysqltest: At line 1: Extra delimiter ";" found mysqltest: At line 1: Extra delimiter ";" found
mysqltest: At line 1: Extra delimiter ";" found
MySQL MySQL
"MySQL" "MySQL"
MySQL: The world''s most popular open source database MySQL: The world''s most popular open source database
@@ -179,7 +180,6 @@ source database
echo message echo message echo message echo message
mysqltest: At line 1: Empty variable mysqltest: At line 1: Empty variable
mysqltest: At line 1: command "';' 2> /dev/null" failed
mysqltest: At line 1: Missing argument in exec mysqltest: At line 1: Missing argument in exec
MySQL MySQL
"MySQL" "MySQL"
@@ -301,7 +301,6 @@ mysqltest: At line 1: First argument to dec must be a variable (start with $)
mysqltest: At line 1: End of line junk detected: "1000" mysqltest: At line 1: End of line junk detected: "1000"
mysqltest: At line 1: Missing arguments to system, nothing to do! mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: Missing arguments to system, nothing to do! mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: system command 'NonExistsinfComamdn 2> /dev/null' failed
test test
test2 test2
test3 test3

View File

@@ -335,39 +335,37 @@ create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4); insert into t1 (a) values (1), (2), (3), (4);
set @precision=10000000000; set @precision=10000000000;
select rand(), select rand(),
cast(rand(10)*@precision as unsigned integer), cast(rand(10)*@precision as unsigned integer) from t1;
cast(rand(a)*@precision as unsigned integer) from t1; rand() cast(rand(10)*@precision as unsigned integer)
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(a)*@precision as unsigned integer) - 6570515219
- 1282061302
- 6698761160
- 9647622201
prepare stmt from
"select rand(),
cast(rand(10)*@precision as unsigned integer),
cast(rand(?)*@precision as unsigned integer) from t1";
set @var=1;
execute stmt using @var;
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
- 6570515219 - - 6570515219 -
- 1282061302 - - 1282061302 -
- 6698761160 - - 6698761160 -
- 9647622201 - - 9647622201 -
prepare stmt from
"select rand(),
cast(rand(10)*@precision as unsigned integer),
cast(rand(a)*@precision as unsigned integer),
cast(rand(?)*@precision as unsigned integer) from t1";
set @var=1;
execute stmt using @var;
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(a)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
- 6570515219 - 4054035371
- 1282061302 - 8716141803
- 6698761160 - 1418603212
- 9647622201 - 944590960
set @var=2; set @var=2;
execute stmt using @var; execute stmt using @var;
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(a)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer) rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
- 6570515219 1559528654 6555866465 - 6570515219 6555866465
- 1282061302 6238114970 1223466192 - 1282061302 1223466192
- 6698761160 6511989195 6449731873 - 6698761160 6449731873
- 9647622201 3845601374 8578261098 - 9647622201 8578261098
set @var=3; set @var=3;
execute stmt using @var; execute stmt using @var;
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(a)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer) rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
- 6570515219 1559528654 9057697559 - 6570515219 9057697559
- 1282061302 6238114970 3730790581 - 1282061302 3730790581
- 6698761160 6511989195 1480860534 - 6698761160 1480860534
- 9647622201 3845601374 6211931236 - 9647622201 6211931236
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
create database mysqltest1; create database mysqltest1;

View File

@@ -758,3 +758,10 @@ execute stmt;
ERROR 42000: FUNCTION test.bug11834_1 does not exist ERROR 42000: FUNCTION test.bug11834_1 does not exist
deallocate prepare stmt; deallocate prepare stmt;
drop function bug11834_2; drop function bug11834_2;
DROP FUNCTION IF EXISTS bug12953|
CREATE FUNCTION bug12953() RETURNS INT
BEGIN
OPTIMIZE TABLE t1;
RETURN 1;
END|
ERROR 0A000: OPTIMIZE TABLE is not allowed in stored procedures

View File

@@ -2151,3 +2151,29 @@ select * from v1;
strcmp(f1,'a') strcmp(f1,'a')
drop view v1; drop view v1;
drop table t1; drop table t1;
create table t1 (
r_object_id char(16) NOT NULL,
group_name varchar(32) NOT NULL
) engine = InnoDB;
create table t2 (
r_object_id char(16) NOT NULL,
i_position int(11) NOT NULL,
users_names varchar(32) default NULL
) Engine = InnoDB;
create view v1 as select r_object_id, group_name from t1;
create view v2 as select r_object_id, i_position, users_names from t2;
create unique index r_object_id on t1(r_object_id);
create index group_name on t1(group_name);
create unique index r_object_id_i_position on t2(r_object_id,i_position);
create index users_names on t2(users_names);
insert into t1 values('120001a080000542','tstgroup1');
insert into t2 values('120001a080000542',-1, 'guser01');
insert into t2 values('120001a080000542',-2, 'guser02');
select v1.r_object_id, v2.users_names from v1, v2
where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id
order by users_names;
r_object_id users_names
120001a080000542 guser01
120001a080000542 guser02
drop view v1, v2;
drop table t1, t2;

View File

@@ -0,0 +1,58 @@
source include/have_archive.inc;
source include/federated.inc;
connection slave;
--disable_warnings
DROP TABLE IF EXISTS federated.archive_table;
--enable_warnings
CREATE TABLE federated.archive_table (
`id` int(4) NOT NULL,
`name` varchar(54) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
connection master;
--disable_warnings
DROP TABLE IF EXISTS federated.t1;
--enable_warnings
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.t1 (
`id` int(4) NOT NULL,
`name` varchar(54) default NULL,
PRIMARY KEY (`id`)
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/archive_table';
INSERT INTO federated.t1 (id, name) VALUES (1, 'foo');
INSERT INTO federated.t1 (id, name) VALUES (2, 'bar');
SELECT * FROM federated.t1;
--error 1430
DELETE FROM federated.t1 WHERE id = 1;
SELECT * FROM federated.t1;
--error 1430
UPDATE federated.t1 SET name='baz' WHERE id = 1;
SELECT * FROM federated.t1;
# --error 1430
# TRUNCATE federated.t1;
#
# SELECT * from federated.t1;
DROP TABLE federated.t1;
connection slave;
DROP TABLE federated.archive_table;
source include/federated_cleanup.inc;

View File

@@ -107,4 +107,13 @@ drop table t1;
# #
select abs(-2) * -2; select abs(-2) * -2;
#
# Bug #6172 RAND(a) should only accept constant values as arguments
#
create table t1 (i int);
insert into t1 values (1);
--error 1210
select rand(i) from t1;
drop table t1;
# End of 4.1 tests # End of 4.1 tests

View File

@@ -358,14 +358,19 @@ select 3 from t1 ;
# Missing delimiter # Missing delimiter
# The comment will be "sucked into" the sleep command since # The comment will be "sucked into" the sleep command since
# delimiter is missing until after "show status" # delimiter is missing until after "show status"
--system echo "sleep 4" > var/log/mysqltest.sql
--system echo "# A comment" >> var/log/mysqltest.sql
--system echo "show status;" >> var/log/mysqltest.sql
--error 1 --error 1
--exec echo -e "sleep 4\n # A comment\nshow status;" | $MYSQL_TEST 2>&1 --exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
# #
# Extra delimiter # Extra delimiter
# #
--error 1 --error 1
--exec echo "--sleep 4;" | $MYSQL_TEST 2>&1 --exec echo "--sleep 4;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--disable_query_log;" | $MYSQL_TEST 2>&1
# Allow trailing # comment # Allow trailing # comment
@@ -423,8 +428,9 @@ echo ;
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Illegal use of exec # Illegal use of exec
--error 1 # Disabled, some shells prints the failed command regardless of pipes
--exec echo "--exec ';' 2> /dev/null" | $MYSQL_TEST 2>&1 #--error 1
#--exec echo "--exec ';' 2> /dev/null" | $MYSQL_TEST 2>&1
--error 1 --error 1
--exec echo "--exec " | $MYSQL_TEST 2>&1 --exec echo "--exec " | $MYSQL_TEST 2>&1
@@ -588,7 +594,7 @@ while ($num)
--source var/tmp/sourced1.sql --source var/tmp/sourced1.sql
dec $num; dec $num;
} }
--enable_abort_on_error; --enable_abort_on_error
--enable_query_log --enable_query_log
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@@ -671,8 +677,9 @@ system echo "hej" > /dev/null;
--exec echo "system;" | $MYSQL_TEST 2>&1 --exec echo "system;" | $MYSQL_TEST 2>&1
--error 1 --error 1
--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1 --exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1
--error 1 # Disabled, some shells prints the failed command regardless of pipes
--exec echo "system NonExistsinfComamdn 2> /dev/null;" | $MYSQL_TEST 2>&1 #--error 1
#--exec echo "system NonExistsinfComamdn 2> /dev/null;" | $MYSQL_TEST 2>&1
--disable_abort_on_error --disable_abort_on_error
system NonExistsinfComamdn; system NonExistsinfComamdn;
@@ -722,12 +729,21 @@ while ($i)
--exec echo "end;" | $MYSQL_TEST 2>&1 --exec echo "end;" | $MYSQL_TEST 2>&1
--error 1 --error 1
--exec echo "{;" | $MYSQL_TEST 2>&1 --exec echo "{;" | $MYSQL_TEST 2>&1
--system echo "while (0)" > var/log/mysqltest.sql
--system echo "echo hej;" >> var/log/mysqltest.sql
--error 1 --error 1
--exec echo -e "while (0)\necho hej;" | $MYSQL_TEST 2>&1 --exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
--system echo "while (0)" > var/log/mysqltest.sql
--system echo "{echo hej;" >> var/log/mysqltest.sql
--error 1 --error 1
--exec echo -e "while (0)\n{echo hej;" | $MYSQL_TEST 2>&1 --exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
--system echo "while (0){" > var/log/mysqltest.sql
--system echo "echo hej;" >> var/log/mysqltest.sql
--error 1 --error 1
--exec echo -e "while (0){\n echo hej;" | $MYSQL_TEST 2>&1 --exec $MYSQL_TEST < var/log/mysqltest.sql 2>&1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Test error messages returned from comments starting with a command # Test error messages returned from comments starting with a command
@@ -792,6 +808,19 @@ select "a" as col1, "c" as col2;
--error 1 --error 1
--exec echo "save_master_pos; sync_with_master a;" | $MYSQL_TEST 2>&1 --exec echo "save_master_pos; sync_with_master a;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
# Test mysqltest arguments
# ----------------------------------------------------------------------------
# -x <file_name>, use the file specified after -x as the test file
#--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1
#--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1
#--exec $MYSQL_TEST --result_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1
#--error 1
#--exec $MYSQL_TEST -x non_existing_file.inc 2>&1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# TODO Test queries, especially their errormessages... so it's easy to debug # TODO Test queries, especially their errormessages... so it's easy to debug
# new scripts and diagnose errors # new scripts and diagnose errors

View File

@@ -20,22 +20,22 @@ connect (con4,localhost,ssl_user4,,);
connection con1; connection con1;
select * from t1; select * from t1;
--error 1142; --error 1142
delete from t1; delete from t1;
connection con2; connection con2;
select * from t1; select * from t1;
--error 1142; --error 1142
delete from t1; delete from t1;
connection con3; connection con3;
select * from t1; select * from t1;
--error 1142; --error 1142
delete from t1; delete from t1;
connection con4; connection con4;
select * from t1; select * from t1;
--error 1142; --error 1142
delete from t1; delete from t1;
connection default; connection default;

View File

@@ -371,12 +371,10 @@ insert into t1 (a) values (1), (2), (3), (4);
set @precision=10000000000; set @precision=10000000000;
--replace_column 1 - 3 - --replace_column 1 - 3 -
select rand(), select rand(),
cast(rand(10)*@precision as unsigned integer), cast(rand(10)*@precision as unsigned integer) from t1;
cast(rand(a)*@precision as unsigned integer) from t1;
prepare stmt from prepare stmt from
"select rand(), "select rand(),
cast(rand(10)*@precision as unsigned integer), cast(rand(10)*@precision as unsigned integer),
cast(rand(a)*@precision as unsigned integer),
cast(rand(?)*@precision as unsigned integer) from t1"; cast(rand(?)*@precision as unsigned integer) from t1";
set @var=1; set @var=1;
--replace_column 1 - 3 - --replace_column 1 - 3 -

View File

@@ -1085,6 +1085,21 @@ drop function bug11834_1;
execute stmt; execute stmt;
deallocate prepare stmt; deallocate prepare stmt;
drop function bug11834_2; drop function bug11834_2;
#
# Bug#12953 "Stored procedures: crash if OPTIMIZE TABLE in function"
#
delimiter |;
--disable_warnings
DROP FUNCTION IF EXISTS bug12953|
--enable_warnings
--error ER_SP_BADSTATEMENT
CREATE FUNCTION bug12953() RETURNS INT
BEGIN
OPTIMIZE TABLE t1;
RETURN 1;
END|
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
# #
@@ -1092,5 +1107,3 @@ drop function bug11834_2;
#drop procedure if exists bugNNNN| #drop procedure if exists bugNNNN|
#--enable_warnings #--enable_warnings
#create procedure bugNNNN... #create procedure bugNNNN...

View File

@@ -2018,3 +2018,36 @@ create view v1 as select strcmp(f1,'a') from t1;
select * from v1; select * from v1;
drop view v1; drop view v1;
drop table t1; drop table t1;
#
# BUG#12941
#
create table t1 (
r_object_id char(16) NOT NULL,
group_name varchar(32) NOT NULL
) engine = InnoDB;
create table t2 (
r_object_id char(16) NOT NULL,
i_position int(11) NOT NULL,
users_names varchar(32) default NULL
) Engine = InnoDB;
create view v1 as select r_object_id, group_name from t1;
create view v2 as select r_object_id, i_position, users_names from t2;
create unique index r_object_id on t1(r_object_id);
create index group_name on t1(group_name);
create unique index r_object_id_i_position on t2(r_object_id,i_position);
create index users_names on t2(users_names);
insert into t1 values('120001a080000542','tstgroup1');
insert into t2 values('120001a080000542',-1, 'guser01');
insert into t2 values('120001a080000542',-2, 'guser02');
select v1.r_object_id, v2.users_names from v1, v2
where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id
order by users_names;
drop view v1, v2;
drop table t1, t2;

View File

@@ -221,11 +221,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
#endif #endif
} }
#ifdef SAFEMALLOC #define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left)
#define TRASH(X) bfill(((char*)(X) + ((X)->size-(X)->left)), (X)->left, 0xa5)
#else
#define TRASH /* no-op */
#endif
/* Mark all data in blocks free for reusage */ /* Mark all data in blocks free for reusage */
@@ -239,7 +235,7 @@ static inline void mark_blocks_free(MEM_ROOT* root)
for (next= root->free; next; next= *(last= &next->next)) for (next= root->free; next; next= *(last= &next->next))
{ {
next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM)); next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM));
TRASH(next); TRASH_MEM(next);
} }
/* Combine the free and the used list */ /* Combine the free and the used list */
@@ -249,7 +245,7 @@ static inline void mark_blocks_free(MEM_ROOT* root)
for (; next; next= next->next) for (; next; next= next->next)
{ {
next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM)); next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM));
TRASH(next); TRASH_MEM(next);
} }
/* Now everything is set; Indicate that nothing is used anymore */ /* Now everything is set; Indicate that nothing is used anymore */
@@ -310,7 +306,7 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{ {
root->free=root->pre_alloc; root->free=root->pre_alloc;
root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(USED_MEM)); root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(USED_MEM));
TRASH(root->pre_alloc); TRASH_MEM(root->pre_alloc);
root->free->next=0; root->free->next=0;
} }
root->block_num= 4; root->block_num= 4;

View File

@@ -342,11 +342,23 @@ int handle_options(int *argc, char ***argv,
--enable-'option-name'. --enable-'option-name'.
*optend was set to '0' if one used --disable-option *optend was set to '0' if one used --disable-option
*/ */
my_bool tmp= (my_bool) (!optend || *optend == '1');
*((my_bool*) value)= tmp;
(*argc)--; (*argc)--;
if (!optend || *optend == '1' ||
!my_strcasecmp(&my_charset_latin1, optend, "true"))
*((my_bool*) value)= (my_bool) 1;
else if (*optend == '0' ||
!my_strcasecmp(&my_charset_latin1, optend, "false"))
*((my_bool*) value)= (my_bool) 0;
else
{
my_getopt_error_reporter(WARNING_LEVEL,
"%s: ignoring option '--%s' due to \
invalid value '%s'\n",
my_progname, optp->name, optend);
continue;
}
get_one_option(optp->id, optp, get_one_option(optp->id, optp,
tmp ? (char*) "1" : disabled_my_option); value ? (char*) "1" : disabled_my_option);
continue; continue;
} }
argument= optend; argument= optend;

View File

@@ -1935,6 +1935,8 @@ int ha_federated::delete_row(const byte *buf)
{ {
int error_code= ER_QUERY_ON_FOREIGN_DATA_SOURCE; int error_code= ER_QUERY_ON_FOREIGN_DATA_SOURCE;
char error_buffer[FEDERATED_QUERY_BUFFER_SIZE]; char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
my_sprintf(error_buffer, (error_buffer, ": %d : %s",
mysql_errno(mysql), mysql_error(mysql)));
my_error(error_code, MYF(0), error_buffer); my_error(error_code, MYF(0), error_buffer);
DBUG_RETURN(error_code); DBUG_RETURN(error_code);
} }

View File

@@ -1874,6 +1874,11 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref)
used_tables_cache|= RAND_TABLE_BIT; used_tables_cache|= RAND_TABLE_BIT;
if (arg_count) if (arg_count)
{ // Only use argument once in query { // Only use argument once in query
if (!args[0]->const_during_execution())
{
my_error(ER_WRONG_ARGUMENTS, MYF(0), "RAND");
return TRUE;
}
/* /*
Allocate rand structure once: we must use thd->stmt_arena Allocate rand structure once: we must use thd->stmt_arena
to create rand in proper mem_root if it's a prepared statement or to create rand in proper mem_root if it's a prepared statement or

View File

@@ -552,6 +552,7 @@ struct Query_cache_query_flags
#define query_cache_store_query(A, B) query_cache.store_query(A, B) #define query_cache_store_query(A, B) query_cache.store_query(A, B)
#define query_cache_destroy() query_cache.destroy() #define query_cache_destroy() query_cache.destroy()
#define query_cache_result_size_limit(A) query_cache.result_size_limit(A) #define query_cache_result_size_limit(A) query_cache.result_size_limit(A)
#define query_cache_init() query_cache.init()
#define query_cache_resize(A) query_cache.resize(A) #define query_cache_resize(A) query_cache.resize(A)
#define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A) #define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A)
#define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C) #define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
@@ -565,6 +566,7 @@ struct Query_cache_query_flags
#define query_cache_store_query(A, B) #define query_cache_store_query(A, B)
#define query_cache_destroy() #define query_cache_destroy()
#define query_cache_result_size_limit(A) #define query_cache_result_size_limit(A)
#define query_cache_init()
#define query_cache_resize(A) #define query_cache_resize(A)
#define query_cache_set_min_res_unit(A) #define query_cache_set_min_res_unit(A)
#define query_cache_invalidate3(A, B, C) #define query_cache_invalidate3(A, B, C)
@@ -1175,6 +1177,7 @@ extern bool opt_using_transactions, mysqld_embedded;
extern bool using_update_log, opt_large_files, server_id_supplied; extern bool using_update_log, opt_large_files, server_id_supplied;
extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log; extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log;
extern bool opt_disable_networking, opt_skip_show_db; extern bool opt_disable_networking, opt_skip_show_db;
extern bool opt_character_set_client_handshake;
extern bool volatile abort_loop, shutdown_in_progress, grant_option; extern bool volatile abort_loop, shutdown_in_progress, grant_option;
extern bool mysql_proc_table_exists; extern bool mysql_proc_table_exists;
extern uint volatile thread_count, thread_running, global_read_lock; extern uint volatile thread_count, thread_running, global_read_lock;

View File

@@ -339,6 +339,7 @@ static my_bool opt_sync_bdb_logs;
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
bool opt_error_log= IF_WIN(1,0); bool opt_error_log= IF_WIN(1,0);
bool opt_disable_networking=0, opt_skip_show_db=0; bool opt_disable_networking=0, opt_skip_show_db=0;
bool opt_character_set_client_handshake= 1;
bool server_id_supplied = 0; bool server_id_supplied = 0;
bool opt_endinfo,using_udf_functions, locked_in_memory; bool opt_endinfo,using_udf_functions, locked_in_memory;
bool opt_using_transactions, using_update_log; bool opt_using_transactions, using_update_log;
@@ -2783,6 +2784,7 @@ static int init_server_components()
query_cache_result_size_limit(query_cache_limit); query_cache_result_size_limit(query_cache_limit);
query_cache_set_min_res_unit(query_cache_min_res_unit); query_cache_set_min_res_unit(query_cache_min_res_unit);
query_cache_init();
query_cache_resize(query_cache_size); query_cache_resize(query_cache_size);
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2); randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
reset_floating_point_exceptions(); reset_floating_point_exceptions();
@@ -4423,6 +4425,7 @@ enum options_mysqld
OPT_EXPIRE_LOGS_DAYS, OPT_EXPIRE_LOGS_DAYS,
OPT_GROUP_CONCAT_MAX_LEN, OPT_GROUP_CONCAT_MAX_LEN,
OPT_DEFAULT_COLLATION, OPT_DEFAULT_COLLATION,
OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
OPT_INIT_CONNECT, OPT_INIT_CONNECT,
OPT_INIT_SLAVE, OPT_INIT_SLAVE,
OPT_SECURE_AUTH, OPT_SECURE_AUTH,
@@ -4524,6 +4527,11 @@ Disable with --skip-bdb (will save memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0, {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"character-set-client-handshake", OPT_CHARACTER_SET_CLIENT_HANDSHAKE,
"Don't use client side character set value sent during handshake.",
(gptr*) &opt_character_set_client_handshake,
(gptr*) &opt_character_set_client_handshake,
0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"character-set-server", 'C', "Set the default character set.", {"character-set-server", 'C', "Set the default character set.",
(gptr*) &default_character_set_name, (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, (gptr*) &default_character_set_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },

View File

@@ -573,13 +573,18 @@ void query_cache_insert(NET *net, const char *packet, ulong length)
{ {
DBUG_ENTER("query_cache_insert"); DBUG_ENTER("query_cache_insert");
#ifndef DBUG_OFF
// Check if we have called query_cache.wreck() (which disables the cache)
if (query_cache.query_cache_size == 0)
DBUG_VOID_RETURN;
#endif
STRUCT_LOCK(&query_cache.structure_guard_mutex); STRUCT_LOCK(&query_cache.structure_guard_mutex);
/*
It is very unlikely that following condition is TRUE (it is possible
only if other thread is resizing cache), so we check it only after guard
mutex lock
*/
if (unlikely(query_cache.query_cache_size == 0))
{
STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
DBUG_VOID_RETURN;
}
Query_cache_block *query_block = ((Query_cache_block*) Query_cache_block *query_block = ((Query_cache_block*)
net->query_cache_query); net->query_cache_query);
if (query_block) if (query_block)
@@ -623,14 +628,20 @@ void query_cache_abort(NET *net)
{ {
DBUG_ENTER("query_cache_abort"); DBUG_ENTER("query_cache_abort");
#ifndef DBUG_OFF
// Check if we have called query_cache.wreck() (which disables the cache)
if (query_cache.query_cache_size == 0)
DBUG_VOID_RETURN;
#endif
if (net->query_cache_query != 0) // Quick check on unlocked structure if (net->query_cache_query != 0) // Quick check on unlocked structure
{ {
STRUCT_LOCK(&query_cache.structure_guard_mutex); STRUCT_LOCK(&query_cache.structure_guard_mutex);
/*
It is very unlikely that following condition is TRUE (it is possible
only if other thread is resizing cache), so we check it only after guard
mutex lock
*/
if (unlikely(query_cache.query_cache_size == 0))
{
STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
DBUG_VOID_RETURN;
}
Query_cache_block *query_block = ((Query_cache_block*) Query_cache_block *query_block = ((Query_cache_block*)
net->query_cache_query); net->query_cache_query);
if (query_block) // Test if changed by other thread if (query_block) // Test if changed by other thread
@@ -652,11 +663,6 @@ void query_cache_end_of_result(THD *thd)
{ {
DBUG_ENTER("query_cache_end_of_result"); DBUG_ENTER("query_cache_end_of_result");
#ifndef DBUG_OFF
// Check if we have called query_cache.wreck() (which disables the cache)
if (query_cache.query_cache_size == 0) DBUG_VOID_RETURN;
#endif
if (thd->net.query_cache_query != 0) // Quick check on unlocked structure if (thd->net.query_cache_query != 0) // Quick check on unlocked structure
{ {
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
@@ -664,6 +670,17 @@ void query_cache_end_of_result(THD *thd)
emb_count_querycache_size(thd)); emb_count_querycache_size(thd));
#endif #endif
STRUCT_LOCK(&query_cache.structure_guard_mutex); STRUCT_LOCK(&query_cache.structure_guard_mutex);
/*
It is very unlikely that following condition is TRUE (it is possible
only if other thread is resizing cache), so we check it only after guard
mutex lock
*/
if (unlikely(query_cache.query_cache_size == 0))
{
STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
DBUG_VOID_RETURN;
}
Query_cache_block *query_block = ((Query_cache_block*) Query_cache_block *query_block = ((Query_cache_block*)
thd->net.query_cache_query); thd->net.query_cache_query);
if (query_block) if (query_block)
@@ -743,9 +760,14 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
DBUG_ENTER("Query_cache::resize"); DBUG_ENTER("Query_cache::resize");
DBUG_PRINT("qcache", ("from %lu to %lu",query_cache_size, DBUG_PRINT("qcache", ("from %lu to %lu",query_cache_size,
query_cache_size_arg)); query_cache_size_arg));
free_cache(0); DBUG_ASSERT(initialized);
STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size > 0)
free_cache();
query_cache_size= query_cache_size_arg; query_cache_size= query_cache_size_arg;
DBUG_RETURN(::query_cache_size= init_cache()); ::query_cache_size= init_cache();
STRUCT_UNLOCK(&structure_guard_mutex);
DBUG_RETURN(::query_cache_size);
} }
@@ -1438,7 +1460,7 @@ void Query_cache::destroy()
} }
else else
{ {
free_cache(1); free_cache();
pthread_mutex_destroy(&structure_guard_mutex); pthread_mutex_destroy(&structure_guard_mutex);
initialized = 0; initialized = 0;
} }
@@ -1467,8 +1489,6 @@ ulong Query_cache::init_cache()
int align; int align;
DBUG_ENTER("Query_cache::init_cache"); DBUG_ENTER("Query_cache::init_cache");
if (!initialized)
init();
approx_additional_data_size = (sizeof(Query_cache) + approx_additional_data_size = (sizeof(Query_cache) +
sizeof(gptr)*(def_query_hash_size+ sizeof(gptr)*(def_query_hash_size+
def_table_hash_size)); def_table_hash_size));
@@ -1526,14 +1546,9 @@ ulong Query_cache::init_cache()
goto err; goto err;
query_cache_size -= additional_data_size; query_cache_size -= additional_data_size;
STRUCT_LOCK(&structure_guard_mutex); if (!(cache= (byte *)
if (!(cache = (byte *)
my_malloc_lock(query_cache_size+additional_data_size, MYF(0)))) my_malloc_lock(query_cache_size+additional_data_size, MYF(0))))
{
STRUCT_UNLOCK(&structure_guard_mutex);
goto err; goto err;
}
DBUG_PRINT("qcache", ("cache length %lu, min unit %lu, %u bins", DBUG_PRINT("qcache", ("cache length %lu, min unit %lu, %u bins",
query_cache_size, min_allocation_unit, mem_bin_num)); query_cache_size, min_allocation_unit, mem_bin_num));
@@ -1629,7 +1644,6 @@ ulong Query_cache::init_cache()
queries_in_cache = 0; queries_in_cache = 0;
queries_blocks = 0; queries_blocks = 0;
STRUCT_UNLOCK(&structure_guard_mutex);
DBUG_RETURN(query_cache_size + DBUG_RETURN(query_cache_size +
additional_data_size + approx_additional_data_size); additional_data_size + approx_additional_data_size);
@@ -1645,6 +1659,7 @@ void Query_cache::make_disabled()
{ {
DBUG_ENTER("Query_cache::make_disabled"); DBUG_ENTER("Query_cache::make_disabled");
query_cache_size= 0; query_cache_size= 0;
queries_blocks= 0;
free_memory= 0; free_memory= 0;
bins= 0; bins= 0;
steps= 0; steps= 0;
@@ -1656,14 +1671,11 @@ void Query_cache::make_disabled()
} }
void Query_cache::free_cache(my_bool destruction) void Query_cache::free_cache()
{ {
DBUG_ENTER("Query_cache::free_cache"); DBUG_ENTER("Query_cache::free_cache");
if (query_cache_size > 0) if (query_cache_size > 0)
{ {
if (!destruction)
STRUCT_LOCK(&structure_guard_mutex);
flush_cache(); flush_cache();
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (bins[0].free_blocks == 0) if (bins[0].free_blocks == 0)
@@ -1685,8 +1697,6 @@ void Query_cache::free_cache(my_bool destruction)
make_disabled(); make_disabled();
hash_free(&queries); hash_free(&queries);
hash_free(&tables); hash_free(&tables);
if (!destruction)
STRUCT_UNLOCK(&structure_guard_mutex);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -2401,7 +2411,19 @@ Query_cache::allocate_block(ulong len, my_bool not_less, ulong min,
} }
if (!under_guard) if (!under_guard)
{
STRUCT_LOCK(&structure_guard_mutex); STRUCT_LOCK(&structure_guard_mutex);
/*
It is very unlikely that following condition is TRUE (it is possible
only if other thread is resizing cache), so we check it only after
guard mutex lock
*/
if (unlikely(query_cache.query_cache_size == 0))
{
STRUCT_UNLOCK(&structure_guard_mutex);
DBUG_RETURN(0);
}
}
/* Free old queries until we have enough memory to store this block */ /* Free old queries until we have enough memory to store this block */
Query_cache_block *block; Query_cache_block *block;
@@ -2947,6 +2969,17 @@ void Query_cache::pack_cache()
{ {
DBUG_ENTER("Query_cache::pack_cache"); DBUG_ENTER("Query_cache::pack_cache");
STRUCT_LOCK(&structure_guard_mutex); STRUCT_LOCK(&structure_guard_mutex);
/*
It is very unlikely that following condition is TRUE (it is possible
only if other thread is resizing cache), so we check it only after
guard mutex lock
*/
if (unlikely(query_cache_size == 0))
{
STRUCT_UNLOCK(&structure_guard_mutex);
DBUG_VOID_RETURN;
}
DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1);); DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1););
byte *border = 0; byte *border = 0;
@@ -3256,6 +3289,7 @@ my_bool Query_cache::join_results(ulong join_limit)
STRUCT_LOCK(&structure_guard_mutex); STRUCT_LOCK(&structure_guard_mutex);
if (queries_blocks != 0) if (queries_blocks != 0)
{ {
DBUG_ASSERT(query_cache_size > 0);
Query_cache_block *block = queries_blocks; Query_cache_block *block = queries_blocks;
do do
{ {
@@ -3552,7 +3586,19 @@ my_bool Query_cache::check_integrity(bool not_locked)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!not_locked) if (!not_locked)
{
STRUCT_LOCK(&structure_guard_mutex); STRUCT_LOCK(&structure_guard_mutex);
/*
It is very unlikely that following condition is TRUE (it is possible
only if other thread is resizing cache), so we check it only after
guard mutex lock
*/
if (unlikely(query_cache_size == 0))
{
STRUCT_UNLOCK(&query_cache.structure_guard_mutex);
DBUG_RETURN(0);
}
}
if (hash_check(&queries)) if (hash_check(&queries))
{ {

View File

@@ -327,10 +327,9 @@ protected:
Following function control structure_guard_mutex Following function control structure_guard_mutex
by themself or don't need structure_guard_mutex by themself or don't need structure_guard_mutex
*/ */
void init();
ulong init_cache(); ulong init_cache();
void make_disabled(); void make_disabled();
void free_cache(my_bool destruction); void free_cache();
Query_cache_block *write_block_data(ulong data_len, gptr data, Query_cache_block *write_block_data(ulong data_len, gptr data,
ulong header_len, ulong header_len,
Query_cache_block::block_type type, Query_cache_block::block_type type,
@@ -366,6 +365,8 @@ protected:
uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE, uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE); uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);
/* initialize cache (mutex) */
void init();
/* resize query cache (return real query size, 0 if disabled) */ /* resize query cache (return real query size, 0 if disabled) */
ulong resize(ulong query_cache_size); ulong resize(ulong query_cache_size);
/* set limit on result size */ /* set limit on result size */

View File

@@ -879,11 +879,13 @@ static int check_connection(THD *thd)
DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8])); DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
/* /*
Use server character set and collation if Use server character set and collation if
- opt_character_set_client_handshake is not set
- client has not specified a character set - client has not specified a character set
- client character set is the same as the servers - client character set is the same as the servers
- client character set doesn't exists in server - client character set doesn't exists in server
*/ */
if (!(thd->variables.character_set_client= if (!opt_character_set_client_handshake ||
!(thd->variables.character_set_client=
get_charset((uint) net->read_pos[8], MYF(0))) || get_charset((uint) net->read_pos[8], MYF(0))) ||
!my_strcasecmp(&my_charset_latin1, !my_strcasecmp(&my_charset_latin1,
global_system_variables.character_set_client->name, global_system_variables.character_set_client->name,

View File

@@ -8069,12 +8069,17 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
bool table_cant_handle_bit_fields, bool table_cant_handle_bit_fields,
uint convert_blob_length) uint convert_blob_length)
{ {
Item::Type orig_type;
Item *orig_item;
if (type != Item::FIELD_ITEM && if (type != Item::FIELD_ITEM &&
item->real_item()->type() == Item::FIELD_ITEM && item->real_item()->type() == Item::FIELD_ITEM &&
(item->type() != Item::REF_ITEM || (item->type() != Item::REF_ITEM ||
!((Item_ref *) item)->depended_from)) !((Item_ref *) item)->depended_from))
{ {
orig_item= item;
item= item->real_item(); item= item->real_item();
orig_type= type;
type= Item::FIELD_ITEM; type= Item::FIELD_ITEM;
} }
switch (type) { switch (type) {
@@ -8090,29 +8095,34 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case Item::DEFAULT_VALUE_ITEM: case Item::DEFAULT_VALUE_ITEM:
{ {
Item_field *field= (Item_field*) item; Item_field *field= (Item_field*) item;
bool orig_modify= modify_item;
Field *result;
if (orig_type == Item::REF_ITEM)
modify_item= 0;
/* /*
If item have to be able to store NULLs but underlaid field can't do it, If item have to be able to store NULLs but underlaid field can't do it,
create_tmp_field_from_field() can't be used for tmp field creation. create_tmp_field_from_field() can't be used for tmp field creation.
*/ */
if (field->maybe_null && !field->field->maybe_null()) if (field->maybe_null && !field->field->maybe_null())
{ {
Field *res= create_tmp_field_from_item(thd, item, table, NULL, result= create_tmp_field_from_item(thd, item, table, NULL,
modify_item, convert_blob_length); modify_item, convert_blob_length);
*from_field= field->field; *from_field= field->field;
if (res && modify_item) if (result && modify_item)
((Item_field*)item)->result_field= res; ((Item_field*)item)->result_field= result;
return res;
} }
else if (table_cant_handle_bit_fields && field->field->type() == FIELD_TYPE_BIT)
if (table_cant_handle_bit_fields && result= create_tmp_field_from_item(thd, item, table, copy_func,
field->field->type() == FIELD_TYPE_BIT)
return create_tmp_field_from_item(thd, item, table, copy_func,
modify_item, convert_blob_length); modify_item, convert_blob_length);
return create_tmp_field_from_field(thd, (*from_field= field->field), else
result= create_tmp_field_from_field(thd, (*from_field= field->field),
item->name, table, item->name, table,
modify_item ? (Item_field*) item : modify_item ? (Item_field*) item :
NULL, NULL,
convert_blob_length); convert_blob_length);
if (orig_type == Item::REF_ITEM && orig_modify)
((Item_ref*)orig_item)->set_result_field(result);
return result;
} }
/* Fall through */ /* Fall through */
case Item::FUNC_ITEM: case Item::FUNC_ITEM:

View File

@@ -4413,6 +4413,11 @@ optimize:
OPTIMIZE opt_no_write_to_binlog table_or_tables OPTIMIZE opt_no_write_to_binlog table_or_tables
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (lex->sphead)
{
my_error(ER_SP_BADSTATEMENT, MYF(0), "OPTIMIZE TABLE");
YYABORT;
}
lex->sql_command = SQLCOM_OPTIMIZE; lex->sql_command = SQLCOM_OPTIMIZE;
lex->no_write_to_binlog= $2; lex->no_write_to_binlog= $2;
lex->check_opt.init(); lex->check_opt.init();