Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a234b8f3
Commit
a234b8f3
authored
Oct 10, 2007
by
dkatz@damien-katzs-computer.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into damien-katzs-computer.local:/Users/dkatz/mysql-5.1-runtime
parents
38d35756
ac83b312
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
750 additions
and
26 deletions
+750
-26
include/config-win.h
include/config-win.h
+3
-0
include/my_pthread.h
include/my_pthread.h
+5
-4
libmysqld/lib_sql.cc
libmysqld/lib_sql.cc
+1
-1
mysql-test/r/sp.result
mysql-test/r/sp.result
+176
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+290
-0
mysql-test/t/upgrade.test
mysql-test/t/upgrade.test
+5
-1
mysys/my_winthread.c
mysys/my_winthread.c
+23
-0
mysys/thr_mutex.c
mysys/thr_mutex.c
+42
-7
sql/item_func.cc
sql/item_func.cc
+11
-2
sql/mysql_priv.h
sql/mysql_priv.h
+0
-1
sql/sql_class.cc
sql/sql_class.cc
+6
-0
sql/sql_connect.cc
sql/sql_connect.cc
+14
-6
sql/sql_parse.cc
sql/sql_parse.cc
+3
-4
tests/mysql_client_test.c
tests/mysql_client_test.c
+171
-0
No files found.
include/config-win.h
View file @
a234b8f3
...
...
@@ -21,6 +21,9 @@
/* We have to do this define before including windows.h to get the AWE API
functions */
#define _WIN32_WINNT 0x0500
#else
/* Get NT 4.0 functions */
#define _WIN32_WINNT 0x0400
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400
...
...
include/my_pthread.h
View file @
a234b8f3
...
...
@@ -101,6 +101,7 @@ struct timespec {
void
win_pthread_init
(
void
);
int
win_pthread_setspecific
(
void
*
A
,
void
*
B
,
uint
length
);
int
win_pthread_mutex_trylock
(
pthread_mutex_t
*
mutex
);
int
pthread_create
(
pthread_t
*
,
pthread_attr_t
*
,
pthread_handler
,
void
*
);
int
pthread_cond_init
(
pthread_cond_t
*
cond
,
const
pthread_condattr_t
*
attr
);
int
pthread_cond_wait
(
pthread_cond_t
*
cond
,
pthread_mutex_t
*
mutex
);
...
...
@@ -156,7 +157,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define pthread_equal(A,B) ((A) == (B))
#define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0)
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
#define pthread_mutex_trylock(A)
(WaitForSingleObject((A), 0) == WAIT_TIMEOUT
)
#define pthread_mutex_trylock(A)
win_pthread_mutex_trylock((A)
)
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
...
...
@@ -472,7 +473,7 @@ typedef struct st_safe_mutex_info_t
int
safe_mutex_init
(
safe_mutex_t
*
mp
,
const
pthread_mutexattr_t
*
attr
,
const
char
*
file
,
uint
line
);
int
safe_mutex_lock
(
safe_mutex_t
*
mp
,
const
char
*
file
,
uint
line
);
int
safe_mutex_lock
(
safe_mutex_t
*
mp
,
my_bool
try_lock
,
const
char
*
file
,
uint
line
);
int
safe_mutex_unlock
(
safe_mutex_t
*
mp
,
const
char
*
file
,
uint
line
);
int
safe_mutex_destroy
(
safe_mutex_t
*
mp
,
const
char
*
file
,
uint
line
);
int
safe_cond_wait
(
pthread_cond_t
*
cond
,
safe_mutex_t
*
mp
,
const
char
*
file
,
...
...
@@ -495,12 +496,12 @@ void safe_mutex_end(FILE *file);
#undef pthread_cond_timedwait
#undef pthread_mutex_trylock
#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__)
#define pthread_mutex_lock(A) safe_mutex_lock((A),
__FILE__,
__LINE__)
#define pthread_mutex_lock(A) safe_mutex_lock((A),
FALSE, __FILE__,
__LINE__)
#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
#define pthread_mutex_trylock(A)
pthread_mutex_lock(A
)
#define pthread_mutex_trylock(A)
safe_mutex_lock((A), TRUE, __FILE__, __LINE__
)
#define pthread_mutex_t safe_mutex_t
#define safe_mutex_assert_owner(mp) \
DBUG_ASSERT((mp)->count > 0 && \
...
...
libmysqld/lib_sql.cc
View file @
a234b8f3
...
...
@@ -111,7 +111,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
}
thd
->
net
.
no_send_error
=
0
;
result
=
dispatch_command
(
command
,
thd
,
(
char
*
)
arg
,
arg_length
+
1
);
result
=
dispatch_command
(
command
,
thd
,
(
char
*
)
arg
,
arg_length
);
thd
->
cur_data
=
0
;
if
(
!
skip_check
)
...
...
mysql-test/r/sp.result
View file @
a234b8f3
...
...
@@ -6620,6 +6620,182 @@ DROP TABLE t1;
DROP PROCEDURE p1;
DROP PROCEDURE p2;
#
# Bug#31035.
#
#
# - Prepare.
#
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
DROP FUNCTION IF EXISTS f3;
DROP FUNCTION IF EXISTS f4;
#
# - Create required objects.
#
CREATE TABLE t1(c1 INT);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE FUNCTION f1()
RETURNS INT
NOT DETERMINISTIC
RETURN 1;
CREATE FUNCTION f2(p INT)
RETURNS INT
NOT DETERMINISTIC
RETURN 1;
CREATE FUNCTION f3()
RETURNS INT
DETERMINISTIC
RETURN 1;
CREATE FUNCTION f4(p INT)
RETURNS INT
DETERMINISTIC
RETURN 1;
#
# - Check.
#
SELECT f1() AS a FROM t1 GROUP BY a;
a
1
SELECT f2(@a) AS a FROM t1 GROUP BY a;
a
1
SELECT f3() AS a FROM t1 GROUP BY a;
a
1
SELECT f4(0) AS a FROM t1 GROUP BY a;
a
1
SELECT f4(@a) AS a FROM t1 GROUP BY a;
a
1
#
# - Cleanup.
#
DROP TABLE t1;
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP FUNCTION f4;
#
# Bug#31191.
#
#
# - Prepare.
#
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP FUNCTION IF EXISTS f1;
#
# - Create required objects.
#
CREATE TABLE t1 (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
barcode INT(8) UNSIGNED ZEROFILL nOT NULL,
PRIMARY KEY (id),
UNIQUE KEY barcode (barcode)
);
INSERT INTO t1 (id, barcode) VALUES (1, 12345678);
INSERT INTO t1 (id, barcode) VALUES (2, 12345679);
CREATE TABLE test.t2 (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708);
INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709);
CREATE FUNCTION f1(p INT(8))
RETURNS BIGINT(11) UNSIGNED
READS SQL DATA
RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10);
#
# - Check.
#
SELECT DISTINCT t1.barcode, f1(t1.barcode)
FROM t1
INNER JOIN t2
ON f1(t1.barcode) = t2.barcode
WHERE t1.barcode=12345678;
barcode f1(t1.barcode)
12345678 12345106708
#
# - Cleanup.
#
DROP TABLE t1;
DROP TABLE t2;
DROP FUNCTION f1;
#
# Bug#31226.
#
#
# - Prepare.
#
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
#
# - Create required objects.
#
CREATE TABLE t1(id INT);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE FUNCTION f1()
RETURNS DATETIME
NOT DETERMINISTIC NO SQL
RETURN NOW();
#
# - Check.
#
SELECT f1() FROM t1 GROUP BY 1;
f1()
<timestamp>
#
# - Cleanup.
#
DROP TABLE t1;
DROP FUNCTION f1;
End of 5.0 tests
#
...
...
mysql-test/t/sp.test
View file @
a234b8f3
...
...
@@ -7581,6 +7581,296 @@ DROP TABLE t1;
DROP
PROCEDURE
p1
;
DROP
PROCEDURE
p2
;
###########################################################################
#
# Bug#31035: select from function, group by result crasher.
#
###########################################################################
--
echo
--
echo
#
--
echo
# Bug#31035.
--
echo
#
--
echo
--
echo
#
--
echo
# - Prepare.
--
echo
#
--
echo
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
DROP
FUNCTION
IF
EXISTS
f1
;
DROP
FUNCTION
IF
EXISTS
f2
;
DROP
FUNCTION
IF
EXISTS
f3
;
DROP
FUNCTION
IF
EXISTS
f4
;
--
enable_warnings
--
echo
--
echo
#
--
echo
# - Create required objects.
--
echo
#
--
echo
CREATE
TABLE
t1
(
c1
INT
);
--
echo
INSERT
INTO
t1
VALUES
(
1
),
(
2
),
(
3
);
--
echo
CREATE
FUNCTION
f1
()
RETURNS
INT
NOT
DETERMINISTIC
RETURN
1
;
--
echo
CREATE
FUNCTION
f2
(
p
INT
)
RETURNS
INT
NOT
DETERMINISTIC
RETURN
1
;
--
echo
CREATE
FUNCTION
f3
()
RETURNS
INT
DETERMINISTIC
RETURN
1
;
--
echo
CREATE
FUNCTION
f4
(
p
INT
)
RETURNS
INT
DETERMINISTIC
RETURN
1
;
--
echo
--
echo
#
--
echo
# - Check.
--
echo
#
--
echo
# Not deterministic function, no arguments.
SELECT
f1
()
AS
a
FROM
t1
GROUP
BY
a
;
--
echo
# Not deterministic function, non-constant argument.
SELECT
f2
(
@
a
)
AS
a
FROM
t1
GROUP
BY
a
;
--
echo
# Deterministic function, no arguments.
SELECT
f3
()
AS
a
FROM
t1
GROUP
BY
a
;
--
echo
# Deterministic function, constant argument.
SELECT
f4
(
0
)
AS
a
FROM
t1
GROUP
BY
a
;
--
echo
# Deterministic function, non-constant argument.
SELECT
f4
(
@
a
)
AS
a
FROM
t1
GROUP
BY
a
;
--
echo
--
echo
#
--
echo
# - Cleanup.
--
echo
#
--
echo
DROP
TABLE
t1
;
DROP
FUNCTION
f1
;
DROP
FUNCTION
f2
;
DROP
FUNCTION
f3
;
DROP
FUNCTION
f4
;
--
echo
###########################################################################
#
# Bug#31191: JOIN in combination with stored function crashes the server.
#
###########################################################################
--
echo
#
--
echo
# Bug#31191.
--
echo
#
--
echo
--
echo
#
--
echo
# - Prepare.
--
echo
#
--
echo
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
DROP
TABLE
IF
EXISTS
t2
;
DROP
FUNCTION
IF
EXISTS
f1
;
--
enable_warnings
--
echo
--
echo
#
--
echo
# - Create required objects.
--
echo
#
--
echo
CREATE
TABLE
t1
(
id
INT
(
10
)
UNSIGNED
NOT
NULL
AUTO_INCREMENT
,
barcode
INT
(
8
)
UNSIGNED
ZEROFILL
nOT
NULL
,
PRIMARY
KEY
(
id
),
UNIQUE
KEY
barcode
(
barcode
)
);
--
echo
INSERT
INTO
t1
(
id
,
barcode
)
VALUES
(
1
,
12345678
);
INSERT
INTO
t1
(
id
,
barcode
)
VALUES
(
2
,
12345679
);
--
echo
CREATE
TABLE
test
.
t2
(
id
INT
(
10
)
UNSIGNED
NOT
NULL
AUTO_INCREMENT
,
barcode
BIGINT
(
11
)
UNSIGNED
ZEROFILL
NOT
NULL
,
PRIMARY
KEY
(
id
)
);
--
echo
INSERT
INTO
test
.
t2
(
id
,
barcode
)
VALUES
(
1
,
12345106708
);
INSERT
INTO
test
.
t2
(
id
,
barcode
)
VALUES
(
2
,
12345106709
);
--
echo
CREATE
FUNCTION
f1
(
p
INT
(
8
))
RETURNS
BIGINT
(
11
)
UNSIGNED
READS
SQL
DATA
RETURN
FLOOR
(
p
/
1000
)
*
1000000
+
100000
+
FLOOR
((
p
MOD
1000
)
/
10
)
*
100
+
(
p
MOD
10
);
--
echo
--
echo
#
--
echo
# - Check.
--
echo
#
--
echo
SELECT
DISTINCT
t1
.
barcode
,
f1
(
t1
.
barcode
)
FROM
t1
INNER
JOIN
t2
ON
f1
(
t1
.
barcode
)
=
t2
.
barcode
WHERE
t1
.
barcode
=
12345678
;
--
echo
--
echo
#
--
echo
# - Cleanup.
--
echo
#
--
echo
DROP
TABLE
t1
;
DROP
TABLE
t2
;
DROP
FUNCTION
f1
;
--
echo
###########################################################################
#
# Bug#31226: Group by function crashes mysql.
#
###########################################################################
--
echo
#
--
echo
# Bug#31226.
--
echo
#
--
echo
--
echo
#
--
echo
# - Prepare.
--
echo
#
--
echo
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
DROP
FUNCTION
IF
EXISTS
f1
;
--
enable_warnings
--
echo
--
echo
#
--
echo
# - Create required objects.
--
echo
#
--
echo
CREATE
TABLE
t1
(
id
INT
);
--
echo
INSERT
INTO
t1
VALUES
(
1
),
(
2
),
(
3
);
--
echo
CREATE
FUNCTION
f1
()
RETURNS
DATETIME
NOT
DETERMINISTIC
NO
SQL
RETURN
NOW
();
--
echo
--
echo
#
--
echo
# - Check.
--
echo
#
--
echo
--
replace_column
1
<
timestamp
>
SELECT
f1
()
FROM
t1
GROUP
BY
1
;
--
echo
--
echo
#
--
echo
# - Cleanup.
--
echo
#
--
echo
DROP
TABLE
t1
;
DROP
FUNCTION
f1
;
--
echo
###########################################################################
--
echo
End
of
5.0
tests
###########################################################################
...
...
mysql-test/t/upgrade.test
View file @
a234b8f3
--
source
include
/
not_embedded
.
inc
# Temporary disabled on windows,
# because of --exec mkdir
# TODO: implement Bug#31004 and remove this limitation
--
source
include
/
not_windows
.
inc
--
disable_warnings
drop
database
if
exists
`mysqltest1`
;
drop
database
if
exists
`mysqltest-1`
;
...
...
@@ -60,7 +65,6 @@ drop table t1;
# Bug#28360 (RENAME DATABASE destroys routines)
#
--
disable_warnings
drop
database
if
exists
`tabc`
;
drop
database
if
exists
`a-b-c`
;
...
...
mysys/my_winthread.c
View file @
a234b8f3
...
...
@@ -40,6 +40,29 @@ void win_pthread_init(void)
pthread_mutex_init
(
&
THR_LOCK_thread
,
MY_MUTEX_INIT_FAST
);
}
/**
Adapter to @c pthread_mutex_trylock()
@retval 0 Mutex was acquired
@retval EBUSY Mutex was already locked by a thread
*/
int
win_pthread_mutex_trylock
(
pthread_mutex_t
*
mutex
)
{
if
(
TryEnterCriticalSection
(
mutex
))
{
/* Don't allow recursive lock */
if
(
mutex
->
RecursionCount
>
1
){
LeaveCriticalSection
(
mutex
);
return
EBUSY
;
}
return
0
;
}
return
EBUSY
;
}
/*
** We have tried to use '_beginthreadex' instead of '_beginthread' here
** but in this case the program leaks about 512 characters for each
...
...
mysys/thr_mutex.c
View file @
a234b8f3
...
...
@@ -91,7 +91,7 @@ int safe_mutex_init(safe_mutex_t *mp,
}
int
safe_mutex_lock
(
safe_mutex_t
*
mp
,
const
char
*
file
,
uint
line
)
int
safe_mutex_lock
(
safe_mutex_t
*
mp
,
my_bool
try_lock
,
const
char
*
file
,
uint
line
)
{
int
error
;
if
(
!
mp
->
file
)
...
...
@@ -104,15 +104,50 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
}
pthread_mutex_lock
(
&
mp
->
global
);
if
(
mp
->
count
>
0
&&
pthread_equal
(
pthread_self
(),
mp
->
thread
)
)
if
(
mp
->
count
>
0
)
{
fprintf
(
stderr
,
"safe_mutex: Trying to lock mutex at %s, line %d, when the mutex was already locked at %s, line %d in thread %s
\n
"
,
file
,
line
,
mp
->
file
,
mp
->
line
,
my_thread_name
());
fflush
(
stderr
);
abort
();
if
(
try_lock
)
{
pthread_mutex_unlock
(
&
mp
->
global
);
return
EBUSY
;
}
else
if
(
pthread_equal
(
pthread_self
(),
mp
->
thread
))
{
fprintf
(
stderr
,
"safe_mutex: Trying to lock mutex at %s, line %d, when the"
" mutex was already locked at %s, line %d in thread %s
\n
"
,
file
,
line
,
mp
->
file
,
mp
->
line
,
my_thread_name
());
fflush
(
stderr
);
abort
();
}
}
pthread_mutex_unlock
(
&
mp
->
global
);
error
=
pthread_mutex_lock
(
&
mp
->
mutex
);
/*
If we are imitating trylock(), we need to take special
precautions.
- We cannot use pthread_mutex_lock() only since another thread can
overtake this thread and take the lock before this thread
causing pthread_mutex_trylock() to hang. In this case, we should
just return EBUSY. Hence, we use pthread_mutex_trylock() to be
able to return immediately.
- We cannot just use trylock() and continue execution below, since
this would generate an error and abort execution if the thread
was overtaken and trylock() returned EBUSY . In this case, we
instead just return EBUSY, since this is the expected behaviour
of trylock().
*/
if
(
try_lock
)
{
error
=
pthread_mutex_trylock
(
&
mp
->
mutex
);
if
(
error
==
EBUSY
)
return
error
;
}
else
error
=
pthread_mutex_lock
(
&
mp
->
mutex
);
if
(
error
||
(
error
=
pthread_mutex_lock
(
&
mp
->
global
)))
{
fprintf
(
stderr
,
"Got error %d when trying to lock mutex at %s, line %d
\n
"
,
...
...
sql/item_func.cc
View file @
a234b8f3
...
...
@@ -5592,8 +5592,13 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
#endif
/* ! NO_EMBEDDED_ACCESS_CHECKS */
}
if
(
!
m_sp
->
m_chistics
->
detistic
)
used_tables_cache
|=
RAND_TABLE_BIT
;
{
used_tables_cache
|=
RAND_TABLE_BIT
;
const_item_cache
=
FALSE
;
}
DBUG_RETURN
(
res
);
}
...
...
@@ -5601,8 +5606,12 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
void
Item_func_sp
::
update_used_tables
()
{
Item_func
::
update_used_tables
();
if
(
!
m_sp
->
m_chistics
->
detistic
)
used_tables_cache
|=
RAND_TABLE_BIT
;
{
used_tables_cache
|=
RAND_TABLE_BIT
;
const_item_cache
=
FALSE
;
}
}
...
...
sql/mysql_priv.h
View file @
a234b8f3
...
...
@@ -917,7 +917,6 @@ void decrease_user_connections(USER_CONN *uc);
void
thd_init_client_charset
(
THD
*
thd
,
uint
cs_number
);
bool
setup_connection_thread_globals
(
THD
*
thd
);
bool
login_connection
(
THD
*
thd
);
void
prepare_new_connection_state
(
THD
*
thd
);
void
end_connection
(
THD
*
thd
);
bool
mysql_create_db
(
THD
*
thd
,
char
*
db
,
HA_CREATE_INFO
*
create
,
bool
silent
);
...
...
sql/sql_class.cc
View file @
a234b8f3
...
...
@@ -585,6 +585,12 @@ void THD::init(void)
if
(
variables
.
sql_mode
&
MODE_NO_BACKSLASH_ESCAPES
)
server_status
|=
SERVER_STATUS_NO_BACKSLASH_ESCAPES
;
options
=
thd_startup_options
;
if
(
variables
.
max_join_size
==
HA_POS_ERROR
)
options
|=
OPTION_BIG_SELECTS
;
else
options
&=
~
OPTION_BIG_SELECTS
;
transaction
.
all
.
modified_non_trans_table
=
transaction
.
stmt
.
modified_non_trans_table
=
FALSE
;
open_options
=
ha_open_options
;
update_lock_default
=
(
variables
.
low_priority_updates
?
...
...
sql/sql_connect.cc
View file @
a234b8f3
...
...
@@ -933,7 +933,7 @@ bool login_connection(THD *thd)
NET
*
net
=
&
thd
->
net
;
Security_context
*
sctx
=
thd
->
security_ctx
;
DBUG_ENTER
(
"login_connection"
);
DBUG_PRINT
(
"info"
,
(
"
handle_one
_connection called by thread %lu"
,
DBUG_PRINT
(
"info"
,
(
"
login
_connection called by thread %lu"
,
thd
->
thread_id
));
net
->
no_send_error
=
0
;
...
...
@@ -973,21 +973,29 @@ void end_connection(THD *thd)
plugin_thdvar_cleanup
(
thd
);
if
(
thd
->
user_connect
)
decrease_user_connections
(
thd
->
user_connect
);
if
(
thd
->
killed
||
net
->
error
&&
net
->
vio
!=
0
&&
net
->
report_error
)
{
statistic_increment
(
aborted_threads
,
&
LOCK_status
);
}
if
(
net
->
error
&&
net
->
vio
!=
0
&&
net
->
report_error
)
{
Security_context
*
sctx
=
thd
->
security_ctx
;
if
(
!
thd
->
killed
&&
thd
->
variables
.
log_warnings
>
1
)
{
Security_context
*
sctx
=
thd
->
security_ctx
;
sql_print_warning
(
ER
(
ER_NEW_ABORTING_CONNECTION
),
thd
->
thread_id
,(
thd
->
db
?
thd
->
db
:
"unconnected"
),
sctx
->
user
?
sctx
->
user
:
"unauthenticated"
,
sctx
->
host_or_ip
,
(
net
->
last_errno
?
ER
(
net
->
last_errno
)
:
ER
(
ER_UNKNOWN_ERROR
)));
}
net_send_error
(
thd
,
net
->
last_errno
,
NullS
);
statistic_increment
(
aborted_threads
,
&
LOCK_status
);
}
else
if
(
thd
->
killed
)
statistic_increment
(
aborted_threads
,
&
LOCK_status
);
}
...
...
@@ -995,7 +1003,7 @@ void end_connection(THD *thd)
Initialize THD to handle queries
*/
void
prepare_new_connection_state
(
THD
*
thd
)
static
void
prepare_new_connection_state
(
THD
*
thd
)
{
Security_context
*
sctx
=
thd
->
security_ctx
;
...
...
sql/sql_parse.cc
View file @
a234b8f3
...
...
@@ -86,7 +86,6 @@ const char *xa_state_names[]={
"NON-EXISTING"
,
"ACTIVE"
,
"IDLE"
,
"PREPARED"
};
static
void
unlock_locked_tables
(
THD
*
thd
)
{
if
(
thd
->
locked_tables
)
...
...
@@ -681,12 +680,12 @@ bool do_command(THD *thd)
DBUG_PRINT
(
"info"
,(
"Got error %d reading command from socket %s"
,
net
->
error
,
vio_description
(
net
->
vio
)));
/* Check if we can continue without closing the connection */
if
(
net
->
error
!=
3
)
{
statistic_increment
(
aborted_threads
,
&
LOCK_status
);
DBUG_RETURN
(
TRUE
);
// We have to close it.
}
net_send_error
(
thd
,
net
->
last_errno
,
NullS
);
net
->
error
=
0
;
DBUG_RETURN
(
FALSE
);
...
...
tests/mysql_client_test.c
View file @
a234b8f3
...
...
@@ -16819,6 +16819,176 @@ static void test_bug30472()
mysql_close
(
&
con
);
}
static
void
bug20023_change_user
(
MYSQL
*
con
)
{
DIE_IF
(
mysql_change_user
(
con
,
opt_user
,
opt_password
,
opt_db
?
opt_db
:
"test"
));
}
static
void
bug20023_query_int_variable
(
MYSQL
*
con
,
const
char
*
var_name
,
int
*
var_value
)
{
MYSQL_RES
*
rs
;
MYSQL_ROW
row
;
char
query_buffer
[
MAX_TEST_QUERY_LENGTH
];
my_snprintf
(
query_buffer
,
sizeof
(
query_buffer
),
"SELECT @@%s"
,
(
const
char
*
)
var_name
);
DIE_IF
(
mysql_query
(
con
,
query_buffer
));
DIE_UNLESS
(
rs
=
mysql_store_result
(
con
));
DIE_UNLESS
(
row
=
mysql_fetch_row
(
rs
));
*
var_value
=
atoi
(
row
[
0
]);
mysql_free_result
(
rs
);
}
static
void
test_bug20023
()
{
MYSQL
con
;
int
sql_big_selects_orig
;
int
max_join_size_orig
;
int
sql_big_selects_2
;
int
sql_big_selects_3
;
int
sql_big_selects_4
;
int
sql_big_selects_5
;
char
query_buffer
[
MAX_TEST_QUERY_LENGTH
];
/* Create a new connection. */
DIE_UNLESS
(
mysql_init
(
&
con
));
DIE_UNLESS
(
mysql_real_connect
(
&
con
,
opt_host
,
opt_user
,
opt_password
,
opt_db
?
opt_db
:
"test"
,
opt_port
,
opt_unix_socket
,
CLIENT_FOUND_ROWS
));
/***********************************************************************
Remember original SQL_BIG_SELECTS, MAX_JOIN_SIZE values.
***********************************************************************/
bug20023_query_int_variable
(
&
con
,
"session.sql_big_selects"
,
&
sql_big_selects_orig
);
bug20023_query_int_variable
(
&
con
,
"global.max_join_size"
,
&
max_join_size_orig
);
/***********************************************************************
Test that COM_CHANGE_USER resets the SQL_BIG_SELECTS to the initial value.
***********************************************************************/
/* Issue COM_CHANGE_USER. */
bug20023_change_user
(
&
con
);
/* Query SQL_BIG_SELECTS. */
bug20023_query_int_variable
(
&
con
,
"session.sql_big_selects"
,
&
sql_big_selects_2
);
/* Check that SQL_BIG_SELECTS is reset properly. */
DIE_UNLESS
(
sql_big_selects_orig
==
sql_big_selects_2
);
/***********************************************************************
Test that if MAX_JOIN_SIZE set to non-default value,
SQL_BIG_SELECTS will be 0.
***********************************************************************/
/* Set MAX_JOIN_SIZE to some non-default value. */
DIE_IF
(
mysql_query
(
&
con
,
"SET @@global.max_join_size = 10000"
));
DIE_IF
(
mysql_query
(
&
con
,
"SET @@session.max_join_size = default"
));
/* Issue COM_CHANGE_USER. */
bug20023_change_user
(
&
con
);
/* Query SQL_BIG_SELECTS. */
bug20023_query_int_variable
(
&
con
,
"session.sql_big_selects"
,
&
sql_big_selects_3
);
/* Check that SQL_BIG_SELECTS is 0. */
DIE_UNLESS
(
sql_big_selects_3
==
0
);
/***********************************************************************
Test that if MAX_JOIN_SIZE set to default value,
SQL_BIG_SELECTS will be 1.
***********************************************************************/
/* Set MAX_JOIN_SIZE to the default value (-1). */
DIE_IF
(
mysql_query
(
&
con
,
"SET @@global.max_join_size = -1"
));
DIE_IF
(
mysql_query
(
&
con
,
"SET @@session.max_join_size = default"
));
/* Issue COM_CHANGE_USER. */
bug20023_change_user
(
&
con
);
/* Query SQL_BIG_SELECTS. */
bug20023_query_int_variable
(
&
con
,
"session.sql_big_selects"
,
&
sql_big_selects_4
);
/* Check that SQL_BIG_SELECTS is 1. */
DIE_UNLESS
(
sql_big_selects_4
==
1
);
/***********************************************************************
Restore MAX_JOIN_SIZE.
Check that SQL_BIG_SELECTS will be the original one.
***********************************************************************/
/* Restore MAX_JOIN_SIZE. */
my_snprintf
(
query_buffer
,
sizeof
(
query_buffer
),
"SET @@global.max_join_size = %d"
,
(
int
)
max_join_size_orig
);
DIE_IF
(
mysql_query
(
&
con
,
query_buffer
));
DIE_IF
(
mysql_query
(
&
con
,
"SET @@session.max_join_size = default"
));
/* Issue COM_CHANGE_USER. */
bug20023_change_user
(
&
con
);
/* Query SQL_BIG_SELECTS. */
bug20023_query_int_variable
(
&
con
,
"session.sql_big_selects"
,
&
sql_big_selects_5
);
/* Check that SQL_BIG_SELECTS is 1. */
DIE_UNLESS
(
sql_big_selects_5
==
sql_big_selects_orig
);
/***********************************************************************
That's it. Cleanup.
***********************************************************************/
mysql_close
(
&
con
);
}
/*
Read and parse arguments and MySQL options from my.cnf
...
...
@@ -17115,6 +17285,7 @@ static struct my_tests_st my_tests[]= {
{
"test_bug29306"
,
test_bug29306
},
{
"test_change_user"
,
test_change_user
},
{
"test_bug30472"
,
test_bug30472
},
{
"test_bug20023"
,
test_bug20023
},
{
0
,
0
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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