merge 5.5 -> 10.0-base

This commit is contained in:
unknown 2013-09-25 21:07:06 +03:00
commit 9d83468e78
42 changed files with 279 additions and 203 deletions

View File

@ -3,6 +3,6 @@
export LDFLAGS='-m64 -lmtmalloc -R/usr/sfw/lib/64' export LDFLAGS='-m64 -lmtmalloc -R/usr/sfw/lib/64'
export CFLAGS='-mtune=i386 -D__sun -m64 -mtune=athlon64' export CFLAGS='-mtune=i386 -D__sun -m64 -mtune=athlon64'
export CXXFLAGS='-mtune=i386 -D__sun -m64 -mtune=athlon64' export CXXFLAGS='-mtune=i386 -D__sun -m64 -mtune=athlon64'
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DWITH_EXTRA_CHARSETS=complex -DWITH_READLINE=ON -DWITH_SSL=bundled -DWITH_MAX=ON -DWITH_EMBEDDED_SERVER=ON -DWITH_JEMALLOC=NO cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DWITH_EXTRA_CHARSETS=complex -DWITH_READLINE=ON -DWITH_SSL=bundled -DWITH_MAX=ON -DWITH_EMBEDDED_SERVER=ON
gmake -j6 VERBOSE=1 gmake -j6 VERBOSE=1

View File

@ -123,7 +123,8 @@ static char *host= NULL, *opt_password= NULL, *user= NULL,
*default_engine= NULL, *default_engine= NULL,
*pre_system= NULL, *pre_system= NULL,
*post_system= NULL, *post_system= NULL,
*opt_mysql_unix_port= NULL; *opt_mysql_unix_port= NULL,
*opt_init_command= NULL;
static char *opt_plugin_dir= 0, *opt_default_auth= 0; static char *opt_plugin_dir= 0, *opt_default_auth= 0;
const char *delimiter= "\n"; const char *delimiter= "\n";
@ -629,6 +630,11 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", &host, &host, 0, GET_STR, {"host", 'h', "Connect to host.", &host, &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"init-command", OPT_INIT_COMMAND,
"SQL Command to execute when connecting to MySQL server. Will "
"automatically be re-executed when reconnecting.",
&opt_init_command, &opt_init_command, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"iterations", 'i', "Number of times to run the tests.", &iterations, {"iterations", 'i', "Number of times to run the tests.", &iterations,
&iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
{"no-drop", OPT_SLAP_NO_DROP, "Do not drop the schema after the test.", {"no-drop", OPT_SLAP_NO_DROP, "Do not drop the schema after the test.",
@ -2241,6 +2247,8 @@ slap_connect(MYSQL *mysql)
for (x= 0; x < 10; x++) for (x= 0; x < 10; x++)
{ {
set_mysql_connect_options(mysql); set_mysql_connect_options(mysql);
if (opt_init_command)
mysql_options(mysql, MYSQL_INIT_COMMAND, opt_init_command);
if (mysql_real_connect(mysql, host, user, opt_password, if (mysql_real_connect(mysql, host, user, opt_password,
create_schema_string, create_schema_string,
opt_mysql_port, opt_mysql_port,

View File

@ -15,13 +15,20 @@ MACRO (USE_BUNDLED_JEMALLOC)
IF (CMAKE_BUILD_TYPE MATCHES "Debug" AND NOT APPLE) # see the comment in CMakeLists.txt IF (CMAKE_BUILD_TYPE MATCHES "Debug" AND NOT APPLE) # see the comment in CMakeLists.txt
LIST(APPEND JEMALLOC_CONFIGURE_OPTS --enable-debug) LIST(APPEND JEMALLOC_CONFIGURE_OPTS --enable-debug)
ENDIF() ENDIF()
IF(CMAKE_GENERATOR MATCHES "Makefiles")
SET(MAKE_COMMAND ${CMAKE_MAKE_PROGRAM})
ELSE() # Xcode/Ninja generators
SET(MAKE_COMMAND make)
ENDIF()
ExternalProject_Add(jemalloc ExternalProject_Add(jemalloc
PREFIX extra/jemalloc PREFIX extra/jemalloc
SOURCE_DIR ${SOURCE_DIR} SOURCE_DIR ${SOURCE_DIR}
BINARY_DIR ${BINARY_DIR} BINARY_DIR ${BINARY_DIR}
STAMP_DIR ${BINARY_DIR} STAMP_DIR ${BINARY_DIR}
CONFIGURE_COMMAND "${SOURCE_DIR}/configure" ${JEMALLOC_CONFIGURE_OPTS} CONFIGURE_COMMAND "${SOURCE_DIR}/configure" ${JEMALLOC_CONFIGURE_OPTS}
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} "build_lib_static" BUILD_COMMAND ${MAKE_COMMAND} "build_lib_static"
INSTALL_COMMAND "" INSTALL_COMMAND ""
) )
ADD_LIBRARY(libjemalloc STATIC IMPORTED) ADD_LIBRARY(libjemalloc STATIC IMPORTED)
@ -29,13 +36,19 @@ MACRO (USE_BUNDLED_JEMALLOC)
ADD_DEPENDENCIES(libjemalloc jemalloc) ADD_DEPENDENCIES(libjemalloc jemalloc)
ENDMACRO() ENDMACRO()
SET(WITH_JEMALLOC "yes" CACHE STRING IF(CMAKE_SYSTEM_NAME MATCHES "Linux" OR APPLE)
# Linux and OSX are the only systems where bundled jemalloc can be built without problems,
# as they both have GNU make and jemalloc actually compiles.
# Also, BSDs use jemalloc as malloc already
SET(WITH_JEMALLOC_DEFAULT "yes")
ELSE()
SET(WITH_JEMALLOC_DEFAULT "no")
ENDIF()
SET(WITH_JEMALLOC ${WITH_JEMALLOC_DEFAULT} CACHE STRING
"Which jemalloc to use (possible values are 'no', 'bundled', 'system', 'yes' (system if possible, otherwise bundled)") "Which jemalloc to use (possible values are 'no', 'bundled', 'system', 'yes' (system if possible, otherwise bundled)")
MACRO (CHECK_JEMALLOC) MACRO (CHECK_JEMALLOC)
IF(WIN32)
SET(WITH_JEMALLOC "no")
ENDIF()
IF(WITH_JEMALLOC STREQUAL "system" OR WITH_JEMALLOC STREQUAL "yes") IF(WITH_JEMALLOC STREQUAL "system" OR WITH_JEMALLOC STREQUAL "yes")
CHECK_LIBRARY_EXISTS(jemalloc malloc_stats_print "" HAVE_JEMALLOC) CHECK_LIBRARY_EXISTS(jemalloc malloc_stats_print "" HAVE_JEMALLOC)
IF (HAVE_JEMALLOC) IF (HAVE_JEMALLOC)

View File

@ -578,6 +578,21 @@ Connect to the MySQL server on the given host\&.
.sp -1 .sp -1
.IP \(bu 2.3 .IP \(bu 2.3
.\} .\}
.\" mysqlslap: init-command option
.\" init-command option: mysqlslap
\fB\-\-init\-command=str\fR
.sp
SQL Command to execute when connecting to MySQL server\&. Will automatically be re\-executed when reconnecting\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
.\" mysqlslap: iterations option .\" mysqlslap: iterations option
.\" iterations option: mysqlslap .\" iterations option: mysqlslap
\fB\-\-iterations=\fR\fB\fIN\fR\fR, \fB\-\-iterations=\fR\fB\fIN\fR\fR,

View File

@ -171,3 +171,26 @@ a b c d e g
2 6 two 12 2 6 2 6 two 12 2 6
DROP TABLE t1, t2; DROP TABLE t1, t2;
set optimizer_switch=@tmp_mdev3817; set optimizer_switch=@tmp_mdev3817;
#
# MDEV-5037: Server crash on a JOIN on a derived table with join_cache_level > 2
#
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE t1 (
id char(8) CHARACTER SET utf8 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE t2 (
id char(8) CHARACTER SET utf8 DEFAULT NULL,
url text CHARACTER SET utf8
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
insert into t1 select '03b2ca8c' from t0 A, t0 B limit 80;
insert into t2 select '03b2ca8c','' from t0 A, t0 B, t0 C;
set @tmp_mdev5037=@@join_cache_level;
set join_cache_level=3;
explain SELECT 1 FROM (SELECT url, id FROM t2 LIMIT 1 OFFSET 20) derived RIGHT JOIN t1 ON t1.id = derived.id;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL #
1 PRIMARY <derived2> hash_ALL key0 #hash#key0 25 test.t1.id # Using join buffer (flat, BNLH join)
2 DERIVED t2 ALL NULL NULL NULL NULL #
set join_cache_level= @tmp_mdev5037;
drop table t0,t1,t2;

View File

@ -251,3 +251,7 @@ Benchmark
Number of clients running queries: 1 Number of clients running queries: 1
Average number of queries per client: 0 Average number of queries per client: 0
#
# MDEV-4684 - Enhancement request: --init-command support for mysqlslap
#
DROP TABLE t1;

View File

@ -165,3 +165,30 @@ SELECT * FROM t1, t2 WHERE g = b AND ( a < 7 OR a > e );
DROP TABLE t1, t2; DROP TABLE t1, t2;
set optimizer_switch=@tmp_mdev3817; set optimizer_switch=@tmp_mdev3817;
--echo #
--echo # MDEV-5037: Server crash on a JOIN on a derived table with join_cache_level > 2
--echo #
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE t1 (
id char(8) CHARACTER SET utf8 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE t2 (
id char(8) CHARACTER SET utf8 DEFAULT NULL,
url text CHARACTER SET utf8
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
insert into t1 select '03b2ca8c' from t0 A, t0 B limit 80;
insert into t2 select '03b2ca8c','' from t0 A, t0 B, t0 C;
set @tmp_mdev5037=@@join_cache_level;
set join_cache_level=3;
--replace_column 9 #
explain SELECT 1 FROM (SELECT url, id FROM t2 LIMIT 1 OFFSET 20) derived RIGHT JOIN t1 ON t1.id = derived.id;
set join_cache_level= @tmp_mdev5037;
drop table t0,t1,t2;

View File

@ -73,3 +73,10 @@ DROP DATABASE bug58090;
--replace_regex /queries: [0-9]+.[0-9]+/queries: TIME/ --replace_regex /queries: [0-9]+.[0-9]+/queries: TIME/
--exec $MYSQL_SLAP --exec $MYSQL_SLAP
--echo #
--echo # MDEV-4684 - Enhancement request: --init-command support for mysqlslap
--echo #
--exec $MYSQL_SLAP --create-schema=test --init-command="CREATE TABLE t1(a INT)" --silent --concurrency=1 --iterations=1
DROP TABLE t1;

View File

@ -869,12 +869,6 @@ static int findopt(char *optpat, uint length,
} }
} }
} }
if (is_prefix && count == 1)
my_getopt_error_reporter(WARNING_LEVEL,
"Using unique option prefix %.*s instead of %s "
"is deprecated and will be removed in a future "
"release. Please use the full name instead.",
length, optpat, *ffname);
DBUG_RETURN(count); DBUG_RETURN(count);
} }

View File

@ -44,12 +44,16 @@ static const char *get_os_version_name(OSVERSIONINFOEX *ver)
DWORD major = ver->dwMajorVersion; DWORD major = ver->dwMajorVersion;
DWORD minor = ver->dwMinorVersion; DWORD minor = ver->dwMinorVersion;
if (major == 6 && minor == 3)
{
return (ver->wProductType == VER_NT_WORKSTATION)?
"Windows 8.1":"Windows Server 2012 R2";
}
if (major == 6 && minor == 2) if (major == 6 && minor == 2)
{ {
return (ver->wProductType == VER_NT_WORKSTATION)? return (ver->wProductType == VER_NT_WORKSTATION)?
"Windows 8":"Windows Server 2012"; "Windows 8":"Windows Server 2012";
} }
if (major == 6 && minor == 1) if (major == 6 && minor == 1)
{ {
return (ver->wProductType == VER_NT_WORKSTATION)? return (ver->wProductType == VER_NT_WORKSTATION)?

View File

@ -25,7 +25,6 @@ ${CMAKE_BINARY_DIR}/sql
SET(GEN_SOURCES SET(GEN_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
) )
@ -89,6 +88,7 @@ SET (SQL_SOURCE
../sql-common/mysql_async.c ../sql-common/mysql_async.c
my_apc.cc my_apc.h my_apc.cc my_apc.h
rpl_gtid.cc rpl_gtid.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
${GEN_SOURCES} ${GEN_SOURCES}
${MYSYS_LIBWRAP_SOURCE} ${MYSYS_LIBWRAP_SOURCE}
) )

View File

@ -2862,6 +2862,7 @@ public:
virtual bool check_if_supported_virtual_columns(void) { return FALSE;} virtual bool check_if_supported_virtual_columns(void) { return FALSE;}
TABLE* get_table() { return table; } TABLE* get_table() { return table; }
TABLE_SHARE* get_table_share() { return table_share; }
protected: protected:
/* deprecated, don't use in new engines */ /* deprecated, don't use in new engines */
inline void ha_statistic_increment(ulong SSV::*offset) const { } inline void ha_statistic_increment(ulong SSV::*offset) const { }
@ -3115,7 +3116,7 @@ public:
#include "multi_range_read.h" #include "multi_range_read.h"
bool key_uses_partial_cols(TABLE *table, uint keyno); bool key_uses_partial_cols(TABLE_SHARE *table, uint keyno);
/* Some extern variables used with handlers */ /* Some extern variables used with handlers */

View File

@ -9641,18 +9641,10 @@ table_map Item_ref::used_tables() const
} }
void Item_ref::update_used_tables() void Item_ref::update_used_tables()
{ {
if (!get_depended_from()) if (!get_depended_from())
(*ref)->update_used_tables(); (*ref)->update_used_tables();
maybe_null|= (*ref)->maybe_null;
}
void Item_direct_view_ref::update_used_tables()
{
Item_ref::update_used_tables();
if (view->table && view->table->maybe_null)
maybe_null= TRUE;
} }
table_map Item_direct_view_ref::used_tables() const table_map Item_direct_view_ref::used_tables() const

View File

@ -2102,8 +2102,6 @@ public:
void update_used_tables() void update_used_tables()
{ {
update_table_bitmaps(); update_table_bitmaps();
if (field && field->table)
maybe_null|= field->maybe_null();
} }
Item *get_tmp_table_item(THD *thd); Item *get_tmp_table_item(THD *thd);
bool collect_item_field_processor(uchar * arg); bool collect_item_field_processor(uchar * arg);
@ -3249,7 +3247,6 @@ public:
void update_used_tables() void update_used_tables()
{ {
orig_item->update_used_tables(); orig_item->update_used_tables();
maybe_null|= orig_item->maybe_null;
} }
bool const_item() const { return orig_item->const_item(); } bool const_item() const { return orig_item->const_item(); }
table_map not_null_tables() const { return orig_item->not_null_tables(); } table_map not_null_tables() const { return orig_item->not_null_tables(); }
@ -3342,7 +3339,6 @@ public:
Item *replace_equal_field(uchar *arg); Item *replace_equal_field(uchar *arg);
table_map used_tables() const; table_map used_tables() const;
table_map not_null_tables() const; table_map not_null_tables() const;
void update_used_tables();
bool walk(Item_processor processor, bool walk_subquery, uchar *arg) bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
{ {
return (*ref)->walk(processor, walk_subquery, arg) || return (*ref)->walk(processor, walk_subquery, arg) ||

View File

@ -1354,7 +1354,7 @@ int Arg_comparator::compare_e_row()
void Item_func_truth::fix_length_and_dec() void Item_func_truth::fix_length_and_dec()
{ {
set_persist_maybe_null(0); maybe_null= 0;
null_value= 0; null_value= 0;
decimals= 0; decimals= 0;
max_length= 1; max_length= 1;
@ -1906,8 +1906,7 @@ longlong Item_func_eq::val_int()
void Item_func_equal::fix_length_and_dec() void Item_func_equal::fix_length_and_dec()
{ {
Item_bool_func2::fix_length_and_dec(); Item_bool_func2::fix_length_and_dec();
set_persist_maybe_null(0); maybe_null=null_value=0;
null_value= 0;
} }
longlong Item_func_equal::val_int() longlong Item_func_equal::val_int()
@ -2046,7 +2045,7 @@ void Item_func_interval::fix_length_and_dec()
} }
} }
} }
set_persist_maybe_null(0); maybe_null= 0;
max_length= 2; max_length= 2;
used_tables_cache|= row->used_tables(); used_tables_cache|= row->used_tables();
not_null_tables_cache= row->not_null_tables(); not_null_tables_cache= row->not_null_tables();
@ -2742,7 +2741,7 @@ void
Item_func_nullif::fix_length_and_dec() Item_func_nullif::fix_length_and_dec()
{ {
Item_bool_func2::fix_length_and_dec(); Item_bool_func2::fix_length_and_dec();
set_persist_maybe_null(1); maybe_null=1;
if (args[0]) // Only false if EOM if (args[0]) // Only false if EOM
{ {
max_length=args[0]->max_length; max_length=args[0]->max_length;
@ -4646,8 +4645,6 @@ void Item_cond::update_used_tables()
item->update_used_tables(); item->update_used_tables();
used_tables_cache|= item->used_tables(); used_tables_cache|= item->used_tables();
const_item_cache&= item->const_item(); const_item_cache&= item->const_item();
if (!persistent_maybe_null && item->maybe_null)
maybe_null= 1;
} }
} }
@ -4826,9 +4823,10 @@ longlong Item_is_not_null_test::val_int()
*/ */
void Item_is_not_null_test::update_used_tables() void Item_is_not_null_test::update_used_tables()
{ {
args[0]->update_used_tables();
if (!args[0]->maybe_null) if (!args[0]->maybe_null)
used_tables_cache= 0; /* is always true */ used_tables_cache= 0; /* is always true */
else
args[0]->update_used_tables();
} }
@ -5132,7 +5130,7 @@ Item_func_regex::fix_fields(THD *thd, Item **ref)
int comp_res= regcomp(TRUE); int comp_res= regcomp(TRUE);
if (comp_res == -1) if (comp_res == -1)
{ // Will always return NULL { // Will always return NULL
set_persist_maybe_null(1); maybe_null=1;
fixed= 1; fixed= 1;
return FALSE; return FALSE;
} }
@ -5142,7 +5140,7 @@ Item_func_regex::fix_fields(THD *thd, Item **ref)
maybe_null= args[0]->maybe_null; maybe_null= args[0]->maybe_null;
} }
else else
set_persist_maybe_null(1); maybe_null=1;
fixed= 1; fixed= 1;
return FALSE; return FALSE;
} }
@ -6088,8 +6086,6 @@ void Item_equal::update_used_tables()
used_tables_cache|= item->used_tables(); used_tables_cache|= item->used_tables();
/* see commentary at Item_equal::update_const() */ /* see commentary at Item_equal::update_const() */
const_item_cache&= item->const_item() && !item->is_outer_field(); const_item_cache&= item->const_item() && !item->is_outer_field();
if (!persistent_maybe_null && item->maybe_null)
maybe_null= 1;
} }
} }

View File

@ -765,11 +765,6 @@ public:
my_decimal *decimal_op(my_decimal *); my_decimal *decimal_op(my_decimal *);
bool date_op(MYSQL_TIME *ltime,uint fuzzydate); bool date_op(MYSQL_TIME *ltime,uint fuzzydate);
void fix_length_and_dec(); void fix_length_and_dec();
void update_used_tables()
{
Item_func_coalesce::update_used_tables();
maybe_null|= args[1]->maybe_null;
}
const char *func_name() const { return "ifnull"; } const char *func_name() const { return "ifnull"; }
Field *tmp_table_field(TABLE *table); Field *tmp_table_field(TABLE *table);
uint decimal_precision() const; uint decimal_precision() const;
@ -789,11 +784,6 @@ public:
String *str_op(String *); String *str_op(String *);
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
void fix_length_and_dec(); void fix_length_and_dec();
void update_used_tables()
{
Item_func::update_used_tables();
maybe_null|= args[1]->maybe_null || args[2]->maybe_null;
}
uint decimal_precision() const; uint decimal_precision() const;
const char *func_name() const { return "if"; } const char *func_name() const { return "if"; }
bool eval_not_null_tables(uchar *opt_arg); bool eval_not_null_tables(uchar *opt_arg);
@ -1259,12 +1249,6 @@ public:
bool date_op(MYSQL_TIME *ltime, uint fuzzydate); bool date_op(MYSQL_TIME *ltime, uint fuzzydate);
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec(); void fix_length_and_dec();
void update_used_tables()
{
Item_func::update_used_tables();
if (else_expr_num == -1 || args[else_expr_num]->maybe_null)
maybe_null= 1;
}
uint decimal_precision() const; uint decimal_precision() const;
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
const char *func_name() const { return "case"; } const char *func_name() const { return "case"; }
@ -1384,14 +1368,13 @@ public:
enum Functype functype() const { return ISNULL_FUNC; } enum Functype functype() const { return ISNULL_FUNC; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; max_length=1; set_persist_maybe_null(0); decimals=0; max_length=1; maybe_null=0;
update_used_tables(); update_used_tables();
} }
const char *func_name() const { return "isnull"; } const char *func_name() const { return "isnull"; }
/* Optimize case of not_null_column IS NULL */ /* Optimize case of not_null_column IS NULL */
virtual void update_used_tables() virtual void update_used_tables()
{ {
args[0]->update_used_tables();
if (!args[0]->maybe_null) if (!args[0]->maybe_null)
{ {
used_tables_cache= 0; /* is always false */ used_tables_cache= 0; /* is always false */
@ -1399,6 +1382,7 @@ public:
} }
else else
{ {
args[0]->update_used_tables();
used_tables_cache= args[0]->used_tables(); used_tables_cache= args[0]->used_tables();
const_item_cache= args[0]->const_item(); const_item_cache= args[0]->const_item();
} }
@ -1446,7 +1430,7 @@ public:
enum Functype functype() const { return ISNOTNULL_FUNC; } enum Functype functype() const { return ISNOTNULL_FUNC; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; max_length=1; set_persist_maybe_null(0); decimals=0; max_length=1; maybe_null=0;
} }
const char *func_name() const { return "isnotnull"; } const char *func_name() const { return "isnotnull"; }
optimize_type select_optimize() const { return OPTIMIZE_NULL; } optimize_type select_optimize() const { return OPTIMIZE_NULL; }
@ -1517,12 +1501,6 @@ public:
void cleanup(); void cleanup();
longlong val_int(); longlong val_int();
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
void update_used_tables()
{
Item_bool_func::update_used_tables();
if (regex_is_const)
maybe_null= 1;
}
const char *func_name() const { return "regexp"; } const char *func_name() const { return "regexp"; }
virtual inline void print(String *str, enum_query_type query_type) virtual inline void print(String *str, enum_query_type query_type)

View File

@ -112,7 +112,7 @@ void Item_func::set_arguments(List<Item> &list)
} }
Item_func::Item_func(List<Item> &list) Item_func::Item_func(List<Item> &list)
:allowed_arg_cols(1), persistent_maybe_null(0) :allowed_arg_cols(1)
{ {
set_arguments(list); set_arguments(list);
} }
@ -120,7 +120,6 @@ Item_func::Item_func(List<Item> &list)
Item_func::Item_func(THD *thd, Item_func *item) Item_func::Item_func(THD *thd, Item_func *item)
:Item_result_field(thd, item), :Item_result_field(thd, item),
allowed_arg_cols(item->allowed_arg_cols), allowed_arg_cols(item->allowed_arg_cols),
persistent_maybe_null(0),
arg_count(item->arg_count), arg_count(item->arg_count),
used_tables_cache(item->used_tables_cache), used_tables_cache(item->used_tables_cache),
not_null_tables_cache(item->not_null_tables_cache), not_null_tables_cache(item->not_null_tables_cache),
@ -448,8 +447,6 @@ void Item_func::update_used_tables()
args[i]->update_used_tables(); args[i]->update_used_tables();
used_tables_cache|=args[i]->used_tables(); used_tables_cache|=args[i]->used_tables();
const_item_cache&=args[i]->const_item(); const_item_cache&=args[i]->const_item();
if (!persistent_maybe_null && args[i]->maybe_null)
maybe_null= 1;
} }
} }
@ -1875,7 +1872,7 @@ void Item_func_div::fix_length_and_dec()
case IMPOSSIBLE_RESULT: case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); DBUG_ASSERT(0);
} }
set_persist_maybe_null(1); // devision by zero maybe_null= 1; // devision by zero
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -1959,7 +1956,7 @@ void Item_func_int_div::fix_length_and_dec()
max_length=args[0]->max_length - max_length=args[0]->max_length -
(argtype == DECIMAL_RESULT || argtype == INT_RESULT ? (argtype == DECIMAL_RESULT || argtype == INT_RESULT ?
args[0]->decimals : 0); args[0]->decimals : 0);
set_persist_maybe_null(1); maybe_null=1;
unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag; unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
} }
@ -2046,7 +2043,7 @@ void Item_func_mod::result_precision()
void Item_func_mod::fix_length_and_dec() void Item_func_mod::fix_length_and_dec()
{ {
Item_num_op::fix_length_and_dec(); Item_num_op::fix_length_and_dec();
set_persist_maybe_null(1); maybe_null= 1;
unsigned_flag= args[0]->unsigned_flag; unsigned_flag= args[0]->unsigned_flag;
} }
@ -3264,7 +3261,7 @@ longlong Item_func_field::val_int()
void Item_func_field::fix_length_and_dec() void Item_func_field::fix_length_and_dec()
{ {
set_persist_maybe_null(0); max_length=3; maybe_null=0; max_length=3;
cmp_type= args[0]->result_type(); cmp_type= args[0]->result_type();
for (uint i=1; i < arg_count ; i++) for (uint i=1; i < arg_count ; i++)
cmp_type= item_cmp_type(cmp_type, args[i]->result_type()); cmp_type= item_cmp_type(cmp_type, args[i]->result_type());
@ -5575,7 +5572,7 @@ void Item_func_get_user_var::fix_length_and_dec()
{ {
THD *thd=current_thd; THD *thd=current_thd;
int error; int error;
set_persist_maybe_null(1); maybe_null=1;
decimals=NOT_FIXED_DEC; decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
@ -5774,7 +5771,7 @@ void Item_func_get_system_var::update_null_value()
void Item_func_get_system_var::fix_length_and_dec() void Item_func_get_system_var::fix_length_and_dec()
{ {
char *cptr; char *cptr;
set_persist_maybe_null(1); maybe_null= TRUE;
max_length= 0; max_length= 0;
if (var->check_type(var_type)) if (var->check_type(var_type))
@ -6194,7 +6191,7 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref)
status_var_increment(thd->status_var.feature_fulltext); status_var_increment(thd->status_var.feature_fulltext);
set_persist_maybe_null(1); maybe_null=1;
join_key=0; join_key=0;
/* /*
@ -6480,7 +6477,7 @@ longlong Item_func_row_count::val_int()
Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, sp_name *name) Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, sp_name *name)
:Item_func(), context(context_arg), m_name(name), m_sp(NULL), sp_result_field(NULL) :Item_func(), context(context_arg), m_name(name), m_sp(NULL), sp_result_field(NULL)
{ {
set_persist_maybe_null(1); maybe_null= 1;
m_name->init_qname(current_thd); m_name->init_qname(current_thd);
dummy_table= (TABLE*) sql_calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE)); dummy_table= (TABLE*) sql_calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE));
dummy_table->s= (TABLE_SHARE*) (dummy_table+1); dummy_table->s= (TABLE_SHARE*) (dummy_table+1);
@ -6491,7 +6488,7 @@ Item_func_sp::Item_func_sp(Name_resolution_context *context_arg,
sp_name *name, List<Item> &list) sp_name *name, List<Item> &list)
:Item_func(list), context(context_arg), m_name(name), m_sp(NULL),sp_result_field(NULL) :Item_func(list), context(context_arg), m_name(name), m_sp(NULL),sp_result_field(NULL)
{ {
set_persist_maybe_null(1); maybe_null= 1;
m_name->init_qname(current_thd); m_name->init_qname(current_thd);
dummy_table= (TABLE*) sql_calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE)); dummy_table= (TABLE*) sql_calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE));
dummy_table->s= (TABLE_SHARE*) (dummy_table+1); dummy_table->s= (TABLE_SHARE*) (dummy_table+1);
@ -6645,7 +6642,7 @@ void Item_func_sp::fix_length_and_dec()
decimals= sp_result_field->decimals(); decimals= sp_result_field->decimals();
max_length= sp_result_field->field_length; max_length= sp_result_field->field_length;
collation.set(sp_result_field->charset()); collation.set(sp_result_field->charset());
set_persist_maybe_null(1); maybe_null= 1;
unsigned_flag= test(sp_result_field->flags & UNSIGNED_FLAG); unsigned_flag= test(sp_result_field->flags & UNSIGNED_FLAG);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;

View File

@ -39,8 +39,6 @@ protected:
0 means get this number from first argument 0 means get this number from first argument
*/ */
uint allowed_arg_cols; uint allowed_arg_cols;
/* maybe_null can't be changed by parameters or used table state */
bool persistent_maybe_null;
public: public:
uint arg_count; uint arg_count;
/* /*
@ -73,13 +71,13 @@ public:
enum Type type() const { return FUNC_ITEM; } enum Type type() const { return FUNC_ITEM; }
virtual enum Functype functype() const { return UNKNOWN_FUNC; } virtual enum Functype functype() const { return UNKNOWN_FUNC; }
Item_func(void): Item_func(void):
allowed_arg_cols(1), persistent_maybe_null(0), arg_count(0) allowed_arg_cols(1), arg_count(0)
{ {
with_sum_func= 0; with_sum_func= 0;
with_field= 0; with_field= 0;
} }
Item_func(Item *a): Item_func(Item *a):
allowed_arg_cols(1), persistent_maybe_null(0), arg_count(1) allowed_arg_cols(1), arg_count(1)
{ {
args= tmp_arg; args= tmp_arg;
args[0]= a; args[0]= a;
@ -87,7 +85,7 @@ public:
with_field= a->with_field; with_field= a->with_field;
} }
Item_func(Item *a,Item *b): Item_func(Item *a,Item *b):
allowed_arg_cols(1), persistent_maybe_null(0), arg_count(2) allowed_arg_cols(1), arg_count(2)
{ {
args= tmp_arg; args= tmp_arg;
args[0]= a; args[1]= b; args[0]= a; args[1]= b;
@ -95,7 +93,7 @@ public:
with_field= a->with_field || b->with_field; with_field= a->with_field || b->with_field;
} }
Item_func(Item *a,Item *b,Item *c): Item_func(Item *a,Item *b,Item *c):
allowed_arg_cols(1), persistent_maybe_null(0) allowed_arg_cols(1)
{ {
arg_count= 0; arg_count= 0;
if ((args= (Item**) sql_alloc(sizeof(Item*)*3))) if ((args= (Item**) sql_alloc(sizeof(Item*)*3)))
@ -107,7 +105,7 @@ public:
} }
} }
Item_func(Item *a,Item *b,Item *c,Item *d): Item_func(Item *a,Item *b,Item *c,Item *d):
allowed_arg_cols(1), persistent_maybe_null(0) allowed_arg_cols(1)
{ {
arg_count= 0; arg_count= 0;
if ((args= (Item**) sql_alloc(sizeof(Item*)*4))) if ((args= (Item**) sql_alloc(sizeof(Item*)*4)))
@ -121,7 +119,7 @@ public:
} }
} }
Item_func(Item *a,Item *b,Item *c,Item *d,Item* e): Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
allowed_arg_cols(1), persistent_maybe_null(0) allowed_arg_cols(1)
{ {
arg_count= 5; arg_count= 5;
if ((args= (Item**) sql_alloc(sizeof(Item*)*5))) if ((args= (Item**) sql_alloc(sizeof(Item*)*5)))
@ -189,7 +187,7 @@ public:
if (max_result_length >= MAX_BLOB_WIDTH) if (max_result_length >= MAX_BLOB_WIDTH)
{ {
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
set_persist_maybe_null(1); maybe_null= 1;
} }
else else
max_length= (uint32) max_result_length; max_length= (uint32) max_result_length;
@ -395,11 +393,6 @@ public:
info.bool_function= &Item::restore_to_before_no_rows_in_result; info.bool_function= &Item::restore_to_before_no_rows_in_result;
walk(&Item::call_bool_func_processor, FALSE, (uchar*) &info); walk(&Item::call_bool_func_processor, FALSE, (uchar*) &info);
} }
inline void set_persist_maybe_null(bool mb_null)
{
maybe_null= mb_null;
persistent_maybe_null= 1;
}
}; };
@ -684,7 +677,7 @@ public:
} }
double val_real(); double val_real();
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
void fix_length_and_dec() { set_persist_maybe_null(1); } void fix_length_and_dec() { maybe_null= 1; }
const char *func_name() const { return "double_typecast"; } const char *func_name() const { return "double_typecast"; }
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
}; };
@ -825,7 +818,7 @@ class Item_dec_func :public Item_real_func
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=NOT_FIXED_DEC; max_length=float_length(decimals); decimals=NOT_FIXED_DEC; max_length=float_length(decimals);
set_persist_maybe_null(1); maybe_null=1;
} }
}; };
@ -1157,7 +1150,7 @@ public:
Item_func_coercibility(Item *a) :Item_int_func(a) {} Item_func_coercibility(Item *a) :Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "coercibility"; } const char *func_name() const { return "coercibility"; }
void fix_length_and_dec() { max_length=10; set_persist_maybe_null(0); } void fix_length_and_dec() { max_length=10; maybe_null= 0; }
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
}; };
@ -1320,7 +1313,7 @@ public:
{} {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "benchmark"; } const char *func_name() const { return "benchmark"; }
void fix_length_and_dec() { max_length=1; set_persist_maybe_null(0); } void fix_length_and_dec() { max_length=1; maybe_null=0; }
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
{ {
@ -1576,7 +1569,7 @@ public:
double val_real() { DBUG_ASSERT(fixed == 1); null_value= 1; return 0.0; } double val_real() { DBUG_ASSERT(fixed == 1); null_value= 1; return 0.0; }
longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; } longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() { set_persist_maybe_null(1); max_length=0; } void fix_length_and_dec() { maybe_null=1; max_length=0; }
}; };
#endif /* HAVE_DLOPEN */ #endif /* HAVE_DLOPEN */
@ -1591,7 +1584,7 @@ class Item_func_get_lock :public Item_int_func
Item_func_get_lock(Item *a,Item *b) :Item_int_func(a,b) {} Item_func_get_lock(Item *a,Item *b) :Item_int_func(a,b) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "get_lock"; } const char *func_name() const { return "get_lock"; }
void fix_length_and_dec() { max_length=1; set_persist_maybe_null(1);} void fix_length_and_dec() { max_length=1; maybe_null=1;}
table_map used_tables() const table_map used_tables() const
{ {
return Item_int_func::used_tables() | RAND_TABLE_BIT; return Item_int_func::used_tables() | RAND_TABLE_BIT;
@ -1611,7 +1604,7 @@ public:
Item_func_release_lock(Item *a) :Item_int_func(a) {} Item_func_release_lock(Item *a) :Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "release_lock"; } const char *func_name() const { return "release_lock"; }
void fix_length_and_dec() { max_length=1; set_persist_maybe_null(1);} void fix_length_and_dec() { max_length= 1; maybe_null= 1;}
table_map used_tables() const table_map used_tables() const
{ {
return Item_int_func::used_tables() | RAND_TABLE_BIT; return Item_int_func::used_tables() | RAND_TABLE_BIT;
@ -1635,7 +1628,7 @@ public:
Item_master_pos_wait(Item *a,Item *b, Item *c, Item *d) :Item_int_func(a,b,c,d) {} Item_master_pos_wait(Item *a,Item *b, Item *c, Item *d) :Item_int_func(a,b,c,d) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "master_pos_wait"; } const char *func_name() const { return "master_pos_wait"; }
void fix_length_and_dec() { max_length=21; set_persist_maybe_null(1);} void fix_length_and_dec() { max_length=21; maybe_null=1;}
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
{ {
return trace_unsupported_by_check_vcol_func_processor(func_name()); return trace_unsupported_by_check_vcol_func_processor(func_name());
@ -1859,8 +1852,7 @@ public:
Item_func_inet_aton(Item *a) :Item_int_func(a) {} Item_func_inet_aton(Item *a) :Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "inet_aton"; } const char *func_name() const { return "inet_aton"; }
void fix_length_and_dec() void fix_length_and_dec() { decimals= 0; max_length= 21; maybe_null= 1; unsigned_flag= 1;}
{ decimals= 0; max_length= 21; set_persist_maybe_null(1); unsigned_flag= 1; }
}; };
@ -1928,8 +1920,7 @@ public:
Item_func_is_free_lock(Item *a) :Item_int_func(a) {} Item_func_is_free_lock(Item *a) :Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "is_free_lock"; } const char *func_name() const { return "is_free_lock"; }
void fix_length_and_dec() void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
{ decimals= 0; max_length= 1; set_persist_maybe_null(1); }
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
{ {
return trace_unsupported_by_check_vcol_func_processor(func_name()); return trace_unsupported_by_check_vcol_func_processor(func_name());
@ -1943,8 +1934,7 @@ public:
Item_func_is_used_lock(Item *a) :Item_int_func(a) {} Item_func_is_used_lock(Item *a) :Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "is_used_lock"; } const char *func_name() const { return "is_used_lock"; }
void fix_length_and_dec() void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;}
{ decimals= 0; max_length= 10; set_persist_maybe_null(1);}
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
{ {
return trace_unsupported_by_check_vcol_func_processor(func_name()); return trace_unsupported_by_check_vcol_func_processor(func_name());
@ -1967,7 +1957,7 @@ public:
Item_func_row_count() :Item_int_func() {} Item_func_row_count() :Item_int_func() {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "row_count"; } const char *func_name() const { return "row_count"; }
void fix_length_and_dec() { decimals= 0; set_persist_maybe_null(0); } void fix_length_and_dec() { decimals= 0; maybe_null=0; }
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
{ {
@ -2108,7 +2098,7 @@ public:
Item_func_found_rows() :Item_int_func() {} Item_func_found_rows() :Item_int_func() {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "found_rows"; } const char *func_name() const { return "found_rows"; }
void fix_length_and_dec() { decimals= 0; set_persist_maybe_null(0); } void fix_length_and_dec() { decimals= 0; maybe_null=0; }
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
{ {
return trace_unsupported_by_check_vcol_func_processor(func_name()); return trace_unsupported_by_check_vcol_func_processor(func_name());

View File

@ -53,7 +53,7 @@ void Item_geometry_func::fix_length_and_dec()
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
decimals=0; decimals=0;
max_length= (uint32) 4294967295U; max_length= (uint32) 4294967295U;
set_persist_maybe_null(1); maybe_null= 1;
} }
@ -147,7 +147,7 @@ void Item_func_as_wkt::fix_length_and_dec()
{ {
collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
set_persist_maybe_null(1); maybe_null= 1;
} }

View File

@ -89,7 +89,7 @@ public:
{ {
// "GeometryCollection" is the longest // "GeometryCollection" is the longest
fix_length_and_charset(20, default_charset()); fix_length_and_charset(20, default_charset());
set_persist_maybe_null(1); maybe_null= 1;
}; };
}; };
@ -224,7 +224,7 @@ public:
{ {
Item_func::print(str, query_type); Item_func::print(str, query_type);
} }
void fix_length_and_dec() { set_persist_maybe_null(1); } void fix_length_and_dec() { maybe_null= 1; }
bool is_null() { (void) val_int(); return null_value; } bool is_null() { (void) val_int(); return null_value; }
}; };
@ -251,7 +251,7 @@ public:
Item_func::print(str, query_type); Item_func::print(str, query_type);
} }
void fix_length_and_dec() { set_persist_maybe_null(1); } void fix_length_and_dec() { maybe_null= 1; }
bool is_null() { (void) val_int(); return null_value; } bool is_null() { (void) val_int(); return null_value; }
}; };
@ -342,7 +342,7 @@ public:
longlong val_int(); longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_NONE; } optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "st_isempty"; } const char *func_name() const { return "st_isempty"; }
void fix_length_and_dec() { set_persist_maybe_null(1); } void fix_length_and_dec() { maybe_null= 1; }
}; };
class Item_func_issimple: public Item_bool_func class Item_func_issimple: public Item_bool_func
@ -356,7 +356,7 @@ public:
longlong val_int(); longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_NONE; } optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "st_issimple"; } const char *func_name() const { return "st_issimple"; }
void fix_length_and_dec() { set_persist_maybe_null(1); } void fix_length_and_dec() { maybe_null= 1; }
}; };
class Item_func_isclosed: public Item_bool_func class Item_func_isclosed: public Item_bool_func
@ -366,7 +366,7 @@ public:
longlong val_int(); longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_NONE; } optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "st_isclosed"; } const char *func_name() const { return "st_isclosed"; }
void fix_length_and_dec() { set_persist_maybe_null(1); } void fix_length_and_dec() { maybe_null= 1; }
}; };
class Item_func_dimension: public Item_int_func class Item_func_dimension: public Item_int_func
@ -376,7 +376,7 @@ public:
Item_func_dimension(Item *a): Item_int_func(a) {} Item_func_dimension(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_dimension"; } const char *func_name() const { return "st_dimension"; }
void fix_length_and_dec() { max_length= 10; set_persist_maybe_null(1); } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
class Item_func_x: public Item_real_func class Item_func_x: public Item_real_func
@ -389,7 +389,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
Item_real_func::fix_length_and_dec(); Item_real_func::fix_length_and_dec();
set_persist_maybe_null(1); maybe_null= 1;
} }
}; };
@ -404,7 +404,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
Item_real_func::fix_length_and_dec(); Item_real_func::fix_length_and_dec();
set_persist_maybe_null(1); maybe_null= 1;
} }
}; };
@ -416,7 +416,7 @@ public:
Item_func_numgeometries(Item *a): Item_int_func(a) {} Item_func_numgeometries(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_numgeometries"; } const char *func_name() const { return "st_numgeometries"; }
void fix_length_and_dec() { max_length= 10; set_persist_maybe_null(1); } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
@ -427,7 +427,7 @@ public:
Item_func_numinteriorring(Item *a): Item_int_func(a) {} Item_func_numinteriorring(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_numinteriorrings"; } const char *func_name() const { return "st_numinteriorrings"; }
void fix_length_and_dec() { max_length= 10; set_persist_maybe_null(1); } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
@ -438,7 +438,7 @@ public:
Item_func_numpoints(Item *a): Item_int_func(a) {} Item_func_numpoints(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "st_numpoints"; } const char *func_name() const { return "st_numpoints"; }
void fix_length_and_dec() { max_length= 10; set_persist_maybe_null(1); } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
@ -452,7 +452,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
Item_real_func::fix_length_and_dec(); Item_real_func::fix_length_and_dec();
set_persist_maybe_null(1); maybe_null= 1;
} }
}; };
@ -467,7 +467,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
Item_real_func::fix_length_and_dec(); Item_real_func::fix_length_and_dec();
set_persist_maybe_null(1); maybe_null= 1;
} }
}; };
@ -479,7 +479,7 @@ public:
Item_func_srid(Item *a): Item_int_func(a) {} Item_func_srid(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "srid"; } const char *func_name() const { return "srid"; }
void fix_length_and_dec() { max_length= 10; set_persist_maybe_null(1); } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };

View File

@ -146,13 +146,11 @@ void Item_row::update_used_tables()
{ {
used_tables_cache= 0; used_tables_cache= 0;
const_item_cache= 1; const_item_cache= 1;
maybe_null= 0;
for (uint i= 0; i < arg_count; i++) for (uint i= 0; i < arg_count; i++)
{ {
items[i]->update_used_tables(); items[i]->update_used_tables();
used_tables_cache|= items[i]->used_tables(); used_tables_cache|= items[i]->used_tables();
const_item_cache&= items[i]->const_item(); const_item_cache&= items[i]->const_item();
maybe_null|= items[i]->maybe_null;
} }
} }

View File

@ -346,7 +346,7 @@ String *Item_func_sha2::val_str_ascii(String *str)
void Item_func_sha2::fix_length_and_dec() void Item_func_sha2::fix_length_and_dec()
{ {
set_persist_maybe_null(1); maybe_null= 1;
max_length = 0; max_length = 0;
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
@ -472,7 +472,7 @@ String *Item_func_aes_decrypt::val_str(String *str)
void Item_func_aes_decrypt::fix_length_and_dec() void Item_func_aes_decrypt::fix_length_and_dec()
{ {
max_length=args[0]->max_length; max_length=args[0]->max_length;
set_persist_maybe_null(1); maybe_null= 1;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -2494,7 +2494,7 @@ void Item_func_elt::fix_length_and_dec()
set_if_bigger(decimals,args[i]->decimals); set_if_bigger(decimals,args[i]->decimals);
} }
fix_char_length(char_length); fix_char_length(char_length);
set_persist_maybe_null(1); // NULL if wrong first arg maybe_null=1; // NULL if wrong first arg
} }
@ -2689,7 +2689,7 @@ void Item_func_repeat::fix_length_and_dec()
else else
{ {
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
set_persist_maybe_null(1); maybe_null= 1;
} }
} }
@ -2808,7 +2808,7 @@ void Item_func_rpad::fix_length_and_dec()
else else
{ {
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
set_persist_maybe_null(1); maybe_null= 1;
} }
} }
@ -2914,7 +2914,7 @@ void Item_func_lpad::fix_length_and_dec()
else else
{ {
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
set_persist_maybe_null(1); maybe_null= 1;
} }
} }
@ -3891,7 +3891,7 @@ bool Item_func_dyncol_create::fix_fields(THD *thd, Item **ref)
void Item_func_dyncol_create::fix_length_and_dec() void Item_func_dyncol_create::fix_length_and_dec()
{ {
set_persist_maybe_null(1); maybe_null= TRUE;
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
decimals= 0; decimals= 0;
} }

View File

@ -156,7 +156,7 @@ public:
{ {
collation.set(system_charset_info); collation.set(system_charset_info);
max_length= MAX_BLOB_WIDTH; max_length= MAX_BLOB_WIDTH;
set_persist_maybe_null(1); maybe_null= 1;
} }
const char *func_name() const { return "decode_histogram"; } const char *func_name() const { return "decode_histogram"; }
}; };
@ -373,7 +373,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_persist_maybe_null(1); maybe_null=1;
/* 9 = MAX ((8- (arg_len % 8)) + 1) */ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length = args[0]->max_length + 9; max_length = args[0]->max_length + 9;
} }
@ -389,7 +389,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_persist_maybe_null(1); maybe_null=1;
/* 9 = MAX ((8- (arg_len % 8)) + 1) */ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
max_length= args[0]->max_length; max_length= args[0]->max_length;
if (max_length >= 9U) if (max_length >= 9U)
@ -417,7 +417,7 @@ public:
constructor_helper(); constructor_helper();
} }
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() { set_persist_maybe_null(1); max_length = 13; } void fix_length_and_dec() { maybe_null=1; max_length = 13; }
const char *func_name() const { return "encrypt"; } const char *func_name() const { return "encrypt"; }
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
{ {
@ -487,7 +487,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
set_persist_maybe_null(1); maybe_null=1;
} }
const char *func_name() const { return "database"; } const char *func_name() const { return "database"; }
const char *fully_qualified_func_name() const { return "database()"; } const char *fully_qualified_func_name() const { return "database()"; }
@ -661,7 +661,7 @@ public:
{ {
collation.set(default_charset()); collation.set(default_charset());
max_length=64; max_length=64;
set_persist_maybe_null(1); maybe_null= 1;
} }
}; };
@ -688,7 +688,7 @@ public:
Item_func_unhex(Item *a) :Item_str_func(a) Item_func_unhex(Item *a) :Item_str_func(a)
{ {
/* there can be bad hex strings */ /* there can be bad hex strings */
set_persist_maybe_null(1); maybe_null= 1;
} }
const char *func_name() const { return "unhex"; } const char *func_name() const { return "unhex"; }
String *val_str(String *); String *val_str(String *);
@ -774,7 +774,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
collation.set(&my_charset_bin, DERIVATION_COERCIBLE); collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
set_persist_maybe_null(1); maybe_null=1;
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
} }
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)
@ -807,7 +807,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_length_and_charset(3 * 8 + 7, default_charset()); fix_length_and_charset(3 * 8 + 7, default_charset());
set_persist_maybe_null(1); maybe_null= 1;
} }
}; };
@ -934,7 +934,7 @@ public:
{ {
collation.set(system_charset_info); collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough max_length= 64 * collation.collation->mbmaxlen; // should be enough
set_persist_maybe_null(0); maybe_null= 0;
}; };
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
}; };
@ -949,7 +949,7 @@ public:
{ {
collation.set(system_charset_info); collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough max_length= 64 * collation.collation->mbmaxlen; // should be enough
set_persist_maybe_null(0); maybe_null= 0;
}; };
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
}; };
@ -995,8 +995,7 @@ class Item_func_uncompress: public Item_str_func
String buffer; String buffer;
public: public:
Item_func_uncompress(Item *a): Item_str_func(a){} Item_func_uncompress(Item *a): Item_str_func(a){}
void fix_length_and_dec() void fix_length_and_dec(){ maybe_null= 1; max_length= MAX_BLOB_WIDTH; }
{ set_persist_maybe_null(1); max_length= MAX_BLOB_WIDTH; }
const char *func_name() const{return "uncompress";} const char *func_name() const{return "uncompress";}
String *val_str(String *) ZLIB_DEPENDED_FUNCTION String *val_str(String *) ZLIB_DEPENDED_FUNCTION
}; };
@ -1061,7 +1060,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_persist_maybe_null(1); maybe_null= 1;
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
decimals= 0; decimals= 0;
} }
@ -1078,7 +1077,7 @@ public:
:Item_str_func(str, num) :Item_str_func(str, num)
{} {}
void fix_length_and_dec() void fix_length_and_dec()
{ set_persist_maybe_null(1); max_length= MAX_BLOB_WIDTH; } { maybe_null= 1;; max_length= MAX_BLOB_WIDTH; }
/* Mark that collation can change between calls */ /* Mark that collation can change between calls */
bool dynamic_result() { return 1; } bool dynamic_result() { return 1; }
@ -1097,8 +1096,7 @@ class Item_func_dyncol_list: public Item_str_func
{ {
public: public:
Item_func_dyncol_list(Item *str) :Item_str_func(str) {}; Item_func_dyncol_list(Item *str) :Item_str_func(str) {};
void fix_length_and_dec() void fix_length_and_dec() { maybe_null= 1; max_length= MAX_BLOB_WIDTH; };
{ set_persist_maybe_null(1); max_length= MAX_BLOB_WIDTH; };
const char *func_name() const{ return "column_list"; } const char *func_name() const{ return "column_list"; }
String *val_str(String *); String *val_str(String *);
}; };

View File

@ -942,7 +942,7 @@ void Item_func_monthname::fix_length_and_dec()
collation.set(cs, DERIVATION_COERCIBLE, repertoire); collation.set(cs, DERIVATION_COERCIBLE, repertoire);
decimals=0; decimals=0;
max_length= locale->max_month_name_length * collation.collation->mbmaxlen; max_length= locale->max_month_name_length * collation.collation->mbmaxlen;
set_persist_maybe_null(1); maybe_null=1;
} }
@ -1089,7 +1089,7 @@ void Item_func_dayname::fix_length_and_dec()
collation.set(cs, DERIVATION_COERCIBLE, repertoire); collation.set(cs, DERIVATION_COERCIBLE, repertoire);
decimals=0; decimals=0;
max_length= locale->max_day_name_length * collation.collation->mbmaxlen; max_length= locale->max_day_name_length * collation.collation->mbmaxlen;
set_persist_maybe_null(1); maybe_null=1;
} }
@ -1451,7 +1451,7 @@ void Item_temporal_func::fix_length_and_dec()
We set maybe_null to 1 as default as any bad argument with date or We set maybe_null to 1 as default as any bad argument with date or
time can get us to return NULL. time can get us to return NULL.
*/ */
set_persist_maybe_null(1); maybe_null= 1;
max_length= mysql_temporal_int_part_length(field_type()); max_length= mysql_temporal_int_part_length(field_type());
if (decimals) if (decimals)
{ {
@ -1521,7 +1521,7 @@ void Item_func_curdate::fix_length_and_dec()
ltime.hour= ltime.minute= ltime.second= 0; ltime.hour= ltime.minute= ltime.second= 0;
ltime.time_type= MYSQL_TIMESTAMP_DATE; ltime.time_type= MYSQL_TIMESTAMP_DATE;
Item_datefunc::fix_length_and_dec(); Item_datefunc::fix_length_and_dec();
set_persist_maybe_null(0); maybe_null= false;
} }
/** /**
@ -1760,7 +1760,7 @@ void Item_func_date_format::fix_length_and_dec()
collation.collation->mbmaxlen; collation.collation->mbmaxlen;
set_if_smaller(max_length,MAX_BLOB_WIDTH); set_if_smaller(max_length,MAX_BLOB_WIDTH);
} }
set_persist_maybe_null(1); // If wrong date maybe_null=1; // If wrong date
} }
@ -2123,7 +2123,7 @@ void Item_extract::print(String *str, enum_query_type query_type)
void Item_extract::fix_length_and_dec() void Item_extract::fix_length_and_dec()
{ {
set_persist_maybe_null(1); // If wrong date maybe_null=1; // If wrong date
switch (int_type) { switch (int_type) {
case INTERVAL_YEAR: max_length=4; date_value=1; break; case INTERVAL_YEAR: max_length=4; date_value=1; break;
case INTERVAL_YEAR_MONTH: max_length=6; date_value=1; break; case INTERVAL_YEAR_MONTH: max_length=6; date_value=1; break;

View File

@ -80,7 +80,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
enum_monotonicity_info get_monotonicity_info() const; enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp); longlong val_int_endpoint(bool left_endp, bool *incl_endp);
@ -103,7 +103,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null= 1;
} }
enum_monotonicity_info get_monotonicity_info() const; enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp); longlong val_int_endpoint(bool left_endp, bool *incl_endp);
@ -136,7 +136,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -168,7 +168,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_char_length(2); fix_char_length(2);
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -206,7 +206,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_char_length(3); fix_char_length(3);
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -227,7 +227,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -248,7 +248,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -269,7 +269,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=1*MY_CHARSET_BIN_MB_MAXLEN; max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -290,7 +290,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -311,7 +311,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
}; };
@ -325,7 +325,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -348,7 +348,7 @@ public:
{ {
decimals=0; decimals=0;
max_length=4*MY_CHARSET_BIN_MB_MAXLEN; max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -382,7 +382,7 @@ public:
{ {
decimals= 0; decimals= 0;
fix_char_length(1); fix_char_length(1);
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -419,7 +419,7 @@ public:
decimals= args[0]->temporal_precision(arg0_expected_type()); decimals= args[0]->temporal_precision(arg0_expected_type());
set_if_smaller(decimals, TIME_SECOND_PART_DIGITS); set_if_smaller(decimals, TIME_SECOND_PART_DIGITS);
max_length=17 + (decimals ? decimals + 1 : 0); max_length=17 + (decimals ? decimals + 1 : 0);
set_persist_maybe_null(1); maybe_null= true;
} }
void find_num_type() void find_num_type()
{ cached_result_type= decimals ? DECIMAL_RESULT : INT_RESULT; } { cached_result_type= decimals ? DECIMAL_RESULT : INT_RESULT; }
@ -472,7 +472,7 @@ public:
const char *func_name() const { return "time_to_sec"; } const char *func_name() const { return "time_to_sec"; }
void fix_num_length_and_dec() void fix_num_length_and_dec()
{ {
set_persist_maybe_null(1); maybe_null= true;
Item_func_seconds_hybrid::fix_num_length_and_dec(); Item_func_seconds_hybrid::fix_num_length_and_dec();
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
@ -544,7 +544,7 @@ public:
{ {
store_now_in_TIME(&ltime); store_now_in_TIME(&ltime);
Item_timefunc::fix_length_and_dec(); Item_timefunc::fix_length_and_dec();
set_persist_maybe_null(0); maybe_null= false;
} }
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
/* /*
@ -626,7 +626,7 @@ public:
{ {
store_now_in_TIME(&ltime); store_now_in_TIME(&ltime);
Item_temporal_func::fix_length_and_dec(); Item_temporal_func::fix_length_and_dec();
set_persist_maybe_null(0); maybe_null= false;
} }
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
@ -671,7 +671,7 @@ public:
void update_used_tables() void update_used_tables()
{ {
Item_func_now::update_used_tables(); Item_func_now::update_used_tables();
set_persist_maybe_null(0); maybe_null= 0;
used_tables_cache|= RAND_TABLE_BIT; used_tables_cache|= RAND_TABLE_BIT;
} }
}; };
@ -972,7 +972,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
set_persist_maybe_null(1); maybe_null=1;
} }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@ -994,7 +994,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
set_persist_maybe_null(1); maybe_null=1;
} }
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
}; };
@ -1016,7 +1016,7 @@ public:
const char *func_name() const { return "get_format"; } const char *func_name() const { return "get_format"; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_persist_maybe_null(1); maybe_null= 1;
decimals=0; decimals=0;
fix_length_and_charset(17, default_charset()); fix_length_and_charset(17, default_charset());
} }

View File

@ -2604,7 +2604,6 @@ void Item_xml_str_func::fix_length_and_dec()
status_var_increment(current_thd->status_var.feature_xml); status_var_increment(current_thd->status_var.feature_xml);
nodeset_func= 0; nodeset_func= 0;
set_persist_maybe_null(1);
if (agg_arg_charsets_for_comparison(collation, args, arg_count)) if (agg_arg_charsets_for_comparison(collation, args, arg_count))
return; return;

View File

@ -34,10 +34,14 @@ protected:
public: public:
Item_xml_str_func(Item *a, Item *b): Item_xml_str_func(Item *a, Item *b):
Item_str_func(a,b) Item_str_func(a,b)
{} {
maybe_null= TRUE;
}
Item_xml_str_func(Item *a, Item *b, Item *c): Item_xml_str_func(Item *a, Item *b, Item *c):
Item_str_func(a,b,c) Item_str_func(a,b,c)
{} {
maybe_null= TRUE;
}
void fix_length_and_dec(); void fix_length_and_dec();
String *parse_xml(String *raw_xml, String *parsed_xml_buf); String *parse_xml(String *raw_xml, String *parsed_xml_buf);
bool check_vcol_func_processor(uchar *int_arg) bool check_vcol_func_processor(uchar *int_arg)

View File

@ -1494,10 +1494,10 @@ ha_rows DsMrr_impl::dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq,
@retval FALSE No @retval FALSE No
*/ */
bool key_uses_partial_cols(TABLE *table, uint keyno) bool key_uses_partial_cols(TABLE_SHARE *share, uint keyno)
{ {
KEY_PART_INFO *kp= table->key_info[keyno].key_part; KEY_PART_INFO *kp= share->key_info[keyno].key_part;
KEY_PART_INFO *kp_end= kp + table->key_info[keyno].key_parts; KEY_PART_INFO *kp_end= kp + share->key_info[keyno].key_parts;
for (; kp != kp_end; kp++) for (; kp != kp_end; kp++)
{ {
if (!kp->field->part_of_key.is_set(keyno)) if (!kp->field->part_of_key.is_set(keyno))
@ -1518,10 +1518,11 @@ bool key_uses_partial_cols(TABLE *table, uint keyno)
@retval FALSE Otherwise @retval FALSE Otherwise
*/ */
bool DsMrr_impl::check_cpk_scan(THD *thd, uint keyno, uint mrr_flags) bool DsMrr_impl::check_cpk_scan(THD *thd, TABLE_SHARE *share, uint keyno,
uint mrr_flags)
{ {
return test((mrr_flags & HA_MRR_SINGLE_POINT) && return test((mrr_flags & HA_MRR_SINGLE_POINT) &&
keyno == table->s->primary_key && keyno == share->primary_key &&
primary_file->primary_key_is_clustered() && primary_file->primary_key_is_clustered() &&
optimizer_flag(thd, OPTIMIZER_SWITCH_MRR_SORT_KEYS)); optimizer_flag(thd, OPTIMIZER_SWITCH_MRR_SORT_KEYS));
} }
@ -1557,14 +1558,15 @@ bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags,
COST_VECT dsmrr_cost; COST_VECT dsmrr_cost;
bool res; bool res;
THD *thd= current_thd; THD *thd= current_thd;
TABLE_SHARE *share= primary_file->get_table_share();
bool doing_cpk_scan= check_cpk_scan(thd, keyno, *flags); bool doing_cpk_scan= check_cpk_scan(thd, share, keyno, *flags);
bool using_cpk= test(keyno == table->s->primary_key && bool using_cpk= test(keyno == share->primary_key &&
primary_file->primary_key_is_clustered()); primary_file->primary_key_is_clustered());
*flags &= ~HA_MRR_IMPLEMENTATION_FLAGS; *flags &= ~HA_MRR_IMPLEMENTATION_FLAGS;
if (!optimizer_flag(thd, OPTIMIZER_SWITCH_MRR) || if (!optimizer_flag(thd, OPTIMIZER_SWITCH_MRR) ||
*flags & HA_MRR_INDEX_ONLY || *flags & HA_MRR_INDEX_ONLY ||
(using_cpk && !doing_cpk_scan) || key_uses_partial_cols(table, keyno)) (using_cpk && !doing_cpk_scan) || key_uses_partial_cols(share, keyno))
{ {
/* Use the default implementation */ /* Use the default implementation */
*flags |= HA_MRR_USE_DEFAULT_IMPL; *flags |= HA_MRR_USE_DEFAULT_IMPL;
@ -1572,7 +1574,7 @@ bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags,
return TRUE; return TRUE;
} }
uint add_len= table->key_info[keyno].key_length + primary_file->ref_length; uint add_len= share->key_info[keyno].key_length + primary_file->ref_length;
*bufsz -= add_len; *bufsz -= add_len;
if (get_disk_sweep_mrr_cost(keyno, rows, *flags, bufsz, &dsmrr_cost)) if (get_disk_sweep_mrr_cost(keyno, rows, *flags, bufsz, &dsmrr_cost))
return TRUE; return TRUE;

View File

@ -627,7 +627,7 @@ private:
COST_VECT *cost); COST_VECT *cost);
bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
uint *buffer_size, COST_VECT *cost); uint *buffer_size, COST_VECT *cost);
bool check_cpk_scan(THD *thd, uint keyno, uint mrr_flags); bool check_cpk_scan(THD *thd, TABLE_SHARE *share, uint keyno, uint mrr_flags);
bool setup_buffer_sharing(uint key_size_in_keybuf, key_part_map key_tuple_map); bool setup_buffer_sharing(uint key_size_in_keybuf, key_part_map key_tuple_map);

View File

@ -192,7 +192,7 @@ public:
(PREV_BITS(key_part_map, max_loose_keypart+1) & // (3) (PREV_BITS(key_part_map, max_loose_keypart+1) & // (3)
(found_part | loose_scan_keyparts)) == // (3) (found_part | loose_scan_keyparts)) == // (3)
PREV_BITS(key_part_map, max_loose_keypart+1) && // (3) PREV_BITS(key_part_map, max_loose_keypart+1) && // (3)
!key_uses_partial_cols(s->table, key)) !key_uses_partial_cols(s->table->s, key))
{ {
/* Ok, can use the strategy */ /* Ok, can use the strategy */
part1_conds_met= TRUE; part1_conds_met= TRUE;

View File

@ -620,6 +620,15 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
sl->context.outer_context= 0; sl->context.outer_context= 0;
// Prepare underlying views/DT first. // Prepare underlying views/DT first.
sl->handle_derived(lex, DT_PREPARE); sl->handle_derived(lex, DT_PREPARE);
if (derived->outer_join)
{
/* Mark that table is part of OUTER JOIN and fields may be NULL */
for (TABLE_LIST *cursor= (TABLE_LIST*) sl->table_list.first;
cursor;
cursor= cursor->next_local)
cursor->outer_join|= JOIN_TYPE_OUTER;
}
} }
unit->derived= derived; unit->derived= derived;
@ -714,6 +723,10 @@ exit:
/* Add new temporary table to list of open derived tables */ /* Add new temporary table to list of open derived tables */
table->next= thd->derived_tables; table->next= thd->derived_tables;
thd->derived_tables= table; thd->derived_tables= table;
/* If table is used by a left join, mark that any column may be null */
if (derived->outer_join)
table->maybe_null= 1;
} }
if (arena) if (arena)
thd->restore_active_arena(arena, &backup); thd->restore_active_arena(arena, &backup);

View File

@ -8934,7 +8934,7 @@ make_outerjoin_info(JOIN *join)
TABLE_LIST *tbl= table->pos_in_table_list; TABLE_LIST *tbl= table->pos_in_table_list;
TABLE_LIST *embedding= tbl->embedding; TABLE_LIST *embedding= tbl->embedding;
if (tbl->outer_join) if (tbl->outer_join & (JOIN_TYPE_LEFT | JOIN_TYPE_RIGHT))
{ {
/* /*
Table tab is the only one inner table for outer join. Table tab is the only one inner table for outer join.
@ -13384,7 +13384,8 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
table->embedding->nested_join->not_null_tables|= not_null_tables; table->embedding->nested_join->not_null_tables|= not_null_tables;
} }
if (!table->outer_join || (used_tables & not_null_tables)) if (!(table->outer_join & (JOIN_TYPE_LEFT | JOIN_TYPE_RIGHT)) ||
(used_tables & not_null_tables))
{ {
/* /*
For some of the inner tables there are conjunctive predicates For some of the inner tables there are conjunctive predicates

View File

@ -1555,6 +1555,7 @@ typedef struct st_schema_table
#define JOIN_TYPE_LEFT 1 #define JOIN_TYPE_LEFT 1
#define JOIN_TYPE_RIGHT 2 #define JOIN_TYPE_RIGHT 2
#define JOIN_TYPE_OUTER 4 /* Marker that this is an outer join */
#define VIEW_SUID_INVOKER 0 #define VIEW_SUID_INVOKER 0
#define VIEW_SUID_DEFINER 1 #define VIEW_SUID_DEFINER 1

View File

@ -46,7 +46,7 @@ SET(TOKUDB_PLUGIN_DYNAMIC "ha_tokudb")
SET(TOKUDB_SOURCES ha_tokudb.cc) SET(TOKUDB_SOURCES ha_tokudb.cc)
MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY
COMPONENT "tokudb-engine" COMPONENT "tokudb-engine"
LINK_LIBRARIES tokufractaltree_static tokuportability_static z stdc++) LINK_LIBRARIES tokufractaltree_static tokuportability_static ${ZLIB_LIBRARY} stdc++)
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto -fuse-linker-plugin") SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto -fuse-linker-plugin")
IF (INSTALL_SYSCONF2DIR) IF (INSTALL_SYSCONF2DIR)

View File

@ -34,6 +34,7 @@ ExternalProject_Add(build_lzma
CONFIGURE_COMMAND CONFIGURE_COMMAND
"<SOURCE_DIR>/configure" ${xz_configure_opts} "<SOURCE_DIR>/configure" ${xz_configure_opts}
"--prefix=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/xz" "--prefix=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/xz"
"--libdir=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/xz/lib"
BUILD_COMMAND BUILD_COMMAND
${SUBMAKE_COMMAND} -C src/liblzma ${SUBMAKE_COMMAND} -C src/liblzma
INSTALL_COMMAND INSTALL_COMMAND

View File

@ -87,14 +87,14 @@ add_dependencies(ft_static install_tdb_h generate_log_code build_lzma)
## link with lzma (which should be static) and link dependers with zlib ## link with lzma (which should be static) and link dependers with zlib
target_link_libraries(ft LINK_PRIVATE util_static lzma ${LIBTOKUPORTABILITY}) target_link_libraries(ft LINK_PRIVATE util_static lzma ${LIBTOKUPORTABILITY})
target_link_libraries(ft LINK_PUBLIC z) target_link_libraries(ft LINK_PUBLIC ${ZLIB_LIBRARY} )
target_link_libraries(ft_static LINK_PRIVATE lzma) target_link_libraries(ft_static LINK_PRIVATE lzma)
## build the bins in this directory ## build the bins in this directory
foreach(tool tokuftdump tdb_logprint tdb-recover ftverify) foreach(tool tokuftdump tdb_logprint tdb-recover ftverify)
add_executable(${tool} ${tool}.cc) add_executable(${tool} ${tool}.cc)
add_dependencies(${tool} install_tdb_h) add_dependencies(${tool} install_tdb_h)
target_link_libraries(${tool} ft_static util_static z lzma ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS}) target_link_libraries(${tool} ft_static util_static ${ZLIB_LIBRARY} lzma ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
add_space_separated_property(TARGET ${tool} COMPILE_FLAGS -fvisibility=hidden) add_space_separated_property(TARGET ${tool} COMPILE_FLAGS -fvisibility=hidden)
endforeach(tool) endforeach(tool)

View File

@ -109,7 +109,7 @@ static bool check_huge_pages_config_file(const char *fname)
char *r = fgets(buf, sizeof(buf), f); char *r = fgets(buf, sizeof(buf), f);
assert(r != NULL); assert(r != NULL);
if (strstr(buf, "[always]")) { if (strstr(buf, "[always]")) {
fprintf(stderr, "Transparent huge pages are enabled, according to %s\n", fname); fprintf(stderr,"TokuDB: Transparent huge pages are enabled, according to %s. TokuDB will be disabled. To use TokuDB disable huge pages in your kernel or, for testing, set the environment variable TOKU_HUGE_PAGES_OK to 1\n", fname);
huge_pages_enabled = true; huge_pages_enabled = true;
} else { } else {
huge_pages_enabled =false; huge_pages_enabled =false;

View File

@ -19,7 +19,7 @@ set(tokudb_srcs
add_library(${LIBTOKUDB} SHARED ${tokudb_srcs}) add_library(${LIBTOKUDB} SHARED ${tokudb_srcs})
add_dependencies(${LIBTOKUDB} install_tdb_h generate_log_code) add_dependencies(${LIBTOKUDB} install_tdb_h generate_log_code)
target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma ${LIBTOKUPORTABILITY}) target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma ${LIBTOKUPORTABILITY})
target_link_libraries(${LIBTOKUDB} LINK_PUBLIC z) target_link_libraries(${LIBTOKUDB} LINK_PUBLIC ${ZLIB_LIBRARY} )
## make the static library ## make the static library
add_library(tokudb_static_conv STATIC ${tokudb_srcs}) add_library(tokudb_static_conv STATIC ${tokudb_srcs})

View File

@ -360,7 +360,7 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
## #5138 only reproduces when using the static library. ## #5138 only reproduces when using the static library.
list(REMOVE_ITEM tdb_bins test-5138.tdb) list(REMOVE_ITEM tdb_bins test-5138.tdb)
add_executable(test-5138.tdb test-5138.cc) add_executable(test-5138.tdb test-5138.cc)
target_link_libraries(test-5138.tdb ${LIBTOKUDB}_static z ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS}) target_link_libraries(test-5138.tdb ${LIBTOKUDB}_static ${ZLIB_LIBRARY} ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
set_property(TARGET test-5138.tdb APPEND PROPERTY set_property(TARGET test-5138.tdb APPEND PROPERTY
COMPILE_DEFINITIONS "USE_TDB;IS_TDB=1;TOKUDB=1") COMPILE_DEFINITIONS "USE_TDB;IS_TDB=1;TOKUDB=1")
add_space_separated_property(TARGET test-5138.tdb COMPILE_FLAGS -fvisibility=hidden) add_space_separated_property(TARGET test-5138.tdb COMPILE_FLAGS -fvisibility=hidden)

View File

@ -5,7 +5,7 @@ foreach(util ${utils})
add_executable(${util} ${util}.cc) add_executable(${util} ${util}.cc)
set_target_properties(${util} PROPERTIES set_target_properties(${util} PROPERTIES
COMPILE_DEFINITIONS "IS_TDB=1;USE_TDB=1;TDB_IS_STATIC=1") COMPILE_DEFINITIONS "IS_TDB=1;USE_TDB=1;TDB_IS_STATIC=1")
target_link_libraries(${util} ${LIBTOKUDB}_static ft_static z lzma ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS}) target_link_libraries(${util} ${LIBTOKUDB}_static ft_static ${ZLIB_LIBRARY} lzma ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
add_space_separated_property(TARGET ${util} COMPILE_FLAGS -fvisibility=hidden) add_space_separated_property(TARGET ${util} COMPILE_FLAGS -fvisibility=hidden)

View File

@ -0,0 +1,11 @@
package My::Suite::TokuDB;
use File::Basename;
@ISA = qw(My::Suite);
# Ensure we can run the TokuDB tests even if hugepages are enabled
$ENV{TOKU_HUGE_PAGES_OK}=1;
#return "Not run for embedded server" if $::opt_embedded_server;
return "No TokuDB engine" unless $ENV{HA_TOKUDB_SO} or $::mysqld_variables{tokudb};
bless { };

View File

@ -2,6 +2,9 @@ package My::Suite::TokuDB;
use File::Basename; use File::Basename;
@ISA = qw(My::Suite); @ISA = qw(My::Suite);
# Ensure we can run the TokuDB tests even if hugepages are enabled
$ENV{TOKU_HUGE_PAGES_OK}=1;
#return "Not run for embedded server" if $::opt_embedded_server; #return "Not run for embedded server" if $::opt_embedded_server;
return "No TokuDB engine" unless $ENV{HA_TOKUDB_SO} or $::mysqld_variables{tokudb}; return "No TokuDB engine" unless $ENV{HA_TOKUDB_SO} or $::mysqld_variables{tokudb};
bless { }; bless { };