Merge mysql.com:/home/mydev/mysql-5.0

into mysql.com:/home/mydev/mysql-5.0-5000


sql/set_var.cc:
  Auto merged
This commit is contained in:
unknown 2005-01-25 09:47:01 +01:00
commit d31a16d9b2
49 changed files with 261 additions and 189 deletions

View file

@ -396,6 +396,7 @@ libmysqld/gstream.cc
libmysqld/ha_archive.cc libmysqld/ha_archive.cc
libmysqld/ha_berkeley.cc libmysqld/ha_berkeley.cc
libmysqld/ha_example.cc libmysqld/ha_example.cc
libmysqld/ha_federated.cc
libmysqld/ha_heap.cc libmysqld/ha_heap.cc
libmysqld/ha_innobase.cc libmysqld/ha_innobase.cc
libmysqld/ha_innodb.cc libmysqld/ha_innodb.cc
@ -1036,6 +1037,7 @@ test/tools/verify_index
test_xml test_xml
tests/client_test tests/client_test
tests/connect_test tests/connect_test
tests/mysql_client_test
thread_test thread_test
tmp/* tmp/*
tools/my_vsnprintf.c tools/my_vsnprintf.c

View file

@ -1430,12 +1430,6 @@ static void build_completion_hash(bool rehash, bool write_info)
if (status.batch || quick || !current_db) if (status.batch || quick || !current_db)
DBUG_VOID_RETURN; // We don't need completion in batches DBUG_VOID_RETURN; // We don't need completion in batches
if (tables)
{
mysql_free_result(tables);
tables=0;
}
/* hash SQL commands */ /* hash SQL commands */
while (cmd->name) { while (cmd->name) {
add_word(&ht,(char*) cmd->name); add_word(&ht,(char*) cmd->name);
@ -1681,8 +1675,8 @@ static int com_server_help(String *buffer __attribute__((unused)),
else if (num_fields >= 2 && num_rows) else if (num_fields >= 2 && num_rows)
{ {
init_pager(); init_pager();
char last_char; char last_char= 0;
int num_name= 0, num_cat= 0; int num_name= 0, num_cat= 0;
LINT_INIT(num_name); LINT_INIT(num_name);
LINT_INIT(num_cat); LINT_INIT(num_cat);
@ -1693,7 +1687,6 @@ static int com_server_help(String *buffer __attribute__((unused)),
put_info("To make a more specific request, please type 'help <item>',\nwhere <item> is one of the following", INFO_INFO); put_info("To make a more specific request, please type 'help <item>',\nwhere <item> is one of the following", INFO_INFO);
num_name= 0; num_name= 0;
num_cat= 1; num_cat= 1;
last_char= '_';
} }
else if ((cur= mysql_fetch_row(result))) else if ((cur= mysql_fetch_row(result)))
{ {
@ -1703,7 +1696,7 @@ static int com_server_help(String *buffer __attribute__((unused)),
num_cat= 2; num_cat= 2;
print_help_item(&cur,1,2,&last_char); print_help_item(&cur,1,2,&last_char);
} }
while ((cur= mysql_fetch_row(result))) while ((cur= mysql_fetch_row(result)))
print_help_item(&cur,num_name,num_cat,&last_char); print_help_item(&cur,num_name,num_cat,&last_char);
tee_fprintf(PAGER, "\n"); tee_fprintf(PAGER, "\n");

View file

@ -780,11 +780,7 @@ static int check_master_version(MYSQL* mysql,
if (mysql_query(mysql, "SELECT VERSION()") || if (mysql_query(mysql, "SELECT VERSION()") ||
!(res = mysql_store_result(mysql))) !(res = mysql_store_result(mysql)))
{ die("Error checking master version: %s", mysql_error(mysql));
mysql_close(mysql);
die("Error checking master version: %s",
mysql_error(mysql));
}
if (!(row = mysql_fetch_row(res))) if (!(row = mysql_fetch_row(res)))
{ {
mysql_free_result(res); mysql_free_result(res);

View file

@ -2436,8 +2436,7 @@ static const char *check_if_ignore_table(const char *table_name)
fprintf(stderr, fprintf(stderr,
"Error: Couldn't read status information for table %s (%s)\n", "Error: Couldn't read status information for table %s (%s)\n",
table_name, mysql_error(sock)); table_name, mysql_error(sock));
if (res) mysql_free_result(res);
mysql_free_result(res);
return 0; /* assume table is ok */ return 0; /* assume table is ok */
} }
if (!(row[1])) if (!(row[1]))
@ -2448,7 +2447,7 @@ static const char *check_if_ignore_table(const char *table_name)
strcmp(row[1], (result= "MRG_ISAM"))) strcmp(row[1], (result= "MRG_ISAM")))
result= 0; result= 0;
} }
mysql_free_result(res); mysql_free_result(res);
return result; return result;
} }

View file

@ -733,9 +733,10 @@ VAR* var_get(const char* var_name, const char** var_name_end, my_bool raw,
die("Empty variable"); die("Empty variable");
} }
length= (uint) (var_name - save_var_name); length= (uint) (var_name - save_var_name);
if (length >= MAX_VAR_NAME)
die("Too long variable name: %s", save_var_name);
if (!(v = (VAR*) hash_search(&var_hash, save_var_name, length)) && if (!(v = (VAR*) hash_search(&var_hash, save_var_name, length)))
length < MAX_VAR_NAME)
{ {
char buff[MAX_VAR_NAME+1]; char buff[MAX_VAR_NAME+1];
strmake(buff, save_var_name, length); strmake(buff, save_var_name, length);

View file

@ -1084,7 +1084,7 @@ do { doubleget_union _tmp; \
#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float)) #define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
#define doublestore(T,V) do { *(T)= ((byte *) &V)[4];\ #define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\
*(((char*)T)+1)=(char) ((byte *) &V)[5];\ *(((char*)T)+1)=(char) ((byte *) &V)[5];\
*(((char*)T)+2)=(char) ((byte *) &V)[6];\ *(((char*)T)+2)=(char) ((byte *) &V)[6];\
*(((char*)T)+3)=(char) ((byte *) &V)[7];\ *(((char*)T)+3)=(char) ((byte *) &V)[7];\

View file

@ -3077,7 +3077,7 @@ static my_bool int_is_null_false= 0;
values and mysql_stmt_execute() the statement. values and mysql_stmt_execute() the statement.
See also: mysql_stmt_send_long_data() for sending long text/blob See also: mysql_stmt_send_long_data() for sending long text/blob
data in pieces, examples in tests/client_test.c. data in pieces, examples in tests/mysql_client_test.c.
Next steps you might want to make: Next steps you might want to make:
- execute statement with mysql_stmt_execute(), - execute statement with mysql_stmt_execute(),
- reset statement using mysql_stmt_reset() or reprepare it with - reset statement using mysql_stmt_reset() or reprepare it with

View file

@ -1,6 +1,7 @@
noinst_PROGRAMS = mysqltest mysql client_test noinst_PROGRAMS = mysql
client_sources = $(mysqltest_SOURCES) $(mysql_SOURCES) bin_PROGRAMS = mysqltest_embedded mysql_client_test_embedded
tests_sources= $(client_test_SOURCES) client_sources = $(mysqltest_embedded_SOURCES) $(mysql_SOURCES)
tests_sources= $(mysql_client_test_embedded_SOURCES)
link_sources: link_sources:
for f in $(client_sources); do \ for f in $(client_sources); do \
@ -19,16 +20,16 @@ INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include -I$(srcdir) \
LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS)
mysqltest_LINK = $(CXXLINK) mysqltest_embedded_LINK = $(CXXLINK)
mysqltest_SOURCES = mysqltest.c mysqltest_embedded_SOURCES = mysqltest.c
mysqltest_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a
mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \ mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
my_readline.h sql_string.h completion_hash.h my_readline.h sql_string.h completion_hash.h
mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD)
client_test_LINK = $(CXXLINK) mysql_client_test_embedded_LINK = $(CXXLINK)
client_test_SOURCES = client_test.c mysql_client_test_embedded_SOURCES = $(top_srcdir)/tests/mysql_client_test.c
clean: clean:
rm -f $(client_sources) rm -f $(client_sources)

View file

@ -346,11 +346,12 @@ static void _ftb_init_index_search(FT_INFO *ftb)
if (ftbe->flags & FTB_FLAG_NO || /* 2 */ if (ftbe->flags & FTB_FLAG_NO || /* 2 */
ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */ ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */
{ {
FTB_EXPR *top_ftbe=ftbe->up->up; FTB_EXPR *top_ftbe=ftbe->up;
ftbw->docid[0]=HA_OFFSET_ERROR; ftbw->docid[0]=HA_OFFSET_ERROR;
for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) for (ftbe=(FTB_EXPR *)ftbw;
if (!(ftbe->flags & FTB_FLAG_NO)) ftbe != top_ftbe && !(ftbe->flags & FTB_FLAG_NO);
ftbe->yweaks++; ftbe=ftbe->up)
ftbe->up->yweaks++;
ftbe=0; ftbe=0;
break; break;
} }
@ -364,7 +365,7 @@ static void _ftb_init_index_search(FT_INFO *ftb)
else else
reset_tree(& ftb->no_dupes); reset_tree(& ftb->no_dupes);
} }
if (_ft2_search(ftb, ftbw, 1)) if (_ft2_search(ftb, ftbw, 1))
return; return;
} }

View file

@ -184,21 +184,14 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
my_malloc((length+OFFSET_TABLE_SIZE)*sizeof(uint16)+ my_malloc((length+OFFSET_TABLE_SIZE)*sizeof(uint16)+
(uint) (share->pack.header_length+7), (uint) (share->pack.header_length+7),
MYF(MY_WME | MY_ZEROFILL)))) MYF(MY_WME | MY_ZEROFILL))))
{
my_free((gptr) share->decode_trees,MYF(0));
goto err1; goto err1;
}
tmp_buff=share->decode_tables+length; tmp_buff=share->decode_tables+length;
disk_cache=(byte*) (tmp_buff+OFFSET_TABLE_SIZE); disk_cache=(byte*) (tmp_buff+OFFSET_TABLE_SIZE);
if (my_read(file,disk_cache, if (my_read(file,disk_cache,
(uint) (share->pack.header_length-sizeof(header)), (uint) (share->pack.header_length-sizeof(header)),
MYF(MY_NABP))) MYF(MY_NABP)))
{
my_free((gptr) share->decode_trees,MYF(0));
my_free((gptr) share->decode_tables,MYF(0));
goto err2; goto err2;
}
huff_tree_bits=max_bit(trees ? trees-1 : 0); huff_tree_bits=max_bit(trees ? trees-1 : 0);
init_bit_buffer(&bit_buff, (uchar*) disk_cache, init_bit_buffer(&bit_buff, (uchar*) disk_cache,

View file

@ -948,15 +948,14 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length)
/* check for redundant root (not leaf, 1 child) and eliminate */ /* check for redundant root (not leaf, 1 child) and eliminate */
if ((old_root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) if ((old_root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
goto err1; goto err1;
if (!_mi_fetch_keypage(info, keyinfo, old_root, DFLT_INIT_HITS, if (!_mi_fetch_keypage(info, keyinfo, old_root, DFLT_INIT_HITS,
info->buff, 0)) info->buff, 0))
goto err1; goto err1;
nod_flag = mi_test_if_nod(info->buff); nod_flag = mi_test_if_nod(info->buff);
page_size = mi_getint(info->buff); page_size = mi_getint(info->buff);
if (nod_flag && (page_size == 2 + key_length + if (nod_flag && (page_size == 2 + key_length + nod_flag))
(nod_flag ? nod_flag : info->s->base.rec_reflength)))
{ {
my_off_t new_root = _mi_kpos(nod_flag, my_off_t new_root = _mi_kpos(nod_flag,
rt_PAGE_FIRST_KEY(info->buff, nod_flag)); rt_PAGE_FIRST_KEY(info->buff, nod_flag));
if (_mi_dispose(info, keyinfo, old_root, DFLT_INIT_HITS)) if (_mi_dispose(info, keyinfo, old_root, DFLT_INIT_HITS))
goto err1; goto err1;

View file

@ -162,7 +162,10 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
{ {
if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer,
maxbuffer/2)) maxbuffer/2))
{
my_free((gptr) sort_keys,MYF(0)); my_free((gptr) sort_keys,MYF(0));
sort_keys= 0;
}
else else
break; break;
} }

View file

@ -499,13 +499,13 @@ DASH72=`$ECHO '-------------------------------------------------------'|$CUT -c
# on binary, use what is installed # on binary, use what is installed
if [ x$SOURCE_DIST = x1 ] ; then if [ x$SOURCE_DIST = x1 ] ; then
if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then
if [ -f "$BASEDIR/libmysqld/examples/mysqltest" ] ; then if [ -f "$BASEDIR/libmysqld/examples/mysqltest_embedded" ] ; then
MYSQL_TEST="$VALGRIND $BASEDIR/libmysqld/examples/mysqltest" MYSQL_TEST="$VALGRIND $BASEDIR/libmysqld/examples/mysqltest_embedded"
else else
echo "Fatal error: Cannot find embedded server 'mysqltest'" 1>&2 echo "Fatal error: Cannot find embedded server 'mysqltest_embedded'" 1>&2
exit 1 exit 1
fi fi
TESTS_BINDIR="$BASEDIR/libmysqld/examples" MYSQL_CLIENT_TEST="$BASEDIR/libmysqld/examples/mysql_client_test_embedded"
else else
MYSQLD="$VALGRIND $BASEDIR/sql/mysqld" MYSQLD="$VALGRIND $BASEDIR/sql/mysqld"
if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then
@ -515,7 +515,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
else else
MYSQL_TEST="$BASEDIR/client/mysqltest" MYSQL_TEST="$BASEDIR/client/mysqltest"
fi fi
TESTS_BINDIR="$BASEDIR/tests" MYSQL_CLIENT_TEST="$BASEDIR/tests/mysql_client_test"
fi fi
if [ -f "$BASEDIR/client/.libs/mysqldump" ] ; then if [ -f "$BASEDIR/client/.libs/mysqldump" ] ; then
MYSQL_DUMP="$BASEDIR/client/.libs/mysqldump" MYSQL_DUMP="$BASEDIR/client/.libs/mysqldump"
@ -545,6 +545,14 @@ if [ x$SOURCE_DIST = x1 ] ; then
NDB_TOOLS_DIR="$BASEDIR/ndb/tools" NDB_TOOLS_DIR="$BASEDIR/ndb/tools"
NDB_MGM="$BASEDIR/ndb/src/mgmclient/ndb_mgm" NDB_MGM="$BASEDIR/ndb/src/mgmclient/ndb_mgm"
else else
# We have a binary installation. Note that this can be both from
# unpacking a MySQL AB binary distribution (created using
# "scripts/make_binary_distribution", and from a "make install".
# Unfortunately the structure differs a bit, for a "make install"
# currently all binaries are in "bin", for a MySQL AB packaging
# some are in "tests".
if test -x "$BASEDIR/libexec/mysqld" if test -x "$BASEDIR/libexec/mysqld"
then then
MYSQLD="$VALGRIND $BASEDIR/libexec/mysqld" MYSQLD="$VALGRIND $BASEDIR/libexec/mysqld"
@ -578,7 +586,23 @@ else
else else
LANGUAGE="$BASEDIR/share/english/" LANGUAGE="$BASEDIR/share/english/"
CHARSETSDIR="$BASEDIR/share/charsets" CHARSETSDIR="$BASEDIR/share/charsets"
fi fi
if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then
if [ -f "$CLIENT_BINDIR/mysqltest_embedded" ] ; then
MYSQL_TEST="$VALGRIND $CLIENT_BINDIR/mysqltest_embedded"
else
echo "Fatal error: Cannot find embedded server 'mysqltest_embedded'" 1>&2
exit 1
fi
if [ -d "$BASEDIR/tests/mysql_client_test_embedded" ] ; then
MYSQL_CLIENT_TEST="$TESTS_BINDIR/mysql_client_test_embedded"
else
MYSQL_CLIENT_TEST="$CLIENT_BINDIR/mysql_client_test_embedded"
fi
else
MYSQL_TEST="$CLIENT_BINDIR/mysqltest"
MYSQL_CLIENT_TEST="$CLIENT_BINDIR/mysql_client_test"
fi
fi fi
if [ -z "$MASTER_MYSQLD" ] if [ -z "$MASTER_MYSQLD" ]
@ -612,13 +636,13 @@ then
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root"
fi fi
MYSQL_CLIENT_TEST="$MYSQL_CLIENT_TEST --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent"
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT"
MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES
export CLIENT_BINDIR TESTS_BINDIR CHARSETSDIR export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR
export NDB_TOOLS_DIR export NDB_TOOLS_DIR
export NDB_MGM export NDB_MGM

View file

@ -148,6 +148,9 @@ select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN B
a b a b
select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE);
a b a b
select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE);
a b
Full-text indexes are called collections
select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE);
a b a b
select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE);

View file

@ -1,4 +0,0 @@
# Skip when testing the embedded server
--source include/not_embedded.inc
--disable_result_log
--exec $TESTS_BINDIR/client_test --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent

0
mysql-test/t/ctype_cp932.test Executable file → Normal file
View file

0
mysql-test/t/ctype_eucjpms.test Executable file → Normal file
View file

View file

@ -67,6 +67,7 @@ select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE);
select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN BOOLEAN MODE);
select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE);
select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE);
select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE);
# bug#2708, bug#3870 crash # bug#2708, bug#3870 crash

View file

@ -0,0 +1,3 @@
# We run with different binaries for normal and --embedded-server
--disable_result_log
--exec $MYSQL_CLIENT_TEST

View file

@ -352,6 +352,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
MYF(0)))) MYF(0))))
break; break;
my_large_free(keycache->block_mem, MYF(0)); my_large_free(keycache->block_mem, MYF(0));
keycache->block_mem= 0;
} }
if (blocks < 8) if (blocks < 8)
{ {

View file

@ -275,7 +275,11 @@ static void safe_hash_change(SAFE_HASH *hash, byte *old_data, byte *new_data)
if (entry->data == old_data) if (entry->data == old_data)
{ {
if (new_data == hash->default_value) if (new_data == hash->default_value)
{
if ((*entry->prev= entry->next))
entry->next->prev= entry->prev;
hash_delete(&hash->hash, (byte*) entry); hash_delete(&hash->hash, (byte*) entry);
}
else else
entry->data= new_data; entry->data= new_data;
} }

View file

@ -69,7 +69,7 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
my_close() my_close()
fd File sescriptor fd File sescriptor
myf Special Flags myf Special Flags
*/ */
int my_close(File fd, myf MyFlags) int my_close(File fd, myf MyFlags)
@ -79,7 +79,12 @@ int my_close(File fd, myf MyFlags)
DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags)); DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags));
pthread_mutex_lock(&THR_LOCK_open); pthread_mutex_lock(&THR_LOCK_open);
if ((err = close(fd))) do
{
err= close(fd);
} while (err == -1 && errno == EINTR);
if (err)
{ {
DBUG_PRINT("error",("Got error %d on close",err)); DBUG_PRINT("error",("Got error %d on close",err));
my_errno=errno; my_errno=errno;

View file

@ -40,15 +40,19 @@ int my_sync(File fd, myf my_flags)
DBUG_ENTER("my_sync"); DBUG_ENTER("my_sync");
DBUG_PRINT("my",("Fd: %d my_flags: %d", fd, my_flags)); DBUG_PRINT("my",("Fd: %d my_flags: %d", fd, my_flags));
do
{
#if defined(HAVE_FDATASYNC) #if defined(HAVE_FDATASYNC)
res= fdatasync(fd); res= fdatasync(fd);
#elif defined(HAVE_FSYNC) #elif defined(HAVE_FSYNC)
res=fsync(fd); res= fsync(fd);
#elif defined(__WIN__) #elif defined(__WIN__)
res= _commit(fd); res= _commit(fd);
#else #else
res= 0; /* No sync (strange OS) */ res= 0; /* No sync (strange OS) */
#endif #endif
} while (res == -1 && errno == EINTR);
if (res) if (res)
{ {
if (!(my_errno= errno)) if (!(my_errno= errno))

View file

@ -248,7 +248,7 @@ void thr_end_alarm(thr_alarm_t *alarmed)
if (alarm_data->malloced) if (alarm_data->malloced)
my_free((gptr) alarm_data,MYF(0)); my_free((gptr) alarm_data,MYF(0));
found++; found++;
#ifndef DBUG_OFF #ifdef DBUG_OFF
break; break;
#endif #endif
} }

View file

@ -21,8 +21,8 @@
char * char *
strdup(const char *s){ strdup(const char *s){
void *p2; void *p2;
p2 = malloc(strlen(s)+1); if ((p2 = malloc(strlen(s)+1)))
strcpy(p2, s); strcpy(p2, s);
return p2; return p2;
} }
#endif #endif

View file

@ -126,6 +126,8 @@ else
client/.libs/mysqltest client/.libs/mysqlcheck \ client/.libs/mysqltest client/.libs/mysqlcheck \
client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \ client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \
client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \ client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \
tests/.libs/mysql_client_test libmysqld/examples/mysql_client_test_embedded \
libmysqld/examples/mysqltest_embedded \
"; ";
fi fi
@ -186,7 +188,7 @@ fi
if [ $BASE_SYSTEM != "netware" ] ; then if [ $BASE_SYSTEM != "netware" ] ; then
if [ -d tests ] ; then if [ -d tests ] ; then
$CP tests/client_test tests/*.res tests/*.tst tests/*.pl $BASE/tests $CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
fi fi
if [ -d man ] ; then if [ -d man ] ; then
$CP man/*.1 $BASE/man/man1 $CP man/*.1 $BASE/man/man1

View file

@ -358,22 +358,19 @@ Item *create_func_sin(Item* a)
Item *create_func_sha(Item* a) Item *create_func_sha(Item* a)
{ {
return new Item_func_sha(a); return new Item_func_sha(a);
} }
Item *create_func_space(Item *a) Item *create_func_space(Item *a)
{ {
CHARSET_INFO *cs= current_thd->variables.collation_connection; CHARSET_INFO *cs= current_thd->variables.collation_connection;
Item *sp; Item *sp;
if (cs->mbminlen > 1) if (cs->mbminlen > 1)
{ {
uint dummy_errors;
sp= new Item_string("",0,cs); sp= new Item_string("",0,cs);
if (sp) sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors);
{
uint dummy_errors;
sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors);
}
} }
else else
{ {

View file

@ -2519,6 +2519,9 @@ String* Item_func_export_set::val_str(String* str)
case 3: case 3:
sep_buf.set(",", 1, default_charset()); sep_buf.set(",", 1, default_charset());
sep = &sep_buf; sep = &sep_buf;
break;
default:
DBUG_ASSERT(0); // cannot happen
} }
null_value=0; null_value=0;

View file

@ -2131,20 +2131,25 @@ void Item_char_typecast::print(String *str)
String *Item_char_typecast::val_str(String *str) String *Item_char_typecast::val_str(String *str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
String *res, *res1; String *res;
uint32 length; uint32 length;
if (!charset_conversion && !(res= args[0]->val_str(str))) #if 0
if (!charset_conversion)
{ {
null_value= 1; if (!(res= args[0]->val_str(str)))
return 0; {
null_value= 1;
return 0;
}
} }
else else
#endif
{ {
// Convert character set if differ // Convert character set if differ
uint dummy_errors; uint dummy_errors;
if (!(res1= args[0]->val_str(&tmp_value)) || if (!(res= args[0]->val_str(&tmp_value)) ||
str->copy(res1->ptr(), res1->length(), res1->charset(), str->copy(res->ptr(), res->length(), res->charset(),
cast_cs, &dummy_errors)) cast_cs, &dummy_errors))
{ {
null_value= 1; null_value= 1;
@ -2154,13 +2159,13 @@ String *Item_char_typecast::val_str(String *str)
} }
res->set_charset(cast_cs); res->set_charset(cast_cs);
/* /*
Cut the tail if cast with length Cut the tail if cast with length
and the result is longer than cast length, e.g. and the result is longer than cast length, e.g.
CAST('string' AS CHAR(1)) CAST('string' AS CHAR(1))
*/ */
if (cast_length >= 0 && if (cast_length >= 0 &&
(res->length() > (length= (uint32) res->charpos(cast_length)))) (res->length() > (length= (uint32) res->charpos(cast_length))))
{ // Safe even if const arg { // Safe even if const arg
if (!res->alloced_length()) if (!res->alloced_length())
@ -2169,7 +2174,7 @@ String *Item_char_typecast::val_str(String *str)
res= &str_value; res= &str_value;
} }
res->length((uint) length); res->length((uint) length);
} }
null_value= 0; null_value= 0;
return res; return res;
} }

View file

@ -2257,9 +2257,9 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff,
DBUG_ENTER("print_buffer_to_nt_eventlog"); DBUG_ENTER("print_buffer_to_nt_eventlog");
buffptr= buff; buffptr= buff;
if (length > (uint)(buffLen-4)) if (length > (uint)(buffLen-5))
{ {
char *newBuff= new char[length + 4]; char *newBuff= new char[length + 5];
strcpy(newBuff, buff); strcpy(newBuff, buff);
buffptr= newBuff; buffptr= newBuff;
} }

View file

@ -3031,6 +3031,18 @@ You should consider changing lower_case_table_names to 1 or 2",
lower_case_table_names= 2; lower_case_table_names= 2;
} }
} }
else if (lower_case_table_names == 2 &&
!(lower_case_file_system=
(test_if_case_insensitive(mysql_real_data_home) == 1)))
{
if (global_system_variables.log_warnings)
sql_print_warning("\
You have forced lower_case_table_names to 2 through a command-line \
option, even though your file system '%s' is case sensitive. This means \
that you can create a table that you can then no longer access. \
You should consider changing lower_case_table_names to 0.",
mysql_real_data_home);
}
select_thread=pthread_self(); select_thread=pthread_self();
select_thread_in_use=1; select_thread_in_use=1;

View file

@ -778,6 +778,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file, DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file,
free_file)); free_file));
file->reset(); file->reset();
file->external_lock(current_thd, F_UNLCK);
file->close(); file->close();
} }
} }
@ -929,6 +930,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
THD *thd= current_thd;
if (!(file= get_new_handler(head, head->s->db_type))) if (!(file= get_new_handler(head, head->s->db_type)))
goto failure; goto failure;
DBUG_PRINT("info", ("Allocated new handler %p", file)); DBUG_PRINT("info", ("Allocated new handler %p", file));
@ -937,11 +939,14 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
/* Caller will free the memory */ /* Caller will free the memory */
goto failure; goto failure;
} }
if (file->external_lock(thd, F_RDLCK))
goto failure;
if (file->extra(HA_EXTRA_KEYREAD) || if (file->extra(HA_EXTRA_KEYREAD) ||
file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) || file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) ||
init() || reset()) init() || reset())
{ {
file->external_lock(thd, F_UNLCK);
file->close(); file->close();
goto failure; goto failure;
} }

View file

@ -3035,8 +3035,8 @@ int set_var_password::check(THD *thd)
if (!user->host.str) if (!user->host.str)
user->host.str= (char*) thd->host_or_ip; user->host.str= (char*) thd->host_or_ip;
/* Returns 1 as the function sends error to client */ /* Returns 1 as the function sends error to client */
return check_change_password(thd, user->host.str, user->user.str, password) ? return check_change_password(thd, user->host.str, user->user.str,
1 : 0; password, strlen(password)) ? 1 : 0;
#else #else
return 0; return 0;
#endif #endif

View file

@ -2610,18 +2610,19 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
init_abort_pos_wait= abort_pos_wait; init_abort_pos_wait= abort_pos_wait;
/* /*
We'll need to We'll need to
handle all possible log names comparisons (e.g. 999 vs 1000). handle all possible log names comparisons (e.g. 999 vs 1000).
We use ulong for string->number conversion ; this is no We use ulong for string->number conversion ; this is no
stronger limitation than in find_uniq_filename in sql/log.cc stronger limitation than in find_uniq_filename in sql/log.cc
*/ */
ulong log_name_extension; ulong log_name_extension;
char log_name_tmp[FN_REFLEN]; //make a char[] from String char log_name_tmp[FN_REFLEN]; //make a char[] from String
char *end= strmake(log_name_tmp, log_name->ptr(), min(log_name->length(),
FN_REFLEN-1)); strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
char *p= fn_ext(log_name_tmp); char *p= fn_ext(log_name_tmp);
char *p_end; char *p_end;
if (!*p || log_pos<0) if (!*p || log_pos<0)
{ {
error= -2; //means improper arguments error= -2; //means improper arguments
goto err; goto err;

View file

@ -1240,6 +1240,10 @@ bool acl_check_host(const char *host, const char *ip)
thd THD thd THD
host hostname for the user host hostname for the user
user user name user user name
new_password new password
NOTE:
new_password cannot be NULL
RETURN VALUE RETURN VALUE
0 OK 0 OK
@ -1247,7 +1251,7 @@ bool acl_check_host(const char *host, const char *ip)
*/ */
bool check_change_password(THD *thd, const char *host, const char *user, bool check_change_password(THD *thd, const char *host, const char *user,
char *new_password) char *new_password, uint new_password_len)
{ {
if (!initialized) if (!initialized)
{ {
@ -1296,12 +1300,13 @@ bool check_change_password(THD *thd, const char *host, const char *user,
bool change_password(THD *thd, const char *host, const char *user, bool change_password(THD *thd, const char *host, const char *user,
char *new_password) char *new_password)
{ {
uint new_password_len= strlen(new_password);
DBUG_ENTER("change_password"); DBUG_ENTER("change_password");
DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'", DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'",
host,user,new_password)); host,user,new_password));
DBUG_ASSERT(host != 0); // Ensured by parent DBUG_ASSERT(host != 0); // Ensured by parent
if (check_change_password(thd, host, user, new_password)) if (check_change_password(thd, host, user, new_password, new_password_len))
DBUG_RETURN(1); DBUG_RETURN(1);
VOID(pthread_mutex_lock(&acl_cache->lock)); VOID(pthread_mutex_lock(&acl_cache->lock));
@ -1313,7 +1318,6 @@ bool change_password(THD *thd, const char *host, const char *user,
DBUG_RETURN(1); DBUG_RETURN(1);
} }
/* update loaded acl entry: */ /* update loaded acl entry: */
uint new_password_len= new_password ? strlen(new_password) : 0;
set_user_salt(acl_user, new_password, new_password_len); set_user_salt(acl_user, new_password, new_password_len);
if (update_user_table(thd, if (update_user_table(thd,
@ -3241,7 +3245,7 @@ end:
SYNOPSIS SYNOPSIS
grant_reload() grant_reload()
thd Thread handler thd Thread handler (can be NULL)
NOTES NOTES
Locked tables are checked by acl_init and doesn't have to be checked here Locked tables are checked by acl_init and doesn't have to be checked here

View file

@ -176,7 +176,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, const char *passwd,
int acl_getroot_no_password(THD *thd); int acl_getroot_no_password(THD *thd);
bool acl_check_host(const char *host, const char *ip); bool acl_check_host(const char *host, const char *ip);
bool check_change_password(THD *thd, const char *host, const char *user, bool check_change_password(THD *thd, const char *host, const char *user,
char *password); char *password, uint password_len);
bool change_password(THD *thd, const char *host, const char *user, bool change_password(THD *thd, const char *host, const char *user,
char *password); char *password);
bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list, bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list,

View file

@ -70,6 +70,9 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
field_info **f_info; field_info **f_info;
DBUG_ENTER("proc_analyse_init"); DBUG_ENTER("proc_analyse_init");
if (!pc)
DBUG_RETURN(0);
if (!(param = param->next)) if (!(param = param->next))
{ {
pc->max_tree_elements = MAX_TREE_ELEMENTS; pc->max_tree_elements = MAX_TREE_ELEMENTS;
@ -81,33 +84,30 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
if ((*param->item)->type() != Item::INT_ITEM || if ((*param->item)->type() != Item::INT_ITEM ||
(*param->item)->val_real() < 0) (*param->item)->val_real() < 0)
{ {
delete pc;
my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
DBUG_RETURN(0); goto err;
} }
pc->max_tree_elements = (uint) (*param->item)->val_int(); pc->max_tree_elements = (uint) (*param->item)->val_int();
param = param->next; param = param->next;
if (param->next) // no third parameter possible if (param->next) // no third parameter possible
{ {
my_error(ER_WRONG_PARAMCOUNT_TO_PROCEDURE, MYF(0), proc_name); my_error(ER_WRONG_PARAMCOUNT_TO_PROCEDURE, MYF(0), proc_name);
DBUG_RETURN(0); goto err;
} }
// second parameter // second parameter
if ((*param->item)->type() != Item::INT_ITEM || if ((*param->item)->type() != Item::INT_ITEM ||
(*param->item)->val_real() < 0) (*param->item)->val_real() < 0)
{ {
delete pc;
my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
DBUG_RETURN(0); goto err;
} }
pc->max_treemem = (uint) (*param->item)->val_int(); pc->max_treemem = (uint) (*param->item)->val_int();
} }
else if ((*param->item)->type() != Item::INT_ITEM || else if ((*param->item)->type() != Item::INT_ITEM ||
(*param->item)->val_real() < 0) (*param->item)->val_real() < 0)
{ {
delete pc;
my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
DBUG_RETURN(0); goto err;
} }
// if only one parameter was given, it will be the value of max_tree_elements // if only one parameter was given, it will be the value of max_tree_elements
else else
@ -116,34 +116,39 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
pc->max_treemem = MAX_TREEMEM; pc->max_treemem = MAX_TREEMEM;
} }
if (!pc || !(pc->f_info = (field_info**) if (!(pc->f_info=
sql_alloc(sizeof(field_info*)*field_list.elements))) (field_info**)sql_alloc(sizeof(field_info*)*field_list.elements)))
DBUG_RETURN(0); goto err;
pc->f_end = pc->f_info + field_list.elements; pc->f_end = pc->f_info + field_list.elements;
pc->fields = field_list; pc->fields = field_list;
List_iterator_fast<Item> it(pc->fields);
f_info = pc->f_info;
Item *item;
while ((item = it++))
{ {
if (item->result_type() == INT_RESULT) List_iterator_fast<Item> it(pc->fields);
f_info = pc->f_info;
Item *item;
while ((item = it++))
{ {
// Check if fieldtype is ulonglong if (item->result_type() == INT_RESULT)
if (item->type() == Item::FIELD_ITEM && {
((Item_field*) item)->field->type() == FIELD_TYPE_LONGLONG && // Check if fieldtype is ulonglong
((Field_longlong*) ((Item_field*) item)->field)->unsigned_flag) if (item->type() == Item::FIELD_ITEM &&
*f_info++ = new field_ulonglong(item, pc); ((Item_field*) item)->field->type() == FIELD_TYPE_LONGLONG &&
else ((Field_longlong*) ((Item_field*) item)->field)->unsigned_flag)
*f_info++ = new field_longlong(item, pc); *f_info++ = new field_ulonglong(item, pc);
else
*f_info++ = new field_longlong(item, pc);
}
if (item->result_type() == REAL_RESULT)
*f_info++ = new field_real(item, pc);
if (item->result_type() == STRING_RESULT)
*f_info++ = new field_str(item, pc);
} }
if (item->result_type() == REAL_RESULT)
*f_info++ = new field_real(item, pc);
if (item->result_type() == STRING_RESULT)
*f_info++ = new field_str(item, pc);
} }
DBUG_RETURN(pc); DBUG_RETURN(pc);
err:
delete pc;
DBUG_RETURN(0);
} }

View file

@ -261,13 +261,19 @@ void free_io_cache(TABLE *table)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* Close all tables which aren't in use by any thread */ /*
Close all tables which aren't in use by any thread
THD can be NULL, but then if_wait_for_refresh must be FALSE
and tables must be NULL.
*/
bool close_cached_tables(THD *thd, bool if_wait_for_refresh, bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
TABLE_LIST *tables) TABLE_LIST *tables)
{ {
bool result=0; bool result=0;
DBUG_ENTER("close_cached_tables"); DBUG_ENTER("close_cached_tables");
DBUG_ASSERT(thd || (!if_wait_for_refresh && !tables));
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
if (!tables) if (!tables)
@ -343,7 +349,6 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
if (if_wait_for_refresh) if (if_wait_for_refresh)
{ {
THD *thd=current_thd;
pthread_mutex_lock(&thd->mysys_var->mutex); pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0; thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0; thd->mysys_var->current_cond= 0;
@ -2401,11 +2406,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
strxnmov(buff,sizeof(buff)-1,db,".",table_name,NullS); strxnmov(buff,sizeof(buff)-1,db,".",table_name,NullS);
table_name=buff; table_name=buff;
} }
if (report_error == REPORT_ALL_ERRORS || my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, thd->where);
report_error == REPORT_EXCEPT_NON_UNIQUE)
my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, thd->where);
else
return (Field*) not_found_field;
} }
else else
if (report_error == REPORT_ALL_ERRORS || if (report_error == REPORT_ALL_ERRORS ||

View file

@ -1164,12 +1164,12 @@ void Query_cache::invalidate(THD *thd, TABLE_LIST *tables_used,
DBUG_ASSERT(!using_transactions || tables_used->table!=0); DBUG_ASSERT(!using_transactions || tables_used->table!=0);
if (tables_used->derived) if (tables_used->derived)
continue; continue;
if (using_transactions && if (using_transactions &&
(tables_used->table->file->table_cache_type() == (tables_used->table->file->table_cache_type() ==
HA_CACHE_TBL_TRANSACT)) HA_CACHE_TBL_TRANSACT))
/* /*
Tables_used->table can't be 0 in transaction. Tables_used->table can't be 0 in transaction.
Only 'drop' invalidate not opened table, but 'drop' Only 'drop' invalidate not opened table, but 'drop'
force transaction finish. force transaction finish.
*/ */
thd->add_changed_table(tables_used->table); thd->add_changed_table(tables_used->table);
@ -1217,7 +1217,7 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
*/ */
void Query_cache::invalidate_locked_for_write(TABLE_LIST *tables_used) void Query_cache::invalidate_locked_for_write(TABLE_LIST *tables_used)
{ {
DBUG_ENTER("Query_cache::invalidate (changed table list)"); DBUG_ENTER("Query_cache::invalidate_locked_for_write");
if (query_cache_size > 0 && tables_used) if (query_cache_size > 0 && tables_used)
{ {
STRUCT_LOCK(&structure_guard_mutex); STRUCT_LOCK(&structure_guard_mutex);

View file

@ -227,7 +227,7 @@ void del_dbopt(const char *path)
} }
/* /*
Create database options file: Create database options file:
DESCRIPTION DESCRIPTION
@ -246,10 +246,10 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
if (!create->default_table_charset) if (!create->default_table_charset)
create->default_table_charset= thd->variables.collation_server; create->default_table_charset= thd->variables.collation_server;
if (put_dbopt(path, create)) if (put_dbopt(path, create))
return 1; return 1;
if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0)
{ {
ulong length; ulong length;
@ -531,21 +531,21 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
if ((error=write_db_opt(thd, path, create_info))) if ((error=write_db_opt(thd, path, create_info)))
goto exit; goto exit;
/* /*
Change options if current database is being altered Change options if current database is being altered
TODO: Delete this code TODO: Delete this code
*/ */
if (thd->db && !strcmp(thd->db,db)) if (thd->db && !strcmp(thd->db,db))
{ {
thd->db_charset= (create_info && create_info->default_table_charset) ? thd->db_charset= create_info->default_table_charset ?
create_info->default_table_charset : create_info->default_table_charset :
thd->variables.collation_server; thd->variables.collation_server;
thd->variables.collation_database= thd->db_charset; thd->variables.collation_database= thd->db_charset;
} }
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, Query_log_event qinfo(thd, thd->query, thd->query_length, 0,
/* suppress_use */ TRUE); /* suppress_use */ TRUE);
/* /*
@ -627,12 +627,12 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
pthread_mutex_lock(&LOCK_open); pthread_mutex_lock(&LOCK_open);
remove_db_from_cache(db); remove_db_from_cache(db);
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
error= -1; error= -1;
if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0)) >= 0) if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0)) >= 0)
{ {
ha_drop_database(path); ha_drop_database(path);
query_cache_invalidate1(db); query_cache_invalidate1(db);
error = 0; error = 0;
} }
} }
@ -643,7 +643,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
my_casedn_str(files_charset_info, tmp_db); my_casedn_str(files_charset_info, tmp_db);
db= tmp_db; db= tmp_db;
} }
if (!silent && deleted>=0 && thd) if (!silent && deleted>=0)
{ {
const char *query; const char *query;
ulong query_length; ulong query_length;
@ -693,7 +693,7 @@ exit:
have 'if (data_buf) free(data_buf)' data_buf is !=0 so this makes a have 'if (data_buf) free(data_buf)' data_buf is !=0 so this makes a
DOUBLE free(). DOUBLE free().
Side effects of this double free() are, randomly (depends on the machine), Side effects of this double free() are, randomly (depends on the machine),
when the slave is replicating a DROP DATABASE: when the slave is replicating a DROP DATABASE:
- garbage characters in the error message: - garbage characters in the error message:
"Error 'Can't drop database 'test2'; database doesn't exist' on query "Error 'Can't drop database 'test2'; database doesn't exist' on query
'h4zI<EFBFBD>©'" 'h4zI<EFBFBD>©'"

View file

@ -1603,9 +1603,6 @@ void st_select_lex::print_limit(THD *thd, String *str)
return; return;
} }
if (!thd)
thd= current_thd;
if (explicit_limit) if (explicit_limit)
{ {
str->append(" limit ", 7); str->append(" limit ", 7);

View file

@ -897,14 +897,16 @@ static int check_connection(THD *thd)
char *user= end; char *user= end;
char *passwd= strend(user)+1; char *passwd= strend(user)+1;
char *db= passwd; char *db= passwd;
char db_buff[NAME_LEN+1]; // buffer to store db in utf8 char db_buff[NAME_LEN+1]; // buffer to store db in utf8
char user_buff[USERNAME_LENGTH+1]; // buffer to store user in utf8 char user_buff[USERNAME_LENGTH+1]; // buffer to store user in utf8
/* uint dummy_errors;
/*
Old clients send null-terminated string as password; new clients send Old clients send null-terminated string as password; new clients send
the size (1 byte) + string (not null-terminated). Hence in case of empty the size (1 byte) + string (not null-terminated). Hence in case of empty
password both send '\0'. password both send '\0'.
*/ */
uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
*passwd++ : strlen(passwd); *passwd++ : strlen(passwd);
db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ? db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ?
db + passwd_len + 1 : 0; db + passwd_len + 1 : 0;
@ -912,7 +914,6 @@ static int check_connection(THD *thd)
/* Since 4.1 all database names are stored in utf8 */ /* Since 4.1 all database names are stored in utf8 */
if (db) if (db)
{ {
uint dummy_errors;
db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1,
system_charset_info, system_charset_info,
db, strlen(db), db, strlen(db),
@ -920,14 +921,10 @@ static int check_connection(THD *thd)
db= db_buff; db= db_buff;
} }
if (user) user_buff[copy_and_convert(user_buff, sizeof(user_buff)-1,
{ system_charset_info, user, strlen(user),
uint dummy_errors; thd->charset(), &dummy_errors)]= '\0';
user_buff[copy_and_convert(user_buff, sizeof(user_buff)-1, user= user_buff;
system_charset_info, user, strlen(user),
thd->charset(), &dummy_errors)]= '\0';
user= user_buff;
}
if (thd->user) if (thd->user)
x_free(thd->user); x_free(thd->user);
@ -3349,12 +3346,12 @@ unsent_create_error:
/* /*
If in a slave thread : If in a slave thread :
ALTER DATABASE DB may not be preceded by USE DB. ALTER DATABASE DB may not be preceded by USE DB.
For that reason, maybe db_ok() in sql/slave.cc did not check the For that reason, maybe db_ok() in sql/slave.cc did not check the
do_db/ignore_db. And as this query involves no tables, tables_ok() do_db/ignore_db. And as this query involves no tables, tables_ok()
above was not called. So we have to check rules again here. above was not called. So we have to check rules again here.
*/ */
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
if (thd->slave_thread && if (thd->slave_thread &&
(!db_ok(db, replicate_do_db, replicate_ignore_db) || (!db_ok(db, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(db))) !db_ok_with_wild_table(db)))
{ {
@ -3467,8 +3464,7 @@ unsent_create_error:
case SQLCOM_GRANT: case SQLCOM_GRANT:
{ {
if (check_access(thd, lex->grant | lex->grant_tot_col | GRANT_ACL, if (check_access(thd, lex->grant | lex->grant_tot_col | GRANT_ACL,
((first_table && first_table->db) ? first_table ? first_table->db : select_lex->db,
first_table->db : select_lex->db),
first_table ? &first_table->grant.privilege : 0, first_table ? &first_table->grant.privilege : 0,
first_table ? 0 : 1, 0)) first_table ? 0 : 1, 0))
goto error; goto error;

View file

@ -1977,10 +1977,10 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
for (table= tables; table; table= table->next_local) for (table= tables; table; table= table->next_local)
{ {
char table_name[NAME_LEN*2+2]; char table_name[NAME_LEN*2+2];
char* db = (table->db) ? table->db : thd->db; char* db = table->db;
bool fatal_error=0; bool fatal_error=0;
strxmov(table_name,db ? db : "",".",table->table_name,NullS);
strxmov(table_name, db, ".", table->table_name, NullS);
thd->open_options|= extra_open_options; thd->open_options|= extra_open_options;
table->lock_type= lock_type; table->lock_type= lock_type;
/* open only one table from local list of command */ /* open only one table from local list of command */

View file

@ -120,7 +120,7 @@ int mysql_update(THD *thd,
bool used_key_is_modified, transactional_table, log_delayed; bool used_key_is_modified, transactional_table, log_delayed;
int res; int res;
int error=0; int error=0;
uint used_index; uint used_index= MAX_KEY;
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
uint want_privilege; uint want_privilege;
#endif #endif
@ -134,7 +134,6 @@ int mysql_update(THD *thd,
SELECT_LEX *select_lex= &thd->lex->select_lex; SELECT_LEX *select_lex= &thd->lex->select_lex;
DBUG_ENTER("mysql_update"); DBUG_ENTER("mysql_update");
LINT_INIT(used_index);
LINT_INIT(timestamp_query_id); LINT_INIT(timestamp_query_id);
if (open_tables(thd, table_list, &table_count)) if (open_tables(thd, table_list, &table_count))
@ -273,7 +272,7 @@ int mysql_update(THD *thd,
matching rows before updating the table! matching rows before updating the table!
*/ */
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
if ( (used_index != MAX_KEY) && old_used_keys.is_set(used_index)) if (used_index < MAX_KEY && old_used_keys.is_set(used_index))
{ {
table->key_read=1; table->key_read=1;
table->file->extra(HA_EXTRA_KEYREAD); table->file->extra(HA_EXTRA_KEYREAD);

View file

@ -342,12 +342,14 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
VOID(my_seek(file,pos,MY_SEEK_SET,MYF(0))); VOID(my_seek(file,pos,MY_SEEK_SET,MYF(0)));
if (my_read(file,(byte*) head,288,MYF(MY_NABP))) if (my_read(file,(byte*) head,288,MYF(MY_NABP)))
goto err; goto err;
#ifdef HAVE_CRYPTED_FRM
if (crypted) if (crypted)
{ {
crypted->decode((char*) head+256,288-256); crypted->decode((char*) head+256,288-256);
if (sint2korr(head+284) != 0) // Should be 0 if (sint2korr(head+284) != 0) // Should be 0
goto err; // Wrong password goto err; // Wrong password
} }
#endif
share->fields= uint2korr(head+258); share->fields= uint2korr(head+258);
pos= uint2korr(head+260); /* Length of all screens */ pos= uint2korr(head+260); /* Length of all screens */
@ -375,12 +377,14 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
pos+ (uint) (n_length+int_length+com_length)); pos+ (uint) (n_length+int_length+com_length));
if (read_string(file,(gptr*) &disk_buff,read_length)) if (read_string(file,(gptr*) &disk_buff,read_length))
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
#ifdef HAVE_CRYPTED_FRM
if (crypted) if (crypted)
{ {
crypted->decode((char*) disk_buff,read_length); crypted->decode((char*) disk_buff,read_length);
delete crypted; delete crypted;
crypted=0; crypted=0;
} }
#endif
strpos= disk_buff+pos; strpos= disk_buff+pos;
share->intervals= (TYPELIB*) (field_ptr+share->fields+1); share->intervals= (TYPELIB*) (field_ptr+share->fields+1);

View file

@ -1861,7 +1861,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
{ {
ttid= (uint)table->field[1]->val_int(); ttid= (uint)table->field[1]->val_int();
if (ttid > TZ_MAX_TYPES) if (ttid >= TZ_MAX_TYPES)
{ {
sql_print_error("Error while loading time zone description from " sql_print_error("Error while loading time zone description from "
"mysql.time_zone_transition_type table: too big " "mysql.time_zone_transition_type table: too big "

View file

@ -26,7 +26,7 @@ EXTRA_DIST = auto_increment.res auto_increment.tst \
pmail.pl mail_to_db.pl table_types.pl \ pmail.pl mail_to_db.pl table_types.pl \
udf_test udf_test.res myisam-big-rows.tst udf_test udf_test.res myisam-big-rows.tst
bin_PROGRAMS = client_test bin_PROGRAMS = mysql_client_test
noinst_PROGRAMS = insert_test select_test thread_test noinst_PROGRAMS = insert_test select_test thread_test
# #
@ -38,7 +38,7 @@ LDADD = @CLIENT_EXTRA_LDFLAGS@ \
$(top_builddir)/libmysql/libmysqlclient.la $(top_builddir)/libmysql/libmysqlclient.la
client_test_LDADD= $(LDADD) $(CXXLDFLAGS) \ client_test_LDADD= $(LDADD) $(CXXLDFLAGS) \
$(top_builddir)/mysys/libmysys.a $(top_builddir)/mysys/libmysys.a
client_test_SOURCES= client_test.c client_test_SOURCES= mysql_client_test.c
insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)

View file

@ -11406,6 +11406,12 @@ static void test_bug5194()
if (bind == 0 || query == 0 || param_str == 0) if (bind == 0 || query == 0 || param_str == 0)
{ {
fprintf(stderr, "Can't allocate enough memory for query structs\n"); fprintf(stderr, "Can't allocate enough memory for query structs\n");
if (bind)
free(bind);
if (query)
free(query);
if (param_str)
free(param_str);
return; return;
} }

View file

@ -142,23 +142,29 @@ int vio_fastsend(Vio * vio __attribute__((unused)))
int r=0; int r=0;
DBUG_ENTER("vio_fastsend"); DBUG_ENTER("vio_fastsend");
#ifdef IPTOS_THROUGHPUT #if defined(IPTOS_THROUGHPUT) && !defined(__EMX__)
{ {
#ifndef __EMX__
int tos = IPTOS_THROUGHPUT; int tos = IPTOS_THROUGHPUT;
if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos))) r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos));
#endif /* !__EMX__ */ }
{ #endif /* IPTOS_THROUGHPUT && !__EMX__ */
int nodelay = 1; if (!r)
if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay, {
sizeof(nodelay))) { #ifdef __WIN__
DBUG_PRINT("warning", BOOL nodelay= 1;
("Couldn't set socket option for fast send")); r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (const char*) &nodelay,
r= -1; sizeof(nodelay));
} #else
} int nodelay = 1;
r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void*) &nodelay,
sizeof(nodelay));
#endif /* __WIN__ */
}
if (r)
{
DBUG_PRINT("warning", ("Couldn't set socket option for fast send"));
r= -1;
} }
#endif /* IPTOS_THROUGHPUT */
DBUG_PRINT("exit", ("%d", r)); DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r); DBUG_RETURN(r);
} }