Commit 8f4847f3 authored by unknown's avatar unknown

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

into ice.snake.net:/Volumes/ice2/MySQL/bk/mysql-4.1


configure.in:
  Auto merged
parents f00cd26b 4603a7b3
...@@ -786,3 +786,4 @@ vio/test-sslserver ...@@ -786,3 +786,4 @@ vio/test-sslserver
vio/viotest-ssl vio/viotest-ssl
extra/tztime.cc extra/tztime.cc
extra/mysql_tzinfo_to_sql extra/mysql_tzinfo_to_sql
sql/mysql_tzinfo_to_sql_tztime.cc
...@@ -2407,6 +2407,8 @@ do ...@@ -2407,6 +2407,8 @@ do
AC_DEFINE(USE_MB) AC_DEFINE(USE_MB)
AC_DEFINE(USE_MB_IDENT) AC_DEFINE(USE_MB_IDENT)
;; ;;
binary)
;;
cp1250) cp1250)
AC_DEFINE(HAVE_CHARSET_cp1250) AC_DEFINE(HAVE_CHARSET_cp1250)
;; ;;
...@@ -2533,6 +2535,10 @@ case $default_charset in ...@@ -2533,6 +2535,10 @@ case $default_charset in
default_charset_default_collation="big5_chinese_ci" default_charset_default_collation="big5_chinese_ci"
default_charset_collations="big5_chinese_ci big5_bin" default_charset_collations="big5_chinese_ci big5_bin"
;; ;;
binary)
default_charset_default_collation="binary"
default_charset_collations="binary"
;;
cp1250) cp1250)
default_charset_default_collation="cp1250_general_ci" default_charset_default_collation="cp1250_general_ci"
default_charset_collations="cp1250_general_ci cp1250_czech_ci cp1250_bin" default_charset_collations="cp1250_general_ci cp1250_czech_ci cp1250_bin"
......
...@@ -119,3 +119,21 @@ EXECUTE stmt1 USING @var; ...@@ -119,3 +119,21 @@ EXECUTE stmt1 USING @var;
_utf8 'A' collate utf8_bin = ? _utf8 'A' collate utf8_bin = ?
1 1
DEALLOCATE PREPARE stmt1; DEALLOCATE PREPARE stmt1;
create table t1 (id int);
prepare stmt1 from "select FOUND_ROWS()";
select SQL_CALC_FOUND_ROWS * from t1;
id
execute stmt1;
FOUND_ROWS()
0
insert into t1 values (1);
select SQL_CALC_FOUND_ROWS * from t1;
id
1
execute stmt1;
FOUND_ROWS()
1
execute stmt1;
FOUND_ROWS()
0
deallocate prepare stmt1;
...@@ -124,3 +124,19 @@ PREPARE stmt1 FROM "select _utf8 'A' collate utf8_bin = ?"; ...@@ -124,3 +124,19 @@ PREPARE stmt1 FROM "select _utf8 'A' collate utf8_bin = ?";
set @var='A'; set @var='A';
EXECUTE stmt1 USING @var; EXECUTE stmt1 USING @var;
DEALLOCATE PREPARE stmt1; DEALLOCATE PREPARE stmt1;
#
# BUG#3486: FOUND_ROWS() fails inside stored procedure [and prepared statement]
#
create table t1 (id int);
prepare stmt1 from "select FOUND_ROWS()";
select SQL_CALC_FOUND_ROWS * from t1;
# Expect 0
execute stmt1;
insert into t1 values (1);
select SQL_CALC_FOUND_ROWS * from t1;
# Expect 1
execute stmt1;
# Expect 0
execute stmt1;
deallocate prepare stmt1;
...@@ -27,6 +27,7 @@ WRAPLIBS= @WRAPLIBS@ ...@@ -27,6 +27,7 @@ WRAPLIBS= @WRAPLIBS@
SUBDIRS = share SUBDIRS = share
libexec_PROGRAMS = mysqld libexec_PROGRAMS = mysqld
noinst_PROGRAMS = gen_lex_hash noinst_PROGRAMS = gen_lex_hash
bin_PROGRAMS = mysql_tzinfo_to_sql
gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@ gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@
LDADD = @isam_libs@ \ LDADD = @isam_libs@ \
../myisam/libmyisam.a \ ../myisam/libmyisam.a \
...@@ -92,6 +93,10 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ ...@@ -92,6 +93,10 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
gen_lex_hash_SOURCES = gen_lex_hash.cc gen_lex_hash_SOURCES = gen_lex_hash.cc
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS) gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql_tztime.cc
mysql_tzinfo_to_sql_CXXFLAGS = -DTZINFO2SQL $(AM_CXXFLAGS)
mysql_tzinfo_to_sql_LDADD = $(LDADD) $(CXXLDFLAGS)
DEFS = -DMYSQL_SERVER \ DEFS = -DMYSQL_SERVER \
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \
...@@ -113,6 +118,10 @@ link_sources: ...@@ -113,6 +118,10 @@ link_sources:
gen_lex_hash.o: gen_lex_hash.cc lex.h gen_lex_hash.o: gen_lex_hash.cc lex.h
$(CXXCOMPILE) -c $(INCLUDES) $< $(CXXCOMPILE) -c $(INCLUDES) $<
mysql_tzinfo_to_sql_tztime.cc: tztime.cc
rm -f $(srcdir)/mysql_tzinfo_to_sql_tztime.cc
@LN_CP_F@ $(srcdir)/tztime.cc $(srcdir)/mysql_tzinfo_to_sql_tztime.cc
# Try to get better dependencies for the grammar. Othervise really bad # Try to get better dependencies for the grammar. Othervise really bad
# things like different grammars for different pars of MySQL can # things like different grammars for different pars of MySQL can
# happen if you are unlucky. # happen if you are unlucky.
......
...@@ -1013,16 +1013,29 @@ bool ha_myisam::check_and_repair(THD *thd) ...@@ -1013,16 +1013,29 @@ bool ha_myisam::check_and_repair(THD *thd)
if (!file->state->del && (myisam_recover_options & HA_RECOVER_QUICK)) if (!file->state->del && (myisam_recover_options & HA_RECOVER_QUICK))
check_opt.flags|=T_QUICK; check_opt.flags|=T_QUICK;
sql_print_error("Warning: Checking table: '%s'",table->path); sql_print_error("Warning: Checking table: '%s'",table->path);
if ((marked_crashed=mi_is_crashed(file)) || check(thd, &check_opt)) if ((marked_crashed=mi_is_crashed(file)))
{ {
sql_print_error("Warning: Recovering table: '%s'",table->path); char *old_query= thd->query;
check_opt.flags= uint old_query_length= thd->query_length;
((myisam_recover_options & HA_RECOVER_BACKUP ? T_BACKUP_DATA : 0) | pthread_mutex_lock(&LOCK_thread_count);
(marked_crashed ? 0 : T_QUICK) | thd->query= table->real_name;
(myisam_recover_options & HA_RECOVER_FORCE ? 0 : T_SAFE_REPAIR) | thd->query_length= strlen(table->real_name);
T_AUTO_REPAIR); pthread_mutex_unlock(&LOCK_thread_count);
if (repair(thd, &check_opt)) if (check(thd, &check_opt))
error=1; {
sql_print_error("Warning: Recovering table: '%s'",table->path);
check_opt.flags=
((myisam_recover_options & HA_RECOVER_BACKUP ? T_BACKUP_DATA : 0) |
(marked_crashed ? 0 : T_QUICK) |
(myisam_recover_options & HA_RECOVER_FORCE ? 0 : T_SAFE_REPAIR) |
T_AUTO_REPAIR);
if (repair(thd, &check_opt))
error=1;
}
pthread_mutex_lock(&LOCK_thread_count);
thd->query= old_query;
thd->query_length= old_query_length;
pthread_mutex_unlock(&LOCK_thread_count);
} }
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
...@@ -578,10 +578,11 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) ...@@ -578,10 +578,11 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
if ((trans == &thd->transaction.all) && mysql_bin_log.is_open()) if ((trans == &thd->transaction.all) && mysql_bin_log.is_open())
{ {
/* /*
Update the binary log with a BEGIN/ROLLBACK block if we have cached some Update the binary log with a BEGIN/ROLLBACK block if we have
queries and we updated some non-transactional table. Such cases should cached some queries and we updated some non-transactional
be rare (updating a non-transactional table inside a transaction...). table. Such cases should be rare (updating a
Count disk writes to trans_log in any case. non-transactional table inside a transaction...). Count disk
writes to trans_log in any case.
*/ */
if (my_b_tell(&thd->transaction.trans_log)) if (my_b_tell(&thd->transaction.trans_log))
{ {
...@@ -626,12 +627,12 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) ...@@ -626,12 +627,12 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
simply truncate the binlog cache, we lose the part of the binlog cache where simply truncate the binlog cache, we lose the part of the binlog cache where
the update is. If we want to not lose it, we need to write the SAVEPOINT the update is. If we want to not lose it, we need to write the SAVEPOINT
command and the ROLLBACK TO SAVEPOINT command to the binlog cache. The latter command and the ROLLBACK TO SAVEPOINT command to the binlog cache. The latter
is easy: it's just write at the end of the binlog cache, but the former should is easy: it's just write at the end of the binlog cache, but the former
be *inserted* to the place where the user called SAVEPOINT. The solution is should be *inserted* to the place where the user called SAVEPOINT. The
that when the user calls SAVEPOINT, we write it to the binlog cache (so no solution is that when the user calls SAVEPOINT, we write it to the binlog
need to later insert it). As transactions are never intermixed in the binary log cache (so no need to later insert it). As transactions are never intermixed
(i.e. they are serialized), we won't have conflicts with savepoint names when in the binary log (i.e. they are serialized), we won't have conflicts with
using mysqlbinlog or in the slave SQL thread. savepoint names when using mysqlbinlog or in the slave SQL thread.
Then when ROLLBACK TO SAVEPOINT is called, if we updated some Then when ROLLBACK TO SAVEPOINT is called, if we updated some
non-transactional table, we don't truncate the binlog cache but instead write non-transactional table, we don't truncate the binlog cache but instead write
ROLLBACK TO SAVEPOINT to it; otherwise we truncate the binlog cache (which ROLLBACK TO SAVEPOINT to it; otherwise we truncate the binlog cache (which
......
...@@ -154,7 +154,7 @@ Item *create_func_found_rows(void) ...@@ -154,7 +154,7 @@ Item *create_func_found_rows(void)
{ {
THD *thd=current_thd; THD *thd=current_thd;
thd->lex->safe_to_cache_query= 0; thd->lex->safe_to_cache_query= 0;
return new Item_int(NullS,(longlong) thd->found_rows(),21); return new Item_func_found_rows();
} }
Item *create_func_from_days(Item* a) Item *create_func_from_days(Item* a)
......
...@@ -3234,3 +3234,12 @@ longlong Item_func_is_used_lock::val_int() ...@@ -3234,3 +3234,12 @@ longlong Item_func_is_used_lock::val_int()
null_value=0; null_value=0;
return ull->thread_id; return ull->thread_id;
} }
longlong Item_func_found_rows::val_int()
{
DBUG_ASSERT(fixed == 1);
THD *thd= current_thd;
return thd->found_rows();
}
...@@ -1071,3 +1071,13 @@ enum Cast_target ...@@ -1071,3 +1071,13 @@ enum Cast_target
ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT, ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT,
ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR
}; };
class Item_func_found_rows :public Item_int_func
{
public:
Item_func_found_rows() :Item_int_func() {}
longlong val_int();
const char *func_name() const { return "found_rows"; }
void fix_length_and_dec() { decimals= 0; maybe_null=0; }
};
...@@ -1258,12 +1258,12 @@ bool MYSQL_LOG::write(Log_event* event_info) ...@@ -1258,12 +1258,12 @@ bool MYSQL_LOG::write(Log_event* event_info)
{ {
char buf[200]; char buf[200];
int written= my_snprintf(buf, sizeof(buf)-1, int written= my_snprintf(buf, sizeof(buf)-1,
"SET ONE_SHOT CHARACTER_SET_CLIENT=%lu,\ "SET ONE_SHOT CHARACTER_SET_CLIENT=%u,\
COLLATION_CONNECTION=%lu,COLLATION_DATABASE=%lu,COLLATION_SERVER=%lu", COLLATION_CONNECTION=%u,COLLATION_DATABASE=%u,COLLATION_SERVER=%u",
thd->variables.character_set_client->number, (uint) thd->variables.character_set_client->number,
thd->variables.collation_connection->number, (uint) thd->variables.collation_connection->number,
thd->variables.collation_database->number, (uint) thd->variables.collation_database->number,
thd->variables.collation_server->number); (uint) thd->variables.collation_server->number);
Query_log_event e(thd, buf, written, 0); Query_log_event e(thd, buf, written, 0);
e.set_log_pos(this); e.set_log_pos(this);
if (e.write(file)) if (e.write(file))
......
...@@ -1610,7 +1610,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, ...@@ -1610,7 +1610,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
if (name) if (name)
{ {
stmt->name.length= name->length; stmt->name.length= name->length;
if (!(stmt->name.str= memdup_root(&stmt->mem_root, (byte*)name->str, if (!(stmt->name.str= memdup_root(&stmt->mem_root, (char*)name->str,
name->length))) name->length)))
{ {
delete stmt; delete stmt;
......
...@@ -1088,12 +1088,14 @@ JOIN::exec() ...@@ -1088,12 +1088,14 @@ JOIN::exec()
DBUG_ENTER("JOIN::exec"); DBUG_ENTER("JOIN::exec");
error= 0; error= 0;
thd->limit_found_rows= thd->examined_row_count= 0;
if (procedure) if (procedure)
{ {
if (procedure->change_columns(fields_list) || if (procedure->change_columns(fields_list) ||
result->prepare(fields_list, unit)) result->prepare(fields_list, unit))
{
thd->limit_found_rows= thd->examined_row_count= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
}
} }
if (!tables_list) if (!tables_list)
...@@ -1119,8 +1121,10 @@ JOIN::exec() ...@@ -1119,8 +1121,10 @@ JOIN::exec()
else else
error=(int) result->send_eof(); error=(int) result->send_eof();
} }
thd->limit_found_rows= thd->examined_row_count= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
thd->limit_found_rows= thd->examined_row_count= 0;
if (zero_result_cause) if (zero_result_cause)
{ {
......
...@@ -24,13 +24,11 @@ ...@@ -24,13 +24,11 @@
#pragma implementation // gcc: Class implementation #pragma implementation // gcc: Class implementation
#endif #endif
#include "mysql_priv.h" #include "mysql_priv.h"
#include "tzfile.h" #include "tzfile.h"
#include <m_string.h> #include <m_string.h>
#include <my_dir.h> #include <my_dir.h>
/* /*
Now we don't use abbreviations in server but we will do this in future. Now we don't use abbreviations in server but we will do this in future.
*/ */
...@@ -53,8 +51,8 @@ typedef struct ttinfo ...@@ -53,8 +51,8 @@ typedef struct ttinfo
uint tt_abbrind; // Index of start of abbreviation for this time type. uint tt_abbrind; // Index of start of abbreviation for this time type.
#endif #endif
/* /*
We don't use tt_ttisstd and tt_ttisgmt members of original elsie-code struct We don't use tt_ttisstd and tt_ttisgmt members of original elsie-code
since we don't support POSIX-style TZ descriptions in variables. struct since we don't support POSIX-style TZ descriptions in variables.
*/ */
} TRAN_TYPE_INFO; } TRAN_TYPE_INFO;
...@@ -1337,6 +1335,7 @@ static MEM_ROOT tz_storage; ...@@ -1337,6 +1335,7 @@ static MEM_ROOT tz_storage;
tz_storage. So contention is low. tz_storage. So contention is low.
*/ */
static pthread_mutex_t tz_LOCK; static pthread_mutex_t tz_LOCK;
static bool tz_inited= 0;
/* /*
This two static variables are inteded for holding info about leap seconds This two static variables are inteded for holding info about leap seconds
...@@ -1410,7 +1409,6 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) ...@@ -1410,7 +1409,6 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
my_bool return_val= 1; my_bool return_val= 1;
int res; int res;
uint not_used; uint not_used;
DBUG_ENTER("my_tz_init"); DBUG_ENTER("my_tz_init");
/* /*
...@@ -1436,6 +1434,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) ...@@ -1436,6 +1434,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
} }
init_alloc_root(&tz_storage, 32 * 1024, 0); init_alloc_root(&tz_storage, 32 * 1024, 0);
VOID(pthread_mutex_init(&tz_LOCK, MY_MUTEX_INIT_FAST)); VOID(pthread_mutex_init(&tz_LOCK, MY_MUTEX_INIT_FAST));
tz_inited= 1;
/* Add 'SYSTEM' time zone to tz_names hash */ /* Add 'SYSTEM' time zone to tz_names hash */
if (!(tmp_tzname= new (&tz_storage) TZ_NAMES_ENTRY())) if (!(tmp_tzname= new (&tz_storage) TZ_NAMES_ENTRY()))
...@@ -1591,12 +1590,17 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) ...@@ -1591,12 +1590,17 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
SYNOPSIS SYNOPSIS
my_tz_free() my_tz_free()
*/ */
void my_tz_free() void my_tz_free()
{ {
VOID(pthread_mutex_destroy(&tz_LOCK)); if (tz_inited)
hash_free(&offset_tzs); {
hash_free(&tz_names); tz_inited= 0;
free_root(&tz_storage, MYF(0)); VOID(pthread_mutex_destroy(&tz_LOCK));
hash_free(&offset_tzs);
hash_free(&tz_names);
free_root(&tz_storage, MYF(0));
}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment