Below is the list of changes that have just been committed into a local
5.1 repository of kostja. When kostja does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-01 12:12:06+04:00, kostja@bodhi.(none) +48 -0
Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into bodhi.(none):/opt/local/work/mysql-5.1-runtime
MERGE: 1.2511.1.4
client/mysqlbinlog.cc@stripped, 2007-06-01 11:43:50+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.155.1.2
include/config-win.h@stripped, 2007-06-01 11:43:50+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.99.1.2
include/my_global.h@stripped, 2007-06-01 11:43:50+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.169.1.3
include/my_pthread.h@stripped, 2007-06-01 11:43:50+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.113.1.2
mysql-test/lib/mtr_report.pl@stripped, 2007-06-01 11:43:50+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.47.1.1
mysql-test/t/disabled.def@stripped, 2007-06-01 11:43:50+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.253.2.1
sql/event_data_objects.cc@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.99.1.1
sql/event_queue.cc@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.33.1.1
sql/field.h@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.226.1.1
sql/filesort.cc@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.127.1.4
sql/handler.cc@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.307.1.2
sql/handler.h@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.258.1.1
sql/item_func.cc@stripped, 2007-06-01 12:12:02+04:00, kostja@bodhi.(none) +0 -0
Manual merge.
MERGE: 1.394.1.3
sql/item_func.h@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.165.1.12
sql/item_xmlfunc.cc@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.26.2.1
sql/log_event.cc@stripped, 2007-06-01 11:43:51+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.278.1.3
sql/log_event.h@stripped, 2007-06-01 11:43:52+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.149.1.1
sql/mysql_priv.h@stripped, 2007-06-01 11:43:52+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.509.1.4
sql/mysqld.cc@stripped, 2007-06-01 11:43:52+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.645.1.2
sql/set_var.cc@stripped, 2007-06-01 11:43:52+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.233.1.3
sql/sp.cc@stripped, 2007-06-01 12:12:02+04:00, kostja@bodhi.(none) +1 -2
Manual merge.
MERGE: 1.151.1.2
sql/sp.h@stripped, 2007-06-01 11:43:52+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.38.1.1
sql/sp_head.cc@stripped, 2007-06-01 11:43:53+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.271.1.4
sql/sp_head.h@stripped, 2007-06-01 11:43:53+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.106.1.1
sql/sql_acl.cc@stripped, 2007-06-01 11:43:53+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.234.1.4
sql/sql_base.cc@stripped, 2007-06-01 11:43:53+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.403.1.2
sql/sql_cache.cc@stripped, 2007-06-01 12:12:02+04:00, kostja@bodhi.(none) +1 -1
Manual merge.
MERGE: 1.109.1.1
sql/sql_class.cc@stripped, 2007-06-01 11:43:53+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.334.1.2
sql/sql_class.h@stripped, 2007-06-01 11:43:53+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.362.1.2
sql/sql_db.cc@stripped, 2007-06-01 11:43:53+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.151.1.1
sql/sql_insert.cc@stripped, 2007-06-01 11:43:54+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.268.1.2
sql/sql_lex.cc@stripped, 2007-06-01 11:43:54+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.242.1.4
sql/sql_lex.h@stripped, 2007-06-01 11:43:54+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.276.1.1
sql/sql_list.h@stripped, 2007-06-01 11:43:54+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.46.1.1
sql/sql_load.cc@stripped, 2007-06-01 11:43:54+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.123.1.2
sql/sql_parse.cc@stripped, 2007-06-01 11:43:54+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.668.2.1
sql/sql_partition.cc@stripped, 2007-06-01 11:43:54+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.103.1.1
sql/sql_prepare.cc@stripped, 2007-06-01 11:43:54+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.217.1.1
sql/sql_select.cc@stripped, 2007-06-01 11:43:55+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.521.1.1
sql/sql_show.cc@stripped, 2007-06-01 11:43:55+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.412.1.1
sql/sql_table.cc@stripped, 2007-06-01 12:12:02+04:00, kostja@bodhi.(none) +1 -2
Manual merge.
MERGE: 1.416.1.2
sql/sql_test.cc@stripped, 2007-06-01 11:43:55+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.52.1.1
sql/sql_update.cc@stripped, 2007-06-01 11:43:55+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.239.1.3
sql/sql_view.cc@stripped, 2007-06-01 11:43:56+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.133.1.2
sql/sql_yacc.yy@stripped, 2007-06-01 11:43:56+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.569.1.3
storage/heap/hp_hash.c@stripped, 2007-06-01 11:43:56+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.50.1.1
strings/my_vsnprintf.c@stripped, 2007-06-01 12:12:02+04:00, kostja@bodhi.(none) +0 -0
Manual merge.
MERGE: 1.38.1.1
tests/mysql_client_test.c@stripped, 2007-06-01 11:43:56+04:00, kostja@bodhi.(none) +0 -0
Auto merged
MERGE: 1.236.1.7
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: kostja
# Host: bodhi.(none)
# Root: /opt/local/work/mysql-5.1-runtime/RESYNC
--- 1.51/storage/heap/hp_hash.c 2007-05-10 13:59:31 +04:00
+++ 1.52/storage/heap/hp_hash.c 2007-06-01 11:43:56 +04:00
@@ -379,7 +379,13 @@
ulong hp_hashnr(register HP_KEYDEF *keydef, register const uchar *key)
{
- register ulong nr=0;
+ /*
+ Note, if a key consists of a combination of numeric and
+ a text columns, it most likely won't work well.
+ Making text columns work with NEW_HASH_FUNCTION
+ needs also changes in strings/ctype-xxx.c.
+ */
+ ulong nr= 1, nr2= 4;
HA_KEYSEG *seg,*endseg;
for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
@@ -401,14 +407,15 @@
}
if (seg->type == HA_KEYTYPE_TEXT)
{
- seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,NULL);
+ seg->charset->coll->hash_sort(seg->charset, pos, ((uchar*)key)-pos,
+ &nr, &nr2);
}
else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */
{
uint pack_length= 2; /* Key packing is constant */
uint length= uint2korr(pos);
- seg->charset->hash_sort(seg->charset, pos+pack_length, length, &nr,
- NULL);
+ seg->charset->coll->hash_sort(seg->charset, pos+pack_length, length,
+ &nr, &nr2);
key+= pack_length;
}
else
@@ -428,7 +435,7 @@
ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
{
- register ulong nr=0;
+ ulong nr= 1, nr2= 4;
HA_KEYSEG *seg,*endseg;
for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
@@ -444,14 +451,16 @@
}
if (seg->type == HA_KEYTYPE_TEXT)
{
- seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,NULL);
+ uint char_length= seg->length; /* TODO: fix to use my_charpos() */
+ seg->charset->coll->hash_sort(seg->charset, pos, char_length,
+ &nr, &nr2);
}
else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */
{
uint pack_length= seg->bit_start;
uint length= (pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos));
- seg->charset->hash_sort(seg->charset, pos+pack_length,
- length, &nr, NULL);
+ seg->charset->coll->hash_sort(seg->charset, pos+pack_length,
+ length, &nr, &nr2);
}
else
{
--- 1.100/include/config-win.h 2007-05-10 13:59:24 +04:00
+++ 1.101/include/config-win.h 2007-06-01 11:43:50 +04:00
@@ -350,7 +350,10 @@
#define SPRINTF_RETURNS_INT
#define HAVE_SETFILEPOINTER
#define HAVE_VIO_READ_BUFF
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+/* strnlen() appeared in Studio 2005 */
#define HAVE_STRNLEN
+#endif
#define HAVE_WINSOCK2
#define strcasecmp stricmp
@@ -411,16 +414,7 @@
#ifdef __NT__ /* This should also work on Win98 but .. */
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
-#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
-#else
-#define thread_safe_add(V,C,L) \
- pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
-#define thread_safe_sub(V,C,L) \
- pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
-#define statistic_add(V,C,L) (V)+=(C)
#endif
-#define statistic_increment(V,L) thread_safe_increment((V),(L))
-#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
#define shared_memory_buffer_length 16000
#define default_shared_memory_base_name "MYSQL"
--- 1.114/include/my_pthread.h 2007-05-10 13:59:24 +04:00
+++ 1.115/include/my_pthread.h 2007-06-01 11:43:50 +04:00
@@ -710,33 +710,68 @@
extern uint thd_lib_detected;
- /* statistics_xxx functions are for not essential statistic */
+/*
+ thread_safe_xxx functions are for critical statistic or counters.
+ The implementation is guaranteed to be thread safe, on all platforms.
+ Note that the calling code should *not* assume the counter is protected
+ by the mutex given, as the implementation of these helpers may change
+ to use my_atomic operations instead.
+*/
+/*
+ Warning:
+ When compiling without threads, this file is not included.
+ See the *other* declarations of thread_safe_xxx in include/my_global.h
+
+ Second warning:
+ See include/config-win.h, for yet another implementation.
+*/
+#ifdef THREAD
#ifndef thread_safe_increment
-#ifdef HAVE_ATOMIC_ADD
-#define thread_safe_increment(V,L) atomic_inc((atomic_t*) &V)
-#define thread_safe_decrement(V,L) atomic_dec((atomic_t*) &V)
-#define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V)
-#define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V)
-#else
#define thread_safe_increment(V,L) \
(pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
#define thread_safe_decrement(V,L) \
(pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
-#define thread_safe_add(V,C,L) (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
+#endif
+
+#ifndef thread_safe_add
+#define thread_safe_add(V,C,L) \
+ (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
#define thread_safe_sub(V,C,L) \
(pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
-#endif /* HAVE_ATOMIC_ADD */
+#endif
+#endif
+
+/*
+ statistics_xxx functions are for non critical statistic,
+ maintained in global variables.
+ When compiling with SAFE_STATISTICS:
+ - race conditions can not occur.
+ - some locking occurs, which may cause performance degradation.
+
+ When compiling without SAFE_STATISTICS:
+ - race conditions can occur, making the result slightly inaccurate.
+ - the lock given is not honored.
+*/
#ifdef SAFE_STATISTICS
-#define statistic_increment(V,L) thread_safe_increment((V),(L))
-#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
-#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
+#define statistic_increment(V,L) thread_safe_increment((V),(L))
+#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
+#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
+#define statistic_sub(V,C,L) thread_safe_sub((V),(C),(L))
#else
#define statistic_decrement(V,L) (V)--
#define statistic_increment(V,L) (V)++
#define statistic_add(V,C,L) (V)+=(C)
+#define statistic_sub(V,C,L) (V)-=(C)
#endif /* SAFE_STATISTICS */
-#endif /* thread_safe_increment */
+
+/*
+ No locking needed, the counter is owned by the thread
+*/
+#define status_var_increment(V) (V)++
+#define status_var_decrement(V) (V)--
+#define status_var_add(V,C) (V)+=(C)
+#define status_var_sub(V,C) (V)-=(C)
#ifdef __cplusplus
}
--- 1.39/strings/my_vsnprintf.c 2007-05-10 13:59:34 +04:00
+++ 1.40/strings/my_vsnprintf.c 2007-06-01 12:12:02 +04:00
@@ -97,8 +97,7 @@
reg2 char *par = va_arg(ap, char *);
size_t plen,left_len = (size_t) (end - to) + 1;
if (!par) par = (char*)"(null)";
- plen= strlen(par);
- set_if_smaller(plen,width);
+ plen= (uint) strnlen(par, width);
if (left_len <= plen)
plen = left_len - 1;
to=strnmov(to,par,plen);
--- 1.228/sql/field.h 2007-05-24 20:47:54 +04:00
+++ 1.229/sql/field.h 2007-06-01 11:43:51 +04:00
@@ -1628,6 +1628,9 @@
uint offset,pack_flag;
create_field() :after(0) {}
create_field(Field *field, Field *orig_field);
+ /* Used to make a clone of this object for ALTER/CREATE TABLE */
+ create_field *clone(MEM_ROOT *mem_root) const
+ { return new (mem_root) create_field(*this); }
void create_length_to_internal_length(void);
/* Init for a tmp table field. To be extended if need be. */
--- 1.129/sql/filesort.cc 2007-05-24 02:39:17 +04:00
+++ 1.130/sql/filesort.cc 2007-06-01 11:43:51 +04:00
@@ -171,11 +171,11 @@
if (select && select->quick)
{
- statistic_increment(thd->status_var.filesort_range_count, &LOCK_status);
+ status_var_increment(thd->status_var.filesort_range_count);
}
else
{
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
+ status_var_increment(thd->status_var.filesort_scan_count);
}
#ifdef CAN_TRUST_RANGE
if (select && select->quick && select->quick->records > 0L)
@@ -1129,8 +1129,7 @@
THD::killed_state not_killable;
DBUG_ENTER("merge_buffers");
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
+ status_var_increment(current_thd->status_var.filesort_merge_passes);
if (param->not_killable)
{
killed= ¬_killable;
--- 1.309/sql/handler.cc 2007-05-24 19:33:55 +04:00
+++ 1.310/sql/handler.cc 2007-06-01 11:43:51 +04:00
@@ -368,7 +368,7 @@
/* Allocate a pointer array for the error message strings. */
if (! (errmsgs= my_error_unregister(HA_ERR_FIRST, HA_ERR_LAST)))
return 1;
- my_free((gptr) errmsgs, MYF(0));
+ my_free((uchar*) errmsgs, MYF(0));
return 0;
}
@@ -406,7 +406,7 @@
}
}
- my_free((gptr)hton, MYF(0));
+ my_free((uchar*)hton, MYF(0));
DBUG_RETURN(0);
}
@@ -1053,7 +1053,7 @@
}
// recovery mode
if (info->commit_list ?
- hash_search(info->commit_list, (byte *)&x, sizeof(x)) != 0 :
+ hash_search(info->commit_list, (uchar *)&x, sizeof(x)) != 0 :
tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT)
{
#ifndef DBUG_OFF
@@ -1123,7 +1123,7 @@
plugin_foreach(NULL, xarecover_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &info);
- my_free((gptr)info.list, MYF(0));
+ my_free((uchar*)info.list, MYF(0));
if (info.found_foreign_xids)
sql_print_warning("Found %d prepared XA transactions",
info.found_foreign_xids);
@@ -1247,7 +1247,7 @@
{
int err;
DBUG_ASSERT((*ht)->savepoint_set != 0);
- if ((err= (*(*ht)->savepoint_rollback)(*ht, thd, (byte *)(sv+1)+(*ht)->savepoint_offset)))
+ if ((err= (*(*ht)->savepoint_rollback)(*ht, thd, (uchar *)(sv+1)+(*ht)->savepoint_offset)))
{ // cannot happen
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1;
@@ -1295,7 +1295,7 @@
error=1;
break;
}
- if ((err= (*(*ht)->savepoint_set)(*ht, thd, (byte *)(sv+1)+(*ht)->savepoint_offset)))
+ if ((err= (*(*ht)->savepoint_set)(*ht, thd, (uchar *)(sv+1)+(*ht)->savepoint_offset)))
{ // cannot happen
my_error(ER_GET_ERRNO, MYF(0), err);
error=1;
@@ -1322,7 +1322,7 @@
if (!(*ht)->savepoint_release)
continue;
if ((err= (*(*ht)->savepoint_release)(*ht, thd,
- (byte *)(sv+1)+
+ (uchar *)(sv+1)+
(*ht)->savepoint_offset)))
{ // cannot happen
my_error(ER_GET_ERRNO, MYF(0), err);
@@ -1572,7 +1572,7 @@
table->db_stat|=HA_READ_ONLY;
(void) extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL
- if (!(ref= (byte*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2)))
+ if (!(ref= (uchar*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2)))
{
close();
error=HA_ERR_OUT_OF_MEM;
@@ -1590,7 +1590,7 @@
This is never called for InnoDB tables, as these table types
has the HA_STATS_RECORDS_IS_EXACT set.
*/
-int handler::read_first_row(byte * buf, uint primary_key)
+int handler::read_first_row(uchar * buf, uint primary_key)
{
register int error;
DBUG_ENTER("handler::read_first_row");
@@ -1999,7 +1999,7 @@
}
else
{
- byte key[MAX_KEY_LENGTH];
+ uchar key[MAX_KEY_LENGTH];
key_copy(key, table->record[0],
table->key_info + table->s->next_number_index,
table->s->next_number_key_offset);
@@ -2358,12 +2358,12 @@
int4store(version, MYSQL_VERSION_ID);
- if ((result= my_pwrite(file,(byte*) version,4,51L,MYF_RW)))
+ if ((result= my_pwrite(file,(uchar*) version,4,51L,MYF_RW)))
goto err;
- for (entry=(TABLE*) hash_first(&open_cache,(byte*) key,key_length, &state);
+ for (entry=(TABLE*) hash_first(&open_cache,(uchar*) key,key_length, &state);
entry;
- entry= (TABLE*) hash_next(&open_cache,(byte*) key,key_length, &state))
+ entry= (TABLE*) hash_next(&open_cache,(uchar*) key,key_length, &state))
entry->s->mysql_version= MYSQL_VERSION_ID;
}
err:
@@ -2526,7 +2526,7 @@
DBUG_RETURN(error);
}
-int handler::index_next_same(byte *buf, const byte *key, uint keylen)
+int handler::index_next_same(uchar *buf, const uchar *key, uint keylen)
{
int error;
if (!(error=index_next(buf)))
@@ -2635,8 +2635,8 @@
int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
{
int error;
- const void *frmblob;
- uint frmlen;
+ uchar *frmblob;
+ size_t frmlen;
char path[FN_REFLEN];
HA_CREATE_INFO create_info;
TABLE table;
@@ -2644,7 +2644,7 @@
DBUG_ENTER("ha_create_table_from_engine");
DBUG_PRINT("enter", ("name '%s'.'%s'", db, name));
- bzero((char*) &create_info,sizeof(create_info));
+ bzero((uchar*) &create_info,sizeof(create_info));
if ((error= ha_discover(thd, db, name, &frmblob, &frmlen)))
{
/* Table could not be discovered and thus not created */
@@ -2659,7 +2659,7 @@
(void)strxnmov(path,FN_REFLEN-1,mysql_data_home,"/",db,"/",name,NullS);
// Save the frm file
error= writefrm(path, frmblob, frmlen);
- my_free((char*) frmblob, MYF(0));
+ my_free(frmblob, MYF(0));
if (error)
DBUG_RETURN(2);
@@ -2801,8 +2801,8 @@
{
const char *db;
const char *name;
- const void** frmblob;
- uint* frmlen;
+ uchar **frmblob;
+ size_t *frmlen;
};
static my_bool discover_handlerton(THD *thd, plugin_ref plugin,
@@ -2820,7 +2820,7 @@
}
int ha_discover(THD *thd, const char *db, const char *name,
- const void **frmblob, uint *frmlen)
+ uchar **frmblob, size_t *frmlen)
{
int error= -1; // Table does not exist in any handler
DBUG_ENTER("ha_discover");
@@ -3310,7 +3310,7 @@
}
-int handler::index_read_idx(byte * buf, uint index, const byte * key,
+int handler::index_read_idx(uchar * buf, uint index, const uchar * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag)
{
@@ -3570,8 +3570,8 @@
template<class RowsEventT> int
binlog_log_row(TABLE* table,
- const byte *before_record,
- const byte *after_record)
+ const uchar *before_record,
+ const uchar *after_record)
{
if (table->file->ha_table_flags() & HA_HAS_OWN_BINLOGGING)
return 0;
@@ -3620,13 +3620,13 @@
*/
template int
- binlog_log_row<Write_rows_log_event>(TABLE *, const byte *, const byte *);
+ binlog_log_row<Write_rows_log_event>(TABLE *, const uchar *, const uchar *);
template int
- binlog_log_row<Delete_rows_log_event>(TABLE *, const byte *, const byte *);
+ binlog_log_row<Delete_rows_log_event>(TABLE *, const uchar *, const uchar *);
template int
- binlog_log_row<Update_rows_log_event>(TABLE *, const byte *, const byte *);
+ binlog_log_row<Update_rows_log_event>(TABLE *, const uchar *, const uchar *);
}
@@ -3650,9 +3650,9 @@
{
DBUG_ENTER("ha_reset");
/* Check that we have called all proper deallocation functions */
- DBUG_ASSERT((byte*) table->def_read_set.bitmap +
+ DBUG_ASSERT((uchar*) table->def_read_set.bitmap +
table->s->column_bitmap_size ==
- (byte*) table->def_write_set.bitmap);
+ (uchar*) table->def_write_set.bitmap);
DBUG_ASSERT(bitmap_is_set_all(&table->s->all_set));
DBUG_ASSERT(table->key_read == 0);
/* ensure that ha_index_end / ha_rnd_end has been called */
@@ -3663,7 +3663,7 @@
}
-int handler::ha_write_row(byte *buf)
+int handler::ha_write_row(uchar *buf)
{
int error;
if (unlikely(error= write_row(buf)))
@@ -3673,7 +3673,7 @@
return 0;
}
-int handler::ha_update_row(const byte *old_data, byte *new_data)
+int handler::ha_update_row(const uchar *old_data, uchar *new_data)
{
int error;
@@ -3690,7 +3690,7 @@
return 0;
}
-int handler::ha_delete_row(const byte *buf)
+int handler::ha_delete_row(const uchar *buf)
{
int error;
if (unlikely(error= delete_row(buf)))
@@ -3813,7 +3813,7 @@
void fl_log_iterator_destroy(struct handler_iterator *iterator)
{
- my_free((gptr)iterator->buffer, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((uchar*)iterator->buffer, MYF(MY_ALLOW_ZERO_PTR));
}
@@ -3826,7 +3826,7 @@
MY_DIR *dirp;
struct fl_buff *buff;
char *name_ptr;
- byte *ptr;
+ uchar *ptr;
FILEINFO *file;
uint32 i;
@@ -3837,7 +3837,7 @@
{
return HA_ITERATOR_ERROR;
}
- if ((ptr= (byte*)my_malloc(ALIGN_SIZE(sizeof(fl_buff)) +
+ if ((ptr= (uchar*)my_malloc(ALIGN_SIZE(sizeof(fl_buff)) +
((ALIGN_SIZE(sizeof(LEX_STRING)) +
sizeof(enum log_status) +
+ FN_REFLEN) *
--- 1.260/sql/handler.h 2007-05-23 15:45:54 +04:00
+++ 1.261/sql/handler.h 2007-06-01 11:43:51 +04:00
@@ -379,9 +379,9 @@
return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
gtrid_length+bqual_length;
}
- byte *key()
+ uchar *key()
{
- return (byte *)>rid_length;
+ return (uchar *)>rid_length;
}
uint key_length()
{
@@ -675,8 +675,8 @@
struct handler_iterator *fill_this_in);
int (*discover)(handlerton *hton, THD* thd, const char *db,
const char *name,
- const void** frmblob,
- uint* frmlen);
+ uchar **frmblob,
+ size_t *frmlen);
int (*find_files)(handlerton *hton, THD *thd,
const char *db,
const char *path,
@@ -836,9 +836,9 @@
typedef struct st_handler_buffer
{
- const byte *buffer; /* Buffer one can start using */
- const byte *buffer_end; /* End of buffer */
- byte *end_of_used_area; /* End of area that was used by handler */
+ const uchar *buffer; /* Buffer one can start using */
+ const uchar *buffer_end; /* End of buffer */
+ uchar *end_of_used_area; /* End of area that was used by handler */
} HANDLER_BUFFER;
typedef struct system_status_var SSV;
@@ -868,7 +868,7 @@
{}
};
-uint calculate_key_len(TABLE *, uint, const byte *, key_part_map);
+uint calculate_key_len(TABLE *, uint, const uchar *, key_part_map);
/*
bitmap with first N+1 bits set
(keypart_map for a key prefix of [0..N] keyparts)
@@ -919,8 +919,8 @@
virtual int end_bulk_insert() {return 0; }
public:
handlerton *ht; /* storage engine of this handler */
- byte *ref; /* Pointer to current row */
- byte *dup_ref; /* Pointer to duplicate row */
+ uchar *ref; /* Pointer to current row */
+ uchar *dup_ref; /* Pointer to duplicate row */
ha_statistics stats;
@@ -1143,9 +1143,9 @@
and delete_row() below.
*/
int ha_external_lock(THD *thd, int lock_type);
- int ha_write_row(byte * buf);
- int ha_update_row(const byte * old_data, byte * new_data);
- int ha_delete_row(const byte * buf);
+ int ha_write_row(uchar * buf);
+ int ha_update_row(const uchar * old_data, uchar * new_data);
+ int ha_delete_row(const uchar * buf);
/*
SYNOPSIS
@@ -1178,7 +1178,7 @@
0 Bulk delete used by handler
1 Bulk delete not used, normal operation used
*/
- virtual int bulk_update_row(const byte *old_data, byte *new_data,
+ virtual int bulk_update_row(const uchar *old_data, uchar *new_data,
uint *dup_key_found)
{
DBUG_ASSERT(FALSE);
@@ -1227,7 +1227,7 @@
return HA_ERR_WRONG_COMMAND;
}
private:
- virtual int index_read(byte * buf, const byte * key, uint key_len,
+ virtual int index_read(uchar * buf, const uchar * key, uint key_len,
enum ha_rkey_function find_flag)
{ return HA_ERR_WRONG_COMMAND; }
public:
@@ -1237,7 +1237,7 @@
row if available. If the key value is null, begin at the first key of the
index.
*/
- virtual int index_read(byte * buf, const byte * key, key_part_map keypart_map,
+ virtual int index_read(uchar * buf, const uchar * key, key_part_map keypart_map,
enum ha_rkey_function find_flag)
{
uint key_len= calculate_key_len(table, active_index, key, keypart_map);
@@ -1249,20 +1249,20 @@
row if available. If the key value is null, begin at the first key of the
index.
*/
- virtual int index_read_idx(byte * buf, uint index, const byte * key,
+ virtual int index_read_idx(uchar * buf, uint index, const uchar * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag);
- virtual int index_next(byte * buf)
+ virtual int index_next(uchar * buf)
{ return HA_ERR_WRONG_COMMAND; }
- virtual int index_prev(byte * buf)
+ virtual int index_prev(uchar * buf)
{ return HA_ERR_WRONG_COMMAND; }
- virtual int index_first(byte * buf)
+ virtual int index_first(uchar * buf)
{ return HA_ERR_WRONG_COMMAND; }
- virtual int index_last(byte * buf)
+ virtual int index_last(uchar * buf)
{ return HA_ERR_WRONG_COMMAND; }
- virtual int index_next_same(byte *buf, const byte *key, uint keylen);
+ virtual int index_next_same(uchar *buf, const uchar *key, uint keylen);
private:
- virtual int index_read_last(byte * buf, const byte * key, uint key_len)
+ virtual int index_read_last(uchar * buf, const uchar * key, uint key_len)
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
public:
/**
@@ -1270,7 +1270,7 @@
The following functions works like index_read, but it find the last
row with the current key value or prefix.
*/
- virtual int index_read_last(byte * buf, const byte * key,
+ virtual int index_read_last(uchar * buf, const uchar * key,
key_part_map keypart_map)
{
uint key_len= calculate_key_len(table, active_index, key, keypart_map);
@@ -1289,21 +1289,21 @@
void ft_end() { ft_handler=NULL; }
virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key)
{ return NULL; }
- virtual int ft_read(byte *buf) { return HA_ERR_WRONG_COMMAND; }
- virtual int rnd_next(byte *buf)=0;
- virtual int rnd_pos(byte * buf, byte *pos)=0;
- virtual int read_first_row(byte *buf, uint primary_key);
+ virtual int ft_read(uchar *buf) { return HA_ERR_WRONG_COMMAND; }
+ virtual int rnd_next(uchar *buf)=0;
+ virtual int rnd_pos(uchar * buf, uchar *pos)=0;
+ virtual int read_first_row(uchar *buf, uint primary_key);
/*
The following function is only needed for tables that may be temporary
tables during joins
*/
- virtual int restart_rnd_next(byte *buf, byte *pos)
+ virtual int restart_rnd_next(uchar *buf, uchar *pos)
{ return HA_ERR_WRONG_COMMAND; }
- virtual int rnd_same(byte *buf, uint inx)
+ virtual int rnd_same(uchar *buf, uint inx)
{ return HA_ERR_WRONG_COMMAND; }
virtual ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key)
{ return (ha_rows) 10; }
- virtual void position(const byte *record)=0;
+ virtual void position(const uchar *record)=0;
virtual int info(uint)=0; // see my_base.h for full description
virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info,
uint part_id);
@@ -1559,8 +1559,8 @@
const char *path,
ulonglong *copied,
ulonglong *deleted,
- const void *pack_frm_data,
- uint pack_frm_len)
+ const uchar *pack_frm_data,
+ size_t pack_frm_len)
{ return HA_ERR_WRONG_COMMAND; }
virtual int drop_partitions(const char *path)
{ return HA_ERR_WRONG_COMMAND; }
@@ -1603,7 +1603,7 @@
false otherwise
*/
virtual bool primary_key_is_clustered() { return FALSE; }
- virtual int cmp_ref(const byte *ref1, const byte *ref2)
+ virtual int cmp_ref(const uchar *ref1, const uchar *ref2)
{
return memcmp(ref1, ref2, ref_length);
}
@@ -1648,18 +1648,18 @@
{ return COMPATIBLE_DATA_NO; }
/* These are only called from sql_select for internal temporary tables */
- virtual int write_row(byte *buf __attribute__((unused)))
+ virtual int write_row(uchar *buf __attribute__((unused)))
{
return HA_ERR_WRONG_COMMAND;
}
- virtual int update_row(const byte *old_data __attribute__((unused)),
- byte *new_data __attribute__((unused)))
+ virtual int update_row(const uchar *old_data __attribute__((unused)),
+ uchar *new_data __attribute__((unused)))
{
return HA_ERR_WRONG_COMMAND;
}
- virtual int delete_row(const byte *buf __attribute__((unused)))
+ virtual int delete_row(const uchar *buf __attribute__((unused)))
{
return HA_ERR_WRONG_COMMAND;
}
@@ -1752,7 +1752,7 @@
/* discovery */
int ha_create_table_from_engine(THD* thd, const char *db, const char *name);
int ha_discover(THD* thd, const char* dbname, const char* name,
- const void** frmblob, uint* frmlen);
+ uchar** frmblob, size_t* frmlen);
int ha_find_files(THD *thd,const char *db,const char *path,
const char *wild, bool dir,List<char>* files);
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
--- 1.396/sql/item_func.cc 2007-05-24 20:48:33 +04:00
+++ 1.397/sql/item_func.cc 2007-06-01 12:12:02 +04:00
@@ -36,7 +36,6 @@
#define sp_restore_security_context(A,B) while (0) {}
#endif
-
bool check_reserved_words(LEX_STRING *name)
{
if (!my_strcasecmp(system_charset_info, name->str, "GLOBAL") ||
@@ -4453,7 +4452,7 @@
> set @a:=1;
> insert into t1 values (@a), (@a:=@a+1), (@a:=@a+1);
We have to write to binlog value @a= 1.
-
+
We allocate the user_var_event on user_var_events_alloc pool, not on
the this-statement-execution pool because in SPs user_var_event objects
may need to be valid after current [SP] statement execution pool is
@@ -4463,7 +4462,7 @@
if (!(user_var_event= (BINLOG_USER_VAR_EVENT *)
alloc_root(thd->user_var_events_alloc, size)))
goto err;
-
+
user_var_event->value= (char*) user_var_event +
ALIGN_SIZE(sizeof(BINLOG_USER_VAR_EVENT));
user_var_event->user_var_event= var_entry;
@@ -4485,7 +4484,7 @@
var_entry->used_query_id= thd->query_id;
if (insert_dynamic(&thd->user_var_events, (uchar*) &user_var_event))
goto err;
-
+
*out_entry= var_entry;
return 0;
@@ -4494,7 +4493,6 @@
return 1;
}
-
void Item_func_get_user_var::fix_length_and_dec()
{
THD *thd=current_thd;
@@ -4505,10 +4503,19 @@
error= get_var_with_binlog(thd, thd->lex->sql_command, name, &var_entry);
+ /*
+ If the variable didn't exist it has been created as a STRING-type.
+ 'var_entry' is NULL only if there occured an error during the call to
+ get_var_with_binlog.
+ */
if (var_entry)
{
+ m_cached_result_type= var_entry->type;
+ unsigned_flag= var_entry->unsigned_flag;
+ max_length= var_entry->length;
+
collation.set(var_entry->collation);
- switch (var_entry->type) {
+ switch(m_cached_result_type) {
case REAL_RESULT:
max_length= DBL_DIG + 8;
break;
@@ -4533,6 +4540,8 @@
{
collation.set(&my_charset_bin, DERIVATION_IMPLICIT);
null_value= 1;
+ m_cached_result_type= STRING_RESULT;
+ max_length= MAX_BLOB_WIDTH;
}
if (error)
@@ -4550,12 +4559,7 @@
enum Item_result Item_func_get_user_var::result_type() const
{
- user_var_entry *entry;
- if (!(entry = (user_var_entry*) hash_search(¤t_thd->user_vars,
- (uchar*) name.str,
- name.length)))
- return STRING_RESULT;
- return entry->type;
+ return m_cached_result_type;
}
--- 1.169/sql/item_func.h 2007-05-24 14:24:28 +04:00
+++ 1.170/sql/item_func.h 2007-06-01 11:43:51 +04:00
@@ -1256,11 +1256,12 @@
private Settable_routine_parameter
{
user_var_entry *var_entry;
+ Item_result m_cached_result_type;
public:
LEX_STRING name; // keep it public
Item_func_get_user_var(LEX_STRING a):
- Item_func(), name(a) {}
+ Item_func(), m_cached_result_type(STRING_RESULT), name(a) {}
enum Functype functype() const { return GUSERVAR_FUNC; }
LEX_STRING get_name() { return name; }
double val_real();
@@ -1274,13 +1275,11 @@
We must always return variables as strings to guard against selects of type
select @t1:=1,@t1,@t:="hello",@t from foo where (@t1:= t2.b)
*/
- enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
const char *func_name() const { return "get_user_var"; }
bool const_item() const;
table_map used_tables() const
{ return const_item() ? 0 : RAND_TABLE_BIT; }
bool eq(const Item *item, bool binary_cmp) const;
-
private:
bool set_value(THD *thd, sp_rcontext *ctx, Item **it);
--- 1.279/sql/log_event.cc 2007-05-24 02:39:20 +04:00
+++ 1.280/sql/log_event.cc 2007-06-01 11:43:51 +04:00
@@ -1462,20 +1462,31 @@
/*
- Query_log_event::Query_log_event()
+ SYNOPSIS
+ Query_log_event::Query_log_event()
+ thd - thread handle
+ query_arg - array of char representing the query
+ query_length - size of the `query_arg' array
+ using_trans - there is a modified transactional table
+ suppress_use - suppress the generation of 'USE' statements
+ killed_status_arg - an optional with default to THD::KILLED_NO_VALUE
+ if the value is different from the default, the arg
+ is set to the current thd->killed value.
+ A caller might need to masquerade thd->killed with
+ THD::NOT_KILLED.
+ DESCRIPTION
+ Creates an event for binlogging
+ The value for local `killed_status' can be supplied by caller.
*/
Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
ulong query_length, bool using_trans,
- bool suppress_use)
+ bool suppress_use, THD::killed_state killed_status_arg)
:Log_event(thd_arg,
((thd_arg->tmp_table_used ? LOG_EVENT_THREAD_SPECIFIC_F : 0)
| (suppress_use ? LOG_EVENT_SUPPRESS_USE_F : 0)),
using_trans),
data_buf(0), query(query_arg), catalog(thd_arg->catalog),
db(thd_arg->db), q_len((uint32) query_length),
- error_code((thd_arg->killed != THD::NOT_KILLED) ?
- ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ?
- 0 : thd->killed_errno()) : thd_arg->net.last_errno),
thread_id(thd_arg->thread_id),
/* save the original thread id; we already know the server id */
slave_proxy_id(thd_arg->variables.pseudo_thread_id),
@@ -1487,6 +1498,14 @@
charset_database_number(0)
{
time_t end_time;
+
+ if (killed_status_arg == THD::KILLED_NO_VALUE)
+ killed_status_arg= thd_arg->killed;
+ error_code=
+ (killed_status_arg == THD::NOT_KILLED) ? thd_arg->net.last_errno :
+ ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 :
+ thd->killed_errno());
+
time(&end_time);
exec_time = (ulong) (end_time - thd->start_time);
catalog_len = (catalog) ? (uint32) strlen(catalog) : 0;
@@ -6742,10 +6761,23 @@
lex->duplicates flag.
*/
thd->lex->sql_command= SQLCOM_REPLACE;
-
- table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); // Needed for ndbcluster
- table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE); // Needed for ndbcluster
- table->file->extra(HA_EXTRA_IGNORE_NO_KEY); // Needed for ndbcluster
+ /*
+ Do not raise the error flag in case of hitting to an unique attribute
+ */
+ table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
+ /*
+ NDB specific: update from ndb master wrapped as Write_rows
+ */
+ /*
+ so that the event should be applied to replace slave's row
+ */
+ table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
+ /*
+ NDB specific: if update from ndb master wrapped as Write_rows
+ does not find the row it's assumed idempotent binlog applying
+ is taking place; don't raise the error.
+ */
+ table->file->extra(HA_EXTRA_IGNORE_NO_KEY);
/*
TODO: the cluster team (Tomas?) says that it's better if the engine knows
how many rows are going to be inserted, then it can allocate needed memory
@@ -6773,9 +6805,20 @@
int Write_rows_log_event::do_after_row_operations(TABLE *table, int error)
{
- if (error == 0)
- error= table->file->ha_end_bulk_insert();
- return error;
+ int local_error= 0;
+ table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
+ table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
+ /*
+ reseting the extra with
+ table->file->extra(HA_EXTRA_NO_IGNORE_NO_KEY);
+ fires bug#27077
+ todo: explain or fix
+ */
+ if ((local_error= table->file->ha_end_bulk_insert()))
+ {
+ table->file->print_error(local_error, MYF(0));
+ }
+ return error? error : local_error;
}
int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
--- 1.150/sql/log_event.h 2007-05-10 13:59:28 +04:00
+++ 1.151/sql/log_event.h 2007-06-01 11:43:52 +04:00
@@ -1023,7 +1023,8 @@
#ifndef MYSQL_CLIENT
Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
- bool using_trans, bool suppress_use);
+ bool using_trans, bool suppress_use,
+ THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE);
const char* get_db() { return db; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
--- 1.510/sql/mysql_priv.h 2007-05-24 02:39:20 +04:00
+++ 1.511/sql/mysql_priv.h 2007-06-01 11:43:52 +04:00
@@ -962,33 +962,26 @@
longlong table_flags);
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
- List<create_field> &fields, List<Key> &keys,
- bool tmp_table, uint select_field_count,
- bool use_copy_create_info);
+ Alter_info *alter_info,
+ bool tmp_table, uint select_field_count);
bool mysql_create_table_no_lock(THD *thd, const char *db,
const char *table_name,
HA_CREATE_INFO *create_info,
- List<create_field> &fields, List<Key> &keys,
- bool tmp_table, uint select_field_count,
- bool use_copy_create_info);
+ Alter_info *alter_info,
+ bool tmp_table, uint select_field_count);
bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
- List<create_field> &fields,
- List<Key> &keys,
- uint order_num, ORDER *order, bool ignore,
- ALTER_INFO *alter_info, bool do_send_ok);
-bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok);
+ Alter_info *alter_info,
+ uint order_num, ORDER *order, bool ignore);
+bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list);
bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
- HA_CREATE_INFO *create_info,
- Table_ident *src_table);
+ TABLE_LIST *src_table,
+ HA_CREATE_INFO *create_info);
bool mysql_rename_table(handlerton *base, const char *old_db,
const char * old_name, const char *new_db,
const char * new_name, uint flags);
-bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys);
-bool mysql_drop_index(THD *thd, TABLE_LIST *table_list,
- ALTER_INFO *alter_info);
bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
Item **conds, uint order_num, ORDER *order);
int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
@@ -1034,8 +1027,11 @@
bool lock_table_name_if_not_cached(THD *thd, const char *db,
const char *table_name, TABLE **table);
TABLE *find_locked_table(THD *thd, const char *db,const char *table_name);
+bool reopen_table(TABLE *table);
bool reopen_tables(THD *thd,bool get_locks,bool in_refresh);
-bool close_data_tables(THD *thd,const char *db, const char *table_name);
+void close_data_files_and_morph_locks(THD *thd, const char *db,
+ const char *table_name);
+void close_handle_and_leave_table_as_lock(TABLE *table);
bool wait_for_tables(THD *thd);
bool table_is_used(TABLE *table, bool wait_for_name_lock);
TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name);
@@ -1309,14 +1305,13 @@
#ifdef WITH_PARTITION_STORAGE_ENGINE
uint fast_alter_partition_table(THD *thd, TABLE *table,
- ALTER_INFO *alter_info,
+ Alter_info *alter_info,
HA_CREATE_INFO *create_info,
TABLE_LIST *table_list,
- List<create_field> *create_list,
- List<Key> *key_list, char *db,
+ char *db,
const char *table_name,
uint fast_alter_partition);
-uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info,
+uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
HA_CREATE_INFO *create_info,
handlerton *old_db_type,
bool *partition_changed,
@@ -1348,11 +1343,7 @@
ulonglong deleted;
THD *thd;
HA_CREATE_INFO *create_info;
- ALTER_INFO *alter_info;
- List<create_field> *create_list;
- List<create_field> new_create_list;
- List<Key> *key_list;
- List<Key> new_key_list;
+ Alter_info *alter_info;
TABLE *table;
KEY *key_info_buffer;
const char *db;
@@ -1678,7 +1669,7 @@
extern my_bool opt_log_queries_not_using_indexes;
extern bool opt_disable_networking, opt_skip_show_db;
extern my_bool opt_character_set_client_handshake;
-extern bool volatile abort_loop, shutdown_in_progress, grant_option;
+extern bool volatile abort_loop, shutdown_in_progress;
extern uint volatile thread_count, thread_running, global_read_lock;
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
--- 1.156/client/mysqlbinlog.cc 2007-05-10 13:59:20 +04:00
+++ 1.157/client/mysqlbinlog.cc 2007-06-01 11:43:50 +04:00
@@ -635,6 +635,7 @@
print_event_info->common_header_len=
glob_description_event->common_header_len;
ev->print(result_file, print_event_info);
+ ev->temp_buf= 0; // as the event ref is zeroed
/*
We don't want this event to be deleted now, so let's hide it (I
(Guilhem) should later see if this triggers a non-serious Valgrind
@@ -682,8 +683,16 @@
end:
rec_count++;
+ /*
+ Destroy the log_event object. If reading from a remote host,
+ set the temp_buf to NULL so that memory isn't freed twice.
+ */
if (ev)
+ {
+ if (remote_opt)
+ ev->temp_buf= 0;
delete ev;
+ }
DBUG_RETURN(0);
}
@@ -1172,6 +1181,12 @@
error= 1;
goto err;
}
+ /*
+ If reading from a remote host, ensure the temp_buf for the
+ Log_event class is pointing to the incoming stream.
+ */
+ if (remote_opt)
+ ev->register_temp_buf((char*) net->read_pos + 1);
Log_event_type type= ev->get_type_code();
if (glob_description_event->binlog_version >= 3 ||
--- 1.646/sql/mysqld.cc 2007-05-24 14:24:28 +04:00
+++ 1.647/sql/mysqld.cc 2007-06-01 11:43:52 +04:00
@@ -351,7 +351,15 @@
my_bool locked_in_memory;
bool opt_using_transactions, using_update_log;
bool volatile abort_loop;
-bool volatile shutdown_in_progress, grant_option;
+bool volatile shutdown_in_progress;
+/**
+ @brief 'grant_option' is used to indicate if privileges needs
+ to be checked, in which case the lock, LOCK_grant, is used
+ to protect access to the grant table.
+ @note This flag is dropped in 5.1
+ @see grant_init()
+ */
+bool volatile grant_option;
my_bool opt_skip_slave_start = 0; // If set, slave is not autostarted
my_bool opt_reckless_slave = 0;
--- 1.235/sql/sql_acl.cc 2007-05-10 13:59:29 +04:00
+++ 1.236/sql/sql_acl.cc 2007-06-01 11:43:53 +04:00
@@ -3137,7 +3137,6 @@
}
}
}
- grant_option=TRUE;
thd->mem_root= old_root;
pthread_mutex_unlock(&acl_cache->lock);
@@ -3311,7 +3310,6 @@
continue;
}
}
- grant_option=TRUE;
thd->mem_root= old_root;
pthread_mutex_unlock(&acl_cache->lock);
if (!result && !no_error)
@@ -3459,7 +3457,6 @@
void grant_free(void)
{
DBUG_ENTER("grant_free");
- grant_option = FALSE;
hash_free(&column_priv_hash);
hash_free(&proc_priv_hash);
hash_free(&func_priv_hash);
@@ -3523,7 +3520,6 @@
THR_MALLOC);
DBUG_ENTER("grant_load");
- grant_option = FALSE;
(void) hash_init(&column_priv_hash,system_charset_info,
0,0,0, (hash_get_key) get_grant_table,
(hash_free_key) free_grant_table,0);
@@ -3553,7 +3549,6 @@
if (!(mem_check=new (memex_ptr) GRANT_TABLE(t_table,c_table)))
{
/* This could only happen if we are out memory */
- grant_option= FALSE;
goto end_unlock;
}
@@ -3576,7 +3571,6 @@
else if (my_hash_insert(&column_priv_hash,(uchar*) mem_check))
{
delete mem_check;
- grant_option= FALSE;
goto end_unlock;
}
}
@@ -3593,7 +3587,6 @@
if (!(mem_check=new (&memex) GRANT_NAME(p_table)))
{
/* This could only happen if we are out memory */
- grant_option= FALSE;
goto end_unlock;
}
@@ -3632,13 +3625,11 @@
else if (my_hash_insert(hash, (uchar*) mem_check))
{
delete mem_check;
- grant_option= FALSE;
goto end_unlock;
}
}
while (!p_table->file->index_next(p_table->record[0]));
}
- grant_option= TRUE;
return_val=0; // Return ok
end_unlock:
@@ -3671,7 +3662,6 @@
{
TABLE_LIST tables[3];
HASH old_column_priv_hash, old_proc_priv_hash, old_func_priv_hash;
- bool old_grant_option;
MEM_ROOT old_mem;
my_bool return_val= 1;
DBUG_ENTER("grant_reload");
@@ -3701,7 +3691,6 @@
old_column_priv_hash= column_priv_hash;
old_proc_priv_hash= proc_priv_hash;
old_func_priv_hash= func_priv_hash;
- old_grant_option= grant_option;
old_mem= memex;
if ((return_val= grant_load(tables)))
@@ -3711,7 +3700,6 @@
column_priv_hash= old_column_priv_hash; /* purecov: deadcode */
proc_priv_hash= old_proc_priv_hash;
func_priv_hash= old_func_priv_hash;
- grant_option= old_grant_option; /* purecov: deadcode */
memex= old_mem; /* purecov: deadcode */
}
else
@@ -4008,8 +3996,6 @@
want_access &= ~grant->privilege;
if (!want_access)
return 0; // Already checked
- if (!grant_option)
- goto err2;
rw_rdlock(&LOCK_grant);
@@ -4040,7 +4026,6 @@
err:
rw_unlock(&LOCK_grant);
-err2:
char command[128];
get_privilege_desc(command, sizeof(command), want_access);
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
@@ -4199,18 +4184,15 @@
bool is_proc)
{
bool no_routine_acl= 1;
- if (grant_option)
- {
- GRANT_NAME *grant_proc;
- Security_context *sctx= thd->security_ctx;
- rw_rdlock(&LOCK_grant);
- if ((grant_proc= routine_hash_search(sctx->priv_host,
- sctx->ip, db,
- sctx->priv_user,
- name, is_proc, 0)))
- no_routine_acl= !(grant_proc->privs & SHOW_PROC_ACLS);
- rw_unlock(&LOCK_grant);
- }
+ GRANT_NAME *grant_proc;
+ Security_context *sctx= thd->security_ctx;
+ rw_rdlock(&LOCK_grant);
+ if ((grant_proc= routine_hash_search(sctx->priv_host,
+ sctx->ip, db,
+ sctx->priv_user,
+ name, is_proc, 0)))
+ no_routine_acl= !(grant_proc->privs & SHOW_PROC_ACLS);
+ rw_unlock(&LOCK_grant);
return no_routine_acl;
}
@@ -6403,12 +6385,6 @@
/* db privileges */
grant->privilege|= acl_get(sctx->host, sctx->ip, sctx->priv_user, db, 0);
-
- if (!grant_option)
- {
- DBUG_PRINT("info", ("privilege 0x%lx", grant->privilege));
- DBUG_VOID_RETURN;
- }
/* table privileges */
rw_rdlock(&LOCK_grant);
--- 1.405/sql/sql_base.cc 2007-05-24 20:47:54 +04:00
+++ 1.406/sql/sql_base.cc 2007-06-01 11:43:53 +04:00
@@ -99,7 +99,6 @@
TABLE_LIST *table_desc, MEM_ROOT *mem_root);
static void close_old_data_files(THD *thd, TABLE *table, bool morph_locks,
bool send_refresh);
-static bool reopen_table(TABLE *table);
static bool
has_two_write_locked_tables_with_auto_increment(TABLE_LIST *tables);
@@ -681,7 +680,7 @@
*/
-static void close_handle_and_leave_table_as_lock(TABLE *table)
+void close_handle_and_leave_table_as_lock(TABLE *table)
{
TABLE_SHARE *share, *old_share= table->s;
char *key_buff;
@@ -2393,10 +2392,17 @@
VOID(pthread_mutex_unlock(&LOCK_open));
}
}
- if ((thd->locked_tables) && (thd->locked_tables->lock_count > 0))
- my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias);
- else
+ /*
+ No table in the locked tables list. In case of explicit LOCK TABLES
+ this can happen if a user did not include the able into the list.
+ In case of pre-locked mode locked tables list is generated automatically,
+ so we may only end up here if the table did not exist when
+ locked tables list was created.
+ */
+ if (thd->prelocked_mode == PRELOCKED)
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias);
+ else
+ my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias);
DBUG_RETURN(0);
}
@@ -2705,7 +2711,7 @@
1 error. The old table object is not changed.
*/
-static bool reopen_table(TABLE *table)
+bool reopen_table(TABLE *table)
{
TABLE tmp;
bool error= 1;
@@ -2788,27 +2794,55 @@
}
-/*
- Used with ALTER TABLE:
- Close all instanses of table when LOCK TABLES is in used;
- Close first all instances of table and then reopen them
+/**
+ @brief Close all instances of a table open by this thread and replace
+ them with exclusive name-locks.
+
+ @param thd Thread context
+ @param db Database name for the table to be closed
+ @param table_name Name of the table to be closed
+
+ @note This function assumes that if we are not under LOCK TABLES,
+ then there is only one table open and locked. This means that
+ the function probably has to be adjusted before it can be used
+ anywhere outside ALTER TABLE.
*/
-bool close_data_tables(THD *thd,const char *db, const char *table_name)
+void close_data_files_and_morph_locks(THD *thd, const char *db,
+ const char *table_name)
{
TABLE *table;
- DBUG_ENTER("close_data_tables");
+ DBUG_ENTER("close_data_files_and_morph_locks");
+
+ safe_mutex_assert_owner(&LOCK_open);
+ if (thd->lock)
+ {
+ /*
+ If we are not under LOCK TABLES we should have only one table
+ open and locked so it makes sense to remove the lock at once.
+ */
+ mysql_unlock_tables(thd, thd->lock);
+ thd->lock= 0;
+ }
+
+ /*
+ Note that open table list may contain a name-lock placeholder
+ for target table name if we process ALTER TABLE ... RENAME.
+ So loop below makes sense even if we are not under LOCK TABLES.
+ */
for (table=thd->open_tables; table ; table=table->next)
{
if (!strcmp(table->s->table_name.str, table_name) &&
!strcmp(table->s->db.str, db))
{
- mysql_lock_remove(thd, thd->locked_tables,table);
+ if (thd->locked_tables)
+ mysql_lock_remove(thd, thd->locked_tables, table);
+ table->open_placeholder= 1;
close_handle_and_leave_table_as_lock(table);
}
}
- DBUG_RETURN(0); // For the future
+ DBUG_VOID_RETURN;
}
--- 1.111/sql/sql_cache.cc 2007-05-23 15:04:47 +04:00
+++ 1.112/sql/sql_cache.cc 2007-06-01 12:12:02 +04:00
@@ -365,7 +365,7 @@
inline Query_cache_block * Query_cache_block_table::block()
{
- return (Query_cache_block *)(((byte*)this) -
+ return (Query_cache_block *)(((uchar*)this) -
ALIGN_SIZE(sizeof(Query_cache_block_table)*n) -
ALIGN_SIZE(sizeof(Query_cache_block)));
}
@@ -401,9 +401,9 @@
ALIGN_SIZE(sizeof(Query_cache_block)));
}
-inline gptr Query_cache_block::data(void)
+inline uchar* Query_cache_block::data(void)
{
- return (gptr)( ((byte*)this) + headers_len() );
+ return (uchar*)( ((uchar*)this) + headers_len() );
}
inline Query_cache_query * Query_cache_block::query()
@@ -437,7 +437,7 @@
inline Query_cache_block_table * Query_cache_block::table(TABLE_COUNTER_TYPE n)
{
return ((Query_cache_block_table *)
- (((byte*)this)+ALIGN_SIZE(sizeof(Query_cache_block)) +
+ (((uchar*)this)+ALIGN_SIZE(sizeof(Query_cache_block)) +
n*sizeof(Query_cache_block_table)));
}
@@ -448,13 +448,13 @@
extern "C"
{
-byte *query_cache_table_get_key(const byte *record, uint *length,
+uchar *query_cache_table_get_key(const uchar *record, size_t *length,
my_bool not_used __attribute__((unused)))
{
Query_cache_block* table_block = (Query_cache_block*) record;
*length = (table_block->used - table_block->headers_len() -
ALIGN_SIZE(sizeof(Query_cache_table)));
- return (((byte *) table_block->data()) +
+ return (((uchar *) table_block->data()) +
ALIGN_SIZE(sizeof(Query_cache_table)));
}
}
@@ -522,7 +522,7 @@
my_rwlock_init(&lock, NULL);
lock_writing();
DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
- (long) (((byte*) this) -
+ (long) (((uchar*) this) -
ALIGN_SIZE(sizeof(Query_cache_block)))));
DBUG_VOID_RETURN;
}
@@ -532,7 +532,7 @@
{
DBUG_ENTER("Query_cache_query::unlock_n_destroy");
DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx",
- (long) (((byte*) this) -
+ (long) (((uchar*) this) -
ALIGN_SIZE(sizeof(Query_cache_block)))));
/*
The following call is not needed on system where one can destroy an
@@ -546,13 +546,13 @@
extern "C"
{
-byte *query_cache_query_get_key(const byte *record, uint *length,
+uchar *query_cache_query_get_key(const uchar *record, size_t *length,
my_bool not_used)
{
Query_cache_block *query_block = (Query_cache_block*) record;
*length = (query_block->used - query_block->headers_len() -
ALIGN_SIZE(sizeof(Query_cache_query)));
- return (((byte *) query_block->data()) +
+ return (((uchar *) query_block->data()) +
ALIGN_SIZE(sizeof(Query_cache_query)));
}
}
@@ -639,7 +639,7 @@
done by query_cache.append_result_data if success (if not we need
query_cache.structure_guard_mutex locked to free query)
*/
- if (!query_cache.append_result_data(&result, length, (gptr) packet,
+ if (!query_cache.append_result_data(&result, length, (uchar*) packet,
query_block))
{
DBUG_PRINT("warning", ("Can't append data"));
@@ -946,13 +946,13 @@
/* Check if another thread is processing the same query? */
Query_cache_block *competitor = (Query_cache_block *)
- hash_search(&queries, (byte*) thd->query, tot_length);
+ hash_search(&queries, (uchar*) thd->query, tot_length);
DBUG_PRINT("qcache", ("competitor 0x%lx", (ulong) competitor));
if (competitor == 0)
{
/* Query is not in cache and no one is working with it; Store it */
Query_cache_block *query_block;
- query_block= write_block_data(tot_length, (gptr) thd->query,
+ query_block= write_block_data(tot_length, (uchar*) thd->query,
ALIGN_SIZE(sizeof(Query_cache_query)),
Query_cache_block::QUERY, local_tables, 1);
if (query_block != 0)
@@ -962,7 +962,7 @@
Query_cache_query *header = query_block->query();
header->init_n_lock();
- if (my_hash_insert(&queries, (byte*) query_block))
+ if (my_hash_insert(&queries, (uchar*) query_block))
{
refused++;
DBUG_PRINT("qcache", ("insertion in query hash"));
@@ -975,7 +975,7 @@
{
refused++;
DBUG_PRINT("warning", ("tables list including failed"));
- hash_delete(&queries, (byte *) query_block);
+ hash_delete(&queries, (uchar *) query_block);
header->unlock_n_destroy();
free_memory_block(query_block);
STRUCT_UNLOCK(&structure_guard_mutex);
@@ -984,7 +984,7 @@
double_linked_list_simple_include(query_block, &queries_blocks);
inserts++;
queries_in_cache++;
- net->query_cache_query= (gptr) query_block;
+ net->query_cache_query= (uchar*) query_block;
header->writer(net);
header->tables_type(tables_type);
@@ -1154,9 +1154,9 @@
flags.group_concat_max_len,
flags.div_precision_increment,
flags.default_week_format));
- memcpy((void *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
- &flags, QUERY_CACHE_FLAGS_SIZE);
- query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql,
+ memcpy((uchar *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
+ (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE);
+ query_block = (Query_cache_block *) hash_search(&queries, (uchar*) sql,
tot_length);
/* Quick abort on unlocked data */
if (query_block == 0 ||
@@ -1267,7 +1267,7 @@
("Handler require invalidation queries of %s.%s %lu-%lu",
table_list.db, table_list.alias,
(ulong) engine_data, (ulong) table->engine_data()));
- invalidate_table((byte *) table->db(), table->key_length());
+ invalidate_table((uchar *) table->db(), table->key_length());
}
else
thd->lex->safe_to_cache_query= 0; // Don't try to cache this
@@ -1371,7 +1371,7 @@
DUMP(this);
for (; tables_used; tables_used= tables_used->next)
{
- invalidate_table((byte*) tables_used->key, tables_used->key_length);
+ invalidate_table((uchar*) tables_used->key, tables_used->key_length);
DBUG_PRINT("qcache", ("db: %s table: %s", tables_used->key,
tables_used->key+
strlen(tables_used->key)+1));
@@ -1452,7 +1452,7 @@
if (using_transactions) // used for innodb => has_transactions() is TRUE
thd->add_changed_table(key, key_length);
else
- invalidate_table((byte*)key, key_length);
+ invalidate_table((uchar*)key, key_length);
}
STRUCT_UNLOCK(&structure_guard_mutex);
@@ -1513,8 +1513,8 @@
uint key_length= filename_2_table_key(key, filename, &db_length);
Query_cache_block *table_block;
if ((table_block = (Query_cache_block*) hash_search(&tables,
- (byte*) key,
- key_length)))
+ (uchar*) key,
+ key_length)))
invalidate_table(table_block);
}
STRUCT_UNLOCK(&structure_guard_mutex);
@@ -1601,7 +1601,7 @@
DBUG_ENTER("Query_cache::init_cache");
approx_additional_data_size = (sizeof(Query_cache) +
- sizeof(gptr)*(def_query_hash_size+
+ sizeof(uchar*)*(def_query_hash_size+
def_table_hash_size));
if (query_cache_size < approx_additional_data_size)
goto err;
@@ -1657,7 +1657,7 @@
goto err;
query_cache_size -= additional_data_size;
- if (!(cache= (byte *)
+ if (!(cache= (uchar *)
my_malloc_lock(query_cache_size+additional_data_size, MYF(0))))
goto err;
@@ -1796,7 +1796,7 @@
{
DBUG_ENTER("Query_cache::free_cache");
- my_free((gptr) cache, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((uchar*) cache, MYF(MY_ALLOW_ZERO_PTR));
make_disabled();
hash_free(&queries);
hash_free(&tables);
@@ -1999,7 +1999,7 @@
(ulong) query_block,
query_block->query()->length() ));
- hash_delete(&queries,(byte *) query_block);
+ hash_delete(&queries,(uchar *) query_block);
free_query_internal(query_block);
DBUG_VOID_RETURN;
@@ -2010,7 +2010,7 @@
*****************************************************************************/
Query_cache_block *
-Query_cache::write_block_data(ulong data_len, gptr data,
+Query_cache::write_block_data(ulong data_len, uchar* data,
ulong header_len,
Query_cache_block::block_type type,
TABLE_COUNTER_TYPE ntab,
@@ -2033,8 +2033,7 @@
block->n_tables = ntab;
block->used = len;
- memcpy((void*) (((byte *) block)+ all_headers_len),
- (void*) data, data_len);
+ memcpy((uchar *) block+ all_headers_len, data, data_len);
}
DBUG_RETURN(block);
}
@@ -2046,7 +2045,7 @@
my_bool
Query_cache::append_result_data(Query_cache_block **current_block,
- ulong data_len, gptr data,
+ ulong data_len, uchar* data,
Query_cache_block *query_block)
{
DBUG_ENTER("Query_cache::append_result_data");
@@ -2102,7 +2101,7 @@
by the next call
*/
success = write_result_data(&new_block, data_len-last_block_free_space,
- (gptr)(((byte*)data)+last_block_free_space),
+ (uchar*)(((uchar*)data)+last_block_free_space),
query_block,
Query_cache_block::RES_CONT);
/*
@@ -2124,8 +2123,7 @@
ulong to_copy = min(data_len,last_block_free_space);
DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
last_block_free_space, (ulong)last_block, to_copy));
- memcpy((void*) (((byte*) last_block) + last_block->used), (void*) data,
- to_copy);
+ memcpy((uchar*) last_block + last_block->used, data, to_copy);
last_block->used+=to_copy;
}
DBUG_RETURN(success);
@@ -2133,7 +2131,7 @@
my_bool Query_cache::write_result_data(Query_cache_block **result_block,
- ulong data_len, gptr data,
+ ulong data_len, uchar* data,
Query_cache_block *query_block,
Query_cache_block::block_type type)
{
@@ -2159,7 +2157,7 @@
ALIGN_SIZE(sizeof(Query_cache_result)));
#ifndef EMBEDDED_LIBRARY
Query_cache_block *block= *result_block;
- byte *rest= (byte*) data;
+ uchar *rest= data;
// Now fill list of blocks that created by allocate_data_chain
do
{
@@ -2167,7 +2165,7 @@
ulong length = block->used - headers_len;
DBUG_PRINT("qcache", ("write %lu byte in block 0x%lx",length,
(ulong)block));
- memcpy((void*)(((byte*) block)+headers_len), (void*) rest, length);
+ memcpy((uchar*) block+headers_len, rest, length);
rest += length;
block = block->next;
type = Query_cache_block::RES_CONT;
@@ -2302,18 +2300,18 @@
// We don't store temporary tables => no key_length+=4 ...
if ((table_block = (Query_cache_block*)
- hash_search(&tables,(byte*) key,key_length)))
+ hash_search(&tables,(uchar*) key,key_length)))
invalidate_table(table_block);
}
}
void Query_cache::invalidate_table(TABLE *table)
{
- invalidate_table((byte*) table->s->table_cache_key.str,
+ invalidate_table((uchar*) table->s->table_cache_key.str,
table->s->table_cache_key.length);
}
-void Query_cache::invalidate_table(byte * key, uint32 key_length)
+void Query_cache::invalidate_table(uchar * key, uint32 key_length)
{
Query_cache_block *table_block;
if ((table_block = ((Query_cache_block*)
@@ -2391,11 +2389,11 @@
else
{
DBUG_PRINT("qcache",
- ("table: %s db: %s openinfo: 0x%lx keylen: %u key: 0x%lx",
+ ("table: %s db: %s openinfo: 0x%lx keylen: %lu key: 0x%lx",
tables_used->table->s->table_name.str,
tables_used->table->s->table_cache_key.str,
(ulong) tables_used->table,
- tables_used->table->s->table_cache_key.length,
+ (ulong) tables_used->table->s->table_cache_key.length,
(ulong) tables_used->table->s->table_cache_key.str));
if (!insert_table(tables_used->table->s->table_cache_key.length,
tables_used->table->s->table_cache_key.str,
@@ -2492,7 +2490,7 @@
(ulong)node, key_len));
Query_cache_block *table_block = ((Query_cache_block *)
- hash_search(&tables, (byte*) key,
+ hash_search(&tables, (uchar*) key,
key_len));
if (table_block &&
@@ -2516,7 +2514,7 @@
{
DBUG_PRINT("qcache", ("new table block from 0x%lx (%u)",
(ulong) key, (int) key_len));
- table_block = write_block_data(key_len, (gptr) key,
+ table_block = write_block_data(key_len, (uchar*) key,
ALIGN_SIZE(sizeof(Query_cache_table)),
Query_cache_block::TABLE,
1, 1);
@@ -2531,7 +2529,7 @@
Query_cache_block_table *list_root = table_block->table(0);
list_root->n = 0;
list_root->next = list_root->prev = list_root;
- if (my_hash_insert(&tables, (const byte *) table_block))
+ if (my_hash_insert(&tables, (const uchar *) table_block))
{
DBUG_PRINT("qcache", ("Can't insert table to hash"));
// write_block_data return locked block
@@ -2568,7 +2566,7 @@
Query_cache_block *table_block = neighbour->block();
double_linked_list_exclude(table_block,
&tables_blocks);
- hash_delete(&tables,(byte *) table_block);
+ hash_delete(&tables,(uchar *) table_block);
free_memory_block(table_block);
}
DBUG_VOID_RETURN;
@@ -2723,7 +2721,7 @@
void Query_cache::split_block(Query_cache_block *block, ulong len)
{
DBUG_ENTER("Query_cache::split_block");
- Query_cache_block *new_block = (Query_cache_block*)(((byte*) block)+len);
+ Query_cache_block *new_block = (Query_cache_block*)(((uchar*) block)+len);
new_block->init(block->length - len);
total_blocks++;
@@ -3156,7 +3154,7 @@
DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1););
- byte *border = 0;
+ uchar *border = 0;
Query_cache_block *before = 0;
ulong gap = 0;
my_bool ok = 1;
@@ -3192,7 +3190,7 @@
}
-my_bool Query_cache::move_by_type(byte **border,
+my_bool Query_cache::move_by_type(uchar **border,
Query_cache_block **before, ulong *gap,
Query_cache_block *block)
{
@@ -3205,7 +3203,7 @@
DBUG_PRINT("qcache", ("block 0x%lx FREE", (ulong) block));
if (*border == 0)
{
- *border = (byte *) block;
+ *border = (uchar *) block;
*before = block->pprev;
DBUG_PRINT("qcache", ("gap beginning here"));
}
@@ -3235,10 +3233,10 @@
*new_block =(Query_cache_block *) *border;
uint tablename_offset = block->table()->table() - block->table()->db();
char *data = (char*) block->data();
- byte *key;
- uint key_length;
- key=query_cache_table_get_key((byte*) block, &key_length, 0);
- hash_first(&tables, (byte*) key, key_length, &record_idx);
+ uchar *key;
+ size_t key_length;
+ key=query_cache_table_get_key((uchar*) block, &key_length, 0);
+ hash_first(&tables, (uchar*) key, key_length, &record_idx);
block->destroy();
new_block->init(len);
@@ -3272,7 +3270,7 @@
/* Fix pointer to table name */
new_block->table()->table(new_block->table()->db() + tablename_offset);
/* Fix hash to point at moved block */
- hash_replace(&tables, &record_idx, (byte*) new_block);
+ hash_replace(&tables, &record_idx, (uchar*) new_block);
DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx",
len, (ulong) new_block, (ulong) *border));
@@ -3295,10 +3293,10 @@
char *data = (char*) block->data();
Query_cache_block *first_result_block = ((Query_cache_query *)
block->data())->result();
- byte *key;
- uint key_length;
- key=query_cache_query_get_key((byte*) block, &key_length, 0);
- hash_first(&queries, (byte*) key, key_length, &record_idx);
+ uchar *key;
+ size_t key_length;
+ key=query_cache_query_get_key((uchar*) block, &key_length, 0);
+ hash_first(&queries, (uchar*) key, key_length, &record_idx);
// Move table of used tables
memmove((char*) new_block->table(0), (char*) block->table(0),
ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table)));
@@ -3314,7 +3312,7 @@
queries_blocks = new_block;
Query_cache_block_table *beg_of_table_table= block->table(0),
*end_of_table_table= block->table(n_tables);
- byte *beg_of_new_table_table= (byte*) new_block->table(0);
+ uchar *beg_of_new_table_table= (uchar*) new_block->table(0);
for (TABLE_COUNTER_TYPE j=0; j < n_tables; j++)
{
@@ -3324,8 +3322,8 @@
if ((beg_of_table_table <= block_table->next) &&
(block_table->next < end_of_table_table))
((Query_cache_block_table *)(beg_of_new_table_table +
- (((byte*)block_table->next) -
- ((byte*)beg_of_table_table))))->prev=
+ (((uchar*)block_table->next) -
+ ((uchar*)beg_of_table_table))))->prev=
block_table;
else
block_table->next->prev= block_table;
@@ -3334,8 +3332,8 @@
if ((beg_of_table_table <= block_table->prev) &&
(block_table->prev < end_of_table_table))
((Query_cache_block_table *)(beg_of_new_table_table +
- (((byte*)block_table->prev) -
- ((byte*)beg_of_table_table))))->next=
+ (((uchar*)block_table->prev) -
+ ((uchar*)beg_of_table_table))))->next=
block_table;
else
block_table->prev->next = block_table;
@@ -3363,10 +3361,10 @@
NET *net = new_block->query()->writer();
if (net != 0)
{
- net->query_cache_query= (gptr) new_block;
+ net->query_cache_query= (uchar*) new_block;
}
/* Fix hash to point at moved block */
- hash_replace(&queries, &record_idx, (byte*) new_block);
+ hash_replace(&queries, &record_idx, (uchar*) new_block);
DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx",
len, (ulong) new_block, (ulong) *border));
break;
@@ -3502,7 +3500,7 @@
Query_cache_result *new_result = new_result_block->result();
new_result->parent(block);
- byte *write_to = (byte*) new_result->data();
+ uchar *write_to = (uchar*) new_result->data();
Query_cache_block *result_block = first_result;
do
{
@@ -3686,18 +3684,18 @@
Query_cache_block *block = queries_blocks;
do
{
- uint len;
- char *str = (char*) query_cache_query_get_key((byte*) block, &len, 0);
+ size_t len;
+ char *str = (char*) query_cache_query_get_key((uchar*) block, &len, 0);
len-= QUERY_CACHE_FLAGS_SIZE; // Point at flags
Query_cache_query_flags flags;
memcpy(&flags, str+len, QUERY_CACHE_FLAGS_SIZE);
str[len]= 0; // make zero ending DB name
- DBUG_PRINT("qcache", ("F: %u C: %u L: %lu T: '%s' (%u) '%s' '%s'",
+ DBUG_PRINT("qcache", ("F: %u C: %u L: %lu T: '%s' (%lu) '%s' '%s'",
flags.client_long_flag,
flags.character_set_client_num,
(ulong)flags.limit,
flags.time_zone->get_name()->ptr(),
- len, str, strend(str)+1));
+ (ulong) len, str, strend(str)+1));
DBUG_PRINT("qcache", ("-b- 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx", (ulong) block,
(ulong) block->next, (ulong) block->prev,
(ulong)block->pnext, (ulong)block->pprev));
@@ -3811,25 +3809,25 @@
// Check memory allocation
if (block->pnext == first_block) // Is it last block?
{
- if (((byte*)block) + block->length !=
- ((byte*)first_block) + query_cache_size)
+ if (((uchar*)block) + block->length !=
+ ((uchar*)first_block) + query_cache_size)
{
DBUG_PRINT("error",
("block 0x%lx, type %u, ended at 0x%lx, but cache ended at 0x%lx",
(ulong) block, (uint) block->type,
- (ulong) (((byte*)block) + block->length),
- (ulong) (((byte*)first_block) + query_cache_size)));
+ (ulong) (((uchar*)block) + block->length),
+ (ulong) (((uchar*)first_block) + query_cache_size)));
result = 1;
}
}
else
- if (((byte*)block) + block->length != ((byte*)block->pnext))
+ if (((uchar*)block) + block->length != ((uchar*)block->pnext))
{
DBUG_PRINT("error",
("block 0x%lx, type %u, ended at 0x%lx, but next block begining at 0x%lx",
(ulong) block, (uint) block->type,
- (ulong) (((byte*)block) + block->length),
- (ulong) ((byte*)block->pnext)));
+ (ulong) (((uchar*)block) + block->length),
+ (ulong) ((uchar*)block->pnext)));
}
if (block->type == Query_cache_block::FREE)
free+= block->length;
@@ -3841,8 +3839,8 @@
Query_cache_memory_bin *bin = *((Query_cache_memory_bin **)
block->data());
//is it correct pointer?
- if (((byte*)bin) < ((byte*)bins) ||
- ((byte*)bin) >= ((byte*)first_block))
+ if (((uchar*)bin) < ((uchar*)bins) ||
+ ((uchar*)bin) >= ((uchar*)first_block))
{
DBUG_PRINT("error",
("free block 0x%lx have bin pointer 0x%lx beyaond of bins array bounds [0x%lx,0x%lx]",
@@ -3854,7 +3852,7 @@
}
else
{
- int idx = (((byte*)bin) - ((byte*)bins)) /
+ int idx = (((uchar*)bin) - ((uchar*)bins)) /
sizeof(Query_cache_memory_bin);
if (in_list(bins[idx].free_blocks, block, "free memory"))
result = 1;
@@ -3876,7 +3874,7 @@
Query_cache_block_table *block_table = block->table(j);
Query_cache_block_table *block_table_root =
(Query_cache_block_table *)
- (((byte*)block_table->parent) -
+ (((uchar*)block_table->parent) -
ALIGN_SIZE(sizeof(Query_cache_block_table)));
if (in_table_list(block_table, block_table_root, "table list"))
@@ -3892,15 +3890,15 @@
case Query_cache_block::RESULT:
{
Query_cache_block * query_block = block->result()->parent();
- if (((byte*)query_block) < ((byte*)first_block) ||
- ((byte*)query_block) >= (((byte*)first_block) + query_cache_size))
+ if (((uchar*)query_block) < ((uchar*)first_block) ||
+ ((uchar*)query_block) >= (((uchar*)first_block) + query_cache_size))
{
DBUG_PRINT("error",
("result block 0x%lx have query block pointer 0x%lx beyaond of block pool bounds [0x%lx,0x%lx]",
(ulong) block,
(ulong) query_block,
(ulong) first_block,
- (ulong) (((byte*)first_block) + query_cache_size)));
+ (ulong) (((uchar*)first_block) + query_cache_size)));
result = 1;
}
else
@@ -3947,10 +3945,10 @@
{
DBUG_PRINT("qcache", ("block 0x%lx, type %u...",
(ulong) block, (uint) block->type));
- uint length;
- byte *key = query_cache_query_get_key((byte*) block, &length, 0);
- gptr val = hash_search(&queries, key, length);
- if (((gptr)block) != val)
+ size_t length;
+ uchar *key = query_cache_query_get_key((uchar*) block, &length, 0);
+ uchar* val = hash_search(&queries, key, length);
+ if (((uchar*)block) != val)
{
DBUG_PRINT("error", ("block 0x%lx found in queries hash like 0x%lx",
(ulong) block, (ulong) val));
@@ -3982,10 +3980,10 @@
{
DBUG_PRINT("qcache", ("block 0x%lx, type %u...",
(ulong) block, (uint) block->type));
- uint length;
- byte *key = query_cache_table_get_key((byte*) block, &length, 0);
- gptr val = hash_search(&tables, key, length);
- if (((gptr)block) != val)
+ size_t length;
+ uchar *key = query_cache_table_get_key((uchar*) block, &length, 0);
+ uchar* val = hash_search(&tables, key, length);
+ if (((uchar*)block) != val)
{
DBUG_PRINT("error", ("block 0x%lx found in tables hash like 0x%lx",
(ulong) block, (ulong) val));
--- 1.336/sql/sql_class.cc 2007-05-31 18:45:16 +04:00
+++ 1.337/sql/sql_class.cc 2007-06-01 11:43:53 +04:00
@@ -91,6 +91,40 @@
return length == other.length && !strcmp(field_name, other.field_name);
}
+/**
+ Construct an (almost) deep copy of this key. Only those
+ elements that are known to never change are not copied.
+ If out of memory, a partial copy is returned and an error is set
+ in THD.
+*/
+
+Key::Key(const Key &rhs, MEM_ROOT *mem_root)
+ :type(rhs.type),
+ key_create_info(rhs.key_create_info),
+ columns(rhs.columns, mem_root),
+ name(rhs.name),
+ generated(rhs.generated)
+{
+ list_copy_and_replace_each_value(columns, mem_root);
+}
+
+/**
+ Construct an (almost) deep copy of this foreign key. Only those
+ elements that are known to never change are not copied.
+ If out of memory, a partial copy is returned and an error is set
+ in THD.
+*/
+
+foreign_key::foreign_key(const foreign_key &rhs, MEM_ROOT *mem_root)
+ :Key(rhs),
+ ref_table(rhs.ref_table),
+ ref_columns(rhs.ref_columns),
+ delete_opt(rhs.delete_opt),
+ update_opt(rhs.update_opt),
+ match_opt(rhs.match_opt)
+{
+ list_copy_and_replace_each_value(ref_columns, mem_root);
+}
/*
Test if a foreign key (= generated key) is a prefix of the given key
@@ -3026,9 +3060,9 @@
RETURN VALUE
Error code, or 0 if no error.
*/
-int THD::binlog_query(THD::enum_binlog_query_type qtype,
- char const *query, ulong query_len,
- bool is_trans, bool suppress_use)
+int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query,
+ ulong query_len, bool is_trans, bool suppress_use,
+ THD::killed_state killed_status_arg)
{
DBUG_ENTER("THD::binlog_query");
DBUG_PRINT("enter", ("qtype=%d, query='%s'", qtype, query));
@@ -3067,7 +3101,8 @@
flush the pending rows event if necessary.
*/
{
- Query_log_event qinfo(this, query, query_len, is_trans, suppress_use);
+ Query_log_event qinfo(this, query, query_len, is_trans, suppress_use,
+ killed_status_arg);
qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
/*
Binlog table maps will be irrelevant after a Query_log_event
--- 1.363/sql/sql_class.h 2007-05-24 02:39:22 +04:00
+++ 1.364/sql/sql_class.h 2007-06-01 11:43:53 +04:00
@@ -90,6 +90,17 @@
uint length;
key_part_spec(const char *name,uint len=0) :field_name(name), length(len) {}
bool operator==(const key_part_spec& other) const;
+ /**
+ Construct a copy of this key_part_spec. field_name is copied
+ by-pointer as it is known to never change. At the same time
+ 'length' may be reset in mysql_prepare_create_table, and this
+ is why we supply it with a copy.
+
+ @return If out of memory, 0 is returned and an error is set in
+ THD.
+ */
+ key_part_spec *clone(MEM_ROOT *mem_root) const
+ { return new (mem_root) key_part_spec(*this); }
};
@@ -100,6 +111,12 @@
enum drop_type type;
Alter_drop(enum drop_type par_type,const char *par_name)
:name(par_name), type(par_type) {}
+ /**
+ Used to make a clone of this object for ALTER/CREATE TABLE
+ @sa comment for key_part_spec::clone
+ */
+ Alter_drop *clone(MEM_ROOT *mem_root) const
+ { return new (mem_root) Alter_drop(*this); }
};
@@ -109,6 +126,12 @@
Item *def;
Alter_column(const char *par_name,Item *literal)
:name(par_name), def(literal) {}
+ /**
+ Used to make a clone of this object for ALTER/CREATE TABLE
+ @sa comment for key_part_spec::clone
+ */
+ Alter_column *clone(MEM_ROOT *mem_root) const
+ { return new (mem_root) Alter_column(*this); }
};
@@ -127,9 +150,16 @@
:type(type_par), key_create_info(*key_info_arg), columns(cols),
name(name_arg), generated(generated_arg)
{}
- ~Key() {}
+ Key(const Key &rhs, MEM_ROOT *mem_root);
+ virtual ~Key() {}
/* Equality comparison of keys (ignoring name) */
friend bool foreign_key_prefix(Key *a, Key *b);
+ /**
+ Used to make a clone of this object for ALTER/CREATE TABLE
+ @sa comment for key_part_spec::clone
+ */
+ virtual Key *clone(MEM_ROOT *mem_root) const
+ { return new (mem_root) Key(*this, mem_root); }
};
class Table_ident;
@@ -152,6 +182,13 @@
delete_opt(delete_opt_arg), update_opt(update_opt_arg),
match_opt(match_opt_arg)
{}
+ foreign_key(const foreign_key &rhs, MEM_ROOT *mem_root);
+ /**
+ Used to make a clone of this object for ALTER/CREATE TABLE
+ @sa comment for key_part_spec::clone
+ */
+ virtual Key *clone(MEM_ROOT *mem_root) const
+ { return new (mem_root) foreign_key(*this, mem_root); }
};
typedef struct st_mysql_lock
@@ -1068,32 +1105,6 @@
}
#endif /* MYSQL_CLIENT */
-#ifndef MYSQL_CLIENT
-public:
- enum enum_binlog_query_type {
- /*
- The query can be logged row-based or statement-based
- */
- ROW_QUERY_TYPE,
-
- /*
- The query has to be logged statement-based
- */
- STMT_QUERY_TYPE,
-
- /*
- The query represents a change to a table in the "mysql"
- database and is currently mapped to ROW_QUERY_TYPE.
- */
- MYSQL_QUERY_TYPE,
- QUERY_TYPE_COUNT
- };
-
- int binlog_query(enum_binlog_query_type qtype,
- char const *query, ulong query_len,
- bool is_trans, bool suppress_use);
-#endif
-
public:
struct st_transactions {
@@ -1348,7 +1359,14 @@
DYNAMIC_ARRAY user_var_events; /* For user variables replication */
MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
- enum killed_state { NOT_KILLED=0, KILL_BAD_DATA=1, KILL_CONNECTION=ER_SERVER_SHUTDOWN, KILL_QUERY=ER_QUERY_INTERRUPTED };
+ enum killed_state
+ {
+ NOT_KILLED=0,
+ KILL_BAD_DATA=1,
+ KILL_CONNECTION=ER_SERVER_SHUTDOWN,
+ KILL_QUERY=ER_QUERY_INTERRUPTED,
+ KILLED_NO_VALUE /* means neither of the states */
+ };
killed_state volatile killed;
/* scramble - random string sent to client on handshake */
@@ -1473,6 +1491,33 @@
void close_active_vio();
#endif
void awake(THD::killed_state state_to_set);
+
+#ifndef MYSQL_CLIENT
+ enum enum_binlog_query_type {
+ /*
+ The query can be logged row-based or statement-based
+ */
+ ROW_QUERY_TYPE,
+
+ /*
+ The query has to be logged statement-based
+ */
+ STMT_QUERY_TYPE,
+
+ /*
+ The query represents a change to a table in the "mysql"
+ database and is currently mapped to ROW_QUERY_TYPE.
+ */
+ MYSQL_QUERY_TYPE,
+ QUERY_TYPE_COUNT
+ };
+
+ int binlog_query(enum_binlog_query_type qtype,
+ char const *query, ulong query_len,
+ bool is_trans, bool suppress_use,
+ THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE);
+#endif
+
/*
For enter_cond() / exit_cond() to work the mutex must be got before
enter_cond(); this mutex is then released by exit_cond().
@@ -1599,7 +1644,8 @@
void end_statement();
inline int killed_errno() const
{
- return killed != KILL_BAD_DATA ? killed : 0;
+ killed_state killed_val; /* to cache the volatile 'killed' */
+ return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0;
}
inline void send_kill_message() const
{
@@ -1933,20 +1979,20 @@
class select_create: public select_insert {
ORDER *group;
TABLE_LIST *create_table;
- List<create_field> *extra_fields;
- List<Key> *keys;
HA_CREATE_INFO *create_info;
+ Alter_info *alter_info;
Field **field;
public:
- select_create (TABLE_LIST *table_arg,
- HA_CREATE_INFO *create_info_par,
- List<create_field> &fields_par,
- List<Key> &keys_par,
- List<Item> &select_fields,enum_duplicates duplic, bool ignore)
- :select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore),
- create_table(table_arg), extra_fields(&fields_par),keys(&keys_par),
- create_info(create_info_par)
- {}
+ select_create(TABLE_LIST *table_arg,
+ HA_CREATE_INFO *create_info_arg,
+ Alter_info *alter_info_arg,
+ List<Item> &select_fields,
+ enum_duplicates duplic, bool ignore)
+ :select_insert(NULL, NULL, &select_fields, 0, 0, duplic, ignore),
+ create_table(table_arg),
+ create_info(create_info_arg),
+ alter_info(alter_info_arg)
+ {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
void binlog_show_create_table(TABLE **tables, uint count);
--- 1.152/sql/sql_db.cc 2007-05-10 13:59:29 +04:00
+++ 1.153/sql/sql_db.cc 2007-06-01 11:43:53 +04:00
@@ -1445,7 +1445,7 @@
if (!force_switch &&
!(db_access & DB_ACLS) &&
- (!grant_option || check_grant_db(thd, new_db_file_name.str)))
+ check_grant_db(thd, new_db_file_name.str))
{
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
sctx->priv_user,
--- 1.272/sql/sql_insert.cc 2007-05-31 12:23:30 +04:00
+++ 1.273/sql/sql_insert.cc 2007-06-01 11:43:54 +04:00
@@ -1380,9 +1380,9 @@
goto err;
}
}
- key_copy((byte*) key,table->record[0],table->key_info+key_nr,0);
+ key_copy((uchar*) key,table->record[0],table->key_info+key_nr,0);
if ((error=(table->file->index_read_idx(table->record[1],key_nr,
- (byte*) key, HA_WHOLE_KEY,
+ (uchar*) key, HA_WHOLE_KEY,
HA_READ_KEY_EXACT))))
goto err;
}
@@ -1853,8 +1853,8 @@
thd->proc_info="got old table";
if (tmp->thd.killed)
{
- if (tmp->thd.net.report_error)
- {
+ if (tmp->thd.net.report_error)
+ {
/*
Copy the error message. Note that we don't treat fatal
errors in the delayed thread as fatal errors in the
@@ -1870,7 +1870,7 @@
if (thd->killed)
{
tmp->unlock();
- goto end_create;
+ goto end_create;
}
}
pthread_mutex_unlock(&LOCK_delayed_create);
@@ -1886,7 +1886,7 @@
}
/* Unlock the delayed insert object after its last access. */
tmp->unlock();
- DBUG_RETURN(table_list->table == NULL);
+ DBUG_RETURN((table_list->table == NULL));
end_create:
pthread_mutex_unlock(&LOCK_delayed_create);
@@ -1916,7 +1916,7 @@
Field **field,**org_field, *found_next_number_field;
TABLE *copy;
TABLE_SHARE *share= table->s;
- byte *bitmap;
+ uchar *bitmap;
DBUG_ENTER("Delayed_insert::get_local_table");
/* First request insert thread to get a lock */
@@ -1960,7 +1960,7 @@
/* We don't need to change the file handler here */
/* Assign the pointers for the field pointers array and the record. */
field= copy->field= (Field**) (copy + 1);
- bitmap= (byte*) (field + share->fields + 1);
+ bitmap= (uchar*) (field + share->fields + 1);
copy->record[0]= (bitmap + share->column_bitmap_size * 2);
memcpy((char*) copy->record[0], (char*) table->record[0], share->reclength);
/*
@@ -2029,7 +2029,8 @@
Delayed_insert *di=thd->di;
const Discrete_interval *forced_auto_inc;
DBUG_ENTER("write_delayed");
- DBUG_PRINT("enter", ("query = '%s' length %u", query.str, query.length));
+ DBUG_PRINT("enter", ("query = '%s' length %lu", query.str,
+ (ulong) query.length));
thd->proc_info="waiting for handler insert";
pthread_mutex_lock(&di->mutex);
@@ -2416,7 +2417,7 @@
{
if ((*ptr)->flags & BLOB_FLAG)
{
- char *str;
+ uchar *str;
((Field_blob *) (*ptr))->get_ptr(&str);
my_free(str,MYF(MY_ALLOW_ZERO_PTR));
((Field_blob *) (*ptr))->reset();
@@ -2478,8 +2479,9 @@
use values from the previous interval (of the previous rows).
*/
bool log_query= (row->log_query && row->query.str != NULL);
- DBUG_PRINT("delayed", ("query: '%s' length: %u", row->query.str ?
- row->query.str : "[NULL]", row->query.length));
+ DBUG_PRINT("delayed", ("query: '%s' length: %lu", row->query.str ?
+ row->query.str : "[NULL]",
+ (ulong) row->query.length));
if (log_query)
{
/*
@@ -2811,7 +2813,7 @@
while ((item= li++))
{
item->transform(&Item::update_value_transformer,
- (byte*)lex->current_select);
+ (uchar*)lex->current_select);
}
}
@@ -3286,7 +3288,6 @@
create_info, alter_info, 0,
select_field_count))
{
-
if (create_info->table_existed &&
!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
{
@@ -3328,7 +3329,6 @@
close_temporary_table(thd, create_table);
}
}
-
}
reenable_binlog(thd);
if (!table) // open failed
--- 1.243/sql/sql_lex.cc 2007-05-24 02:39:23 +04:00
+++ 1.244/sql/sql_lex.cc 2007-06-01 11:43:54 +04:00
@@ -1118,11 +1118,40 @@
}
+Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
+ :drop_list(rhs.drop_list, mem_root),
+ alter_list(rhs.alter_list, mem_root),
+ key_list(rhs.key_list, mem_root),
+ create_list(rhs.create_list, mem_root),
+ flags(rhs.flags),
+ keys_onoff(rhs.keys_onoff),
+ tablespace_op(rhs.tablespace_op),
+ partition_names(rhs.partition_names, mem_root),
+ no_parts(rhs.no_parts)
+{
+ /*
+ Make deep copies of used objects.
+ This is not a fully deep copy - clone() implementations
+ of Alter_drop, Alter_column, Key, foreign_key, key_part_spec
+ do not copy string constants. At the same length the only
+ reason we make a copy currently is that ALTER/CREATE TABLE
+ code changes input Alter_info definitions, but string
+ constants never change.
+ */
+ list_copy_and_replace_each_value(drop_list, mem_root);
+ list_copy_and_replace_each_value(alter_list, mem_root);
+ list_copy_and_replace_each_value(key_list, mem_root);
+ list_copy_and_replace_each_value(create_list, mem_root);
+ /* partition_names are not deeply copied currently */
+}
+
+
/*
Skip comment in the end of statement.
SYNOPSIS
skip_rear_comments()
+ cs character set
begin pointer to the beginning of statement
end pointer to the end of statement
@@ -1133,10 +1162,12 @@
Pointer to the last non-comment symbol of the statement.
*/
-const char *skip_rear_comments(const char *begin, const char *end)
+const char *skip_rear_comments(CHARSET_INFO *cs, const char *begin,
+ const char *end)
{
- while (begin < end && (end[-1] <= ' ' || end[-1] == '*' ||
- end[-1] == '/' || end[-1] == ';'))
+ while (begin < end && (end[-1] == '*' ||
+ end[-1] == '/' || end[-1] == ';' ||
+ my_isspace(cs, end[-1])))
end-= 1;
return end;
}
@@ -1786,8 +1817,6 @@
:result(0), yacc_yyss(0), yacc_yyvs(0),
sql_command(SQLCOM_END), option_type(OPT_DEFAULT)
{
- /* Check that plugins_static_buffer is declared immediately after plugins */
- compile_time_assert((&plugins + 1) == (DYNAMIC_ARRAY*)plugins_static_buffer);
my_init_dynamic_array2(&plugins, sizeof(plugin_ref),
plugins_static_buffer,
@@ -2381,3 +2410,22 @@
current_index_hint_clause,
str, length));
}
+
+/**
+ A routine used by the parser to decide whether we are specifying a full
+ partitioning or if only partitions to add or to split.
+
+ @note This needs to be outside of WITH_PARTITION_STORAGE_ENGINE since it
+ is used from the sql parser that doesn't have any #ifdef's
+
+ @retval TRUE Yes, it is part of a management partition command
+ @retval FALSE No, not a management partition command
+*/
+
+bool st_lex::is_partition_management() const
+{
+ return (sql_command == SQLCOM_ALTER_TABLE &&
+ (alter_info.flags == ALTER_ADD_PARTITION ||
+ alter_info.flags == ALTER_REORGANIZE_PARTITION));
+}
+
--- 1.280/sql/sql_lex.h 2007-05-30 00:52:15 +04:00
+++ 1.281/sql/sql_lex.h 2007-06-01 11:43:54 +04:00
@@ -221,7 +221,7 @@
Keep in sync with index_hint_type.
*/
extern const char * index_hint_type_name[];
-typedef byte index_clause_map;
+typedef uchar index_clause_map;
/*
Bits in index_clause_map : one for each possible FOR clause in
@@ -409,7 +409,7 @@
static void *operator new(size_t size)
{
- return (void*) sql_alloc((uint) size);
+ return sql_alloc(size);
}
static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); }
@@ -733,7 +733,7 @@
{
order_list.elements= 0;
order_list.first= 0;
- order_list.next= (byte**) &order_list.first;
+ order_list.next= (uchar**) &order_list.first;
}
/*
This method created for reiniting LEX in mysql_admin_table() and can be
@@ -947,7 +947,7 @@
in which it was right after query parsing.
*/
SQL_LIST sroutines_list;
- byte **sroutines_list_own_last;
+ uchar **sroutines_list_own_last;
uint sroutines_list_own_elements;
/*
@@ -1111,7 +1111,7 @@
LEX_STRING comment, ident;
LEX_USER *grant_user;
XID *xid;
- gptr yacc_yyss,yacc_yyvs;
+ uchar* yacc_yyss, *yacc_yyvs;
THD *thd;
/* maintain a list of used plugins for this LEX */
@@ -1400,7 +1400,7 @@
{
static void *operator new(size_t size)
{
- return (void*) sql_alloc((uint) size);
+ return sql_alloc(size);
}
static void *operator new(size_t size, MEM_ROOT *mem_root)
{
--- 1.47/sql/sql_list.h 2007-05-10 13:59:29 +04:00
+++ 1.48/sql/sql_list.h 2007-06-01 11:43:54 +04:00
@@ -1,3 +1,5 @@
+#ifndef INCLUDES_MYSQL_SQL_LIST_H
+#define INCLUDES_MYSQL_SQL_LIST_H
/* Copyright (C) 2000-2003 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -63,21 +65,24 @@
pointer.
*/
-class list_node :public Sql_alloc
+
+/**
+ list_node - a node of a single-linked list.
+ @note We never call a destructor for instances of this class.
+*/
+
+struct list_node :public Sql_alloc
{
-public:
list_node *next;
void *info;
list_node(void *info_par,list_node *next_par)
:next(next_par),info(info_par)
- {}
+ {}
list_node() /* For end_of_list */
- {
- info=0;
- next= this;
- }
- friend class base_list;
- friend class base_list_iterator;
+ {
+ info= 0;
+ next= this;
+ }
};
@@ -93,12 +98,28 @@
inline void empty() { elements=0; first= &end_of_list; last=&first;}
inline base_list() { empty(); }
+ /**
+ This is a shallow copy constructor that implicitly passes the ownership
+ from the source list to the new instance. The old instance is not
+ updated, so both objects end up sharing the same nodes. If one of
+ the instances then adds or removes a node, the other becomes out of
+ sync ('last' pointer), while still operational. Some old code uses and
+ relies on this behaviour. This logic is quite tricky: please do not use
+ it in any new code.
+ */
inline base_list(const base_list &tmp) :Sql_alloc()
{
elements= tmp.elements;
first= tmp.first;
last= elements ? tmp.last : &first;
}
+ /**
+ Construct a deep copy of the argument in memory root mem_root.
+ The elements themselves are copied by pointer. If you also
+ need to copy elements by value, you should employ
+ list_copy_and_replace_each_value after creating a copy.
+ */
+ base_list(const base_list &rhs, MEM_ROOT *mem_root);
inline base_list(bool error) { }
inline bool push_back(void *info)
{
@@ -185,6 +206,15 @@
elements+= list->elements;
}
}
+ /**
+ Swap two lists.
+ */
+ inline void swap(base_list &rhs)
+ {
+ swap_variables(list_node *, first, rhs.first);
+ swap_variables(list_node **, last, rhs.last);
+ swap_variables(uint, elements, rhs.elements);
+ }
inline list_node* last_node() { return *last; }
inline list_node* first_node() { return first;}
inline void *head() { return first->info; }
@@ -349,6 +379,8 @@
public:
inline List() :base_list() {}
inline List(const List<T> &tmp) :base_list(tmp) {}
+ inline List(const List<T> &tmp, MEM_ROOT *mem_root) :
+ base_list(tmp, mem_root) {}
inline bool push_back(T *a) { return base_list::push_back(a); }
inline bool push_back(T *a, MEM_ROOT *mem_root)
{ return base_list::push_back(a, mem_root); }
@@ -547,3 +579,32 @@
I_List_iterator(I_List<T> &a) : base_ilist_iterator(a) {}
inline T* operator++(int) { return (T*) base_ilist_iterator::next(); }
};
+
+/**
+ Make a deep copy of each list element.
+
+ @note A template function and not a template method of class List
+ is employed because of explicit template instantiation:
+ in server code there are explicit instantiations of List<T> and
+ an explicit instantiation of a template requires that any method
+ of the instantiated class used in the template can be resolved.
+ Evidently not all template arguments have clone() method with
+ the right signature.
+
+ @return You must query the error state in THD for out-of-memory
+ situation after calling this function.
+*/
+
+template <typename T>
+inline
+void
+list_copy_and_replace_each_value(List<T> &list, MEM_ROOT *mem_root)
+{
+ /* Make a deep copy of each element */
+ List_iterator<T> it(list);
+ T *el;
+ while ((el= it++))
+ it.replace(el->clone(mem_root));
+}
+
+#endif // INCLUDES_MYSQL_SQL_LIST_H
--- 1.127/sql/sql_load.cc 2007-05-28 11:26:44 +04:00
+++ 1.128/sql/sql_load.cc 2007-06-01 11:43:54 +04:00
@@ -25,7 +25,7 @@
class READ_INFO {
File file;
- byte *buffer, /* Buffer for read text */
+ uchar *buffer, /* Buffer for read text */
*end_of_buff; /* Data in bufferts ends here */
uint buff_length, /* Length of buffert */
max_length; /* Max length of row */
@@ -40,7 +40,7 @@
public:
bool error,line_cuted,found_null,enclosed;
- byte *row_start, /* Found row starts here */
+ uchar *row_start, /* Found row starts here */
*row_end; /* Found row ends here */
CHARSET_INFO *read_charset;
@@ -576,7 +576,7 @@
continue;
}
it.rewind();
- byte *pos=read_info.row_start;
+ uchar *pos=read_info.row_start;
#ifdef HAVE_purify
read_info.row_end[0]=0;
#endif
@@ -611,7 +611,7 @@
else
{
uint length;
- byte save_chr;
+ uchar save_chr;
if ((length=(uint) (read_info.row_end-pos)) >
field->field_length)
length=field->field_length;
@@ -705,7 +705,7 @@
while ((item= it++))
{
uint length;
- byte *pos;
+ uchar *pos;
if (read_info.read_field())
break;
@@ -914,7 +914,7 @@
set_if_bigger(length,line_start.length());
stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
- if (!(buffer=(byte*) my_malloc(buff_length+1,MYF(0))))
+ if (!(buffer=(uchar*) my_malloc(buff_length+1,MYF(0))))
error=1; /* purecov: inspected */
else
{
@@ -924,7 +924,7 @@
(is_fifo ? READ_FIFO : READ_CACHE),0L,1,
MYF(MY_WME)))
{
- my_free((gptr) buffer,MYF(0)); /* purecov: inspected */
+ my_free((uchar*) buffer,MYF(0)); /* purecov: inspected */
error=1;
}
else
@@ -955,7 +955,7 @@
{
if (need_end_io_cache)
::end_io_cache(&cache);
- my_free((gptr) buffer,MYF(0));
+ my_free((uchar*) buffer,MYF(0));
error=1;
}
}
@@ -988,7 +988,7 @@
int READ_INFO::read_field()
{
int chr,found_enclosed_char;
- byte *to,*new_buffer;
+ uchar *to,*new_buffer;
found_null=0;
if (found_end_of_line)
@@ -1011,7 +1011,7 @@
if (chr == enclosed_char)
{
found_enclosed_char=enclosed_char;
- *to++=(byte) chr; // If error
+ *to++=(uchar) chr; // If error
}
else
{
@@ -1053,7 +1053,7 @@
{
if ((chr=GET) == my_b_EOF)
{
- *to++= (byte) escape_char;
+ *to++= (uchar) escape_char;
goto found_eof;
}
/*
@@ -1065,7 +1065,7 @@
*/
if (escape_char != enclosed_char || chr == escape_char)
{
- *to++ = (byte) unescape((char) chr);
+ *to++ = (uchar) unescape((char) chr);
continue;
}
PUSH(chr);
@@ -1090,7 +1090,7 @@
{
if ((chr=GET) == found_enclosed_char)
{ // Remove dupplicated
- *to++ = (byte) chr;
+ *to++ = (uchar) chr;
continue;
}
// End of enclosed field if followed by field_term or line_term
@@ -1130,12 +1130,12 @@
return 0;
}
}
- *to++ = (byte) chr;
+ *to++ = (uchar) chr;
}
/*
** We come here if buffer is too small. Enlarge it and continue
*/
- if (!(new_buffer=(byte*) my_realloc((char*) buffer,buff_length+1+IO_SIZE,
+ if (!(new_buffer=(uchar*) my_realloc((char*) buffer,buff_length+1+IO_SIZE,
MYF(MY_WME))))
return (error=1);
to=new_buffer + (to-buffer);
@@ -1170,7 +1170,7 @@
int READ_INFO::read_fixed_length()
{
int chr;
- byte *to;
+ uchar *to;
if (found_end_of_line)
return 1; // One have to call next_line
@@ -1190,10 +1190,10 @@
{
if ((chr=GET) == my_b_EOF)
{
- *to++= (byte) escape_char;
+ *to++= (uchar) escape_char;
goto found_eof;
}
- *to++ =(byte) unescape((char) chr);
+ *to++ =(uchar) unescape((char) chr);
continue;
}
if (chr == line_term_char)
@@ -1205,7 +1205,7 @@
return 0;
}
}
- *to++ = (byte) chr;
+ *to++ = (uchar) chr;
}
row_end=to; // Found full line
return 0;
@@ -1236,7 +1236,7 @@
#ifdef USE_MB
if (my_mbcharlen(read_charset, chr) > 1)
{
- for (int i=1;
+ for (uint i=1;
chr != my_b_EOF && i<my_mbcharlen(read_charset, chr);
i++)
chr = GET;
--- 1.674/sql/sql_parse.cc 2007-05-30 19:34:23 +04:00
+++ 1.675/sql/sql_parse.cc 2007-06-01 11:43:54 +04:00
@@ -193,7 +193,7 @@
void init_update_queries(void)
{
- bzero((gptr) &sql_command_flags, sizeof(sql_command_flags));
+ bzero((uchar*) &sql_command_flags, sizeof(sql_command_flags));
sql_command_flags[SQLCOM_CREATE_TABLE]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_CREATE_INDEX]= CF_CHANGES_DATA;
@@ -372,8 +372,9 @@
continue;
thd->query_length=length;
- thd->query= thd->memdup_w_gap(buff, length+1,
- thd->db_length+1+QUERY_CACHE_FLAGS_SIZE);
+ thd->query= (char*) thd->memdup_w_gap(buff, length+1,
+ thd->db_length+1+
+ QUERY_CACHE_FLAGS_SIZE);
thd->query[length] = '\0';
DBUG_PRINT("query",("%-.4096s",thd->query));
/*
@@ -759,13 +760,13 @@
status_var_increment(thd->status_var.com_other);
thd->enable_slow_log= opt_log_slow_admin_statements;
- db.str= thd->alloc(db_len + tbl_len + 2);
- db.length= db_len;
+ db.str= (char*) thd->alloc(db_len + tbl_len + 2);
if (!db.str)
{
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
break;
}
+ db.length= db_len;
tbl_name= strmake(db.str, packet + 1, db_len)+1;
strmake(tbl_name, packet + db_len + 2, tbl_len);
mysql_table_dump(thd, &db, tbl_name);
@@ -853,8 +854,8 @@
if (save_user_connect)
decrease_user_connections(save_user_connect);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
- x_free((gptr) save_db);
- x_free((gptr) save_security_ctx.user);
+ x_free((uchar*) save_db);
+ x_free((uchar*) save_security_ctx.user);
}
break;
}
@@ -951,7 +952,7 @@
/* Locked closure of all tables */
TABLE_LIST table_list;
LEX_STRING conv_name;
- uint dummy;
+ size_t dummy;
/* used as fields initializator */
lex_start(thd);
@@ -978,7 +979,7 @@
}
thd->query_length= (uint) (packet_end - packet); // Don't count end \0
- if (!(thd->query=fields=thd->memdup(packet,thd->query_length+1)))
+ if (!(thd->query=fields= (char*) thd->memdup(packet,thd->query_length+1)))
break;
general_log_print(thd, command, "%s %s", table_list.table_name, fields);
if (lower_case_table_names)
@@ -996,8 +997,8 @@
mysql_reset_thd_for_next_command(thd);
thd->lex->
- select_lex.table_list.link_in_list((byte*) &table_list,
- (byte**) &table_list.next_local);
+ select_lex.table_list.link_in_list((uchar*) &table_list,
+ (uchar**) &table_list.next_local);
thd->lex->add_to_query_tables(&table_list);
/* switch on VIEW optimisation: do not fill temporary tables */
@@ -1189,7 +1190,7 @@
}
#endif
#ifndef EMBEDDED_LIBRARY
- VOID(my_net_write(net, buff, length));
+ VOID(my_net_write(net, (uchar*) buff, length));
VOID(net_flush(net));
#endif
break;
@@ -1386,7 +1387,7 @@
#else
{
LEX_STRING db;
- uint dummy;
+ size_t dummy;
if (lex->select_lex.db == NULL &&
thd->copy_db_to(&lex->select_lex.db, &dummy))
{
@@ -1487,7 +1488,7 @@
}
/* We must allocate some extra memory for query cache */
thd->query_length= 0; // Extra safety: Avoid races
- if (!(thd->query= (char*) thd->memdup_w_gap((gptr) (packet),
+ if (!(thd->query= (char*) thd->memdup_w_gap((uchar*) (packet),
packet_length,
thd->db_length+ 1 +
QUERY_CACHE_FLAGS_SIZE)))
@@ -1951,7 +1952,7 @@
goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements;
res = mysql_backup_table(thd, first_table);
- select_lex->table_list.first= (byte*) first_table;
+ select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
break;
}
@@ -1963,7 +1964,7 @@
goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements;
res = mysql_restore_table(thd, first_table);
- select_lex->table_list.first= (byte*) first_table;
+ select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
break;
}
@@ -2509,7 +2510,7 @@
thd->query, thd->query_length, 0, FALSE);
}
}
- select_lex->table_list.first= (byte*) first_table;
+ select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
break;
}
@@ -2520,7 +2521,7 @@
goto error; /* purecov: inspected */
thd->enable_slow_log= opt_log_slow_admin_statements;
res = mysql_check_table(thd, first_table, &lex->check_opt);
- select_lex->table_list.first= (byte*) first_table;
+ select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
break;
}
@@ -2544,7 +2545,7 @@
thd->query, thd->query_length, 0, FALSE);
}
}
- select_lex->table_list.first= (byte*) first_table;
+ select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
break;
}
@@ -2571,7 +2572,7 @@
thd->query, thd->query_length, 0, FALSE);
}
}
- select_lex->table_list.first= (byte*) first_table;
+ select_lex->table_list.first= (uchar*) first_table;
lex->query_tables=all_tables;
break;
}
@@ -2737,7 +2738,7 @@
{
/* Skip first table, which is the table we are inserting in */
TABLE_LIST *second_table= first_table->next_local;
- select_lex->table_list.first= (byte*) second_table;
+ select_lex->table_list.first= (uchar*) second_table;
select_lex->context.table_list=
select_lex->context.first_name_resolution_table= second_table;
res= mysql_insert_select_prepare(thd);
@@ -2770,7 +2771,7 @@
delete sel_result;
}
/* revert changes for SP */
- select_lex->table_list.first= (byte*) first_table;
+ select_lex->table_list.first= (uchar*) first_table;
}
/*
@@ -5039,7 +5040,7 @@
- Passing to check_stack_overrun() prevents the compiler from removing it.
*/
bool check_stack_overrun(THD *thd, long margin,
- char *buf __attribute__((unused)))
+ uchar *buf __attribute__((unused)))
{
long stack_used;
DBUG_ASSERT(thd == current_thd);
@@ -5071,19 +5072,19 @@
if (!lex->yacc_yyvs)
old_info= *yystacksize;
*yystacksize= set_zone((*yystacksize)*2,MY_YACC_INIT,MY_YACC_MAX);
- if (!(lex->yacc_yyvs= (char*)
- my_realloc((gptr) lex->yacc_yyvs,
+ if (!(lex->yacc_yyvs= (uchar*)
+ my_realloc(lex->yacc_yyvs,
*yystacksize*sizeof(**yyvs),
MYF(MY_ALLOW_ZERO_PTR | MY_FREE_ON_ERROR))) ||
- !(lex->yacc_yyss= (char*)
- my_realloc((gptr) lex->yacc_yyss,
+ !(lex->yacc_yyss= (uchar*)
+ my_realloc(lex->yacc_yyss,
*yystacksize*sizeof(**yyss),
MYF(MY_ALLOW_ZERO_PTR | MY_FREE_ON_ERROR))))
return 1;
if (old_info)
{ // Copy old info from stack
- memcpy(lex->yacc_yyss, (gptr) *yyss, old_info*sizeof(**yyss));
- memcpy(lex->yacc_yyvs, (gptr) *yyvs, old_info*sizeof(**yyvs));
+ memcpy(lex->yacc_yyss, (uchar*) *yyss, old_info*sizeof(**yyss));
+ memcpy(lex->yacc_yyvs, (uchar*) *yyvs, old_info*sizeof(**yyvs));
}
*yyss=(short*) lex->yacc_yyss;
*yyvs=(YYSTYPE*) lex->yacc_yyvs;
@@ -5570,7 +5571,7 @@
*item_ptr= item;
order->item=item_ptr;
order->free_me=0;
- thd->lex->proc_list.link_in_list((byte*) order,(byte**) &order->next);
+ thd->lex->proc_list.link_in_list((uchar*) order,(uchar**) &order->next);
return 0;
}
@@ -5592,7 +5593,7 @@
order->free_me=0;
order->used=0;
order->counter_used= 0;
- list.link_in_list((byte*) order,(byte**) &order->next);
+ list.link_in_list((uchar*) order,(uchar**) &order->next);
DBUG_RETURN(0);
}
@@ -5657,7 +5658,7 @@
ER(ER_DERIVED_MUST_HAVE_ALIAS), MYF(0));
DBUG_RETURN(0);
}
- if (!(alias_str=thd->memdup(alias_str,table->table.length+1)))
+ if (!(alias_str= (char*) thd->memdup(alias_str,table->table.length+1)))
DBUG_RETURN(0);
}
if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
@@ -5744,7 +5745,7 @@
previous table reference to 'ptr'. Here we also add one element to the
list 'table_list'.
*/
- table_list.link_in_list((byte*) ptr, (byte**) &ptr->next_local);
+ table_list.link_in_list((uchar*) ptr, (uchar**) &ptr->next_local);
ptr->next_name_resolution_table= NULL;
/* Link table in global list (all used tables) */
lex->add_to_query_tables(ptr);
@@ -5783,7 +5784,7 @@
sizeof(NESTED_JOIN))))
DBUG_RETURN(1);
nested_join= ptr->nested_join=
- ((NESTED_JOIN*) ((byte*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST))));
+ ((NESTED_JOIN*) ((uchar*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST))));
join_list->push_front(ptr);
ptr->embedding= embedding;
@@ -5869,7 +5870,7 @@
sizeof(NESTED_JOIN))))
DBUG_RETURN(0);
nested_join= ptr->nested_join=
- ((NESTED_JOIN*) ((byte*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST))));
+ ((NESTED_JOIN*) ((uchar*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST))));
ptr->embedding= embedding;
ptr->join_list= join_list;
@@ -6462,7 +6463,7 @@
/* Fix is using unix filename format on dos */
strmov(buff,*filename_ptr);
end=convert_dirname(buff, *filename_ptr, NullS);
- if (!(ptr=thd->alloc((uint) (end-buff)+(uint) strlen(table_name)+1)))
+ if (!(ptr= (char*) thd->alloc((size_t) (end-buff) + strlen(table_name)+1)))
return 1; // End of memory
*filename_ptr=ptr;
strxmov(ptr,buff,table_name,NullS);
--- 1.522/sql/sql_select.cc 2007-05-24 02:39:25 +04:00
+++ 1.523/sql/sql_select.cc 2007-06-01 11:43:55 +04:00
@@ -6288,8 +6288,7 @@
join->thd->server_status|=SERVER_QUERY_NO_GOOD_INDEX_USED;
tab->read_first_record= join_init_quick_read_record;
if (statistics)
- statistic_increment(join->thd->status_var.select_range_check_count,
- &LOCK_status);
+ status_var_increment(join->thd->status_var.select_range_check_count);
}
else
{
@@ -6299,15 +6298,13 @@
if (tab->select && tab->select->quick)
{
if (statistics)
- statistic_increment(join->thd->status_var.select_range_count,
- &LOCK_status);
+ status_var_increment(join->thd->status_var.select_range_count);
}
else
{
join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
if (statistics)
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
+ status_var_increment(join->thd->status_var.select_scan_count);
}
}
else
@@ -6315,15 +6312,13 @@
if (tab->select && tab->select->quick)
{
if (statistics)
- statistic_increment(join->thd->status_var.select_full_range_join_count,
- &LOCK_status);
+ status_var_increment(join->thd->status_var.select_full_range_join_count);
}
else
{
join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
if (statistics)
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
+ status_var_increment(join->thd->status_var.select_full_join_count);
}
}
if (!table->no_keyread)
@@ -9382,7 +9377,7 @@
(int) distinct, (int) save_sum_fields,
(ulong) rows_limit,test(group)));
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
+ status_var_increment(thd->status_var.created_tmp_tables);
if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
temp_pool_slot = bitmap_lock_set_next(&temp_pool);
@@ -10254,8 +10249,7 @@
table->db_stat=0;
goto err;
}
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
+ status_var_increment(table->in_use->status_var.created_tmp_disk_tables);
share->db_record_offset= 1;
DBUG_RETURN(0);
err:
--- 1.413/sql/sql_show.cc 2007-05-24 02:39:25 +04:00
+++ 1.414/sql/sql_show.cc 2007-06-01 11:43:55 +04:00
@@ -706,7 +706,7 @@
else
db_access= (acl_get(sctx->host, sctx->ip, sctx->priv_user, dbname, 0) |
sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
+ if (!(db_access & DB_ACLS) && check_grant_db(thd,dbname))
{
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
sctx->priv_user, sctx->host_or_ip, dbname);
@@ -2649,7 +2649,7 @@
&thd->col_access, 0, 1, with_i_schema) ||
sctx->master_access & (DB_ACLS | SHOW_DB_ACL) ||
acl_get(sctx->host, sctx->ip, sctx->priv_user, base_name,0) ||
- (grant_option && !check_grant_db(thd, base_name)))
+ !check_grant_db(thd, base_name))
#endif
{
List<char> files;
@@ -2849,7 +2849,7 @@
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (sctx->master_access & (DB_ACLS | SHOW_DB_ACL) ||
acl_get(sctx->host, sctx->ip, sctx->priv_user, file_name,0) ||
- (grant_option && !check_grant_db(thd, file_name)))
+ !check_grant_db(thd, file_name))
#endif
{
load_db_opt_by_name(thd, file_name, &create);
--- 1.422/sql/sql_table.cc 2007-05-28 16:31:12 +04:00
+++ 1.423/sql/sql_table.cc 2007-06-01 12:12:02 +04:00
@@ -319,11 +319,11 @@
{
bool error= FALSE;
File file_id= global_ddl_log.file_id;
- char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
+ uchar *file_entry_buf= (uchar*)global_ddl_log.file_entry_buf;
uint io_size= global_ddl_log.io_size;
DBUG_ENTER("read_ddl_log_file_entry");
- if (my_pread(file_id, (byte*)file_entry_buf, io_size, io_size * entry_no,
+ if (my_pread(file_id, file_entry_buf, io_size, io_size * entry_no,
MYF(MY_WME)) != io_size)
error= TRUE;
DBUG_RETURN(error);
@@ -347,7 +347,7 @@
char *file_entry_buf= (char*)global_ddl_log.file_entry_buf;
DBUG_ENTER("write_ddl_log_file_entry");
- if (my_pwrite(file_id, (byte*)file_entry_buf,
+ if (my_pwrite(file_id, (uchar*)file_entry_buf,
IO_SIZE, IO_SIZE * entry_no, MYF(MY_WME)) != IO_SIZE)
error= TRUE;
DBUG_RETURN(error);
@@ -560,7 +560,9 @@
int error= TRUE;
char to_path[FN_REFLEN];
char from_path[FN_REFLEN];
+#ifdef WITH_PARTITION_STORAGE_ENGINE
char *par_ext= (char*)".par";
+#endif
handlerton *hton;
DBUG_ENTER("execute_ddl_log_action");
@@ -1143,13 +1145,13 @@
while (used_list)
{
DDL_LOG_MEMORY_ENTRY *tmp= used_list->next_log_entry;
- my_free((char*)used_list, MYF(0));
+ my_free(used_list, MYF(0));
used_list= tmp;
}
while (free_list)
{
DDL_LOG_MEMORY_ENTRY *tmp= free_list->next_log_entry;
- my_free((char*)free_list, MYF(0));
+ my_free(free_list, MYF(0));
free_list= tmp;
}
close_ddl_log();
@@ -1268,13 +1270,13 @@
handlers that have the main version of the frm file stored in the
handler.
*/
- const void *data= 0;
- uint length= 0;
+ uchar *data;
+ size_t length;
if (readfrm(shadow_path, &data, &length) ||
packfrm(data, length, &lpt->pack_frm_data, &lpt->pack_frm_len))
{
- my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*)lpt->pack_frm_data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(lpt->pack_frm_data, MYF(MY_ALLOW_ZERO_PTR));
mem_alloc_error(length);
error= 1;
goto end;
@@ -2926,7 +2928,7 @@
DBUG_RETURN(TRUE);
}
/* Sort keys in optimized order */
- qsort((gptr) *key_info_buffer, *key_count, sizeof(KEY),
+ qsort((uchar*) *key_info_buffer, *key_count, sizeof(KEY),
(qsort_cmp) sort_keys);
create_info->null_bits= null_fields;
@@ -3478,7 +3480,7 @@
/* Wait for any database locks */
pthread_mutex_lock(&LOCK_lock_db);
while (!thd->killed &&
- hash_search(&lock_db_cache,(byte*) db, strlen(db)))
+ hash_search(&lock_db_cache,(uchar*) db, strlen(db)))
{
wait_for_condition(thd, &LOCK_lock_db, &COND_refresh);
pthread_mutex_lock(&LOCK_lock_db);
@@ -4021,7 +4023,7 @@
table->next_global= 0;
save_next_local= table->next_local;
table->next_local= 0;
- select->table_list.first= (byte*)table;
+ select->table_list.first= (uchar*)table;
/*
Time zone tables and SP tables can be add to lex->query_tables list,
so it have to be prepared.
@@ -6438,7 +6440,7 @@
{
/* Close the intermediate table that will be the new table */
intern_close_table(new_table);
- my_free((gptr) new_table,MYF(0));
+ my_free(new_table,MYF(0));
}
VOID(pthread_mutex_lock(&LOCK_open));
if (error)
@@ -6619,7 +6621,7 @@
if (t_table)
{
intern_close_table(t_table);
- my_free((char*) t_table, MYF(0));
+ my_free(t_table, MYF(0));
}
else
sql_print_warning("Could not open table %s.%s after rename\n",
@@ -6815,7 +6817,7 @@
copy_ptr->do_copy(copy_ptr);
}
prev_insert_id= to->file->next_insert_id;
- error=to->file->write_row((byte*) to->record[0]);
+ error=to->file->write_row(to->record[0]);
to->auto_increment_field_not_null= FALSE;
if (error)
{
@@ -6996,10 +6998,10 @@
{
String tmp;
f->val_str(&tmp);
- row_crc= my_checksum(row_crc, (byte*) tmp.ptr(), tmp.length());
+ row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(), tmp.length());
}
else
- row_crc= my_checksum(row_crc, (byte*) f->ptr,
+ row_crc= my_checksum(row_crc, f->ptr,
f->pack_length());
}
--- 1.53/sql/sql_test.cc 2007-05-10 13:59:30 +04:00
+++ 1.54/sql/sql_test.cc 2007-06-01 11:43:55 +04:00
@@ -508,7 +508,9 @@
display_table_locks();
fflush(stdout);
my_checkmalloc();
+ fprintf(stdout,"\nBegin safemalloc memory dump:\n"); // tag needed for test suite
TERMINATE(stdout); // Write malloc information
+ fprintf(stdout,"\nEnd safemalloc memory dump.\n");
#ifdef HAVE_MALLINFO
struct mallinfo info= mallinfo();
--- 1.241/sql/sql_update.cc 2007-05-24 02:39:26 +04:00
+++ 1.242/sql/sql_update.cc 2007-06-01 11:43:55 +04:00
@@ -621,6 +621,37 @@
thd->row_count++;
}
dup_key_found= 0;
+
+ /*
+ todo bug#27571: to avoid asynchronization of `error' and
+ `error_code' of binlog event constructor
+
+ The concept, which is a bit different for insert(!), is to
+ replace `error' assignment with the following lines
+
+ killed_status= thd->killed; // get the status of the volatile
+
+ Notice: thd->killed is type of "state" whereas the lhs has
+ "status" the suffix which translates according to WordNet: a state
+ at a particular time - at the time of the end of per-row loop in
+ our case. Binlogging ops are conducted with the status.
+
+ error= (killed_status == THD::NOT_KILLED)? error : 1;
+
+ which applies to most mysql_$query functions.
+ Event's constructor will accept `killed_status' as an argument:
+
+ Query_log_event qinfo(..., killed_status);
+
+ thd->killed might be changed after killed_status had got cached and this
+ won't affect binlogging event but other effects remain.
+
+ Open issue: In a case the error happened not because of KILLED -
+ and then KILLED was caught later still within the loop - we shall
+ do something to avoid binlogging of incorrect ER_SERVER_SHUTDOWN
+ error_code.
+ */
+
if (thd->killed && !error)
error= 1; // Aborted
else if (will_batch &&
@@ -936,7 +967,7 @@
if (check_access(thd, want_privilege,
tl->db, &tl->grant.privilege, 0, 0,
test(tl->schema_table)) ||
- (grant_option && check_grant(thd, want_privilege, tl, 0, 1, 0)))
+ check_grant(thd, want_privilege, tl, 0, 1, 0))
DBUG_RETURN(TRUE);
}
}
--- 1.572/sql/sql_yacc.yy 2007-05-28 15:29:57 +04:00
+++ 1.573/sql/sql_yacc.yy 2007-06-01 11:43:56 +04:00
@@ -4332,10 +4332,10 @@
lex->create_info.merge_list= lex->select_lex.table_list;
lex->create_info.merge_list.elements--;
lex->create_info.merge_list.first=
- (byte*) (table_list->next_local);
+ (uchar*) (table_list->next_local);
lex->select_lex.table_list.elements=1;
lex->select_lex.table_list.next=
- (byte**) &(table_list->next_local);
+ (uchar**) &(table_list->next_local);
table_list->next_local= 0;
lex->create_info.used_fields|= HA_CREATE_USED_UNION;
}
@@ -5570,10 +5570,10 @@
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
- uint dummy;
+ size_t dummy;
lex->select_lex.db=$3->db.str;
if (lex->select_lex.db == NULL &&
- thd->copy_db_to(&lex->select_lex.db, &dummy))
+ thd->copy_db_to(&lex->select_lex.db, &dummy))
{
MYSQL_YYABORT;
}
@@ -7979,7 +7979,7 @@
}
lex->proc_list.elements=0;
lex->proc_list.first=0;
- lex->proc_list.next= (byte**) &lex->proc_list.first;
+ lex->proc_list.next= (uchar**) &lex->proc_list.first;
if (add_proc_to_list(lex->thd, new Item_field(&lex->
current_select->
context,
@@ -9550,8 +9550,9 @@
Let us add this item to list of all Item_trigger_field objects
in trigger.
*/
- lex->trg_table_fields.link_in_list((byte *)trg_fld,
- (byte**)&trg_fld->next_trg_field);
+ lex->trg_table_fields.link_in_list((uchar*) trg_fld,
+ (uchar**) &trg_fld->
+ next_trg_field);
$$= (Item *)trg_fld;
}
@@ -10179,7 +10180,8 @@
else
qbuff.length= lip->tok_end - sp->m_tmp_query;
- if (!(qbuff.str= alloc_root(thd->mem_root, qbuff.length + 5)))
+ if (!(qbuff.str= (char*) alloc_root(thd->mem_root,
+ qbuff.length + 5)))
MYSQL_YYABORT;
strmake(strmake(qbuff.str, "SET ", 4), sp->m_tmp_query,
@@ -10265,8 +10267,9 @@
Let us add this item to list of all Item_trigger_field
objects in trigger.
*/
- lex->trg_table_fields.link_in_list((byte *)trg_fld,
- (byte **)&trg_fld->next_trg_field);
+ lex->trg_table_fields.link_in_list((uchar *)trg_fld,
+ (uchar **) &trg_fld->
+ next_trg_field);
lex->sphead->add_instr(sp_fld);
}
@@ -10839,7 +10842,7 @@
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
- uint dummy;
+ size_t dummy;
if (thd->copy_db_to(&lex->current_select->db, &dummy))
MYSQL_YYABORT;
if (lex->grant == GLOBAL_ACLS)
--- 1.35/sql/event_queue.cc 2007-05-23 02:19:32 +04:00
+++ 1.36/sql/event_queue.cc 2007-06-01 11:43:51 +04:00
@@ -53,7 +53,7 @@
*/
static int
-event_queue_element_compare_q(void *vptr, byte* a, byte *b)
+event_queue_element_compare_q(void *vptr, uchar* a, uchar *b)
{
my_time_t lhs = ((Event_queue_element *)a)->execute_at;
my_time_t rhs = ((Event_queue_element *)b)->execute_at;
@@ -195,7 +195,7 @@
DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element));
LOCK_QUEUE_DATA();
- *created= (queue_insert_safe(&queue, (byte *) new_element) == FALSE);
+ *created= (queue_insert_safe(&queue, (uchar *) new_element) == FALSE);
dbug_dump_queue(thd->query_start());
pthread_cond_broadcast(&COND_queue_state);
UNLOCK_QUEUE_DATA();
@@ -244,7 +244,7 @@
if (new_element)
{
DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element));
- queue_insert_safe(&queue, (byte *) new_element);
+ queue_insert_safe(&queue, (uchar *) new_element);
pthread_cond_broadcast(&COND_queue_state);
}
--- 1.100/sql/event_data_objects.cc 2007-05-24 02:39:17 +04:00
+++ 1.101/sql/event_data_objects.cc 2007-06-01 11:43:51 +04:00
@@ -413,7 +413,8 @@
default:
;/* these are the microsec stuff */
}
- if (interval_tmp.neg || expression > EVEX_MAX_INTERVAL_VALUE)
+ if (interval_tmp.neg || expression == 0 ||
+ expression > EVEX_MAX_INTERVAL_VALUE)
{
my_error(ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG, MYF(0));
DBUG_RETURN(EVEX_BAD_PARAMS);
--- 1.29/sql/item_xmlfunc.cc 2007-05-23 11:34:44 +04:00
+++ 1.30/sql/item_xmlfunc.cc 2007-06-01 11:43:51 +04:00
@@ -2656,7 +2656,7 @@
RETURN
Currently only MY_XML_OK
*/
-static int xml_enter(MY_XML_PARSER *st,const char *attr, uint len)
+static int xml_enter(MY_XML_PARSER *st,const char *attr, size_t len)
{
MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data;
MY_XML_NODE *nodes= (MY_XML_NODE*) data->pxml->ptr();
@@ -2687,7 +2687,7 @@
RETURN
Currently only MY_XML_OK
*/
-static int xml_value(MY_XML_PARSER *st,const char *attr, uint len)
+static int xml_value(MY_XML_PARSER *st,const char *attr, size_t len)
{
MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data;
MY_XML_NODE *nodes= (MY_XML_NODE*) data->pxml->ptr();
@@ -2717,7 +2717,7 @@
RETURN
Currently only MY_XML_OK
*/
-static int xml_leave(MY_XML_PARSER *st,const char *attr, uint len)
+static int xml_leave(MY_XML_PARSER *st,const char *attr, size_t len)
{
MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data;
DBUG_ASSERT(data->level > 0);
@@ -2767,7 +2767,7 @@
if ((rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length())) != MY_XML_OK)
{
char buf[128];
- my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %d: %s",
+ my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %lu: %s",
my_xml_error_lineno(&p) + 1,
my_xml_error_pos(&p) + 1,
my_xml_error_string(&p));
--- 1.134/sql/sql_view.cc 2007-05-24 02:39:26 +04:00
+++ 1.135/sql/sql_view.cc 2007-06-01 11:43:56 +04:00
@@ -322,11 +322,11 @@
*/
if ((check_access(thd, CREATE_VIEW_ACL, view->db, &view->grant.privilege,
0, 0, is_schema_db(view->db)) ||
- grant_option && check_grant(thd, CREATE_VIEW_ACL, view, 0, 1, 0)) ||
+ check_grant(thd, CREATE_VIEW_ACL, view, 0, 1, 0)) ||
(mode != VIEW_CREATE_NEW &&
(check_access(thd, DROP_ACL, view->db, &view->grant.privilege,
0, 0, is_schema_db(view->db)) ||
- grant_option && check_grant(thd, DROP_ACL, view, 0, 1, 0))))
+ check_grant(thd, DROP_ACL, view, 0, 1, 0))))
{
res= TRUE;
goto err;
@@ -379,7 +379,7 @@
{
if (check_access(thd, SELECT_ACL, tbl->db,
&tbl->grant.privilege, 0, 0, test(tbl->schema_table)) ||
- grant_option && check_grant(thd, SELECT_ACL, tbl, 0, 1, 0))
+ check_grant(thd, SELECT_ACL, tbl, 0, 1, 0))
{
res= TRUE;
goto err;
@@ -775,7 +775,7 @@
view->query.length= str.length()-1; // we do not need last \0
view->source.str= thd->query + thd->lex->create_view_select_start;
endp= view->source.str;
- endp= skip_rear_comments(endp, thd->query + thd->query_length);
+ endp= skip_rear_comments(thd->charset(), endp, thd->query + thd->query_length);
view->source.length= endp - view->source.str;
view->file_version= 1;
view->calc_md5(md5);
--- 1.48/mysql-test/lib/mtr_report.pl 2007-05-24 15:54:29 +04:00
+++ 1.49/mysql-test/lib/mtr_report.pl 2007-06-01 11:43:50 +04:00
@@ -265,8 +265,13 @@
else
{
# We report different types of problems in order
- foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x",
- "InnoDB: Warning", "missing DBUG_RETURN",
+ foreach my $pattern ( "^Warning:",
+ "\\[Warning\\]",
+ "\\[ERROR\\]",
+ "^Error:", "^==.* at 0x",
+ "InnoDB: Warning",
+ "^safe_mutex:",
+ "missing DBUG_RETURN",
"mysqld: Warning",
"allocated at line",
"Attempting backtrace", "Assertion .* failed" )
@@ -292,10 +297,69 @@
}
# Skip some non fatal warnings from the log files
- if ( /Warning:\s+Table:.* on (delete|rename)/ or
- /Warning:\s+Setting lower_case_table_names=2/ or
- /Warning:\s+One can only use the --user.*root/ or
- /InnoDB: Warning: we did not need to do crash recovery/)
+ if (
+ /\"SELECT UNIX_TIMESTAMP\(\)\" failed on master/ or
+ /Aborted connection/ or
+ /Client requested master to start replication from impossible position/ or
+ /Could not find first log file name in binary log/ or
+ /Enabling keys got errno/ or
+ /Error reading master configuration/ or
+ /Error reading packet/ or
+ /Event Scheduler/ or
+ /Failed to open log/ or
+ /Failed to open the existing master info file/ or
+ /Forcing shutdown of [0-9]* plugins/ or
+ /Got error [0-9]* when reading table/ or
+ /Incorrect definition of table/ or
+ /Incorrect information in file/ or
+ /InnoDB: Warning: we did not need to do crash recovery/ or
+ /Invalid \(old\?\) table or database name/ or
+ /Lock wait timeout exceeded/ or
+ /Log entry on master is longer than max_allowed_packet/ or
+ /unknown option '--loose-/ or
+ /unknown variable 'loose-/ or
+ /You have forced lower_case_table_names to 0 through a command-line option/ or
+ /Setting lower_case_table_names=2/ or
+ /NDB Binlog:/ or
+ /NDB: failed to setup table/ or
+ /NDB: only row based binary logging/ or
+ /Neither --relay-log nor --relay-log-index were used/ or
+ /Query partially completed/ or
+ /Slave I.O thread aborted while waiting for relay log/ or
+ /Slave SQL thread is stopped because UNTIL condition/ or
+ /Slave SQL thread retried transaction/ or
+ /Slave \(additional info\)/ or
+ /Slave: .*Duplicate column name/ or
+ /Slave: .*master may suffer from/ or
+ /Slave: According to the master's version/ or
+ /Slave: Column [0-9]* type mismatch/ or
+ /Slave: Error .* doesn't exist/ or
+ /Slave: Error .*Deadlock found/ or
+ /Slave: Error .*Unknown table/ or
+ /Slave: Error in Write_rows event: / or
+ /Slave: Field .* of table .* has no default value/ or
+ /Slave: Query caused different errors on master and slave/ or
+ /Slave: Table .* doesn't exist/ or
+ /Slave: Table width mismatch/ or
+ /Slave: The incident LOST_EVENTS occured on the master/ or
+ /Slave: Unknown error.* 1105/ or
+ /Slave: Can't drop database.* database doesn't exist/ or
+ /Sort aborted/ or
+ /Time-out in NDB/ or
+ /Warning:\s+One can only use the --user.*root/ or
+ /Warning:\s+Setting lower_case_table_names=2/ or
+ /Warning:\s+Table:.* on (delete|rename)/ or
+ /You have an error in your SQL syntax/ or
+ /deprecated/ or
+ /description of time zone/ or
+ /equal MySQL server ids/ or
+ /error .*connecting to master/ or
+ /error reading log entry/ or
+ /lower_case_table_names is set/ or
+ /skip-name-resolve mode/ or
+ /slave SQL thread aborted/ or
+ /Slave: .*Duplicate entry/
+ )
{
next; # Skip these lines
}
--- 1.260/mysql-test/t/disabled.def 2007-05-31 12:34:19 +04:00
+++ 1.261/mysql-test/t/disabled.def 2007-06-01 11:43:50 +04:00
@@ -17,6 +17,9 @@
im_utils : Bug#20294 2007-05-30 alik Instance manager tests fail randomly
im_instance_conf : Bug#20294 2007-05-30 alik Instance manager tests fail randomly
im_life_cycle : BUG#27851 Instance manager dies on ASSERT in ~Thread_registry() or from not being able to close a mysqld instance.
+im_instance_conf : BUG#28743 Instance manager generates warnings in test suite
+im_utils : BUG#28743 Instance manager generates warnings in test suite
+
concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences
ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
--- 1.171/include/my_global.h 2007-05-24 20:48:33 +04:00
+++ 1.172/include/my_global.h 2007-06-01 11:43:50 +04:00
@@ -441,17 +441,7 @@
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
-#ifdef HAVE_ATOMIC_ADD
-#define new my_arg_new
-#define need_to_restore_new 1
-C_MODE_START
-#include <asm/atomic.h>
-C_MODE_END
-#ifdef need_to_restore_new /* probably safer than #ifdef new */
-#undef new
-#undef need_to_restore_new
-#endif
-#endif
+
#include <errno.h> /* Recommended by debian */
/* We need the following to go around a problem with openssl on solaris */
#if defined(HAVE_CRYPT_H)
@@ -1431,10 +1421,13 @@
#ifndef THREAD
#define thread_safe_increment(V,L) (V)++
+#define thread_safe_decrement(V,L) (V)--
#define thread_safe_add(V,C,L) (V)+=(C)
#define thread_safe_sub(V,C,L) (V)-=(C)
#define statistic_increment(V,L) (V)++
+#define statistic_decrement(V,L) (V)--
#define statistic_add(V,C,L) (V)+=(C)
+#define statistic_sub(V,C,L) (V)-=(C)
#endif
#ifdef HAVE_CHARSET_utf8
--- 1.234/sql/set_var.cc 2007-05-23 14:55:07 +04:00
+++ 1.235/sql/set_var.cc 2007-06-01 11:43:52 +04:00
@@ -122,9 +122,9 @@
static void fix_server_id(THD *thd, enum_var_type type);
static KEY_CACHE *create_key_cache(const char *name, uint length);
void fix_sql_mode_var(THD *thd, enum_var_type type);
-static byte *get_error_count(THD *thd);
-static byte *get_warning_count(THD *thd);
-static byte *get_tmpdir(THD *thd);
+static uchar *get_error_count(THD *thd);
+static uchar *get_warning_count(THD *thd);
+static uchar *get_tmpdir(THD *thd);
static int sys_check_log_path(THD *thd, set_var *var);
static bool sys_update_general_log_path(THD *thd, set_var * var);
static void sys_default_general_log_path(THD *thd, enum_var_type type);
@@ -788,7 +788,7 @@
static int sys_check_ftb_syntax(THD *thd, set_var *var)
{
if (thd->security_ctx->master_access & SUPER_ACL)
- return (ft_boolean_check_syntax_string((byte*)
+ return (ft_boolean_check_syntax_string((uchar*)
var->value->str_value.c_ptr()) ?
-1 : 0);
else
@@ -1179,9 +1179,9 @@
}
-byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+uchar *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
{
- return (byte*) enum_names->type_names[*value];
+ return (uchar*) enum_names->type_names[*value];
}
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
@@ -1226,12 +1226,12 @@
}
-byte *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
if (type == OPT_GLOBAL)
- return (byte*) &(global_system_variables.*offset);
- return (byte*) &(thd->variables.*offset);
+ return (uchar*) &(global_system_variables.*offset);
+ return (uchar*) &(thd->variables.*offset);
}
@@ -1272,12 +1272,12 @@
}
-byte *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
if (type == OPT_GLOBAL)
- return (byte*) &(global_system_variables.*offset);
- return (byte*) &(thd->variables.*offset);
+ return (uchar*) &(global_system_variables.*offset);
+ return (uchar*) &(thd->variables.*offset);
}
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
@@ -1315,12 +1315,12 @@
}
-byte *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
if (type == OPT_GLOBAL)
- return (byte*) &(global_system_variables.*offset);
- return (byte*) &(thd->variables.*offset);
+ return (uchar*) &(global_system_variables.*offset);
+ return (uchar*) &(thd->variables.*offset);
}
@@ -1343,12 +1343,12 @@
}
-byte *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
if (type == OPT_GLOBAL)
- return (byte*) &(global_system_variables.*offset);
- return (byte*) &(thd->variables.*offset);
+ return (uchar*) &(global_system_variables.*offset);
+ return (uchar*) &(thd->variables.*offset);
}
@@ -1538,13 +1538,13 @@
}
-byte *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
ulong tmp= ((type == OPT_GLOBAL) ?
global_system_variables.*offset :
thd->variables.*offset);
- return (byte*) enum_names->type_names[tmp];
+ return (uchar*) enum_names->type_names[tmp];
}
bool sys_var_thd_bit::check(THD *thd, set_var *var)
@@ -1560,7 +1560,7 @@
}
-byte *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
/*
@@ -1569,7 +1569,7 @@
*/
thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
!reverse : reverse);
- return (byte*) &thd->sys_var_tmp.my_bool_value;
+ return (uchar*) &thd->sys_var_tmp.my_bool_value;
}
@@ -1580,7 +1580,7 @@
{
DATE_TIME_FORMAT *old;
DBUG_ENTER("sys_var_date_time_format::update2");
- DBUG_DUMP("positions",(char*) new_value->positions,
+ DBUG_DUMP("positions", (uchar*) new_value->positions,
sizeof(new_value->positions));
if (type == OPT_GLOBAL)
@@ -1660,7 +1660,7 @@
}
-byte *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
if (type == OPT_GLOBAL)
@@ -1673,9 +1673,9 @@
*/
res= thd->strmake((global_system_variables.*offset)->format.str,
(global_system_variables.*offset)->format.length);
- return (byte*) res;
+ return (uchar*) res;
}
- return (byte*) (thd->variables.*offset)->format.str;
+ return (uchar*) (thd->variables.*offset)->format.str;
}
@@ -1796,11 +1796,11 @@
}
-byte *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
- return cs ? (byte*) cs->csname : (byte*) NULL;
+ return cs ? (uchar*) cs->csname : (uchar*) NULL;
}
@@ -1870,11 +1870,12 @@
}
-byte *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
+ LEX_STRING *base)
{
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
- global_system_variables.*offset : thd->variables.*offset);
- return cs ? (byte*) cs->name : (byte*) "NULL";
+ global_system_variables.*offset : thd->variables.*offset);
+ return cs ? (uchar*) cs->name : (uchar*) "NULL";
}
@@ -1892,13 +1893,13 @@
}
-byte *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
KEY_CACHE *key_cache= get_key_cache(base);
if (!key_cache)
key_cache= &zero_key_cache;
- return (byte*) key_cache + offset ;
+ return (uchar*) key_cache + offset ;
}
@@ -2084,11 +2085,12 @@
}
else
{
+ size_t path_length;
/*
Check if directory exists and
we have permission to create file & write to file
*/
- (void) dirname_part(path, var_path);
+ (void) dirname_part(path, var_path, &path_length);
if (my_access(path, (F_OK|W_OK)))
return -1;
}
@@ -2214,7 +2216,7 @@
}
-byte *sys_var_log_output::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_log_output::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
char buff[256];
@@ -2235,7 +2237,7 @@
if ((length= tmp.length()))
length--;
- return (byte*) thd->strmake(tmp.ptr(), length);
+ return (uchar*) thd->strmake(tmp.ptr(), length);
}
@@ -2274,11 +2276,11 @@
}
-byte *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
thd->sys_var_tmp.long_value= (long) thd->start_time;
- return (byte*) &thd->sys_var_tmp.long_value;
+ return (uchar*) &thd->sys_var_tmp.long_value;
}
@@ -2290,7 +2292,7 @@
}
-byte *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
/*
@@ -2299,7 +2301,7 @@
*/
thd->sys_var_tmp.ulonglong_value=
thd->read_first_successful_insert_id_in_prev_stmt();
- return (byte*) &thd->sys_var_tmp.ulonglong_value;
+ return (uchar*) &thd->sys_var_tmp.ulonglong_value;
}
@@ -2310,12 +2312,12 @@
}
-byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
thd->sys_var_tmp.ulonglong_value=
thd->auto_inc_intervals_forced.minimum();
- return (byte*) &thd->sys_var_tmp.ulonglong_value;
+ return (uchar*) &thd->sys_var_tmp.ulonglong_value;
}
@@ -2362,7 +2364,7 @@
}
-byte *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
/*
@@ -2370,7 +2372,7 @@
time zone name is guaranteed to be zero ended.
*/
if (type == OPT_GLOBAL)
- return (byte *)(global_system_variables.time_zone->get_name()->ptr());
+ return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
else
{
/*
@@ -2382,7 +2384,7 @@
(binlog code stores session value only).
*/
thd->time_zone_used= 1;
- return (byte *)(thd->variables.time_zone->get_name()->ptr());
+ return (uchar *)(thd->variables.time_zone->get_name()->ptr());
}
}
@@ -2444,13 +2446,13 @@
}
-byte *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
if (type != OPT_GLOBAL &&
thd->user_connect && thd->user_connect->user_resources.user_conn)
- return (byte*) &(thd->user_connect->user_resources.user_conn);
- return (byte*) &(max_user_connections);
+ return (uchar*) &(thd->user_connect->user_resources.user_conn);
+ return (uchar*) &(max_user_connections);
}
@@ -2501,12 +2503,12 @@
}
-byte *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
return type == OPT_GLOBAL ?
- (byte *) global_system_variables.lc_time_names->name :
- (byte *) thd->variables.lc_time_names->name;
+ (uchar *) global_system_variables.lc_time_names->name :
+ (uchar *) thd->variables.lc_time_names->name;
}
@@ -2615,20 +2617,20 @@
#endif
}
-static byte *get_warning_count(THD *thd)
+static uchar *get_warning_count(THD *thd)
{
thd->sys_var_tmp.long_value=
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
- return (byte*) &thd->sys_var_tmp.long_value;
+ return (uchar*) &thd->sys_var_tmp.long_value;
}
-static byte *get_error_count(THD *thd)
+static uchar *get_error_count(THD *thd)
{
thd->sys_var_tmp.long_value=
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
- return (byte*) &thd->sys_var_tmp.long_value;
+ return (uchar*) &thd->sys_var_tmp.long_value;
}
@@ -2649,11 +2651,11 @@
RETURN VALUES
ptr pointer to NUL-terminated string
*/
-static byte *get_tmpdir(THD *thd)
+static uchar *get_tmpdir(THD *thd)
{
if (opt_mysql_tmpdir)
- return (byte *)opt_mysql_tmpdir;
- return (byte*)mysql_tmpdir;
+ return (uchar *)opt_mysql_tmpdir;
+ return (uchar*)mysql_tmpdir;
}
/****************************************************************************
@@ -2699,11 +2701,11 @@
Return variable name and length for hashing of variables
*/
-static byte *get_sys_var_length(const sys_var *var, uint *length,
- my_bool first)
+static uchar *get_sys_var_length(const sys_var *var, size_t *length,
+ my_bool first)
{
*length= var->name_length;
- return (byte*) var->name;
+ return (uchar*) var->name;
}
@@ -2720,6 +2722,7 @@
otherwise FAILURE
*/
+
int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options)
{
sys_var *var;
@@ -2730,7 +2733,7 @@
{
var->name_length= strlen(var->name);
/* this fails if there is a conflicting variable name. see HASH_UNIQUE */
- if (my_hash_insert(&system_variable_hash, (byte*) var))
+ if (my_hash_insert(&system_variable_hash, (uchar*) var))
goto error;
if (long_options)
var->option_limits= find_option(long_options, var->name);
@@ -2739,42 +2742,42 @@
error:
for (; first != var; first= first->next)
- hash_delete(&system_variable_hash, (byte*) first);
+ hash_delete(&system_variable_hash, (uchar*) first);
return 1;
}
-
-
+
+
/*
Remove variables to the dynamic hash of system variables
-
+
SYNOPSIS
mysql_del_sys_var_chain()
first Pointer to first system variable to remove
-
+
RETURN VALUES
0 SUCCESS
otherwise FAILURE
*/
-
+
int mysql_del_sys_var_chain(sys_var *first)
{
int result= 0;
-
+
/* A write lock should be held on LOCK_system_variables_hash */
-
+
for (sys_var *var= first; var; var= var->next)
- result|= hash_delete(&system_variable_hash, (byte*) var);
+ result|= hash_delete(&system_variable_hash, (uchar*) var);
return result;
}
-
-
+
+
static int show_cmp(SHOW_VAR *a, SHOW_VAR *b)
{
return strcmp(a->name, b->name);
}
-
-
+
+
/*
Constructs an array of system variables for display to the user.
@@ -2891,7 +2894,7 @@
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count)
{
for (; count > 0; count--, show_vars++)
- if (insert_dynamic(&fixed_show_vars, (char*) show_vars))
+ if (insert_dynamic(&fixed_show_vars, (uchar*) show_vars))
return 1;
return 0;
}
@@ -2920,7 +2923,7 @@
A lock on LOCK_system_variable_hash should be held
*/
var= (sys_var*) hash_search(&system_variable_hash,
- (byte*) str, length ? length : strlen(str));
+ (uchar*) str, length ? length : strlen(str));
if (!(var || no_error))
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);
@@ -3213,10 +3216,10 @@
}
-byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
- byte* result;
+ uchar* result;
handlerton *hton;
LEX_STRING *name;
plugin_ref plugin= thd->variables.*offset;
@@ -3224,7 +3227,7 @@
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
hton= plugin_data(plugin, handlerton*);
name= &hton2plugin[hton->slot]->name;
- result= (byte *) thd->strmake(name->str, name->length);
+ result= (uchar *) thd->strmake(name->str, name->length);
if (type == OPT_GLOBAL)
plugin_unlock(thd, plugin);
return result;
@@ -3326,14 +3329,14 @@
}
-byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
LEX_STRING sql_mode;
ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
thd->variables.*offset);
(void) symbolic_mode_representation(thd, val, &sql_mode);
- return (byte *) sql_mode.str;
+ return (uchar *) sql_mode.str;
}
@@ -3424,7 +3427,7 @@
Named list handling
****************************************************************************/
-gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
+uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
NAMED_LIST **found)
{
I_List_iterator<NAMED_LIST> it(*list);
@@ -3443,7 +3446,7 @@
void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char *name, gptr))
+ void (*free_element)(const char *name, uchar*))
{
NAMED_LIST *element;
DBUG_ENTER("delete_elements");
@@ -3467,7 +3470,7 @@
if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
MYF(MY_ZEROFILL | MY_WME))))
{
- if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache))
+ if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
{
my_free((char*) key_cache, MYF(0));
key_cache= 0;
@@ -3626,14 +3629,14 @@
}
-byte *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
+uchar *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
{
char buf[256];
if (type == OPT_GLOBAL)
DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
else
DBUG_EXPLAIN(buf, sizeof(buf));
- return (byte*) thd->strdup(buf);
+ return (uchar*) thd->strdup(buf);
}
@@ -3676,10 +3679,10 @@
}
-byte *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type,
+uchar *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
- return (byte *) Events::get_opt_event_scheduler_str();
+ return (uchar *) Events::get_opt_event_scheduler_str();
}
--- 1.105/sql/sql_partition.cc 2007-05-28 15:29:57 +04:00
+++ 1.106/sql/sql_partition.cc 2007-06-01 11:43:54 +04:00
@@ -123,23 +123,23 @@
uint32 get_partition_id_key_sub(partition_info *part_info);
uint32 get_partition_id_linear_hash_sub(partition_info *part_info);
uint32 get_partition_id_linear_key_sub(partition_info *part_info);
-#endif
-
static uint32 get_next_partition_via_walking(PARTITION_ITERATOR*);
+static void set_up_range_analysis_info(partition_info *part_info);
static uint32 get_next_subpartition_via_walking(PARTITION_ITERATOR*);
+#endif
+
uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter);
uint32 get_next_partition_id_list(PARTITION_ITERATOR* part_iter);
int get_part_iter_for_interval_via_mapping(partition_info *part_info,
bool is_subpart,
- char *min_value, char *max_value,
+ uchar *min_value, uchar *max_value,
uint flags,
PARTITION_ITERATOR *part_iter);
int get_part_iter_for_interval_via_walking(partition_info *part_info,
bool is_subpart,
- char *min_value, char *max_value,
+ uchar *min_value, uchar *max_value,
uint flags,
PARTITION_ITERATOR *part_iter);
-static void set_up_range_analysis_info(partition_info *part_info);
#ifdef WITH_PARTITION_STORAGE_ENGINE
/*
@@ -294,8 +294,8 @@
> 0 Error code
*/
-int get_parts_for_update(const byte *old_data, byte *new_data,
- const byte *rec0, partition_info *part_info,
+int get_parts_for_update(const uchar *old_data, uchar *new_data,
+ const uchar *rec0, partition_info *part_info,
uint32 *old_part_id, uint32 *new_part_id,
longlong *new_func_value)
{
@@ -368,7 +368,7 @@
calculate the partition id.
*/
-int get_part_for_delete(const byte *buf, const byte *rec0,
+int get_part_for_delete(const uchar *buf, const uchar *rec0,
partition_info *part_info, uint32 *part_id)
{
int error;
@@ -907,7 +907,7 @@
context->table_list= &tables;
context->first_name_resolution_table= &tables;
context->last_name_resolution_table= NULL;
- func_expr->walk(&Item::change_context_processor, 0, (byte*) context);
+ func_expr->walk(&Item::change_context_processor, 0, (uchar*) context);
save_where= thd->where;
thd->where= "partition function";
/*
@@ -1673,7 +1673,7 @@
static int add_write(File fptr, const char *buf, uint len)
{
- uint len_written= my_write(fptr, (const byte*)buf, len, MYF(0));
+ uint len_written= my_write(fptr, (const uchar*)buf, len, MYF(0));
if (likely(len == len_written))
return 0;
@@ -2120,13 +2120,13 @@
goto close_file;
*buf_length= (uint)buffer_length;
if (use_sql_alloc)
- buf= sql_alloc(*buf_length+1);
+ buf= (char*) sql_alloc(*buf_length+1);
else
- buf= my_malloc(*buf_length+1, MYF(MY_WME));
+ buf= (char*) my_malloc(*buf_length+1, MYF(MY_WME));
if (!buf)
goto close_file;
- if (unlikely(my_read(fptr, (byte*)buf, *buf_length, MYF(MY_FNABP))))
+ if (unlikely(my_read(fptr, (uchar*)buf, *buf_length, MYF(MY_FNABP))))
{
if (!use_sql_alloc)
my_free(buf, MYF(0));
@@ -2389,8 +2389,8 @@
*/
static void copy_to_part_field_buffers(Field **ptr,
- char **field_bufs,
- char **restore_ptr)
+ uchar **field_bufs,
+ uchar **restore_ptr)
{
Field *field;
while ((field= *(ptr++)))
@@ -2401,7 +2401,7 @@
{
CHARSET_INFO *cs= ((Field_str*)field)->charset();
uint len= field->pack_length();
- char *field_buf= *field_bufs;
+ uchar *field_buf= *field_bufs;
/*
We only use the field buffer for VARCHAR and CHAR strings
which isn't of a binary collation. We also only use the
@@ -2412,17 +2412,17 @@
if (field->type() == MYSQL_TYPE_VARCHAR)
{
uint len_bytes= ((Field_varstring*)field)->length_bytes;
- my_strnxfrm(cs, (uchar*)(field_buf + len_bytes), (len - len_bytes),
- (uchar*)(field->ptr + len_bytes), field->field_length);
+ my_strnxfrm(cs, field_buf + len_bytes, (len - len_bytes),
+ field->ptr + len_bytes, field->field_length);
if (len_bytes == 1)
- *field_buf= (uchar)field->field_length;
+ *field_buf= (uchar) field->field_length;
else
int2store(field_buf, field->field_length);
}
else
{
- my_strnxfrm(cs, (uchar*)field_buf, len,
- (uchar*)field->ptr, field->field_length);
+ my_strnxfrm(cs, field_buf, len,
+ field->ptr, field->field_length);
}
field->ptr= field_buf;
}
@@ -2441,7 +2441,7 @@
RETURN VALUES
*/
-static void restore_part_field_pointers(Field **ptr, char **restore_ptr)
+static void restore_part_field_pointers(Field **ptr, uchar **restore_ptr)
{
Field *field;
while ((field= *(ptr++)))
@@ -3283,16 +3283,16 @@
get the partition identity and restore field pointers afterwards.
*/
-static uint32 get_sub_part_id_from_key(const TABLE *table,byte *buf,
+static uint32 get_sub_part_id_from_key(const TABLE *table,uchar *buf,
KEY *key_info,
const key_range *key_spec)
{
- byte *rec0= table->record[0];
+ uchar *rec0= table->record[0];
partition_info *part_info= table->part_info;
uint32 part_id;
DBUG_ENTER("get_sub_part_id_from_key");
- key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length);
+ key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length);
if (likely(rec0 == buf))
part_id= part_info->get_subpartition_id(part_info);
else
@@ -3326,16 +3326,16 @@
get the partition identity and restore field pointers afterwards.
*/
-bool get_part_id_from_key(const TABLE *table, byte *buf, KEY *key_info,
+bool get_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info,
const key_range *key_spec, uint32 *part_id)
{
bool result;
- byte *rec0= table->record[0];
+ uchar *rec0= table->record[0];
partition_info *part_info= table->part_info;
longlong func_value;
DBUG_ENTER("get_part_id_from_key");
- key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length);
+ key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length);
if (likely(rec0 == buf))
result= part_info->get_part_partition_id(part_info, part_id,
&func_value);
@@ -3371,18 +3371,18 @@
get the partition identity and restore field pointers afterwards.
*/
-void get_full_part_id_from_key(const TABLE *table, byte *buf,
+void get_full_part_id_from_key(const TABLE *table, uchar *buf,
KEY *key_info,
const key_range *key_spec,
part_id_range *part_spec)
{
bool result;
partition_info *part_info= table->part_info;
- byte *rec0= table->record[0];
+ uchar *rec0= table->record[0];
longlong func_value;
DBUG_ENTER("get_full_part_id_from_key");
- key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length);
+ key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length);
if (likely(rec0 == buf))
result= part_info->get_partition_id(part_info, &part_spec->start_part,
&func_value);
@@ -3470,7 +3470,7 @@
RETURN VALUE
part_spec
*/
-void get_partition_set(const TABLE *table, byte *buf, const uint index,
+void get_partition_set(const TABLE *table, uchar *buf, const uint index,
const key_range *key_spec, part_id_range *part_spec)
{
partition_info *part_info= table->part_info;
@@ -3806,9 +3806,9 @@
char *part_func_string= NULL;
char *subpart_func_string= NULL;
if ((part_func_len &&
- !((part_func_string= thd->alloc(part_func_len)))) ||
+ !((part_func_string= (char*) thd->alloc(part_func_len)))) ||
(subpart_func_len &&
- !((subpart_func_string= thd->alloc(subpart_func_len)))))
+ !((subpart_func_string= (char*) thd->alloc(subpart_func_len)))))
{
mem_alloc_error(part_func_len);
thd->free_items();
@@ -6374,8 +6374,8 @@
also for other programs.
*/
-void set_field_ptr(Field **ptr, const byte *new_buf,
- const byte *old_buf)
+void set_field_ptr(Field **ptr, const uchar *new_buf,
+ const uchar *old_buf)
{
my_ptrdiff_t diff= (new_buf - old_buf);
DBUG_ENTER("set_field_ptr");
@@ -6408,8 +6408,8 @@
also for other programs.
*/
-void set_key_field_ptr(KEY *key_info, const byte *new_buf,
- const byte *old_buf)
+void set_key_field_ptr(KEY *key_info, const uchar *new_buf,
+ const uchar *old_buf)
{
KEY_PART_INFO *key_part= key_info->key_part;
uint key_parts= key_info->key_parts;
@@ -6660,7 +6660,7 @@
int get_part_iter_for_interval_via_mapping(partition_info *part_info,
bool is_subpart,
- char *min_value, char *max_value,
+ uchar *min_value, uchar *max_value,
uint flags,
PARTITION_ITERATOR *part_iter)
{
@@ -6816,7 +6816,7 @@
int get_part_iter_for_interval_via_walking(partition_info *part_info,
bool is_subpart,
- char *min_value, char *max_value,
+ uchar *min_value, uchar *max_value,
uint flags,
PARTITION_ITERATOR *part_iter)
{
--- 1.152/sql/sp.cc 2007-05-24 02:39:22 +04:00
+++ 1.153/sql/sp.cc 2007-06-01 12:12:02 +04:00
@@ -442,16 +442,36 @@
delete field;
}
-static int
-db_create_routine(THD *thd, int type, sp_head *sp)
+
+/**
+ Write stored-routine object into mysql.proc.
+
+ This operation stores attributes of the stored procedure/function into
+ the mysql.proc.
+
+ @param thd Thread context.
+ @param type Stored routine type
+ (TYPE_ENUM_PROCEDURE or TYPE_ENUM_FUNCTION).
+ @param sp Stored routine object to store.
+
+ @return Error code. SP_OK is returned on success. Other SP_ constants are
+ used to indicate about errors.
+*/
+
+int
+sp_create_routine(THD *thd, int type, sp_head *sp)
{
int ret;
TABLE *table;
char definer[USER_HOST_BUFF_SIZE];
- DBUG_ENTER("db_create_routine");
+
+ DBUG_ENTER("sp_create_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s",type, (int) sp->m_name.length,
sp->m_name.str));
+ DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE ||
+ type == TYPE_ENUM_FUNCTION);
+
/*
This statement will be replicated as a statement, even when using
row-based replication. The flag will be reset at the end of the
@@ -586,15 +606,33 @@
}
-static int
-db_drop_routine(THD *thd, int type, sp_name *name)
+/**
+ Delete the record for the stored routine object from mysql.proc.
+
+ The operation deletes the record for the stored routine specified by name
+ from the mysql.proc table and invalidates the stored-routine cache.
+
+ @param thd Thread context.
+ @param type Stored routine type
+ (TYPE_ENUM_PROCEDURE or TYPE_ENUM_FUNCTION)
+ @param name Stored routine name.
+
+ @return Error code. SP_OK is returned on success. Other SP_ constants are
+ used to indicate about errors.
+*/
+
+int
+sp_drop_routine(THD *thd, int type, sp_name *name)
{
TABLE *table;
int ret;
- DBUG_ENTER("db_drop_routine");
+ DBUG_ENTER("sp_drop_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s",
type, (int) name->m_name.length, name->m_name.str));
+ DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE ||
+ type == TYPE_ENUM_FUNCTION);
+
/*
This statement will be replicated as a statement, even when using
row-based replication. The flag will be reset at the end of the
@@ -618,6 +656,8 @@
thd->binlog_query(THD::MYSQL_QUERY_TYPE,
thd->query, thd->query_length, FALSE, FALSE);
}
+
+ sp_cache_invalidate();
}
close_thread_tables(thd);
@@ -625,18 +665,37 @@
}
-static int
-db_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
+/**
+ Find and updated the record for the stored routine object in mysql.proc.
+
+ The operation finds the record for the stored routine specified by name
+ in the mysql.proc table and updates it with new attributes. After
+ successful update, the cache is invalidated.
+
+ @param thd Thread context.
+ @param type Stored routine type
+ (TYPE_ENUM_PROCEDURE or TYPE_ENUM_FUNCTION)
+ @param name Stored routine name.
+ @param chistics New values of stored routine attributes to write.
+
+ @return Error code. SP_OK is returned on success. Other SP_ constants are
+ used to indicate about errors.
+*/
+
+int
+sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
{
TABLE *table;
int ret;
- DBUG_ENTER("db_update_routine");
+ DBUG_ENTER("sp_update_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s",
type, (int) name->m_name.length, name->m_name.str));
+ DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE ||
+ type == TYPE_ENUM_FUNCTION);
/*
This statement will be replicated as a statement, even when using
- row-based replication. The flag will be reset at the end of the
+ row-based replication. The flag will be reset at the end of the
statement.
*/
thd->clear_current_stmt_binlog_row_based();
@@ -670,6 +729,8 @@
thd->binlog_query(THD::MYSQL_QUERY_TYPE,
thd->query, thd->query_length, FALSE, FALSE);
}
+
+ sp_cache_invalidate();
}
close_thread_tables(thd);
@@ -755,13 +816,28 @@
}
-static int
-db_show_routine_status(THD *thd, int type, const char *wild)
+/**
+ Implement SHOW STATUS statement for stored routines.
+
+ @param thd Thread context.
+ @param type Stored routine type
+ (TYPE_ENUM_PROCEDURE or TYPE_ENUM_FUNCTION)
+ @param name_pattern Stored routine name pattern.
+
+ @return Error code. SP_OK is returned on success. Other SP_ constants are
+ used to indicate about errors.
+*/
+
+int
+sp_show_status_routine(THD *thd, int type, const char *name_pattern)
{
TABLE *table;
TABLE_LIST tables;
int res;
- DBUG_ENTER("db_show_routine_status");
+ DBUG_ENTER("sp_show_status_routine");
+
+ DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE ||
+ type == TYPE_ENUM_FUNCTION);
memset(&tables, 0, sizeof(tables));
tables.db= (char*)"mysql";
@@ -789,14 +865,14 @@
{
switch (used_field->field_type) {
case MYSQL_TYPE_TIMESTAMP:
- field_list.push_back(item=
- new Item_return_date_time(used_field->field_name,
- MYSQL_TYPE_DATETIME));
+ item= new Item_return_date_time(used_field->field_name,
+ MYSQL_TYPE_DATETIME);
+ field_list.push_back(item);
break;
default:
- field_list.push_back(item=new Item_empty_string(used_field->field_name,
- used_field->
- field_length));
+ item= new Item_empty_string(used_field->field_name,
+ used_field->field_length);
+ field_list.push_back(item);
break;
}
}
@@ -840,13 +916,16 @@
res= (res == HA_ERR_END_OF_FILE) ? 0 : SP_INTERNAL_ERROR;
goto err_case1;
}
- if ((res= print_field_values(thd, table, used_fields, type, wild)))
- goto err_case1;
- while (!table->file->index_next(table->record[0]))
+
+ do
{
- if ((res= print_field_values(thd, table, used_fields, type, wild)))
+ res= print_field_values(thd, table, used_fields, type, name_pattern);
+
+ if (res)
goto err_case1;
}
+ while (!table->file->index_next(table->record[0]));
+
res= SP_OK;
}
@@ -913,9 +992,60 @@
}
-/*****************************************************************************
- PROCEDURE
-******************************************************************************/
+/**
+ Implement SHOW CREATE statement for stored routines.
+
+ The operation finds the stored routine object specified by name and then
+ calls sp_head::show_create_routine() for the object.
+
+ @param thd Thread context.
+ @param type Stored routine type
+ (TYPE_ENUM_PROCEDURE or TYPE_ENUM_FUNCTION)
+ @param name Stored routine name.
+
+ @return Error status.
+ @retval FALSE on success
+ @retval TRUE on error
+*/
+
+bool
+sp_show_create_routine(THD *thd, int type, sp_name *name)
+{
+ bool err_status= TRUE;
+ sp_head *sp;
+ sp_cache **cache = type == TYPE_ENUM_PROCEDURE ?
+ &thd->sp_proc_cache : &thd->sp_func_cache;
+
+ DBUG_ENTER("sp_show_create_routine");
+ DBUG_PRINT("enter", ("name: %.*s", name->m_name.length, name->m_name.str));
+
+ DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE ||
+ type == TYPE_ENUM_FUNCTION);
+
+ if (type == TYPE_ENUM_PROCEDURE)
+ {
+ /*
+ SHOW CREATE PROCEDURE may require two instances of one sp_head
+ object when SHOW CREATE PROCEDURE is called for the procedure that
+ is being executed. Basically, there is no actual recursion, so we
+ increase the recursion limit for this statement (kind of hack).
+
+ SHOW CREATE FUNCTION does not require this because SHOW CREATE
+ statements are prohibitted within stored functions.
+ */
+
+ thd->variables.max_sp_recursion_depth++;
+ }
+
+ if ((sp= sp_find_routine(thd, type, name, cache, FALSE)))
+ err_status= sp->show_create_routine(thd, type);
+
+ if (type == TYPE_ENUM_PROCEDURE)
+ thd->variables.max_sp_recursion_depth--;
+
+ DBUG_RETURN(err_status);
+}
+
/*
Obtain object representing stored procedure/function by its name from
@@ -1106,158 +1236,6 @@
close_system_tables(thd, &open_tables_state_backup);
}
return ret;
-}
-
-
-int
-sp_create_procedure(THD *thd, sp_head *sp)
-{
- int ret;
- DBUG_ENTER("sp_create_procedure");
- DBUG_PRINT("enter", ("name: %.*s", (int) sp->m_name.length, sp->m_name.str));
-
- ret= db_create_routine(thd, TYPE_ENUM_PROCEDURE, sp);
- DBUG_RETURN(ret);
-}
-
-
-int
-sp_drop_procedure(THD *thd, sp_name *name)
-{
- int ret;
- DBUG_ENTER("sp_drop_procedure");
- DBUG_PRINT("enter", ("name: %.*s",
- (int) name->m_name.length, name->m_name.str));
-
- ret= db_drop_routine(thd, TYPE_ENUM_PROCEDURE, name);
- if (!ret)
- sp_cache_invalidate();
- DBUG_RETURN(ret);
-}
-
-
-int
-sp_update_procedure(THD *thd, sp_name *name, st_sp_chistics *chistics)
-{
- int ret;
- DBUG_ENTER("sp_update_procedure");
- DBUG_PRINT("enter", ("name: %.*s",
- (int) name->m_name.length, name->m_name.str));
-
- ret= db_update_routine(thd, TYPE_ENUM_PROCEDURE, name, chistics);
- if (!ret)
- sp_cache_invalidate();
- DBUG_RETURN(ret);
-}
-
-
-int
-sp_show_create_procedure(THD *thd, sp_name *name)
-{
- int ret= SP_KEY_NOT_FOUND;
- sp_head *sp;
- DBUG_ENTER("sp_show_create_procedure");
- DBUG_PRINT("enter", ("name: %.*s",
- (int) name->m_name.length, name->m_name.str));
-
- /*
- Increase the recursion limit for this statement. SHOW CREATE PROCEDURE
- does not do actual recursion.
- */
- thd->variables.max_sp_recursion_depth++;
- if ((sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, name,
- &thd->sp_proc_cache, FALSE)))
- ret= sp->show_create_procedure(thd);
-
- thd->variables.max_sp_recursion_depth--;
- DBUG_RETURN(ret);
-}
-
-
-int
-sp_show_status_procedure(THD *thd, const char *wild)
-{
- int ret;
- DBUG_ENTER("sp_show_status_procedure");
-
- ret= db_show_routine_status(thd, TYPE_ENUM_PROCEDURE, wild);
- DBUG_RETURN(ret);
-}
-
-
-/*****************************************************************************
- FUNCTION
-******************************************************************************/
-
-int
-sp_create_function(THD *thd, sp_head *sp)
-{
- int ret;
- DBUG_ENTER("sp_create_function");
- DBUG_PRINT("enter", ("name: %.*s",
- (int) sp->m_name.length, sp->m_name.str));
-
- ret= db_create_routine(thd, TYPE_ENUM_FUNCTION, sp);
- DBUG_RETURN(ret);
-}
-
-
-int
-sp_drop_function(THD *thd, sp_name *name)
-{
- int ret;
- DBUG_ENTER("sp_drop_function");
- DBUG_PRINT("enter", ("name: %.*s",
- (int) name->m_name.length, name->m_name.str));
-
- ret= db_drop_routine(thd, TYPE_ENUM_FUNCTION, name);
- if (!ret)
- sp_cache_invalidate();
- DBUG_RETURN(ret);
-}
-
-
-int
-sp_update_function(THD *thd, sp_name *name, st_sp_chistics *chistics)
-{
- int ret;
- DBUG_ENTER("sp_update_procedure");
- DBUG_PRINT("enter", ("name: %.*s",
- (int) name->m_name.length, name->m_name.str));
-
- ret= db_update_routine(thd, TYPE_ENUM_FUNCTION, name, chistics);
- if (!ret)
- sp_cache_invalidate();
- DBUG_RETURN(ret);
-}
-
-
-int
-sp_show_create_function(THD *thd, sp_name *name)
-{
- sp_head *sp;
- DBUG_ENTER("sp_show_create_function");
- DBUG_PRINT("enter", ("name: %.*s",
- (int) name->m_name.length, name->m_name.str));
-
- if ((sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, name,
- &thd->sp_func_cache, FALSE)))
- {
- int ret= sp->show_create_function(thd);
-
- DBUG_RETURN(ret);
- }
- DBUG_RETURN(SP_KEY_NOT_FOUND);
-}
-
-
-int
-sp_show_status_function(THD *thd, const char *wild)
-{
- int ret;
- DBUG_ENTER("sp_show_status_function");
- ret= db_show_routine_status(thd, TYPE_ENUM_FUNCTION, wild);
- DBUG_RETURN(ret);
}
--- 1.39/sql/sp.h 2007-05-10 13:59:28 +04:00
+++ 1.40/sql/sp.h 2007-06-01 11:43:52 +04:00
@@ -44,37 +44,20 @@
int
sp_routine_exists_in_table(THD *thd, int type, sp_name *name);
-int
-sp_create_procedure(THD *thd, sp_head *sp);
-
-int
-sp_drop_procedure(THD *thd, sp_name *name);
-
+bool
+sp_show_create_routine(THD *thd, int type, sp_name *name);
int
-sp_update_procedure(THD *thd, sp_name *name, st_sp_chistics *chistics);
+sp_show_status_routine(THD *thd, int type, const char *wild);
int
-sp_show_create_procedure(THD *thd, sp_name *name);
+sp_create_routine(THD *thd, int type, sp_head *sp);
int
-sp_show_status_procedure(THD *thd, const char *wild);
+sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics);
int
-sp_create_function(THD *thd, sp_head *sp);
-
-int
-sp_drop_function(THD *thd, sp_name *name);
-
-int
-sp_update_function(THD *thd, sp_name *name, st_sp_chistics *chistics);
-
-int
-sp_show_create_function(THD *thd, sp_name *name);
-
-int
-sp_show_status_function(THD *thd, const char *wild);
-
+sp_drop_routine(THD *thd, int type, sp_name *name);
/*
Procedures for pre-caching of stored routines and building table list
--- 1.272/sql/sp_head.cc 2007-05-24 02:39:22 +04:00
+++ 1.273/sql/sp_head.cc 2007-06-01 11:43:53 +04:00
@@ -570,7 +570,7 @@
Trim "garbage" at the end. This is sometimes needed with the
"/ * ! VERSION... * /" wrapper in dump files.
*/
- endp= skip_rear_comments(m_body_begin, endp);
+ endp= skip_rear_comments(thd->charset(), m_body_begin, endp);
m_body.length= endp - m_body_begin;
m_body.str= strmake_root(root, m_body_begin, m_body.length);
@@ -636,17 +636,10 @@
sp_head::create(THD *thd)
{
DBUG_ENTER("sp_head::create");
- int ret;
-
DBUG_PRINT("info", ("type: %d name: %s params: %s body: %s",
m_type, m_name.str, m_params.str, m_body.str));
- if (m_type == TYPE_ENUM_FUNCTION)
- ret= sp_create_function(thd, this);
- else
- ret= sp_create_procedure(thd, this);
-
- DBUG_RETURN(ret);
+ DBUG_RETURN(sp_create_routine(thd, m_type, this));
}
sp_head::~sp_head()
@@ -2104,49 +2097,97 @@
}
-int
-sp_head::show_create_procedure(THD *thd)
+/**
+ Implement SHOW CREATE statement for stored routines.
+
+ @param thd Thread context.
+ @param type Stored routine type
+ (TYPE_ENUM_PROCEDURE or TYPE_ENUM_FUNCTION)
+
+ @return Error status.
+ @retval FALSE on success
+ @retval TRUE on error
+*/
+
+bool
+sp_head::show_create_routine(THD *thd, int type)
{
+ const char *col1_caption= type == TYPE_ENUM_PROCEDURE ?
+ "Procedure" : "Function";
+
+ const char *col3_caption= type == TYPE_ENUM_PROCEDURE ?
+ "Create Procedure" : "Create Function";
+
+ bool err_status;
+
Protocol *protocol= thd->protocol;
- char buff[2048];
- String buffer(buff, sizeof(buff), system_charset_info);
- int res;
- List<Item> field_list;
+ List<Item> fields;
+
LEX_STRING sql_mode;
+
bool full_access;
- DBUG_ENTER("sp_head::show_create_procedure");
- DBUG_PRINT("info", ("procedure %s", m_name.str));
+
+ DBUG_ENTER("sp_head::show_create_routine");
+ DBUG_PRINT("info", ("routine %s", m_name.str));
+
+ DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE ||
+ type == TYPE_ENUM_FUNCTION);
if (check_show_routine_access(thd, this, &full_access))
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
+
+ sys_var_thd_sql_mode::symbolic_mode_representation(
+ thd, m_sql_mode, &sql_mode);
+
+ /* Send header. */
+
+ fields.push_back(new Item_empty_string(col1_caption, NAME_CHAR_LEN));
+ fields.push_back(new Item_empty_string("sql_mode", sql_mode.length));
+
+ {
+ /*
+ NOTE: SQL statement field must be not less than 1024 in order not to
+ confuse old clients.
+ */
+
+ Item_empty_string *stmt_fld=
+ new Item_empty_string(col3_caption,
+ max(m_defstr.length, 1024));
+
+ stmt_fld->maybe_null= TRUE;
+
+ fields.push_back(stmt_fld);
+ }
+
+ if (protocol->send_fields(&fields,
+ Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
+ {
+ DBUG_RETURN(TRUE);
+ }
+
+ /* Send data. */
- sys_var_thd_sql_mode::symbolic_mode_representation(thd, m_sql_mode,
- &sql_mode);
- field_list.push_back(new Item_empty_string("Procedure", NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("sql_mode", sql_mode.length));
- // 1024 is for not to confuse old clients
- Item_empty_string *definition=
- new Item_empty_string("Create Procedure", max(buffer.length(),1024));
- definition->maybe_null= TRUE;
- field_list.push_back(definition);
-
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
protocol->prepare_for_resend();
+
protocol->store(m_name.str, m_name.length, system_charset_info);
- protocol->store((char*) sql_mode.str, sql_mode.length, system_charset_info);
+ protocol->store(sql_mode.str, sql_mode.length, system_charset_info);
+
if (full_access)
- protocol->store(m_defstr.str, m_defstr.length, system_charset_info);
+ protocol->store(m_defstr.str, m_defstr.length, &my_charset_bin);
else
protocol->store_null();
- res= protocol->write();
- send_eof(thd);
- DBUG_RETURN(res);
+ err_status= protocol->write();
+
+ if (!err_status)
+ send_eof(thd);
+
+ DBUG_RETURN(err_status);
}
+
+
/*
Add instruction to SP
@@ -2167,48 +2208,6 @@
*/
instr->mem_root= &main_mem_root;
insert_dynamic(&m_instr, (uchar*)&instr);
-}
-
-
-int
-sp_head::show_create_function(THD *thd)
-{
- Protocol *protocol= thd->protocol;
- char buff[2048];
- String buffer(buff, sizeof(buff), system_charset_info);
- int res;
- List<Item> field_list;
- LEX_STRING sql_mode;
- bool full_access;
- DBUG_ENTER("sp_head::show_create_function");
- DBUG_PRINT("info", ("procedure %s", m_name.str));
-
- if (check_show_routine_access(thd, this, &full_access))
- DBUG_RETURN(1);
-
- sys_var_thd_sql_mode::symbolic_mode_representation(thd, m_sql_mode,
- &sql_mode);
- field_list.push_back(new Item_empty_string("Function",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("sql_mode", sql_mode.length));
- Item_empty_string *definition=
- new Item_empty_string("Create Function", max(buffer.length(),1024));
- definition->maybe_null= TRUE;
- field_list.push_back(definition);
-
- if (protocol->send_fields(&field_list,
- Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
- DBUG_RETURN(1);
- protocol->prepare_for_resend();
- protocol->store(m_name.str, m_name.length, system_charset_info);
- protocol->store(sql_mode.str, sql_mode.length, system_charset_info);
- if (full_access)
- protocol->store(m_defstr.str, m_defstr.length, system_charset_info);
- else
- protocol->store_null();
- res= protocol->write();
- send_eof(thd);
-
- DBUG_RETURN(res);
}
--- 1.107/sql/sp_head.h 2007-05-24 02:39:22 +04:00
+++ 1.108/sql/sp_head.h 2007-06-01 11:43:53 +04:00
@@ -225,11 +225,8 @@
bool
execute_procedure(THD *thd, List<Item> *args);
- int
- show_create_procedure(THD *thd);
-
- int
- show_create_function(THD *thd);
+ bool
+ show_create_routine(THD *thd, int type);
void
add_instr(sp_instr *instr);
--- 1.218/sql/sql_prepare.cc 2007-05-22 23:41:36 +04:00
+++ 1.219/sql/sql_prepare.cc 2007-06-01 11:43:54 +04:00
@@ -229,7 +229,7 @@
static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
{
NET *net= &stmt->thd->net;
- char buff[12];
+ uchar buff[12];
uint tmp;
DBUG_ENTER("send_prep_stmt");
@@ -946,7 +946,7 @@
Item_param *param= *it;
varname= var_it++;
entry= (user_var_entry*)hash_search(&stmt->thd->user_vars,
- (byte*) varname->str,
+ (uchar*) varname->str,
varname->length);
if (param->set_from_user_var(stmt->thd, entry) ||
param->convert_str_value(stmt->thd))
@@ -1077,7 +1077,7 @@
if (table_list->table)
{
// don't allocate insert_values
- table_list->table->insert_values=(byte *)1;
+ table_list->table->insert_values=(uchar *)1;
}
if (mysql_prepare_insert(thd, table_list, table_list->table,
@@ -1604,7 +1604,7 @@
next_local;
/* Skip first table, which is the table we are inserting in */
- first_select->table_list.first= (byte *) second_table;
+ first_select->table_list.first= (uchar *) second_table;
thd->lex->select_lex.context.table_list=
thd->lex->select_lex.context.first_name_resolution_table= second_table;
@@ -1635,7 +1635,7 @@
if (tables->table)
{
// don't allocate insert_values
- tables->table->insert_values=(byte *)1;
+ tables->table->insert_values=(uchar *)1;
}
if (insert_precheck(stmt->thd, tables))
@@ -1650,7 +1650,7 @@
&mysql_insert_select_prepare_tester,
OPTION_SETUP_TABLES_DONE);
/* revert changes made by mysql_insert_select_prepare_tester */
- lex->select_lex.table_list.first= (byte*) first_local_table;
+ lex->select_lex.table_list.first= (uchar*) first_local_table;
return res;
}
@@ -1987,7 +1987,7 @@
*/
if ((entry=
(user_var_entry*)hash_search(&thd->user_vars,
- (byte*)lex->prepared_stmt_code.str,
+ (uchar*)lex->prepared_stmt_code.str,
lex->prepared_stmt_code.length))
&& entry->value)
{
@@ -2016,7 +2016,7 @@
len= (needs_conversion ? var_value->length() * to_cs->mbmaxlen :
var_value->length());
- if (!(query_str= alloc_root(thd->mem_root, len+1)))
+ if (!(query_str= (char*) alloc_root(thd->mem_root, len+1)))
goto end;
if (needs_conversion)
@@ -2369,7 +2369,7 @@
/* Query text for binary, general or slow log, if any of them is open */
String expanded_query;
DBUG_ENTER("mysql_sql_stmt_execute");
- DBUG_PRINT("info", ("EXECUTE: %.*s\n", name->length, name->str));
+ DBUG_PRINT("info", ("EXECUTE: %.*s\n", (int) name->length, name->str));
if (!(stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
{
@@ -2557,7 +2557,8 @@
{
Prepared_statement* stmt;
LEX_STRING *name= &thd->lex->prepared_stmt_name;
- DBUG_PRINT("info", ("DEALLOCATE PREPARE: %.*s\n", name->length, name->str));
+ DBUG_PRINT("info", ("DEALLOCATE PREPARE: %.*s\n", (int) name->length,
+ name->str));
if (! (stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
{
@@ -2802,7 +2803,7 @@
bool Prepared_statement::set_name(LEX_STRING *name_arg)
{
name.length= name_arg->length;
- name.str= memdup_root(mem_root, (char*) name_arg->str, name_arg->length);
+ name.str= (char*) memdup_root(mem_root, name_arg->str, name_arg->length);
return name.str == 0;
}
--- 1.237/tests/mysql_client_test.c 2007-05-10 13:59:35 +04:00
+++ 1.238/tests/mysql_client_test.c 2007-06-01 11:43:56 +04:00
@@ -2471,7 +2471,7 @@
"(2, 'hh', 'hh'), (1, 'ii', 'ii'), (2, 'ii', 'ii')");
myquery(rc);
- for (iteration= TEST_QCACHE_ON; iteration < TEST_QCACHE_ON_OFF; iteration++)
+ for (iteration= TEST_QCACHE_ON; iteration <= TEST_QCACHE_ON_OFF; iteration++)
{
switch (iteration)
@@ -2610,7 +2610,9 @@
case TEST_QCACHE_ON_OFF: /* should not have hit */
DIE_UNLESS(hits2-hits1 == 0);
break;
- case TEST_QCACHE_ON_WITH_OTHER_CONN:
+ case TEST_QCACHE_ON_WITH_OTHER_CONN: /* should have hit */
+ DIE_UNLESS(hits2-hits1 == 1);
+ break;
mysql_close(lmysql);
mysql= org_mysql;
}
@@ -16074,6 +16076,92 @@
/*
+ Bug#28075 "COM_DEBUG crashes mysqld"
+ Note: Test disabled because of failure in PushBuild.
+*/
+#ifdef fix_bug_in_pb_first
+static void test_bug28075()
+{
+ int rc;
+
+ DBUG_ENTER("test_bug28075");
+ myheader("test_bug28075");
+
+ rc= mysql_dump_debug_info(mysql);
+ DIE_UNLESS(rc == 0);
+
+ rc= mysql_ping(mysql);
+ DIE_UNLESS(rc == 0);
+
+ DBUG_VOID_RETURN;
+}
+#endif
+
+
+/*
+ Bug#27876 (SF with cyrillic variable name fails during execution (regression))
+*/
+static void test_bug27876()
+{
+ int rc;
+ MYSQL_RES *result;
+
+ char utf8_func[] =
+ {
+ 0xd1, 0x84, 0xd1, 0x83, 0xd0, 0xbd, 0xd0, 0xba,
+ 0xd1, 0x86, 0xd0, 0xb8, 0xd0, 0xb9, 0xd0, 0xba,
+ 0xd0, 0xb0,
+ 0x00
+ };
+
+ char utf8_param[] =
+ {
+ 0xd0, 0xbf, 0xd0, 0xb0, 0xd1, 0x80, 0xd0, 0xb0,
+ 0xd0, 0xbc, 0xd0, 0xb5, 0xd1, 0x82, 0xd1, 0x8a,
+ 0xd1, 0x80, 0x5f, 0xd0, 0xb2, 0xd0, 0xb5, 0xd1,
+ 0x80, 0xd1, 0x81, 0xd0, 0xb8, 0xd1, 0x8f,
+ 0x00
+ };
+
+ char query[500];
+
+ DBUG_ENTER("test_bug27876");
+ myheader("test_bug27876");
+
+ rc= mysql_query(mysql, "set names utf8");
+ myquery(rc);
+
+ rc= mysql_query(mysql, "select version()");
+ myquery(rc);
+ result= mysql_store_result(mysql);
+ mytest(result);
+
+ sprintf(query, "DROP FUNCTION IF EXISTS %s", utf8_func);
+ rc= mysql_query(mysql, query);
+ myquery(rc);
+
+ sprintf(query,
+ "CREATE FUNCTION %s( %s VARCHAR(25))"
+ " RETURNS VARCHAR(25) DETERMINISTIC RETURN %s",
+ utf8_func, utf8_param, utf8_param);
+ rc= mysql_query(mysql, query);
+ myquery(rc);
+ sprintf(query, "SELECT %s(VERSION())", utf8_func);
+ rc= mysql_query(mysql, query);
+ myquery(rc);
+ result= mysql_store_result(mysql);
+ mytest(result);
+
+ sprintf(query, "DROP FUNCTION %s", utf8_func);
+ rc= mysql_query(mysql, query);
+ myquery(rc);
+
+ rc= mysql_query(mysql, "set names default");
+ myquery(rc);
+}
+
+
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -16357,6 +16445,10 @@
{ "test_status", test_status },
{ "test_bug24179", test_bug24179 },
{ "test_ps_query_cache", test_ps_query_cache },
+#ifdef fix_bug_in_pb_first
+ { "test_bug28075", test_bug28075 },
+#endif
+ { "test_bug27876", test_bug27876 },
{ 0, 0 }
};
| Thread |
|---|
| • bk commit into 5.1 tree (kostja:1.2534) | konstantin | 1 Jun |