diff options
author | unknown <monty@hundin.mysql.fi> | 2001-06-25 11:35:22 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-06-25 11:35:22 +0300 |
commit | 4d5dcac35ea0fc25632d17657b3f42af41bd2c7d (patch) | |
tree | c5dedde5af42a65776a3a0d1d3b949cad43a0d59 /sql | |
parent | 157c1bc5f948995697ca96fb100ea1657c7952c9 (diff) | |
download | mariadb-git-4d5dcac35ea0fc25632d17657b3f42af41bd2c7d.tar.gz |
Fixed bug when sorting big files (introduced with multi-table-delete)
Changed mysql-test to use --language
Cleaned up parameters to filesort()
configure.in:
Fixed typo
mysql-test/install_test_db.sh:
Changed test case to use --language
mysql-test/mysql-test-run.sh:
Changed test case to use --language
Fixed that test names are not 'cut'-ed.
mysql-test/r/select_found.result:
Fixed test case to make it repeatable
mysql-test/t/insert.test:
Added test of unique key handling
mysql-test/t/order_fill_sortbuf.test:
Cleaned up test
mysql-test/t/select_found.test:
Fixed test case to make it repeatable
sql/filesort.cc:
Fixed bug when sorting big files (introduced with multi-table-delete)
cleaned up parameters.
sql/mysql_priv.h:
Cleaned up parameters to filesort()
sql/mysqld.cc:
Fixed typo on enum
sql/sql_delete.cc:
Cleanup
sql/sql_select.cc:
Cleanup
sql/sql_table.cc:
Cleanup
sql/sql_test.cc:
Cleanup
sql/sql_update.cc:
Cleanup
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 32 | ||||
-rw-r--r-- | sql/mysql_priv.h | 5 | ||||
-rw-r--r-- | sql/mysqld.cc | 6 | ||||
-rw-r--r-- | sql/sql_delete.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 4 | ||||
-rw-r--r-- | sql/sql_test.cc | 3 | ||||
-rw-r--r-- | sql/sql_update.cc | 2 |
8 files changed, 32 insertions, 26 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 18bdc8e86d8..fe06d3eb9b6 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -53,11 +53,19 @@ static int merge_index(SORTPARAM *param,uchar *sort_buffer, static bool save_index(SORTPARAM *param,uchar **sort_keys, uint count); static uint sortlength(SORT_FIELD *sortorder,uint length); - /* Makes a indexfil of recordnumbers of a sorted database */ - /* outfile is reset before data is written to it, if it wasn't - open a new file is opened */ + /* + Creates a set of pointers that can be used to read the rows + in sorted order. This should be done with the functions + in records.cc -ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, + Before calling filesort, one must have done + table->file->info(HA_STATUS_VARIABLE) + + The result set is stored in table->io_cache or + table->record_pointers + */ + +ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length, SQL_SELECT *select, ha_rows special, ha_rows max_rows, ha_rows *examined_rows) { @@ -69,19 +77,20 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, IO_CACHE tempfile,*selected_records_file,*outfile; SORTPARAM param; DBUG_ENTER("filesort"); - DBUG_EXECUTE("info",TEST_filesort(table,sortorder,s_length,special);); + DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length,special);); #ifdef SKIPP_DBUG_IN_FILESORT DBUG_PUSH(""); /* No DBUG here */ #endif - outfile= table[0]->io_cache; + outfile= table->io_cache; my_b_clear(&tempfile); buffpek= (BUFFPEK *) NULL; sort_keys= (uchar **) NULL; error= 1; maxbuffer=1; - param.ref_length= table[0]->file->ref_length; + param.ref_length= table->file->ref_length; param.sort_length=sortlength(sortorder,s_length)+ param.ref_length; param.max_rows= max_rows; param.examined_rows=0; + param.unique_buff=0; if (select && select->quick) { @@ -106,17 +115,14 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, #ifdef CAN_TRUST_RANGE else if (select && select->quick && select->quick->records > 0L) { - /* Get record-count */ - table[0]->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2), - table[0]->file->records)+EXTRA_RECORDS; + table->file->records)+EXTRA_RECORDS; selected_records_file=0; } #endif else { - table[0]->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);/* Get record-count */ - records=table[0]->file->estimate_number_of_rows(); + records=table->file->estimate_number_of_rows(); selected_records_file= 0; } if (param.sort_length == param.ref_length && records > param.max_rows) @@ -170,7 +176,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length, my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),sortbuff_size); goto err; } - param.sort_form= table[0]; + param.sort_form= table; param.end=(param.local_sortorder=sortorder)+s_length; if ((records=find_all_keys(¶m,select,sort_keys,buffpek,&maxbuffer, &tempfile, selected_records_file)) == diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 07c73aa37a9..63c9478d236 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -475,8 +475,7 @@ pthread_handler_decl(handle_manager, arg); #ifndef DBUG_OFF void print_where(COND *cond,const char *info); void print_cached_tables(void); -void TEST_filesort(TABLE **form,SORT_FIELD *sortorder,uint s_length, - ha_rows special); +void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special); #endif void mysql_print_status(THD *thd); /* key.cc */ @@ -618,7 +617,7 @@ void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form, SQL_SELECT *select, int use_record_cache, bool print_errors); void end_read_record(READ_RECORD *info); -ha_rows filesort(TABLE **form,struct st_sort_field *sortorder, uint s_length, +ha_rows filesort(TABLE *form,struct st_sort_field *sortorder, uint s_length, SQL_SELECT *select, ha_rows special,ha_rows max_rows, ha_rows *examined_rows); void change_double_for_sort(double nr,byte *to); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c86ed19092c..7c40b5f15ef 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2479,7 +2479,7 @@ enum options { OPT_INNODB_LOG_ARCH_DIR, OPT_INNODB_LOG_ARCHIVE, OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, - OPT_innodb_flush_method, + OPT_INNODB_FLUSH_METHOD, OPT_SAFE_SHOW_DB, OPT_GEMINI_SKIP, OPT_INNODB_SKIP, OPT_TEMP_POOL, OPT_DO_PSTACK, OPT_TX_ISOLATION, @@ -2545,7 +2545,7 @@ static struct option long_options[] = { {"innodb_flush_log_at_trx_commit", optional_argument, 0, OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT}, {"innodb_flush_method", required_argument, 0, - OPT_INNODB_UNIX_FILE_FLUSH_METHOD}, + OPT_INNODB_FLUSH_METHOD}, #endif {"help", no_argument, 0, '?'}, {"init-file", required_argument, 0, (int) OPT_INIT_FILE}, @@ -3703,7 +3703,7 @@ static void get_options(int argc,char **argv) case OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT: innobase_flush_log_at_trx_commit= optarg ? test(atoi(optarg)) : 1; break; - case OPT_INNODB_UNIX_FILE_FLUSH_METHOD: + case OPT_INNODB_FLUSH_METHOD: innobase_unix_file_flush_method=optarg; break; #endif /* HAVE_INNOBASE_DB */ diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index dc07d81f8f2..b690ef4b327 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -214,7 +214,7 @@ int mysql_delete(THD *thd, MYF(MY_FAE | MY_ZEROFILL)); if (setup_order(thd, &tables, fields, all_fields, order) || !(sortorder=make_unireg_sortorder(order, &length)) || - (table->found_records = filesort(&table, sortorder, length, + (table->found_records = filesort(table, sortorder, length, (SQL_SELECT *) 0, 0L, HA_POS_ERROR, &examined_rows)) == HA_POS_ERROR) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4a033f3e6ad..bb1e72d943f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5334,7 +5334,9 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit) goto err; } } - table->found_records=filesort(&table,sortorder,length, + if (table->tmp_table) + table->file->info(HA_STATUS_VARIABLE); // Get record count + table->found_records=filesort(table,sortorder,length, select, 0L, select_limit, &examined_rows); delete select; // filesort did select tab->select=0; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3988a823e83..b755a4d6327 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1755,8 +1755,8 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (setup_order(thd, &tables, fields, all_fields, order) || !(sortorder=make_unireg_sortorder(order, &length)) || - (from->found_records = filesort(&from, sortorder, length, - (SQL_SELECT *) 0, 0L, HA_POS_ERROR, + (from->found_records = filesort(from, sortorder, length, + (SQL_SELECT *) 0, 0L, HA_POS_ERROR, &examined_rows)) == HA_POS_ERROR) goto err; diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 3edfdd3d5ef..d20bc74ecb2 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -96,8 +96,7 @@ void print_cached_tables(void) } -void TEST_filesort(TABLE **table,SORT_FIELD *sortorder,uint s_length, - ha_rows special) +void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special) { char buff[256],buff2[256]; String str(buff,sizeof(buff)),out(buff2,sizeof(buff2)); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index bdcc6c00b19..a6ded7cef9c 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -184,7 +184,7 @@ int mysql_update(THD *thd, MYF(MY_FAE | MY_ZEROFILL)); if (setup_order(thd, &tables, fields, all_fields, order) || !(sortorder=make_unireg_sortorder(order, &length)) || - (table->found_records = filesort(&table, sortorder, length, + (table->found_records = filesort(table, sortorder, length, (SQL_SELECT *) 0, 0L, HA_POS_ERROR, &examined_rows)) == HA_POS_ERROR) |