From ca0defad77340f630a56f6c75da574cb1c2269e0 Mon Sep 17 00:00:00 2001 From: "ram@mysql.r18.ru" <> Date: Thu, 19 Dec 2002 12:38:32 +0400 Subject: patches from sleepycat.com have been applied (SCRUM) ha_berkeley::rename_table() has been added (SCRUM) --- sql/ha_berkeley.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sql/ha_berkeley.cc') diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 1b8a2d9b3f8..adc2e0db195 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -1940,6 +1940,24 @@ int ha_berkeley::delete_table(const char *name) DBUG_RETURN(error); } + +int ha_berkeley::rename_table(const char * from, const char * to) +{ + int error; + char from_buff[FN_REFLEN]; + char to_buff[FN_REFLEN]; + + if ((error= db_create(&file, db_env, 0))) + my_errno= error; + else + error= file->rename(file, + fn_format(from_buff, from, "", ha_berkeley_ext, 2 | 4), + NULL, fn_format(to_buff, to, "", ha_berkeley_ext, + 2 | 4), 0); + return error; +} + + /* How many seeks it will take to read through the table This is to be comparable to the number returned by records_in_range so -- cgit v1.2.1 From 9ecf9645ebab531ce5aa29514b6b9457968f9946 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Sun, 5 Jan 2003 20:18:49 +0200 Subject: A lot of portability fixes. Added rename table for BDB. This fixes a bug in ALTER TABLE with BDB tables. --- sql/ha_berkeley.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'sql/ha_berkeley.cc') diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 06acf4fa2e3..2154fbd7a32 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -1921,6 +1921,26 @@ int ha_berkeley::delete_table(const char *name) DBUG_RETURN(error); } +int ha_berkeley::rename_table(const char * from, const char * to) +{ + int error; + char from_buff[FN_REFLEN]; + char to_buff[FN_REFLEN]; + + if ((error= db_create(&file, db_env, 0))) + my_errno= error; + else + { + /* On should not do a file->close() after rename returns */ + error= file->rename(file, + fn_format(from_buff, from, "", ha_berkeley_ext, 2 | 4), + NULL, fn_format(to_buff, to, "", ha_berkeley_ext, + 2 | 4), 0); + } + return error; +} + + /* How many seeks it will take to read through the table This is to be comparable to the number returned by records_in_range so @@ -2080,7 +2100,7 @@ int ha_berkeley::analyze(THD* thd, HA_CHECK_OPT* check_opt) free(stat); stat=0; } - if (key_file[i]->stat(key_file[i], (void*) &stat, 0, 0)) + if ((key_file[i]->stat)(key_file[i], (void*) &stat, 0, 0)) goto err; /* purecov: inspected */ share->rec_per_key[i]= (stat->bt_ndata / (stat->bt_nkeys ? stat->bt_nkeys : 1)); @@ -2093,7 +2113,7 @@ int ha_berkeley::analyze(THD* thd, HA_CHECK_OPT* check_opt) free(stat); stat=0; } - if (file->stat(file, (void*) &stat, 0, 0)) + if ((file->stat)(file, (void*) &stat, 0, 0)) goto err; /* purecov: inspected */ } pthread_mutex_lock(&share->mutex); -- cgit v1.2.1 From 1f6ecc0cd3d9acf4751ebbbf8db8b6ee468d3abf Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Mon, 6 Jan 2003 01:48:59 +0200 Subject: Changed mysql-test to print warnings for not existing table to DROP TABLE Cleaned up test; Removed wrong DROP TABLE commands and use standard table and database names. changed store_warning() -> push_warning_print() --- sql/ha_berkeley.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sql/ha_berkeley.cc') diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index adc2e0db195..5d57e9cdf9b 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -512,7 +512,8 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) file->app_private= (void*) (table->key_info+table->primary_key); if ((error= txn_begin(db_env, 0, (DB_TXN**) &transaction, 0)) || (error= (file->open(file, transaction, - fn_format(name_buff, name, "", ha_berkeley_ext, 2 | 4), + fn_format(name_buff, name, "", ha_berkeley_ext, + 2 | 4), "main", DB_BTREE, open_mode, 0))) || (error= transaction->commit(transaction, 0))) { @@ -1950,10 +1951,13 @@ int ha_berkeley::rename_table(const char * from, const char * to) if ((error= db_create(&file, db_env, 0))) my_errno= error; else + { + /* On should not do a file->close() after rename returns */ error= file->rename(file, fn_format(from_buff, from, "", ha_berkeley_ext, 2 | 4), NULL, fn_format(to_buff, to, "", ha_berkeley_ext, 2 | 4), 0); + } return error; } -- cgit v1.2.1