summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2005-10-13 17:17:32 +0400
committerunknown <evgen@moonbone.local>2005-10-13 17:17:32 +0400
commit8b6ba46c2c957ca23e4d8440e53369f485c85c86 (patch)
tree3b306436788cb89a4776bc07a508684c67ea4f08 /sql
parent228d5c42fae46260671478961de9646f6cc4925f (diff)
parent341fbced18ad7f81ceba4c2dcc88badc1b7a3682 (diff)
downloadmariadb-git-8b6ba46c2c957ca23e4d8440e53369f485c85c86.tar.gz
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1
into moonbone.local:/work/13535-bug-4.1-mysql mysql-test/r/select.result: Auto merged mysql-test/t/select.test: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc15
-rw-r--r--sql/item.h8
-rw-r--r--sql/item_strfunc.cc8
-rw-r--r--sql/mysqld.cc37
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_lex.h1
-rw-r--r--sql/sql_select.cc5
7 files changed, 43 insertions, 33 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 7419bc173d5..d284af2b9f1 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1760,6 +1760,21 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if ((tmp= find_field_in_tables(thd, this, tables, &where, 0)) ==
not_found_field)
{
+ /* Look up in current select's item_list to find aliased fields */
+ if (thd->lex->current_select->is_item_list_lookup)
+ {
+ uint counter;
+ bool not_used;
+ Item** res= find_item_in_list(this, thd->lex->current_select->item_list,
+ &counter, REPORT_EXCEPT_NOT_FOUND,
+ &not_used);
+ if (res != not_found_item && (*res)->type() == Item::FIELD_ITEM)
+ {
+ set_field((*((Item_field**)res))->field);
+ return 0;
+ }
+ }
+
/*
We can't find table field in table list of current select,
consequently we have to find it in outer subselect(s).
diff --git a/sql/item.h b/sql/item.h
index b1aed733101..1d01ce0d3f3 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -703,6 +703,14 @@ public:
longlong val_int()
{
DBUG_ASSERT(fixed == 1);
+ if (value <= (double) LONGLONG_MIN)
+ {
+ return LONGLONG_MIN;
+ }
+ else if (value >= (double) (ulonglong) LONGLONG_MAX)
+ {
+ return LONGLONG_MAX;
+ }
return (longlong) (value+(value > 0 ? 0.5 : -0.5));
}
String *val_str(String*);
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 6962ba7c4ac..6ca6ce62c54 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1497,7 +1497,13 @@ String *Item_func_encrypt::val_str(String *str)
salt_ptr= salt_str->c_ptr();
}
pthread_mutex_lock(&LOCK_crypt);
- char *tmp=crypt(res->c_ptr(),salt_ptr);
+ char *tmp= crypt(res->c_ptr(),salt_ptr);
+ if (!tmp)
+ {
+ pthread_mutex_unlock(&LOCK_crypt);
+ null_value= 1;
+ return 0;
+ }
str->set(tmp,(uint) strlen(tmp),res->charset());
str->copy();
pthread_mutex_unlock(&LOCK_crypt);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 55077b22320..bb5402de3fd 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -860,7 +860,7 @@ static void __cdecl kill_server(int sig_ptr)
RETURN_FROM_KILL_SERVER;
kill_in_progress=TRUE;
abort_loop=1; // This should be set
- signal(sig,SIG_IGN);
+ my_sigset(sig,SIG_IGN);
if (sig == MYSQL_KILL_SIGNAL || sig == 0)
sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname);
else
@@ -908,11 +908,6 @@ extern "C" pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
}
#endif
-#if defined(__amiga__)
-#undef sigset
-#define sigset signal
-#endif
-
extern "C" sig_handler print_signal_warning(int sig)
{
if (!DBUG_IN_USE)
@@ -922,7 +917,7 @@ extern "C" sig_handler print_signal_warning(int sig)
sig,my_thread_id());
}
#ifdef DONT_REMEMBER_SIGNAL
- sigset(sig,print_signal_warning); /* int. thread system calls */
+ my_sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
if (sig == SIGALRM)
@@ -1587,23 +1582,6 @@ void flush_thread_cache()
}
-/*
- Aborts a thread nicely. Commes here on SIGPIPE
- TODO: One should have to fix that thr_alarm know about this
- thread too.
-*/
-
-#ifdef THREAD_SPECIFIC_SIGPIPE
-extern "C" sig_handler abort_thread(int sig __attribute__((unused)))
-{
- THD *thd=current_thd;
- DBUG_ENTER("abort_thread");
- if (thd)
- thd->killed=1;
- DBUG_VOID_RETURN;
-}
-#endif
-
/******************************************************************************
Setup a signal thread with handles all signals.
Because Linux doesn't support schemas use a mutex to check that
@@ -2019,8 +1997,8 @@ static void init_signals(void)
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
- sigset(THR_KILL_SIGNAL,end_thread_signal);
- sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
+ my_sigset(THR_KILL_SIGNAL,end_thread_signal);
+ my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
{
@@ -2054,13 +2032,8 @@ static void init_signals(void)
}
#endif
(void) sigemptyset(&set);
-#ifdef THREAD_SPECIFIC_SIGPIPE
- sigset(SIGPIPE,abort_thread);
- sigaddset(&set,SIGPIPE);
-#else
- (void) signal(SIGPIPE,SIG_IGN); // Can't know which thread
+ my_sigset(SIGPIPE,SIG_IGN);
sigaddset(&set,SIGPIPE);
-#endif
sigaddset(&set,SIGINT);
#ifndef IGNORE_SIGHUP_SIGQUIT
sigaddset(&set,SIGQUIT);
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 8636b6542fc..16641ad6dd5 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1083,6 +1083,7 @@ void st_select_lex::init_query()
prep_where= 0;
subquery_in_having= explicit_limit= 0;
parsing_place= NO_MATTER;
+ is_item_list_lookup= 0;
}
void st_select_lex::init_select()
@@ -1109,6 +1110,7 @@ void st_select_lex::init_select()
select_limit= HA_POS_ERROR;
offset_limit= 0;
with_sum_func= 0;
+
}
/*
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 8d919f12563..47908ba8685 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -426,6 +426,7 @@ public:
List<Item> item_list; /* list of fields & expressions */
List<String> interval_list, use_index, *use_index_ptr,
ignore_index, *ignore_index_ptr;
+ bool is_item_list_lookup;
/*
Usualy it is pointer to ftfunc_list_alloc, but in union used to create fake
select_lex for calling mysql_select under results of union
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 0d9cab6a36b..f72d897e22d 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8348,11 +8348,16 @@ find_order_in_list(THD *thd, Item **ref_pointer_array,
'it' reassigned in if condition because fix_field can change it.
*/
+ thd->lex->current_select->is_item_list_lookup= 1;
if (!it->fixed &&
(it->fix_fields(thd, tables, order->item) ||
(it= *order->item)->check_cols(1) ||
thd->is_fatal_error))
+ {
+ thd->lex->current_select->is_item_list_lookup= 0;
return 1; // Wrong field
+ }
+ thd->lex->current_select->is_item_list_lookup= 0;
uint el= all_fields.elements;
all_fields.push_front(it); // Add new field to field list
ref_pointer_array[el]= it;