From 2bd02714d2fb70cb75c78d6f1da43273d6572bf2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Apr 2005 12:28:25 +0300 Subject: [PATCH 1/7] Fixed a bug using mysqldump to InnoDB tables causes error (Bug #10200). sql/ha_innodb.cc: Fixed a bug using mysqldump to InnoDB tables causes error (Bug #10200). Lock type must be stored when sql_command = SQLCOM_LOCK_TABLES and lock_type = TL_READ or TL_READ_INSERT even when innobase_locks_unsafe_for_binlog is set. --- sql/ha_innodb.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 83c72594dfb..8f9671c5e67 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -5340,15 +5340,14 @@ ha_innobase::store_lock( (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) && thd->lex->sql_command != SQLCOM_SELECT && thd->lex->sql_command != SQLCOM_UPDATE_MULTI && - thd->lex->sql_command != SQLCOM_DELETE_MULTI ) { + thd->lex->sql_command != SQLCOM_DELETE_MULTI && + thd->lex->sql_command != SQLCOM_LOCK_TABLES) { /* In case we have innobase_locks_unsafe_for_binlog option set and isolation level of the transaction is not set to serializable and MySQL is doing INSERT INTO...SELECT without FOR UPDATE or IN - SHARE MODE we use consistent read for select. - Similarly, in case of DELETE...SELECT and - UPDATE...SELECT when these are not multi table.*/ + SHARE MODE we use consistent read for select. */ prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; From 8736d8ac061f0a668bef1c2f8c37591f4b49ba63 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 May 2005 10:16:03 +0200 Subject: [PATCH 2/7] logging_ok: Logging to logging@openlogging.org accepted NDBT_ResultRow.cpp, ndb_restore.test, ndb_restore.result: BUG#10287 mysql-test/r/ndb_restore.result: BUG#10287 mysql-test/t/ndb_restore.test: BUG#10287 ndb/test/src/NDBT_ResultRow.cpp: BUG#10287 BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 2 ++ mysql-test/r/ndb_restore.result | 1 + mysql-test/t/ndb_restore.test | 6 ++++++ ndb/test/src/NDBT_ResultRow.cpp | 8 ++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 330d28daf52..1b33d659cfd 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -167,6 +167,7 @@ mysqldev@build.mysql2.com mysqldev@melody.local mysqldev@mysql.com mysqldev@o2k.irixworld.net +ndbdev@dl145b.mysql.com ndbdev@eel.hemma.oreland.se ndbdev@ndbmaster.mysql.com nick@mysql.com @@ -240,6 +241,7 @@ tonu@x153.internalnet tonu@x3.internalnet tsmith@build.mysql.com tulin@build.mysql.com +tulin@dl145b.mysql.com tulin@mysql.com ulli@morbus.(none) venu@hundin.mysql.fi diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index 8e4449b1996..c78a4137468 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -247,3 +247,4 @@ count(*) 3 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +520093696,1 diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index ee47f7da6bc..0c3babd54e4 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -208,3 +208,9 @@ select count(*) drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; --enable_warnings + +# +# Test BUG#10287 +# + +--exec $NDB_TOOLS_DIR/ndb_select_all -d sys -D , SYSTAB_0 | grep 520093696 diff --git a/ndb/test/src/NDBT_ResultRow.cpp b/ndb/test/src/NDBT_ResultRow.cpp index f82963901b1..11554b4a9b3 100644 --- a/ndb/test/src/NDBT_ResultRow.cpp +++ b/ndb/test/src/NDBT_ResultRow.cpp @@ -116,8 +116,12 @@ BaseString NDBT_ResultRow::c_str() { NdbOut & operator << (NdbOut& ndbout, const NDBT_ResultRow & res) { - for(int i = 0; i Date: Wed, 4 May 2005 12:24:56 +0300 Subject: [PATCH 3/7] Initial value for a auto_increment can now be set using ALTER TABLE AUTO_INCREMENT = X; or CREATE TABLE .. AUTO_INCREMENT = X; This change is backported from 5.0 (Bug #7061). sql/ha_innodb.cc: Initial value for a auto_increment can now be set using ALTER TABLE AUTO_INCREMENT = X; or CREATE TABLE .. AUTO_INCREMENT = X; This change is backported from 5.0. --- sql/ha_innodb.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 8f9671c5e67..dea938f126e 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1216,7 +1216,7 @@ innobase_commit( &innodb_dummy_stmt_trx_handle: the latter means that the current SQL statement ended */ { - trx_t* trx; + trx_t* trx; DBUG_ENTER("innobase_commit"); DBUG_PRINT("trans", ("ending transaction")); @@ -3939,6 +3939,20 @@ ha_innobase::create( DBUG_ASSERT(innobase_table != 0); + if ((create_info->used_fields & HA_CREATE_USED_AUTO) && + (create_info->auto_increment_value != 0)) { + + /* Query was ALTER TABLE...AUTO_INCREMENT = x; or + CREATE TABLE ...AUTO_INCREMENT = x; Find out a table + definition from the dictionary and get the current value + of the auto increment field. Set a new value to the + auto increment field if the value is greater than the + maximum value in the column. */ + + auto_inc_value = create_info->auto_increment_value; + dict_table_autoinc_initialize(innobase_table, auto_inc_value); + } + /* Tell the InnoDB server that there might be work for utility threads: */ @@ -5346,8 +5360,9 @@ ha_innobase::store_lock( /* In case we have innobase_locks_unsafe_for_binlog option set and isolation level of the transaction is not set to serializable and MySQL is doing - INSERT INTO...SELECT without FOR UPDATE or IN - SHARE MODE we use consistent read for select. */ + INSERT INTO...SELECT or UPDATE ... = (SELECT ...) + without FOR UPDATE or IN SHARE MODE in select, then + we use consistent read for select. */ prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; From 709c4ad12060786d6eb97e5952f7a7390bbfa2ba Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 May 2005 08:08:39 +0300 Subject: [PATCH 4/7] Fig compiler error. --- sql/ha_innodb.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index dea938f126e..0cb0f5564bf 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -3766,6 +3766,7 @@ ha_innobase::create( char name2[FN_REFLEN]; char norm_name[FN_REFLEN]; THD *thd= current_thd; + ib_longlong auto_inc_value; DBUG_ENTER("ha_innobase::create"); From f59fef3f972a5ae06523f811c55ef713a9303679 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 May 2005 09:15:14 +0200 Subject: [PATCH 5/7] terminal.c, sql_bitmap.h, my_sys.h, configure.in, config.h: Initial Metrowerks CodeWarrior compiler support cmd-line-utils/libedit/config.h: Initial Metrowerks CodeWarrior compiler support configure.in: Initial Metrowerks CodeWarrior compiler support include/my_sys.h: Initial Metrowerks CodeWarrior compiler support sql/sql_bitmap.h: Initial Metrowerks CodeWarrior compiler support cmd-line-utils/readline/terminal.c: Initial Metrowerks CodeWarrior compiler support --- cmd-line-utils/libedit/config.h | 2 ++ cmd-line-utils/readline/terminal.c | 2 +- configure.in | 23 +++++++++++++++++++++-- include/my_sys.h | 4 ++++ sql/sql_bitmap.h | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/cmd-line-utils/libedit/config.h b/cmd-line-utils/libedit/config.h index b6f002d5b9e..642123d1ddc 100644 --- a/cmd-line-utils/libedit/config.h +++ b/cmd-line-utils/libedit/config.h @@ -2,8 +2,10 @@ #include "my_config.h" #include "sys.h" +#if defined(LIBC_SCCS) && !defined(lint) #define __RCSID(x) #define __COPYRIGHT(x) +#endif #define __RENAME(x) #define _DIAGASSERT(x) diff --git a/cmd-line-utils/readline/terminal.c b/cmd-line-utils/readline/terminal.c index a506fa6de09..b2bcf5f146c 100644 --- a/cmd-line-utils/readline/terminal.c +++ b/cmd-line-utils/readline/terminal.c @@ -346,7 +346,7 @@ get_term_capabilities (bp) register unsigned int i; for (i = 0; i < NUM_TC_STRINGS; i++) -# ifdef __LCC__ +# if defined(__LCC__) || defined(__MWERKS__) *(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp); # else *(tc_strings[i].tc_value) = tgetstr (tc_strings[i].tc_var, bp); diff --git a/configure.in b/configure.in index 6efdc56d450..b37f0b3c537 100644 --- a/configure.in +++ b/configure.in @@ -127,8 +127,25 @@ AC_PROG_MAKE_SET # This generates rules for webpage generation for the MySQL homepage. AM_CONDITIONAL(LOCAL, test -d ../web/SitePages) -# This is need before AC_PROG_CC -# +############################################################################## +# The below section needs to be done before AC_PROG_CC +############################################################################## + +# Hack for OS X/Darwin and Metrowerks CodeWarrior +AC_ARG_WITH(darwin-mwcc, +[ --with-darwin-mwcc Use Metrowerks CodeWarrior wrappers on OS X/Darwin],[ + builddir=`pwd` + ccwrapper="$builddir/support-files/MacOSX/mwcc-wrapper" + arwrapper="$builddir/support-files/MacOSX/mwar-wrapper" + CC="$ccwrapper" + CXX="$ccwrapper" + LD="$ccwrapper" + AR="$arwrapper" + RANLIB=: + export CC CXX LD AR RANLIB + AC_SUBST(AR) + AC_SUBST(RANLIB) +]) if test "x${CFLAGS-}" = x ; then cflags_is_set=no @@ -148,6 +165,8 @@ else ldflags_is_set=yes fi +################ End of section to be done before AC_PROG_CC ################# + # The following hack should ensure that configure doesn't add optimizing # or debugging flags to CFLAGS or CXXFLAGS # C_EXTRA_FLAGS are flags that are automaticly added to both diff --git a/include/my_sys.h b/include/my_sys.h index 7ead643a9c6..c9552f8558b 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -163,6 +163,10 @@ extern char *my_strdup_with_length(const byte *from, uint length, #if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) #pragma alloca #endif /* _AIX */ +#if defined(__MWERKS__) +#undef alloca +#define alloca __alloca +#endif /* __MWERKS__ */ #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca) #define alloca __builtin_alloca #endif /* GNUC */ diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index 5c51f3ecb67..2fd603d9381 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -91,7 +91,7 @@ template <> class Bitmap<64> ulonglong map; public: Bitmap<64>() { } -#if defined(__NETWARE__) +#if defined(__NETWARE__) || defined(__MWERKS__) /* Metwork compiler gives error on Bitmap<64> Changed to Bitmap, since in this case also it will proper construct From 203543d1e73ec768cbd0ea636474eaeffd8537d7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 May 2005 09:34:15 +0200 Subject: [PATCH 6/7] mwcc-wrapper, compile-darwin-mwcc, mwar-wrapper: Initial Metrowerks CodeWarrior compiler support new file support-files/MacOSX/mwar-wrapper: Initial Metrowerks CodeWarrior compiler support BUILD/compile-darwin-mwcc: Initial Metrowerks CodeWarrior compiler support support-files/MacOSX/mwcc-wrapper: Initial Metrowerks CodeWarrior compiler support --- BUILD/compile-darwin-mwcc | 54 +++++++++++++++++++++++++++++++ support-files/MacOSX/mwar-wrapper | 16 +++++++++ support-files/MacOSX/mwcc-wrapper | 48 +++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100755 BUILD/compile-darwin-mwcc create mode 100755 support-files/MacOSX/mwar-wrapper create mode 100755 support-files/MacOSX/mwcc-wrapper diff --git a/BUILD/compile-darwin-mwcc b/BUILD/compile-darwin-mwcc new file mode 100755 index 00000000000..6fd0eab7e26 --- /dev/null +++ b/BUILD/compile-darwin-mwcc @@ -0,0 +1,54 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +c_warnings="" +cxx_warnings="" +fast_cflags="-O3" +base_cxxflags="-fno-handle-exceptions" + +# FIXME do we need to link static, not to depend on CodeWarrior libs? + +if [ x$MODE = x ] ; then + echo "You need to give an argument, 'standard', 'max', 'debug' or 'debug-max'" + echo "Like: MODE=standard BUILD/compile-darwin-codewarrior" + exit 1 +else + case $MODE in + standard|pro-gpl) + # FIXME pro/pro-gpl different libedit/readline + extra_flags="$ppc_cflags $fast_cflags" + ;; + pro) + # FIXME pro/pro-gpl different libedit/readline + extra_flags="$ppc_cflags $fast_cflags" + extra_configs="--with-libedit" + ;; + max) + extra_flags="$ppc_cflags $fast_cflags" + extra_configs="$max_configs" + ;; + debug) + extra_flags="$ppc_cflags $debug_cflags" + c_warnings="$c_warnings $debug_extra_warnings" + cxx_warnings="$cxx_warnings $debug_extra_warnings" + extra_configs="$debug_configs" + ;; + debug-max) + extra_flags="$ppc_cflags $debug_cflags $max_cflags" + c_warnings="$c_warnings $debug_extra_warnings" + cxx_warnings="$cxx_warnings $debug_extra_warnings" + extra_configs="$debug_configs $max_configs" + ;; + *) + echo "You need to give an argument, 'standard', 'max', 'debug' or 'debug-max'" + echo "Like: MODE=standard BUILD/compile-darwin-codewarrior" + exit 1 + ;; + esac +fi + +extra_configs="$extra_configs --with-darwin-mwcc" + +. "$path/FINISH.sh" diff --git a/support-files/MacOSX/mwar-wrapper b/support-files/MacOSX/mwar-wrapper new file mode 100755 index 00000000000..4bc5153e7ef --- /dev/null +++ b/support-files/MacOSX/mwar-wrapper @@ -0,0 +1,16 @@ +#!/bin/sh + +# This script can only create a library, not take it apart +# again to AR files + +case $1 in + -d*|-m*|-t*|-p*|-r*|-x*|x) + echo "$0: can't handle arguments $*" + exit 1; + ;; + -c|c|cr|cru|cu) + shift; + ;; +esac + +exec mwld -lib -o $* diff --git a/support-files/MacOSX/mwcc-wrapper b/support-files/MacOSX/mwcc-wrapper new file mode 100755 index 00000000000..914578aca1d --- /dev/null +++ b/support-files/MacOSX/mwcc-wrapper @@ -0,0 +1,48 @@ +#!/bin/sh + +if [ -z "$CWINSTALL" ] ; then + echo "ERROR: You need to source 'mwvars' to set CWINSTALL and other variables" + exit 1 +fi + +if [ `expr "$MWMacOSXPPCLibraryFiles" : ".*BSD.*"` = 0 ] ; then + echo "ERROR: You need to source 'mwvars' with the 'bsd' argument" + exit 1 +fi + +# ============================================================================== + +# Extra options that don't change + +PREOPTS="-D__SCHAR_MAX__=127 -D__CHAR_BIT__=8 -ext o -gccinc" +PREOPTS="$PREOPTS -wchar_t on -bool on -relax_pointers -align power_gcc" +PREOPTS="$PREOPTS -stabs all -fno-handle-exceptions -Cpp_exceptions off" + +# ============================================================================== + +# We want the "PPC Specific" directory to be last, before the source +# file. It is to work around a CodeWarrior/Apple bug, that we need a +# Metrowersk header even though we have configured CodeWarrior to use +# the BSD headers. But not to conflict, the directory has to be last. + +# FIXME this will probably break if one path contains space characters + +PREARGS="" +for i in $* ; do + case "$i" in + -bind_at_load) + # This is a flag some version of libtool adds, when the host + # is "*darwin*". It doesn't check that it is gcc. + # FIXME add some flag?! + ;; + *.c|*.cc|*.cpp) + break + ;; + *) + PREARGS="$PREARGS $1" + ;; + esac + shift +done +#echo "mwcc $PREOPTS $PREARGS -I\"$CWINSTALL/MacOS X Support/Headers/PPC Specific\" $*" +exec mwcc $PREOPTS $PREARGS -I"$CWINSTALL/MacOS X Support/Headers/PPC Specific" $* From c758512a9176b40532f8431e7771f8dbeed77111 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 May 2005 12:55:09 +0400 Subject: [PATCH 7/7] A fix and test case for Bug#9777 " Empty set returned by Prepared Statement when it should return a non empty one" (see comments for the changed files for details). mysql-test/r/ps.result: A test case for Bug#9777: tests results fixed. mysql-test/t/ps.test: A test case for Bug#9777 sql/item.cc: A fix for Bug#9777: when creating a constant item from within Item_int_with_ref::new_item, create the item by value, not by name. This should work with prepared statements placeholders. Item_int_with_ref is a special optimization case used when we compare datetime constants with datetime value. Converting the item to integer early is OK as it is in line with the purpose of Item_int_with_ref - to speed up comparison by using integers. Minor cleanups. sql/item.h: Declaration for Item_int_with_ref::new_item --- mysql-test/r/ps.result | 38 ++++++++++++++++++++++++++++++++++ mysql-test/t/ps.test | 47 ++++++++++++++++++++++++++++++++++++++++++ sql/item.cc | 24 ++++++++++++++++++++- sql/item.h | 7 ++----- 4 files changed, 110 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index df3e24afd1a..d66114fe44e 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -519,3 +519,41 @@ c1 c2 200887 860 200887 200887 deallocate prepare stmt; +drop table t1; +create table t1 ( +id bigint(20) not null auto_increment, +code varchar(20) character set utf8 collate utf8_bin not null default '', +company_name varchar(250) character set utf8 collate utf8_bin default null, +setup_mode tinyint(4) default null, +start_date datetime default null, +primary key (id), unique key code (code) +); +create table t2 ( +id bigint(20) not null auto_increment, +email varchar(250) character set utf8 collate utf8_bin default null, +name varchar(250) character set utf8 collate utf8_bin default null, +t1_id bigint(20) default null, +password varchar(250) character set utf8 collate utf8_bin default null, +primary_contact tinyint(4) not null default '0', +email_opt_in tinyint(4) not null default '1', +primary key (id), unique key email (email), key t1_id (t1_id), +constraint t2_fk1 foreign key (t1_id) references t1 (id) +); +insert into t1 values +(1, 'demo', 'demo s', 0, current_date()), +(2, 'code2', 'name 2', 0, current_date()), +(3, 'code3', 'name 3', 0, current_date()); +insert into t2 values +(2, 'email1', 'name1', 3, 'password1', 0, 0), +(3, 'email2', 'name1', 1, 'password2', 1, 0), +(5, 'email3', 'name3', 2, 'password3', 0, 0); +prepare stmt from 'select t2.id from t2, t1 where (t1.id=? and t2.t1_id=t1.id)'; +set @a=1; +execute stmt using @a; +id +3 +select t2.id from t2, t1 where (t1.id=1 and t2.t1_id=t1.id); +id +3 +deallocate prepare stmt; +drop table t1, t2; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index ef36b8b1b0b..96b83a09497 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -522,3 +522,50 @@ set @a=200887, @b=860; # this query did not return all matching rows execute stmt using @a, @b; deallocate prepare stmt; +drop table t1; + +# +# Bug#9777 - another occurrence of the problem stated in Bug#9096: +# we can not compare basic constants by their names, because a placeholder +# is a basic constant while his name is always '?' +# + +create table t1 ( + id bigint(20) not null auto_increment, + code varchar(20) character set utf8 collate utf8_bin not null default '', + company_name varchar(250) character set utf8 collate utf8_bin default null, + setup_mode tinyint(4) default null, + start_date datetime default null, + primary key (id), unique key code (code) +); + +create table t2 ( + id bigint(20) not null auto_increment, + email varchar(250) character set utf8 collate utf8_bin default null, + name varchar(250) character set utf8 collate utf8_bin default null, + t1_id bigint(20) default null, + password varchar(250) character set utf8 collate utf8_bin default null, + primary_contact tinyint(4) not null default '0', + email_opt_in tinyint(4) not null default '1', + primary key (id), unique key email (email), key t1_id (t1_id), + constraint t2_fk1 foreign key (t1_id) references t1 (id) +); + +insert into t1 values +(1, 'demo', 'demo s', 0, current_date()), +(2, 'code2', 'name 2', 0, current_date()), +(3, 'code3', 'name 3', 0, current_date()); + +insert into t2 values +(2, 'email1', 'name1', 3, 'password1', 0, 0), +(3, 'email2', 'name1', 1, 'password2', 1, 0), +(5, 'email3', 'name3', 2, 'password3', 0, 0); + +prepare stmt from 'select t2.id from t2, t1 where (t1.id=? and t2.t1_id=t1.id)'; +set @a=1; +execute stmt using @a; + +select t2.id from t2, t1 where (t1.id=1 and t2.t1_id=t1.id); + +deallocate prepare stmt; +drop table t1, t2; diff --git a/sql/item.cc b/sql/item.cc index 7e74bb1fd85..211e165cc6b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -769,6 +769,13 @@ Item_uint::Item_uint(const char *str_arg, uint length): } +Item_uint::Item_uint(const char *str_arg, longlong i, uint length): + Item_int(str_arg, i, length) +{ + unsigned_flag= 1; +} + + String *Item_uint::val_str(String *str) { // following assert is redundant, because fixed=1 assigned in constructor @@ -1377,7 +1384,9 @@ Item_param::new_item() case NULL_VALUE: return new Item_null(name); case INT_VALUE: - return new Item_int(name, value.integer, max_length); + return (unsigned_flag ? + new Item_uint(name, value.integer, max_length) : + new Item_int(name, value.integer, max_length)); case REAL_VALUE: return new Item_real(name, value.real, decimals, max_length); case STRING_VALUE: @@ -2023,6 +2032,19 @@ bool Item_int::eq(const Item *arg, bool binary_cmp) const } +Item *Item_int_with_ref::new_item() +{ + DBUG_ASSERT(ref->basic_const_item()); + /* + We need to evaluate the constant to make sure it works with + parameter markers. + */ + return (ref->unsigned_flag ? + new Item_uint(ref->name, ref->val_int(), ref->max_length) : + new Item_int(ref->name, ref->val_int(), ref->max_length)); +} + + Item_num *Item_uint::neg() { return new Item_real(name, - ((double) value), 0, max_length); diff --git a/sql/item.h b/sql/item.h index 3f3ff491bb5..6f1f56451ab 100644 --- a/sql/item.h +++ b/sql/item.h @@ -651,6 +651,7 @@ class Item_uint :public Item_int { public: Item_uint(const char *str_arg, uint length); + Item_uint(const char *str_arg, longlong i, uint length); Item_uint(uint32 i) :Item_int((longlong) i, 10) { unsigned_flag= 1; } double val() @@ -1046,11 +1047,7 @@ public: { return ref->save_in_field(field, no_conversions); } - Item *new_item() - { - return (ref->unsigned_flag)? new Item_uint(ref->name, ref->max_length) : - new Item_int(ref->name, ref->max_length); - } + Item *new_item(); };