From fb9257dc45c843cfe91e3e5049e6c9c0ff92107a Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Fri, 28 May 2004 11:15:59 +0300 Subject: [PATCH 01/11] InnoDB: Add diagnostics when tmpfile() fails at start (Bug #3919) --- innobase/dict/dict0dict.c | 2 +- innobase/include/os0file.h | 7 ++++++ innobase/lock/lock0lock.c | 2 +- innobase/os/os0file.c | 44 ++++++++++++++++++++++++++------------ 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 0fc4ac2b687..f14e2a4e58c 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -642,7 +642,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 de17e2302ae..43741f79855 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -133,6 +133,13 @@ Creates the seek mutexes used in positioned reads and writes. */ 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) */ /******************************************************************** A simple function to open or create a file. */ diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 791b81366b2..d9848577728 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 681c4e487e7..8cb2b171328 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -301,14 +301,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(); if (err == OS_FILE_DISK_FULL) { @@ -374,6 +371,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); +} + /******************************************************************** A simple function to open or create a file. */ @@ -430,7 +446,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) { @@ -472,7 +488,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) { @@ -678,7 +694,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) { @@ -766,7 +782,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) { @@ -801,7 +817,7 @@ os_file_close( return(TRUE); } - os_file_handle_error(file, NULL, "close"); + os_file_handle_error(NULL, "close"); return(FALSE); #else int ret; @@ -809,7 +825,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); } @@ -1029,7 +1045,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 */ @@ -1063,7 +1079,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 */ @@ -1323,7 +1339,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; @@ -2278,7 +2294,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) { @@ -2378,7 +2394,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; } From 605962a9384912cf665ae33b105326abd5f6a486 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Fri, 28 May 2004 15:01:16 +0500 Subject: [PATCH 02/11] a fix. (Bug#3738: SQL_CALC_FOUND_ROWS ignores WHERE if LIMIT used, Bug#3845: wrong FOUND_ROWS result) --- mysql-test/r/select_found.result | 17 +++++++++++++++++ mysql-test/t/select_found.test | 19 +++++++++++++++++++ sql/sql_select.cc | 6 ++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result index 367bdd798b4..444124bcd67 100644 --- a/mysql-test/r/select_found.result +++ b/mysql-test/r/select_found.result @@ -206,3 +206,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 e584fca206f..7599277a867 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -127,3 +127,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/sql_select.cc b/sql/sql_select.cc index b299e3af0b7..5b754186736 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5348,7 +5348,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; @@ -5429,7 +5430,8 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), DBUG_RETURN(-1); /* purecov: inspected */ if (end_of_records) { - join->send_records++; + if (!error) + join->send_records++; DBUG_RETURN(0); } if (!error && From 2e1ded2fe12ae42dfe41b4d536ddb85578ed9f8a Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Sat, 29 May 2004 17:52:20 +0200 Subject: [PATCH 03/11] backport wild_compare fix from 4.1 - bug#3924 --- include/my_sys.h | 2 +- mysys/mf_wcomp.c | 67 ++++++++++++++++++++++++++++++++---------------- mysys/mf_wfile.c | 4 +-- sql/sql_acl.cc | 10 ++++---- sql/sql_acl.h | 2 +- sql/sql_base.cc | 2 +- sql/sql_db.cc | 2 +- sql/sql_parse.cc | 4 +-- sql/sql_show.cc | 6 ++--- 9 files changed, 61 insertions(+), 38 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 8f0040055d6..4934df3c4e5 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -620,7 +620,7 @@ extern my_string my_path(my_string to,const char *progname, const char *own_pathname_part); extern my_string my_load_path(my_string to, const char *path, const char *own_path_prefix); -extern int wild_compare(const char *str,const char *wildstr); +extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern); extern my_string my_strcasestr(const char *src,const char *suffix); extern int my_strcasecmp(const char *s,const char *t); extern int my_strsortcmp(const char *s,const char *t); diff --git a/mysys/mf_wcomp.c b/mysys/mf_wcomp.c index bdcfb0501d8..1a01388a3db 100644 --- a/mysys/mf_wcomp.c +++ b/mysys/mf_wcomp.c @@ -23,11 +23,12 @@ char wild_many='*'; char wild_one='?'; -char wild_prefix=0; +char wild_prefix=0; /* QQ this can potentially cause a SIGSEGV */ -int wild_compare(register const char *str, register const char *wildstr) +int wild_compare(register const char *str, register const char *wildstr, + pbool str_is_pattern) { - reg3 int flag; + char cmp; DBUG_ENTER("wild_compare"); while (*wildstr) @@ -35,33 +36,55 @@ int wild_compare(register const char *str, register const char *wildstr) while (*wildstr && *wildstr != wild_many && *wildstr != wild_one) { if (*wildstr == wild_prefix && wildstr[1]) + { wildstr++; - if (*wildstr++ != *str++) DBUG_RETURN(1); + if (str_is_pattern && *str++ != wild_prefix) + DBUG_RETURN(1); + } + if (*wildstr++ != *str++) + DBUG_RETURN(1); } - if (! *wildstr ) DBUG_RETURN (*str != 0); + if (! *wildstr ) + DBUG_RETURN(*str != 0); if (*wildstr++ == wild_one) { - if (! *str++) DBUG_RETURN (1); /* One char; skipp */ + if (! *str || (str_is_pattern && *str == wild_many)) + DBUG_RETURN(1); /* One char; skip */ + if (*str++ == wild_prefix && str_is_pattern && *str) + str++; } else { /* Found '*' */ - if (!*wildstr) DBUG_RETURN(0); /* '*' as last char: OK */ - flag=(*wildstr != wild_many && *wildstr != wild_one); - do + while (str_is_pattern && *str == wild_many) + str++; + for (; *wildstr == wild_many || *wildstr == wild_one; wildstr++) + if (*wildstr == wild_many) + { + while (str_is_pattern && *str == wild_many) + str++; + } + else + { + if (str_is_pattern && *str == wild_prefix && str[1]) + str+=2; + else if (! *str++) + DBUG_RETURN (1); + } + if (!*wildstr) + DBUG_RETURN(0); /* '*' as last char: OK */ + if ((cmp= *wildstr) == wild_prefix && wildstr[1] && !str_is_pattern) + cmp=wildstr[1]; + for (;;str++) { - if (flag) - { - char cmp; - if ((cmp= *wildstr) == wild_prefix && wildstr[1]) - cmp=wildstr[1]; - while (*str && *str != cmp) - str++; - if (!*str) DBUG_RETURN (1); - } - if (wild_compare(str,wildstr) == 0) DBUG_RETURN (0); - } while (*str++ && wildstr[0] != wild_many); - DBUG_RETURN(1); + while (*str && *str != cmp) + str++; + if (!*str) + DBUG_RETURN (1); + if (wild_compare(str,wildstr,str_is_pattern) == 0) + DBUG_RETURN (0); + } + /* We will never come here */ } } - DBUG_RETURN (*str != '\0'); + DBUG_RETURN (*str != 0); } /* wild_compare */ diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c index e9e12c72755..067e4b7acc5 100644 --- a/mysys/mf_wfile.c +++ b/mysys/mf_wfile.c @@ -106,7 +106,7 @@ int wf_test(register WF_PACK *wf_pack, register const char *name) not_pos=wf_pack->not_pos; for (i=0 ; i < not_pos; i++) - if (wild_compare(name,wf_pack->wild[i]) == 0) + if (wild_compare(name,wf_pack->wild[i],0) == 0) goto found; if (i) DBUG_RETURN(1); /* No-match */ @@ -115,7 +115,7 @@ found: /* Test that it isn't in not-list */ for (i=not_pos ; i < wf_pack->wilds; i++) - if (wild_compare(name,wf_pack->wild[i]) == 0) + if (wild_compare(name,wf_pack->wild[i],0) == 0) DBUG_RETURN(1); DBUG_RETURN(0); } /* wf_test */ diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 6d2f662b7df..9b676442995 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -834,7 +834,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 *bin_ip, - const char *user, const char *db) + const char *user, const char *db, my_bool db_is_pattern) { ulong host_access,db_access; uint i,key_length; @@ -868,7 +868,7 @@ ulong acl_get(const char *host, const char *ip, const char *bin_ip, { if (compare_hostname(&acl_db->host,host,ip)) { - if (!acl_db->db || !wild_compare(db,acl_db->db)) + if (!acl_db->db || !wild_compare(db,acl_db->db,db_is_pattern)) { db_access=acl_db->access; if (acl_db->host.hostname) @@ -890,7 +890,7 @@ ulong acl_get(const char *host, const char *ip, const char *bin_ip, ACL_HOST *acl_host=dynamic_element(&acl_hosts,i,ACL_HOST*); if (compare_hostname(&acl_host->host,host,ip)) { - if (!acl_host->db || !wild_compare(db,acl_host->db)) + if (!acl_host->db || !wild_compare(db,acl_host->db,0)) { host_access=acl_host->access; // Fully specified. Take it break; @@ -1222,7 +1222,7 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname, } return (!host->hostname || (hostname && !wild_case_compare(hostname,host->hostname)) || - (ip && !wild_compare(ip,host->hostname))); + (ip && !wild_compare(ip,host->hostname,0))); } @@ -1300,7 +1300,7 @@ static bool test_if_create_new_users(THD *thd) tl.db= (char*) "mysql"; tl.real_name= (char*) "user"; db_access=acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr, - thd->priv_user, tl.db); + thd->priv_user, tl.db, 0); if (!(db_access & INSERT_ACL)) { if (check_grant(thd,INSERT_ACL,&tl,0,1)) diff --git a/sql/sql_acl.h b/sql/sql_acl.h index bf269e5a7e3..7d8dcfd2079 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -85,7 +85,7 @@ my_bool acl_init(THD *thd, bool dont_read_acl_tables); void acl_reload(THD *thd); void acl_free(bool end=0); ulong acl_get(const char *host, const char *ip, const char *bin_ip, - const char *user, const char *db); + const char *user, const char *db, my_bool db_is_pattern); ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, const char *password,const char *scramble, char **priv_user, char *priv_host, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6bf0b0bd2ba..c4cad8a8786 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -149,7 +149,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild) if (wild) { strxmov(name,entry->table_cache_key,".",entry->real_name,NullS); - if (wild_compare(name,wild)) + if (wild_compare(name,wild,0)) continue; } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 865b2e1328f..2ee725e7432 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -410,7 +410,7 @@ bool mysql_change_db(THD *thd,const char *name) db_access=DB_ACLS; else db_access= (acl_get(thd->host,thd->ip,(char*) &thd->remote.sin_addr, - thd->priv_user,dbname) | + thd->priv_user,dbname,0) | thd->master_access); if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname))) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7e68db0dcd2..7ddbf79c6fe 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2672,7 +2672,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, if (!(thd->master_access & SELECT_ACL) && (db && (!thd->db || strcmp(db,thd->db)))) db_access=acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr, - thd->priv_user, db); /* purecov: inspected */ + thd->priv_user, db, 0); /* purecov: inspected */ *save_priv=thd->master_access | db_access; DBUG_RETURN(FALSE); } @@ -2692,7 +2692,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, if (db && (!thd->db || strcmp(db,thd->db))) db_access=acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr, - thd->priv_user, db); /* purecov: inspected */ + thd->priv_user, db, 0); /* purecov: inspected */ else db_access=thd->db_access; // Remove SHOW attribute and access rights we already have diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a4ef735c715..26163ed9bef 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -78,7 +78,7 @@ mysqld_show_dbs(THD *thd,const char *wild) { if (thd->master_access & (DB_ACLS | SHOW_DB_ACL) || acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr, - thd->priv_user, file_name) || + thd->priv_user, file_name, 0) || (grant_option && !check_grant_db(thd, file_name))) { thd->packet.length(0); @@ -214,7 +214,7 @@ mysql_find_files(THD *thd,List *files, const char *db,const char *path, #endif { if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat->st_mode) || - (wild && wild_compare(file->name,wild))) + (wild && wild_compare(file->name,wild, 0))) continue; } } @@ -232,7 +232,7 @@ mysql_find_files(THD *thd,List *files, const char *db,const char *path, if (wild_case_compare(file->name,wild)) continue; } - else if (wild_compare(file->name,wild)) + else if (wild_compare(file->name,wild, 0)) continue; } } From 88647105ca8bbc203edf397edc71b6346d825a3e Mon Sep 17 00:00:00 2001 From: "miguel@light." <> Date: Sun, 30 May 2004 04:11:19 -0300 Subject: [PATCH 04/11] VC++ project for to compile the udf_example.cc on Windows --- .../examples/udf_example/udf_example.def | 9 ++ .../examples/udf_example/udf_example.dsp | 111 ++++++++++++++++++ .../examples/udf_example/udf_example.dsw | 29 +++++ 3 files changed, 149 insertions(+) create mode 100644 VC++Files/examples/udf_example/udf_example.def create mode 100644 VC++Files/examples/udf_example/udf_example.dsp create mode 100644 VC++Files/examples/udf_example/udf_example.dsw 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> +{{{ +}}} + +############################################################################### + From 9145dcef5e5b33bd4618d500118624b59332d20d Mon Sep 17 00:00:00 2001 From: "hf@deer.(none)" <> Date: Mon, 31 May 2004 13:53:10 +0500 Subject: [PATCH 05/11] mysql_get_parameter interface fixed --- include/mysql.h | 2 +- libmysql/libmysql.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 1665dd5027e..7db6b36e667 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -263,7 +263,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/libmysql/libmysql.c b/libmysql/libmysql.c index 0a23954ae67..b3624ef3e94 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -124,7 +124,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; } From df8f60560941ed31c287e8e0277fe0849d8cd9ef Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Mon, 31 May 2004 16:33:45 +0300 Subject: [PATCH 06/11] InnoDB: Do not get a lock for consistent reads (Bug #3894) --- sql/ha_innodb.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index dee34b47ccb..e09a5e20d34 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4504,6 +4504,17 @@ ha_innobase::start_stmt( prepared for an update of a row */ prebuilt->select_lock_type = LOCK_X; + } else { + /* For other than temporary tables, we obtain + no lock for consistent read (plain SELECT), and + an exclusive lock for SELECT ... FOR UPDATE or + SELECT ... LOCK IN SHARE MODE. */ + + prebuilt->select_lock_type = + thd->lex.sql_command == SQLCOM_SELECT + && thd->lex.lock_option == TL_READ + ? LOCK_NONE + : LOCK_X; } /* Set the MySQL flag to mark that there is an active transaction */ From 2953c23ab04e89addc0daa8bc2d1d52a39da554c Mon Sep 17 00:00:00 2001 From: "jani@a80-186-24-72.elisa-laajakaista.fi" <> Date: Tue, 1 Jun 2004 17:29:24 +0300 Subject: [PATCH 07/11] Changed --log-warnings to be integer instead of boolean. Given --skip-log-warnings will disable warnings, --log-warnings will increment warning level by one, or the level can be given as an optional argument. Default level is 1. Changed aborted connection warning to be logged only if the level is > 1. --- sql/mysqld.cc | 12 ++++++++++-- sql/set_var.cc | 2 +- sql/sql_class.h | 2 +- sql/sql_parse.cc | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 65903d7ce8a..3cd42dbeac1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3944,11 +3944,11 @@ replicating a LOAD DATA INFILE command", 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.", @@ -4656,6 +4656,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 'I': case '?': usage(); diff --git a/sql/set_var.cc b/sql/set_var.cc index 525da26a5ac..4b66a621f62 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -133,7 +133,7 @@ sys_var_ulonglong_ptr sys_key_buffer_size("key_buffer_size", fix_key_buffer_size); 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_class.h b/sql/sql_class.h index 9663957963f..484a442af20 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -333,8 +333,8 @@ struct system_variables ulong query_prealloc_size; ulong trans_alloc_block_size; ulong trans_prealloc_size; + ulong log_warnings; - 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 7ddbf79c6fe..a9723108674 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -742,7 +742,7 @@ pthread_handler_decl(handle_one_connection,arg) free_root(&thd->mem_root,MYF(0)); if (net->error && net->vio != 0) { - 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", From aac5c88bcd1b83a7465b9c18c0805abbb564b3a9 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Tue, 1 Jun 2004 19:19:48 +0300 Subject: [PATCH 08/11] row0mysql.c, row0mysql.h, ha_innodb.cc: Inside LOCK TABLES, use either LOCK_S or LOCK_X in locking reads; an improvent over the previous patch --- innobase/include/row0mysql.h | 3 +++ innobase/row/row0mysql.c | 1 + sql/ha_innodb.cc | 40 ++++++++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h index a74c5bf4c60..e088071a1c4 100644 --- a/innobase/include/row0mysql.h +++ b/innobase/include/row0mysql.h @@ -507,6 +507,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/row/row0mysql.c b/innobase/row/row0mysql.c index 228f19c865f..4bbe901532c 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -380,6 +380,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/sql/ha_innodb.cc b/sql/ha_innodb.cc index e09a5e20d34..df193bde947 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4505,16 +4505,38 @@ ha_innobase::start_stmt( prebuilt->select_lock_type = LOCK_X; } else { - /* For other than temporary tables, we obtain - no lock for consistent read (plain SELECT), and - an exclusive lock for SELECT ... FOR UPDATE or - SELECT ... LOCK IN SHARE MODE. */ + /* 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. */ - prebuilt->select_lock_type = - thd->lex.sql_command == SQLCOM_SELECT - && thd->lex.lock_option == TL_READ - ? LOCK_NONE - : LOCK_X; + 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 */ From 7650da771122c99cb0417bc3605c8335c2ace01e Mon Sep 17 00:00:00 2001 From: "paul@ice.snake.net" <> Date: Tue, 1 Jun 2004 14:18:34 -0500 Subject: [PATCH 09/11] README: Update README URL. (Bug #3678) --- mysql-test/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/README b/mysql-test/README index c5dc3e219de..6ad97adbd2b 100644 --- a/mysql-test/README +++ b/mysql-test/README @@ -8,7 +8,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: From 5b905beee1ae8fbec075077b092818533be2dd35 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Tue, 1 Jun 2004 23:34:47 +0300 Subject: [PATCH 10/11] Updated version number Portability fix for netware. (We can't use TRY_RUN when cross compiling) --- configure.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index f2b66d1e09d..e346ebfa15e 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.0.20) +AM_INIT_AUTOMAKE(mysql, 4.0.21) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -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 From 3b313f14f2986cc6069ab55ad9123afe73ba821e Mon Sep 17 00:00:00 2001 From: "greg@mysql.com" <> Date: Tue, 1 Jun 2004 19:35:09 -0100 Subject: [PATCH 11/11] Fix applied to allow building of 4.0.20 for NetWare --- client/mysqltest.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index cdf1648769b..22ce5208445 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -185,7 +185,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__ */ @@ -3509,6 +3509,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) @@ -3528,7 +3529,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))) @@ -3571,11 +3572,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));