Commit 88321595 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/my/mysql-4.1


sql/sql_insert.cc:
  Auto merged
parents 399845ae 1cff3d98
......@@ -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)"],
......
......@@ -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
......@@ -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)
{
/*
......
......@@ -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;
......@@ -143,15 +142,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)
......@@ -180,6 +184,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);
......@@ -297,12 +302,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;
......@@ -323,6 +330,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)
......@@ -334,6 +342,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
query_cache_invalidate3(thd, table_list, 1);
}
else
#endif
{
if (bulk_insert)
{
......@@ -430,8 +439,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);
......@@ -603,6 +614,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;
......@@ -1391,8 +1404,7 @@ bool delayed_insert::handle_inserts(void)
pthread_mutex_lock(&mutex);
DBUG_RETURN(1);
}
#endif /* EMBEDDED_LIBRARY */
/***************************************************************************
Store records in INSERT ... SELECT *
......@@ -1669,7 +1681,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__ */
......@@ -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 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
return (uint32) (to - to_start);
}
void String::print(String *str)
{
char *st= (char*)Ptr, *end= st+str_length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment