diff options
author | unknown <monty@mashka.mysql.fi> | 2003-09-11 19:06:23 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2003-09-11 19:06:23 +0300 |
commit | dd0d199ebeab47facb4d01269cda97c258491c22 (patch) | |
tree | ba442d57a65bd55a0d0fec02aa6abeae237a568b /sql | |
parent | c9d1bdfac3956f5b32e338e620bd5698439bb43c (diff) | |
download | mariadb-git-dd0d199ebeab47facb4d01269cda97c258491c22.tar.gz |
After merge fixes.
Note that mix_innodb_myisam_binlog and union fails after this patch (Will be fixed shortly by maintaners of this code)
client/mysql.cc:
After merge fix
include/mysql.h:
Some additions to MYSQL_BIND for cleaner prepared statement code
libmysql/libmysql.c:
mysql_prepare_result -> mysql_get_metadata()
Added test for offset overflow when using mysql_fetch_column()
Cleaned up mysql_fetch_column()
Optimized fetch_result() usage
mysql-test/r/func_group.result:
Updated results after merge
mysql-test/r/func_test.result:
Updated results after merge
mysql-test/r/grant.result:
Updated results after merge
mysql-test/r/loaddata.result:
Updated results after merge
mysql-test/r/lowercase_table.result:
Updated results after merge
mysql-test/r/mix_innodb_myisam_binlog.result:
Updated results after merge (note that this is still not correct; Need patch to mysqld to fix this properly)
mysql-test/r/myisam.result:
Updated results after merge
mysql-test/r/range.result:
Updated results after merge
mysql-test/r/rpl_loaddata.result:
Updated results after merge
mysql-test/r/rpl_loaddata_rule_m.result:
Updated results after merge
mysql-test/r/rpl_loaddata_rule_s.result:
Updated results after merge
mysql-test/r/rpl_log.result:
Updated results after merge
mysql-test/r/union.result:
Updated results after merge
mysql-test/t/lowercase_table.test:
Update after merge
mysql-test/t/myisam.test:
Update after merge
mysql-test/t/union.test:
Update after merge
sql-bench/compare-results.sh:
Fix for now output format
sql/field.h:
Added is_null_in_record() to make ha_innodb.cc code more general
sql/ha_innodb.cc:
Removed some functions that uses inernal (private) MySQL information
sql/item_cmpfunc.cc:
After merge fix
sql/log_event.cc:
After merge fix; (Some code should be checked by Guilhem)
sql/opt_range.cc:
Simple optimzation and after merge fixes
sql/slave.cc:
After merge fix
sql/sql_acl.cc:
After merge fix + code cleanup
sql/sql_select.cc:
After merge fix
sql/sql_show.cc:
After merge fix
sql/sql_table.cc:
After merge fix
Cleanup of mysql_checksum_table()
sql/sql_union.cc:
After merge fixes.
Note that after this the union test still fails; Will be fixed shortly...
tests/client_test.c:
mysql_prepare_result() -> mysql_get_metadata()
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.h | 7 | ||||
-rw-r--r-- | sql/ha_innodb.cc | 95 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 2 | ||||
-rw-r--r-- | sql/log_event.cc | 25 | ||||
-rw-r--r-- | sql/opt_range.cc | 9 | ||||
-rw-r--r-- | sql/slave.cc | 1 | ||||
-rw-r--r-- | sql/sql_acl.cc | 73 | ||||
-rw-r--r-- | sql/sql_select.cc | 1 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 46 | ||||
-rw-r--r-- | sql/sql_union.cc | 27 |
11 files changed, 83 insertions, 205 deletions
diff --git a/sql/field.h b/sql/field.h index 10d3e671867..fe5141e9d80 100644 --- a/sql/field.h +++ b/sql/field.h @@ -125,6 +125,13 @@ public: { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : table->null_row; } inline bool is_real_null(uint row_offset=0) { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : 0; } + inline bool is_null_in_record(const uchar *record) + { + if (!null_ptr) + return 0; + return test(record[(uint) (null_ptr - (uchar*) table->record[0])] & + null_bit); + } inline void set_null(int row_offset=0) { if (null_ptr) null_ptr[row_offset]|= null_bit; } inline void set_notnull(int row_offset=0) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index bcdb01da9ca..017151dfca0 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1540,82 +1540,6 @@ ha_innobase::close(void) DBUG_RETURN(0); } -/* The following accessor functions should really be inside MySQL code! */ - -/****************************************************************** -Gets field offset for a field in a table. */ -inline -uint -get_field_offset( -/*=============*/ - /* out: offset */ - TABLE* table, /* in: MySQL table object */ - Field* field) /* in: MySQL field object */ -{ - return((uint) (field->ptr - (char*) table->record[0])); -} - -/****************************************************************** -Checks if a field in a record is SQL NULL. Uses the record format -information in table to track the null bit in record. */ -inline -uint -field_in_record_is_null( -/*====================*/ - /* out: 1 if NULL, 0 otherwise */ - TABLE* table, /* in: MySQL table object */ - Field* field, /* in: MySQL field object */ - char* record) /* in: a row in MySQL format */ -{ - int null_offset; - - if (!field->null_ptr) { - - return(0); - } - - null_offset = (uint) ((char*) field->null_ptr - - (char*) table->record[0]); - - if (record[null_offset] & field->null_bit) { - - return(1); - } - - return(0); -} - -/****************************************************************** -Sets a field in a record to SQL NULL. Uses the record format -information in table to track the null bit in record. */ -inline -void -set_field_in_record_to_null( -/*========================*/ - TABLE* table, /* in: MySQL table object */ - Field* field, /* in: MySQL field object */ - char* record) /* in: a row in MySQL format */ -{ - int null_offset; - - null_offset = (uint) ((char*) field->null_ptr - - (char*) table->record[0]); - - record[null_offset] = record[null_offset] | field->null_bit; -} - -/****************************************************************** -Resets SQL NULL bits in a record to zero. */ -inline -void -reset_null_bits( -/*============*/ - TABLE* table, /* in: MySQL table object */ - char* record) /* in: a row in MySQL format */ -{ - bzero(record, table->null_bytes); -} - extern "C" { /***************************************************************** InnoDB uses this function is to compare two data fields for which the @@ -1825,11 +1749,10 @@ ha_innobase::store_key_val_for_row( blob_data = row_mysql_read_blob_ref(&blob_len, (byte*) (record - + (ulint)get_field_offset(table, field)), + + (ulint) field->offset()), (ulint) field->pack_length()); - ut_a(get_field_offset(table, field) - == key_part->offset); + ut_a(field->offset() == key_part->offset); if (blob_len > key_part->length) { blob_len = key_part->length; } @@ -2009,9 +1932,7 @@ build_template( templ->mysql_null_bit_mask = 0; } - templ->mysql_col_offset = (ulint) - get_field_offset(table, field); - + templ->mysql_col_offset = (ulint) field->offset(); templ->mysql_col_len = (ulint) field->pack_length(); templ->type = get_innobase_type_from_mysql_type(field); templ->is_unsigned = (ulint) (field->flags & UNSIGNED_FLAG); @@ -2348,8 +2269,8 @@ calc_row_difference( /* goto skip_field; }*/ - o_ptr = (byte*) old_row + get_field_offset(table, field); - n_ptr = (byte*) new_row + get_field_offset(table, field); + o_ptr = (byte*) old_row + field->offset(); + n_ptr = (byte*) new_row + field->offset(); o_len = field->pack_length(); n_len = field->pack_length(); @@ -2374,13 +2295,11 @@ calc_row_difference( } if (field->null_ptr) { - if (field_in_record_is_null(table, field, - (char*) old_row)) { + if (field->is_null_in_record((uchar*) old_row)) { o_len = UNIV_SQL_NULL; } - if (field_in_record_is_null(table, field, - (char*) new_row)) { + if (field->is_null_in_record((uchar*) new_row)) { n_len = UNIV_SQL_NULL; } } diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 09b92d7df40..c36b8dcc9d8 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1459,7 +1459,7 @@ void Item_func_in::fix_length_and_dec() DBUG_ASSERT(0); return; } - if (array && !(current_thd->fatal_error)) // If not EOM + if (array && !(current_thd->is_fatal_error)) // If not EOM { uint j=0; for (uint i=1 ; i < arg_count ; i++) diff --git a/sql/log_event.cc b/sql/log_event.cc index 48c2000d11b..91349feec39 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -913,18 +913,6 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) mysql_parse(thd, thd->query, q_len); /* - Set a flag if we are inside an transaction so that we can restart - the transaction from the start if we are killed - - This will only be done if we are supporting transactional tables - in the slave. - */ - if (!strcmp(thd->query,"BEGIN")) - rli->inside_transaction= opt_using_transactions; - else if (!(strcmp(thd->query,"COMMIT") && strcmp(thd->query,"ROLLBACK"))) - rli->inside_transaction=0; - - /* If we expected a non-zero error code, and we don't get the same error code, and none of them should be ignored. */ @@ -1771,7 +1759,7 @@ Fatal error running LOAD DATA INFILE on table '%s'. Default database: '%s'", void Rotate_log_event::pack_info(Protocol *protocol) { char buf1[256], buf[22]; - String tmp(buf1, sizeof(buf1)); + String tmp(buf1, sizeof(buf1), log_cs); tmp.length(0); tmp.append(new_log_ident, ident_len); tmp.append(";pos="); @@ -1896,16 +1884,19 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli) pthread_mutex_lock(&rli->data_lock); +#ifdef TO_BE_CHECKED_BY_GUILHEM if (rli->inside_transaction) { slave_print_error(rli, 0, - "there is an unfinished transaction in the relay log \ -(could find neither COMMIT nor ROLLBACK in the relay log); it could be that \ -the master died while writing the transaction to its binary log. Now the slave \ -is rolling back the transaction."); + "\ +There is an unfinished transaction in the relay log (could find neither \ +COMMIT nor ROLLBACK in the relay log); It could be that the master died while \ +writing the transaction to its binary log. Now the slave is rolling back the \ +transaction."); pthread_mutex_unlock(&rli->data_lock); DBUG_RETURN(1); } +#endif memcpy(log_name, new_log_ident, ident_len+1); rli->group_master_log_pos = pos; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 947c930b2f4..5a883ce8b2c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -618,6 +618,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables, SEL_TREE *tree; KEY_PART *key_parts; PARAM param; + THD *thd= current_thd; /* set up parameter that is passed to all functions */ param.baseflag=basflag; @@ -628,13 +629,13 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables, param.keys=0; param.mem_root= &alloc; - current_thd->no_errors=1; // Don't warn about NULL + thd->no_errors=1; // Don't warn about NULL init_sql_alloc(&alloc,2048,0); if (!(param.key_parts = (KEY_PART*) alloc_root(&alloc, sizeof(KEY_PART)* head->key_parts))) { - current_thd->no_errors=0; + thd->no_errors=0; free_root(&alloc,MYF(0)); // Return memory & allocator DBUG_RETURN(0); // Can't use range } @@ -736,7 +737,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables, } free_root(&alloc,MYF(0)); // Return memory & allocator my_pthread_setspecific_ptr(THR_MALLOC,old_root); - current_thd->no_errors=0; + thd->no_errors=0; } DBUG_EXECUTE("info",print_quick(quick,needed_reg);); /* @@ -764,7 +765,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) while ((item=li++)) { SEL_TREE *new_tree=get_mm_tree(param,item); - if(current_thd->fatal_error) + if (current_thd->is_fatal_error) DBUG_RETURN(0); // out of memory tree=tree_and(param,tree,new_tree); if (tree && tree->type == SEL_TREE::IMPOSSIBLE) diff --git a/sql/slave.cc b/sql/slave.cc index 531b7897d83..0c8db2fe6cc 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2963,7 +2963,6 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ restarts replication from a non-transactional statement (with CHANGE MASTER). */ - rli->inside_transaction= 0; /* Wake up master_pos_wait() */ pthread_mutex_unlock(&rli->data_lock); DBUG_PRINT("info",("Signaling possibly waiting master_pos_wait() functions")); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 60353d23c16..6f588427ede 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -532,36 +532,13 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b) /* - Prepare crypted scramble to be sent to the client -*/ - -void prepare_scramble(THD *thd, ACL_USER *acl_user,char* prepared_scramble) -{ - /* Binary password format to be used for generation*/ - char bin_password[SCRAMBLE41_LENGTH]; - /* Generate new long scramble for the thread */ - create_random_string(SCRAMBLE41_LENGTH,&thd->rand,thd->scramble); - thd->scramble[SCRAMBLE41_LENGTH]=0; - /* Get binary form, First 4 bytes of prepared scramble is salt */ - get_hash_and_password(acl_user->salt,acl_user->pversion,prepared_scramble, - (unsigned char*) bin_password); - /* Store "*" as identifier for old passwords */ - if (!acl_user->pversion) - prepared_scramble[0]='*'; - /* Finally encrypt password to get prepared scramble */ - password_crypt(thd->scramble, prepared_scramble+4, bin_password, - SCRAMBLE41_LENGTH); -} - + Seek ACL entry for a user, check password, SSL cypher, and if + everything is OK, update THD user data and USER_RESOURCES struct. -/* - Seek ACL entry for a user, check password, SSL cypher, and if - everything is OK, update THD user data and USER_RESOURCES struct. - - IMPLEMENTATION - This function does not check if the user has any sensible privileges: - only user's existence and validity is checked. - Note, that entire operation is protected by acl_cache_lock. + IMPLEMENTATION + This function does not check if the user has any sensible privileges: + only user's existence and validity is checked. + Note, that entire operation is protected by acl_cache_lock. SYNOPSIS acl_getroot() @@ -578,7 +555,7 @@ void prepare_scramble(THD *thd, ACL_USER *acl_user,char* prepared_scramble) SCRAMBLE_LENGTH_323, SCRAMBLE_LENGTH 'thd' and 'mqh' are updated on success; other params are IN. - RETURN VALUE + RETURN VALUE 0 success: thd->priv_user, thd->priv_host, thd->master_access, mqh are updated 1 user not found or authentification failure @@ -616,29 +593,29 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, for (uint i=0 ; i < acl_users.elements ; i++) { - ACL_USER *acl_user= dynamic_element(&acl_users,i,ACL_USER*); - if (!acl_user->user || !strcmp(thd->user, acl_user->user)) + ACL_USER *acl_user_tmp= dynamic_element(&acl_users,i,ACL_USER*); + if (!acl_user_tmp->user || !strcmp(thd->user, acl_user_tmp->user)) { - if (compare_hostname(&acl_user->host, thd->host, thd->ip)) + if (compare_hostname(&acl_user_tmp->host, thd->host, thd->ip)) { /* check password: it should be empty or valid */ - if (passwd_len == acl_user->salt_len) + if (passwd_len == acl_user_tmp->salt_len) { - if (acl_user->salt_len == 0 || - acl_user->salt_len == SCRAMBLE_LENGTH && - check_scramble(passwd, thd->scramble, acl_user->salt) == 0 || + if (acl_user_tmp->salt_len == 0 || + acl_user_tmp->salt_len == SCRAMBLE_LENGTH && + check_scramble(passwd, thd->scramble, acl_user_tmp->salt) == 0 || check_scramble_323(passwd, thd->scramble, - (ulong *) acl_user->salt) == 0) + (ulong *) acl_user_tmp->salt) == 0) { - acl_user= acl_user; + acl_user= acl_user_tmp; res= 0; } } else if (passwd_len == SCRAMBLE_LENGTH && - acl_user->salt_len == SCRAMBLE_LENGTH_323) + acl_user_tmp->salt_len == SCRAMBLE_LENGTH_323) res= -1; else if (passwd_len == SCRAMBLE_LENGTH_323 && - acl_user->salt_len == SCRAMBLE_LENGTH) + acl_user_tmp->salt_len == SCRAMBLE_LENGTH) res= 2; /* linear search complete: */ break; @@ -2472,7 +2449,7 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, { my_printf_error(ER_WRONG_USAGE, ER(ER_WRONG_USAGE), MYF(0), "DB GRANT","GLOBAL PRIVILEGES"); - result= 1; + result= -1; } } } @@ -3113,7 +3090,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) protocol->store(global.ptr(),global.length(),global.charset()); if (protocol->write()) { - error=-1; + error= -1; goto end; } } @@ -3171,7 +3148,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) protocol->store(db.ptr(),db.length(),db.charset()); if (protocol->write()) { - error=-1; + error= -1; goto end; } } @@ -3421,7 +3398,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) { if (!(acl_user= check_acl_user(user_name, &counter))) { - sql_print_error("DROP USER: Can't drop user: '%s'@'%s'", + sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; No such user", user_name->user.str, user_name->host.str); result= -1; @@ -3429,7 +3406,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) } if ((acl_user->access & ~0)) { - sql_print_error("DROP USER: Can't drop user: '%s'@'%s'", + sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Global privileges exists", user_name->user.str, user_name->host.str); result= -1; @@ -3452,7 +3429,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) } if (counter != acl_dbs.elements) { - sql_print_error("DROP USER: Can't drop user: '%s'@'%s'", + sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Database privileges exists", user_name->user.str, user_name->host.str); result= -1; @@ -3475,7 +3452,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) } if (counter != column_priv_hash.records) { - sql_print_error("DROP USER: Can't drop user: '%s'@'%s'", + sql_print_error("DROP USER: Can't drop user: '%s'@'%s'; Table privileges exists", user_name->user.str, user_name->host.str); result= -1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 080e25cc7eb..eac4007d9fc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1414,6 +1414,7 @@ JOIN::exec() curr_join->group_list : curr_join->order, curr_join->select_limit, unit->select_limit_cnt)) DBUG_VOID_RETURN; + } } curr_join->having= curr_join->tmp_having; thd->proc_info="Sending data"; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0e1ad17c252..685d00db391 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1035,7 +1035,7 @@ static void append_directory(THD *thd, String *packet, const char *dir_type, const char *filename) { uint length; - if (filename && !(thd->sql_mode & MODE_NO_DIR_IN_CREATE)) + if (filename && !(thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)) { length= dirname_length(filename); packet->append(' '); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0a2821e02e3..af1cb634ed7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -916,7 +916,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, thd->proc_info="creating table"; - if (thd->sql_mode & MODE_NO_DIR_IN_CREATE) + if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE) create_info->data_file_name= create_info->index_file_name= 0; create_info->table_options=db_options; @@ -2597,7 +2597,8 @@ copy_data_between_tables(TABLE *from,TABLE *to, DBUG_RETURN(error > 0 ? -1 : 0); } -int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt) + +int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) { TABLE_LIST *table; List<Item> field_list; @@ -2612,24 +2613,23 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt) if (protocol->send_fields(&field_list, 1)) DBUG_RETURN(-1); - for (table = tables; table; table = table->next) + for (table= tables; table; table= table->next) { char table_name[NAME_LEN*2+2]; - char* db = (table->db) ? table->db : thd->db; - bool fatal_error=0; + bool fatal_error= 0; TABLE *t; - strxmov(table_name,db ? db : "",".",table->real_name,NullS); - t=table->table = open_ltable(thd, table, TL_READ_NO_INSERT); -#ifdef EMBEDDED_LIBRARY - thd->net.last_errno= 0; // these errors shouldn't get client -#endif + strxmov(table_name, table->db ,".", table->real_name, NullS); + + t= table->table= open_ltable(thd, table, TL_READ_NO_INSERT); + thd->clear_error(); // these errors shouldn't get client protocol->prepare_for_resend(); protocol->store(table_name, system_charset_info); if (!t) { + /* Table didn't exist */ protocol->store_null(); thd->net.last_error[0]=0; } @@ -2641,45 +2641,42 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt) !(check_opt->flags & T_EXTEND)) protocol->store((ulonglong)t->file->checksum()); else if (!(t->file->table_flags() & HA_HAS_CHECKSUM) && - check_opt->flags & T_QUICK) + (check_opt->flags & T_QUICK)) protocol->store_null(); else { /* calculating table's checksum */ - ha_checksum crc=0; + ha_checksum crc= 0; if (t->file->rnd_init(1)) protocol->store_null(); else { while (!t->file->rnd_next(t->record[0])) { - ha_checksum row_crc=0; + ha_checksum row_crc= 0; if (t->record[0] != t->field[0]->ptr) - row_crc=my_checksum(row_crc, t->record[0], - t->field[0]->ptr - t->record[0]); + row_crc= my_checksum(row_crc, t->record[0], + t->field[0]->ptr - t->record[0]); - for (uint i=0; i < t->fields; i++ ) + for (uint i= 0; i < t->fields; i++ ) { - Field *f=t->field[i]; + Field *f= t->field[i]; if (f->type() == FIELD_TYPE_BLOB) { String tmp; f->val_str(&tmp,&tmp); - row_crc=my_checksum(row_crc, tmp.ptr(), tmp.length()); + row_crc= my_checksum(row_crc, tmp.ptr(), tmp.length()); } else - row_crc=my_checksum(row_crc, f->ptr, f->pack_length()); + row_crc= my_checksum(row_crc, f->ptr, f->pack_length()); } - crc+=row_crc; + crc+= row_crc; } protocol->store((ulonglong)crc); } } -#ifdef EMBEDDED_LIBRARY - thd->net.last_errno= 0; // these errors shouldn't get client -#endif - + thd->clear_error(); close_thread_tables(thd); table->table=0; // For query cache } @@ -2689,6 +2686,7 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt) send_eof(thd); DBUG_RETURN(0); + err: close_thread_tables(thd); // Shouldn't be needed if (table) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 7146630d132..381311b4975 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -262,23 +262,8 @@ int st_select_lex_unit::exec() res= sl->join->reinit(); else { - /* Don't use offset for the last union if there is no braces */ - if (sl != lex_sl) - { - offset_limit_cnt= sl->offset_limit; - select_limit_cnt= sl->select_limit+sl->offset_limit; - } - else - { - offset_limit_cnt= 0; - /* - We can't use LIMIT at this stage if we are using ORDER BY for the - whole query - */ - select_limit_cnt= HA_POS_ERROR; - if (! sl->order_list.first) - select_limit_cnt= sl->select_limit+sl->offset_limit; - } + offset_limit_cnt= sl->offset_limit; + select_limit_cnt= sl->select_limit+sl->offset_limit; if (select_limit_cnt < sl->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit @@ -297,10 +282,10 @@ int st_select_lex_unit::exec() sl->options|= found_rows_for_union; } - /* - As far as union share table space we should reassign table map, - which can be spoiled by 'prepare' of JOIN of other UNION parts - if it use same tables + /* + As far as union share table space we should reassign table map, + which can be spoiled by 'prepare' of JOIN of other UNION parts + if it use same tables */ uint tablenr=0; for (TABLE_LIST *table_list= (TABLE_LIST*) sl->table_list.first; |