diff options
-rw-r--r-- | Docs/internals.texi | 19 | ||||
-rw-r--r-- | mysql-test/r/create.result | 23 | ||||
-rw-r--r-- | mysql-test/t/create.test | 17 | ||||
-rw-r--r-- | sql/handler.cc | 9 | ||||
-rw-r--r-- | sql/sql_parse.cc | 3 | ||||
-rw-r--r-- | sql/sql_show.cc | 4 |
6 files changed, 64 insertions, 11 deletions
diff --git a/Docs/internals.texi b/Docs/internals.texi index 1f90b8d1999..686ecd27fda 100644 --- a/Docs/internals.texi +++ b/Docs/internals.texi @@ -2213,11 +2213,11 @@ Storage: same as TINYINT. @strong{DATE} @itemize @bullet @item -Storage: fixed-length series of binary integers, always three bytes -long. +Storage: 3 byte integer, low byte first. +Packed as: 'day + month*32 + year*16*32' @item -Example: a DATE column containing '0001-01-01' looks like:@* -@code{hexadecimal 21 02 00} +Example: a DATE column containing '1962-01-02' looks like:@* +@code{hexadecimal 22 54 0F} @end itemize @strong{DATETIME} @@ -2236,16 +2236,19 @@ Example: a DATETIME column for '0001-01-01 01:01:01' looks like:@* @strong{TIME} @itemize @bullet @item -Storage: a value offset from 8385959, always three bytes long. +Storage: 3 bytes, low byte first. +This is stored as seconds: days*24*3600+hours*3600+minutes*60+seconds @item -Example: a TIME column containing '01:01:01' looks like:@* -@code{hexadecimal 75 27 00} +Example: a TIME column containing '1 02:03:04' (1 day 2 hour 3 minutes and 4 seconds) looks like:@* +@code{hexadecimal 58 6E 01} @end itemize @strong{TIMESTAMP} @itemize @bullet @item -Storage: four bytes long (NOTE TO SELF: not figured out) +Storage: 4 bytes, low byte first. +Stored as unix @code{time()}, which is seconds since the Epoch +(00:00:00 UTC, January 1, 1970). @item Example: a TIMESTAMP column containing '2003-01-01 01:01:01' looks like:@* @code{hexadecimal 4D AE 12 23} diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 0cc98c38d49..a2ab0e97905 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -148,3 +148,26 @@ select * from t1; if('2002'='2002','Y','N') Y drop table if exists t1; +SET SESSION table_type="heap"; +SELECT @@table_type; +@@table_type +HEAP +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL default '0' +) TYPE=HEAP +drop table t1; +SET SESSION table_type="gemini"; +SELECT @@table_type; +@@table_type +GEMINI +CREATE TABLE t1 (a int not null); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL default '0' +) TYPE=MyISAM +SET SESSION table_type=default; +drop table t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 7d566cb89ac..68d68929f07 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -102,3 +102,20 @@ drop table t1; create table t1 select if('2002'='2002','Y','N'); select * from t1; drop table if exists t1; + +# +# Test default table type +# +SET SESSION table_type="heap"; +SELECT @@table_type; +CREATE TABLE t1 (a int not null); +show create table t1; +drop table t1; +# Test what happens when using a non existing table type +SET SESSION table_type="gemini"; +SELECT @@table_type; +CREATE TABLE t1 (a int not null); +show create table t1; +SET SESSION table_type=default; +drop table t1; + diff --git a/sql/handler.cc b/sql/handler.cc index ebae0d5e901..6e3f8486b45 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -121,8 +121,15 @@ handler *get_new_handler(TABLE *table, enum db_type db_type) #endif case DB_TYPE_HEAP: return new ha_heap(table); - case DB_TYPE_MYISAM: default: // should never happen + { + enum db_type def=(enum db_type) current_thd->variables.table_type; + /* Try first with 'default table type' */ + if (db_type != def) + return get_new_handler(table, def); + } + /* Fall back to MyISAM */ + case DB_TYPE_MYISAM: return new ha_myisam(table); case DB_TYPE_MRG_MYISAM: return new ha_myisammrg(table); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index dde4b6c5c93..8439db0be6b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -499,7 +499,10 @@ check_connections(THD *thd) thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors); /* Cut very long hostnames to avoid possible overflows */ if (thd->host) + { thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0; + thd->host_or_ip= thd->host; + } if (connect_errors > max_connect_errors) return(ER_HOST_IS_BLOCKED); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 95197ecfc4b..23e5049636a 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1064,10 +1064,10 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) { if ((thd_info->host= thd->alloc(LIST_PROCESS_HOST_LEN+1))) my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN, - "%s:%u", thd->host_or_ip, tmp->peer_port); + "%s:%u", tmp->host_or_ip, tmp->peer_port); } else - thd_info->host= thd->strdup(thd->host_or_ip); + thd_info->host= thd->strdup(tmp->host_or_ip); if ((thd_info->db=tmp->db)) // Safe test thd_info->db=thd->strdup(thd_info->db); thd_info->command=(int) tmp->command; |