diff options
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r-- | sql/sql_handler.cc | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 3bbf4b78d07..ab3f2797405 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -207,21 +207,21 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) DBUG_RETURN(TRUE); } - if (! hash_inited(&thd->handler_tables_hash)) + if (! my_hash_inited(&thd->handler_tables_hash)) { /* HASH entries are of type TABLE_LIST. */ - if (hash_init(&thd->handler_tables_hash, &my_charset_latin1, - HANDLER_TABLES_HASH_SIZE, 0, 0, - (hash_get_key) mysql_ha_hash_get_key, - (hash_free_key) mysql_ha_hash_free, 0)) + if (my_hash_init(&thd->handler_tables_hash, &my_charset_latin1, + HANDLER_TABLES_HASH_SIZE, 0, 0, + (my_hash_get_key) mysql_ha_hash_get_key, + (my_hash_free_key) mysql_ha_hash_free, 0)) goto err; } else if (! reopen) /* Otherwise we have 'tables' already. */ { - if (hash_search(&thd->handler_tables_hash, (uchar*) tables->alias, - strlen(tables->alias) + 1)) + if (my_hash_search(&thd->handler_tables_hash, (uchar*) tables->alias, + strlen(tables->alias) + 1)) { DBUG_PRINT("info",("duplicate '%s'", tables->alias)); my_error(ER_NONUNIQ_TABLE, MYF(0), tables->alias); @@ -367,12 +367,12 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables) DBUG_PRINT("enter",("'%s'.'%s' as '%s'", tables->db, tables->table_name, tables->alias)); - if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, - (uchar*) tables->alias, - strlen(tables->alias) + 1))) + if ((hash_tables= (TABLE_LIST*) my_hash_search(&thd->handler_tables_hash, + (uchar*) tables->alias, + strlen(tables->alias) + 1))) { mysql_ha_close_table(thd, hash_tables, FALSE); - hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables); + my_hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables); } else { @@ -436,9 +436,9 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, it++; retry: - if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, - (uchar*) tables->alias, - strlen(tables->alias) + 1))) + if ((hash_tables= (TABLE_LIST*) my_hash_search(&thd->handler_tables_hash, + (uchar*) tables->alias, + strlen(tables->alias) + 1))) { table= hash_tables->table; DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' table: 0x%lx", @@ -460,7 +460,7 @@ retry: hash_tables->db, hash_tables->table_name, hash_tables->alias, table)); } - + table->pos_in_table_list= tables; #if MYSQL_VERSION_ID < 40100 if (*tables->db && strcmp(table->table_cache_key, tables->db)) { @@ -545,7 +545,7 @@ retry: tables->db, tables->alias, &it, 0)) goto err; - protocol->send_fields(&list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); + protocol->send_result_set_metadata(&list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); /* In ::external_lock InnoDB resets the fields which tell it that @@ -667,18 +667,11 @@ retry: continue; if (num_rows >= offset_limit_cnt) { - Item *item; protocol->prepare_for_resend(); - it.rewind(); - while ((item=it++)) - { - if (item->send(thd->protocol, &buffer)) - { - protocol->free(); // Free used - my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); - goto err; - } - } + + if (protocol->send_result_set_row(&list)) + goto err; + protocol->write(); } num_rows++; @@ -716,7 +709,7 @@ static TABLE_LIST *mysql_ha_find(THD *thd, TABLE_LIST *tables) /* search for all handlers with matching table names */ for (uint i= 0; i < thd->handler_tables_hash.records; i++) { - hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i); + hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i); for (tables= first; tables; tables= tables->next_local) { if ((! *tables->db || @@ -760,7 +753,7 @@ void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables, bool is_locked) next= hash_tables->next_local; if (hash_tables->table) mysql_ha_close_table(thd, hash_tables, is_locked); - hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables); + my_hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables); hash_tables= next; } @@ -786,7 +779,7 @@ void mysql_ha_flush(THD *thd) for (uint i= 0; i < thd->handler_tables_hash.records; i++) { - hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i); + hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i); if (hash_tables->table && hash_tables->table->needs_reopen_or_name_lock()) mysql_ha_close_table(thd, hash_tables, TRUE); } @@ -810,12 +803,12 @@ void mysql_ha_cleanup(THD *thd) for (uint i= 0; i < thd->handler_tables_hash.records; i++) { - hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i); + hash_tables= (TABLE_LIST*) my_hash_element(&thd->handler_tables_hash, i); if (hash_tables->table) mysql_ha_close_table(thd, hash_tables, FALSE); - } + } - hash_free(&thd->handler_tables_hash); + my_hash_free(&thd->handler_tables_hash); DBUG_VOID_RETURN; } |