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
97042da6
Commit
97042da6
authored
Nov 12, 2002
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge abarkov@work.mysql.com:/home/bk/mysql-4.1
into bar.mysql.r18.ru:/usr/home/bar/mysql-4.1.wrk
parents
86f1a1e0
9ef9f59d
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
181 additions
and
52 deletions
+181
-52
sql/item_timefunc.cc
sql/item_timefunc.cc
+59
-23
sql/item_timefunc.h
sql/item_timefunc.h
+122
-29
No files found.
sql/item_timefunc.cc
View file @
97042da6
...
...
@@ -402,16 +402,16 @@ String *Item_date::val_str(String *str)
return
(
String
*
)
0
;
if
(
!
value
)
// zero daynr
{
str
->
copy
(
"0000-00-00"
,
10
,
my_charset_latin1
);
str
->
copy
(
"0000-00-00"
,
10
,
my_charset_latin1
,
thd_charset
()
);
return
str
;
}
if
(
str
->
alloc
(
11
))
return
&
empty_string
;
/* purecov: inspected */
sprintf
(
(
char
*
)
str
->
ptr
()
,
"%04d-%02d-%02d"
,
char
tmpbuff
[
11
];
sprintf
(
tmpbuff
,
"%04d-%02d-%02d"
,
(
int
)
(
value
/
10000L
)
%
10000
,
(
int
)
(
value
/
100
)
%
100
,
(
int
)
(
value
%
100
));
str
->
length
(
10
);
str
->
copy
(
tmpbuff
,
10
,
my_charset_latin1
,
thd_charset
()
);
return
str
;
}
...
...
@@ -448,7 +448,10 @@ void Item_func_curdate::fix_length_and_dec()
{
struct
tm
tm_tmp
,
*
start
;
time_t
query_start
=
current_thd
->
query_start
();
decimals
=
0
;
max_length
=
10
;
set_charset
(
thd_charset
());
decimals
=
0
;
max_length
=
10
*
thd_charset
()
->
mbmaxlen
;
localtime_r
(
&
query_start
,
&
tm_tmp
);
start
=&
tm_tmp
;
value
=
(
longlong
)
((
ulong
)
((
uint
)
start
->
tm_year
+
1900
)
*
10000L
+
...
...
@@ -473,27 +476,48 @@ bool Item_func_curdate::get_date(TIME *res,
return
0
;
}
String
*
Item_func_curtime
::
val_str
(
String
*
str
)
{
str_value
.
set
(
buff
,
buff_length
,
thd_charset
());
return
&
str_value
;
}
void
Item_func_curtime
::
fix_length_and_dec
()
{
struct
tm
tm_tmp
,
*
start
;
time_t
query_start
=
current_thd
->
query_start
();
decimals
=
0
;
max_length
=
8
;
CHARSET_INFO
*
cs
=
thd_charset
();
decimals
=
0
;
max_length
=
8
*
cs
->
mbmaxlen
;
localtime_r
(
&
query_start
,
&
tm_tmp
);
start
=&
tm_tmp
;
set_charset
(
cs
);
value
=
(
longlong
)
((
ulong
)
((
uint
)
start
->
tm_hour
)
*
10000L
+
(
ulong
)
(((
uint
)
start
->
tm_min
)
*
100L
+
(
uint
)
start
->
tm_sec
));
buff_length
=
my_sprintf
(
buff
,
(
buff
,
"%02d:%02d:%02d"
,
buff_length
=
cs
->
snprintf
(
cs
,
buff
,
sizeof
(
buff
),
"%02d:%02d:%02d"
,
(
int
)
start
->
tm_hour
,
(
int
)
start
->
tm_min
,
(
int
)
start
->
tm_sec
));
(
int
)
start
->
tm_sec
);
}
String
*
Item_func_now
::
val_str
(
String
*
str
)
{
str_value
.
set
(
buff
,
buff_length
,
thd_charset
());
return
&
str_value
;
}
void
Item_func_now
::
fix_length_and_dec
()
{
struct
tm
tm_tmp
,
*
start
;
time_t
query_start
=
current_thd
->
query_start
();
decimals
=
0
;
max_length
=
19
;
CHARSET_INFO
*
cs
=
thd_charset
();
decimals
=
0
;
max_length
=
19
*
cs
->
mbmaxlen
;
set_charset
(
cs
);
localtime_r
(
&
query_start
,
&
tm_tmp
);
start
=&
tm_tmp
;
value
=
((
longlong
)
((
ulong
)
((
uint
)
start
->
tm_year
+
1900
)
*
10000L
+
...
...
@@ -502,13 +526,14 @@ void Item_func_now::fix_length_and_dec()
(
longlong
)
((
ulong
)
((
uint
)
start
->
tm_hour
)
*
10000L
+
(
ulong
)
(((
uint
)
start
->
tm_min
)
*
100L
+
(
uint
)
start
->
tm_sec
)));
buff_length
=
(
uint
)
my_sprintf
(
buff
,
(
buff
,
"%04d-%02d-%02d %02d:%02d:%02d"
,
buff_length
=
(
uint
)
cs
->
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_sec
);
/* For getdate */
ltime
.
year
=
start
->
tm_year
+
1900
;
ltime
.
month
=
start
->
tm_mon
+
1
;
...
...
@@ -539,7 +564,7 @@ int Item_func_now::save_in_field(Field *to)
String
*
Item_func_sec_to_time
::
val_str
(
String
*
str
)
{
char
buff
[
23
];
char
buff
[
23
*
2
];
const
char
*
sign
=
""
;
longlong
seconds
=
(
longlong
)
args
[
0
]
->
val_int
();
ulong
length
;
...
...
@@ -553,7 +578,7 @@ String *Item_func_sec_to_time::val_str(String *str)
uint
sec
=
(
uint
)
((
ulonglong
)
seconds
%
3600
);
length
=
my_sprintf
(
buff
,(
buff
,
"%s%02lu:%02u:%02u"
,
sign
,(
long
)
(
seconds
/
3600
),
sec
/
60
,
sec
%
60
));
str
->
copy
(
buff
,
length
,
my_charset_latin1
);
str
->
copy
(
buff
,
length
,
my_charset_latin1
,
thd_charset
()
);
return
str
;
}
...
...
@@ -897,20 +922,26 @@ String *Item_func_from_unixtime::val_str(String *str)
{
struct
tm
tm_tmp
,
*
start
;
time_t
tmp
=
(
time_t
)
args
[
0
]
->
val_int
();
uint32
l
;
CHARSET_INFO
*
cs
=
thd_charset
();
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
localtime_r
(
&
tmp
,
&
tm_tmp
);
start
=&
tm_tmp
;
if
(
str
->
alloc
(
20
))
l
=
20
*
cs
->
mbmaxlen
+
32
;
if
(
str
->
alloc
(
l
))
return
str
;
/* purecov: inspected */
sprintf
((
char
*
)
str
->
ptr
()
,
"%04d-%02d-%02d %02d:%02d:%02d"
,
l
=
cs
->
snprintf
(
cs
,(
char
*
)
str
->
ptr
(),
l
,
"%04d-%02d-%02d %02d:%02d:%02d"
,
(
int
)
start
->
tm_year
+
1900
,
(
int
)
start
->
tm_mon
+
1
,
(
int
)
start
->
tm_mday
,
(
int
)
start
->
tm_hour
,
(
int
)
start
->
tm_min
,
(
int
)
start
->
tm_sec
);
str
->
length
(
19
);
str
->
length
(
l
);
str
->
set_charset
(
cs
);
return
str
;
}
...
...
@@ -1041,26 +1072,31 @@ bool Item_date_add_interval::get_date(TIME *ltime, bool fuzzy_date)
String
*
Item_date_add_interval
::
val_str
(
String
*
str
)
{
TIME
ltime
;
CHARSET_INFO
*
cs
=
thd_charset
();
uint32
l
;
if
(
Item_date_add_interval
::
get_date
(
&
ltime
,
0
))
return
0
;
if
(
ltime
.
time_type
==
TIMESTAMP_DATE
)
{
if
(
str
->
alloc
(
11
))
l
=
11
*
cs
->
mbmaxlen
+
32
;
if
(
str
->
alloc
(
l
))
goto
null_date
;
sprintf
((
char
*
)
str
->
ptr
()
,
"%04d-%02d-%02d"
,
l
=
cs
->
snprintf
(
cs
,(
char
*
)
str
->
ptr
(),
l
,
"%04d-%02d-%02d"
,
ltime
.
year
,
ltime
.
month
,
ltime
.
day
);
str
->
length
(
10
);
str
->
length
(
l
);
}
else
{
if
(
str
->
alloc
(
20
))
l
=
20
*
cs
->
mbmaxlen
+
32
;
if
(
str
->
alloc
(
l
))
goto
null_date
;
sprintf
((
char
*
)
str
->
ptr
()
,
"%04d-%02d-%02d %02d:%02d:%02d"
,
l
=
cs
->
snprintf
(
cs
,(
char
*
)
str
->
ptr
(),
l
,
"%04d-%02d-%02d %02d:%02d:%02d"
,
ltime
.
year
,
ltime
.
month
,
ltime
.
day
,
ltime
.
hour
,
ltime
.
minute
,
ltime
.
second
);
str
->
length
(
19
);
str
->
length
(
l
);
}
str
->
set_charset
(
cs
);
return
str
;
null_date:
...
...
sql/item_timefunc.h
View file @
97042da6
This diff is collapsed.
Click to expand it.
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