From 63e56390a3f1a4f80642932a790ab74f28de8010 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 10 Sep 2009 03:18:29 -0600 Subject: WL#2110 (SIGNAL) WL#2265 (RESIGNAL) Manual merge of SIGNAL and RESIGNAL to mysql-trunk-signal, plus required dependencies. --- sql/sql_base.cc | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b81070000b3..92ae390894a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -44,9 +44,12 @@ public: virtual ~Prelock_error_handler() {} - virtual bool handle_error(uint sql_errno, const char *message, - MYSQL_ERROR::enum_warning_level level, - THD *thd); + virtual bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* msg, + MYSQL_ERROR ** cond_hdl); bool safely_trapped_errors(); @@ -57,11 +60,14 @@ private: bool -Prelock_error_handler::handle_error(uint sql_errno, - const char * /* message */, - MYSQL_ERROR::enum_warning_level /* level */, - THD * /* thd */) +Prelock_error_handler::handle_condition(THD *, + uint sql_errno, + const char*, + MYSQL_ERROR::enum_warning_level, + const char*, + MYSQL_ERROR ** cond_hdl) { + *cond_hdl= NULL; if (sql_errno == ER_NO_SUCH_TABLE) { m_handled_errors++; @@ -473,7 +479,7 @@ static TABLE_SHARE @todo Rework alternative ways to deal with ER_NO_SUCH TABLE. */ - if (share || (thd->is_error() && thd->main_da.sql_errno() != ER_NO_SUCH_TABLE)) + if (share || (thd->is_error() && thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE)) DBUG_RETURN(share); @@ -520,7 +526,7 @@ static TABLE_SHARE DBUG_RETURN(0); } /* Table existed in engine. Let's open it */ - mysql_reset_errors(thd, 1); // Clear warnings + thd->warning_info->clear_warning_info(thd->query_id); thd->clear_error(); // Clear error message DBUG_RETURN(get_table_share(thd, table_list, key, key_length, db_flags, error)); @@ -1281,9 +1287,9 @@ void close_thread_tables(THD *thd) */ if (!(thd->state_flags & Open_tables_state::BACKUPS_AVAIL)) { - thd->main_da.can_overwrite_status= TRUE; + thd->stmt_da->can_overwrite_status= TRUE; ha_autocommit_or_rollback(thd, thd->is_error()); - thd->main_da.can_overwrite_status= FALSE; + thd->stmt_da->can_overwrite_status= FALSE; /* Reset transaction state, but only if we're not inside a @@ -3943,7 +3949,7 @@ retry: release_table_share(share, RELEASE_WAIT_FOR_DROP); if (!thd->killed) { - mysql_reset_errors(thd, 1); // Clear warnings + thd->warning_info->clear_warning_info(thd->query_id); thd->clear_error(); // Clear error message goto retry; } -- cgit v1.2.1 From 595b8f92ae89eb2ef2d502ca80668a525ed2fa99 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Wed, 14 Oct 2009 15:14:58 +0400 Subject: Backport of: ---------------------------------------------------------- revno: 2630.22.8 committer: Konstantin Osipov branch nick: mysql-6.0-runtime timestamp: Sun 2008-08-10 18:49:52 +0400 message: Get rid of typedef struct for the most commonly used types: TABLE, TABLE_SHARE, LEX. This simplifies use of tags and forward declarations. --- sql/sql_base.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e5005f42b0d..d09473beb60 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2927,7 +2927,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, Set 1 as a flag here */ if (error < 0) - table_list->view= (st_lex*)1; + table_list->view= (LEX*)1; my_free((uchar*)table, MYF(0)); VOID(pthread_mutex_unlock(&LOCK_open)); -- cgit v1.2.1 From 9b41c7532d18b04d2f430932ad916886c77fbff6 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Wed, 14 Oct 2009 20:37:38 +0400 Subject: Backport of: ---------------------------------------------------------- revno: 2617.22.5 committer: Konstantin Osipov branch nick: mysql-6.0-runtime timestamp: Tue 2009-01-27 05:08:48 +0300 message: Remove non-prefixed use of HASH. Always use my_hash_init(), my_hash_inited(), my_hash_search(), my_hash_element(), my_hash_delete(), my_hash_free() rather than non-prefixed counterparts (hash_init(), etc). Remove the backward-compatible defines. --- sql/sql_base.cc | 117 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 58 deletions(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d09473beb60..0c6ea53d39c 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -126,9 +126,9 @@ extern "C" uchar *table_cache_key(const uchar *record, size_t *length, bool table_cache_init(void) { - return hash_init(&open_cache, &my_charset_bin, table_cache_size+16, - 0, 0, table_cache_key, - (hash_free_key) free_cache_entry, 0) != 0; + return my_hash_init(&open_cache, &my_charset_bin, table_cache_size+16, + 0, 0, table_cache_key, + (my_hash_free_key) free_cache_entry, 0) != 0; } void table_cache_free(void) @@ -138,7 +138,7 @@ void table_cache_free(void) { close_cached_tables(NULL, NULL, FALSE, FALSE, FALSE); if (!open_cache.records) // Safety first - hash_free(&open_cache); + my_hash_free(&open_cache); } DBUG_VOID_RETURN; } @@ -173,7 +173,7 @@ static void check_unused(void) } for (idx=0 ; idx < open_cache.records ; idx++) { - TABLE *entry=(TABLE*) hash_element(&open_cache,idx); + TABLE *entry=(TABLE*) my_hash_element(&open_cache,idx); if (!entry->in_use) count--; if (entry->file) @@ -286,9 +286,9 @@ bool table_def_init(void) oldest_unused_share= &end_of_unused_share; end_of_unused_share.prev= &oldest_unused_share; - return hash_init(&table_def_cache, &my_charset_bin, table_def_size, - 0, 0, table_def_key, - (hash_free_key) table_def_free_entry, 0) != 0; + return my_hash_init(&table_def_cache, &my_charset_bin, table_def_size, + 0, 0, table_def_key, + (my_hash_free_key) table_def_free_entry, 0) != 0; } @@ -299,7 +299,7 @@ void table_def_free(void) { table_def_inited= 0; pthread_mutex_destroy(&LOCK_table_share); - hash_free(&table_def_cache); + my_hash_free(&table_def_cache); } DBUG_VOID_RETURN; } @@ -345,8 +345,8 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, *error= 0; /* Read table definition from cache */ - if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, - key_length))) + if ((share= (TABLE_SHARE*) my_hash_search(&table_def_cache,(uchar*) key, + key_length))) goto found; if (!(share= alloc_table_share(table_list, key, key_length))) @@ -383,7 +383,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, if (open_table_def(thd, share, db_flags)) { *error= share->error; - (void) hash_delete(&table_def_cache, (uchar*) share); + (void) my_hash_delete(&table_def_cache, (uchar*) share); DBUG_RETURN(0); } share->ref_count++; // Mark in use @@ -435,7 +435,7 @@ found: oldest_unused_share->next) { pthread_mutex_lock(&oldest_unused_share->mutex); - VOID(hash_delete(&table_def_cache, (uchar*) oldest_unused_share)); + VOID(my_hash_delete(&table_def_cache, (uchar*) oldest_unused_share)); } DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u", @@ -590,7 +590,7 @@ void release_table_share(TABLE_SHARE *share, enum release_type type) if (to_be_deleted) { DBUG_PRINT("info", ("Deleting share")); - hash_delete(&table_def_cache, (uchar*) share); + my_hash_delete(&table_def_cache, (uchar*) share); DBUG_VOID_RETURN; } pthread_mutex_unlock(&share->mutex); @@ -621,7 +621,8 @@ TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name) table_list.db= (char*) db; table_list.table_name= (char*) table_name; key_length= create_table_def_key((THD*) 0, key, &table_list, 0); - return (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, key_length); + return (TABLE_SHARE*) my_hash_search(&table_def_cache, + (uchar*) key, key_length); } @@ -718,7 +719,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild) for (uint idx=0 ; result == 0 && idx < open_cache.records; idx++) { OPEN_TABLE_LIST *table; - TABLE *entry=(TABLE*) hash_element(&open_cache,idx); + TABLE *entry=(TABLE*) my_hash_element(&open_cache,idx); TABLE_SHARE *share= entry->s; if (db && my_strcasecmp(system_charset_info, db, share->db.str)) @@ -867,17 +868,17 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, while (unused_tables) { #ifdef EXTRA_DEBUG - if (hash_delete(&open_cache,(uchar*) unused_tables)) + if (my_hash_delete(&open_cache,(uchar*) unused_tables)) printf("Warning: Couldn't delete open table from hash\n"); #else - VOID(hash_delete(&open_cache,(uchar*) unused_tables)); + VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); #endif } /* Free table shares */ while (oldest_unused_share->next) { pthread_mutex_lock(&oldest_unused_share->mutex); - VOID(hash_delete(&table_def_cache, (uchar*) oldest_unused_share)); + VOID(my_hash_delete(&table_def_cache, (uchar*) oldest_unused_share)); } DBUG_PRINT("tcache", ("incremented global refresh_version to: %lu", refresh_version)); @@ -922,7 +923,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, */ for (uint idx=0 ; idx < open_cache.records ; idx++) { - TABLE *table=(TABLE*) hash_element(&open_cache,idx); + TABLE *table=(TABLE*) my_hash_element(&open_cache,idx); if (table->in_use) table->in_use->some_tables_deleted= 1; } @@ -966,7 +967,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, found=0; for (uint idx=0 ; idx < open_cache.records ; idx++) { - TABLE *table=(TABLE*) hash_element(&open_cache,idx); + TABLE *table=(TABLE*) my_hash_element(&open_cache,idx); /* Avoid a self-deadlock. */ if (table->in_use == thd) continue; @@ -1048,7 +1049,7 @@ bool close_cached_connection_tables(THD *thd, bool if_wait_for_refresh, for (idx= 0; idx < table_def_cache.records; idx++) { - TABLE_SHARE *share= (TABLE_SHARE *) hash_element(&table_def_cache, idx); + TABLE_SHARE *share= (TABLE_SHARE *) my_hash_element(&table_def_cache, idx); /* Ignore if table is not open or does not have a connect_string */ if (!share->connect_string.length || !share->ref_count) @@ -1204,7 +1205,7 @@ static void close_open_tables(THD *thd) /* Free tables to hold down open files */ while (open_cache.records > table_cache_size && unused_tables) - VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ + VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ check_unused(); if (found_old_table) { @@ -1390,7 +1391,7 @@ bool close_thread_table(THD *thd, TABLE **table_ptr) if (table->needs_reopen_or_name_lock() || thd->version != refresh_version || !table->db_stat) { - VOID(hash_delete(&open_cache,(uchar*) table)); + VOID(my_hash_delete(&open_cache,(uchar*) table)); found_old_table=1; } else @@ -2093,7 +2094,7 @@ void unlink_open_table(THD *thd, TABLE *find, bool unlock) /* Remove table from open_tables list. */ *prev= list->next; /* Close table. */ - VOID(hash_delete(&open_cache,(uchar*) list)); // Close table + VOID(my_hash_delete(&open_cache,(uchar*) list)); // Close table } else { @@ -2398,7 +2399,7 @@ bool lock_table_name_if_not_cached(THD *thd, const char *db, key_length= (uint)(strmov(strmov(key, db) + 1, table_name) - key) + 1; VOID(pthread_mutex_lock(&LOCK_open)); - if (hash_search(&open_cache, (uchar *)key, key_length)) + if (my_hash_search(&open_cache, (uchar *)key, key_length)) { VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_PRINT("info", ("Table is cached, name-lock is not obtained")); @@ -2753,11 +2754,11 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, an implicit "pending locks queue" - see wait_for_locked_table_names for details. */ - for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length, - &state); + for (table= (TABLE*) my_hash_first(&open_cache, (uchar*) key, key_length, + &state); table && table->in_use ; - table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length, - &state)) + table= (TABLE*) my_hash_next(&open_cache, (uchar*) key, key_length, + &state)) { DBUG_PRINT("tcache", ("in_use table: '%s'.'%s' 0x%lx", table->s->db.str, table->s->table_name.str, (long) table)); @@ -2869,7 +2870,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, DBUG_PRINT("tcache", ("opening new table")); /* Free cache if too big */ while (open_cache.records > table_cache_size && unused_tables) - VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ + VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ if (table_list->create) { @@ -3326,7 +3327,7 @@ bool reopen_tables(THD *thd, bool get_locks, bool mark_share_as_old) */ if (table->child_l || table->parent) detach_merge_children(table, TRUE); - VOID(hash_delete(&open_cache,(uchar*) table)); + VOID(my_hash_delete(&open_cache,(uchar*) table)); error=1; } else @@ -3355,7 +3356,7 @@ bool reopen_tables(THD *thd, bool get_locks, bool mark_share_as_old) { while (err_tables) { - VOID(hash_delete(&open_cache, (uchar*) err_tables)); + VOID(my_hash_delete(&open_cache, (uchar*) err_tables)); err_tables= err_tables->next; } } @@ -3507,11 +3508,11 @@ bool table_is_used(TABLE *table, bool wait_for_name_lock) DBUG_PRINT("loop", ("table_name: %s", table->alias)); HASH_SEARCH_STATE state; - for (TABLE *search= (TABLE*) hash_first(&open_cache, (uchar*) key, - key_length, &state); + for (TABLE *search= (TABLE*) my_hash_first(&open_cache, (uchar*) key, + key_length, &state); search ; - search= (TABLE*) hash_next(&open_cache, (uchar*) key, - key_length, &state)) + search= (TABLE*) my_hash_next(&open_cache, (uchar*) key, + key_length, &state)) { DBUG_PRINT("info", ("share: 0x%lx " "open_placeholder: %d locked_by_name: %d " @@ -3637,7 +3638,7 @@ TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name) else { /* We already have a name lock, remove copy */ - VOID(hash_delete(&open_cache,(uchar*) table)); + VOID(my_hash_delete(&open_cache,(uchar*) table)); } } else @@ -4611,7 +4612,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) Let us free memory used by 'sroutines' hash here since we never call destructor for this LEX. */ - hash_free(&tables->view->sroutines); + my_hash_free(&tables->view->sroutines); goto process_view_routines; } @@ -5875,8 +5876,8 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length, field_ptr= table->field + cached_field_index; else if (table->s->name_hash.records) { - field_ptr= (Field**) hash_search(&table->s->name_hash, (uchar*) name, - length); + field_ptr= (Field**) my_hash_search(&table->s->name_hash, (uchar*) name, + length); if (field_ptr) { /* @@ -6122,8 +6123,8 @@ Field *find_field_in_table_sef(TABLE *table, const char *name) Field **field_ptr; if (table->s->name_hash.records) { - field_ptr= (Field**)hash_search(&table->s->name_hash,(uchar*) name, - strlen(name)); + field_ptr= (Field**)my_hash_search(&table->s->name_hash,(uchar*) name, + strlen(name)); if (field_ptr) { /* @@ -8365,7 +8366,7 @@ void remove_db_from_cache(const char *db) { for (uint idx=0 ; idx < open_cache.records ; idx++) { - TABLE *table=(TABLE*) hash_element(&open_cache,idx); + TABLE *table=(TABLE*) my_hash_element(&open_cache,idx); if (!strcmp(table->s->db.str, db)) { table->s->version= 0L; /* Free when thread is ready */ @@ -8374,7 +8375,7 @@ void remove_db_from_cache(const char *db) } } while (unused_tables && !unused_tables->s->version) - VOID(hash_delete(&open_cache,(uchar*) unused_tables)); + VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); } @@ -8390,7 +8391,7 @@ void flush_tables() { (void) pthread_mutex_lock(&LOCK_open); while (unused_tables) - hash_delete(&open_cache,(uchar*) unused_tables); + my_hash_delete(&open_cache,(uchar*) unused_tables); (void) pthread_mutex_unlock(&LOCK_open); } @@ -8427,11 +8428,11 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, HASH_SEARCH_STATE state; result= signalled= 0; - for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length, - &state); + for (table= (TABLE*) my_hash_first(&open_cache, (uchar*) key, key_length, + &state); table; - table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length, - &state)) + table= (TABLE*) my_hash_next(&open_cache, (uchar*) key, key_length, + &state)) { THD *in_use; DBUG_PRINT("tcache", ("found table: '%s'.'%s' 0x%lx", table->s->db.str, @@ -8498,12 +8499,12 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, } } while (unused_tables && !unused_tables->s->version) - VOID(hash_delete(&open_cache,(uchar*) unused_tables)); + VOID(my_hash_delete(&open_cache,(uchar*) unused_tables)); DBUG_PRINT("info", ("Removing table from table_def_cache")); /* Remove table from table definition cache if it's not in use */ - if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, - key_length))) + if ((share= (TABLE_SHARE*) my_hash_search(&table_def_cache,(uchar*) key, + key_length))) { DBUG_PRINT("info", ("share version: %lu ref_count: %u", share->version, share->ref_count)); @@ -8511,7 +8512,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, if (share->ref_count == 0) { pthread_mutex_lock(&share->mutex); - VOID(hash_delete(&table_def_cache, (uchar*) share)); + VOID(my_hash_delete(&table_def_cache, (uchar*) share)); } } @@ -8759,11 +8760,11 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table key_length=(uint) (strmov(strmov(key,lpt->db)+1,lpt->table_name)-key)+1; VOID(pthread_mutex_lock(&LOCK_open)); HASH_SEARCH_STATE state; - for (table= (TABLE*) hash_first(&open_cache,(uchar*) key,key_length, - &state) ; + for (table= (TABLE*) my_hash_first(&open_cache,(uchar*) key,key_length, + &state) ; table; - table= (TABLE*) hash_next(&open_cache,(uchar*) key,key_length, - &state)) + table= (TABLE*) my_hash_next(&open_cache,(uchar*) key,key_length, + &state)) { THD *in_use= table->in_use; table->s->version= 0L; -- cgit v1.2.1 From 0659b857e7fe232ebfe7f48c5e0affd59dbf5862 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Mon, 19 Oct 2009 14:58:13 +0200 Subject: Bug#27145 EXTRA_ACL troubles The flag EXTRA_ACL is used in conjugation with our access checks, yet it is not clear what impact this flag has. This is a code clean up which replaces use of EXTRA_ACL with an explicit function parameter. The patch also fixes privilege checks for: - SHOW CREATE TABLE: The new privilege requirement is any privilege on the table-level. - CHECKSUM TABLE: Requires SELECT on the table level. - SHOW CREATE VIEW: Requires SHOW_VIEW and SELECT on the table level (just as the manual claims) - SHOW INDEX: Requires any privilege on any column combination. mysql-test/r/grant.result: * Error message now shows correct command (SHOW instead of SELECT) mysql-test/r/grant2.result: * Error message now shows correct command (SHOW instead of SELECT) mysql-test/r/grant4.result: * This test file tests privilege requirements for SHOW COLUMNS CREATE TABLE .. LIKE SHOW CREATE TABLE SHOW INDEX CHECKSUM TABLE SHOW CREATE VIEW mysql-test/r/information_schema_db.result: * Added SELECT privilege to testdb_2 as SHOW CREATE VIEW now demands this privilege as well as SHOW VIEW. mysql-test/r/outfile.result: * Changed error code mysql-test/r/view_grant.result: * Additional SELECT privilege is now needed for SHOW CREATE VIEW mysql-test/t/grant4.test: * This test file tests privilege requirements for SHOW COLUMNS CREATE TABLE .. LIKE SHOW CREATE TABLE SHOW INDEX CHECKSUM TABLE SHOW CREATE VIEW mysql-test/t/information_schema_db.test: * Added SELECT privilege to testdb_2 as SHOW CREATE VIEW now demands this privilege as well as SHOW VIEW. mysql-test/t/outfile.test: * Changed error code mysql-test/t/view_grant.test: * Additional SELECT privilege is now needed for SHOW CREATE VIEW sql/mysql_priv.h: * Replaced EXTRA_ACL with a parameter sql/sp_head.cc: * Replaced EXTRA_ACL with a parameter sql/sql_acl.cc: * Converted function documentation to doxygen and clarified some behaviors. * Changed value from uint to bool to better reflect its meaning. * Removed pointless variable orig_want_access * Added function has_any_table_level_privileges to help with requirements checks during SHOW CREATE TABLE. sql/sql_acl.h: * changed signature of check_grant() * introduced access control function has_any_table_leevl_privileges() sql/sql_base.cc: * Check_table_access has new signature sql/sql_cache.cc: * Check_table_access has new signature sql/sql_parse.cc: * Rewrote function documentation in doxygen comments for: check_access, check_table_acces, check_grant. * Removed EXTRA_ACL flag where it doesn't hold any meaningful purpose anymore and replaced it with a function parameter where any privileges on any column combination would satisfy the requirement. * Fixed privilege check for SHOW COLUMNS and SHOW INDEX * Modified check_table_access to gain clarity in what EXTRA_ACL actually does. * Modified check_access to gain clarity in what EXTRA_ACL actually does. * Fixed privilege check for CREATE TABLE .. LIKE .. ; It now requires SELECT privileges on the table. * Fixed privilege check for SHOW CREATE TABLE ..; It now requires any privilege on the table level. sql/sql_plugin.cc: * check_table_access has new signature sql/sql_prepare.cc: * check_table_access has new signature sql/sql_show.cc: * check_table_access has new signature sql/sql_trigger.cc: * check_table_access has new signature sql/sql_update.cc: * check grant has new signature sql/sql_view.cc: * check_table_access has new signature --- sql/sql_base.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e5005f42b0d..d02a917644a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -731,7 +731,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild) table_list.table_name= share->table_name.str; table_list.grant.privilege=0; - if (check_table_access(thd,SELECT_ACL | EXTRA_ACL,&table_list, 1, TRUE)) + if (check_table_access(thd,SELECT_ACL,&table_list, TRUE, 1, TRUE)) continue; /* need to check if we haven't already listed it */ for (table= open_list ; table ; table=table->next) -- cgit v1.2.1 From 70fab22cabe0245cd560b8b2f9cf8b8746c30dca Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Mon, 19 Oct 2009 15:23:42 +0200 Subject: Back-port from 6.0 of the fix for BUG#41759: "Valgrind warning: Invalid read of size 1 open_tables() with ps-protocol" (from revid:sergefp@mysql.com-20081227013233-f9n2by8romt37hyi) --- sql/sql_base.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e5005f42b0d..770694dd472 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4516,9 +4516,6 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) */ for (tables= *start; tables ;tables= tables->next_global) { - DBUG_PRINT("tcache", ("opening table: '%s'.'%s' item: 0x%lx", - tables->db, tables->table_name, (long) tables)); - safe_to_ignore_table= FALSE; /* @@ -4555,6 +4552,8 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) } DBUG_RETURN(-1); } + DBUG_PRINT("tcache", ("opening table: '%s'.'%s' item: 0x%lx", + tables->db, tables->table_name, (long) tables)); (*counter)++; /* -- cgit v1.2.1 From 8ec23470f14323bb85220bae42d154681a4be7f3 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Thu, 22 Oct 2009 00:02:06 +0400 Subject: Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1, 2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29, 2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and some other minor revisions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch implements: WL#4264 "Backup: Stabilize Service Interface" -- all the server prerequisites except si_objects.{h,cc} themselves (they can be just copied over, when needed). WL#4435: Support OUT-parameters in prepared statements. (and all issues in the initial patches for these two tasks, that were discovered in pushbuild and during testing). Bug#39519: mysql_stmt_close() should flush all data associated with the statement. After execution of a prepared statement, send OUT parameters of the invoked stored procedure, if any, to the client. When using the binary protocol, send the parameters in an additional result set over the wire. When using the text protocol, assign out parameters to the user variables from the CALL(@var1, @var2, ...) specification. The following refactoring has been made: - Protocol::send_fields() was renamed to Protocol::send_result_set_metadata(); - A new Protocol::send_result_set_row() was introduced to incapsulate common functionality for sending row data. - Signature of Protocol::prepare_for_send() was changed: this operation does not need a list of items, the number of items is fully sufficient. The following backward incompatible changes have been made: - CLIENT_MULTI_RESULTS is now enabled by default in the client; - CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client. include/mysql.h: Add a new flag to MYSQL_METHODS::flush_use_result function pointer. This flag determines if all results should be flushed or only the first one: - if flush_all_results is TRUE, then cli_flush_use_result() will read/flush all pending results. I.e. it will read all packets while server status attribute indicates that there are more results. This is a new semantic, required to fix the bug. - if flush_all_results is FALSE, the old sematic is preserved -- i.e. cli_flush_use_result() reads data until first EOF-packet. include/mysql.h.pp: Update the ABI with new calls (compatible changes). include/mysql_com.h: Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю libmysql/libmysql.c: Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol. Fix a minor bug in alloc_fields() -- not all members were copied over, and some only shallow-copied (catalog). Flush all results in mysql_stmt_close() (Bug#39519). libmysqld/lib_sql.cc: Rename send_fields() -> send_result_set_metadata(). Refactoring: change prepare_for_send() so that it accepts only what it really needs -- a number of elements in the list. mysql-test/r/ps.result: Update results: WL#4435. mysql-test/t/ps.test: WL#4435: A test case for an SQL-part of the problem. sql-common/client.c: Bug#39519. Implement new functionality in cli_flush_use_result(): if flush_all_delete is TRUE, then it should read/flush all pending results. sql/Makefile.am: Add a new header sql_prepare.h to the list of build headers. sql/events.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/handler.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/mysql_priv.h: Move sql_prepare.cc-specific declarations to a new header - sql_prepare.h. sql/procedure.h: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/protocol.cc: Move the logic responsible for sending of one result set row to the Protocol class. Define a template for end-of-statement action. Refactoring: change prepare_for_send() so that it accepts only what it really needs -- a number of elements in the list. Rename send_fields() to send_result_set_metadata(). sql/protocol.h: Update with new declarations (WL#4435). Rename send_fields() -> send_result_set_metadata(). prepare_for_send() only needs the number of columns to send, and doesn't use the item list - update signature to require only what's needed. Add a new protocol type -- Protocol_local. sql/repl_failsafe.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/slave.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_acl.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_base.cc: Include sql_prepare.h (for Reprepare_observer). sql/sql_cache.cc: Extend the query cache flags block to be able to store a numeric id for the result format, not just a flag binary/non-binary. sql/sql_class.cc: Update to use the rename of Protocol::send_fields() to Protocol::send_result_set_metadata(). Use Protocol::send_one_result_set_row(). sql/sql_class.h: Move the declaration of Reprepare_observer to the new header - sql_prepare.h. Update to the new signature of class Protocol::send_fields(). sql/sql_connect.cc: Use a protocol template method instead of raw NET layer API at the end of a statement. sql/sql_cursor.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_error.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_handler.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). Use new method Protocol::send_one_result_set_row(). sql/sql_help.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_lex.cc: Initialize multi_statements variable. Add a handy constant for empty lex string. sql/sql_lex.h: Add a separate member for a standalone parsing option - multi-statements support. sql/sql_list.cc: sql_list.h is a standalone header now, no need to include mysql_priv.h. sql/sql_list.h: Make sql_list.h a stand-alone header. sql/sql_parse.cc: Include sql_prepare.h for prepared statements- related declarations. Use a new Protocol template method to end each statement (send OK, EOF or ERROR to the client). sql/sql_prepare.cc: Implement Execute Direct API (WL#4264), currently unused. It will be used by the service interface (Backup). Use a new header - sql_prepare.h. Add support for OUT parameters in the binary and text protocol (prepared statements only). sql/sql_prepare.h: Add a new header to contain (for now) all prepared statement- external related declarations. sql/sql_profile.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_repl.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_select.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_show.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_string.h: Add a way to convert a String to LEX_STRING. sql/sql_table.cc: Rename: Protocol::send_fields() -> Protocol::send_result_set_metadata(). sql/sql_update.cc: Remove an extraneous my_error(). The error is already reported in update_non_unique_table_error(). sql/sql_yacc.yy: Support for multi-statements is an independent property of parsing, not derived from the protocol type. tests/mysql_client_test.c: Add tests for WL#4435 (binary protocol). --- sql/sql_base.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0c6ea53d39c..b5d713ebe62 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -21,6 +21,7 @@ #include "sp_head.h" #include "sp.h" #include "sql_trigger.h" +#include "sql_prepare.h" #include #include #include -- cgit v1.2.1 From 96dbafaa8d6bfa18a861476babfda3c6b7875db4 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 23 Oct 2009 14:19:54 +0500 Subject: Bug#35428 When selecting from INFORMATION_SCHEMA tables, incomplete metadata backport to Betony --- sql/sql_base.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 31242ae0f68..26bcd83d235 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6010,7 +6010,9 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, table_name && table_name[0] && (my_strcasecmp(table_alias_charset, table_list->alias, table_name) || (db_name && db_name[0] && table_list->db && table_list->db[0] && - strcmp(db_name, table_list->db)))) + (table_list->schema_table ? + my_strcasecmp(system_charset_info, db_name, table_list->db) : + strcmp(db_name, table_list->db))))) DBUG_RETURN(0); *actual_table= NULL; -- cgit v1.2.1