summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-07-18 23:45:17 +0400
committerunknown <evgen@moonbone.local>2006-07-18 23:45:17 +0400
commitdc50ce997083b4f3d3e4ab237c6a1f5e11cfd90f (patch)
treea7cde77bb894ad2fe7efa42cf6785616d7604353 /sql
parentec40f4a588faa4b759816fd619929088b0723c24 (diff)
parent7c7396cee5e8f88763a7b3468f4ae3f543195cf2 (diff)
downloadmariadb-git-dc50ce997083b4f3d3e4ab237c6a1f5e11cfd90f.tar.gz
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into moonbone.local:/work/tmp_merge-5.0-opt-mysql client/mysql.cc: Auto merged mysql-test/r/date_formats.result: Auto merged mysql-test/r/func_str.result: Auto merged mysql-test/t/date_formats.test: Auto merged mysql-test/t/func_str.test: Auto merged sql/item_strfunc.cc: Auto merged sql/sql_class.cc: Auto merged sql/time.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/item_func.h5
-rw-r--r--sql/item_strfunc.cc4
-rw-r--r--sql/sql_acl.cc4
-rw-r--r--sql/sql_parse.cc16
-rw-r--r--sql/sql_prepare.cc3
-rw-r--r--sql/table.cc16
-rw-r--r--sql/table.h5
7 files changed, 43 insertions, 10 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index 2ca4be9f3f2..c54fc701c53 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -156,7 +156,10 @@ public:
{
return (null_value=args[0]->get_time(ltime));
}
- bool is_null() { (void) val_int(); return null_value; }
+ bool is_null() {
+ (void) val_int(); /* Discard result. It sets null_value as side-effect. */
+ return null_value;
+ }
void signal_divide_by_null();
friend class udf_handler;
Field *tmp_table_field() { return result_field; }
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index c03f360271f..5ceb462385c 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1041,7 +1041,7 @@ String *Item_func_left::val_str(String *str)
long length =(long) args[1]->val_int();
uint char_pos;
- if ((null_value=args[0]->null_value))
+ if ((null_value=(args[0]->null_value || args[1]->null_value)))
return 0;
if (length <= 0)
return &my_empty_string;
@@ -1081,7 +1081,7 @@ String *Item_func_right::val_str(String *str)
String *res =args[0]->val_str(str);
long length =(long) args[1]->val_int();
- if ((null_value=args[0]->null_value))
+ if ((null_value=(args[0]->null_value || args[1]->null_value)))
return 0; /* purecov: inspected */
if (length <= 0)
return &my_empty_string; /* purecov: inspected */
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index f7dac349d8a..ae5ea210a47 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -149,8 +149,8 @@ my_bool acl_init(bool dont_read_acl_tables)
acl_cache= new hash_filo(ACL_CACHE_SIZE, 0, 0,
(hash_get_key) acl_entry_get_key,
(hash_free_key) free,
- /* Use the case sensitive "binary" charset */
- &my_charset_bin);
+ lower_case_file_system ?
+ system_charset_info : &my_charset_bin);
if (dont_read_acl_tables)
{
DBUG_RETURN(0); /* purecov: tested */
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6dbd6623264..e37bc7cc3f7 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -69,8 +69,8 @@ extern "C" int gethostname(char *name, int namelen);
static void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
static int check_for_max_user_connections(THD *thd, USER_CONN *uc);
-#endif
static void decrease_user_connections(USER_CONN *uc);
+#endif /* NO_EMBEDDED_ACCESS_CHECKS */
static bool check_db_used(THD *thd,TABLE_LIST *tables);
static bool check_multi_update_lock(THD *thd);
static void remove_escape(char *name);
@@ -204,6 +204,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables)
return 0;
}
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
static HASH hash_user_connections;
static int get_or_create_user_conn(THD *thd, const char *user,
@@ -255,6 +256,7 @@ end:
return return_val;
}
+#endif /* !NO_EMBEDDED_ACCESS_CHECKS */
/*
@@ -303,8 +305,6 @@ int check_user(THD *thd, enum enum_server_command command,
{
/* Send the error to the client */
net_send_error(thd);
- if (thd->user_connect)
- decrease_user_connections(thd->user_connect);
DBUG_RETURN(-1);
}
}
@@ -495,10 +495,12 @@ extern "C" void free_user(struct user_conn *uc)
void init_max_user_conn(void)
{
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
(void) hash_init(&hash_user_connections,system_charset_info,max_connections,
0,0,
(hash_get_key) get_key_conn, (hash_free_key) free_user,
0);
+#endif
}
@@ -561,7 +563,6 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc)
(void) pthread_mutex_unlock(&LOCK_user_conn);
DBUG_RETURN(error);
}
-#endif /* NO_EMBEDDED_ACCESS_CHECKS */
/*
Decrease user connection count
@@ -595,13 +596,18 @@ static void decrease_user_connections(USER_CONN *uc)
DBUG_VOID_RETURN;
}
+#endif /* NO_EMBEDDED_ACCESS_CHECKS */
+
void free_max_user_conn(void)
{
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
hash_free(&hash_user_connections);
+#endif /* NO_EMBEDDED_ACCESS_CHECKS */
}
+
/*
Mark all commands that somehow changes a table
This is used to check number of updates / hour
@@ -1706,9 +1712,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
else
{
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
/* we've authenticated new user */
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);
}
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 103a0b9e54e..ffe54310843 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2135,7 +2135,8 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
Reset old pointers to TABLEs: they are not valid since the tables
were closed in the end of previous prepare or execute call.
*/
- tables->table= 0;
+ tables->reinit_before_use(thd);
+
/* Reset is_schema_table_processed value(needed for I_S tables */
tables->is_schema_table_processed= FALSE;
diff --git a/sql/table.cc b/sql/table.cc
index 728b98b2d35..e50b401df5f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2985,6 +2985,22 @@ Field_iterator_table_ref::get_natural_column_ref()
return nj_col;
}
+/*
+ Cleanup this table for re-execution.
+
+ SYNOPSIS
+ st_table_list::reinit_before_use()
+*/
+
+void st_table_list::reinit_before_use(THD * /* thd */)
+{
+ /*
+ Reset old pointers to TABLEs: they are not valid since the tables
+ were closed in the end of previous prepare or execute call.
+ */
+ table= 0;
+}
+
/*****************************************************************************
** Instansiate templates
diff --git a/sql/table.h b/sql/table.h
index d23d58e964f..eb34867c390 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -668,6 +668,11 @@ typedef struct st_table_list
Security_context *find_view_security_context(THD *thd);
bool prepare_view_securety_context(THD *thd);
#endif
+ /*
+ Cleanup for re-execution in a prepared statement or a stored
+ procedure.
+ */
+ void reinit_before_use(THD *thd);
private:
bool prep_check_option(THD *thd, uint8 check_opt_type);