Commit 68ca84db authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Print right hostname or IP in SHOW PROCESSLIST

Use SESSION TABLE_HANDLER as default table handler if given table handler doesn't exists
parent 056e88fe
...@@ -2213,11 +2213,11 @@ Storage: same as TINYINT. ...@@ -2213,11 +2213,11 @@ Storage: same as TINYINT.
@strong{DATE} @strong{DATE}
@itemize @bullet @itemize @bullet
@item @item
Storage: fixed-length series of binary integers, always three bytes Storage: 3 byte integer, low byte first.
long. Packed as: 'day + month*32 + year*16*32'
@item @item
Example: a DATE column containing '0001-01-01' looks like:@* Example: a DATE column containing '1962-01-02' looks like:@*
@code{hexadecimal 21 02 00} @code{hexadecimal 22 54 0F}
@end itemize @end itemize
@strong{DATETIME} @strong{DATETIME}
...@@ -2236,16 +2236,19 @@ Example: a DATETIME column for '0001-01-01 01:01:01' looks like:@* ...@@ -2236,16 +2236,19 @@ Example: a DATETIME column for '0001-01-01 01:01:01' looks like:@*
@strong{TIME} @strong{TIME}
@itemize @bullet @itemize @bullet
@item @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 @item
Example: a TIME column containing '01:01:01' looks like:@* Example: a TIME column containing '1 02:03:04' (1 day 2 hour 3 minutes and 4 seconds) looks like:@*
@code{hexadecimal 75 27 00} @code{hexadecimal 58 6E 01}
@end itemize @end itemize
@strong{TIMESTAMP} @strong{TIMESTAMP}
@itemize @bullet @itemize @bullet
@item @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 @item
Example: a TIMESTAMP column containing '2003-01-01 01:01:01' looks like:@* Example: a TIMESTAMP column containing '2003-01-01 01:01:01' looks like:@*
@code{hexadecimal 4D AE 12 23} @code{hexadecimal 4D AE 12 23}
......
...@@ -148,3 +148,26 @@ select * from t1; ...@@ -148,3 +148,26 @@ select * from t1;
if('2002'='2002','Y','N') if('2002'='2002','Y','N')
Y Y
drop table if exists t1; 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;
...@@ -102,3 +102,20 @@ drop table t1; ...@@ -102,3 +102,20 @@ drop table t1;
create table t1 select if('2002'='2002','Y','N'); create table t1 select if('2002'='2002','Y','N');
select * from t1; select * from t1;
drop table if exists 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;
...@@ -121,8 +121,15 @@ handler *get_new_handler(TABLE *table, enum db_type db_type) ...@@ -121,8 +121,15 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
#endif #endif
case DB_TYPE_HEAP: case DB_TYPE_HEAP:
return new ha_heap(table); return new ha_heap(table);
case DB_TYPE_MYISAM:
default: // should never happen 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); return new ha_myisam(table);
case DB_TYPE_MRG_MYISAM: case DB_TYPE_MRG_MYISAM:
return new ha_myisammrg(table); return new ha_myisammrg(table);
......
...@@ -499,7 +499,10 @@ check_connections(THD *thd) ...@@ -499,7 +499,10 @@ check_connections(THD *thd)
thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors); thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors);
/* Cut very long hostnames to avoid possible overflows */ /* Cut very long hostnames to avoid possible overflows */
if (thd->host) if (thd->host)
{
thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0; thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0;
thd->host_or_ip= thd->host;
}
if (connect_errors > max_connect_errors) if (connect_errors > max_connect_errors)
return(ER_HOST_IS_BLOCKED); return(ER_HOST_IS_BLOCKED);
} }
......
...@@ -1064,10 +1064,10 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) ...@@ -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))) if ((thd_info->host= thd->alloc(LIST_PROCESS_HOST_LEN+1)))
my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN, 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 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 if ((thd_info->db=tmp->db)) // Safe test
thd_info->db=thd->strdup(thd_info->db); thd_info->db=thd->strdup(thd_info->db);
thd_info->command=(int) tmp->command; thd_info->command=(int) tmp->command;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment