diff options
author | unknown <monty@mysql.com> | 2004-03-29 17:57:07 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-03-29 17:57:07 +0300 |
commit | 1cff3d98b361928e6b3fefb92069f6f1658d13c1 (patch) | |
tree | 99c0257fe8779ed78345d81aa4c907abe076bf82 | |
parent | 4ac3ca69903b5955c3675102477669178213951c (diff) | |
download | mariadb-git-1cff3d98b361928e6b3fefb92069f6f1658d13c1.tar.gz |
Disable INSERT DELAYED for embedded library
sql-bench/crash-me.sh:
Fixed typo
sql/mysql_priv.h:
Moved things for embedded library into one section
sql/sql_string.cc:
Simple optimization
-rw-r--r-- | sql-bench/crash-me.sh | 2 | ||||
-rw-r--r-- | sql/mysql_priv.h | 27 | ||||
-rw-r--r-- | sql/sql_base.cc | 2 | ||||
-rw-r--r-- | sql/sql_insert.cc | 26 | ||||
-rw-r--r-- | sql/sql_string.cc | 9 |
5 files changed, 46 insertions, 20 deletions
diff --git a/sql-bench/crash-me.sh b/sql-bench/crash-me.sh index 00989fc0bc8..be24e015553 100644 --- a/sql-bench/crash-me.sh +++ b/sql-bench/crash-me.sh @@ -407,7 +407,7 @@ if ($dbh->do("create table crash_q (a integer, b integer,c1 CHAR(10))") && ["with constraint and restrict/cascade", "alter table crash_q drop constraint u1 restrict"], ["with drop key", - "alter table crash_q drop key c1"]); + "alter table crash_q drop key u1"]); try_and_report("Alter table add primary key",'alter_add_primary_key', ["with constraint", "alter table crash_q1 add constraint p1 primary key(c1)"], diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 499739d8d80..bd919d12348 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -424,11 +424,6 @@ bool do_command(THD *thd); bool dispatch_command(enum enum_server_command command, THD *thd, char* packet, uint packet_length); bool check_dup(const char *db, const char *name, TABLE_LIST *tables); -#ifndef EMBEDDED_LIBRARY -bool check_stack_overrun(THD *thd,char *dummy); -#else -#define check_stack_overrun(A, B) 0 -#endif bool table_cache_init(void); void table_cache_free(void); @@ -534,7 +529,6 @@ int mysql_multi_update(THD *thd, TABLE_LIST *table_list, int mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields, List<List_item> &values, List<Item> &update_fields, List<Item> &update_values, enum_duplicates flag); -void kill_delayed_threads(void); int mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order, ha_rows rows, ulong options); int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok=0); @@ -969,11 +963,6 @@ void make_datetime(DATE_TIME_FORMAT *format, TIME *l_time, String *str); int test_if_number(char *str,int *res,bool allow_wildcards); void change_byte(byte *,uint,char,char); -#ifndef EMBEDDED_LIBRARY -extern "C" void unireg_abort(int exit_code); -#else -#define unireg_abort(exit_code) DBUG_RETURN(exit_code) -#endif void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form, SQL_SELECT *select, int use_record_cache, bool print_errors); @@ -1122,3 +1111,19 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr) table->map= (table_map) 1 << tablenr; table->force_index= table_list->force_index; } + + +/* + Some functions that are different in the embedded library and the normal + server +*/ + +#ifndef EMBEDDED_LIBRARY +extern "C" void unireg_abort(int exit_code); +void kill_delayed_threads(void); +bool check_stack_overrun(THD *thd,char *dummy); +#else +#define unireg_abort(exit_code) DBUG_RETURN(exit_code) +inline void kill_delayed_threads(void) {} +#define check_stack_overrun(A, B) 0 +#endif diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b4ee3df14e2..e8bb3187fb1 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -284,8 +284,10 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh, if (!found) if_wait_for_refresh=0; // Nothing to wait for } +#ifndef EMBEDDED_LIBRARY if (!tables) kill_delayed_threads(); +#endif if (if_wait_for_refresh) { /* diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index a9b947505f0..928afa66916 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -112,14 +112,13 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &update_values, enum_duplicates duplic) { - int error; + int error, res; /* log_on is about delayed inserts only. By default, both logs are enabled (this won't cause problems if the server runs without --log-update or --log-bin). */ int log_on= DELAYED_LOG_UPDATE | DELAYED_LOG_BIN ; - bool transactional_table, log_delayed, bulk_insert; uint value_count; ulong counter = 1; @@ -148,15 +147,20 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, if we are told to replace duplicates, the insert cannot be concurrent delayed insert changed to regular in slave thread */ +#ifdef EMBEDDED_LIBRARY + if (lock_type == TL_WRITE_DELAYED) + lock_type=TL_WRITE; +#else if ((lock_type == TL_WRITE_DELAYED && ((specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) || thd->slave_thread || !thd->variables.max_insert_delayed_threads)) || (lock_type == TL_WRITE_CONCURRENT_INSERT && duplic == DUP_REPLACE) || (duplic == DUP_UPDATE)) lock_type=TL_WRITE; +#endif table_list->lock_type= lock_type; - int res; +#ifndef EMBEDDED_LIBRARY if (lock_type == TL_WRITE_DELAYED) { if (thd->locked_tables) @@ -185,6 +189,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, } } else +#endif /* EMBEDDED_LIBRARY */ res= open_and_lock_tables(thd, table_list); if (res) DBUG_RETURN(-1); @@ -302,12 +307,14 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, break; } } +#ifndef EMBEDDED_LIBRARY if (lock_type == TL_WRITE_DELAYED) { error=write_delayed(thd,table,duplic,query, thd->query_length, log_on); query=0; } else +#endif error=write_record(table,&info); if (error) break; @@ -328,6 +335,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, Now all rows are inserted. Time to update logs and sends response to user */ +#ifndef EMBEDDED_LIBRARY if (lock_type == TL_WRITE_DELAYED) { if (!error) @@ -339,6 +347,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, query_cache_invalidate3(thd, table_list, 1); } else +#endif { if (bulk_insert) { @@ -435,8 +444,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, DBUG_RETURN(0); abort: +#ifndef EMBEDDED_LIBRARY if (lock_type == TL_WRITE_DELAYED) end_delayed_insert(thd); +#endif free_underlaid_joins(thd, &thd->lex->select_lex); table->insert_values=0; DBUG_RETURN(-1); @@ -608,6 +619,8 @@ static int check_null_fields(THD *thd __attribute__((unused)), A thread is created for each table that one uses with the DELAYED attribute. *****************************************************************************/ +#ifndef EMBEDDED_LIBRARY + class delayed_row :public ilink { public: char *record,*query; @@ -1396,8 +1409,7 @@ bool delayed_insert::handle_inserts(void) pthread_mutex_lock(&mutex); DBUG_RETURN(1); } - - +#endif /* EMBEDDED_LIBRARY */ /*************************************************************************** Store records in INSERT ... SELECT * @@ -1674,7 +1686,9 @@ void select_create::abort() #ifdef __GNUC__ template class List_iterator_fast<List_item>; +#ifndef EMBEDDED_LIBRARY template class I_List<delayed_insert>; template class I_List_iterator<delayed_insert>; template class I_List<delayed_row>; -#endif +#endif /* EMBEDDED_LIBRARY */ +#endif /* __GNUC__ */ diff --git a/sql/sql_string.cc b/sql/sql_string.cc index e15beac90b0..a4eae8a6346 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -794,10 +794,14 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs, const uchar *from_end= (const uchar*) from+from_length; char *to_start= to; uchar *to_end= (uchar*) to+to_length; + int (*mb_wc)(struct charset_info_st *, my_wc_t *, const uchar *, + const uchar *) = from_cs->cset->mb_wc; + int (*wc_mb)(struct charset_info_st *, my_wc_t, uchar *s, uchar *e)= + to_cs->cset->wc_mb; while (1) { - if ((cnvres= from_cs->cset->mb_wc(from_cs, &wc, (uchar*) from, + if ((cnvres= (*mb_wc)(from_cs, &wc, (uchar*) from, from_end)) > 0) from+= cnvres; else if (cnvres == MY_CS_ILSEQ) @@ -809,7 +813,7 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs, break; // Impossible char. outp: - if ((cnvres= to_cs->cset->wc_mb(to_cs, wc, (uchar*) to, to_end)) > 0) + if ((cnvres= (*wc_mb)(to_cs, wc, (uchar*) to, to_end)) > 0) to+= cnvres; else if (cnvres == MY_CS_ILUNI && wc != '?') { @@ -822,6 +826,7 @@ outp: return (uint32) (to - to_start); } + void String::print(String *str) { char *st= (char*)Ptr, *end= st+str_length; |