Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2118 06/02/01 18:23:34 stewart@stripped +6 -0
Merge mysql.com:/home/stewart/Documents/MySQL/5.1/new
into mysql.com:/home/stewart/Documents/MySQL/5.1/wl1359
sql/sql_show.cc
1.295 06/02/01 18:23:30 stewart@stripped +0 -0
SCCS merged
sql/log.cc
1.190 06/02/01 18:22:46 stewart@stripped +0 -0
Auto merged
sql/handler.h
1.186 06/02/01 18:22:46 stewart@stripped +0 -0
Auto merged
sql/ha_partition.cc
1.27 06/02/01 18:22:46 stewart@stripped +0 -0
Auto merged
sql/ha_ndbcluster.cc
1.252 06/02/01 18:22:45 stewart@stripped +0 -0
Auto merged
sql/ha_innodb.cc
1.252 06/02/01 18:22:45 stewart@stripped +0 -0
Auto merged
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: stewart
# Host: willster.(none)
# Root: /home/stewart/Documents/MySQL/5.1/wl1359/RESYNC
--- 1.185/sql/handler.h 2006-02-01 04:46:37 +11:00
+++ 1.186/sql/handler.h 2006-02-01 18:22:46 +11:00
@@ -571,6 +571,9 @@
uint (*partition_flags)();
uint (*alter_table_flags)(uint flags);
int (*alter_tablespace)(THD *thd, st_alter_tablespace *ts_info);
+ int (*fill_files_table)(THD *thd,
+ struct st_table_list *tables,
+ class Item *cond);
uint32 flags; /* global handler flags */
/*
Handlerton functions are not set in the different storage
--- 1.189/sql/log.cc 2006-01-28 00:10:37 +11:00
+++ 1.190/sql/log.cc 2006-02-01 18:22:46 +11:00
@@ -101,6 +101,7 @@
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter Tablespace */
+ NULL, /* Fill FILES table */
HTON_NOT_USER_SELECTABLE | HTON_HIDDEN
};
--- 1.294/sql/sql_show.cc 2006-01-28 14:16:19 +11:00
+++ 1.295/sql/sql_show.cc 2006-02-01 18:23:30 +11:00
@@ -25,6 +25,7 @@
#include "sp_head.h"
#include "sql_trigger.h"
#include "authors.h"
+#include "event.h"
#include <my_dir.h>
#ifdef WITH_PARTITION_STORAGE_ENGINE
@@ -1132,6 +1133,17 @@
if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) &&
!foreign_db_mode)
{
/*
+ Get possible table space definitions and append them
+ to the CREATE TABLE statement
+ */
+
+ if ((for_str= file->get_tablespace_create_info()))
+ {
+ packet->append(for_str, strlen(for_str));
+ my_free(for_str, MYF(0));
+ }
+
+ /*
IF check_create_info
THEN add ENGINE only if it was used when creating the table
*/
@@ -1898,6 +1910,7 @@
case SQLCOM_SHOW_TABLES:
case SQLCOM_SHOW_TABLE_STATUS:
case SQLCOM_SHOW_TRIGGERS:
+ case SQLCOM_SHOW_EVENTS:
index_field_values->db_value= lex->select_lex.db;
index_field_values->table_value= wild;
break;
@@ -3767,6 +3780,269 @@
}
+static LEX_STRING interval_type_to_name[] = {
+ {(char *) STRING_WITH_LEN("INTERVAL_YEAR")},
+ {(char *) STRING_WITH_LEN("INTERVAL_QUARTER")},
+ {(char *) STRING_WITH_LEN("INTERVAL_MONTH")},
+ {(char *) STRING_WITH_LEN("INTERVAL_DAY")},
+ {(char *) STRING_WITH_LEN("INTERVAL_HOUR")},
+ {(char *) STRING_WITH_LEN("INTERVAL_MINUTE")},
+ {(char *) STRING_WITH_LEN("INTERVAL_WEEK")},
+ {(char *) STRING_WITH_LEN("INTERVAL_SECOND")},
+ {(char *) STRING_WITH_LEN("INTERVAL_MICROSECOND ")},
+ {(char *) STRING_WITH_LEN("INTERVAL_YEAR_MONTH")},
+ {(char *) STRING_WITH_LEN("INTERVAL_DAY_HOUR")},
+ {(char *) STRING_WITH_LEN("INTERVAL_DAY_MINUTE")},
+ {(char *) STRING_WITH_LEN("INTERVAL_DAY_SECOND")},
+ {(char *) STRING_WITH_LEN("INTERVAL_HOUR_MINUTE")},
+ {(char *) STRING_WITH_LEN("INTERVAL_HOUR_SECOND")},
+ {(char *) STRING_WITH_LEN("INTERVAL_MINUTE_SECOND")},
+ {(char *) STRING_WITH_LEN("INTERVAL_DAY_MICROSECOND")},
+ {(char *) STRING_WITH_LEN("INTERVAL_HOUR_MICROSECOND")},
+ {(char *) STRING_WITH_LEN("INTERVAL_MINUTE_MICROSECOND")},
+ {(char *) STRING_WITH_LEN("INTERVAL_SECOND_MICROSECOND")}
+};
+
+
+static interval_type get_real_interval_type(interval_type i_type)
+{
+ switch (i_type) {
+ case INTERVAL_YEAR:
+ return INTERVAL_YEAR;
+
+ case INTERVAL_QUARTER:
+ case INTERVAL_YEAR_MONTH:
+ case INTERVAL_MONTH:
+ return INTERVAL_MONTH;
+
+ case INTERVAL_WEEK:
+ case INTERVAL_DAY:
+ return INTERVAL_DAY;
+
+ case INTERVAL_DAY_HOUR:
+ case INTERVAL_HOUR:
+ return INTERVAL_HOUR;
+
+ case INTERVAL_DAY_MINUTE:
+ case INTERVAL_HOUR_MINUTE:
+ case INTERVAL_MINUTE:
+ return INTERVAL_MINUTE;
+
+ case INTERVAL_DAY_SECOND:
+ case INTERVAL_HOUR_SECOND:
+ case INTERVAL_MINUTE_SECOND:
+ case INTERVAL_SECOND:
+ return INTERVAL_SECOND;
+
+ case INTERVAL_DAY_MICROSECOND:
+ case INTERVAL_HOUR_MICROSECOND:
+ case INTERVAL_MINUTE_MICROSECOND:
+ case INTERVAL_SECOND_MICROSECOND:
+ case INTERVAL_MICROSECOND:
+ return INTERVAL_MICROSECOND;
+ }
+ DBUG_ASSERT(0);
+ return INTERVAL_SECOND;
+}
+
+
+static int
+fill_events_copy_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
+{
+ const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
+ CHARSET_INFO *scs= system_charset_info;
+ TIME time;
+ event_timed et;
+ DBUG_ENTER("fill_events_copy_to_schema_tab");
+
+ restore_record(sch_table, s->default_values);
+
+ if (et.load_from_row(thd->mem_root, event_table))
+ {
+ my_error(ER_EVENT_CANNOT_LOAD_FROM_TABLE, MYF(0));
+ DBUG_RETURN(1);
+ }
+
+ if (!(!wild || !wild[0] || !wild_compare(et.name.str, wild, 0)))
+ DBUG_RETURN(0);
+
+ //->field[0] is EVENT_CATALOG and is by default NULL
+
+ sch_table->field[1]->store(et.dbname.str, et.dbname.length, scs);
+ sch_table->field[2]->store(et.name.str, et.name.length, scs);
+ sch_table->field[3]->store(et.definer.str, et.definer.length, scs);
+ sch_table->field[4]->store(et.body.str, et.body.length, scs);
+
+ // [9] is SQL_MODE and is NULL for now, will be fixed later
+ sch_table->field[9]->set_null();
+ if (et.expression)
+ {
+ //type
+ sch_table->field[5]->store(STRING_WITH_LEN("RECURRING"), scs);
+ //execute_at
+ sch_table->field[6]->set_null();
+ //interval_value
+ sch_table->field[7]->set_notnull();
+ sch_table->field[7]->store((longlong) et.expression);
+ //interval_type
+ LEX_STRING *ival=&interval_type_to_name[get_real_interval_type(et.interval)];
+ sch_table->field[8]->set_notnull();
+ sch_table->field[8]->store(ival->str, ival->length, scs);
+ //starts & ends
+ sch_table->field[10]->set_notnull();
+ sch_table->field[10]->store_time(&et.starts, MYSQL_TIMESTAMP_DATETIME);
+ sch_table->field[11]->set_notnull();
+ sch_table->field[11]->store_time(&et.ends, MYSQL_TIMESTAMP_DATETIME);
+ }
+ else
+ {
+ //type
+ sch_table->field[5]->store(STRING_WITH_LEN("ONE TIME"), scs);
+ //execute_at
+ sch_table->field[6]->set_notnull();
+ sch_table->field[6]->store_time(&et.execute_at, MYSQL_TIMESTAMP_DATETIME);
+ //interval
+ sch_table->field[7]->set_null();
+ //interval_type
+ sch_table->field[8]->set_null();
+ //starts & ends
+ sch_table->field[10]->set_null();
+ sch_table->field[11]->set_null();
+ }
+
+ //status
+ if (et.status == MYSQL_EVENT_ENABLED)
+ sch_table->field[12]->store(STRING_WITH_LEN("ENABLED"), scs);
+ else
+ sch_table->field[12]->store(STRING_WITH_LEN("DISABLED"), scs);
+
+ //on_completion
+ if (et.on_completion == MYSQL_EVENT_ON_COMPLETION_DROP)
+ sch_table->field[13]->store(STRING_WITH_LEN("NOT PRESERVE"), scs);
+ else
+ sch_table->field[13]->store(STRING_WITH_LEN("PRESERVE"), scs);
+
+ int not_used=0;
+ number_to_datetime(et.created, &time, 0, ¬_used);
+ DBUG_ASSERT(not_used==0);
+ sch_table->field[14]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+
+ number_to_datetime(et.modified, &time, 0, ¬_used);
+ DBUG_ASSERT(not_used==0);
+ sch_table->field[15]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
+
+ if (et.last_executed.year)
+
sch_table->field[16]->store_time(&et.last_executed,MYSQL_TIMESTAMP_DATETIME);
+ else
+ sch_table->field[16]->set_null();
+
+ sch_table->field[17]->store(et.comment.str, et.comment.length, scs);
+
+ if (schema_table_store_record(thd, sch_table))
+ DBUG_RETURN(1);
+
+ DBUG_RETURN(0);
+}
+
+
+int fill_schema_events(THD *thd, TABLE_LIST *tables, COND *cond)
+{
+ TABLE *table= tables->table;
+ CHARSET_INFO *scs= system_charset_info;
+ TABLE *event_table= NULL;
+ Open_tables_state backup;
+ int ret=0;
+ bool verbose= false;
+ char definer[HOSTNAME_LENGTH+USERNAME_LENGTH+2];
+ bool use_prefix_scanning= true;
+ uint key_len= 0;
+ byte *key_buf= NULL;
+ LINT_INIT(key_buf);
+
+ DBUG_ENTER("fill_schema_events");
+
+ strxmov(definer,
thd->security_ctx->priv_user,"@",thd->security_ctx->priv_host,
+ NullS);
+
+ DBUG_PRINT("info",("db=%s current_user=%s", thd->lex->select_lex.db, definer));
+
+ thd->reset_n_backup_open_tables_state(&backup);
+
+ if ((ret= evex_open_event_table(thd, TL_READ, &event_table)))
+ {
+ sql_print_error("Table mysql.event is damaged.");
+ ret= 1;
+ goto err;
+ }
+
+ event_table->file->ha_index_init(0, 1);
+
+ /*
+ see others' events only if you have PROCESS_ACL !!
+ thd->lex->verbose is set either if SHOW FULL EVENTS or
+ in case of SELECT FROM I_S.EVENTS
+ */
+ verbose= (thd->lex->verbose
+ && (thd->security_ctx->master_access & PROCESS_ACL));
+
+ if (verbose && thd->security_ctx->user)
+ {
+ ret= event_table->file->index_first(event_table->record[0]);
+ use_prefix_scanning= false;
+ }
+ else
+ {
+ event_table->field[EVEX_FIELD_DEFINER]->store(definer, strlen(definer), scs);
+ key_len= event_table->key_info->key_part[0].store_length;
+
+ if (thd->lex->select_lex.db)
+ {
+ event_table->field[EVEX_FIELD_DB]->
+ store(thd->lex->select_lex.db, strlen(thd->lex->select_lex.db),
scs);
+ key_len+= event_table->key_info->key_part[1].store_length;
+ }
+ if (!(key_buf= alloc_root(thd->mem_root, key_len)))
+ {
+ ret= 1;
+ goto err;
+ }
+
+ key_copy(key_buf, event_table->record[0], event_table->key_info, key_len);
+ ret= event_table->file->index_read(event_table->record[0], key_buf, key_len,
+ HA_READ_PREFIX);
+ }
+
+ if (ret)
+ {
+ ret= (ret == HA_ERR_END_OF_FILE || ret == HA_ERR_KEY_NOT_FOUND) ? 0 : 1;
+ goto err;
+ }
+
+ while (!ret)
+ {
+ if ((ret= fill_events_copy_to_schema_table(thd, table, event_table)))
+ goto err;
+
+ if (use_prefix_scanning)
+ ret= event_table->file->
+ index_next_same(event_table->record[0], key_buf, key_len);
+ else
+ ret= event_table->file->index_next(event_table->record[0]);
+ }
+ // ret is guaranteed to be != 0
+ ret= (ret != HA_ERR_END_OF_FILE);
+err:
+ if (event_table)
+ {
+ event_table->file->ha_index_end();
+ close_thread_tables(thd);
+ }
+
+ thd->restore_backup_open_tables_state(&backup);
+ DBUG_RETURN(ret);
+}
+
+
int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond)
{
DBUG_ENTER("fill_open_tables");
@@ -4419,6 +4695,31 @@
};
+ST_FIELD_INFO events_fields_info[]=
+{
+ {"EVENT_CATALOG", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"EVENT_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Db"},
+ {"EVENT_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"},
+ {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer"},
+ {"EVENT_BODY", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"EVENT_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, "Type"},
+ {"EXECUTE_AT", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Execute at"},
+ {"INTERVAL_VALUE", 11, MYSQL_TYPE_LONG, 0, 1, "Interval value"},
+ {"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1, "Interval field"},
+ {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"STARTS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Starts"},
+ {"ENDS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Ends"},
+ {"STATUS", 8, MYSQL_TYPE_STRING, 0, 0, "Status"},
+ {"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"CREATED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0},
+ {"LAST_ALTERED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0},
+ {"LAST_EXECUTED", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0},
+ {"EVENT_COMMENT", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
+};
+
+
+
ST_FIELD_INFO coll_charset_app_fields_info[]=
{
{"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0},
@@ -4726,6 +5027,8 @@
fill_schema_column_privileges, 0, 0, -1, -1, 0},
{"ENGINES", engines_fields_info, create_schema_table,
fill_schema_engines, make_old_format, 0, -1, -1, 0},
+ {"EVENTS", events_fields_info, create_schema_table,
+ fill_schema_events, make_old_format, 0, -1, -1, 0},
{"FILES", files_fields_info, create_schema_table,
fill_schema_files, 0, 0, -1, -1, 0},
{"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
--- 1.251/sql/ha_ndbcluster.cc 2006-02-01 11:12:04 +11:00
+++ 1.252/sql/ha_ndbcluster.cc 2006-02-01 18:22:45 +11:00
@@ -63,6 +63,7 @@
static int ndbcluster_end(ha_panic_function flag);
static bool ndbcluster_show_status(THD*,stat_print_fn *,enum ha_stat_type);
static int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info);
+static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond);
handlerton ndbcluster_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
@@ -5795,6 +5796,7 @@
h.alter_tablespace= ndbcluster_alter_tablespace; /* Show status */
h.partition_flags= ndbcluster_partition_flags; /* Partition flags */
h.alter_table_flags=ndbcluster_alter_table_flags; /* Alter table flags */
+ h.fill_files_table= ndbcluster_fill_files_table;
#ifdef HAVE_NDB_BINLOG
ndbcluster_binlog_init_handlerton();
#endif
@@ -9587,3 +9589,161 @@
DBUG_RETURN(TRUE);
}
+static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond)
+{
+ TABLE* table= tables->table;
+ Thd_ndb *thd_ndb= get_thd_ndb(thd);
+ Ndb *ndb= thd_ndb->ndb;
+ NdbDictionary::Dictionary* dict= ndb->getDictionary();
+ NdbDictionary::Dictionary::List dflist;
+
+ dict->listObjects(dflist,NdbDictionary::Object::Datafile);
+
+ for(unsigned i= 0;i < dflist.count;i++)
+ {
+ NdbDictionary::Dictionary::List::Element& elt = dflist.elements[i];
+ Ndb_cluster_connection_node_iter iter;
+ unsigned id;
+
+ g_ndb_cluster_connection->init_get_next_node(iter);
+
+ while(id= g_ndb_cluster_connection->get_next_node(iter))
+ {
+ NdbDictionary::Datafile df= dict->getDatafile(id, elt.name);
+ int c=0;
+ table->field[c++]->set_null(); // FILE_ID
+ table->field[c++]->store(elt.name,strlen(elt.name),system_charset_info);
+ table->field[c++]->store("DATAFILE",8,system_charset_info);
+ table->field[c++]->store(df.getTablespace(),strlen(df.getTablespace()),
+ system_charset_info);
+ table->field[c++]->set_null(); // TABLE_CATALOG
+ table->field[c++]->set_null(); // TABLE_SCHEMA
+ table->field[c++]->set_null(); // TABLE_NAME
+
+ NdbDictionary::Tablespace ts= dict->getTablespace(df.getTablespace());
+
+ // LOGFILE_GROUP_NAME
+ table->field[c++]->store(ts.getDefaultLogfileGroup(),
+ strlen(ts.getDefaultLogfileGroup()),
+ system_charset_info);
+ table->field[c++]->set_null(); // LOGFILE_GROUP_NUMBER
+ table->field[c++]->store(ndbcluster_hton.name,
+ strlen(ndbcluster_hton.name),
+ system_charset_info); // ENGINE
+
+ table->field[c++]->set_null(); // FULLTEXT_KEYS
+ table->field[c++]->set_null(); // DELETED_ROWS
+ table->field[c++]->set_null(); // UPDATE_COUNT
+ table->field[c++]->store(df.getFree() / ts.getExtentSize()); // FREE_EXTENTS
+ table->field[c++]->store(df.getSize() / ts.getExtentSize()); // TOTAL_EXTENTS
+ table->field[c++]->store(ts.getExtentSize()); // EXTENT_SIZE
+
+ table->field[c++]->store(df.getSize()); // INITIAL_SIZE
+ table->field[c++]->store(df.getSize()); // MAXIMUM_SIZE
+ table->field[c++]->set_null(); // AUTOEXTEND_SIZE
+
+ table->field[c++]->set_null(); // CREATION_TIME
+ table->field[c++]->set_null(); // LAST_UPDATE_TIME
+ table->field[c++]->set_null(); // LAST_ACCESS_TIME
+ table->field[c++]->set_null(); // RECOVER_TIME
+ table->field[c++]->set_null(); // TRANSACTION_COUNTER
+
+ table->field[c++]->store(df.getObjectVersion()); // VERSION
+
+ table->field[c++]->store("FIXED",5,system_charset_info); // ROW_FORMAT
+
+ table->field[c++]->set_null(); // TABLE_ROWS
+ table->field[c++]->set_null(); // AVG_ROW_LENGTH
+ table->field[c++]->set_null(); // DATA_LENGTH
+ table->field[c++]->set_null(); // MAX_DATA_LENGTH
+ table->field[c++]->set_null(); // INDEX_LENGTH
+ table->field[c++]->set_null(); // DATA_FREE
+ table->field[c++]->set_null(); // CREATE_TIME
+ table->field[c++]->set_null(); // UPDATE_TIME
+ table->field[c++]->set_null(); // CHECK_TIME
+ table->field[c++]->set_null(); // CHECKSUM
+
+ table->field[c++]->store("NORMAL",6, system_charset_info);
+
+ char extra[30];
+ int len= snprintf(extra,sizeof(extra),"CLUSTER_NODE=%u",id);
+ table->field[c]->store(extra,len,system_charset_info);
+ schema_table_store_record(thd, table);
+ }
+ }
+
+ dict->listObjects(dflist,NdbDictionary::Object::Undofile);
+
+ for(unsigned i= 0;i < dflist.count;i++)
+ {
+ NdbDictionary::Dictionary::List::Element& elt = dflist.elements[i];
+ Ndb_cluster_connection_node_iter iter;
+ unsigned id;
+
+ g_ndb_cluster_connection->init_get_next_node(iter);
+
+ while(id= g_ndb_cluster_connection->get_next_node(iter))
+ {
+ NdbDictionary::Undofile uf= dict->getUndofile(id, elt.name);
+ int c=0;
+ table->field[c++]->set_null(); // FILE_ID
+ table->field[c++]->store(elt.name,strlen(elt.name),system_charset_info);
+ table->field[c++]->store("UNDO LOG",8,system_charset_info);
+ table->field[c++]->set_null(); // TABLESPACE NAME
+ table->field[c++]->set_null(); // TABLE_CATALOG
+ table->field[c++]->set_null(); // TABLE_SCHEMA
+ table->field[c++]->set_null(); // TABLE_NAME
+
+ NdbDictionary::LogfileGroup lfg=
+ dict->getLogfileGroup(uf.getLogfileGroup());
+
+ // LOGFILE_GROUP_NAME
+ table->field[c++]->store(uf.getLogfileGroup(),
+ strlen(uf.getLogfileGroup()),
+ system_charset_info);
+ table->field[c++]->store(uf.getLogfileGroupId()); // LOGFILE_GROUP_NUMBER
+ table->field[c++]->store(ndbcluster_hton.name,
+ strlen(ndbcluster_hton.name),
+ system_charset_info); // ENGINE
+
+ table->field[c++]->set_null(); // FULLTEXT_KEYS
+ table->field[c++]->set_null(); // DELETED_ROWS
+ table->field[c++]->set_null(); // UPDATE_COUNT
+ table->field[c++]->store(lfg.getUndoFreeWords()); // FREE_EXTENTS
+ table->field[c++]->store(lfg.getUndoBufferSize()); // TOTAL_EXTENTS
+ table->field[c++]->store(4); // EXTENT_SIZE
+
+ table->field[c++]->store(uf.getSize()); // INITIAL_SIZE
+ table->field[c++]->store(uf.getSize()); // MAXIMUM_SIZE
+ table->field[c++]->set_null(); // AUTOEXTEND_SIZE
+
+ table->field[c++]->set_null(); // CREATION_TIME
+ table->field[c++]->set_null(); // LAST_UPDATE_TIME
+ table->field[c++]->set_null(); // LAST_ACCESS_TIME
+ table->field[c++]->set_null(); // RECOVER_TIME
+ table->field[c++]->set_null(); // TRANSACTION_COUNTER
+
+ table->field[c++]->store(uf.getObjectVersion()); // VERSION
+
+ table->field[c++]->set_null(); // ROW FORMAT
+
+ table->field[c++]->set_null(); // TABLE_ROWS
+ table->field[c++]->set_null(); // AVG_ROW_LENGTH
+ table->field[c++]->set_null(); // DATA_LENGTH
+ table->field[c++]->set_null(); // MAX_DATA_LENGTH
+ table->field[c++]->set_null(); // INDEX_LENGTH
+ table->field[c++]->set_null(); // DATA_FREE
+ table->field[c++]->set_null(); // CREATE_TIME
+ table->field[c++]->set_null(); // UPDATE_TIME
+ table->field[c++]->set_null(); // CHECK_TIME
+ table->field[c++]->set_null(); // CHECKSUM
+
+ table->field[c++]->store("NORMAL",6, system_charset_info);
+
+ char extra[30];
+ int len= snprintf(extra,sizeof(extra),"CLUSTER_NODE=%u",id);
+ table->field[c]->store(extra,len,system_charset_info);
+ schema_table_store_record(thd, table);
+ }
+ }
+}
--- 1.26/sql/ha_partition.cc 2006-01-28 14:16:19 +11:00
+++ 1.27/sql/ha_partition.cc 2006-02-01 18:22:46 +11:00
@@ -612,7 +612,6 @@
DBUG_ENTER("ha_partition::create");
strmov(t_name, name);
-// *fn_ext(t_name)= 0;
DBUG_ASSERT(*fn_rext((char*)name) == '\0');
if (del_ren_cre_table(t_name, NULL, table_arg, create_info))
{
@@ -2155,7 +2154,7 @@
if (!(engine_array= (handlerton **) my_malloc(m_tot_parts *
sizeof(handlerton*),MYF(0))))
goto err2;
for (i= 0; i < m_tot_parts; i++)
- engine_array[i]= ha_resolve_by_legacy_type(current_thd,
+ engine_array[i]= ha_resolve_by_legacy_type(current_thd,
(enum legacy_db_type) *(uchar *) ((file_buffer) + 12 + i));
address_tot_name_len= file_buffer + 12 + 4 * tot_partition_words;
tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4;
@@ -2209,11 +2208,11 @@
int ha_partition::open(const char *name, int mode, uint test_if_locked)
{
- int error;
- char name_buff[FN_REFLEN];
char *name_buffer_ptr= m_name_buffer_ptr;
- handler **file;
+ int error;
uint alloc_len;
+ handler **file;
+ char name_buff[FN_REFLEN];
DBUG_ENTER("ha_partition::open");
ref_length= 0;
@@ -2225,7 +2224,7 @@
m_start_key.length= 0;
m_rec0= table->record[0];
m_rec_length= table->s->reclength;
- alloc_len= m_tot_parts * (m_rec_length + PARTITION_BYTES_IN_POS);
+ alloc_len= m_tot_parts * (m_rec_length + PARTITION_BYTES_IN_POS);
alloc_len+= table->s->max_key_length;
if (!m_ordered_rec_buffer)
{
@@ -2251,6 +2250,12 @@
m_start_key.key= (const byte*)ptr;
}
}
+
+ /* Initialise the bitmap we use to determine what partitions are used */
+ if (bitmap_init(&(m_part_info->used_partitions), NULL, m_tot_parts, TRUE))
+ DBUG_RETURN(1);
+ bitmap_set_all(&(m_part_info->used_partitions));
+
file= m_file;
do
{
@@ -2263,6 +2268,7 @@
name_buffer_ptr+= strlen(name_buffer_ptr) + 1;
set_if_bigger(ref_length, ((*file)->ref_length));
} while (*(++file));
+
/*
Add 2 bytes for partition id in position ref length.
ref_length=max_in_all_partitions(ref_length) + PARTITION_BYTES_IN_POS
@@ -2280,6 +2286,7 @@
if ((error= init_queue(&m_queue, m_tot_parts, (uint) PARTITION_BYTES_IN_POS,
0, key_rec_cmp, (void*)this)))
goto err_handler;
+
/*
Some handlers update statistics as part of the open call. This will in
some cases corrupt the statistics of the partition handler and thus
@@ -2292,6 +2299,7 @@
err_handler:
while (file-- != m_file)
(*file)->close();
+err:
DBUG_RETURN(error);
}
@@ -2316,11 +2324,12 @@
int ha_partition::close(void)
{
- handler **file;
bool first= TRUE;
+ handler **file;
DBUG_ENTER("ha_partition::close");
delete_queue(&m_queue);
+ bitmap_free(&(m_part_info->used_partitions));
file= m_file;
repeat:
@@ -2328,16 +2337,17 @@
{
(*file)->close();
} while (*(++file));
+
if (first && m_added_file && m_added_file[0])
{
file= m_added_file;
first= FALSE;
goto repeat;
}
+
DBUG_RETURN(0);
}
-
/****************************************************************************
MODULE start/end statement
****************************************************************************/
@@ -2380,9 +2390,9 @@
int ha_partition::external_lock(THD *thd, int lock_type)
{
+ bool first= TRUE;
uint error;
handler **file;
- bool first= TRUE;
DBUG_ENTER("ha_partition::external_lock");
file= m_file;
@@ -2391,12 +2401,15 @@
repeat:
do
{
+ DBUG_PRINT("info", ("external_lock(thd, %d) iteration %d",
+ lock_type, (file - m_file)));
if ((error= (*file)->external_lock(thd, lock_type)))
{
- if (lock_type != F_UNLCK)
- goto err_handler;
+ if (F_UNLCK != lock_type)
+ goto err_handler;
}
} while (*(++file));
+
if (first && m_added_file && m_added_file[0])
{
DBUG_ASSERT(lock_type == F_UNLCK);
@@ -2408,7 +2421,9 @@
err_handler:
while (file-- != m_file)
+ {
(*file)->external_lock(thd, F_UNLCK);
+ }
DBUG_RETURN(error);
}
@@ -2465,10 +2480,10 @@
{
handler **file;
DBUG_ENTER("ha_partition::store_lock");
-
file= m_file;
do
{
+ DBUG_PRINT("info", ("store lock %d iteration", (file - m_file)));
to= (*file)->store_lock(thd, to, lock_type);
} while (*(++file));
DBUG_RETURN(to);
@@ -2526,7 +2541,7 @@
uint ha_partition::lock_count() const
{
DBUG_ENTER("ha_partition::lock_count");
-
+ DBUG_PRINT("info", ("m_no_locks %d", m_no_locks));
DBUG_RETURN(m_no_locks);
}
@@ -2845,7 +2860,6 @@
do
{
int tmp;
- /* We want to execute end_bulk_insert() on all handlers */
if ((tmp= (*file)->end_bulk_insert()))
error= tmp;
} while (*(++file));
@@ -2885,50 +2899,64 @@
int ha_partition::rnd_init(bool scan)
{
int error;
+ uint i= 0;
+ uint32 part_id;
handler **file;
DBUG_ENTER("ha_partition::rnd_init");
include_partition_fields_in_used_fields();
+
+ /* Now we see what the index of our first important partition is */
+ DBUG_PRINT("info", ("m_part_info->used_partitions 0x%x",
+ m_part_info->used_partitions.bitmap));
+ part_id= bitmap_get_first_set(&(m_part_info->used_partitions));
+ DBUG_PRINT("info", ("m_part_spec.start_part %d", part_id));
+
+ if (MY_BIT_NONE == part_id)
+ goto err1;
+
+ /*
+ We have a partition and we are scanning with rnd_next
+ so we bump our cache
+ */
+ DBUG_PRINT("info", ("rnd_init on partition %d", part_id));
if (scan)
{
/*
rnd_end() is needed for partitioning to reset internal data if scan
is already in use
*/
-
rnd_end();
- if (partition_scan_set_up(rec_buf(0), FALSE))
+ late_extra_cache(part_id);
+ if ((error= m_file[part_id]->ha_rnd_init(scan)))
+ goto err;
+ }
+ else
+ {
+ for (i= part_id; i < m_tot_parts; i++)
{
- /*
- The set of partitions to scan is empty. We return success and return
- end of file on first rnd_next.
- */
- DBUG_RETURN(0);
+ if (bitmap_is_set(&(m_part_info->used_partitions), i))
+ {
+ if ((error= m_file[i]->ha_rnd_init(scan)))
+ goto err;
+ }
}
- /*
- We will use the partition set in our scan, using the start and stop
- partition and checking each scan before start dependent on bittfields.
- */
- late_extra_cache(m_part_spec.start_part);
- DBUG_PRINT("info", ("rnd_init on partition %d",m_part_spec.start_part));
- error= m_file[m_part_spec.start_part]->ha_rnd_init(1);
- m_scan_value= 1; // Scan active
- if (error)
- m_scan_value= 2; // No scan active
- DBUG_RETURN(error);
}
- file= m_file;
- do
- {
- if ((error= (*file)->ha_rnd_init(0)))
- goto err;
- } while (*(++file));
- m_scan_value= 0;
+ m_scan_value= scan;
+ m_part_spec.start_part= part_id;
+ m_part_spec.end_part= m_tot_parts - 1;
+ DBUG_PRINT("info", ("m_scan_value=%d", m_scan_value));
DBUG_RETURN(0);
err:
- while (file--)
- (*file)->ha_rnd_end();
+ while ((int)--i >= (int)part_id)
+ {
+ if (bitmap_is_set(&(m_part_info->used_partitions), i))
+ m_file[i]->ha_rnd_end();
+ }
+err1:
+ m_scan_value= 2;
+ m_part_spec.start_part= NO_CURRENT_PART_ID;
DBUG_RETURN(error);
}
@@ -2948,12 +2976,11 @@
{
handler **file;
DBUG_ENTER("ha_partition::rnd_end");
-
switch (m_scan_value) {
case 2: // Error
break;
- case 1: // Table scan
- if (m_part_spec.start_part != NO_CURRENT_PART_ID)
+ case 1:
+ if (NO_CURRENT_PART_ID != m_part_spec.start_part) // Table scan
{
late_extra_no_cache(m_part_spec.start_part);
m_file[m_part_spec.start_part]->ha_rnd_end();
@@ -2963,16 +2990,16 @@
file= m_file;
do
{
- (*file)->ha_rnd_end();
+ if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+ (*file)->ha_rnd_end();
} while (*(++file));
break;
}
- m_part_spec.start_part= NO_CURRENT_PART_ID;
m_scan_value= 2;
+ m_part_spec.start_part= NO_CURRENT_PART_ID;
DBUG_RETURN(0);
}
-
/*
read next row during full table scan (scan in random row order)
@@ -2996,14 +3023,12 @@
int ha_partition::rnd_next(byte *buf)
{
- uint part_id= m_part_spec.start_part; // Cache of this variable
- handler *file= m_file[part_id];
+ handler *file;
int result= HA_ERR_END_OF_FILE;
+ uint part_id= m_part_spec.start_part;
DBUG_ENTER("ha_partition::rnd_next");
- DBUG_ASSERT(m_scan_value == 1);
-
- if (part_id > m_part_spec.end_part)
+ if (NO_CURRENT_PART_ID == part_id)
{
/*
The original set of partitions to scan was empty and thus we report
@@ -3011,40 +3036,50 @@
*/
goto end;
}
+
+ DBUG_ASSERT(m_scan_value == 1);
+ file= m_file[part_id];
+
while (TRUE)
{
- if ((result= file->rnd_next(buf)))
- {
- if (result == HA_ERR_RECORD_DELETED)
- continue; // Probably MyISAM
-
- if (result != HA_ERR_END_OF_FILE)
- break; // Return error
-
- /* End current partition */
- late_extra_no_cache(part_id);
- DBUG_PRINT("info", ("rnd_end on partition %d", part_id));
- if ((result= file->ha_rnd_end()))
- break;
- /* Shift to next partition */
- if (++part_id > m_part_spec.end_part)
- {
- result= HA_ERR_END_OF_FILE;
- break;
- }
- file= m_file[part_id];
- DBUG_PRINT("info", ("rnd_init on partition %d", part_id));
- if ((result= file->ha_rnd_init(1)))
- break;
- late_extra_cache(part_id);
- }
- else
+ int result= file->rnd_next(buf);
+ if (!result)
{
- m_part_spec.start_part= part_id;
m_last_part= part_id;
+ m_part_spec.start_part= part_id;
table->status= 0;
DBUG_RETURN(0);
}
+
+ /*
+ if we get here, then the current partition rnd_next returned failure
+ */
+ if (result == HA_ERR_RECORD_DELETED)
+ continue; // Probably MyISAM
+
+ if (result != HA_ERR_END_OF_FILE)
+ break; // Return error
+
+ /* End current partition */
+ late_extra_no_cache(part_id);
+ DBUG_PRINT("info", ("rnd_end on partition %d", part_id));
+ if ((result= file->ha_rnd_end()))
+ break;
+
+ /* Shift to next partition */
+ while (++part_id < m_tot_parts &&
+ !bitmap_is_set(&(m_part_info->used_partitions), part_id))
+ ;
+ if (part_id >= m_tot_parts)
+ {
+ result= HA_ERR_END_OF_FILE;
+ break;
+ }
+ file= m_file[part_id];
+ DBUG_PRINT("info", ("rnd_init on partition %d", part_id));
+ if ((result= file->ha_rnd_init(1)))
+ break;
+ late_extra_cache(part_id);
}
end:
@@ -3091,7 +3126,8 @@
#ifdef SUPPORTING_PARTITION_OVER_DIFFERENT_ENGINES
#ifdef HAVE_purify
- bzero(ref + PARTITION_BYTES_IN_POS + ref_length, max_ref_length-ref_length);
+ bzero(ref + PARTITION_BYTES_IN_POS + ref_length,
+ max_ref_length-ref_length);
#endif /* HAVE_purify */
#endif
DBUG_VOID_RETURN;
@@ -3180,16 +3216,16 @@
m_ordered= sorted;
m_curr_key_info= table->key_info+inx;
include_partition_fields_in_used_fields();
-
file= m_file;
do
{
/* TODO RONM: Change to index_init() when code is stable */
- if ((error= (*file)->ha_index_init(inx, sorted)))
- {
- DBUG_ASSERT(0); // Should never happen
- break;
- }
+ if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+ if ((error= (*file)->ha_index_init(inx, sorted)))
+ {
+ DBUG_ASSERT(0); // Should never happen
+ break;
+ }
} while (*(++file));
DBUG_RETURN(error);
}
@@ -3222,10 +3258,10 @@
do
{
int tmp;
- /* We want to execute index_end() on all handlers */
/* TODO RONM: Change to index_end() when code is stable */
- if ((tmp= (*file)->ha_index_end()))
- error= tmp;
+ if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+ if ((tmp= (*file)->ha_index_end()))
+ error= tmp;
} while (*(++file));
DBUG_RETURN(error);
}
@@ -3647,7 +3683,10 @@
if (idx_read_flag)
get_partition_set(table,buf,active_index,&m_start_key,&m_part_spec);
else
- get_partition_set(table, buf, MAX_KEY, 0, &m_part_spec);
+ {
+ m_part_spec.start_part= 0;
+ m_part_spec.end_part= m_tot_parts - 1;
+ }
if (m_part_spec.start_part > m_part_spec.end_part)
{
/*
@@ -3671,7 +3710,19 @@
{
/*
Set m_ordered_scan_ongoing according how the scan should be done
+ Only exact partitions are discovered atm by get_partition_set.
+ Verify this, also bitmap must have at least one bit set otherwise
+ the result from this table is the empty set.
*/
+ uint start_part= bitmap_get_first_set(&(m_part_info->used_partitions));
+ if (start_part == MY_BIT_NONE)
+ {
+ DBUG_PRINT("info", ("scan with no partition to scan"));
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
+ if (start_part > m_part_spec.start_part)
+ m_part_spec.start_part= start_part;
+ DBUG_ASSERT(m_part_spec.start_part < m_tot_parts);
m_ordered_scan_ongoing= m_ordered;
}
DBUG_ASSERT(m_part_spec.start_part < m_tot_parts &&
@@ -3769,15 +3820,18 @@
for (i= m_part_spec.start_part; i <= m_part_spec.end_part; i++)
{
int error;
- handler *file= m_file[i];
+ handler *file;
+ if (!(bitmap_is_set(&(m_part_info->used_partitions), i)))
+ continue;
+ file= m_file[i];
m_part_spec.start_part= i;
switch (m_index_scan_type) {
case partition_index_read:
DBUG_PRINT("info", ("index_read on partition %d", i));
error= file->index_read(buf, m_start_key.key,
- m_start_key.length,
- m_start_key.flag);
+ m_start_key.length,
+ m_start_key.flag);
break;
case partition_index_first:
DBUG_PRINT("info", ("index_first on partition %d", i));
@@ -3792,7 +3846,7 @@
if (compare_key(end_range) <= 0)
{
m_last_part= i;
- DBUG_RETURN(0);
+ DBUG_RETURN(0);
}
error= HA_ERR_END_OF_FILE;
}
@@ -3843,18 +3897,22 @@
m_top_entry= NO_CURRENT_PART_ID;
queue_remove_all(&m_queue);
+
+ DBUG_PRINT("info", ("m_part_spec.start_part %d", m_part_spec.start_part));
for (i= m_part_spec.start_part; i <= m_part_spec.end_part; i++)
{
- int error;
+ if (!(bitmap_is_set(&(m_part_info->used_partitions), i)))
+ continue;
byte *rec_buf_ptr= rec_buf(i);
+ int error;
handler *file= m_file[i];
switch (m_index_scan_type) {
case partition_index_read:
error= file->index_read(rec_buf_ptr,
- m_start_key.key,
- m_start_key.length,
- m_start_key.flag);
+ m_start_key.key,
+ m_start_key.length,
+ m_start_key.flag);
reverse_order= FALSE;
break;
case partition_index_first:
@@ -4160,14 +4218,17 @@
file_array= m_file;
do
{
- file= *file_array;
- file->info(HA_STATUS_VARIABLE);
- records+= file->records;
- deleted+= file->deleted;
- data_file_length+= file->data_file_length;
- index_file_length+= file->index_file_length;
- if (file->check_time > check_time)
- check_time= file->check_time;
+ if (bitmap_is_set(&(m_part_info->used_partitions), (file_array - m_file)))
+ {
+ file= *file_array;
+ file->info(HA_STATUS_VARIABLE);
+ records+= file->records;
+ deleted+= file->deleted;
+ data_file_length+= file->data_file_length;
+ index_file_length+= file->index_file_length;
+ if (file->check_time > check_time)
+ check_time= file->check_time;
+ }
} while (*(++file_array));
if (records < 2 &&
m_table_flags & HA_NOT_EXACT_COUNT)
@@ -4675,10 +4736,9 @@
int result= 0, tmp;
handler **file;
DBUG_ENTER("ha_partition::reset");
-
- file= m_file;
if (m_part_info)
- bitmap_clear_all(&m_part_info->used_partitions);
+ bitmap_set_all(&m_part_info->used_partitions);
+ file= m_file;
do
{
if ((tmp= (*file)->reset()))
@@ -4687,7 +4747,6 @@
DBUG_RETURN(result);
}
-
/*
Special extra method for HA_EXTRA_CACHE with cachesize as extra parameter
@@ -4730,8 +4789,7 @@
m_extra_cache_size= cachesize;
if (m_part_spec.start_part != NO_CURRENT_PART_ID)
{
- DBUG_ASSERT(m_part_spec.start_part == 0);
- late_extra_cache(0);
+ late_extra_cache(m_part_spec.start_part);
}
DBUG_VOID_RETURN;
}
@@ -4754,7 +4812,10 @@
int result= 0, tmp;
handler **file;
DBUG_ENTER("ha_partition::loop_extra()");
-
+ /*
+ TODO, 5.2: this is where you could possibly add optimisations to add the bitmap
+ _if_ a SELECT.
+ */
for (file= m_file; *file; file++)
{
if ((tmp= (*file)->extra(operation)))
@@ -4854,7 +4915,8 @@
DBUG_ENTER("ha_partition::scan_time");
for (file= m_file; *file; file++)
- scan_time+= (*file)->scan_time();
+ if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+ scan_time+= (*file)->scan_time();
DBUG_RETURN(scan_time);
}
@@ -4912,14 +4974,20 @@
ha_rows ha_partition::records_in_range(uint inx, key_range *min_key,
key_range *max_key)
{
- ha_rows in_range= 0;
handler **file;
+ ha_rows in_range= 0;
DBUG_ENTER("ha_partition::records_in_range");
file= m_file;
do
{
- in_range+= (*file)->records_in_range(inx, min_key, max_key);
+ if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+ {
+ ha_rows tmp_in_range= (*file)->records_in_range(inx, min_key, max_key);
+ if (tmp_in_range == HA_POS_ERROR)
+ DBUG_RETURN(tmp_in_range);
+ in_range+= tmp_in_range;
+ }
} while (*(++file));
DBUG_RETURN(in_range);
}
@@ -4944,10 +5012,13 @@
file= m_file;
do
{
- rows= (*file)->estimate_rows_upper_bound();
- if (rows == HA_POS_ERROR)
- DBUG_RETURN(HA_POS_ERROR);
- tot_rows+= rows;
+ if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+ {
+ rows= (*file)->estimate_rows_upper_bound();
+ if (rows == HA_POS_ERROR)
+ DBUG_RETURN(HA_POS_ERROR);
+ tot_rows+= rows;
+ }
} while (*(++file));
DBUG_RETURN(tot_rows);
}
| Thread |
|---|
| • bk commit into 5.1 tree (stewart:1.2118) | Stewart Smith | 1 Feb |