Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
27b6d59d
Commit
27b6d59d
authored
Aug 24, 2005
by
jimw@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-5.0
into mysql.com:/home/jimw/my/mysql-5.0-clean
parents
05ee47a8
e11e7317
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
199 additions
and
11 deletions
+199
-11
configure.in
configure.in
+2
-3
dbug/my_main.c
dbug/my_main.c
+2
-0
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+40
-0
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+52
-0
mysys/Makefile.am
mysys/Makefile.am
+1
-1
mysys/mf_getdate.c
mysys/mf_getdate.c
+1
-1
sql/item_timefunc.cc
sql/item_timefunc.cc
+66
-2
sql/item_timefunc.h
sql/item_timefunc.h
+27
-0
sql/lex.h
sql/lex.h
+1
-1
sql/share/Makefile.am
sql/share/Makefile.am
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+5
-0
tests/Makefile.am
tests/Makefile.am
+1
-2
No files found.
configure.in
View file @
27b6d59d
...
...
@@ -2446,7 +2446,7 @@ thread_dirs=
dnl This probably should be cleaned up more -
for
now the threaded
dnl client is just using plain-old libs.
sql_client_dirs
=
"
libmysql strings regex
client"
sql_client_dirs
=
"
strings regex mysys sql/share libmysql
client"
linked_client_targets
=
"linked_libmysql_sources"
if
test
"
$THREAD_SAFE_CLIENT
"
!=
"no"
...
...
@@ -2484,7 +2484,7 @@ then
AC_DEFINE
([
THREAD],
[
1],
[
Define
if
you want to have threaded code. This may be undef on client code]
)
# Avoid _PROGRAMS names
THREAD_LOBJECTS
=
"thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o"
THREAD_LOBJECTS
=
"thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o
mf_keycache.o
"
AC_SUBST
(
THREAD_LOBJECTS
)
server_scripts
=
"mysqld_safe mysql_install_db"
sql_server_dirs
=
"strings mysys dbug extra regex"
...
...
@@ -2595,7 +2595,6 @@ esac
# END of configuration for optional table handlers
#
sql_server_dirs
=
"
$sql_server_dirs
myisam myisammrg heap vio sql"
fi
# IMPORTANT - do not modify LIBS past this line - this hack is the only way
...
...
dbug/my_main.c
View file @
27b6d59d
...
...
@@ -18,7 +18,9 @@ char *argv[];
#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
pthread_init
();
/* Must be called before DBUG_ENTER */
#endif
#ifdef THREAD
my_thread_global_init
();
#endif
{
DBUG_ENTER
(
"main"
);
DBUG_PROCESS
(
argv
[
0
]);
...
...
mysql-test/r/func_time.result
View file @
27b6d59d
...
...
@@ -720,3 +720,43 @@ Warning 1292 Truncated incorrect datetime value: '2005-01-00'
select time_format('100:00:00', '%H %k %h %I %l');
time_format('100:00:00', '%H %k %h %I %l')
100 100 04 04 4
create table t1 (a timestamp default '2005-05-05 01:01:01',
b timestamp default '2005-05-05 01:01:01');
create function t_slow_sysdate() returns timestamp
begin
do sleep(2);
return sysdate();
end;
//
insert into t1 set a = sysdate(), b = t_slow_sysdate();//
create trigger t_before before insert on t1
for each row begin
set new.b = t_slow_sysdate();
end
//
insert into t1 set a = sysdate();
select a != b from t1;
a != b
1
1
drop trigger t_before;
drop function t_slow_sysdate;
drop table t1;
create table t1 (a datetime, i int, b datetime);
insert into t1 select sysdate(), sleep(1), sysdate() from dual;
select a != b from t1;
a != b
1
drop table t1;
create procedure t_sysdate()
begin
select sysdate() into @a;
do sleep(2);
select sysdate() into @b;
select @a != @b;
end;
//
call t_sysdate();
@a != @b
1
drop procedure t_sysdate;
mysql-test/t/func_time.test
View file @
27b6d59d
...
...
@@ -353,3 +353,55 @@ select last_day('2005-01-00');
# the 0-11 range
#
select
time_format
(
'100:00:00'
,
'%H %k %h %I %l'
);
#
# Bug #12562: Make SYSDATE behave like it does in Oracle: always the current
# time, regardless of magic to make NOW() always the same for the
# entirety of a statement.
create
table
t1
(
a
timestamp
default
'2005-05-05 01:01:01'
,
b
timestamp
default
'2005-05-05 01:01:01'
);
delimiter
//;
create
function
t_slow_sysdate
()
returns
timestamp
begin
do
sleep
(
2
);
return
sysdate
();
end
;
//
insert
into
t1
set
a
=
sysdate
(),
b
=
t_slow_sysdate
();
//
create
trigger
t_before
before
insert
on
t1
for
each
row
begin
set
new
.
b
=
t_slow_sysdate
();
end
//
delimiter
;
//
insert
into
t1
set
a
=
sysdate
();
select
a
!=
b
from
t1
;
drop
trigger
t_before
;
drop
function
t_slow_sysdate
;
drop
table
t1
;
create
table
t1
(
a
datetime
,
i
int
,
b
datetime
);
insert
into
t1
select
sysdate
(),
sleep
(
1
),
sysdate
()
from
dual
;
select
a
!=
b
from
t1
;
drop
table
t1
;
delimiter
//;
create
procedure
t_sysdate
()
begin
select
sysdate
()
into
@
a
;
do
sleep
(
2
);
select
sysdate
()
into
@
b
;
select
@
a
!=
@
b
;
end
;
//
delimiter
;
//
call
t_sysdate
();
drop
procedure
t_sysdate
;
# End of 5.0 tests
mysys/Makefile.am
View file @
27b6d59d
...
...
@@ -30,7 +30,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_path.c mf_loadpath.c my_file.c
\
my_open.c my_create.c my_dup.c my_seek.c my_read.c
\
my_pread.c my_write.c
\
mf_keycache
.c mf_keycache
s.c my_crc32.c
\
mf_keycaches.c my_crc32.c
\
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c
\
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c
\
my_malloc.c my_realloc.c my_once.c mulalloc.c
\
...
...
mysys/mf_getdate.c
View file @
27b6d59d
...
...
@@ -54,7 +54,7 @@ void get_date(register my_string to, int flag, time_t date)
if
(
flag
&
GETDATE_GMT
)
start_time
=
localtime
(
&
skr
);
else
gmtime
(
&
skr
,
&
tm_tmp
);
start_time
=
gmtime
(
&
skr
);
#endif
if
(
flag
&
GETDATE_SHORT_DATE
)
sprintf
(
to
,
"%02d%02d%02d"
,
...
...
sql/item_timefunc.cc
View file @
27b6d59d
...
...
@@ -1478,7 +1478,7 @@ void Item_func_now_utc::store_now_in_TIME(TIME *now_time)
bool
Item_func_now
::
get_date
(
TIME
*
res
,
uint
fuzzy_date
__attribute__
((
unused
)))
{
*
res
=
ltime
;
*
res
=
ltime
;
return
0
;
}
...
...
@@ -1491,6 +1491,70 @@ int Item_func_now::save_in_field(Field *to, bool no_conversions)
}
/*
Converts current time in my_time_t to TIME represenatation for local
time zone. Defines time zone (local) used for whole SYSDATE function.
*/
void
Item_func_sysdate_local
::
store_now_in_TIME
(
TIME
*
now_time
)
{
THD
*
thd
=
current_thd
;
thd
->
variables
.
time_zone
->
gmt_sec_to_TIME
(
now_time
,
time
(
NULL
));
thd
->
time_zone_used
=
1
;
}
String
*
Item_func_sysdate_local
::
val_str
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
==
1
);
store_now_in_TIME
(
&
ltime
);
buff_length
=
(
uint
)
my_datetime_to_str
(
&
ltime
,
buff
);
str_value
.
set
(
buff
,
buff_length
,
&
my_charset_bin
);
return
&
str_value
;
}
longlong
Item_func_sysdate_local
::
val_int
()
{
DBUG_ASSERT
(
fixed
==
1
);
store_now_in_TIME
(
&
ltime
);
return
(
longlong
)
TIME_to_ulonglong_datetime
(
&
ltime
);
}
double
Item_func_sysdate_local
::
val_real
()
{
DBUG_ASSERT
(
fixed
==
1
);
store_now_in_TIME
(
&
ltime
);
return
(
longlong
)
TIME_to_ulonglong_datetime
(
&
ltime
);
}
void
Item_func_sysdate_local
::
fix_length_and_dec
()
{
decimals
=
0
;
collation
.
set
(
&
my_charset_bin
);
max_length
=
MAX_DATETIME_WIDTH
*
MY_CHARSET_BIN_MB_MAXLEN
;
}
bool
Item_func_sysdate_local
::
get_date
(
TIME
*
res
,
uint
fuzzy_date
__attribute__
((
unused
)))
{
store_now_in_TIME
(
&
ltime
);
*
res
=
ltime
;
return
0
;
}
int
Item_func_sysdate_local
::
save_in_field
(
Field
*
to
,
bool
no_conversions
)
{
store_now_in_TIME
(
&
ltime
);
to
->
set_notnull
();
to
->
store_time
(
&
ltime
,
MYSQL_TIMESTAMP_DATETIME
);
return
0
;
}
String
*
Item_func_sec_to_time
::
val_str
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
==
1
);
...
...
sql/item_timefunc.h
View file @
27b6d59d
...
...
@@ -446,6 +446,7 @@ class Item_func_curdate_utc :public Item_func_curdate
class
Item_func_now
:
public
Item_date_func
{
protected:
longlong
value
;
char
buff
[
20
*
2
+
32
];
// +32 to make my_snprintf_{8bit|ucs2} happy
uint
buff_length
;
...
...
@@ -485,6 +486,32 @@ class Item_func_now_utc :public Item_func_now
};
/*
This is like NOW(), but always uses the real current time, not the
query_start(). This matches the Oracle behavior.
*/
class
Item_func_sysdate_local
:
public
Item_func_now
{
public:
Item_func_sysdate_local
()
:
Item_func_now
()
{}
Item_func_sysdate_local
(
Item
*
a
)
:
Item_func_now
(
a
)
{}
bool
const_item
()
const
{
return
0
;
}
const
char
*
func_name
()
const
{
return
"sysdate"
;
}
void
store_now_in_TIME
(
TIME
*
now_time
);
double
val_real
();
longlong
val_int
();
int
save_in_field
(
Field
*
to
,
bool
no_conversions
);
String
*
val_str
(
String
*
str
);
void
fix_length_and_dec
();
bool
get_date
(
TIME
*
res
,
uint
fuzzy_date
);
void
update_used_tables
()
{
Item_func_now
::
update_used_tables
();
used_tables_cache
|=
RAND_TABLE_BIT
;
}
};
class
Item_func_from_days
:
public
Item_date
{
public:
...
...
sql/lex.h
View file @
27b6d59d
...
...
@@ -751,7 +751,7 @@ static SYMBOL sql_functions[] = {
{
"SUBSTRING_INDEX"
,
SYM
(
SUBSTRING_INDEX
)},
{
"SUBTIME"
,
F_SYM
(
FUNC_ARG2
),
0
,
CREATE_FUNC
(
create_func_subtime
)},
{
"SUM"
,
SYM
(
SUM_SYM
)},
{
"SYSDATE"
,
SYM
(
NOW_SYM
)},
{
"SYSDATE"
,
SYM
(
SYSDATE
)},
{
"SYSTEM_USER"
,
SYM
(
USER
)},
{
"TAN"
,
F_SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_tan
)},
{
"TIME_FORMAT"
,
F_SYM
(
FUNC_ARG2
),
0
,
CREATE_FUNC
(
create_func_time_format
)},
...
...
sql/share/Makefile.am
View file @
27b6d59d
...
...
@@ -33,7 +33,7 @@ all-local: english/errmsg.sys
# created. Normally these are created by extra/Makefile
english/errmsg.sys
:
errmsg.txt
rm
$(top_builddir)
/include/mysqld_error.h
rm
-f
$(top_builddir)
/include/mysqld_error.h
(
cd
$(top_builddir)
/extra
&&
$(MAKE)
)
install-data-local
:
...
...
sql/sql_yacc.yy
View file @
27b6d59d
...
...
@@ -580,6 +580,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token SUM_SYM
%token SUPER_SYM
%token SUSPEND_SYM
%token SYSDATE
%token TABLES
%token TABLESPACE
%token TABLE_SYM
...
...
@@ -4683,6 +4684,10 @@ simple_expr:
{ $$= new Item_func_substr($3,$5); }
| SUBSTRING_INDEX '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_substr_index($3,$5,$7); }
| SYSDATE optional_braces
{ $$= new Item_func_sysdate_local(); Lex->safe_to_cache_query=0;}
| SYSDATE '(' expr ')'
{ $$= new Item_func_sysdate_local($3); Lex->safe_to_cache_query=0;}
| TIME_SYM '(' expr ')'
{ $$= new Item_time_typecast($3); }
| TIMESTAMP '(' expr ')'
...
...
tests/Makefile.am
View file @
27b6d59d
...
...
@@ -42,8 +42,7 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
LIBS
=
@CLIENT_LIBS@
LDADD
=
@CLIENT_EXTRA_LDFLAGS@
\
$(top_builddir)
/libmysql/libmysqlclient.la
mysql_client_test_LDADD
=
$(LDADD)
$(CXXLDFLAGS)
\
$(top_builddir)
/mysys/libmysys.a
mysql_client_test_LDADD
=
$(LDADD)
$(CXXLDFLAGS)
mysql_client_test_SOURCES
=
mysql_client_test.c
$(yassl_dummy_link_fix)
insert_test_SOURCES
=
insert_test.c
$(yassl_dummy_link_fix)
select_test_SOURCES
=
select_test.c
$(yassl_dummy_link_fix)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment