Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
MariaDB and MySQL Packaging Team
mariadb-5.5
Commits
ac824fa5
Commit
ac824fa5
authored
Jan 19, 2017
by
Otto Kekäläinen
Browse files
Merge tag 'upstream/5.5.54' into ubuntu-14.04
Upstream version 5.5.54
parents
823a5cd5
aa39e58b
Changes
129
Show whitespace changes
Inline
Side-by-side
mysql-test/t/type_decimal.test
View file @
ac824fa5
...
...
@@ -604,6 +604,11 @@ SHOW COLUMNS FROM t1dec102;
SELECT
COLUMN_NAME
,
DATA_TYPE
,
COLUMN_TYPE
FROM
INFORMATION_SCHEMA
.
COLUMNS
WHERE
TABLE_NAME
=
't1dec102'
;
DROP
TABLE
t1dec102
;
#
# MDEV-10552 equality operation on cast of the value "-0.0" to decimal not working
#
select
cast
(
'-0.0'
as
decimal
(
5
,
1
))
<
0
;
--
echo
#
--
echo
# End of 5.5 tests
--
echo
#
mysql-test/t/union.test
View file @
ac824fa5
...
...
@@ -1022,7 +1022,6 @@ ORDER BY a;
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
--
echo
#
--
echo
# Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
--
echo
# subselects into account
...
...
@@ -1126,6 +1125,8 @@ create table t1 (a int);
insert
into
t1
values
(
10
),(
10
),(
10
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
),(
1
),(
10
);
--
sorted_result
select
a
from
t1
where
false
UNION
select
a
from
t1
limit
8
;
--
sorted_result
(
select
a
from
t1
where
false
)
UNION
(
select
a
from
t1
)
limit
8
;
drop
table
t1
;
--
echo
#
...
...
@@ -1350,3 +1351,22 @@ UNION
;
drop
table
t1
;
--
echo
#
--
echo
# MDEV-10172: UNION query returns incorrect rows outside
--
echo
# conditional evaluation
--
echo
#
create
table
t1
(
d
datetime
not
null
primary
key
);
insert
into
t1
(
d
)
values
(
'2016-06-01'
),(
'2016-06-02'
),(
'2016-06-03'
),(
'2016-06-04'
);
select
*
from
(
select
*
from
t1
where
d
between
'2016-06-02'
and
'2016-06-05'
union
(
select
*
from
t1
where
d
<
'2016-06-05'
order
by
d
desc
limit
1
)
)
onlyJun2toJun4
order
by
d
;
drop
table
t1
;
--
echo
End
of
5.0
tests
mysys/CMakeLists.txt
View file @
ac824fa5
...
...
@@ -44,7 +44,7 @@ IF (WIN32)
ENDIF
()
IF
(
UNIX
)
SET
(
MYSYS_SOURCES
${
MYSYS_SOURCES
}
my_addr_resolve.c
)
SET
(
MYSYS_SOURCES
${
MYSYS_SOURCES
}
my_addr_resolve.c
my_setuser.c
)
ENDIF
()
IF
(
HAVE_ALARM
)
...
...
mysys/my_setuser.c
0 → 100644
View file @
ac824fa5
#include
<my_global.h>
#include
<m_string.h>
#include
<my_sys.h>
#include
<my_pthread.h>
#ifdef HAVE_PWD_H
#include
<pwd.h>
#endif
#ifdef HAVE_GRP_H
#include
<grp.h>
#endif
struct
passwd
*
my_check_user
(
const
char
*
user
,
myf
MyFlags
)
{
struct
passwd
*
user_info
;
uid_t
user_id
=
geteuid
();
DBUG_ENTER
(
"my_check_user"
);
// Don't bother if we aren't superuser
if
(
user_id
)
{
if
(
user
)
{
/* Don't give a warning, if real user is same as given with --user */
user_info
=
getpwnam
(
user
);
if
(
!
user_info
||
user_id
!=
user_info
->
pw_uid
)
{
my_errno
=
EPERM
;
if
(
MyFlags
&
MY_WME
)
my_printf_error
(
my_errno
,
"One can only use the --user switch if "
"running as root"
,
MYF
(
ME_JUST_WARNING
|
ME_NOREFRESH
));
}
}
DBUG_RETURN
(
NULL
);
}
if
(
!
user
)
{
if
(
MyFlags
&
MY_FAE
)
{
my_errno
=
EINVAL
;
my_printf_error
(
my_errno
,
"Please consult the Knowledge Base to find "
"out how to run mysqld as root!"
,
MYF
(
ME_NOREFRESH
));
}
DBUG_RETURN
(
NULL
);
}
if
(
!
strcmp
(
user
,
"root"
))
DBUG_RETURN
(
NULL
);
if
(
!
(
user_info
=
getpwnam
(
user
)))
{
// Allow a numeric uid to be used
int
err
=
0
;
user_id
=
my_strtoll10
(
user
,
NULL
,
&
err
);
if
(
err
||
!
(
user_info
=
getpwuid
(
user_id
)))
{
my_errno
=
EINVAL
;
my_printf_error
(
my_errno
,
"Can't change to run as user '%s'. Please "
"check that the user exists!"
,
MYF
(
ME_NOREFRESH
),
user
);
DBUG_RETURN
(
NULL
);
}
}
DBUG_ASSERT
(
user_info
);
DBUG_RETURN
(
user_info
);
}
int
my_set_user
(
const
char
*
user
,
struct
passwd
*
user_info
,
myf
MyFlags
)
{
DBUG_ENTER
(
"my_set_user"
);
DBUG_ASSERT
(
user_info
!=
0
);
#ifdef HAVE_INITGROUPS
initgroups
(
user
,
user_info
->
pw_gid
);
#endif
if
(
setgid
(
user_info
->
pw_gid
)
==
-
1
||
setuid
(
user_info
->
pw_uid
)
==
-
1
)
{
my_errno
=
errno
;
if
(
MyFlags
&
MY_WME
)
my_error
(
my_errno
,
MYF
(
ME_NOREFRESH
));
DBUG_RETURN
(
my_errno
);
}
DBUG_RETURN
(
0
);
}
plugin/server_audit/server_audit.c
View file @
ac824fa5
...
...
@@ -2845,6 +2845,7 @@ void __attribute__ ((constructor)) audit_plugin_so_init(void)
_mysql_plugin_declarations_
[
0
].
info
=
mysql_v4_descriptor
;
use_event_data_for_disconnect
=
1
;
}
MYSQL_SYSVAR_NAME
(
loc_info
).
flags
=
PLUGIN_VAR_READONLY
|
PLUGIN_VAR_MEMALLOC
;
}
memset
(
locinfo_ini_value
,
'O'
,
sizeof
(
locinfo_ini_value
)
-
1
);
...
...
scripts/mysql_install_db.sh
View file @
ac824fa5
...
...
@@ -512,10 +512,8 @@ then
echo
"The latest information about MariaDB is available at http://mariadb.org/."
echo
"You can find additional information about the MySQL part at:"
echo
"http://dev.mysql.com"
echo
"Support MariaDB development by buying support/new features from MariaDB"
echo
"Corporation Ab. You can contact us about this at sales@mariadb.com."
echo
"Alternatively consider joining our community based development effort:"
echo
"http://mariadb.com/kb/en/contributing-to-the-mariadb-project/"
echo
"Consider joining MariaDB's strong and vibrant community:"
echo
"https://mariadb.org/get-involved/"
echo
fi
...
...
scripts/mysqld_safe.sh
View file @
ac824fa5
...
...
@@ -20,6 +20,7 @@ mysqld_ld_preload=
mysqld_ld_library_path
=
flush_caches
=
0
numa_interleave
=
0
unsafe_my_cnf
=
0
# Initial logging status: error log is not open, and not using syslog
logging
=
init
...
...
@@ -128,6 +129,18 @@ my_which ()
return
$ret
# Success
}
find_in_bin
()
{
if
test
-x
"
$MY_BASEDIR_VERSION
/bin/
$1
"
then
echo
"
$MY_BASEDIR_VERSION
/bin/
$1
"
elif
test
-x
"@bindir@/
$1
"
then
echo
"@bindir@/
$1
"
else
echo
"
$1
"
fi
}
log_generic
()
{
priority
=
"
$1
"
shift
...
...
@@ -136,7 +149,7 @@ log_generic () {
echo
"
$msg
"
case
$logging
in
init
)
;;
# Just echo the message, don't save it anywhere
file
)
echo
"
$msg
"
>>
"
$err_log
"
;;
file
)
echo
"
$msg
"
|
"
$helper
"
"
$user
"
log
"
$err_log
"
;;
syslog
)
logger
-t
"
$syslog_tag_mysqld_safe
"
-p
"
$priority
"
"
$*
"
;;
*
)
echo
"Internal program error (non-fatal):"
\
...
...
@@ -156,7 +169,7 @@ log_notice () {
eval_log_error
()
{
cmd
=
"
$1
"
case
$logging
in
file
)
cmd
=
"
$cmd
>>
"
`
shell_quote_string
"
$
err_
log
"
`
" 2>&1"
;;
file
)
cmd
=
"
$cmd
2>&1 |
"
`
shell_quote_string
"
$
helper
"
`
"
$user
log
"
`
shell_quote_string
"
$err_log
"
`
;;
syslog
)
# mysqld often prefixes its messages with a timestamp, which is
# redundant when logging to syslog (which adds its own timestamp)
...
...
@@ -190,6 +203,13 @@ shell_quote_string() {
echo
"
$1
"
|
sed
-e
's,\([^a-zA-Z0-9/_.=-]\),\\\1,g'
}
check_executable_location
()
{
if
test
"
$unsafe_my_cnf
"
=
1
-a
"
$unrecognized_handling
"
!=
collect
;
then
log_error
"Cannot accept
$1
from a config file, when my.cnf is in the datadir"
exit
1
fi
}
parse_arguments
()
{
for
arg
do
# the parameter after "=", or the whole $arg if no match
...
...
@@ -200,7 +220,6 @@ parse_arguments() {
optname_subst
=
`
echo
"
$optname
"
|
sed
's/_/-/g'
`
arg
=
`
echo
$arg
|
sed
"s/^
$optname
/
$optname_subst
/"
`
case
"
$arg
"
in
--crash-script
=
*
)
CRASH_SCRIPT
=
"
$val
"
;;
# these get passed explicitly to mysqld
--basedir
=
*
)
MY_BASEDIR_VERSION
=
"
$val
"
;;
--datadir
=
*
|
--data
=
*
)
DATADIR
=
"
$val
"
;;
...
...
@@ -220,12 +239,14 @@ parse_arguments() {
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
--core-file-size
=
*
)
core_file_size
=
"
$val
"
;;
--ledir
=
*
)
ledir
=
"
$val
"
;;
--malloc-lib
=
*
)
set_malloc_lib
"
$val
"
;;
--mysqld
=
*
)
MYSQLD
=
"
$val
"
;;
--ledir
=
*
)
check_executable_location
"
$arg
"
;
ledir
=
"
$val
"
;;
--malloc-lib
=
*
)
check_executable_location
"
$arg
"
;
set_malloc_lib
"
$val
"
;;
--crash-script
=
*
)
check_executable_location
"
$arg
"
;
crash_script
=
"
$val
"
;;
--mysqld
=
*
)
check_executable_location
"
$arg
"
;
MYSQLD
=
"
$val
"
;;
--mysqld-version
=
*
)
if
test
-n
"
$val
"
then
check_executable_location
"
$arg
"
MYSQLD
=
"mysqld-
$val
"
PLUGIN_VARIANT
=
"/
$val
"
else
...
...
@@ -385,15 +406,8 @@ set_malloc_lib() {
# First, try to find BASEDIR and ledir (where mysqld is)
#
if
echo
'@pkgdatadir@'
|
grep
'^@prefix@'
>
/dev/null
then
relpkgdata
=
`
echo
'@pkgdatadir@'
|
sed
-e
's,^@prefix@,,'
-e
's,^/,,'
-e
's,^,./,'
`
else
# pkgdatadir is not relative to prefix
relpkgdata
=
'@pkgdatadir@'
fi
MY_PWD
=
`
pwd
`
MY_PWD
=
`
dirname
$0
`
MY_PWD
=
`
cd
"
$MY_PWD
"
/..
&&
pwd
`
# Check for the directories we would expect from a binary release install
if
test
-n
"
$MY_BASEDIR_VERSION
"
-a
-d
"
$MY_BASEDIR_VERSION
"
then
...
...
@@ -409,16 +423,16 @@ then
else
ledir
=
"
$MY_BASEDIR_VERSION
/bin"
fi
elif
test
-f
"
$relpkgdata
"
/english/errmsg.sys
-a
-x
"
$MY_PWD
/bin/mysqld"
elif
test
-x
"
$MY_PWD
/bin/mysqld"
then
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where bin, share and data are
ledir
=
"
$MY_PWD
/bin"
# Where mysqld is
# Check for the directories we would expect from a source install
elif
test
-f
"
$relpkgdata
"
/english/errmsg.sys
-a
-x
"
$MY_PWD
/libexec/mysqld"
elif
test
-x
"
$MY_PWD
/libexec/mysqld"
then
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where libexec, share and var are
ledir
=
"
$MY_PWD
/libexec"
# Where mysqld is
elif
test
-f
"
$relpkgdata
"
/english/errmsg.sys
-a
-x
"
$MY_PWD
/sbin/mysqld"
elif
test
-x
"
$MY_PWD
/sbin/mysqld"
then
MY_BASEDIR_VERSION
=
"
$MY_PWD
"
# Where sbin, share and var are
ledir
=
"
$MY_PWD
/sbin"
# Where mysqld is
...
...
@@ -428,6 +442,8 @@ else
ledir
=
'@libexecdir@'
fi
helper
=
`
find_in_bin mysqld_safe_helper
`
print_defaults
=
`
find_in_bin my_print_defaults
`
#
# Second, try to find the data directory
...
...
@@ -465,6 +481,7 @@ IGNORING $DATADIR/my.cnf"
log_error
"WARNING: Found
$DATADIR
/my.cnf
The data directory is a deprecated location for my.cnf, please move it to
$MY_BASEDIR_VERSION
/my.cnf"
unsafe_my_cnf
=
1
MYSQL_HOME
=
$DATADIR
else
MYSQL_HOME
=
$MY_BASEDIR_VERSION
...
...
@@ -472,34 +489,15 @@ $MY_BASEDIR_VERSION/my.cnf"
fi
export
MYSQL_HOME
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
# and then merge with the command line arguments
if
test
-x
"
$MY_BASEDIR_VERSION
/bin/my_print_defaults"
then
print_defaults
=
"
$MY_BASEDIR_VERSION
/bin/my_print_defaults"
elif
test
-x
`
dirname
$0
`
/my_print_defaults
then
print_defaults
=
"
`
dirname
$0
`
/my_print_defaults"
elif
test
-x
./bin/my_print_defaults
then
print_defaults
=
"./bin/my_print_defaults"
elif
test
-x
@bindir@/my_print_defaults
then
print_defaults
=
"@bindir@/my_print_defaults"
elif
test
-x
@bindir@/mysql_print_defaults
then
print_defaults
=
"@bindir@/mysql_print_defaults"
else
print_defaults
=
"my_print_defaults"
fi
append_arg_to_args
()
{
args
=
"
$args
"
`
shell_quote_string
"
$1
"
`
}
args
=
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
# and then merge with the command line arguments
SET_USER
=
2
parse_arguments
`
$print_defaults
$defaults
--loose-verbose
--mysqld
`
if
test
$SET_USER
-eq
2
...
...
@@ -603,11 +601,6 @@ then
log_notice
"Logging to '
$err_log
'."
logging
=
file
if
[
!
-f
"
$err_log
"
]
;
then
# if error log already exists,
touch
"
$err_log
"
# we just append. otherwise,
chmod
"
$fmode
"
"
$err_log
"
# fix the permissions here!
fi
else
if
[
-n
"
$syslog_tag
"
]
then
...
...
@@ -620,10 +613,6 @@ else
logging
=
syslog
fi
# close stdout and stderr, everything goes to $logging now
exec
1>&-
exec
2>&-
USER_OPTION
=
""
if
test
-w
/
-o
"
$USER
"
=
"root"
then
...
...
@@ -631,11 +620,6 @@ then
then
USER_OPTION
=
"--user=
$user
"
fi
# Change the err log to the right user, if it is in use
if
[
$want_syslog
-eq
0
]
;
then
touch
"
$err_log
"
chown
$user
"
$err_log
"
fi
if
test
-n
"
$open_files
"
then
ulimit
-n
$open_files
...
...
@@ -879,6 +863,10 @@ max_fast_restarts=5
# flag whether a usable sleep command exists
have_sleep
=
1
# close stdout and stderr, everything goes to $logging now
exec
1>&-
exec
2>&-
while
true
do
rm
-f
"
$pid_file
"
# Some extra safety
...
...
@@ -886,13 +874,6 @@ do
start_time
=
`
date
+%M%S
`
eval_log_error
"
$cmd
"
if
[
$want_syslog
-eq
0
-a
!
-f
"
$err_log
"
]
;
then
touch
"
$err_log
"
# hypothetical: log was renamed but not
chown
$user
"
$err_log
"
# flushed yet. we'd recreate it with
chmod
"
$fmode
"
"
$err_log
"
# wrong owner next time we log, so set
fi
# it up correctly while we can!
end_time
=
`
date
+%M%S
`
if
test
!
-f
"
$pid_file
"
# This is removed if normal shutdown
...
...
@@ -956,9 +937,9 @@ do
done
fi
log_notice
"mysqld restarted"
if
test
-n
"
$
CRASH_SCRIPT
"
if
test
-n
"
$
crash_script
"
then
crash_script_output
=
`
$
CRASH_SCRIPT
2>&1
`
crash_script_output
=
`
$
crash_script
2>&1
`
log_error
"
$crash_script_output
"
fi
done
...
...
sql/event_db_repository.cc
View file @
ac824fa5
...
...
@@ -17,6 +17,7 @@
#include
"sql_priv.h"
#include
"unireg.h"
#include
"sql_base.h"
// close_thread_tables
#include
"sql_parse.h"
#include
"event_db_repository.h"
#include
"key.h"
// key_copy
#include
"sql_db.h"
// get_default_db_collation
...
...
@@ -702,19 +703,17 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
restore_record
(
table
,
s
->
default_values
);
// Get default values for fields
if
(
system_charset_info
->
cset
->
numchars
(
system_charset_info
,
parse_data
->
dbname
.
str
,
parse_data
->
dbname
.
str
+
parse_data
->
dbname
.
length
)
>
table
->
field
[
ET_FIELD_DB
]
->
char_length
())
if
(
check_string_char_length
(
&
parse_data
->
dbname
,
0
,
table
->
field
[
ET_FIELD_DB
]
->
char_length
(),
system_charset_info
,
1
))
{
my_error
(
ER_TOO_LONG_IDENT
,
MYF
(
0
),
parse_data
->
dbname
.
str
);
goto
end
;
}
if
(
system_charset_info
->
cset
->
numchars
(
system_charset_info
,
parse_data
->
name
.
str
,
parse_data
->
name
.
str
+
parse_data
->
name
.
length
)
>
table
->
field
[
ET_FIELD_NAME
]
->
char_length
())
if
(
check_string_char_length
(
&
parse_data
->
name
,
0
,
table
->
field
[
ET_FIELD_NAME
]
->
char_length
(),
system_charset_info
,
1
))
{
my_error
(
ER_TOO_LONG_IDENT
,
MYF
(
0
),
parse_data
->
name
.
str
);
goto
end
;
...
...
sql/field.cc
View file @
ac824fa5
...
...
@@ -1156,13 +1156,16 @@ void Field_num::prepend_zeros(String *value)
{
int
diff
;
if
((
diff
=
(
int
)
(
field_length
-
value
->
length
()))
>
0
)
{
const
bool
error
=
value
->
realloc
(
field_length
);
if
(
!
error
)
{
bmove_upp
((
uchar
*
)
value
->
ptr
()
+
field_length
,
(
uchar
*
)
value
->
ptr
()
+
value
->
length
(),
value
->
length
());
bfill
((
uchar
*
)
value
->
ptr
(),
diff
,
'0'
);
value
->
length
(
field_length
);
(
void
)
value
->
c_ptr_quick
();
// Avoid warnings in purify
}
}
}
...
...
sql/filesort.cc
View file @
ac824fa5
...
...
@@ -1411,7 +1411,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
if
(
!
(
error
=
(
int
)
read_to_buffer
(
from_file
,
buffpek
,
rec_length
)))
{
queue_remove
(
&
queue
,
0
);
(
void
)
queue_remove
_top
(
&
queue
);
reuse_freed_buff
(
&
queue
,
buffpek
,
rec_length
);
}
else
if
(
error
==
-
1
)
...
...
sql/handler.cc
View file @
ac824fa5
...
...
@@ -3924,7 +3924,7 @@ void handler::get_dynamic_partition_info(PARTITION_STATS *stat_info,
stat_info
->
update_time
=
stats
.
update_time
;
stat_info
->
check_time
=
stats
.
check_time
;
stat_info
->
check_sum
=
0
;
if
(
table_flags
()
&
(
HA_HAS_OLD_CHECKSUM
|
HA_HAS_
OLD
_CHECKSUM
))
if
(
table_flags
()
&
(
HA_HAS_OLD_CHECKSUM
|
HA_HAS_
NEW
_CHECKSUM
))
stat_info
->
check_sum
=
checksum
();
return
;
}
...
...
sql/item.cc
View file @
ac824fa5
...
...
@@ -1164,7 +1164,8 @@ Item *Item_cache::safe_charset_converter(CHARSET_INFO *tocs)
if
(
conv
==
example
)
return
this
;
Item_cache
*
cache
;
if
(
!
conv
||
!
(
cache
=
new
Item_cache_str
(
conv
)))
if
(
!
conv
||
conv
->
fix_fields
(
current_thd
,
(
Item
**
)
NULL
)
||
!
(
cache
=
new
Item_cache_str
(
conv
)))
return
NULL
;
// Safe conversion is not possible, or OEM
cache
->
setup
(
conv
);
cache
->
fixed
=
false
;
// Make Item::fix_fields() happy
...
...
@@ -2777,6 +2778,44 @@ void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref)
depended_from
=
NULL
;
if
(
context
)
{
bool
need_change
=
false
;
/*
Suppose there are nested selects:
select_id=1
select_id=2
select_id=3 <----+
select_id=4 -+
select_id=5 --+
Suppose, pullout operation has moved anything that had select_id=4 or 5
in to select_id=3.
If this Item_field had a name resolution context pointing into select_lex
with id=4 or id=5, it needs a new name resolution context.
However, it could also be that this object is a part of outer reference:
Item_ref(Item_field(field in select with select_id=1))).
- The Item_ref object has a context with select_id=5, and so needs a new
name resolution context.
- The Item_field object has a context with select_id=1, and doesn't need
a new name resolution context.
So, the following loop walks from Item_field's current context upwards.
If we find that the select we've been pulled out to is up there, we
create the new name resolution context. Otherwise, we don't.
*/
for
(
Name_resolution_context
*
ct
=
context
;
ct
;
ct
=
ct
->
outer_context
)
{
if
(
new_parent
==
ct
->
select_lex
)
{
need_change
=
true
;
break
;
}
}
if
(
!
need_change
)
return
;
Name_resolution_context
*
ctx
=
new
Name_resolution_context
();
if
(
context
->
select_lex
==
new_parent
)
{
...
...
@@ -4556,8 +4595,6 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
const
char
*
field_name
;
ORDER
*
found_group
=
NULL
;
int
found_match_degree
=
0
;
Item_ident
*
cur_field
;
int
cur_match_degree
=
0
;
char
name_buff
[
SAFE_NAME_LEN
+
1
];
if
(
find_item
->
type
()
==
Item
::
FIELD_ITEM
||
...
...
@@ -4582,36 +4619,53 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
for
(
ORDER
*
cur_group
=
group_list
;
cur_group
;
cur_group
=
cur_group
->
next
)
{
if
((
*
(
cur_group
->
item
))
->
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
)
int
cur_match_degree
=
0
;
/* SELECT list element with explicit alias */
if
((
*
(
cur_group
->
item
))
->
name
&&
!
(
*
(
cur_group
->
item
))
->
is_autogenerated_name
&&
!
my_strcasecmp
(
system_charset_info
,
(
*
(
cur_group
->
item
))
->
name
,
field_name
))
{
++
cur_match_degree
;
}
/* Reference on the field or view/derived field. */
else
if
((
*
(
cur_group
->
item
))
->
type
()
==
Item
::
FIELD_ITEM
||
(
*
(
cur_group
->
item
))
->
type
()
==
Item
::
REF_ITEM
)
{
cur_field
=
(
Item_ident
*
)
*
cur_group
->
item
;
cur_match_degree
=
0
;
Item_ident
*
cur_field
=
(
Item_ident
*
)
*
cur_group
->
item
;
const
char
*
l_db_name
=
cur_field
->
db_name
;
const
char
*
l_table_name
=
cur_field
->
table_name
;
const
char
*
l_field_name
=
cur_field
->
field_name
;
DBUG_ASSERT
(
cur_field
->
field_name
!=
0
);
DBUG_ASSERT
(
l_
field_name
!=
0
);
if
(
!
my_strcasecmp
(
system_charset_info
,
cur_field
->
field_name
,
field_name
))
l_
field_name
,
field_name
))
++
cur_match_degree
;
else
continue
;
if
(
cur_field
->
table_name
&&
table_name
)
if
(
l_
table_name
&&
table_name
)
{
/* If field_name is qualified by a table name. */
if
(
my_strcasecmp
(
table_alias_charset
,
cur_field
->
table_name
,
table_name
))
if
(
my_strcasecmp
(
table_alias_charset
,
l_
table_name
,
table_name
))
/* Same field names, different tables. */
return
NULL
;
++
cur_match_degree
;
if
(
cur_field
->
db_name
&&
db_name
)
if
(
l_
db_name
&&
db_name
)
{
/* If field_name is also qualified by a database name. */
if
(
strcmp
(
cur_field
->
db_name
,
db_name
))
if
(
strcmp
(
l_
db_name
,
db_name
))
/* Same field names, different databases. */
return
NULL
;
++
cur_match_degree
;
}
}
}
else
continue
;
if
(
cur_match_degree
>
found_match_degree
)
{
...
...
@@ -4619,7 +4673,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
found_group
=
cur_group
;
}
else
if
(
found_group
&&
(
cur_match_degree
==
found_match_degree
)
&&
!
(
*
(
found_group
->
item
))
->
eq
(
cur_
field
,
0
))
!
(
*
(
found_group
->
item
))
->
eq
(
(
*
(
cur_
group
->
item
))
,
0
))
{
/*
If the current resolve candidate matches equally well as the current
...
...
@@ -4631,7 +4685,6 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
return
NULL
;
}
}
}
if
(
found_group
)
return
found_group
->
item
;
...
...
@@ -5743,6 +5796,7 @@ String *Item::check_well_formed_result(String *str, bool send_error)
uint
wlen
=
cs
->
cset
->
well_formed_len
(
cs
,
str
->
ptr
(),
str
->
ptr
()
+
str
->
length
(),
str
->
length
(),
&
well_formed_error
);
null_value
=
false
;
if
(
wlen
<
str
->
length
())
{
THD
*
thd
=
current_thd
;
...
...
sql/item.h
View file @
ac824fa5
...
...
@@ -3294,7 +3294,7 @@ class Item_cache_wrapper :public Item_result_field
if
(
result_type
()
==
ROW_RESULT
)
orig_item
->
bring_value
();
}
virtual
bool
is_expensive
()
{
return
orig_item
->
is_expensive
();
}
bool
is_expensive
()
{
return
orig_item
->
is_expensive
();
}
bool
is_expensive_processor
(
uchar
*
arg
)
{
return
orig_item
->
is_expensive_processor
(
arg
);
}
bool
check_vcol_func_processor
(
uchar
*
arg
)
...
...
sql/item_func.cc
View file @
ac824fa5
...
...
@@ -6778,7 +6778,8 @@ Item_func_sp::init_result_field(THD *thd)
bool
Item_func_sp
::
is_expensive
()
{
return
!
(
m_sp
->
m_chistics
->
detistic
);
return
!
m_sp
->
m_chistics
->
detistic
||
current_thd
->
locked_tables_mode
<
LTM_LOCK_TABLES
;
}
...
...
sql/item_func.h
View file @
ac824fa5
...
...
@@ -39,6 +39,7 @@ class Item_func :public Item_result_field
0 means get this number from first argument
*/
uint
allowed_arg_cols
;
String
*
val_str_from_val_str_ascii
(
String
*
str
,
String
*
str2
);
void
count_only_length
(
Item
**
item
,
uint
nitems
);
void
count_real_length
(
Item
**
item
,
uint
nitems
);
...
...
sql/item_strfunc.cc
View file @
ac824fa5
...
...
@@ -70,7 +70,7 @@ size_t username_char_length= 16;
Normally conversion does not happen, and val_str_ascii() is immediately
returned instead.
*/
String
*
Item_
str_
func
::
val_str_from_val_str_ascii
(
String
*
str
,
String
*
str2
)
String
*
Item_func
::
val_str_from_val_str_ascii
(
String
*
str
,
String
*
str2
)
{
DBUG_ASSERT
(
fixed
==
1
);
...
...
sql/item_strfunc.h
View file @
ac824fa5
...
...
@@ -62,7 +62,6 @@ class Item_str_func :public Item_func
enum
Item_result
result_type
()
const
{
return
STRING_RESULT
;
}
void
left_right_max_length
();
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
String
*
val_str_from_val_str_ascii
(
String
*
str
,
String
*
str2
);
};
...
...
sql/item_subselect.cc
View file @
ac824fa5
/* Copyright (c) 2002, 201
5
, Oracle and/or its affiliates.
Copyright (c) 2010, 201
5
, MariaDB
/* Copyright (c) 2002, 201
6
, Oracle and/or its affiliates.
Copyright (c) 2010, 201
6
, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -209,6 +209,7 @@ bool
Item_subselect
::
select_transformer
(
JOIN
*
join
)
{
DBUG_ENTER
(
"Item_subselect::select_transformer"
);
DBUG_ASSERT
(
thd
==
join
->
thd
);
DBUG_RETURN
(
false
);
}
...
...
@@ -579,7 +580,7 @@ bool Item_subselect::is_expensive()
examined_rows
+=
cur_join
->
get_examined_rows
();
}
// here we are sure that subquery is optimized so thd is set
return
(
examined_rows
>
thd
->
variables
.
expensive_subquery_limit
);
}
...
...
@@ -643,6 +644,7 @@ bool Item_subselect::exec()
subselect_engine
*
org_engine
=
engine
;
DBUG_ENTER
(
"Item_subselect::exec"
);
DBUG_ASSERT
(
fixed
);
/*
Do not execute subselect in case of a fatal error
...
...
@@ -688,6 +690,7 @@ int Item_in_subselect::optimize(double *out_rows, double *cost)
{
int
res
;
DBUG_ENTER
(
"Item_in_subselect::optimize"
);
DBUG_ASSERT
(
fixed
);
SELECT_LEX
*
save_select
=
thd
->
lex
->
current_select
;
JOIN
*
join
=
unit
->
first_select
()
->
join
;
...
...
@@ -802,6 +805,7 @@ bool Item_in_subselect::expr_cache_is_needed(THD *thd)
bool
Item_in_subselect
::
exec
()
{
DBUG_ENTER
(
"Item_in_subselect::exec"
);
DBUG_ASSERT
(
fixed
);
/*
Initialize the cache of the left predicate operand. This has to be done as
late as now, because Cached_item directly contains a resolved field (not
...
...
@@ -856,6 +860,7 @@ table_map Item_subselect::used_tables() const
bool
Item_subselect
::
const_item
()
const
{
DBUG_ASSERT
(
thd
);
return
(
thd
->
lex
->
context_analysis_only
?
FALSE
:
forced_const
||
const_item_cache
);
...
...
@@ -1049,6 +1054,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
DBUG_ENTER
(
"Item_singlerow_subselect::select_transformer"
);
if
(
changed
)
DBUG_RETURN
(
false
);
DBUG_ASSERT
(
join
->
thd
==
thd
);
SELECT_LEX
*
select_lex
=
join
->
select_lex
;
Query_arena
*
arena
=
thd
->
stmt_arena
;
...
...
@@ -1717,6 +1723,7 @@ Item_in_subselect::single_value_transformer(JOIN *join)
{
SELECT_LEX
*
select_lex
=
join
->
select_lex
;
DBUG_ENTER
(
"Item_in_subselect::single_value_transformer"
);
DBUG_ASSERT
(
thd
==
join
->
thd
);
/*
Check that the right part of the subselect contains no more than one
...
...
@@ -1829,9 +1836,9 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
if
(
!
test_strategy
(
SUBS_MAXMIN_INJECTED
|
SUBS_MAXMIN_ENGINE
))
DBUG_RETURN
(
false
);
Item
**
place
=
optimizer
->
arguments
()
+
1
;
THD
*
thd
=
join
->
thd
;
SELECT_LEX
*
select_lex
=
join
->
select_lex
;
Item
*
subs
;
DBUG_ASSERT
(
thd
==
join
->
thd
);
/*
*/
...
...
@@ -1938,6 +1945,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
bool
Item_in_subselect
::
fix_having
(
Item
*
having
,
SELECT_LEX
*
select_lex
)
{
bool
fix_res
=
0
;
DBUG_ASSERT
(
thd
);
if
(
!
having
->
fixed
)
{
select_lex
->
having_fix_field
=
1
;
...
...
@@ -2000,6 +2008,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
Item
**
having_item
)
{
SELECT_LEX
*
select_lex
=
join
->
select_lex
;
DBUG_ASSERT
(
thd
==
join
->
thd
);
/*
The non-transformed HAVING clause of 'join' may be stored in two ways
during JOIN::optimize: this->tmp_having= this->having; this->having= 0;
...
...
@@ -2136,6 +2145,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
uint
cols_num
=
left_expr
->
cols
();
DBUG_ENTER
(
"Item_in_subselect::row_value_transformer"
);
DBUG_ASSERT
(
thd
==
join
->
thd
);
// psergey: duplicated_subselect_card_check
if
(
select_lex
->
item_list
.
elements
!=
cols_num
)
...
...
@@ -2248,6 +2258,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
!
select_lex
->
table_list
.
elements
);
DBUG_ENTER
(
"Item_in_subselect::create_row_in_to_exists_cond"
);
DBUG_ASSERT
(
thd
==
join
->
thd
);
*
where_item
=
NULL
;
*
having_item
=
NULL
;
...
...
@@ -2473,6 +2484,7 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
Item
*
having_item
=
join_arg
->
in_to_exists_having
;
DBUG_ENTER
(
"Item_in_subselect::inject_in_to_exists_cond"
);
DBUG_ASSERT
(
thd
==
join_arg
->
thd
);
if
(
where_item
)
{
...
...
@@ -2561,6 +2573,7 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
bool
result
;
DBUG_ENTER
(
"Item_in_subselect::select_in_like_transformer"
);
DBUG_ASSERT
(
thd
==
join
->
thd
);
/*
IN/SOME/ALL/ANY subqueries aren't support LIMIT clause. Without it
...
...
@@ -2762,6 +2775,7 @@ bool Item_in_subselect::setup_mat_engine()
subselect_single_select_engine
*
select_engine
;
DBUG_ENTER
(
"Item_in_subselect::setup_mat_engine"
);
DBUG_ASSERT
(
thd
);
/*
The select_engine (that executes transformed IN=>EXISTS subselects) is
...
...
@@ -2800,6 +2814,7 @@ bool Item_in_subselect::setup_mat_engine()
bool
Item_in_subselect
::
init_left_expr_cache
()
{
JOIN
*
outer_join
;
DBUG_ASSERT
(
thd
);
outer_join
=
unit
->
outer_select
()
->
join
;
/*
...
...
@@ -2826,6 +2841,7 @@ bool Item_in_subselect::init_left_expr_cache()
bool
Item_in_subselect
::
init_cond_guards
()
{
DBUG_ASSERT
(
thd
);
uint
cols_num
=
left_expr
->
cols
();
if
(
!
abort_on_null
&&
left_expr
->
maybe_null
&&
!
pushed_cond_guards
)
{
...
...
@@ -2953,8 +2969,12 @@ bool subselect_union_engine::is_executed() const
bool
subselect_union_engine
::
no_rows
()
{
bool
rows_present
=
false
;
/* Check if we got any rows when reading UNION result from temp. table: */
return
test
(
!
unit
->
fake_select_lex
->
join
->
send_records
);
if
(
unit
->
fake_select_lex
->
join
)
rows_present
=
test
(
!
unit
->
fake_select_lex
->
join
->
send_records
);
return
rows_present
;
}
...
...
@@ -4336,9 +4356,9 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
result
=
result_sink
;
/*
If the subquery has blobs, or the total key leng
h
t is bigger than
If the subquery has blobs, or the total key lengt
h
is bigger than
some length, or the total number of key parts is more than the
allowed maximum (currently MAX_REF_PARTS ==
16
), then the created
allowed maximum (currently MAX_REF_PARTS ==
32
), then the created
index cannot be used for lookups and we can't use hash semi
join. If this is the case, delete the temporary table since it
will not be used, and tell the caller we failed to initialize the
...
...
@@ -6089,4 +6109,3 @@ bool subselect_table_scan_engine::partial_match()
void
subselect_table_scan_engine
::
cleanup
()
{
}
sql/item_timefunc.cc
View file @
ac824fa5
...
...
@@ -1455,25 +1455,29 @@ bool get_interval_value(Item *args,interval_type int_type, INTERVAL *interval)
void
Item_temporal_func
::
fix_length_and_dec
()
{
uint
char_length
=
mysql_temporal_int_part_length
(
field_type
());
/*
We set maybe_null to 1 as default as any bad argument with date or
time can get us to return NULL.
*/
maybe_null
=
1
;
max_length
=
mysql_temporal_int_part_length
(
field_type
());
if
(
decimals
)
{
if
(
decimals
==
NOT_FIXED_DEC
)
max
_length
+=
TIME_SECOND_PART_DIGITS
+
1
;
char
_length
+=
TIME_SECOND_PART_DIGITS
+
1
;
else
{
set_if_smaller
(
decimals
,
TIME_SECOND_PART_DIGITS
);
max
_length
+=
decimals
+
1
;
char
_length
+=
decimals
+
1
;
}
}
sql_mode
=
current_thd
->
variables
.
sql_mode
&
(
MODE_NO_ZERO_IN_DATE
|
MODE_NO_ZERO_DATE
);
collation
.
set
(
&
my_charset_numeric
,
DERIVATION_NUMERIC
,
MY_REPERTOIRE_ASCII
);
collation
.
set
(
field_type
()
==
MYSQL_TYPE_STRING
?
default_charset
()
:
&
my_charset_numeric
,
DERIVATION_NUMERIC
,
MY_REPERTOIRE_ASCII
);
fix_char_length
(
char_length
);
}
String
*
Item_temporal_func
::
val_str
(
String
*
str
)
...
...
@@ -1483,6 +1487,23 @@ String *Item_temporal_func::val_str(String *str)
}
String
*
Item_temporal_hybrid_func
::
val_str_ascii
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
==
1
);
MYSQL_TIME
ltime
;
if
(
get_date
(
&
ltime
,
0
)
||
(
null_value
=
my_TIME_to_str
(
&
ltime
,
str
,
decimals
)))
return
(
String
*
)
0
;
/* Check that the returned timestamp type matches to the function type */
DBUG_ASSERT
(
cached_field_type
==
MYSQL_TYPE_STRING
||
ltime
.
time_type
==
MYSQL_TIMESTAMP_NONE
||
mysql_type_to_time_type
(
cached_field_type
)
==
ltime
.
time_type
);
return
str
;
}
bool
Item_func_from_days
::
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzy_date
)
{
longlong
value
=
args
[
0
]
->
val_int
();
...
...
sql/item_timefunc.h
View file @
ac824fa5
...
...
@@ -506,6 +506,50 @@ class Item_temporal_func: public Item_func
};
/**
Abstract class for functions returning TIME, DATE, DATETIME or string values,
whose data type depends on parameters and is set at fix_fields time.
*/
class
Item_temporal_hybrid_func
:
public
Item_temporal_func
{
protected:
enum_field_types
cached_field_type
;
// TIME, DATE, DATETIME or STRING
String
ascii_buf
;
// Conversion buffer
public:
Item_temporal_hybrid_func
(
Item
*
a
,
Item
*
b
)
:
Item_temporal_func
(
a
,
b
)
{}
enum_field_types
field_type
()
const
{
return
cached_field_type
;
}
Item_result
cmp_type
()
const
{
return
cached_field_type
==
MYSQL_TYPE_STRING
?
STRING_RESULT
:
TIME_RESULT
;
}
const
CHARSET_INFO
*
charset_for_protocol
()
const
{
/*
Can return TIME, DATE, DATETIME or VARCHAR depending on arguments.
Send using "binary" when TIME, DATE or DATETIME,
or using collation.collation when VARCHAR
(which is fixed from @@collation_connection in fix_length_and_dec).
*/
DBUG_ASSERT
(
fixed
==
1
);
return
cached_field_type
==
MYSQL_TYPE_STRING
?
collation
.
collation
:
&
my_charset_bin
;
}
/**
Return string value in ASCII character set.
*/
String
*
val_str_ascii
(
String
*
str
);
/**
Return string value in @@character_set_connection.
*/
String
*
val_str
(
String
*
str
)
{
return
val_str_from_val_str_ascii
(
str
,
&
ascii_buf
);
}
};
class
Item_datefunc
:
public
Item_temporal_func
{
public:
...
...
@@ -763,17 +807,15 @@ class Item_func_sec_to_time :public Item_timefunc
};
class
Item_date_add_interval
:
public
Item_temporal_func
class
Item_date_add_interval
:
public
Item_temporal_
hybrid_
func
{
enum_field_types
cached_field_type
;
public:
const
interval_type
int_type
;
// keep it public
const
bool
date_sub_interval
;
// keep it public
Item_date_add_interval
(
Item
*
a
,
Item
*
b
,
interval_type
type_arg
,
bool
neg_arg
)
:
Item_temporal_func
(
a
,
b
),
int_type
(
type_arg
),
date_sub_interval
(
neg_arg
)
{}
:
Item_temporal_
hybrid_
func
(
a
,
b
),
int_type
(
type_arg
),
date_sub_interval
(
neg_arg
)
{}
const
char
*
func_name
()
const
{
return
"date_add_interval"
;
}
void
fix_length_and_dec
();
enum_field_types
field_type
()
const
{
return
cached_field_type
;
}
bool
get_date
(
MYSQL_TIME
*
res
,
ulonglong
fuzzy_date
);
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
void
print
(
String
*
str
,
enum_query_type
query_type
);
...
...
@@ -911,16 +953,14 @@ class Item_func_makedate :public Item_temporal_func
};
class
Item_func_add_time
:
public
Item_temporal_func
class
Item_func_add_time
:
public
Item_temporal_
hybrid_
func
{
const
bool
is_date
;
int
sign
;
enum_field_types
cached_field_type
;
public:
Item_func_add_time
(
Item
*
a
,
Item
*
b
,
bool
type_arg
,
bool
neg_arg
)
:
Item_temporal_func
(
a
,
b
),
is_date
(
type_arg
)
{
sign
=
neg_arg
?
-
1
:
1
;
}
enum_field_types
field_type
()
const
{
return
cached_field_type
;
}
:
Item_temporal_hybrid_func
(
a
,
b
),
is_date
(
type_arg
)
{
sign
=
neg_arg
?
-
1
:
1
;
}
void
fix_length_and_dec
();
bool
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzy_date
);
void
print
(
String
*
str
,
enum_query_type
query_type
);
...
...
@@ -1019,9 +1059,8 @@ class Item_func_get_format :public Item_str_ascii_func
};
class
Item_func_str_to_date
:
public
Item_temporal_func
class
Item_func_str_to_date
:
public
Item_temporal_
hybrid_
func
{
enum_field_types
cached_field_type
;
timestamp_type
cached_timestamp_type
;
bool
const_item
;
String
subject_converter
;
...
...
@@ -1029,12 +1068,11 @@ class Item_func_str_to_date :public Item_temporal_func
CHARSET_INFO
*
internal_charset
;
public:
Item_func_str_to_date
(
Item
*
a
,
Item
*
b
)
:
Item_temporal_func
(
a
,
b
),
const_item
(
false
),
:
Item_temporal_
hybrid_
func
(
a
,
b
),
const_item
(
false
),
internal_charset
(
NULL
)
{}
bool
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzy_date
);
const
char
*
func_name
()
const
{
return
"str_to_date"
;
}
enum_field_types
field_type
()
const
{
return
cached_field_type
;
}
void
fix_length_and_dec
();
};
...
...
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment