summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-01-23 02:52:26 +0200
committerunknown <monty@hundin.mysql.fi>2002-01-23 02:52:26 +0200
commit7b72c14bbb857834ec81091eabc846774d35ab96 (patch)
treebe3a98f50b40e6cfe7dd9ac0bfb602ada79dcc02 /sql/handler.cc
parent879e892d661b0236850b0c5b0adf87a1bb3d507a (diff)
downloadmariadb-git-7b72c14bbb857834ec81091eabc846774d35ab96.tar.gz
Increase max package length to 512M for mysql and mysqldump.
Faster 'read_first_row' (Fixes slow 'preparing' state) Read constant tables earlier, which provides better optimzations when using tables with <=1 row. This also fixes a complicated bug involving const tables. Docs/manual.texi: Changelog client/mysql.cc: Increase max package length to 512M client/mysqldump.c: Increase max package length to 512M dbug/dbug.c: Fixed wrong printf() format string. mysql-test/t/innodb.test: Test for multi-table delete sql/handler.cc: Faster 'read_first_row' (Fixes slow 'preparing' state) sql/handler.h: Faster 'read_first_row' (Fixes slow 'preparing' state) sql/opt_range.cc: More debug info. sql/sql_select.cc: Read constant tables earlier, which provides better optimzations when using tables with <=1 row. This also fixes a complicated bug involving const tables. sql/sql_select.h: Read const tables earlier
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc40
1 files changed, 30 insertions, 10 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index e56bdb916bf..58f8192cf22 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -472,17 +472,36 @@ int handler::analyze(THD* thd, HA_CHECK_OPT* check_opt)
return HA_ADMIN_NOT_IMPLEMENTED;
}
- /* Read first row from a table */
+/*
+ Read first row (only) from a table
+ This is never called for InnoDB or BDB tables, as these table types
+ has the HA_NOT_EXACT_COUNT set.
+*/
-int handler::rnd_first(byte * buf)
+int handler::read_first_row(byte * buf, uint primary_key)
{
register int error;
- DBUG_ENTER("handler::rnd_first");
+ DBUG_ENTER("handler::read_first_row");
statistic_increment(ha_read_first_count,&LOCK_status);
- (void) rnd_init();
- while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
- (void) rnd_end();
+
+ /*
+ If there is very few deleted rows in the table, find the first row by
+ scanning the table.
+ */
+ if (deleted < 10 || primary_key >= MAX_KEY)
+ {
+ (void) rnd_init();
+ while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
+ (void) rnd_end();
+ }
+ else
+ {
+ /* Find the first row through the primary key */
+ (void) index_init(primary_key);
+ error=index_first(buf);
+ (void) index_end();
+ }
DBUG_RETURN(error);
}
@@ -498,7 +517,7 @@ int handler::restart_rnd_next(byte *buf, byte *pos)
}
- /* Set a timestamp in record */
+/* Set a timestamp in record */
void handler::update_timestamp(byte *record)
{
@@ -514,9 +533,10 @@ void handler::update_timestamp(byte *record)
return;
}
- /* Updates field with field_type NEXT_NUMBER according to following:
- ** if field = 0 change field to the next free key in database.
- */
+/*
+ Updates field with field_type NEXT_NUMBER according to following:
+ if field = 0 change field to the next free key in database.
+*/
void handler::update_auto_increment()
{