mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
merge 5.0->5.0-ndb
BitKeeper/etc/logging_ok: auto-union ndb/test/tools/Makefile.am: Auto merged
This commit is contained in:
commit
5c93c3e11c
34 changed files with 284 additions and 209 deletions
|
@ -111,6 +111,7 @@ lenz@mysql.com
|
|||
magnus@neptunus.(none)
|
||||
magnus@shellback.(none)
|
||||
marko@hundin.mysql.fi
|
||||
marty@linux.site
|
||||
marty@shark.
|
||||
mats@mysql.com
|
||||
matt@booty.(none)
|
||||
|
|
|
@ -48,6 +48,9 @@ tcx.se .se
|
|||
select concat(':',ltrim(' left '),':',rtrim(' right '),':');
|
||||
concat(':',ltrim(' left '),':',rtrim(' right '),':')
|
||||
:left : right:
|
||||
select concat(':',trim(leading from ' left '),':',trim(trailing from ' right '),':');
|
||||
concat(':',trim(leading from ' left '),':',trim(trailing from ' right '),':')
|
||||
:left : right:
|
||||
select concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':');
|
||||
concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':')
|
||||
:left: right:
|
||||
|
@ -703,3 +706,9 @@ NULL
|
|||
select trim('xyz' from null) as "must_be_null";
|
||||
must_be_null
|
||||
NULL
|
||||
select trim(leading NULL from 'kate') as "must_be_null";
|
||||
must_be_null
|
||||
NULL
|
||||
select trim(trailing NULL from 'xyz') as "must_be_null";
|
||||
must_be_null
|
||||
NULL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
DROP TABLE IF EXISTS t1, `"t"1`;
|
||||
DROP TABLE IF EXISTS t1, `"t"1`, t1aa,t2aa;
|
||||
drop database if exists mysqldump_test_db;
|
||||
CREATE TABLE t1(a int);
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
drop table if exists t1,t2;
|
||||
drop table if exists t1aa,t2aa;
|
||||
drop database if exists mysqltest;
|
||||
delete from mysql.user where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
|
||||
delete from mysql.db where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
|
||||
|
|
|
@ -1639,12 +1639,9 @@ yz,yz
|
|||
drop procedure bug3368|
|
||||
drop table t3|
|
||||
drop table if exists t3|
|
||||
create table t3 (f1 int, f2 int);
|
||||
insert into t3 values (1,1);
|
||||
--disable_warnings|
|
||||
create table t3 (f1 int, f2 int)|
|
||||
insert into t3 values (1,1)|
|
||||
drop procedure if exists bug4579_1|
|
||||
Warnings:
|
||||
Note 1305 PROCEDURE bug4579_1 does not exist
|
||||
create procedure bug4579_1 ()
|
||||
begin
|
||||
declare sf1 int;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
drop table if exists t1;
|
||||
CREATE TABLE t1 (x1 int);
|
||||
ALTER TABLE t1 CHANGE x1 x2 int;
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
drop table if exists t1,t1aa,t2aa;
|
||||
show tables;
|
||||
Tables_in_db
|
||||
columns_priv
|
||||
|
|
|
@ -25,6 +25,7 @@ select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',
|
|||
select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1);
|
||||
|
||||
select concat(':',ltrim(' left '),':',rtrim(' right '),':');
|
||||
select concat(':',trim(leading from ' left '),':',trim(trailing from ' right '),':');
|
||||
select concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':');
|
||||
select concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':');
|
||||
select concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':');
|
||||
|
@ -443,3 +444,5 @@ select quote(trim(concat(' ', 'a')));
|
|||
#
|
||||
select trim(null from 'kate') as "must_be_null";
|
||||
select trim('xyz' from null) as "must_be_null";
|
||||
select trim(leading NULL from 'kate') as "must_be_null";
|
||||
select trim(trailing NULL from 'xyz') as "must_be_null";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1, `"t"1`;
|
||||
DROP TABLE IF EXISTS t1, `"t"1`, t1aa,t2aa;
|
||||
drop database if exists mysqldump_test_db;
|
||||
--enable_warnings
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
--disable_warnings
|
||||
drop table if exists t1,t2,t3,t4;
|
||||
# The following may be left from older tests
|
||||
drop table if exists t1_1,t1_2,t9_1,t9_2;
|
||||
drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa;
|
||||
drop view if exists v1;
|
||||
--enable_warnings
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2;
|
||||
drop table if exists t1aa,t2aa;
|
||||
drop database if exists mysqltest;
|
||||
|
||||
delete from mysql.user where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
|
||||
|
|
|
@ -945,10 +945,12 @@ insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
|
|||
insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
|
||||
|
||||
# These don't work yet.
|
||||
--disable_ps_protocol
|
||||
select * from t2 where s = append("a", "b")|
|
||||
select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)|
|
||||
select * from t2 where d = e()|
|
||||
select * from t2|
|
||||
--enable_ps_protocol
|
||||
delete from t2|
|
||||
|
||||
drop function e|
|
||||
|
@ -1263,8 +1265,10 @@ end|
|
|||
|
||||
call rc()|
|
||||
select row_count()|
|
||||
--disable_ps_protocol
|
||||
update t1 set data=42 where id = "b";
|
||||
select row_count()|
|
||||
--enable_ps_protocol
|
||||
delete from t1|
|
||||
select row_count()|
|
||||
delete from t1|
|
||||
|
@ -2022,8 +2026,8 @@ drop table t3|
|
|||
--disable_warnings
|
||||
drop table if exists t3|
|
||||
--enable_warnings
|
||||
create table t3 (f1 int, f2 int);
|
||||
insert into t3 values (1,1);
|
||||
create table t3 (f1 int, f2 int)|
|
||||
insert into t3 values (1,1)|
|
||||
|
||||
--disable_warnings
|
||||
drop procedure if exists bug4579_1|
|
||||
|
|
|
@ -557,7 +557,7 @@ INSERT IGNORE INTO t1 (col1) values (1/0);
|
|||
INSERT IGNORE INTO t1 VALUES (+1.9E+309,-1.9E+309);
|
||||
INSERT IGNORE INTO t1 VALUES ('+2.0E+309','-2.0E+309');
|
||||
# stupid...
|
||||
--replace_result -0 0
|
||||
--replace_result -0 0 1.7976931348623e+308 1.79769313486232e+308
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#
|
||||
# Test for Bug #2385 CREATE TABLE LIKE lacks locking on source and destination table
|
||||
# Test for Bug #2385 CREATE TABLE LIKE lacks locking on source and destination
|
||||
# table
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
connect (con1,localhost,root,,);
|
||||
connect (con2,localhost,root,,);
|
||||
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
# This test must examine integrity of system database "mysql"
|
||||
#
|
||||
|
||||
# First delete some tables maybe left over from previous tests
|
||||
--disable_warnings
|
||||
drop table if exists t1,t1aa,t2aa;
|
||||
--enable_warnings
|
||||
|
||||
-- disable_query_log
|
||||
use mysql;
|
||||
-- enable_query_log
|
||||
|
|
|
@ -53,6 +53,7 @@ select @a;
|
|||
drop trigger t1.trg;
|
||||
drop table t1;
|
||||
|
||||
--disable_ps_protocol
|
||||
# Before update trigger
|
||||
# (In future we will achieve this via proper error handling in triggers)
|
||||
create table t1 (aid int not null primary key, balance int not null default 0);
|
||||
|
@ -74,6 +75,7 @@ select * from t1|
|
|||
drop trigger t1.trg|
|
||||
drop table t1|
|
||||
delimiter ;|
|
||||
--enable_ps_protocol
|
||||
|
||||
# After update trigger
|
||||
create table t1 (i int);
|
||||
|
|
|
@ -31,12 +31,48 @@
|
|||
#define HAVE_STRCASECMP
|
||||
#define strcasecmp _strcmpi
|
||||
#pragma warning(disable: 4503 4786)
|
||||
typedef unsigned __int64 Uint64;
|
||||
typedef signed __int64 Int64;
|
||||
#else
|
||||
#undef NDB_WIN32
|
||||
#define DIR_SEPARATOR "/"
|
||||
typedef unsigned long long Uint64;
|
||||
typedef signed long long Int64;
|
||||
#endif
|
||||
|
||||
#include <my_global.h>
|
||||
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char Uint8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short Uint16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int Uint32;
|
||||
|
||||
typedef unsigned int UintR;
|
||||
|
||||
#ifdef __SIZE_TYPE__
|
||||
typedef __SIZE_TYPE__ UintPtr;
|
||||
#elif SIZEOF_CHARP == 4
|
||||
typedef Uint32 UintPtr;
|
||||
#elif SIZEOF_CHARP == 8
|
||||
typedef Uint64 UintPtr;
|
||||
#else
|
||||
#error "Unknown size of (char *)"
|
||||
#endif
|
||||
|
||||
#if ! (SIZEOF_CHAR == 1)
|
||||
#error "Invalid define for Uint8"
|
||||
#endif
|
||||
|
||||
#if ! (SIZEOF_INT == 4)
|
||||
#error "Invalid define for Uint32"
|
||||
#endif
|
||||
|
||||
#if ! (SIZEOF_LONG_LONG == 8)
|
||||
#error "Invalid define for Uint64"
|
||||
#endif
|
||||
|
||||
#include <my_alarm.h>
|
||||
|
||||
#ifdef _AIX
|
||||
|
|
|
@ -21,41 +21,7 @@
|
|||
#ifndef NDB_TYPES_H
|
||||
#define NDB_TYPES_H
|
||||
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char Uint8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short Uint16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int Uint32;
|
||||
|
||||
typedef unsigned int UintR;
|
||||
|
||||
#ifdef __SIZE_TYPE__
|
||||
typedef __SIZE_TYPE__ UintPtr;
|
||||
#else
|
||||
#include <ndb_global.h>
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
#if defined(WIN32) || defined(NDB_WIN32)
|
||||
typedef Uint32 UintPtr;
|
||||
#else
|
||||
typedef uintptr_t UintPtr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(NDB_WIN32)
|
||||
typedef unsigned __int64 Uint64;
|
||||
typedef signed __int64 Int64;
|
||||
typedef UintPtr ssize_t;
|
||||
#else
|
||||
typedef unsigned long long Uint64;
|
||||
typedef signed long long Int64;
|
||||
#endif
|
||||
|
||||
#include "ndb_global.h"
|
||||
#include "ndb_constants.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -213,6 +213,13 @@ Thd_ndb::~Thd_ndb()
|
|||
{
|
||||
if (ndb)
|
||||
delete ndb;
|
||||
ndb= 0;
|
||||
}
|
||||
|
||||
inline
|
||||
Ndb *ha_ndbcluster::get_ndb()
|
||||
{
|
||||
return ((Thd_ndb*)current_thd->transaction.thd_ndb)->ndb;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -246,8 +253,9 @@ void ha_ndbcluster::records_update()
|
|||
info->no_uncommitted_rows_count));
|
||||
// if (info->records == ~(ha_rows)0)
|
||||
{
|
||||
Ndb *ndb= get_ndb();
|
||||
Uint64 rows;
|
||||
if(ndb_get_table_statistics(m_ndb, m_tabname, &rows, 0) == 0){
|
||||
if(ndb_get_table_statistics(ndb, m_tabname, &rows, 0) == 0){
|
||||
info->records= rows;
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +340,8 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans)
|
|||
switch (err.classification) {
|
||||
case NdbError::SchemaError:
|
||||
{
|
||||
NDBDICT *dict= m_ndb->getDictionary();
|
||||
Ndb *ndb= get_ndb();
|
||||
NDBDICT *dict= ndb->getDictionary();
|
||||
DBUG_PRINT("info", ("invalidateTable %s", m_tabname));
|
||||
dict->invalidateTable(m_tabname);
|
||||
table->version=0L; /* Free when thread is ready */
|
||||
|
@ -362,7 +371,7 @@ bool ha_ndbcluster::get_error_message(int error,
|
|||
DBUG_ENTER("ha_ndbcluster::get_error_message");
|
||||
DBUG_PRINT("enter", ("error: %d", error));
|
||||
|
||||
Ndb *ndb= ((Thd_ndb*)current_thd->transaction.thd_ndb)->ndb;
|
||||
Ndb *ndb= get_ndb();
|
||||
if (!ndb)
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
|
@ -697,7 +706,8 @@ bool ha_ndbcluster::uses_blob_value(bool all_fields)
|
|||
|
||||
int ha_ndbcluster::get_metadata(const char *path)
|
||||
{
|
||||
NDBDICT *dict= m_ndb->getDictionary();
|
||||
Ndb *ndb= get_ndb();
|
||||
NDBDICT *dict= ndb->getDictionary();
|
||||
const NDBTAB *tab;
|
||||
int error;
|
||||
bool invalidating_ndb_table= FALSE;
|
||||
|
@ -772,7 +782,8 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
|
|||
static const char* unique_suffix= "$unique";
|
||||
KEY* key_info= tab->key_info;
|
||||
const char **key_name= tab->keynames.type_names;
|
||||
NdbDictionary::Dictionary *dict= m_ndb->getDictionary();
|
||||
Ndb *ndb= get_ndb();
|
||||
NdbDictionary::Dictionary *dict= ndb->getDictionary();
|
||||
DBUG_ENTER("ha_ndbcluster::build_index_list");
|
||||
|
||||
// Save information about all known indexes
|
||||
|
@ -1775,7 +1786,8 @@ int ha_ndbcluster::write_row(byte *record)
|
|||
if (table->primary_key == MAX_KEY)
|
||||
{
|
||||
// Table has hidden primary key
|
||||
Uint64 auto_value= m_ndb->getAutoIncrementValue((const NDBTAB *) m_table);
|
||||
Ndb *ndb= get_ndb();
|
||||
Uint64 auto_value= ndb->getAutoIncrementValue((const NDBTAB *) m_table);
|
||||
if (set_hidden_key(op, table->fields, (const byte*)&auto_value))
|
||||
ERR_RETURN(op->getNdbError());
|
||||
}
|
||||
|
@ -1852,11 +1864,12 @@ int ha_ndbcluster::write_row(byte *record)
|
|||
}
|
||||
if ((has_auto_increment) && (m_skip_auto_increment))
|
||||
{
|
||||
Ndb *ndb= get_ndb();
|
||||
Uint64 next_val= (Uint64) table->next_number_field->val_int() + 1;
|
||||
DBUG_PRINT("info",
|
||||
("Trying to set next auto increment value to %lu",
|
||||
(ulong) next_val));
|
||||
if (m_ndb->setAutoIncrementValue((const NDBTAB *) m_table, next_val, TRUE))
|
||||
if (ndb->setAutoIncrementValue((const NDBTAB *) m_table, next_val, TRUE))
|
||||
DBUG_PRINT("info",
|
||||
("Setting next auto increment value to %u", next_val));
|
||||
}
|
||||
|
@ -2723,9 +2736,12 @@ void ha_ndbcluster::info(uint flag)
|
|||
}
|
||||
else
|
||||
{
|
||||
Uint64 rows= 100;
|
||||
if ((my_errno= check_ndb_connection()))
|
||||
DBUG_VOID_RETURN;
|
||||
Ndb *ndb= get_ndb();
|
||||
Uint64 rows;
|
||||
if (current_thd->variables.ndb_use_exact_count)
|
||||
ndb_get_table_statistics(m_ndb, m_tabname, &rows, 0);
|
||||
ndb_get_table_statistics(ndb, m_tabname, &rows, 0);
|
||||
records= rows;
|
||||
}
|
||||
}
|
||||
|
@ -3054,6 +3070,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
|
|||
DBUG_RETURN(1);
|
||||
|
||||
Thd_ndb *thd_ndb= (Thd_ndb*)thd->transaction.thd_ndb;
|
||||
Ndb *ndb= thd_ndb->ndb;
|
||||
|
||||
DBUG_PRINT("enter", ("transaction.thd_ndb->lock_count: %d",
|
||||
thd_ndb->lock_count));
|
||||
|
@ -3071,9 +3088,9 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
|
|||
DBUG_ASSERT(!thd->transaction.stmt.ndb_tid);
|
||||
DBUG_PRINT("trans",("Starting transaction stmt"));
|
||||
|
||||
trans= m_ndb->startTransaction();
|
||||
trans= ndb->startTransaction();
|
||||
if (trans == NULL)
|
||||
ERR_RETURN(m_ndb->getNdbError());
|
||||
ERR_RETURN(ndb->getNdbError());
|
||||
no_uncommitted_rows_reset(thd);
|
||||
thd->transaction.stmt.ndb_tid= trans;
|
||||
}
|
||||
|
@ -3085,9 +3102,9 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
|
|||
// A "master" transaction ha not been started yet
|
||||
DBUG_PRINT("trans",("starting transaction, all"));
|
||||
|
||||
trans= m_ndb->startTransaction();
|
||||
trans= ndb->startTransaction();
|
||||
if (trans == NULL)
|
||||
ERR_RETURN(m_ndb->getNdbError());
|
||||
ERR_RETURN(ndb->getNdbError());
|
||||
no_uncommitted_rows_reset(thd);
|
||||
|
||||
/*
|
||||
|
@ -3137,7 +3154,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
|
|||
m_retrieve_primary_key= FALSE;
|
||||
m_ops_pending= 0;
|
||||
{
|
||||
NDBDICT *dict= m_ndb->getDictionary();
|
||||
NDBDICT *dict= ndb->getDictionary();
|
||||
const NDBTAB *tab;
|
||||
void *tab_info;
|
||||
if (!(tab= dict->getTable(m_tabname, &tab_info)))
|
||||
|
@ -3164,7 +3181,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
|
|||
We must in this case close the transaction to release resources
|
||||
*/
|
||||
DBUG_PRINT("trans",("ending non-updating transaction"));
|
||||
m_ndb->closeTransaction(m_active_trans);
|
||||
ndb->closeTransaction(m_active_trans);
|
||||
thd->transaction.stmt.ndb_tid= 0;
|
||||
}
|
||||
}
|
||||
|
@ -3214,16 +3231,17 @@ int ha_ndbcluster::start_stmt(THD *thd)
|
|||
|
||||
NdbConnection *trans= (NdbConnection*)thd->transaction.stmt.ndb_tid;
|
||||
if (!trans){
|
||||
Ndb *ndb= ((Thd_ndb*)thd->transaction.thd_ndb)->ndb;
|
||||
DBUG_PRINT("trans",("Starting transaction stmt"));
|
||||
|
||||
NdbConnection *tablock_trans=
|
||||
(NdbConnection*)thd->transaction.all.ndb_tid;
|
||||
DBUG_PRINT("info", ("tablock_trans: %x", (uint)tablock_trans));
|
||||
DBUG_ASSERT(tablock_trans);
|
||||
// trans= m_ndb->hupp(tablock_trans);
|
||||
trans= m_ndb->startTransaction();
|
||||
// trans= ndb->hupp(tablock_trans);
|
||||
trans= ndb->startTransaction();
|
||||
if (trans == NULL)
|
||||
ERR_RETURN(m_ndb->getNdbError());
|
||||
ERR_RETURN(ndb->getNdbError());
|
||||
no_uncommitted_rows_reset(thd);
|
||||
thd->transaction.stmt.ndb_tid= trans;
|
||||
}
|
||||
|
@ -3616,7 +3634,8 @@ int ha_ndbcluster::create(const char *name,
|
|||
DBUG_RETURN(my_errno);
|
||||
|
||||
// Create the table in NDB
|
||||
NDBDICT *dict= m_ndb->getDictionary();
|
||||
Ndb *ndb= get_ndb();
|
||||
NDBDICT *dict= ndb->getDictionary();
|
||||
if (dict->createTable(tab) != 0)
|
||||
{
|
||||
const NdbError err= dict->getNdbError();
|
||||
|
@ -3661,7 +3680,8 @@ int ha_ndbcluster::create_index(const char *name,
|
|||
KEY *key_info,
|
||||
bool unique)
|
||||
{
|
||||
NdbDictionary::Dictionary *dict= m_ndb->getDictionary();
|
||||
Ndb *ndb= get_ndb();
|
||||
NdbDictionary::Dictionary *dict= ndb->getDictionary();
|
||||
KEY_PART_INFO *key_part= key_info->key_part;
|
||||
KEY_PART_INFO *end= key_part + key_info->key_parts;
|
||||
|
||||
|
@ -3720,14 +3740,15 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
|
|||
if (check_ndb_connection())
|
||||
DBUG_RETURN(my_errno= HA_ERR_NO_CONNECTION);
|
||||
|
||||
dict= m_ndb->getDictionary();
|
||||
Ndb *ndb= get_ndb();
|
||||
dict= ndb->getDictionary();
|
||||
if (!(orig_tab= dict->getTable(m_tabname)))
|
||||
ERR_RETURN(dict->getNdbError());
|
||||
|
||||
m_table= (void *)orig_tab;
|
||||
// Change current database to that of target table
|
||||
set_dbname(to);
|
||||
m_ndb->setDatabaseName(m_dbname);
|
||||
ndb->setDatabaseName(m_dbname);
|
||||
if (!(result= alter_table_name(new_tabname)))
|
||||
{
|
||||
// Rename .ndb file
|
||||
|
@ -3744,7 +3765,8 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
|
|||
|
||||
int ha_ndbcluster::alter_table_name(const char *to)
|
||||
{
|
||||
NDBDICT * dict= m_ndb->getDictionary();
|
||||
Ndb *ndb= get_ndb();
|
||||
NDBDICT *dict= ndb->getDictionary();
|
||||
const NDBTAB *orig_tab= (const NDBTAB *) m_table;
|
||||
int ret;
|
||||
DBUG_ENTER("alter_table_name_table");
|
||||
|
@ -3786,8 +3808,9 @@ int ha_ndbcluster::delete_table(const char *name)
|
|||
|
||||
int ha_ndbcluster::drop_table()
|
||||
{
|
||||
NdbDictionary::Dictionary *dict= m_ndb->getDictionary();
|
||||
|
||||
Ndb *ndb= get_ndb();
|
||||
NdbDictionary::Dictionary *dict= ndb->getDictionary();
|
||||
|
||||
DBUG_ENTER("drop_table");
|
||||
DBUG_PRINT("enter", ("Deleting %s", m_tabname));
|
||||
|
||||
|
@ -3822,6 +3845,7 @@ ulonglong ha_ndbcluster::get_auto_increment()
|
|||
Uint64 auto_value;
|
||||
DBUG_ENTER("get_auto_increment");
|
||||
DBUG_PRINT("enter", ("m_tabname: %s", m_tabname));
|
||||
Ndb *ndb= get_ndb();
|
||||
cache_size=
|
||||
(m_rows_to_insert - m_rows_inserted < m_autoincrement_prefetch) ?
|
||||
m_rows_to_insert - m_rows_inserted
|
||||
|
@ -3830,8 +3854,8 @@ ulonglong ha_ndbcluster::get_auto_increment()
|
|||
: m_autoincrement_prefetch;
|
||||
auto_value=
|
||||
(m_skip_auto_increment) ?
|
||||
m_ndb->readAutoIncrementValue((const NDBTAB *) m_table)
|
||||
: m_ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size);
|
||||
ndb->readAutoIncrementValue((const NDBTAB *) m_table)
|
||||
: ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size);
|
||||
DBUG_RETURN((longlong)auto_value);
|
||||
}
|
||||
|
||||
|
@ -3845,7 +3869,6 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
|
|||
m_active_trans(NULL),
|
||||
m_active_cursor(NULL),
|
||||
m_multi_cursor(NULL),
|
||||
m_ndb(NULL),
|
||||
m_table(NULL),
|
||||
m_table_info(NULL),
|
||||
m_table_flags(HA_REC_NOT_IN_SEQ |
|
||||
|
@ -3977,7 +4000,6 @@ int ha_ndbcluster::close(void)
|
|||
DBUG_ENTER("close");
|
||||
free_share(m_share); m_share= 0;
|
||||
release_metadata();
|
||||
m_ndb= NULL;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
@ -4039,11 +4061,12 @@ Ndb* check_ndb_in_thd(THD* thd)
|
|||
int ha_ndbcluster::check_ndb_connection()
|
||||
{
|
||||
THD* thd= current_thd;
|
||||
Ndb *ndb;
|
||||
DBUG_ENTER("check_ndb_connection");
|
||||
|
||||
if (!(m_ndb= check_ndb_in_thd(thd)))
|
||||
if (!(ndb= check_ndb_in_thd(thd)))
|
||||
DBUG_RETURN(HA_ERR_NO_CONNECTION);
|
||||
m_ndb->setDatabaseName(m_dbname);
|
||||
ndb->setDatabaseName(m_dbname);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,6 @@ class ha_ndbcluster: public handler
|
|||
|
||||
NdbTransaction *m_active_trans;
|
||||
NdbScanOperation *m_active_cursor;
|
||||
Ndb *m_ndb;
|
||||
void *m_table;
|
||||
void *m_table_info;
|
||||
char m_dbname[FN_HEADLEN];
|
||||
|
@ -265,6 +264,7 @@ class ha_ndbcluster: public handler
|
|||
byte *m_multi_range_cursor_result_ptr;
|
||||
int setup_recattr(const NdbRecAttr*);
|
||||
|
||||
Ndb *get_ndb();
|
||||
void set_rec_per_key();
|
||||
void records_update();
|
||||
void no_uncommitted_rows_execute_failure();
|
||||
|
|
|
@ -1185,21 +1185,29 @@ String *Item_func_substr_index::val_str(String *str)
|
|||
String *Item_func_ltrim::val_str(String *str)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
String *res =args[0]->val_str(str);
|
||||
if ((null_value=args[0]->null_value))
|
||||
return 0; /* purecov: inspected */
|
||||
char buff[MAX_FIELD_WIDTH];
|
||||
String tmp(buff,sizeof(buff),res->charset());
|
||||
String *remove_str= (arg_count==2) ? args[1]->val_str(&tmp) : &remove;
|
||||
char buff[MAX_FIELD_WIDTH], *ptr, *end;
|
||||
String tmp(buff,sizeof(buff),system_charset_info);
|
||||
String *res, *remove_str;
|
||||
uint remove_length;
|
||||
LINT_INIT(remove_length);
|
||||
|
||||
if (!remove_str || (remove_length=remove_str->length()) == 0 ||
|
||||
res= args[0]->val_str(str);
|
||||
if ((null_value=args[0]->null_value))
|
||||
return 0;
|
||||
remove_str= &remove; /* Default value. */
|
||||
if (arg_count == 2)
|
||||
{
|
||||
remove_str= args[1]->val_str(&tmp);
|
||||
if ((null_value= args[1]->null_value))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((remove_length= remove_str->length()) == 0 ||
|
||||
remove_length > res->length())
|
||||
return res;
|
||||
|
||||
char *ptr=(char*) res->ptr();
|
||||
char *end=ptr+res->length();
|
||||
ptr= (char*) res->ptr();
|
||||
end= ptr+res->length();
|
||||
if (remove_length == 1)
|
||||
{
|
||||
char chr=(*remove_str)[0];
|
||||
|
@ -1224,21 +1232,29 @@ String *Item_func_ltrim::val_str(String *str)
|
|||
String *Item_func_rtrim::val_str(String *str)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
String *res =args[0]->val_str(str);
|
||||
if ((null_value=args[0]->null_value))
|
||||
return 0; /* purecov: inspected */
|
||||
char buff[MAX_FIELD_WIDTH];
|
||||
String tmp(buff,sizeof(buff),res->charset());
|
||||
String *remove_str= (arg_count==2) ? args[1]->val_str(&tmp) : &remove;
|
||||
char buff[MAX_FIELD_WIDTH], *ptr, *end;
|
||||
String tmp(buff, sizeof(buff), system_charset_info);
|
||||
String *res, *remove_str;
|
||||
uint remove_length;
|
||||
LINT_INIT(remove_length);
|
||||
|
||||
if (!remove_str || (remove_length=remove_str->length()) == 0 ||
|
||||
res= args[0]->val_str(str);
|
||||
if ((null_value=args[0]->null_value))
|
||||
return 0;
|
||||
remove_str= &remove; /* Default value. */
|
||||
if (arg_count == 2)
|
||||
{
|
||||
remove_str= args[1]->val_str(&tmp);
|
||||
if ((null_value= args[1]->null_value))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((remove_length= remove_str->length()) == 0 ||
|
||||
remove_length > res->length())
|
||||
return res;
|
||||
|
||||
char *ptr=(char*) res->ptr();
|
||||
char *end=ptr+res->length();
|
||||
ptr= (char*) res->ptr();
|
||||
end= ptr+res->length();
|
||||
#ifdef USE_MB
|
||||
char *p=ptr;
|
||||
register uint32 l;
|
||||
|
@ -1297,31 +1313,31 @@ String *Item_func_rtrim::val_str(String *str)
|
|||
String *Item_func_trim::val_str(String *str)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
String *res =args[0]->val_str(str);
|
||||
if ((null_value=args[0]->null_value))
|
||||
return 0; /* purecov: inspected */
|
||||
char buff[MAX_FIELD_WIDTH];
|
||||
String tmp(buff,sizeof(buff),res->charset());
|
||||
char buff[MAX_FIELD_WIDTH], *ptr, *end;
|
||||
const char *r_ptr;
|
||||
String tmp(buff, sizeof(buff), system_charset_info);
|
||||
String *res, *remove_str;
|
||||
uint remove_length;
|
||||
LINT_INIT(remove_length);
|
||||
String *remove_str; /* The string to remove from res. */
|
||||
|
||||
res= args[0]->val_str(str);
|
||||
if ((null_value=args[0]->null_value))
|
||||
return 0;
|
||||
remove_str= &remove; /* Default value. */
|
||||
if (arg_count == 2)
|
||||
{
|
||||
remove_str= args[1]->val_str(&tmp);
|
||||
if ((null_value= args[1]->null_value))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
remove_str= &remove; /* Default value. */
|
||||
|
||||
if (!remove_str || (remove_length=remove_str->length()) == 0 ||
|
||||
if ((remove_length= remove_str->length()) == 0 ||
|
||||
remove_length > res->length())
|
||||
return res;
|
||||
|
||||
char *ptr=(char*) res->ptr();
|
||||
char *end=ptr+res->length();
|
||||
const char *r_ptr=remove_str->ptr();
|
||||
ptr= (char*) res->ptr();
|
||||
end= ptr+res->length();
|
||||
r_ptr= remove_str->ptr();
|
||||
while (ptr+remove_length <= end && !memcmp(ptr,r_ptr,remove_length))
|
||||
ptr+=remove_length;
|
||||
#ifdef USE_MB
|
||||
|
|
|
@ -303,12 +303,6 @@ Item_sum_sum_distinct::Item_sum_sum_distinct(THD *thd,
|
|||
}
|
||||
|
||||
|
||||
Item_sum_sum_distinct::~Item_sum_sum_distinct()
|
||||
{
|
||||
delete tree;
|
||||
}
|
||||
|
||||
|
||||
Item *
|
||||
Item_sum_sum_distinct::copy_or_same(THD *thd)
|
||||
{
|
||||
|
@ -356,6 +350,14 @@ void Item_sum_sum_distinct::clear()
|
|||
tree->reset();
|
||||
}
|
||||
|
||||
void Item_sum_sum_distinct::cleanup()
|
||||
{
|
||||
Item_sum_num::cleanup();
|
||||
delete tree;
|
||||
tree= 0;
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_sum_distinct::add()
|
||||
{
|
||||
/* args[0]->val_real() may reset args[0]->null_value */
|
||||
|
|
|
@ -167,10 +167,11 @@ private:
|
|||
Item_sum_sum_distinct(THD *thd, Item_sum_sum_distinct *item);
|
||||
public:
|
||||
Item_sum_sum_distinct(Item *item_par);
|
||||
~Item_sum_sum_distinct();
|
||||
~Item_sum_sum_distinct() {}
|
||||
|
||||
bool setup(THD *thd);
|
||||
void clear();
|
||||
void cleanup();
|
||||
bool add();
|
||||
double val_real();
|
||||
|
||||
|
|
|
@ -248,6 +248,8 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
|
|||
#define OPTION_RELAXED_UNIQUE_CHECKS (1L << 27)
|
||||
#define SELECT_NO_UNLOCK (1L << 28)
|
||||
#define OPTION_SCHEMA_TABLE (1L << 29)
|
||||
/* Flag set if setup_tables already done */
|
||||
#define OPTION_SETUP_TABLES_DONE (1L << 30)
|
||||
|
||||
/* The rest of the file is included in the server only */
|
||||
#ifndef MYSQL_CLIENT
|
||||
|
@ -565,7 +567,8 @@ int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
|
|||
List<Item> &fields, List<Item> &all_fields, ORDER *order,
|
||||
bool *hidden_group_fields);
|
||||
|
||||
bool handle_select(THD *thd, LEX *lex, select_result *result);
|
||||
bool handle_select(THD *thd, LEX *lex, select_result *result,
|
||||
ulong setup_tables_done_option);
|
||||
bool mysql_select(THD *thd, Item ***rref_pointer_array,
|
||||
TABLE_LIST *tables, uint wild_num, List<Item> &list,
|
||||
COND *conds, uint og_num, ORDER *order, ORDER *group,
|
||||
|
@ -578,7 +581,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit,
|
|||
int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type,
|
||||
select_result *result);
|
||||
bool mysql_union(THD *thd, LEX *lex, select_result *result,
|
||||
SELECT_LEX_UNIT *unit);
|
||||
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
|
||||
int mysql_handle_derived(LEX *lex, int (*processor)(THD *thd,
|
||||
LEX *lex,
|
||||
TABLE_LIST *table));
|
||||
|
|
|
@ -1069,6 +1069,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
|
|||
table->outer_join= table->null_row= table->maybe_null= table->force_index= 0;
|
||||
table->status=STATUS_NO_RECORD;
|
||||
table->keys_in_use_for_query= table->keys_in_use;
|
||||
table->insert_values= 0;
|
||||
table->used_keys= table->keys_for_keyread;
|
||||
if (table->timestamp_field)
|
||||
table->timestamp_field_type= table->timestamp_field->get_auto_set_type();
|
||||
|
@ -2793,10 +2794,6 @@ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds,
|
|||
TABLE_LIST *first_select_table= (select_insert ?
|
||||
tables->next_local:
|
||||
0);
|
||||
if (!tables || tables->setup_is_done)
|
||||
DBUG_RETURN(0);
|
||||
tables->setup_is_done= 1;
|
||||
|
||||
if (!(*leaves))
|
||||
make_leaves_list(leaves, tables);
|
||||
|
||||
|
|
|
@ -501,7 +501,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
|||
::send_ok(thd, (ulong) thd->row_count_func, id, buff);
|
||||
}
|
||||
free_underlaid_joins(thd, &thd->lex->select_lex);
|
||||
table_list->clear_insert_values();
|
||||
thd->abort_on_warning= 0;
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
|
@ -511,7 +510,6 @@ abort:
|
|||
end_delayed_insert(thd);
|
||||
#endif
|
||||
free_underlaid_joins(thd, &thd->lex->select_lex);
|
||||
table_list->clear_insert_values();
|
||||
thd->abort_on_warning= 0;
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
@ -1737,12 +1735,6 @@ bool mysql_insert_select_prepare(THD *thd)
|
|||
&lex->select_lex.where, TRUE))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
/*
|
||||
setup was done in mysql_prepare_insert_check_table, but we have to mark
|
||||
first local table
|
||||
*/
|
||||
if (first_select_table)
|
||||
first_select_table->setup_is_done= 1;
|
||||
/*
|
||||
exclude first table from leaf tables list, because it belong to
|
||||
INSERT
|
||||
|
|
|
@ -2212,7 +2212,7 @@ mysql_execute_command(THD *thd)
|
|||
if (!result && !(result= new select_send()))
|
||||
goto error;
|
||||
query_cache_store_query(thd, all_tables);
|
||||
res= handle_select(thd, lex, result);
|
||||
res= handle_select(thd, lex, result, 0);
|
||||
if (result != lex->result)
|
||||
delete result;
|
||||
}
|
||||
|
@ -2635,7 +2635,7 @@ mysql_execute_command(THD *thd)
|
|||
and item_list belong to SELECT
|
||||
*/
|
||||
select_lex->resolve_mode= SELECT_LEX::SELECT_MODE;
|
||||
res=handle_select(thd, lex, result);
|
||||
res= handle_select(thd, lex, result, 0);
|
||||
select_lex->resolve_mode= SELECT_LEX::NOMATTER_MODE;
|
||||
delete result;
|
||||
}
|
||||
|
@ -3005,13 +3005,10 @@ create_error:
|
|||
and item_list belong to SELECT
|
||||
*/
|
||||
lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE;
|
||||
res= handle_select(thd, lex, result);
|
||||
res= handle_select(thd, lex, result, OPTION_SETUP_TABLES_DONE);
|
||||
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
|
||||
delete result;
|
||||
}
|
||||
/* in case of error first_table->table can be 0 */
|
||||
if (first_table->table)
|
||||
first_table->table->insert_values= 0;
|
||||
/* revert changes for SP */
|
||||
lex->select_lex.table_list.first= (byte*) first_table;
|
||||
}
|
||||
|
@ -3095,7 +3092,8 @@ create_error:
|
|||
0, (ORDER *)NULL, (ORDER *)NULL, (Item *)NULL,
|
||||
(ORDER *)NULL,
|
||||
select_lex->options | thd->options |
|
||||
SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK,
|
||||
SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK |
|
||||
OPTION_SETUP_TABLES_DONE,
|
||||
result, unit, select_lex);
|
||||
delete result;
|
||||
}
|
||||
|
|
|
@ -908,7 +908,11 @@ static bool mysql_test_insert(Prepared_statement *stmt,
|
|||
Item *unused_conds= 0;
|
||||
|
||||
if (table_list->table)
|
||||
table_list->table->insert_values=(byte *)1; // don't allocate insert_values
|
||||
{
|
||||
// don't allocate insert_values
|
||||
table_list->table->insert_values=(byte *)1;
|
||||
}
|
||||
|
||||
if ((res= mysql_prepare_insert(thd, table_list, table_list->table,
|
||||
fields, values, update_fields,
|
||||
update_values, duplic,
|
||||
|
@ -934,8 +938,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
|
|||
res= 0;
|
||||
error:
|
||||
lex->unit.cleanup();
|
||||
if (table_list->table)
|
||||
table_list->table->insert_values=0;
|
||||
/* insert_values is cleared in open_table */
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
@ -1040,6 +1043,7 @@ static int mysql_test_delete(Prepared_statement *stmt,
|
|||
|
||||
if (!open_and_lock_tables(thd, table_list))
|
||||
{
|
||||
bool res;
|
||||
if (!table_list->table)
|
||||
{
|
||||
DBUG_ASSERT(table_list->view &&
|
||||
|
@ -1049,9 +1053,9 @@ static int mysql_test_delete(Prepared_statement *stmt,
|
|||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
mysql_prepare_delete(thd, table_list, &lex->select_lex.where);
|
||||
res= mysql_prepare_delete(thd, table_list, &lex->select_lex.where);
|
||||
lex->unit.cleanup();
|
||||
DBUG_RETURN(FALSE);
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
/* TODO: here we should send types of placeholders to the client. */
|
||||
DBUG_RETURN(TRUE);
|
||||
|
@ -1103,7 +1107,11 @@ static int mysql_test_select(Prepared_statement *stmt,
|
|||
|
||||
thd->used_tables= 0; // Updated by setup_fields
|
||||
|
||||
// JOIN::prepare calls
|
||||
/*
|
||||
JOIN::prepare calls
|
||||
It is not SELECT COMMAND for sure, so setup_tables will be called as
|
||||
usual, and we pass 0 as setup_tables_done_option
|
||||
*/
|
||||
if (unit->prepare(thd, 0, 0))
|
||||
{
|
||||
goto err_prep;
|
||||
|
@ -1236,7 +1244,8 @@ error:
|
|||
*/
|
||||
static bool select_like_statement_test(Prepared_statement *stmt,
|
||||
TABLE_LIST *tables,
|
||||
bool (*specific_prepare)(THD *thd))
|
||||
bool (*specific_prepare)(THD *thd),
|
||||
ulong setup_tables_done_option)
|
||||
{
|
||||
DBUG_ENTER("select_like_statement_test");
|
||||
THD *thd= stmt->thd;
|
||||
|
@ -1255,7 +1264,7 @@ static bool select_like_statement_test(Prepared_statement *stmt,
|
|||
thd->used_tables= 0; // Updated by setup_fields
|
||||
|
||||
// JOIN::prepare calls
|
||||
if (lex->unit.prepare(thd, 0, 0))
|
||||
if (lex->unit.prepare(thd, 0, setup_tables_done_option))
|
||||
{
|
||||
res= TRUE;
|
||||
}
|
||||
|
@ -1295,7 +1304,7 @@ static int mysql_test_create_table(Prepared_statement *stmt)
|
|||
select_lex->item_list.elements)
|
||||
{
|
||||
select_lex->resolve_mode= SELECT_LEX::SELECT_MODE;
|
||||
res= select_like_statement_test(stmt, tables, 0);
|
||||
res= select_like_statement_test(stmt, tables, 0, 0);
|
||||
select_lex->resolve_mode= SELECT_LEX::NOMATTER_MODE;
|
||||
}
|
||||
|
||||
|
@ -1330,7 +1339,8 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt,
|
|||
here we do not pass tables for opening, tables will be opened and locked
|
||||
by mysql_multi_update_prepare
|
||||
*/
|
||||
return select_like_statement_test(stmt, 0, &mysql_multi_update_prepare);
|
||||
return select_like_statement_test(stmt, 0, &mysql_multi_update_prepare,
|
||||
OPTION_SETUP_TABLES_DONE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1359,7 +1369,8 @@ static int mysql_test_multidelete(Prepared_statement *stmt,
|
|||
if ((res= multi_delete_precheck(stmt->thd, tables, &fake_counter)))
|
||||
return res;
|
||||
if ((res= select_like_statement_test(stmt, tables,
|
||||
&mysql_multi_delete_prepare)))
|
||||
&mysql_multi_delete_prepare,
|
||||
OPTION_SETUP_TABLES_DONE)))
|
||||
return res;
|
||||
if (!tables->table)
|
||||
{
|
||||
|
@ -1401,13 +1412,19 @@ static int mysql_test_insert_select(Prepared_statement *stmt,
|
|||
DBUG_ASSERT(first_local_table != 0);
|
||||
/* Skip first table, which is the table we are inserting in */
|
||||
lex->select_lex.table_list.first= (byte*) first_local_table->next_local;
|
||||
if (tables->table)
|
||||
{
|
||||
// don't allocate insert_values
|
||||
tables->table->insert_values=(byte *)1;
|
||||
}
|
||||
|
||||
/*
|
||||
insert/replace from SELECT give its SELECT_LEX for SELECT,
|
||||
and item_list belong to SELECT
|
||||
*/
|
||||
lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE;
|
||||
res= select_like_statement_test(stmt, tables, &mysql_insert_select_prepare);
|
||||
res= select_like_statement_test(stmt, tables, &mysql_insert_select_prepare,
|
||||
OPTION_SETUP_TABLES_DONE);
|
||||
/* revert changes*/
|
||||
lex->select_lex.table_list.first= (byte*) first_local_table;
|
||||
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
|
||||
|
@ -1762,11 +1779,6 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
|
|||
for (order= (ORDER *)sl->order_list.first; order; order= order->next)
|
||||
order->item= &order->item_ptr;
|
||||
}
|
||||
{
|
||||
TABLE_LIST *tables= (TABLE_LIST *)sl->table_list.first;
|
||||
if (tables)
|
||||
tables->setup_is_done= 0;
|
||||
}
|
||||
{
|
||||
SELECT_LEX_UNIT *unit= sl->master_unit();
|
||||
unit->unclean();
|
||||
|
|
|
@ -206,18 +206,24 @@ static void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
|
|||
This handles SELECT with and without UNION
|
||||
*/
|
||||
|
||||
bool handle_select(THD *thd, LEX *lex, select_result *result)
|
||||
bool handle_select(THD *thd, LEX *lex, select_result *result,
|
||||
ulong setup_tables_done_option)
|
||||
{
|
||||
bool res;
|
||||
register SELECT_LEX *select_lex = &lex->select_lex;
|
||||
DBUG_ENTER("handle_select");
|
||||
|
||||
if (select_lex->next_select())
|
||||
res= mysql_union(thd, lex, result, &lex->unit);
|
||||
res= mysql_union(thd, lex, result, &lex->unit, setup_tables_done_option);
|
||||
else
|
||||
{
|
||||
SELECT_LEX_UNIT *unit= &lex->unit;
|
||||
unit->set_limit(unit->global_parameters, select_lex);
|
||||
/*
|
||||
'options' of mysql_select will be set in JOIN, as far as JOIN for
|
||||
every PS/SP execution new, we will not need reset this flag if
|
||||
setup_tables_done_option changed for next rexecution
|
||||
*/
|
||||
res= mysql_select(thd, &select_lex->ref_pointer_array,
|
||||
(TABLE_LIST*) select_lex->table_list.first,
|
||||
select_lex->with_wild, select_lex->item_list,
|
||||
|
@ -228,7 +234,8 @@ bool handle_select(THD *thd, LEX *lex, select_result *result)
|
|||
(ORDER*) select_lex->group_list.first,
|
||||
select_lex->having,
|
||||
(ORDER*) lex->proc_list.first,
|
||||
select_lex->options | thd->options,
|
||||
select_lex->options | thd->options |
|
||||
setup_tables_done_option,
|
||||
result, unit, select_lex);
|
||||
}
|
||||
DBUG_PRINT("info",("res: %d report_error: %d", res,
|
||||
|
@ -311,8 +318,9 @@ JOIN::prepare(Item ***rref_pointer_array,
|
|||
|
||||
/* Check that all tables, fields, conds and order are ok */
|
||||
|
||||
if (setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables,
|
||||
FALSE, FALSE) ||
|
||||
if ((!(select_options & OPTION_SETUP_TABLES_DONE) &&
|
||||
setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables,
|
||||
FALSE, FALSE)) ||
|
||||
setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) ||
|
||||
select_lex->setup_ref_array(thd, og_num) ||
|
||||
setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1,
|
||||
|
@ -1082,7 +1090,6 @@ JOIN::reinit()
|
|||
/* conds should not be used here, it is added just for safety */
|
||||
if (tables_list)
|
||||
{
|
||||
tables_list->setup_is_done= 0;
|
||||
if (setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables,
|
||||
TRUE, FALSE))
|
||||
DBUG_RETURN(1);
|
||||
|
|
|
@ -25,11 +25,12 @@
|
|||
#include "sql_select.h"
|
||||
|
||||
bool mysql_union(THD *thd, LEX *lex, select_result *result,
|
||||
SELECT_LEX_UNIT *unit)
|
||||
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option)
|
||||
{
|
||||
DBUG_ENTER("mysql_union");
|
||||
bool res;
|
||||
if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK)))
|
||||
if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK |
|
||||
setup_tables_done_option)))
|
||||
res= unit->exec();
|
||||
if (!res && thd->cursor && thd->cursor->is_open())
|
||||
{
|
||||
|
@ -210,6 +211,13 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
|
|||
JOIN *join= new JOIN(thd_arg, sl->item_list,
|
||||
sl->options | thd_arg->options | additional_options,
|
||||
tmp_result);
|
||||
/*
|
||||
setup_tables_done_option should be set only for very first SELECT,
|
||||
because it protect from secont setup_tables call for select-like non
|
||||
select commands (DELETE/INSERT/...) and they use only very first
|
||||
SELECT (for union it can be only INSERT ... SELECT).
|
||||
*/
|
||||
additional_options&= ~OPTION_SETUP_TABLES_DONE;
|
||||
if (!join)
|
||||
goto err;
|
||||
|
||||
|
|
|
@ -771,9 +771,6 @@ bool mysql_multi_update_prepare(THD *thd)
|
|||
for (TABLE_LIST *tbl= table_list; tbl; tbl= tbl->next_global)
|
||||
tbl->cleanup_items();
|
||||
|
||||
/* undone setup_tables() */
|
||||
table_list->setup_is_done= 0;
|
||||
|
||||
if (setup_tables(thd, table_list, &lex->select_lex.where,
|
||||
&lex->select_lex.leaf_tables, FALSE, FALSE) ||
|
||||
(lex->select_lex.no_wrap_view_item= 1,
|
||||
|
@ -842,7 +839,8 @@ bool mysql_multi_update(THD *thd,
|
|||
total_list,
|
||||
conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL,
|
||||
(ORDER *)NULL,
|
||||
options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK,
|
||||
options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK |
|
||||
OPTION_SETUP_TABLES_DONE,
|
||||
result, unit, select_lex);
|
||||
delete result;
|
||||
thd->abort_on_warning= 0;
|
||||
|
|
20
sql/table.cc
20
sql/table.cc
|
@ -2026,26 +2026,6 @@ bool st_table_list::set_insert_values(MEM_ROOT *mem_root)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
clear insert_values reference
|
||||
|
||||
SYNOPSIS
|
||||
clear_insert_values()
|
||||
*/
|
||||
|
||||
void st_table_list::clear_insert_values()
|
||||
{
|
||||
if (table)
|
||||
table->insert_values= 0;
|
||||
else
|
||||
{
|
||||
DBUG_ASSERT(view && ancestor && ancestor->next_local);
|
||||
for (TABLE_LIST *tbl= ancestor; tbl; tbl= tbl->next_local)
|
||||
tbl->clear_insert_values();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Field_iterator_view::set(TABLE_LIST *table)
|
||||
{
|
||||
ptr= table->field_translation;
|
||||
|
|
|
@ -369,7 +369,6 @@ typedef struct st_table_list
|
|||
/* used in multi-upd/views privilege check */
|
||||
bool table_in_first_from_clause;
|
||||
bool skip_temporary; /* this table shouldn't be temporary */
|
||||
bool setup_is_done; /* setup_tables() is done */
|
||||
/* TRUE if this merged view contain auto_increment field */
|
||||
bool contain_auto_increment;
|
||||
/* FRMTYPE_ERROR if any type is acceptable */
|
||||
|
@ -387,7 +386,6 @@ typedef struct st_table_list
|
|||
void restore_want_privilege();
|
||||
bool check_single_table(st_table_list **table, table_map map);
|
||||
bool set_insert_values(MEM_ROOT *mem_root);
|
||||
void clear_insert_values();
|
||||
} TABLE_LIST;
|
||||
|
||||
class Item;
|
||||
|
|
|
@ -734,8 +734,8 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count)
|
|||
{
|
||||
ulonglong affected_rows= mysql_stmt_affected_rows(stmt);
|
||||
if (!opt_silent)
|
||||
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
|
||||
affected_rows, exp_count);
|
||||
fprintf(stdout, "\n total affected rows: `%ld` (expected: `%ld`)",
|
||||
(long) affected_rows, (long) exp_count);
|
||||
DIE_UNLESS(affected_rows == exp_count);
|
||||
}
|
||||
|
||||
|
@ -746,8 +746,8 @@ static void verify_affected_rows(ulonglong exp_count)
|
|||
{
|
||||
ulonglong affected_rows= mysql_affected_rows(mysql);
|
||||
if (!opt_silent)
|
||||
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
|
||||
affected_rows, exp_count);
|
||||
fprintf(stdout, "\n total affected rows: `%ld` (expected: `%ld`)",
|
||||
(long) affected_rows, (long) exp_count);
|
||||
DIE_UNLESS(affected_rows == exp_count);
|
||||
}
|
||||
|
||||
|
@ -780,8 +780,8 @@ static void execute_prepare_query(const char *query, ulonglong exp_count)
|
|||
|
||||
affected_rows= mysql_stmt_affected_rows(stmt);
|
||||
if (!opt_silent)
|
||||
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
|
||||
affected_rows, exp_count);
|
||||
fprintf(stdout, "\n total affected rows: `%ld` (expected: `%ld`)",
|
||||
(long) affected_rows, (long) exp_count);
|
||||
|
||||
DIE_UNLESS(affected_rows == exp_count);
|
||||
mysql_stmt_close(stmt);
|
||||
|
@ -1017,7 +1017,8 @@ my_bool fetch_n(const char **query_list, unsigned query_count)
|
|||
fprintf(stderr,
|
||||
"Got error reading rows from statement %d,\n"
|
||||
"query is: %s,\n"
|
||||
"error message: %s", fetch - fetch_array, fetch->query,
|
||||
"error message: %s", (int) (fetch - fetch_array),
|
||||
fetch->query,
|
||||
mysql_stmt_error(fetch->handle));
|
||||
error_count++;
|
||||
}
|
||||
|
@ -1479,6 +1480,7 @@ static void test_prepare()
|
|||
double double_data, o_double_data;
|
||||
ulong length[7], len;
|
||||
my_bool is_null[7];
|
||||
char llbuf[22];
|
||||
MYSQL_BIND bind[7];
|
||||
|
||||
myheader("test_prepare");
|
||||
|
@ -1596,7 +1598,8 @@ static void test_prepare()
|
|||
fprintf(stdout, "\n\t tiny : %d (%lu)", tiny_data, length[0]);
|
||||
fprintf(stdout, "\n\t short : %d (%lu)", small_data, length[3]);
|
||||
fprintf(stdout, "\n\t int : %d (%lu)", int_data, length[2]);
|
||||
fprintf(stdout, "\n\t big : %lld (%lu)", big_data, length[4]);
|
||||
fprintf(stdout, "\n\t big : %s (%lu)", llstr(big_data, llbuf),
|
||||
length[4]);
|
||||
|
||||
fprintf(stdout, "\n\t float : %f (%lu)", real_data, length[5]);
|
||||
fprintf(stdout, "\n\t double : %f (%lu)", double_data, length[6]);
|
||||
|
@ -3446,7 +3449,7 @@ static void test_bind_result_ext()
|
|||
MYSQL_BIND bind[8];
|
||||
ulong length[8];
|
||||
my_bool is_null[8];
|
||||
|
||||
char llbuf[22];
|
||||
myheader("test_bind_result_ext");
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result");
|
||||
|
@ -3520,7 +3523,7 @@ static void test_bind_result_ext()
|
|||
fprintf(stdout, "\n data (tiny) : %d", t_data);
|
||||
fprintf(stdout, "\n data (short) : %d", s_data);
|
||||
fprintf(stdout, "\n data (int) : %d", i_data);
|
||||
fprintf(stdout, "\n data (big) : %lld", b_data);
|
||||
fprintf(stdout, "\n data (big) : %s", llstr(b_data, llbuf));
|
||||
|
||||
fprintf(stdout, "\n data (float) : %f", f_data);
|
||||
fprintf(stdout, "\n data (double) : %f", d_data);
|
||||
|
@ -5286,7 +5289,7 @@ static void test_manual_sample()
|
|||
affected_rows= mysql_stmt_affected_rows(stmt);
|
||||
|
||||
if (!opt_silent)
|
||||
fprintf(stdout, "\n total affected rows: %lld", affected_rows);
|
||||
fprintf(stdout, "\n total affected rows: %ld", (ulong) affected_rows);
|
||||
if (affected_rows != 1) /* validate affected rows */
|
||||
{
|
||||
fprintf(stderr, "\n invalid affected rows by MySQL");
|
||||
|
@ -5311,7 +5314,7 @@ static void test_manual_sample()
|
|||
affected_rows= mysql_stmt_affected_rows(stmt);
|
||||
|
||||
if (!opt_silent)
|
||||
fprintf(stdout, "\n total affected rows: %lld", affected_rows);
|
||||
fprintf(stdout, "\n total affected rows: %ld", (ulong) affected_rows);
|
||||
if (affected_rows != 1) /* validate affected rows */
|
||||
{
|
||||
fprintf(stderr, "\n invalid affected rows by MySQL");
|
||||
|
@ -5467,9 +5470,9 @@ DROP TABLE IF EXISTS test_multi_tab";
|
|||
mysql_free_result(result);
|
||||
}
|
||||
else if (!opt_silent)
|
||||
fprintf(stdout, "OK, %lld row(s) affected, %d warning(s)\n",
|
||||
mysql_affected_rows(mysql_local),
|
||||
mysql_warning_count(mysql_local));
|
||||
fprintf(stdout, "OK, %ld row(s) affected, %ld warning(s)\n",
|
||||
(ulong) mysql_affected_rows(mysql_local),
|
||||
(ulong) mysql_warning_count(mysql_local));
|
||||
|
||||
exp_value= (uint) mysql_affected_rows(mysql_local);
|
||||
if (rows[count] != exp_value)
|
||||
|
@ -6549,7 +6552,7 @@ static void test_ushort_bug()
|
|||
ulonglong longlong_value;
|
||||
int rc;
|
||||
uchar tiny_value;
|
||||
|
||||
char llbuf[22];
|
||||
myheader("test_ushort_bug");
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_ushort");
|
||||
|
@ -6601,7 +6604,8 @@ static void test_ushort_bug()
|
|||
{
|
||||
fprintf(stdout, "\n ushort : %d (%ld)", short_value, s_length);
|
||||
fprintf(stdout, "\n ulong : %lu (%ld)", (ulong) long_value, l_length);
|
||||
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
|
||||
fprintf(stdout, "\n longlong : %s (%ld)", llstr(longlong_value, llbuf),
|
||||
ll_length);
|
||||
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
|
||||
}
|
||||
|
||||
|
@ -6636,6 +6640,7 @@ static void test_sshort_bug()
|
|||
ulonglong longlong_value;
|
||||
int rc;
|
||||
uchar tiny_value;
|
||||
char llbuf[22];
|
||||
|
||||
myheader("test_sshort_bug");
|
||||
|
||||
|
@ -6686,7 +6691,8 @@ static void test_sshort_bug()
|
|||
{
|
||||
fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length);
|
||||
fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length);
|
||||
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
|
||||
fprintf(stdout, "\n longlong : %s (%ld)", llstr(longlong_value, llbuf),
|
||||
ll_length);
|
||||
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
|
||||
}
|
||||
|
||||
|
@ -6721,6 +6727,7 @@ static void test_stiny_bug()
|
|||
ulonglong longlong_value;
|
||||
int rc;
|
||||
uchar tiny_value;
|
||||
char llbuf[22];
|
||||
|
||||
myheader("test_stiny_bug");
|
||||
|
||||
|
@ -6770,7 +6777,8 @@ static void test_stiny_bug()
|
|||
{
|
||||
fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length);
|
||||
fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length);
|
||||
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
|
||||
fprintf(stdout, "\n longlong : %s (%ld)", llstr(longlong_value, llbuf),
|
||||
ll_length);
|
||||
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
|
||||
}
|
||||
|
||||
|
@ -11263,7 +11271,7 @@ static void test_bug5399()
|
|||
|
||||
for (stmt= stmt_list; stmt != stmt_list + NUM_OF_USED_STMT; ++stmt)
|
||||
{
|
||||
sprintf(buff, "select %d", stmt - stmt_list);
|
||||
sprintf(buff, "select %d", (int) (stmt - stmt_list));
|
||||
*stmt= mysql_stmt_init(mysql);
|
||||
rc= mysql_stmt_prepare(*stmt, buff, strlen(buff));
|
||||
check_execute(*stmt, rc);
|
||||
|
@ -11452,7 +11460,7 @@ static void test_bug5194()
|
|||
|
||||
if (!opt_silent)
|
||||
printf("Insert: query length= %d, row count= %d, param count= %lu\n",
|
||||
strlen(query), nrows, mysql_stmt_param_count(stmt));
|
||||
(int) strlen(query), nrows, mysql_stmt_param_count(stmt));
|
||||
|
||||
/* bind the parameter array and execute the query */
|
||||
rc= mysql_stmt_bind_param(stmt, bind);
|
||||
|
|
Loading…
Add table
Reference in a new issue