summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorserg@serg.mysql.com <>2003-03-05 18:43:56 +0100
committerserg@serg.mysql.com <>2003-03-05 18:43:56 +0100
commit6897b00216316b26bc2559c7b915db53c0461007 (patch)
treef4a6d09bb6d874e873581e6bfb712a7921f00c3c /sql
parent0309191c37ecfc7f7b4436295b77d06d562b6c25 (diff)
downloadmariadb-git-6897b00216316b26bc2559c7b915db53c0461007.tar.gz
--new option and local variable to optionally turn on
"very new functions" - for now 4.1-compatible TIMESTAMT format
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc29
-rw-r--r--sql/mysqld.cc17
-rw-r--r--sql/set_var.cc3
-rw-r--r--sql/sql_class.h3
-rw-r--r--sql/unireg.h3
5 files changed, 37 insertions, 18 deletions
diff --git a/sql/field.cc b/sql/field.cc
index aae4fac2a38..5eabccab21b 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -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;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a5241d33132..a03c4f5db8b 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3340,7 +3340,7 @@ struct my_option my_long_options[] =
{"log-long-format", OPT_LONG_FORMAT,
"Log some extra information to update log", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
- {"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
+ {"log-slave-updates", OPT_LOG_SLAVE_UPDATES,
"Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.",
(gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -3349,7 +3349,7 @@ struct my_option my_long_options[] =
(gptr*) &global_system_variables.low_priority_updates,
(gptr*) &max_system_variables.low_priority_updates,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"master-host", OPT_MASTER_HOST,
+ {"master-host", OPT_MASTER_HOST,
"Master hostname or IP address for replication. If not set, the slave thread will not be started. Note that the setting of master-host will be ignored if there exists a valid master.info file.",
(gptr*) &master_host, (gptr*) &master_host, 0, GET_STR, REQUIRED_ARG, 0, 0,
0, 0, 0, 0},
@@ -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;
@@ -4232,9 +4231,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
init_slave_skip_errors(argument);
break;
case OPT_SAFEMALLOC_MEM_LIMIT:
-#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
+#if !defined(DBUG_OFF) && defined(SAFEMALLOC)
safemalloc_mem_limit = atoi(argument);
-#endif
+#endif
break;
#ifdef EMBEDDED_LIBRARY
case OPT_MAX_ALLOWED_PACKET:
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 5cfd027bc58..9ae813e1c51 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -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},
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a8eaf1b200d..f7d9d93a606 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -310,7 +310,8 @@ struct system_variables
ulong table_type;
my_bool log_warnings;
- my_bool low_priority_updates;
+ my_bool low_priority_updates;
+ my_bool new_mode;
CONVERT *convert_set;
};
diff --git a/sql/unireg.h b/sql/unireg.h
index eec89fcee0f..7e98d0d3cbe 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -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)