summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VC++Files/examples/udf_example/udf_example.def9
-rw-r--r--VC++Files/examples/udf_example/udf_example.dsp111
-rw-r--r--VC++Files/examples/udf_example/udf_example.dsw29
-rw-r--r--client/mysqltest.c11
-rw-r--r--configure.in9
-rw-r--r--include/mysql.h2
-rw-r--r--innobase/dict/dict0dict.c2
-rw-r--r--innobase/include/os0file.h7
-rw-r--r--innobase/include/row0mysql.h3
-rw-r--r--innobase/lock/lock0lock.c2
-rw-r--r--innobase/os/os0file.c44
-rw-r--r--innobase/row/row0mysql.c1
-rw-r--r--libmysql/libmysql.c2
-rw-r--r--mysql-test/README2
-rw-r--r--mysql-test/r/select_found.result17
-rw-r--r--mysql-test/t/select_found.test19
-rw-r--r--sql/ha_innodb.cc33
-rw-r--r--sql/mysqld.cc12
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/sql_acl.cc2
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_select.cc7
23 files changed, 298 insertions, 32 deletions
diff --git a/VC++Files/examples/udf_example/udf_example.def b/VC++Files/examples/udf_example/udf_example.def
new file mode 100644
index 00000000000..c1cfeea63f8
--- /dev/null
+++ b/VC++Files/examples/udf_example/udf_example.def
@@ -0,0 +1,9 @@
+LIBRARY MYUDF
+DESCRIPTION 'MySQL Sample for UDF'
+VERSION 1.0
+EXPORTS
+ metaphon
+ myfunc_double
+ myfunc_int
+ sequence
+ avgcost \ No newline at end of file
diff --git a/VC++Files/examples/udf_example/udf_example.dsp b/VC++Files/examples/udf_example/udf_example.dsp
new file mode 100644
index 00000000000..bfe4d76bcc7
--- /dev/null
+++ b/VC++Files/examples/udf_example/udf_example.dsp
@@ -0,0 +1,111 @@
+# Microsoft Developer Studio Project File - Name="udf_example" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=udf_example - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "udf_example.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "udf_example.mak" CFG="udf_example - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "udf_example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "udf_example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "udf_example - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UDF_EXAMPLE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UDF_EXAMPLE_EXPORTS" /D "HAVE_DLOPEN" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x416 /d "NDEBUG"
+# ADD RSC /l 0x416 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\lib\opt\strings.lib /nologo /dll /machine:I386 /out:"Release/myudf.dll"
+
+!ELSEIF "$(CFG)" == "udf_example - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UDF_EXAMPLE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UDF_EXAMPLE_EXPORTS" /D "HAVE_DLOPEN" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x416 /d "_DEBUG"
+# ADD RSC /l 0x416 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\lib\debug\strings.lib /nologo /dll /debug /machine:I386 /out:"Debug/myudf.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "udf_example - Win32 Release"
+# Name "udf_example - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\udf_example.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\udf_example.def
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/VC++Files/examples/udf_example/udf_example.dsw b/VC++Files/examples/udf_example/udf_example.dsw
new file mode 100644
index 00000000000..6716e107f6a
--- /dev/null
+++ b/VC++Files/examples/udf_example/udf_example.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "udf_example"=.\udf_example.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/client/mysqltest.c b/client/mysqltest.c
index be2270850fa..830846eda84 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -187,7 +187,7 @@ typedef struct
*/
static char *subst_env_var(const char *cmd);
-static int my_popen(const char *cmd, const char *mode);
+static FILE *my_popen(const char *cmd, const char *mode);
#define popen(A,B) my_popen((A),(B))
#endif /* __NETWARE__ */
@@ -3710,6 +3710,7 @@ static void get_replace_column(struct st_query *q)
static char *subst_env_var(const char *str)
{
char *result;
+ char *pos;
result= pos= my_malloc(MAX_QUERY, MYF(MY_FAE));
while (*str)
@@ -3729,7 +3730,7 @@ static char *subst_env_var(const char *str)
*str && !isspace(*str) && *str != '\\' && *str != '/' &&
*str != '$';
str++)
- *env_pos++ *str;
+ *env_pos++= *str;
*env_pos= 0;
if (!(subst= getenv(env_var)))
@@ -3772,11 +3773,11 @@ static char *subst_env_var(const char *str)
#undef popen /* Remove wrapper */
-int my_popen(const char *cmd, const char *mode __attribute__((unused)) t)
+FILE *my_popen(const char *cmd, const char *mode __attribute__((unused)))
{
char *subst_cmd;
- int res_file;
-
+ FILE *res_file;
+
subst_cmd= subst_env_var(cmd);
res_file= popen(subst_cmd, "r0");
my_free(subst_cmd, MYF(0));
diff --git a/configure.in b/configure.in
index c7667748139..c3c69eba601 100644
--- a/configure.in
+++ b/configure.in
@@ -767,7 +767,14 @@ AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
AC_CHECK_FUNC(sem_init, , AC_CHECK_LIB(posix4, sem_init))
# For compress in zlib
-MYSQL_CHECK_ZLIB_WITH_COMPRESS($with_named_zlib)
+case $SYSTEM_TYPE in
+ *netware*)
+ AC_DEFINE(HAVE_COMPRESS)
+ ;;
+ *)
+ MYSQL_CHECK_ZLIB_WITH_COMPRESS($with_named_zlib)
+ ;;
+esac
#--------------------------------------------------------------------
# Check for TCP wrapper support
diff --git a/include/mysql.h b/include/mysql.h
index ad85bcc1bbd..e2d0acd7839 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -336,7 +336,7 @@ typedef struct st_mysql_parameters
int STDCALL mysql_server_init(int argc, char **argv, char **groups);
void STDCALL mysql_server_end(void);
-MYSQL_PARAMETERS *STDCALL mysql_get_parameters();
+MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void);
/*
Set up and bring down a thread; these function should be called
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
index 84a655bcb77..aa5787ee30e 100644
--- a/innobase/dict/dict0dict.c
+++ b/innobase/dict/dict0dict.c
@@ -681,7 +681,7 @@ dict_init(void)
rw_lock_create(&dict_operation_lock);
rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION);
- dict_foreign_err_file = tmpfile();
+ dict_foreign_err_file = os_file_create_tmpfile();
mutex_create(&dict_foreign_err_mutex);
mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
}
diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h
index 930390241d3..6549a3748df 100644
--- a/innobase/include/os0file.h
+++ b/innobase/include/os0file.h
@@ -169,6 +169,13 @@ void
os_io_init_simple(void);
/*===================*/
/***************************************************************************
+Creates a temporary file. In case of error, causes abnormal termination. */
+
+FILE*
+os_file_create_tmpfile(void);
+/*========================*/
+ /* out: temporary file handle (never NULL) */
+/***************************************************************************
The os_file_opendir() function opens a directory stream corresponding to the
directory named by the dirname argument. The directory stream is positioned
at the first entry. In both Unix and Windows we automatically skip the '.'
diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h
index af6d8969cfc..390e8c4da57 100644
--- a/innobase/include/row0mysql.h
+++ b/innobase/include/row0mysql.h
@@ -558,6 +558,9 @@ struct row_prebuilt_struct {
dtuple_t* clust_ref; /* prebuilt dtuple used in
sel/upd/del */
ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */
+ ulint stored_select_lock_type;/* inside LOCK TABLES, either
+ LOCK_S or LOCK_X depending on the lock
+ type */
ulint mysql_row_len; /* length in bytes of a row in the
MySQL format */
ulint n_rows_fetched; /* number of rows fetched after
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index 223d9af78d1..58c88f67017 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -510,7 +510,7 @@ lock_sys_create(
/* hash_create_mutexes(lock_sys->rec_hash, 2, SYNC_REC_LOCK); */
- lock_latest_err_file = tmpfile();
+ lock_latest_err_file = os_file_create_tmpfile();
}
/*************************************************************************
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 9d428c283a5..6aca90885a6 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -311,14 +311,11 @@ os_file_handle_error(
/*=================*/
/* out: TRUE if we should retry the
operation */
- os_file_t file, /* in: file pointer */
const char* name, /* in: name of a file or NULL */
const char* operation)/* in: operation */
{
ulint err;
- UT_NOT_USED(file);
-
err = os_file_get_last_error(FALSE);
if (err == OS_FILE_DISK_FULL) {
@@ -482,6 +479,25 @@ os_io_init_simple(void)
}
/***************************************************************************
+Creates a temporary file. In case of error, causes abnormal termination. */
+
+FILE*
+os_file_create_tmpfile(void)
+/*========================*/
+ /* out: temporary file handle (never NULL) */
+{
+ FILE* file = tmpfile();
+ if (file == NULL) {
+ ut_print_timestamp(stderr);
+ fputs(" InnoDB: Error: unable to create temporary file\n",
+ stderr);
+ os_file_handle_error(NULL, "tmpfile");
+ ut_error;
+ }
+ return(file);
+}
+
+/***************************************************************************
The os_file_opendir() function opens a directory stream corresponding to the
directory named by the dirname argument. The directory stream is positioned
at the first entry. In both Unix and Windows we automatically skip the '.'
@@ -809,7 +825,7 @@ try_again:
if (file == INVALID_HANDLE_VALUE) {
*success = FALSE;
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
create_mode == OS_FILE_OPEN ?
"open" : "create");
if (retry) {
@@ -859,7 +875,7 @@ try_again:
if (file == -1) {
*success = FALSE;
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
create_mode == OS_FILE_OPEN ?
"open" : "create");
if (retry) {
@@ -1101,7 +1117,7 @@ try_again:
if (file == INVALID_HANDLE_VALUE) {
*success = FALSE;
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
create_mode == OS_FILE_CREATE ?
"create" : "open");
if (retry) {
@@ -1186,7 +1202,7 @@ try_again:
if (file == -1) {
*success = FALSE;
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
create_mode == OS_FILE_CREATE ?
"create" : "open");
if (retry) {
@@ -1389,7 +1405,7 @@ os_file_close(
return(TRUE);
}
- os_file_handle_error(file, NULL, "close");
+ os_file_handle_error(NULL, "close");
return(FALSE);
#else
@@ -1398,7 +1414,7 @@ os_file_close(
ret = close(file);
if (ret == -1) {
- os_file_handle_error(file, NULL, "close");
+ os_file_handle_error(NULL, "close");
return(FALSE);
}
@@ -1651,7 +1667,7 @@ os_file_flush(
return(TRUE);
}
- os_file_handle_error(file, NULL, "flush");
+ os_file_handle_error(NULL, "flush");
/* It is a fatal error if a file flush does not succeed, because then
the database can get corrupt on disk */
@@ -1686,7 +1702,7 @@ os_file_flush(
fprintf(stderr,
" InnoDB: Error: the OS said file flush did not succeed\n");
- os_file_handle_error(file, NULL, "flush");
+ os_file_handle_error(NULL, "flush");
/* It is a fatal error if a file flush does not succeed, because then
the database can get corrupt on disk */
@@ -1946,7 +1962,7 @@ try_again:
#ifdef __WIN__
error_handling:
#endif
- retry = os_file_handle_error(file, NULL, "read");
+ retry = os_file_handle_error(NULL, "read");
if (retry) {
goto try_again;
@@ -3157,7 +3173,7 @@ try_again:
os_aio_array_free_slot(array, slot);
- retry = os_file_handle_error(file, name,
+ retry = os_file_handle_error(name,
type == OS_FILE_READ ? "aio read" : "aio write");
if (retry) {
@@ -3257,7 +3273,7 @@ os_aio_windows_handle(
ut_a(TRUE == os_file_flush(slot->file));
}
} else {
- os_file_handle_error(slot->file, slot->name, "Windows aio");
+ os_file_handle_error(slot->name, "Windows aio");
ret_val = FALSE;
}
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c
index 623069cc90c..974dfa3e1c8 100644
--- a/innobase/row/row0mysql.c
+++ b/innobase/row/row0mysql.c
@@ -397,6 +397,7 @@ row_create_prebuilt(
prebuilt->clust_pcur = btr_pcur_create_for_mysql();
prebuilt->select_lock_type = LOCK_NONE;
+ prebuilt->stored_select_lock_type = 99999999;
prebuilt->sel_graph = NULL;
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 49b076d1b98..a3922313a40 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -186,7 +186,7 @@ void STDCALL mysql_server_end()
static MYSQL_PARAMETERS mysql_internal_parameters=
{&max_allowed_packet, &net_buffer_length};
-MYSQL_PARAMETERS *STDCALL mysql_get_parameters()
+MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void)
{
return &mysql_internal_parameters;
}
diff --git a/mysql-test/README b/mysql-test/README
index 7c6efe7940e..bccb05c555c 100644
--- a/mysql-test/README
+++ b/mysql-test/README
@@ -12,7 +12,7 @@ conflict with it.
All tests must pass. If one or more of them fail on your system, please
read the following manual section of how to report the problem:
-http://www.mysql.com/doc/M/y/MySQL_test_suite.html
+http://dev.mysql.com/doc/mysql/en/MySQL_test_suite.html
You can create your own test cases. To create a test case:
diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result
index 23a39a242a1..470a3e8439f 100644
--- a/mysql-test/r/select_found.result
+++ b/mysql-test/r/select_found.result
@@ -226,3 +226,20 @@ WHERE ( r = 1 AND a IN ( 1, 2 ) AND ( u = 'w' OR u LIKE 'w/%' ) )
OR ( r = 1 AND a IN ( 3 ) AND ( u = 'w/U' OR u LIKE 'w/U/%' ) )
OR ( r = 1 AND a IN ( 1, 2, 3 ) AND ( u = 'w' ) );
drop table t1;
+CREATE TABLE t1 (a VARCHAR(16), UNIQUE(a));
+INSERT INTO t1 VALUES ('1'), ('2'), ('3');
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = '2' LIMIT 0, 1;
+a
+2
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (0), (0), (1), (2);
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = 0 GROUP BY a HAVING a > 10;
+a
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+0
+DROP TABLE t1;
diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test
index e63e894c1cf..c20b6e9ab6c 100644
--- a/mysql-test/t/select_found.test
+++ b/mysql-test/t/select_found.test
@@ -137,3 +137,22 @@ WHERE ( r = 1 AND a IN ( 1, 2 ) AND ( u = 'w' OR u LIKE 'w/%' ) )
OR ( r = 1 AND a IN ( 1, 2, 3 ) AND ( u = 'w' ) );
drop table t1;
+#
+# Bug #3738: we have a ref key
+#
+
+CREATE TABLE t1 (a VARCHAR(16), UNIQUE(a));
+INSERT INTO t1 VALUES ('1'), ('2'), ('3');
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = '2' LIMIT 0, 1;
+SELECT FOUND_ROWS();
+DROP TABLE t1;
+
+#
+# Bug #3845: group by, having and empty result
+#
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (0), (0), (1), (2);
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = 0 GROUP BY a HAVING a > 10;
+SELECT FOUND_ROWS();
+DROP TABLE t1;
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 71c9a5c3b18..4f51d7c7361 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -4657,6 +4657,39 @@ ha_innobase::start_stmt(
prepared for an update of a row */
prebuilt->select_lock_type = LOCK_X;
+ } else {
+ /* When we first come here after LOCK TABLES,
+ select_lock_type is set to LOCK_S or LOCK_X. Store the value
+ in case we run also consistent reads and need to restore the
+ value later. */
+
+ if (prebuilt->select_lock_type != LOCK_NONE) {
+ prebuilt->stored_select_lock_type =
+ prebuilt->select_lock_type;
+ }
+
+ if (prebuilt->stored_select_lock_type != LOCK_S
+ && prebuilt->stored_select_lock_type != LOCK_X) {
+ fprintf(stderr,
+"InnoDB: Error: select_lock_type is %lu inside ::start_stmt()!\n",
+ prebuilt->stored_select_lock_type);
+
+ ut_error;
+ }
+
+ if (thd->lex.sql_command == SQLCOM_SELECT
+ && thd->lex.lock_option == TL_READ) {
+
+ /* For other than temporary tables, we obtain
+ no lock for consistent read (plain SELECT) */
+
+ prebuilt->select_lock_type = LOCK_NONE;
+ } else {
+ /* Not a consistent read: restore the
+ select_lock_type value */
+ prebuilt->select_lock_type =
+ prebuilt->stored_select_lock_type;
+ }
}
/* Set the MySQL flag to mark that there is an active transaction */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index ccdb8674bc3..4f70c72f8ec 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4449,11 +4449,11 @@ replicating a LOAD DATA INFILE command.",
NO_ARG, 0, 0, 0, 0, 0, 0},
{"log-warnings", 'W', "Log some not critical warnings to the log file.",
(gptr*) &global_system_variables.log_warnings,
- (gptr*) &max_system_variables.log_warnings, 0, GET_BOOL, NO_ARG, 1, 0, 0,
+ (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
0, 0, 0},
{"warnings", 'W', "Deprecated ; Use --log-warnings instead.",
(gptr*) &global_system_variables.log_warnings,
- (gptr*) &max_system_variables.log_warnings, 0, GET_BOOL, NO_ARG, 1, 0, 0,
+ (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0,
0, 0, 0},
{ "back_log", OPT_BACK_LOG,
"The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.",
@@ -5474,6 +5474,14 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'V':
print_version();
exit(0);
+ case 'W':
+ if (!argument)
+ global_system_variables.log_warnings++;
+ else if (argument == disabled_my_option)
+ global_system_variables.log_warnings= 0L;
+ else
+ global_system_variables.log_warnings= atoi(argument);
+ break;
case 'T':
test_flags= argument ? (uint) atoi(argument) : 0;
test_flags&= ~TEST_NO_THREADS;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 1112a869515..517a3c65ab8 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -182,7 +182,7 @@ sys_var_key_cache_long sys_key_cache_age_threshold("key_cache_age_threshold",
param_age_threshold));
sys_var_bool_ptr sys_local_infile("local_infile",
&opt_local_infile);
-sys_var_thd_bool sys_log_warnings("log_warnings", &SV::log_warnings);
+sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
sys_var_thd_ulong sys_long_query_time("long_query_time",
&SV::long_query_time);
sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 25ff4c5676b..d5becf81771 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -941,7 +941,7 @@ static void acl_insert_db(const char *user, const char *host, const char *db,
*/
ulong acl_get(const char *host, const char *ip,
- const char *user, const char *db, my_bool db_is_pattern)
+ const char *user, const char *db, my_bool db_is_pattern)
{
ulong host_access,db_access;
uint i,key_length;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 7c8533af285..a3e398dc1d6 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -383,6 +383,7 @@ struct system_variables
ulong query_prealloc_size;
ulong trans_alloc_block_size;
ulong trans_prealloc_size;
+ ulong log_warnings;
ulong group_concat_max_len;
/*
In slave thread we need to know in behalf of which
@@ -390,7 +391,6 @@ struct system_variables
*/
ulong pseudo_thread_id;
- my_bool log_warnings;
my_bool low_priority_updates;
my_bool new_mode;
my_bool query_cache_wlock_invalidate;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 7596e37de93..a7ecda72905 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1021,7 +1021,7 @@ pthread_handler_decl(handle_one_connection,arg)
free_root(&thd->mem_root,MYF(0));
if (net->error && net->vio != 0 && net->report_error)
{
- if (!thd->killed && thd->variables.log_warnings)
+ if (!thd->killed && thd->variables.log_warnings > 1)
sql_print_error(ER(ER_NEW_ABORTING_CONNECTION),
thd->thread_id,(thd->db ? thd->db : "unconnected"),
thd->user ? thd->user : "unauthenticated",
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 8d651c00a0a..0abfb483820 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6369,7 +6369,8 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if ((join->tables == 1) && !join->tmp_table && !join->sort_and_group
&& !join->send_group_parts && !join->having && !jt->select_cond &&
!(jt->select && jt->select->quick) &&
- !(jt->table->file->table_flags() & HA_NOT_EXACT_COUNT))
+ !(jt->table->file->table_flags() & HA_NOT_EXACT_COUNT) &&
+ (jt->ref.key < 0))
{
/* Join over all rows in table; Return number of found rows */
TABLE *table=jt->table;
@@ -6462,7 +6463,11 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (error > 0)
DBUG_RETURN(-1); /* purecov: inspected */
if (end_of_records)
+ {
+ if (!error)
+ join->send_records++;
DBUG_RETURN(0);
+ }
if (join->send_records >= join->unit->select_limit_cnt &&
join->do_send_rows)
{