mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Merge bk-internal:/home/bk/mysql-4.1/
into serg.mylan:/usr/home/serg/Abk/mysql-4.1 sql/sql_select.cc: Auto merged sql/sql_yacc.yy: Auto merged
This commit is contained in:
commit
a09c75ca89
22 changed files with 376 additions and 74 deletions
|
@ -1812,7 +1812,7 @@ AC_CHECK_FUNCS(alarm bmove \
|
|||
gethostbyaddr_r gethostbyname_r getpwnam \
|
||||
bfill bzero bcmp strstr strpbrk strerror \
|
||||
tell atod memcpy memmove \
|
||||
setupterm strcasecmp sighold vidattr lrand48 localtime_r \
|
||||
setupterm strcasecmp sighold vidattr lrand48 localtime_r gmtime_r \
|
||||
sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \
|
||||
pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \
|
||||
pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \
|
||||
|
|
|
@ -463,6 +463,9 @@ typedef unsigned long long os_off_t;
|
|||
/* Define if you have the getwd function. */
|
||||
#define HAVE_GETWD 1
|
||||
|
||||
/* Define to 1 if you have the `gmtime_r' function. */
|
||||
#define HAVE_GMTIME_R 1
|
||||
|
||||
/* Define if you have the index function. */
|
||||
#define HAVE_INDEX 1
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
|
|||
int pthread_attr_setprio(pthread_attr_t *connect_att,int priority);
|
||||
int pthread_attr_destroy(pthread_attr_t *connect_att);
|
||||
struct tm *localtime_r(const time_t *timep,struct tm *tmp);
|
||||
struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
|
||||
|
||||
|
||||
void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
|
||||
|
||||
|
@ -109,6 +111,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
|
|||
#endif
|
||||
#define pthread_self() win_pthread_self
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
#define HAVE_GMTIME_R 1
|
||||
#define _REENTRANT 1
|
||||
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
|
||||
|
@ -276,6 +279,8 @@ extern int my_pthread_create_detached;
|
|||
#define USE_ALARM_THREAD
|
||||
#undef HAVE_LOCALTIME_R
|
||||
#define HAVE_LOCALTIME_R
|
||||
#undef HAVE_GMTIME_R
|
||||
#define HAVE_GMTIME_R
|
||||
#undef HAVE_PTHREAD_ATTR_SETSCOPE
|
||||
#define HAVE_PTHREAD_ATTR_SETSCOPE
|
||||
#undef HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE /* If we are running linux */
|
||||
|
@ -376,6 +381,10 @@ void *my_pthread_getspecific_imp(pthread_key_t key);
|
|||
struct tm *localtime_r(const time_t *clock, struct tm *res);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GMTIME_R
|
||||
struct tm *gmtime_r(const time_t *clock, struct tm *res);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD_CONDATTR_CREATE
|
||||
/* DCE threads on HPUX 10.20 */
|
||||
#define pthread_condattr_init pthread_condattr_create
|
||||
|
|
|
@ -192,3 +192,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where
|
||||
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DERIVED m2 index NULL PRIMARY 3 NULL 9 Using index
|
||||
drop table t1,t2;
|
||||
SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
|
||||
x
|
||||
1
|
||||
|
|
|
@ -37,3 +37,70 @@ select * from t1 where a like "%abc\d%";
|
|||
a
|
||||
abcd
|
||||
drop table t1;
|
||||
SET NAMES koi8r;
|
||||
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r);
|
||||
INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывА'),('ФЫВА');
|
||||
INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж');
|
||||
INSERT INTO t1 VALUES ('фывАпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж');
|
||||
INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВАПРОЛДЖ');
|
||||
SELECT * FROM t1 WHERE a LIKE '%фЫва%';
|
||||
a
|
||||
фыва
|
||||
Фыва
|
||||
фЫва
|
||||
фыВа
|
||||
фывА
|
||||
ФЫВА
|
||||
фывапролдж
|
||||
Фывапролдж
|
||||
фЫвапролдж
|
||||
фыВапролдж
|
||||
фывАпролдж
|
||||
фываПролдж
|
||||
фывапРолдж
|
||||
фывапрОлдж
|
||||
фывапроЛдж
|
||||
фывапролДж
|
||||
фывапролдЖ
|
||||
ФЫВАПРОЛДЖ
|
||||
SELECT * FROM t1 WHERE a LIKE '%фЫв%';
|
||||
a
|
||||
фыва
|
||||
Фыва
|
||||
фЫва
|
||||
фыВа
|
||||
фывА
|
||||
ФЫВА
|
||||
фывапролдж
|
||||
Фывапролдж
|
||||
фЫвапролдж
|
||||
фыВапролдж
|
||||
фывАпролдж
|
||||
фываПролдж
|
||||
фывапРолдж
|
||||
фывапрОлдж
|
||||
фывапроЛдж
|
||||
фывапролДж
|
||||
фывапролдЖ
|
||||
ФЫВАПРОЛДЖ
|
||||
SELECT * FROM t1 WHERE a LIKE 'фЫва%';
|
||||
a
|
||||
фыва
|
||||
Фыва
|
||||
фЫва
|
||||
фыВа
|
||||
фывА
|
||||
ФЫВА
|
||||
фывапролдж
|
||||
Фывапролдж
|
||||
фЫвапролдж
|
||||
фыВапролдж
|
||||
фывАпролдж
|
||||
фываПролдж
|
||||
фывапРолдж
|
||||
фывапрОлдж
|
||||
фывапроЛдж
|
||||
фывапролДж
|
||||
фывапролдЖ
|
||||
ФЫВАПРОЛДЖ
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -465,3 +465,21 @@ select date_add(time,INTERVAL 1 SECOND) from t1;
|
|||
date_add(time,INTERVAL 1 SECOND)
|
||||
2006-07-08 00:00:01
|
||||
drop table t1;
|
||||
select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
|
||||
strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0
|
||||
1
|
||||
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
|
||||
strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0
|
||||
1
|
||||
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
|
||||
strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0
|
||||
1
|
||||
select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
|
||||
strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0
|
||||
1
|
||||
select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
|
||||
strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0
|
||||
1
|
||||
select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
|
||||
strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0
|
||||
1
|
||||
|
|
|
@ -88,5 +88,9 @@ SELECT d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matint
|
|||
|
||||
explain SELECT d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
explain SELECT d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
drop table t1,t2;
|
||||
|
||||
drop table t1,t2
|
||||
#
|
||||
# derived table reference
|
||||
#
|
||||
SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
|
||||
|
|
|
@ -24,3 +24,23 @@ select * from t1 where a like "%abcd%";
|
|||
select * from t1 where a like "%abc\d%";
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
||||
#
|
||||
# Test like with non-default character set
|
||||
#
|
||||
|
||||
SET NAMES koi8r;
|
||||
|
||||
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r);
|
||||
|
||||
INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á');
|
||||
INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏÌÄÖ'),('æÙ×ÁÐÒÏÌÄÖ'),('Æù×ÁÐÒÏÌÄÖ'),('ÆÙ÷ÁÐÒÏÌÄÖ');
|
||||
INSERT INTO t1 VALUES ('ÆÙ×áÐÒÏÌÄÖ'),('ÆÙ×ÁðÒÏÌÄÖ'),('ÆÙ×ÁÐòÏÌÄÖ'),('ÆÙ×ÁÐÒïÌÄÖ');
|
||||
INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏìÄÖ'),('ÆÙ×ÁÐÒÏÌäÖ'),('ÆÙ×ÁÐÒÏÌÄö'),('æù÷áðòïìäö');
|
||||
|
||||
SELECT * FROM t1 WHERE a LIKE '%Æù×Á%';
|
||||
SELECT * FROM t1 WHERE a LIKE '%Æù×%';
|
||||
SELECT * FROM t1 WHERE a LIKE 'Æù×Á%';
|
||||
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -220,3 +220,12 @@ select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
|
|||
# The following is not as one would expect...
|
||||
select date_add(time,INTERVAL 1 SECOND) from t1;
|
||||
drop table t1;
|
||||
|
||||
# Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that
|
||||
# TZ variable set to GMT-3
|
||||
select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
|
||||
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
|
||||
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
|
||||
select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
|
||||
select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
|
||||
select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
|
||||
|
|
|
@ -133,10 +133,13 @@ int my_sigwait(const sigset_t *set,int *sig)
|
|||
|
||||
/* localtime_r for SCO 3.2V4.2 */
|
||||
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||
|
||||
extern pthread_mutex_t LOCK_localtime_r;
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_LOCALTIME_R)
|
||||
struct tm *localtime_r(const time_t *clock, struct tm *res)
|
||||
{
|
||||
struct tm *tmp;
|
||||
|
@ -148,6 +151,22 @@ struct tm *localtime_r(const time_t *clock, struct tm *res)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_GMTIME_R)
|
||||
/*
|
||||
Reentrant version of standard gmtime() function.
|
||||
Needed on some systems which don't implement it.
|
||||
*/
|
||||
|
||||
struct tm *gmtime_r(const time_t *clock, struct tm *res)
|
||||
{
|
||||
struct tm *tmp;
|
||||
pthread_mutex_lock(&LOCK_localtime_r);
|
||||
tmp= gmtime(clock);
|
||||
*res= *tmp;
|
||||
pthread_mutex_unlock(&LOCK_localtime_r);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
** Replacement of sigwait if the system doesn't have one (like BSDI 3.0)
|
||||
|
|
|
@ -31,7 +31,7 @@ pthread_key(struct st_my_thread_var, THR_KEY_mysys);
|
|||
pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache,
|
||||
THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap,
|
||||
THR_LOCK_net, THR_LOCK_charset;
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||
pthread_mutex_t LOCK_localtime_r;
|
||||
#endif
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
|
@ -73,7 +73,7 @@ my_bool my_thread_global_init(void)
|
|||
#if defined( __WIN__) || defined(OS2)
|
||||
win_pthread_init();
|
||||
#endif
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||
pthread_mutex_init(&LOCK_localtime_r,MY_MUTEX_INIT_SLOW);
|
||||
#endif
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
|
@ -103,7 +103,7 @@ void my_thread_global_end(void)
|
|||
pthread_mutex_destroy(&THR_LOCK_heap);
|
||||
pthread_mutex_destroy(&THR_LOCK_net);
|
||||
pthread_mutex_destroy(&THR_LOCK_charset);
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
|
||||
pthread_mutex_destroy(&LOCK_localtime_r);
|
||||
#endif
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
|
|
|
@ -2139,7 +2139,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
|
|||
int shift = pattern_len;
|
||||
int j = 0;
|
||||
int u = 0;
|
||||
CHARSET_INFO *cs=system_charset_info; // QQ Needs to be fixed
|
||||
CHARSET_INFO *cs= cmp.cmp_collation.collation; // QQ Needs to be fixed
|
||||
|
||||
const int plm1= pattern_len - 1;
|
||||
const int tlmpl= text_len - pattern_len;
|
||||
|
|
|
@ -1147,7 +1147,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
|
|||
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
|
||||
0,
|
||||
select_lex->options | thd->options,
|
||||
HA_POS_ERROR)))
|
||||
HA_POS_ERROR, (char*)"")))
|
||||
return 1;
|
||||
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
|
||||
table->no_rows=1;
|
||||
|
@ -1834,7 +1834,8 @@ bool Item_func_group_concat::setup(THD *thd)
|
|||
(types, sizes and so on).
|
||||
*/
|
||||
if (!(table=create_tmp_table(thd, tmp_table_param, all_fields, 0,
|
||||
0, 0, 0,select_lex->options | thd->options)))
|
||||
0, 0, 0,select_lex->options | thd->options,
|
||||
(char *) "")))
|
||||
DBUG_RETURN(1);
|
||||
table->file->extra(HA_EXTRA_NO_ROWS);
|
||||
table->no_rows= 1;
|
||||
|
|
|
@ -571,21 +571,21 @@ longlong Item_func_from_days::val_int()
|
|||
|
||||
void Item_func_curdate::fix_length_and_dec()
|
||||
{
|
||||
struct tm tm_tmp,*start;
|
||||
time_t query_start=current_thd->query_start();
|
||||
struct tm start;
|
||||
|
||||
collation.set(default_charset());
|
||||
decimals=0;
|
||||
max_length=10*default_charset()->mbmaxlen;
|
||||
localtime_r(&query_start,&tm_tmp);
|
||||
start=&tm_tmp;
|
||||
value=(longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+
|
||||
((uint) start->tm_mon+1)*100+
|
||||
(uint) start->tm_mday);
|
||||
|
||||
store_now_in_tm(current_thd->query_start(),&start);
|
||||
|
||||
value=(longlong) ((ulong) ((uint) start.tm_year+1900)*10000L+
|
||||
((uint) start.tm_mon+1)*100+
|
||||
(uint) start.tm_mday);
|
||||
/* For getdate */
|
||||
ltime.year= start->tm_year+1900;
|
||||
ltime.month= start->tm_mon+1;
|
||||
ltime.day= start->tm_mday;
|
||||
ltime.year= start.tm_year+1900;
|
||||
ltime.month= start.tm_mon+1;
|
||||
ltime.day= start.tm_mday;
|
||||
ltime.hour= 0;
|
||||
ltime.minute= 0;
|
||||
ltime.second= 0;
|
||||
|
@ -594,6 +594,7 @@ void Item_func_curdate::fix_length_and_dec()
|
|||
ltime.time_type=TIMESTAMP_DATE;
|
||||
}
|
||||
|
||||
|
||||
bool Item_func_curdate::get_date(TIME *res,
|
||||
bool fuzzy_date __attribute__((unused)))
|
||||
{
|
||||
|
@ -601,6 +602,27 @@ bool Item_func_curdate::get_date(TIME *res,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Converts time in time_t to struct tm represenatation for local timezone.
|
||||
Defines timezone (local) used for whole CURDATE function
|
||||
*/
|
||||
void Item_func_curdate_local::store_now_in_tm(time_t now, struct tm *now_tm)
|
||||
{
|
||||
localtime_r(&now,now_tm);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Converts time in time_t to struct tm represenatation for UTC
|
||||
Defines timezone (UTC) used for whole UTC_DATE function
|
||||
*/
|
||||
void Item_func_curdate_utc::store_now_in_tm(time_t now, struct tm *now_tm)
|
||||
{
|
||||
gmtime_r(&now,now_tm);
|
||||
}
|
||||
|
||||
|
||||
String *Item_func_curtime::val_str(String *str)
|
||||
{
|
||||
str_value.set(buff,buff_length,default_charset());
|
||||
|
@ -609,23 +631,43 @@ String *Item_func_curtime::val_str(String *str)
|
|||
|
||||
void Item_func_curtime::fix_length_and_dec()
|
||||
{
|
||||
struct tm tm_tmp,*start;
|
||||
time_t query_start=current_thd->query_start();
|
||||
CHARSET_INFO *cs=default_charset();
|
||||
struct tm start;
|
||||
CHARSET_INFO *cs= default_charset();
|
||||
|
||||
decimals=0;
|
||||
max_length=8*cs->mbmaxlen;
|
||||
localtime_r(&query_start,&tm_tmp);
|
||||
start=&tm_tmp;
|
||||
collation.set(cs);
|
||||
value=(longlong) ((ulong) ((uint) start->tm_hour)*10000L+
|
||||
(ulong) (((uint) start->tm_min)*100L+
|
||||
(uint) start->tm_sec));
|
||||
|
||||
store_now_in_tm(current_thd->query_start(),&start);
|
||||
|
||||
value=(longlong) ((ulong) ((uint) start.tm_hour)*10000L+
|
||||
(ulong) (((uint) start.tm_min)*100L+
|
||||
(uint) start.tm_sec));
|
||||
|
||||
buff_length=cs->cset->snprintf(cs,buff,sizeof(buff),"%02d:%02d:%02d",
|
||||
(int) start->tm_hour,
|
||||
(int) start->tm_min,
|
||||
(int) start->tm_sec);
|
||||
(int) start.tm_hour,
|
||||
(int) start.tm_min,
|
||||
(int) start.tm_sec);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Converts time in time_t to struct tm represenatation for local timezone.
|
||||
Defines timezone (local) used for whole CURTIME function
|
||||
*/
|
||||
void Item_func_curtime_local::store_now_in_tm(time_t now, struct tm *now_tm)
|
||||
{
|
||||
localtime_r(&now,now_tm);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Converts time in time_t to struct tm represenatation for UTC.
|
||||
Defines timezone (UTC) used for whole UTC_TIME function
|
||||
*/
|
||||
void Item_func_curtime_utc::store_now_in_tm(time_t now, struct tm *now_tm)
|
||||
{
|
||||
gmtime_r(&now,now_tm);
|
||||
}
|
||||
|
||||
|
||||
|
@ -638,37 +680,37 @@ String *Item_func_now::val_str(String *str)
|
|||
|
||||
void Item_func_now::fix_length_and_dec()
|
||||
{
|
||||
struct tm tm_tmp,*start;
|
||||
time_t query_start=current_thd->query_start();
|
||||
struct tm start;
|
||||
CHARSET_INFO *cs= &my_charset_bin;
|
||||
|
||||
decimals=0;
|
||||
max_length=19*cs->mbmaxlen;
|
||||
collation.set(cs);
|
||||
localtime_r(&query_start,&tm_tmp);
|
||||
start=&tm_tmp;
|
||||
value=((longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+
|
||||
(((uint) start->tm_mon+1)*100+
|
||||
(uint) start->tm_mday))*(longlong) 1000000L+
|
||||
(longlong) ((ulong) ((uint) start->tm_hour)*10000L+
|
||||
(ulong) (((uint) start->tm_min)*100L+
|
||||
(uint) start->tm_sec)));
|
||||
|
||||
store_now_in_tm(current_thd->query_start(),&start);
|
||||
|
||||
value=((longlong) ((ulong) ((uint) start.tm_year+1900)*10000L+
|
||||
(((uint) start.tm_mon+1)*100+
|
||||
(uint) start.tm_mday))*(longlong) 1000000L+
|
||||
(longlong) ((ulong) ((uint) start.tm_hour)*10000L+
|
||||
(ulong) (((uint) start.tm_min)*100L+
|
||||
(uint) start.tm_sec)));
|
||||
|
||||
buff_length= (uint) cs->cset->snprintf(cs,buff, sizeof(buff),
|
||||
"%04d-%02d-%02d %02d:%02d:%02d",
|
||||
((int) (start->tm_year+1900)) % 10000,
|
||||
(int) start->tm_mon+1,
|
||||
(int) start->tm_mday,
|
||||
(int) start->tm_hour,
|
||||
(int) start->tm_min,
|
||||
(int) start->tm_sec);
|
||||
((int) (start.tm_year+1900)) % 10000,
|
||||
(int) start.tm_mon+1,
|
||||
(int) start.tm_mday,
|
||||
(int) start.tm_hour,
|
||||
(int) start.tm_min,
|
||||
(int) start.tm_sec);
|
||||
/* For getdate */
|
||||
ltime.year= start->tm_year+1900;
|
||||
ltime.month= start->tm_mon+1;
|
||||
ltime.day= start->tm_mday;
|
||||
ltime.hour= start->tm_hour;
|
||||
ltime.minute= start->tm_min;
|
||||
ltime.second= start->tm_sec;
|
||||
ltime.year= start.tm_year+1900;
|
||||
ltime.month= start.tm_mon+1;
|
||||
ltime.day= start.tm_mday;
|
||||
ltime.hour= start.tm_hour;
|
||||
ltime.minute= start.tm_min;
|
||||
ltime.second= start.tm_sec;
|
||||
ltime.second_part=0;
|
||||
ltime.neg=0;
|
||||
ltime.time_type=TIMESTAMP_FULL;
|
||||
|
@ -690,6 +732,26 @@ int Item_func_now::save_in_field(Field *to, bool no_conversions)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Converts time in time_t to struct tm represenatation for local timezone.
|
||||
Defines timezone (local) used for whole CURRENT_TIMESTAMP function
|
||||
*/
|
||||
void Item_func_now_local::store_now_in_tm(time_t now, struct tm *now_tm)
|
||||
{
|
||||
localtime_r(&now,now_tm);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Converts time in time_t to struct tm represenatation for UTC.
|
||||
Defines timezone (UTC) used for whole UTC_TIMESTAMP function
|
||||
*/
|
||||
void Item_func_now_utc::store_now_in_tm(time_t now, struct tm *now_tm)
|
||||
{
|
||||
gmtime_r(&now,now_tm);
|
||||
}
|
||||
|
||||
|
||||
String *Item_func_sec_to_time::val_str(String *str)
|
||||
{
|
||||
char buff[23*2];
|
||||
|
|
|
@ -350,6 +350,8 @@ public:
|
|||
};
|
||||
|
||||
|
||||
/* Abstract CURTIME function. Children should define what timezone is used */
|
||||
|
||||
class Item_func_curtime :public Item_func
|
||||
{
|
||||
longlong value;
|
||||
|
@ -363,29 +365,77 @@ public:
|
|||
double val() { return (double) value; }
|
||||
longlong val_int() { return value; }
|
||||
String *val_str(String *str);
|
||||
const char *func_name() const { return "curtime"; }
|
||||
void fix_length_and_dec();
|
||||
Field *tmp_table_field() { return result_field; }
|
||||
Field *tmp_table_field(TABLE *t_arg)
|
||||
{
|
||||
return (new Field_time(maybe_null, name, t_arg, default_charset()));
|
||||
}
|
||||
}
|
||||
/*
|
||||
Abstract method that defines which time zone is used for conversion.
|
||||
Converts time from time_t representation to broken down representation
|
||||
in struct tm using gmtime_r or localtime_r functions.
|
||||
*/
|
||||
virtual void store_now_in_tm(time_t now, struct tm *now_tm)=0;
|
||||
};
|
||||
|
||||
|
||||
class Item_func_curtime_local :public Item_func_curtime
|
||||
{
|
||||
public:
|
||||
Item_func_curtime_local() :Item_func_curtime() {}
|
||||
Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
|
||||
const char *func_name() const { return "curtime"; }
|
||||
void store_now_in_tm(time_t now, struct tm *now_tm);
|
||||
};
|
||||
|
||||
|
||||
class Item_func_curtime_utc :public Item_func_curtime
|
||||
{
|
||||
public:
|
||||
Item_func_curtime_utc() :Item_func_curtime() {}
|
||||
Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
|
||||
const char *func_name() const { return "utc_time"; }
|
||||
void store_now_in_tm(time_t now, struct tm *now_tm);
|
||||
};
|
||||
|
||||
|
||||
/* Abstract CURDATE function. See also Item_func_curtime. */
|
||||
|
||||
class Item_func_curdate :public Item_date
|
||||
{
|
||||
longlong value;
|
||||
TIME ltime;
|
||||
public:
|
||||
Item_func_curdate() :Item_date() {}
|
||||
void set_result_from_tm(struct tm *now);
|
||||
longlong val_int() { return (value) ; }
|
||||
const char *func_name() const { return "curdate"; }
|
||||
void fix_length_and_dec(); /* Retrieves curtime */
|
||||
void fix_length_and_dec();
|
||||
bool get_date(TIME *res,bool fuzzy_date);
|
||||
virtual void store_now_in_tm(time_t now, struct tm *now_tm)=0;
|
||||
};
|
||||
|
||||
|
||||
class Item_func_curdate_local :public Item_func_curdate
|
||||
{
|
||||
public:
|
||||
Item_func_curdate_local() :Item_func_curdate() {}
|
||||
const char *func_name() const { return "curdate"; }
|
||||
void store_now_in_tm(time_t now, struct tm *now_tm);
|
||||
};
|
||||
|
||||
|
||||
class Item_func_curdate_utc :public Item_func_curdate
|
||||
{
|
||||
public:
|
||||
Item_func_curdate_utc() :Item_func_curdate() {}
|
||||
const char *func_name() const { return "utc_date"; }
|
||||
void store_now_in_tm(time_t now, struct tm *now_tm);
|
||||
};
|
||||
|
||||
|
||||
/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
|
||||
|
||||
class Item_func_now :public Item_date_func
|
||||
{
|
||||
longlong value;
|
||||
|
@ -400,9 +450,29 @@ public:
|
|||
longlong val_int() { return value; }
|
||||
int save_in_field(Field *to, bool no_conversions);
|
||||
String *val_str(String *str);
|
||||
const char *func_name() const { return "now"; }
|
||||
void fix_length_and_dec();
|
||||
bool get_date(TIME *res,bool fuzzy_date);
|
||||
virtual void store_now_in_tm(time_t now, struct tm *now_tm)=0;
|
||||
};
|
||||
|
||||
|
||||
class Item_func_now_local :public Item_func_now
|
||||
{
|
||||
public:
|
||||
Item_func_now_local() :Item_func_now() {}
|
||||
Item_func_now_local(Item *a) :Item_func_now(a) {}
|
||||
const char *func_name() const { return "now"; }
|
||||
void store_now_in_tm(time_t now, struct tm *now_tm);
|
||||
};
|
||||
|
||||
|
||||
class Item_func_now_utc :public Item_func_now
|
||||
{
|
||||
public:
|
||||
Item_func_now_utc() :Item_func_now() {}
|
||||
Item_func_now_utc(Item *a) :Item_func_now(a) {}
|
||||
const char *func_name() const { return "utc_timestamp"; }
|
||||
void store_now_in_tm(time_t now, struct tm *now_tm);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -404,6 +404,9 @@ static SYMBOL symbols[] = {
|
|||
{ "USE_FRM", SYM(USE_FRM),0,0},
|
||||
{ "USER", SYM(USER),0,0},
|
||||
{ "USING", SYM(USING),0,0},
|
||||
{ "UTC_DATE", SYM(UTC_DATE_SYM),0,0},
|
||||
{ "UTC_TIME", SYM(UTC_TIME_SYM),0,0},
|
||||
{ "UTC_TIMESTAMP", SYM(UTC_TIMESTAMP_SYM),0,0},
|
||||
{ "UPDATE", SYM(UPDATE_SYM),0,0},
|
||||
{ "USAGE", SYM(USAGE),0,0},
|
||||
{ "VALUE", SYM(VALUE_SYM),0,0},
|
||||
|
|
|
@ -157,7 +157,8 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
|
|||
is_union && !unit->union_option, 1,
|
||||
(select_cursor->options | thd->options |
|
||||
TMP_TABLE_ALL_COLUMNS),
|
||||
HA_POS_ERROR)))
|
||||
HA_POS_ERROR,
|
||||
org_table_list->alias)))
|
||||
{
|
||||
res= -1;
|
||||
goto exit;
|
||||
|
|
|
@ -787,7 +787,8 @@ JOIN::optimize()
|
|||
group_list && simple_group,
|
||||
select_options,
|
||||
(order == 0 || skip_sort_order) ? select_limit :
|
||||
HA_POS_ERROR)))
|
||||
HA_POS_ERROR,
|
||||
(char *) "")))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
/*
|
||||
|
@ -1120,7 +1121,8 @@ JOIN::exec()
|
|||
curr_join->select_distinct &&
|
||||
!curr_join->group_list,
|
||||
1, curr_join->select_options,
|
||||
HA_POS_ERROR)))
|
||||
HA_POS_ERROR,
|
||||
(char *) "")))
|
||||
DBUG_VOID_RETURN;
|
||||
curr_join->exec_tmp_table2= exec_tmp_table2;
|
||||
}
|
||||
|
@ -4321,7 +4323,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
|
|||
TABLE *
|
||||
create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
||||
ORDER *group, bool distinct, bool save_sum_fields,
|
||||
ulong select_options, ha_rows rows_limit)
|
||||
ulong select_options, ha_rows rows_limit,
|
||||
char *table_alias)
|
||||
{
|
||||
TABLE *table;
|
||||
uint i,field_count,reclength,null_count,null_pack_length,
|
||||
|
@ -4410,10 +4413,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
|||
table->field=reg_field;
|
||||
table->blob_field= (Field_blob**) blob_field;
|
||||
table->real_name=table->path=tmpname;
|
||||
/*
|
||||
This must be "" as field may refer to it after tempory table is dropped
|
||||
*/
|
||||
table->table_name= (char*) "";
|
||||
table->table_name= table_alias;
|
||||
table->reginfo.lock_type=TL_WRITE; /* Will be updated */
|
||||
table->db_stat=HA_OPEN_KEYFILE+HA_OPEN_RNDFILE;
|
||||
table->blob_ptr_size=mi_portable_sizeof_char_ptr;
|
||||
|
|
|
@ -274,7 +274,8 @@ void TEST_join(JOIN *join);
|
|||
bool store_val_in_field(Field *field,Item *val);
|
||||
TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
||||
ORDER *group, bool distinct, bool save_sum_fields,
|
||||
ulong select_options, ha_rows rows_limit);
|
||||
ulong select_options, ha_rows rows_limit,
|
||||
char* alias);
|
||||
void free_tmp_table(THD *thd, TABLE *entry);
|
||||
void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
|
||||
bool reset_with_sum_func);
|
||||
|
|
|
@ -178,7 +178,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
|
|||
(ORDER*) 0, !union_option,
|
||||
1, (select_cursor->options | thd->options |
|
||||
TMP_TABLE_ALL_COLUMNS),
|
||||
HA_POS_ERROR)))
|
||||
HA_POS_ERROR, (char*) "")))
|
||||
goto err;
|
||||
table->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
|
|
|
@ -640,7 +640,8 @@ multi_update::initialize_tables(JOIN *join)
|
|||
temp_fields,
|
||||
(ORDER*) &group, 0, 0,
|
||||
TMP_TABLE_ALL_COLUMNS,
|
||||
HA_POS_ERROR)))
|
||||
HA_POS_ERROR,
|
||||
(char *) "")))
|
||||
DBUG_RETURN(1);
|
||||
tmp_tables[cnt]->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||
}
|
||||
|
|
|
@ -526,6 +526,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
|
|||
%token UNIQUE_USERS
|
||||
%token UNIX_TIMESTAMP
|
||||
%token USER
|
||||
%token UTC_DATE_SYM
|
||||
%token UTC_TIME_SYM
|
||||
%token UTC_TIMESTAMP_SYM
|
||||
%token WEEK_SYM
|
||||
%token WHEN_SYM
|
||||
%token WORK_SYM
|
||||
|
@ -1916,7 +1919,8 @@ select:
|
|||
LEX *lex= Lex;
|
||||
lex->sql_command= SQLCOM_SELECT;
|
||||
lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE;
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
/* Need select_init2 for subselects. */
|
||||
select_init:
|
||||
|
@ -2373,12 +2377,12 @@ simple_expr:
|
|||
| CONCAT_WS '(' expr ',' expr_list ')'
|
||||
{ $$= new Item_func_concat_ws($3, *$5); }
|
||||
| CURDATE optional_braces
|
||||
{ $$= new Item_func_curdate(); Lex->safe_to_cache_query=0; }
|
||||
{ $$= new Item_func_curdate_local(); Lex->safe_to_cache_query=0; }
|
||||
| CURTIME optional_braces
|
||||
{ $$= new Item_func_curtime(); Lex->safe_to_cache_query=0; }
|
||||
{ $$= new Item_func_curtime_local(); Lex->safe_to_cache_query=0; }
|
||||
| CURTIME '(' expr ')'
|
||||
{
|
||||
$$= new Item_func_curtime($3);
|
||||
$$= new Item_func_curtime_local($3);
|
||||
Lex->safe_to_cache_query=0;
|
||||
}
|
||||
| DATE_ADD_INTERVAL '(' expr ',' interval_expr interval ')'
|
||||
|
@ -2540,9 +2544,9 @@ simple_expr:
|
|||
{ $$= new Item_func_spatial_collection(* $3,
|
||||
Geometry::wkbMultiPolygon, Geometry::wkbPolygon ); }
|
||||
| NOW_SYM optional_braces
|
||||
{ $$= new Item_func_now(); Lex->safe_to_cache_query=0;}
|
||||
{ $$= new Item_func_now_local(); Lex->safe_to_cache_query=0;}
|
||||
| NOW_SYM '(' expr ')'
|
||||
{ $$= new Item_func_now($3); Lex->safe_to_cache_query=0;}
|
||||
{ $$= new Item_func_now_local($3); Lex->safe_to_cache_query=0;}
|
||||
| PASSWORD '(' expr ')'
|
||||
{ $$= new Item_func_password($3); }
|
||||
| PASSWORD '(' expr ',' expr ')'
|
||||
|
@ -2670,6 +2674,12 @@ simple_expr:
|
|||
{ $$= new Item_func_unix_timestamp($3); }
|
||||
| USER '(' ')'
|
||||
{ $$= new Item_func_user(); Lex->safe_to_cache_query=0; }
|
||||
| UTC_DATE_SYM optional_braces
|
||||
{ $$= new Item_func_curdate_utc(); Lex->safe_to_cache_query=0;}
|
||||
| UTC_TIME_SYM optional_braces
|
||||
{ $$= new Item_func_curtime_utc(); Lex->safe_to_cache_query=0;}
|
||||
| UTC_TIMESTAMP_SYM optional_braces
|
||||
{ $$= new Item_func_now_utc(); Lex->safe_to_cache_query=0;}
|
||||
| WEEK_SYM '(' expr ')'
|
||||
{
|
||||
$$= new Item_func_week($3,new Item_int((char*) "0",
|
||||
|
|
Loading…
Reference in a new issue