summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-09-03 05:16:15 +0300
committerunknown <monty@hundin.mysql.fi>2001-09-03 05:16:15 +0300
commit5160501770aafc0b2b9ee287e5a8b7627b1b51bb (patch)
treee5faac23f2977c577bc7fac42a2b90e5f53f2855 /sql
parentb4a417109c16fcb15c2ad050ba156f1bdf099e5e (diff)
downloadmariadb-git-5160501770aafc0b2b9ee287e5a8b7627b1b51bb.tar.gz
Update of manual with 4.0 changes
Create innodb table space if configuring with InnoDB and not using --skip-innodb Fixes for TRUNCATE TABLE and DROP DATABASE. Docs/manual.texi: Update of manual with 4.0 changes. mysql-test/mysql-test-run.sh: Fixed option --mysqld mysql-test/r/innodb.result: More test cases mysql-test/r/truncate.result: More test cases mysql-test/t/drop.test: More test cases mysql-test/t/innodb.test: More test cases mysql-test/t/truncate.test: More test cases sql/gen_lex_hash.cc: Smaller array sql/ha_innobase.cc: Create innodb table space if not using --skip-innodb sql/lock.cc: Fixed wrong mutex handling in global read lock. sql/md5.c: Fixed bug from merge sql/sql_base.cc: cleanup sql/sql_db.cc: Use new global lock functions. Fixed new bug that database wasn't always dropped. sql/sql_delete.cc: Fixed problem with mysql_truncate() when called from restore_table sql/sql_parse.cc: Fixed error message handling. sql/sql_table.cc: cleanup
Diffstat (limited to 'sql')
-rw-r--r--sql/gen_lex_hash.cc2
-rw-r--r--sql/ha_innobase.cc4
-rw-r--r--sql/lock.cc11
-rw-r--r--sql/md5.c5
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_db.cc53
-rw-r--r--sql/sql_delete.cc27
-rw-r--r--sql/sql_parse.cc21
-rw-r--r--sql/sql_table.cc1
9 files changed, 66 insertions, 60 deletions
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index e05fdafcbc4..b6621a056a5 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -472,7 +472,7 @@ int main(int argc,char **argv)
int error;
MY_INIT(argv[0]);
- start_value=6130115L; best_t1=3632784L; best_t2=86437L; best_type=3; /* mode=4229 add=2 type: 0 */
+ start_value=3579077L; best_t1=6681742L; best_t2=142815L; best_type=3; /* mode=5167 add=7 type: 0 */
if (get_options(argc,(char **) argv))
exit(1);
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 5920ce86116..5287c228637 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -92,7 +92,7 @@ bool innobase_flush_log_at_trx_commit, innobase_log_archive,
to specify any startup options.
*/
-char *innobase_data_file_path= (char*) "ibdata:64M";
+char *innobase_data_file_path= (char*) "ibdata1:64M";
/* The following counter is used to convey information to InnoDB
about server activity: in selects it is not sensible to call
@@ -1915,7 +1915,7 @@ ha_innobase::change_active_index(
build_template(prebuilt, user_thd, table, ROW_MYSQL_WHOLE_ROW);
- return(0);
+ DBUG_RETURN(0);
}
/**************************************************************************
diff --git a/sql/lock.cc b/sql/lock.cc
index f523f10b3a7..9ce4137e380 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -394,8 +394,8 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list)
error=0;
end:
- start_waiting_global_read_lock(thd);
pthread_mutex_unlock(&LOCK_open);
+ start_waiting_global_read_lock(thd);
DBUG_RETURN(error);
}
@@ -532,6 +532,10 @@ bool lock_global_read_lock(THD *thd)
(void) pthread_mutex_lock(&LOCK_open);
const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
"Waiting to get readlock");
+ DBUG_PRINT("info",
+ ("waiting_for: %d protect_against: %d",
+ waiting_for_read_lock, protect_against_global_read_lock));
+
waiting_for_read_lock++;
while (protect_against_global_read_lock && !thd->killed)
pthread_cond_wait(&COND_refresh, &LOCK_open);
@@ -573,8 +577,9 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh)
if (thd->global_read_lock) // This thread had the read locks
{
my_error(ER_CANT_UPDATE_WITH_READLOCK,MYF(0));
+ (void) pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(1);
- }
+ }
old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
"Waiting for release of readlock");
while (global_read_lock && ! thd->killed &&
@@ -594,9 +599,11 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh)
void start_waiting_global_read_lock(THD *thd)
{
bool tmp;
+ DBUG_ENTER("start_waiting_global_read_lock");
(void) pthread_mutex_lock(&LOCK_open);
tmp= (!--protect_against_global_read_lock && waiting_for_read_lock);
(void) pthread_mutex_unlock(&LOCK_open);
if (tmp)
pthread_cond_broadcast(&COND_refresh);
+ DBUG_VOID_RETURN;
}
diff --git a/sql/md5.c b/sql/md5.c
index baf45350473..66b96b92ab2 100644
--- a/sql/md5.c
+++ b/sql/md5.c
@@ -124,7 +124,7 @@ void my_MD5Init (my_MD5_CTX *context) /* context */
context.
*/
-void MD5Update (
+void my_MD5Update (
my_MD5_CTX *context, /* context */
unsigned char *input, /* input block */
unsigned int inputLen) /* length of input block */
@@ -165,9 +165,10 @@ unsigned int inputLen) /* length of input block */
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
+
void my_MD5Final (
unsigned char digest[16], /* message digest */
-MD5_CTX *context) /* context */
+my_MD5_CTX *context) /* context */
{
unsigned char bits[8];
unsigned int idx, padLen;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 57679b510e3..4c3e113d537 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -691,7 +691,7 @@ TABLE *reopen_name_locked_table(THD* thd, TABLE_LIST* table_list)
if (thd->killed)
DBUG_RETURN(0);
TABLE* table;
- if(!(table = table_list->table))
+ if (!(table = table_list->table))
DBUG_RETURN(0);
char* db = thd->db ? thd->db : table_list->db;
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index ed9ceaae383..520c6c7e94d 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -40,32 +40,13 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
DBUG_ENTER("mysql_create_db");
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
- VOID(pthread_mutex_lock(&LOCK_open));
// do not create database if another thread is holding read lock
- if (global_read_lock)
+ if (wait_if_global_read_lock(thd,0))
{
- if (thd->global_read_lock)
- {
- net_printf(&thd->net, ER_CREATE_DB_WITH_READ_LOCK);
- VOID(pthread_mutex_unlock(&LOCK_open));
- goto exit;
- }
- while (global_read_lock && ! thd->killed)
- {
- (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
- }
-
- if (thd->killed)
- {
- net_printf(&thd->net, ER_SERVER_SHUTDOWN);
- VOID(pthread_mutex_unlock(&LOCK_open));
- goto exit;
- }
-
+ error= -1;
+ goto exit2;
}
-
- VOID(pthread_mutex_unlock(&LOCK_open));
/* Check directory */
(void)sprintf(path,"%s/%s", mysql_data_home, db);
@@ -75,7 +56,7 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
my_dirend(dirp);
if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS))
{
- if(thd)
+ if (thd)
net_printf(&thd->net,ER_DB_CREATE_EXISTS,db);
error = 1;
goto exit;
@@ -87,14 +68,14 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
strend(path)[-1]=0; // Remove last '/' from path
if (my_mkdir(path,0777,MYF(0)) < 0)
{
- if(thd)
+ if (thd)
net_printf(&thd->net,ER_CANT_CREATE_DB,db,my_errno);
error = 1;
goto exit;
}
}
- if(thd)
+ if (thd)
{
if (!thd->query)
{
@@ -117,7 +98,10 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
}
send_ok(&thd->net, result);
}
+
exit:
+ start_waiting_global_read_lock(thd);
+exit2:
VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
DBUG_RETURN(error);
}
@@ -126,6 +110,10 @@ const char *del_exts[]= {".frm", ".BAK", NullS};
static TYPELIB deletable_extentions=
{array_elements(del_exts)-1,"del_exts", del_exts};
+const char *known_exts[]=
+{".ISM",".ISD",".ISM",".MRG",".MYI",".MYD", ".db", NullS};
+static TYPELIB known_extentions=
+{array_elements(del_exts)-1,"del_exts", known_exts};
/*
Drop all tables in a database.
@@ -145,11 +133,13 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists)
DBUG_ENTER("mysql_rm_db");
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
- VOID(pthread_mutex_lock(&LOCK_open));
// do not drop database if another thread is holding read lock
if (wait_if_global_read_lock(thd,0))
- goto exit;
+ {
+ error= -1;
+ goto exit2;
+ }
(void) sprintf(path,"%s/%s",mysql_data_home,db);
unpack_dirname(path,path); // Convert if not unix
@@ -188,14 +178,14 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists)
thd->query = 0; // just in case
thd->query_length = 0;
}
-
send_ok(&thd->net,(ulong) deleted);
+ error = 0;
}
exit:
- VOID(pthread_mutex_unlock(&LOCK_open));
- VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
start_waiting_global_read_lock(thd);
+exit2:
+ VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
DBUG_RETURN(error);
}
@@ -246,7 +236,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
}
if (find_type(fn_ext(file->name),&deletable_extentions,1+2) <= 0)
{
- found_other_files++;
+ if (find_type(fn_ext(file->name),&known_extentions,1+2) <= 0)
+ found_other_files++;
continue;
}
strxmov(filePath,org_path,"/",file->name,NullS);
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 1a855c927a4..afaa310cbfb 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -488,6 +488,7 @@ bool multi_delete::send_eof()
normally can't safely do this.
- We don't want an ok to be sent to the end user.
- We don't want to log the truncate command
+ - If we want to have a name lock on the table on exit without errors.
*/
int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
@@ -499,8 +500,8 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
DBUG_ENTER("mysql_truncate");
/* If it is a temporary table, close and regenerate it */
- if ((table_ptr=find_temporary_table(thd,table_list->db,
- table_list->real_name)))
+ if (!dont_send_ok && (table_ptr=find_temporary_table(thd,table_list->db,
+ table_list->real_name)))
{
TABLE *table= *table_ptr;
HA_CREATE_INFO create_info;
@@ -536,7 +537,7 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
{
/* Probably InnoDB table */
DBUG_RETURN(mysql_delete(thd,table_list, (COND*) 0, (ORDER*) 0,
- (ha_rows) 0, TL_WRITE, 0));
+ HA_POS_ERROR, TL_WRITE, 0));
}
if (lock_and_wait_for_table_name(thd, table_list))
DBUG_RETURN(-1);
@@ -545,18 +546,22 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
bzero((char*) &create_info,sizeof(create_info));
*fn_ext(path)=0; // Remove the .frm extension
error= ha_create_table(path,&create_info,1) ? -1 : 0;
- VOID(pthread_mutex_unlock(&LOCK_open));
- if (!error && !dont_send_ok)
+ if (!dont_send_ok)
{
- mysql_update_log.write(thd,thd->query,thd->query_length);
- if (mysql_bin_log.is_open())
+ if (!error)
{
- Query_log_event qinfo(thd, thd->query);
- mysql_bin_log.write(&qinfo);
+ mysql_update_log.write(thd,thd->query,thd->query_length);
+ if (mysql_bin_log.is_open())
+ {
+ Query_log_event qinfo(thd, thd->query);
+ mysql_bin_log.write(&qinfo);
+ }
+ send_ok(&thd->net); // This should return record count
}
- send_ok(&thd->net); // This should return record count
+ unlock_table_name(thd, table_list);
}
- unlock_table_name(thd, table_list);
+ else if (error)
+ unlock_table_name(thd, table_list);
DBUG_RETURN(error ? -1 : 0);
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 687d325a95a..cdbcc203e9c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -890,7 +890,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
error=TRUE; // End server
break;
- case COM_CREATE_DB:
+ case COM_CREATE_DB: // QQ: To be removed
{
char *db=thd->strdup(packet);
// null test to handle EOM
@@ -905,7 +905,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
mysql_create_db(thd,db,0);
break;
}
- case COM_DROP_DB:
+ case COM_DROP_DB: // QQ: To be removed
{
char *db=thd->strdup(packet);
// null test to handle EOM
@@ -914,8 +914,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL");
break;
}
- if (check_access(thd,DROP_ACL,db,0,1) || end_active_trans(thd))
+ if (thd->locked_tables || thd->active_transaction())
+ {
+ send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION);
break;
+ }
mysql_log.write(thd,command,db);
mysql_rm_db(thd,db,0);
break;
@@ -1632,7 +1635,7 @@ mysql_execute_command(void)
*/
if (thd->locked_tables || thd->active_transaction())
{
- my_error(ER_LOCK_OR_ACTIVE_TRANSACTION,MYF(0));
+ send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION,NullS);
goto error;
}
res=mysql_truncate(thd,tables);
@@ -1963,7 +1966,7 @@ mysql_execute_command(void)
}
if (check_access(thd,CREATE_ACL,lex->name,0,1))
break;
- mysql_create_db(thd,lex->name,lex->create_info.options);
+ res=mysql_create_db(thd,lex->name,lex->create_info.options);
break;
}
case SQLCOM_DROP_DB:
@@ -1977,10 +1980,10 @@ mysql_execute_command(void)
break;
if (thd->locked_tables || thd->active_transaction())
{
- my_error(ER_LOCK_OR_ACTIVE_TRANSACTION,MYF(0));
+ send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION);
goto error;
}
- mysql_rm_db(thd,lex->name,lex->drop_if_exists);
+ res=mysql_rm_db(thd,lex->name,lex->drop_if_exists);
break;
}
case SQLCOM_CREATE_FUNCTION:
@@ -2057,7 +2060,7 @@ mysql_execute_command(void)
{
if (lex->columns.elements)
{
- net_printf(&thd->net,ER_ILLEGAL_GRANT_FOR_TABLE);
+ send_error(&thd->net,ER_ILLEGAL_GRANT_FOR_TABLE);
res=1;
}
else
@@ -2305,7 +2308,7 @@ static bool check_merge_table_access(THD *thd, char *db,
{
if (!tmp->db || !tmp->db[0])
tmp->db=db;
- else if (!strcmp(tmp->db,db))
+ else if (strcmp(tmp->db,db))
{
send_error(&thd->net,ER_UNION_TABLES_IN_DIFFERENT_DIR);
return 1;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index d667aeb6011..f50da413f53 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -864,7 +864,6 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table)
DBUG_RETURN(send_check_errmsg(thd, table, "restore",
"Failed generating table from .frm file"));
}
- /* truncate has released name lock */
}
DBUG_RETURN(0);
}