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
6897b002
Commit
6897b002
authored
Mar 05, 2003
by
serg@serg.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--new option and local variable to optionally turn on
"very new functions" - for now 4.1-compatible TIMESTAMT format
parent
0309191c
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
71 additions
and
18 deletions
+71
-18
mysql-test/r/type_timestamp.result
mysql-test/r/type_timestamp.result
+20
-0
mysql-test/t/type_timestamp.test
mysql-test/t/type_timestamp.test
+14
-0
sql/field.cc
sql/field.cc
+23
-6
sql/mysqld.cc
sql/mysqld.cc
+8
-9
sql/set_var.cc
sql/set_var.cc
+3
-0
sql/sql_class.h
sql/sql_class.h
+2
-1
sql/unireg.h
sql/unireg.h
+1
-2
No files found.
mysql-test/r/type_timestamp.result
View file @
6897b002
...
...
@@ -84,3 +84,23 @@ date date_time time_stamp
2005-01-01 2005-01-01 00:00:00 20050101000000
2030-01-01 2030-01-01 00:00:00 20300101000000
drop table t1;
show variables like 'new';
Variable_name Value
new OFF
create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
t14 timestamp(14));
insert t1 values (0,0,0,0,0,0,0),
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59");
select * from t1;
t2 t4 t6 t8 t10 t12 t14
00 0000 000000 00000000 0000000000 000000000000 00000000000000
97 9712 971231 19971231 9712312347 971231234759 19971231234759
set new=1;
select * from t1;
t2 t4 t6 t8 t10 t12 t14
00 00-00 00-00-00 0000-00-00 00-00-00 00:00 00-00-00 00:00:00 0000-00-00 00:00:00
97 97-12 97-12-31 1997-12-31 97-12-31 23:47 97-12-31 23:47:59 1997-12-31 23:47:59
drop table t1;
mysql-test/t/type_timestamp.test
View file @
6897b002
...
...
@@ -55,3 +55,17 @@ INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
#INSERT INTO t1 VALUES ("2050-01-01","2050-01-01 00:00:00",20500101000000);
SELECT
*
FROM
t1
;
drop
table
t1
;
show
variables
like
'new'
;
create
table
t1
(
t2
timestamp
(
2
),
t4
timestamp
(
4
),
t6
timestamp
(
6
),
t8
timestamp
(
8
),
t10
timestamp
(
10
),
t12
timestamp
(
12
),
t14
timestamp
(
14
));
insert
t1
values
(
0
,
0
,
0
,
0
,
0
,
0
,
0
),
(
"1997-12-31 23:47:59"
,
"1997-12-31 23:47:59"
,
"1997-12-31 23:47:59"
,
"1997-12-31 23:47:59"
,
"1997-12-31 23:47:59"
,
"1997-12-31 23:47:59"
,
"1997-12-31 23:47:59"
);
select
*
from
t1
;
set
new
=
1
;
select
*
from
t1
;
drop
table
t1
;
sql/field.cc
View file @
6897b002
...
...
@@ -2616,14 +2616,17 @@ String *Field_timestamp::val_str(String *val_buffer,
String
*
val_ptr
__attribute__
((
unused
)))
{
uint
pos
;
int
extra
;
int
part_time
;
uint32
temp
;
time_t
time_arg
;
struct
tm
*
l_time
;
struct
tm
tm_tmp
;
my_bool
new_format
=
(
current_thd
->
variables
.
new_mode
),
full_year
=
(
field_length
==
8
||
field_length
==
14
);
static
const
uint
extras
[]
=
{
0
,
1
,
2
,
2
,
4
,
5
,
5
};
val_buffer
->
alloc
(
field_length
+
1
);
char
*
to
=
(
char
*
)
val_buffer
->
ptr
(),
*
end
=
to
+
field_length
;
extra
=
new_format
?
extras
[
field_length
/
2
-
1
]
:
0
;
#ifdef WORDS_BIGENDIAN
if
(
table
->
db_low_byte_first
)
...
...
@@ -2634,17 +2637,24 @@ String *Field_timestamp::val_str(String *val_buffer,
if
(
temp
==
0L
)
{
/* Zero time is "000000" */
VOID
(
strfill
(
to
,
field_length
,
'0'
));
val_buffer
->
length
(
field_length
);
if
(
new_format
)
val_buffer
->
copy
(
"0000-00-00 00:00:00"
+
2
*
(
1
-
full_year
),
field_length
+
extra
);
else
val_buffer
->
copy
(
"00000000000000"
,
field_length
);
return
val_buffer
;
}
time_arg
=
(
time_t
)
temp
;
localtime_r
(
&
time_arg
,
&
tm_tmp
);
l_time
=&
tm_tmp
;
val_buffer
->
alloc
(
field_length
+
extra
+
1
);
char
*
to
=
(
char
*
)
val_buffer
->
ptr
(),
*
end
=
to
+
field_length
+
extra
;
for
(
pos
=
0
;
to
<
end
;
pos
++
)
{
bool
year_flag
=
0
;
switch
(
dayord
.
pos
[
pos
]
)
{
switch
(
pos
)
{
case
0
:
part_time
=
l_time
->
tm_year
%
100
;
year_flag
=
1
;
break
;
case
1
:
part_time
=
l_time
->
tm_mon
+
1
;
break
;
case
2
:
part_time
=
l_time
->
tm_mday
;
break
;
...
...
@@ -2653,7 +2663,7 @@ String *Field_timestamp::val_str(String *val_buffer,
case
5
:
part_time
=
l_time
->
tm_sec
;
break
;
default:
part_time
=
0
;
break
;
/* purecov: deadcode */
}
if
(
year_flag
&&
(
field_length
==
8
||
field_length
==
14
)
)
if
(
year_flag
&&
full_year
)
{
if
(
part_time
<
YY_PART_YEAR
)
{
...
...
@@ -2666,7 +2676,14 @@ String *Field_timestamp::val_str(String *val_buffer,
}
*
to
++=
(
char
)
(
'0'
+
((
uint
)
part_time
/
10
));
*
to
++=
(
char
)
(
'0'
+
((
uint
)
part_time
%
10
));
if
(
new_format
)
{
static
const
char
delim
[
6
]
=
"-- ::"
;
*
to
++=
delim
[
pos
];
}
}
if
(
new_format
)
to
--
;
*
to
=
0
;
// Safeguard
val_buffer
->
length
((
uint
)
(
to
-
val_buffer
->
ptr
()));
return
val_buffer
;
...
...
sql/mysqld.cc
View file @
6897b002
...
...
@@ -3423,8 +3423,10 @@ struct my_option my_long_options[] =
{
"safemalloc-mem-limit"
,
OPT_SAFEMALLOC_MEM_LIMIT
,
"Simulate memory shortage when compiled with the --with-debug=full option"
,
0
,
0
,
0
,
GET_ULL
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"new"
,
'n'
,
"Use very new possible 'unsafe' functions"
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"new"
,
'n'
,
"Use very new possible 'unsafe' functions"
,
(
gptr
*
)
&
global_system_variables
.
new_mode
,
(
gptr
*
)
&
max_system_variables
.
new_mode
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
#ifdef NOT_YET
{
"no-mix-table-types"
,
OPT_NO_MIX_TYPE
,
"Don't allow commands with uses two different table types"
,
(
gptr
*
)
&
opt_no_mix_types
,
(
gptr
*
)
&
opt_no_mix_types
,
0
,
GET_BOOL
,
NO_ARG
,
...
...
@@ -4222,9 +4224,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case
'L'
:
strmake
(
language
,
argument
,
sizeof
(
language
)
-
1
);
break
;
case
'n'
:
opt_specialflag
|=
SPECIAL_NEW_FUNC
;
break
;
case
'o'
:
protocol_version
=
PROTOCOL_VERSION
-
1
;
break
;
...
...
sql/set_var.cc
View file @
6897b002
...
...
@@ -179,6 +179,7 @@ sys_var_thd_ulong sys_net_write_timeout("net_write_timeout",
sys_var_thd_ulong
sys_net_retry_count
(
"net_retry_count"
,
&
SV
::
net_retry_count
,
fix_net_retry_count
);
sys_var_thd_bool
sys_new_mode
(
"new"
,
&
SV
::
new_mode
);
sys_var_thd_ulong
sys_read_buff_size
(
"read_buffer_size"
,
&
SV
::
read_buff_size
);
sys_var_thd_ulong
sys_read_rnd_buff_size
(
"read_rnd_buffer_size"
,
...
...
@@ -347,6 +348,7 @@ sys_var *sys_variables[]=
&
sys_net_retry_count
,
&
sys_net_wait_timeout
,
&
sys_net_write_timeout
,
&
sys_new_mode
,
&
sys_query_cache_size
,
#ifdef HAVE_QUERY_CACHE
&
sys_query_cache_limit
,
...
...
@@ -490,6 +492,7 @@ struct show_var_st init_vars[]= {
{
sys_net_read_timeout
.
name
,
(
char
*
)
&
sys_net_read_timeout
,
SHOW_SYS
},
{
sys_net_retry_count
.
name
,
(
char
*
)
&
sys_net_retry_count
,
SHOW_SYS
},
{
sys_net_write_timeout
.
name
,(
char
*
)
&
sys_net_write_timeout
,
SHOW_SYS
},
{
sys_new_mode
.
name
,
(
char
*
)
&
sys_new_mode
,
SHOW_SYS
},
{
"open_files_limit"
,
(
char
*
)
&
open_files_limit
,
SHOW_LONG
},
{
"pid_file"
,
(
char
*
)
pidfile_name
,
SHOW_CHAR
},
{
"log_error"
,
(
char
*
)
log_error_file
,
SHOW_CHAR
},
...
...
sql/sql_class.h
View file @
6897b002
...
...
@@ -311,6 +311,7 @@ struct system_variables
my_bool
log_warnings
;
my_bool
low_priority_updates
;
my_bool
new_mode
;
CONVERT
*
convert_set
;
};
...
...
sql/unireg.h
View file @
6897b002
...
...
@@ -82,7 +82,7 @@
#define SPECIAL_USE_LOCKS 1
/* Lock used databases */
#define SPECIAL_NO_NEW_FUNC 2
/* Skip new functions */
#define SPECIAL_
NEW_FUNC 4
/* New nonstandard functions
*/
#define SPECIAL_
SKIP_SHOW_DB 4
/* Don't allow 'show db'
*/
#define SPECIAL_WAIT_IF_LOCKED 8
/* Wait if locked database */
#define SPECIAL_SAME_DB_NAME 16
/* form name = file name */
#define SPECIAL_ENGLISH 32
/* English error messages */
...
...
@@ -92,7 +92,6 @@
#define SPECIAL_NO_HOST_CACHE 512
/* Don't cache hosts */
#define SPECIAL_LONG_LOG_FORMAT 1024
#define SPECIAL_SAFE_MODE 2048
#define SPECIAL_SKIP_SHOW_DB 4096
/* Don't allow 'show db' */
/* Extern defines */
#define store_record(A,B) bmove_allign((A)->record[B],(A)->record[0],(size_t) (A)->reclength)
...
...
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