Commit 03598796 authored by petr@mysql.com's avatar petr@mysql.com

Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/home/cps/mysql/trees/mysql-5.0
parents 1e24a49d 551456b3
......@@ -3689,6 +3689,29 @@ dict_tree_find_index_for_tuple(
return(index);
}
/***********************************************************************
Checks if a table which is a mixed cluster member owns a record. */
ibool
dict_is_mixed_table_rec(
/*====================*/
/* out: TRUE if the record belongs to this
table */
dict_table_t* table, /* in: table in a mixed cluster */
rec_t* rec) /* in: user record in the clustered index */
{
byte* mix_id_field;
ulint len;
ut_ad(!table->comp);
mix_id_field = rec_get_nth_field_old(rec,
table->mix_len, &len);
return(len == table->mix_id_len
&& !ut_memcmp(table->mix_id_buf, mix_id_field, len));
}
/**************************************************************************
Checks that a tuple has n_fields_cmp value in a sensible range, so that
no comparison can occur with the page number field in a node pointer. */
......
......@@ -1140,7 +1140,8 @@ void
ibuf_dummy_index_add_col(
/*====================*/
dict_index_t* index, /* in: dummy index */
dtype_t* type) /* in: the data type of the column */
dtype_t* type, /* in: the data type of the column */
ulint len) /* in: length of the column */
{
ulint i = index->table->n_def;
dict_mem_table_add_col(index->table, "DUMMY",
......@@ -1149,7 +1150,7 @@ ibuf_dummy_index_add_col(
dtype_get_len(type),
dtype_get_prec(type));
dict_index_add_col(index,
dict_table_get_nth_col(index->table, i), 0, 0);
dict_table_get_nth_col(index->table, i), 0, len);
}
/************************************************************************
Deallocates a dummy index for inserting a record to a non-clustered index.
......@@ -1259,7 +1260,7 @@ ibuf_build_entry_from_ibuf_rec(
dfield_get_type(field),
types + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE);
ibuf_dummy_index_add_col(index, dfield_get_type(field));
ibuf_dummy_index_add_col(index, dfield_get_type(field), len);
}
*pindex = index;
......
......@@ -657,19 +657,6 @@ dict_index_copy_types(
dtuple_t* tuple, /* in: data tuple */
dict_index_t* index, /* in: index */
ulint n_fields); /* in: number of field types to copy */
/************************************************************************
Gets the value of a system column in a clustered index record. The clustered
index must contain the system column: if the index is unique, row id is
not contained there! */
UNIV_INLINE
dulint
dict_index_rec_get_sys_col(
/*=======================*/
/* out: system column value */
dict_index_t* index, /* in: clustered index describing the record */
const ulint* offsets,/* in: offsets returned by rec_get_offsets() */
ulint type, /* in: column type: DATA_ROLL_PTR, ... */
rec_t* rec); /* in: record */
/*************************************************************************
Gets the index tree where the index is stored. */
UNIV_INLINE
......@@ -731,7 +718,7 @@ dict_tree_find_index_for_tuple(
dtuple_t* tuple); /* in: tuple for which to find index */
/***********************************************************************
Checks if a table which is a mixed cluster member owns a record. */
UNIV_INLINE
ibool
dict_is_mixed_table_rec(
/*====================*/
......
......@@ -9,7 +9,6 @@ Created 1/8/1996 Heikki Tuuri
#include "dict0load.h"
#include "trx0undo.h"
#include "trx0sys.h"
#include "rem0rec.h"
/*************************************************************************
Gets the column data type. */
......@@ -312,51 +311,6 @@ dict_index_get_sys_col_pos(
dict_table_get_sys_col_no(index->table, type)));
}
/************************************************************************
Gets the value of a system column in a clustered index record. The clustered
index must contain the system column: if the index is unique, row id is
not contained there! */
UNIV_INLINE
dulint
dict_index_rec_get_sys_col(
/*=======================*/
/* out: system column value */
dict_index_t* index, /* in: clustered index describing the record */
const ulint* offsets,/* in: offsets returned by rec_get_offsets() */
ulint type, /* in: column type: DATA_ROLL_PTR, ... */
rec_t* rec) /* in: record */
{
ulint pos;
byte* field;
ulint len;
ut_ad(index);
ut_ad(index->type & DICT_CLUSTERED);
ut_ad(rec_offs_validate(rec, index, offsets));
pos = dict_index_get_sys_col_pos(index, type);
ut_ad(pos != ULINT_UNDEFINED);
field = rec_get_nth_field(rec, offsets, pos, &len);
if (type == DATA_ROLL_PTR) {
ut_ad(len == 7);
return(trx_read_roll_ptr(field));
} else if (type == DATA_TRX_ID) {
return(trx_read_trx_id(field));
} else if (type == DATA_MIX_ID) {
return(mach_dulint_read_compressed(field));
} else {
ut_a(type == DATA_ROW_ID);
return(mach_read_from_6(field));
}
}
/*************************************************************************
Gets the index tree where the index is stored. */
UNIV_INLINE
......@@ -664,31 +618,3 @@ dict_table_get_index(
return(index);
}
/***********************************************************************
Checks if a table which is a mixed cluster member owns a record. */
UNIV_INLINE
ibool
dict_is_mixed_table_rec(
/*====================*/
/* out: TRUE if the record belongs to this
table */
dict_table_t* table, /* in: table in a mixed cluster */
rec_t* rec) /* in: user record in the clustered index */
{
byte* mix_id_field;
ulint len;
ut_ad(!table->comp);
mix_id_field = rec_get_nth_field_old(rec,
table->mix_len, &len);
if ((len != table->mix_id_len)
|| (0 != ut_memcmp(table->mix_id_buf, mix_id_field, len))) {
return(FALSE);
}
return(TRUE);
}
......@@ -485,10 +485,15 @@ trx_undo_page_report_modify(
ptr += 1;
/* Store the values of the system columns */
trx_id = dict_index_rec_get_sys_col(index, offsets,
DATA_TRX_ID, rec);
roll_ptr = dict_index_rec_get_sys_col(index, offsets,
DATA_ROLL_PTR, rec);
field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos(index, DATA_TRX_ID), &len);
ut_ad(len == DATA_TRX_ID_LEN);
trx_id = trx_read_trx_id(field);
field = rec_get_nth_field(rec, offsets,
dict_index_get_sys_col_pos(index, DATA_ROLL_PTR), &len);
ut_ad(len == DATA_ROLL_PTR_LEN);
roll_ptr = trx_read_roll_ptr(field);
len = mach_dulint_write_compressed(ptr, trx_id);
ptr += len;
......
......@@ -116,7 +116,7 @@ count(distinct n)
5000
show status like 'Created_tmp_disk_tables';
Variable_name Value
Created_tmp_disk_tables 1
Created_tmp_disk_tables 2
drop table t1;
create table t1 (s text);
flush status;
......@@ -125,5 +125,5 @@ count(distinct s)
5000
show status like 'Created_tmp_disk_tables';
Variable_name Value
Created_tmp_disk_tables 1
Created_tmp_disk_tables 2
drop table t1;
......@@ -59,7 +59,7 @@ Variable_name Value
Qcache_hits 0
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 0
Qcache_not_cached 5
select "user1";
user1
user1
......@@ -71,7 +71,7 @@ Variable_name Value
Qcache_hits 0
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
Qcache_not_cached 9
select * from t1;
a b c
1 1 1
......@@ -84,7 +84,7 @@ Variable_name Value
Qcache_hits 1
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
Qcache_not_cached 12
select a from t1 ;
a
1
......@@ -97,7 +97,7 @@ Variable_name Value
Qcache_hits 2
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
Qcache_not_cached 15
select c from t1;
c
1
......@@ -110,7 +110,7 @@ Variable_name Value
Qcache_hits 3
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
Qcache_not_cached 18
show grants for current_user();
Grants for @localhost
GRANT USAGE ON *.* TO ''@'localhost'
......@@ -143,7 +143,7 @@ Variable_name Value
Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 2
Qcache_not_cached 22
select "user3";
user3
user3
......@@ -167,7 +167,7 @@ Variable_name Value
Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 7
Qcache_not_cached 30
select "user4";
user4
user4
......@@ -197,7 +197,7 @@ Variable_name Value
Qcache_hits 8
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 8
Qcache_not_cached 34
set names binary;
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
......
show variables variable_name where variable_name like "skip_show_database";
variable_name
skip_show_database
grant all privileges on test.* to mysqltest_1@localhost;
select * from information_schema.SCHEMATA where schema_name > 'm';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME SQL_PATH
......@@ -321,11 +324,11 @@ show keys from v4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.views where TABLE_NAME like "v%";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE
NULL test v0 select `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO
NULL test v1 select `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO
NULL test v2 select `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO
NULL test v3 select `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO
NULL test v4 select `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO
NULL test v0 select sql_no_cache `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO
NULL test v1 select sql_no_cache `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO
NULL test v2 select sql_no_cache `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO
NULL test v3 select sql_no_cache `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO
NULL test v4 select sql_no_cache `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO
drop view v0, v1, v2, v3, v4;
create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost;
......@@ -661,3 +664,14 @@ select table_type from information_schema.tables
where table_schema="mysql" and table_name="user";
table_type
BASE TABLE
show open tables where `table` like "user";
Database Table In_use Name_locked
mysql user 0 0
show status variable_name where variable_name like "%database%";
variable_name
Com_show_databases
show variables variable_name where variable_name like "%database%";
variable_name
character_set_database
collation_database
skip_show_database
......@@ -947,3 +947,13 @@ Variable_name Value
Qcache_hits 7
DROP TABLE t1;
SET GLOBAL query_cache_size=0;
SET SESSION query_cache_type = 2;
create table t1(a int);
select table_name from information_schema.tables
where table_schema="test";
table_name
t1
drop table t1;
select table_name from information_schema.tables
where table_schema="test";
table_name
......@@ -94,6 +94,6 @@ d
2002-10-24 14:50:40
show status like "created_tmp%tables";
Variable_name Value
Created_tmp_disk_tables 0
Created_tmp_tables 1
Created_tmp_disk_tables 1
Created_tmp_tables 2
drop table t1;
......@@ -851,27 +851,27 @@ count(*)
26
show status like 'Slow_queries';
Variable_name Value
Slow_queries 0
Slow_queries 1
select count(*) from t1 where b=13;
count(*)
10
show status like 'Slow_queries';
Variable_name Value
Slow_queries 1
Slow_queries 3
select count(*) from t1 where b=13 union select count(*) from t1 where a=7;
count(*)
10
26
show status like 'Slow_queries';
Variable_name Value
Slow_queries 2
Slow_queries 5
select count(*) from t1 where a=7 union select count(*) from t1 where b=13;
count(*)
26
10
show status like 'Slow_queries';
Variable_name Value
Slow_queries 3
Slow_queries 7
drop table t1;
create table t1 ( RID int(11) not null default '0', IID int(11) not null default '0', nada varchar(50) not null,NAME varchar(50) not null,PHONE varchar(50) not null) engine=MyISAM;
insert into t1 ( RID,IID,nada,NAME,PHONE) values (1, 1, 'main', 'a', '111'), (2, 1, 'main', 'b', '222'), (3, 1, 'main', 'c', '333'), (4, 1, 'main', 'd', '444'), (5, 1, 'main', 'e', '555'), (6, 2, 'main', 'c', '333'), (7, 2, 'main', 'd', '454'), (8, 2, 'main', 'e', '555'), (9, 2, 'main', 'f', '666'), (10, 2, 'main', 'g', '777');
......
......@@ -2,6 +2,7 @@
# Test for information_schema.schemata &
# show databases
show variables variable_name where variable_name like "skip_show_database";
grant all privileges on test.* to mysqltest_1@localhost;
select * from information_schema.SCHEMATA where schema_name > 'm';
......@@ -346,3 +347,10 @@ select TABLE_ROWS from information_schema.tables where
table_schema="information_schema" and table_name="COLUMNS";
select table_type from information_schema.tables
where table_schema="mysql" and table_name="user";
# test for 'show open tables ... where'
show open tables where `table` like "user";
# test for 'show status ... where'
show status variable_name where variable_name like "%database%";
# test for 'show variables ... where'
show variables variable_name where variable_name like "%database%";
......@@ -686,3 +686,14 @@ show status like "Qcache_hits";
#
DROP TABLE t1;
SET GLOBAL query_cache_size=0;
#
# Information schema & query cache test
#
SET SESSION query_cache_type = 2;
create table t1(a int);
select table_name from information_schema.tables
where table_schema="test";
drop table t1;
select table_name from information_schema.tables
where table_schema="test";
......@@ -720,10 +720,6 @@ bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
void mysqld_list_processes(THD *thd,const char *user,bool verbose);
int mysqld_show_status(THD *thd);
int mysqld_show_variables(THD *thd,const char *wild);
bool mysqld_show(THD *thd, const char *wild, show_var_st *variables,
enum enum_var_type value_type,
pthread_mutex_t *mutex,
struct system_status_var *status_var);
int mysql_find_files(THD *thd,List<char> *files, const char *db,
const char *path, const char *wild, bool dir);
bool mysqld_show_storage_engines(THD *thd);
......
......@@ -1964,6 +1964,9 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
break;
}
#endif
case SCH_OPEN_TABLES:
case SCH_VARIABLES:
case SCH_STATUS:
case SCH_PROCEDURES:
case SCH_CHARSETS:
case SCH_COLLATIONS:
......@@ -3121,25 +3124,6 @@ create_error:
case SQLCOM_SHOW_COLUMN_TYPES:
res= mysqld_show_column_types(thd);
break;
case SQLCOM_SHOW_STATUS:
STATUS_VAR tmp;
if (lex->option_type == OPT_GLOBAL)
{
pthread_mutex_lock(&LOCK_status);
calc_sum_of_all_status(&tmp);
}
res= mysqld_show(thd, (lex->wild ? lex->wild->ptr() : NullS),
status_vars, OPT_GLOBAL, &LOCK_status,
(lex->option_type == OPT_GLOBAL ?
&tmp: &thd->status_var));
if (lex->option_type == OPT_GLOBAL)
pthread_mutex_unlock(&LOCK_status);
break;
case SQLCOM_SHOW_VARIABLES:
res= mysqld_show(thd, (lex->wild ? lex->wild->ptr() : NullS),
init_vars, lex->option_type,
&LOCK_global_system_variables, 0);
break;
case SQLCOM_SHOW_LOGS:
#ifdef DONT_ALLOW_SHOW_COMMANDS
my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
......@@ -3153,9 +3137,6 @@ create_error:
break;
}
#endif
case SQLCOM_SHOW_OPEN_TABLES:
res= mysqld_show_open_tables(thd,(lex->wild ? lex->wild->ptr() : NullS));
break;
case SQLCOM_CHANGE_DB:
mysql_change_db(thd,select_lex->db);
break;
......
......@@ -3716,8 +3716,12 @@ choose_plan(JOIN *join, table_map join_tables)
}
}
/* Store the cost of this query into a user variable */
last_query_cost= join->best_read;
/*
Store the cost of this query into a user variable
Don't update last_query_cost for 'show status' command
*/
if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS)
last_query_cost= join->best_read;
DBUG_VOID_RETURN;
}
......
This diff is collapsed.
......@@ -5899,12 +5899,15 @@ show_param:
if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES))
YYABORT;
}
| OPEN_SYM TABLES opt_db wild
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
lex->select_lex.db= $3;
}
| OPEN_SYM TABLES ext_select_item_list opt_db wild_and_where
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_OPEN_TABLES;
lex->select_lex.db= $4;
if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
YYABORT;
}
| ENGINE_SYM storage_engines
{ Lex->create_info.db_type= $2; }
show_engine_param
......@@ -5980,22 +5983,28 @@ show_param:
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
| ERRORS opt_limit_clause_init
{ Lex->sql_command = SQLCOM_SHOW_ERRORS;}
| opt_var_type STATUS_SYM wild
| opt_var_type STATUS_SYM ext_select_item_list wild_and_where
{
THD *thd= YYTHD;
thd->lex->sql_command= SQLCOM_SHOW_STATUS;
thd->lex->option_type= (enum_var_type) $1;
}
LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_STATUS;
lex->option_type= (enum_var_type) $1;
if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
YYABORT;
}
| INNOBASE_SYM STATUS_SYM
{ Lex->sql_command = SQLCOM_SHOW_INNODB_STATUS; WARN_DEPRECATED("SHOW INNODB STATUS", "SHOW ENGINE INNODB STATUS"); }
| opt_full PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
| opt_var_type VARIABLES wild
{
THD *thd= YYTHD;
thd->lex->sql_command= SQLCOM_SHOW_VARIABLES;
thd->lex->option_type= (enum_var_type) $1;
}
| opt_var_type VARIABLES ext_select_item_list wild_and_where
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_VARIABLES;
lex->option_type= (enum_var_type) $1;
if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES))
YYABORT;
}
| charset ext_select_item_list wild_and_where
{
LEX *lex= Lex;
......@@ -6143,12 +6152,6 @@ opt_db:
/* empty */ { $$= 0; }
| from_or_in ident { $$= $2.str; };
wild:
/* empty */
| LIKE TEXT_STRING_sys
{ Lex->wild= new (YYTHD->mem_root) String($2.str, $2.length,
system_charset_info); };
opt_full:
/* empty */ { Lex->verbose=0; }
| FULL { Lex->verbose=1; };
......@@ -6186,7 +6189,10 @@ ext_select_item_list:
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_LIST;
}
/* empty */
ext_select_item_list2;
ext_select_item_list2:
/* empty */ {}
| select_item_list {};
......
......@@ -223,7 +223,7 @@ enum enum_schema_tables
SCH_COLLATION_CHARACTER_SET_APPLICABILITY, SCH_PROCEDURES, SCH_STATISTICS,
SCH_VIEWS, SCH_USER_PRIVILEGES, SCH_SCHEMA_PRIVILEGES, SCH_TABLE_PRIVILEGES,
SCH_COLUMN_PRIVILEGES, SCH_TABLE_CONSTRAINTS, SCH_KEY_COLUMN_USAGE,
SCH_TABLE_NAMES
SCH_TABLE_NAMES, SCH_OPEN_TABLES, SCH_STATUS, SCH_VARIABLES
};
......
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