mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into neptunus.(none):/home/msvensson/mysql/mysql-5.1 client/mysqltest.c: Auto merged configure.in: Auto merged sql/ha_federated.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_yacc.yy: Auto merged
This commit is contained in:
@@ -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])
|
||||||
|
@@ -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 {
|
||||||
|
@@ -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;
|
||||||
|
@@ -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)
|
||||||
|
48
mysql-test/r/federated_archive.result
Normal file
48
mysql-test/r/federated_archive.result
Normal 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;
|
@@ -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;
|
||||||
|
@@ -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;
|
||||||
|
@@ -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
|
||||||
|
58
mysql-test/t/federated_archive.test
Normal file
58
mysql-test/t/federated_archive.test
Normal 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;
|
||||||
|
|
@@ -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
|
||||||
|
@@ -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 -
|
||||||
|
@@ -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...
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
|
@@ -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)
|
||||||
|
@@ -2784,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();
|
||||||
|
116
sql/sql_cache.cc
116
sql/sql_cache.cc
@@ -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 *)
|
||||||
|
my_malloc_lock(query_cache_size+additional_data_size, MYF(0))))
|
||||||
if (!(cache = (byte *)
|
|
||||||
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))
|
||||||
{
|
{
|
||||||
|
@@ -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 */
|
||||||
|
@@ -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();
|
||||||
|
Reference in New Issue
Block a user