#At bzr+ssh://bk-internal.mysql.com/bzrroot/mysql-6.0-sea
2643 Narayanan V 2008-06-27
WL#4448
The attached patch adds a method handlerton::fill_is_table that can be used instead
of having to create specific handlerton::fill_*_table methods.
In working on this issue a major change that is obvious is that I have moved the
definition
of the enumeration enum_schema_tables from sql/table.h to sql/handler.h.
sql/table.h and sql/handler.h have a sort of cyclic dependency in between them, in
that
sql/handler.h uses structures defined in sql/table.h, while, sql/table.h uses
enumerations
defined in sql/handler.h. So to compensate for the problems that arise from
sql/handler.h
included before sql/table.h, sql/handler.h includes forward declarations of the
structures.
In our case since we need an enumeration(enum_schema_tables) from sql/table.h in
sql/handler.h.
This would result in problems since enumerations cannot be forward declared.
The problem can however be solved by moving enum_schema_tables from sql/table.h to
sql/handler.h.
This however might not be semantically appealing to some folks.
The workaround for enum forward declarations can be found here
http://www.ddj.com/cpp/184403894.
I did not find this solution elegant atleast to our context. If this seems better to
folks I can
possibly attempt this.
modified:
sql/ha_ndbcluster.cc
sql/handler.h
sql/mysql_priv.h.pp
sql/sql_show.cc
sql/table.h
per-file messages:
sql/ha_ndbcluster.cc
Implemented the method ndbcluster_fill_is_table that uses the supplied table id to
switch to the appropriate fill_*_table method.
sql/handler.h
Moved the enum_schema_table enumeration from table.h to here.
contains the declaration for the new method fill_is_tables.
sql/mysql_priv.h.pp
Had to change this file to accomodate the shift of enum_schema_tables from sql/table.h
to sql/handler.h.
sql/sql_show.cc
calls the fill_is_table method.
sql/table.h
removed the earlier definition of enum_schema_tables.
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2008-04-25 16:43:25 +0000
+++ b/sql/ha_ndbcluster.cc 2008-06-27 05:11:51 +0000
@@ -83,6 +83,11 @@ static bool ndbcluster_show_status(handl
static int ndbcluster_alter_tablespace(handlerton *hton,
THD* thd,
st_alter_tablespace *info);
+static int ndbcluster_fill_is_table(handlerton *hton,
+ THD *thd,
+ TABLE_LIST *tables,
+ COND *cond,
+ enum enum_schema_tables);
static int ndbcluster_fill_files_table(handlerton *hton,
THD *thd,
TABLE_LIST *tables,
@@ -7897,7 +7902,7 @@ static int ndbcluster_init(void *p)
h->partition_flags= ndbcluster_partition_flags; /* Partition flags */
h->alter_partition_flags=
ndbcluster_alter_partition_flags; /* Alter table flags */
- h->fill_files_table= ndbcluster_fill_files_table;
+ h->fill_is_table= ndbcluster_fill_is_table;
#ifdef HAVE_NDB_BINLOG
ndbcluster_binlog_init_handlerton();
#endif
@@ -11470,6 +11475,29 @@ bool ha_ndbcluster::get_no_parts(const c
DBUG_RETURN(TRUE);
}
+/**
+ Used to fill in INFORMATION_SCHEMA* tables.
+
+ @param hton handle to the handlerton structure
+ @param thd the thread/connection descriptor
+ @param[in,out] tables the information schema table that is filled up
+ @param cond used for conditional pushdown to storage engine
+ @param schema_table_idx the table id that distinguishes the type of table
+
+ @return Operation status
+ */
+static int ndbcluster_fill_is_table(handlerton *hton,
+ THD *thd,
+ TABLE_LIST *tables,
+ COND *cond,
+ enum enum_schema_tables schema_table_idx)
+{
+ if (schema_table_idx == SCH_FILES)
+ {
+ ndbcluster_fill_files_table(hton, thd, tables, cond);
+ }
+}
+
static int ndbcluster_fill_files_table(handlerton *hton,
THD *thd,
TABLE_LIST *tables,
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2008-05-08 13:01:30 +0000
+++ b/sql/handler.h 2008-06-27 05:11:51 +0000
@@ -549,6 +549,49 @@ class st_alter_tablespace : public Sql_a
/* The handler for a table type. Will be included in the TABLE structure */
struct st_table;
+
+/*
+ Make sure that the order of schema_tables and enum_schema_tables are the same.
+*/
+enum enum_schema_tables
+{
+ SCH_CHARSETS= 0,
+ SCH_COLLATIONS,
+ SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
+ SCH_COLUMNS,
+ SCH_COLUMN_PRIVILEGES,
+ SCH_ENGINES,
+ SCH_EVENTS,
+ SCH_FILES,
+ SCH_GLOBAL_STATUS,
+ SCH_GLOBAL_VARIABLES,
+ SCH_KEY_COLUMN_USAGE,
+ SCH_OPEN_TABLES,
+ SCH_PARAMETERS,
+ SCH_PARTITIONS,
+ SCH_PLUGINS,
+ SCH_PROCESSLIST,
+ SCH_PROFILES,
+ SCH_REFERENTIAL_CONSTRAINTS,
+ SCH_PROCEDURES,
+ SCH_SCHEMATA,
+ SCH_SCHEMA_PRIVILEGES,
+ SCH_SESSION_STATUS,
+ SCH_SESSION_VARIABLES,
+ SCH_STATISTICS,
+ SCH_STATUS,
+ SCH_TABLES,
+ SCH_TABLE_CONSTRAINTS,
+ SCH_TABLE_NAMES,
+ SCH_TABLE_PRIVILEGES,
+ SCH_TRIGGERS,
+ SCH_USER_PRIVILEGES,
+ SCH_VARIABLES,
+ SCH_VIEWS,
+ SCH_FALCON_TABLESPACES,
+ SCH_FALCON_TABLESPACE_FILES
+};
+
typedef struct st_table TABLE;
typedef struct st_table_share TABLE_SHARE;
struct st_foreign_key_info;
@@ -716,6 +759,9 @@ struct handlerton
int (*fill_files_table)(handlerton *hton, THD *thd,
TABLE_LIST *tables,
class Item *cond);
+ int (*fill_is_table)(handlerton *hton, THD *thd, TABLE_LIST *tables,
+ class Item *cond,
+ enum enum_schema_tables);
uint32 flags; /* global handler flags */
/*
Those handlerton functions below are properly initialized at handler
=== modified file 'sql/mysql_priv.h.pp'
--- a/sql/mysql_priv.h.pp 2008-06-17 17:17:25 +0000
+++ b/sql/mysql_priv.h.pp 2008-06-27 05:11:51 +0000
@@ -4109,6 +4109,44 @@ class st_alter_tablespace : public Sql_a
}
};
struct st_table;
+enum enum_schema_tables
+{
+ SCH_CHARSETS= 0,
+ SCH_COLLATIONS,
+ SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
+ SCH_COLUMNS,
+ SCH_COLUMN_PRIVILEGES,
+ SCH_ENGINES,
+ SCH_EVENTS,
+ SCH_FILES,
+ SCH_GLOBAL_STATUS,
+ SCH_GLOBAL_VARIABLES,
+ SCH_KEY_COLUMN_USAGE,
+ SCH_OPEN_TABLES,
+ SCH_PARAMETERS,
+ SCH_PARTITIONS,
+ SCH_PLUGINS,
+ SCH_PROCESSLIST,
+ SCH_PROFILES,
+ SCH_REFERENTIAL_CONSTRAINTS,
+ SCH_PROCEDURES,
+ SCH_SCHEMATA,
+ SCH_SCHEMA_PRIVILEGES,
+ SCH_SESSION_STATUS,
+ SCH_SESSION_VARIABLES,
+ SCH_STATISTICS,
+ SCH_STATUS,
+ SCH_TABLES,
+ SCH_TABLE_CONSTRAINTS,
+ SCH_TABLE_NAMES,
+ SCH_TABLE_PRIVILEGES,
+ SCH_TRIGGERS,
+ SCH_USER_PRIVILEGES,
+ SCH_VARIABLES,
+ SCH_VIEWS,
+ SCH_FALCON_TABLESPACES,
+ SCH_FALCON_TABLESPACE_FILES
+};
typedef struct st_table TABLE;
typedef struct st_table_share TABLE_SHARE;
struct st_foreign_key_info;
@@ -4175,6 +4213,9 @@ struct handlerton
int (*fill_files_table)(handlerton *hton, THD *thd,
TABLE_LIST *tables,
class Item *cond);
+ int (*fill_is_table)(handlerton *hton, THD *thd, TABLE_LIST *tables,
+ class Item *cond,
+ enum enum_schema_tables);
uint32 flags;
int (*binlog_func)(handlerton *hton, THD *thd, enum_binlog_func fn, void *arg);
void (*binlog_log_query)(handlerton *hton, THD *thd,
@@ -4510,35 +4551,35 @@ public:
int ha_index_init(uint idx, In_C_you_should_use_my_bool_instead() sorted)
{
int result;
- const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("ha_index_init","./sql/handler.h",1417,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
+ const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("ha_index_init","./sql/handler.h",1463,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
assert(inited==NONE);
if (!(result= index_init(idx, sorted)))
inited=INDEX;
end_range= NULL;
- do {_db_return_ (1422, &_db_func_, &_db_file_, &_db_level_);
return(result);} while(0);
+ do {_db_return_ (1468, &_db_func_, &_db_file_, &_db_level_);
return(result);} while(0);
}
int ha_index_end()
{
- const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("ha_index_end","./sql/handler.h",1426,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
+ const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("ha_index_end","./sql/handler.h",1472,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
assert(inited==INDEX);
inited=NONE;
end_range= NULL;
- do {_db_return_ (1430, &_db_func_, &_db_file_, &_db_level_);
return(index_end());} while(0);
+ do {_db_return_ (1476, &_db_func_, &_db_file_, &_db_level_);
return(index_end());} while(0);
}
int ha_rnd_init(In_C_you_should_use_my_bool_instead() scan)
{
int result;
- const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("ha_rnd_init","./sql/handler.h",1435,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
+ const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("ha_rnd_init","./sql/handler.h",1481,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
assert(inited==NONE || (inited==RND && scan));
inited= (result= rnd_init(scan)) ? NONE: RND;
- do {_db_return_ (1438, &_db_func_, &_db_file_, &_db_level_);
return(result);} while(0);
+ do {_db_return_ (1484, &_db_func_, &_db_file_, &_db_level_);
return(result);} while(0);
}
int ha_rnd_end()
{
- const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("ha_rnd_end","./sql/handler.h",1442,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
+ const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("ha_rnd_end","./sql/handler.h",1488,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
assert(inited==RND);
inited=NONE;
- do {_db_return_ (1445, &_db_func_, &_db_file_, &_db_level_);
return(rnd_end());} while(0);
+ do {_db_return_ (1491, &_db_func_, &_db_file_, &_db_level_);
return(rnd_end());} while(0);
}
int ha_reset();
int ha_index_or_rnd_end()
@@ -4719,7 +4760,7 @@ public:
ulonglong *nb_reserved_values);
void set_next_insert_id(ulonglong id)
{
- do {_db_pargs_(1757,"info"); _db_doprnt_ ("auto_increment: next value %lu",
(ulong)id);} while(0);
+ do {_db_pargs_(1803,"info"); _db_doprnt_ ("auto_increment: next value %lu",
(ulong)id);} while(0);
next_insert_id= id;
}
void restore_auto_increment(ulonglong prev_insert_id)
@@ -4820,12 +4861,12 @@ public:
HA_ALTER_FLAGS *alter_flags,
uint table_changes)
{
- const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("check_if_supported_alter","./sql/handler.h",2030,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
+ const char *_db_func_, *_db_file_; uint _db_level_; char **_db_framep_; _db_enter_
("check_if_supported_alter","./sql/handler.h",2076,&_db_func_,&_db_file_,&_db_level_,
&_db_framep_);
if (this->check_if_incompatible_data(create_info, table_changes)
== 1)
- do {_db_return_ (2033, &_db_func_, &_db_file_, &_db_level_); return(2);}
while(0);
+ do {_db_return_ (2079, &_db_func_, &_db_file_, &_db_level_); return(2);}
while(0);
else
- do {_db_return_ (2035, &_db_func_, &_db_file_, &_db_level_); return(0);}
while(0);
+ do {_db_return_ (2081, &_db_func_, &_db_file_, &_db_level_); return(0);}
while(0);
}
virtual int alter_table_phase1(THD *thd,
TABLE *altered_table,
@@ -5482,44 +5523,6 @@ typedef struct st_foreign_key_info
List<LEX_STRING> foreign_fields;
List<LEX_STRING> referenced_fields;
} FOREIGN_KEY_INFO;
-enum enum_schema_tables
-{
- SCH_CHARSETS= 0,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
- SCH_ENGINES,
- SCH_EVENTS,
- SCH_FILES,
- SCH_GLOBAL_STATUS,
- SCH_GLOBAL_VARIABLES,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PARAMETERS,
- SCH_PARTITIONS,
- SCH_PLUGINS,
- SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_REFERENTIAL_CONSTRAINTS,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
- SCH_SCHEMA_PRIVILEGES,
- SCH_SESSION_STATUS,
- SCH_SESSION_VARIABLES,
- SCH_STATISTICS,
- SCH_STATUS,
- SCH_TABLES,
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
- SCH_VARIABLES,
- SCH_VIEWS,
- SCH_FALCON_TABLESPACES,
- SCH_FALCON_TABLESPACE_FILES
-};
typedef struct st_field_info
{
const char* field_name;
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2008-05-14 13:49:41 +0000
+++ b/sql/sql_show.cc 2008-06-27 05:11:51 +0000
@@ -6339,8 +6339,9 @@ static my_bool run_hton_fill_schema_file
struct run_hton_fill_schema_files_args *args=
(run_hton_fill_schema_files_args *) arg;
handlerton *hton= plugin_data(plugin, handlerton *);
- if(hton->fill_files_table && hton->state == SHOW_OPTION_YES)
- hton->fill_files_table(hton, thd, args->tables, args->cond);
+ if(hton->fill_is_table && hton->state == SHOW_OPTION_YES)
+ hton->fill_is_table(hton, thd, args->tables, args->cond,
+ get_schema_table_idx(args->tables->schema_table));
return false;
}
=== modified file 'sql/table.h'
--- a/sql/table.h 2008-05-21 10:17:29 +0000
+++ b/sql/table.h 2008-06-27 05:11:51 +0000
@@ -814,50 +814,6 @@ typedef struct st_foreign_key_info
List<LEX_STRING> referenced_fields;
} FOREIGN_KEY_INFO;
-/*
- Make sure that the order of schema_tables and enum_schema_tables are the same.
-*/
-
-enum enum_schema_tables
-{
- SCH_CHARSETS= 0,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
- SCH_ENGINES,
- SCH_EVENTS,
- SCH_FILES,
- SCH_GLOBAL_STATUS,
- SCH_GLOBAL_VARIABLES,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PARAMETERS,
- SCH_PARTITIONS,
- SCH_PLUGINS,
- SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_REFERENTIAL_CONSTRAINTS,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
- SCH_SCHEMA_PRIVILEGES,
- SCH_SESSION_STATUS,
- SCH_SESSION_VARIABLES,
- SCH_STATISTICS,
- SCH_STATUS,
- SCH_TABLES,
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
- SCH_VARIABLES,
- SCH_VIEWS,
- SCH_FALCON_TABLESPACES,
- SCH_FALCON_TABLESPACE_FILES
-};
-
-
#define MY_I_S_MAYBE_NULL 1
#define MY_I_S_UNSIGNED 2