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@stripped, 2006-10-26 21:29:27+10:00, stewart@willster.(none) +4 -0
Merge willster.(none):/home/stewart/Documents/MySQL/5.1/ndb
into willster.(none):/home/stewart/Documents/MySQL/5.1/bug20839
MERGE: 1.2303.1.27
client/mysqldump.c@stripped, 2006-10-26 21:29:17+10:00, stewart@willster.(none) +0 -0
Auto merged
MERGE: 1.252.1.1
include/my_sys.h@stripped, 2006-10-26 21:29:18+10:00, stewart@willster.(none) +0 -0
Auto merged
MERGE: 1.206.2.1
sql/ha_ndbcluster.cc@stripped, 2006-10-26 21:29:18+10:00, stewart@willster.(none) +0 -0
Auto merged
MERGE: 1.357.1.10
sql/sql_show.cc@stripped, 2006-10-26 21:29:18+10:00, stewart@willster.(none) +0 -0
Auto merged
MERGE: 1.360.1.4
# 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/bug20839/RESYNC
--- 1.256/client/mysqldump.c 2006-10-26 21:29:36 +10:00
+++ 1.257/client/mysqldump.c 2006-10-26 21:29:36 +10:00
@@ -679,13 +679,13 @@
tty_password=1;
break;
case 'r':
- if (!(md_result_file = my_fopen(argument, O_WRONLY | FILE_BINARY,
+ if (!(md_result_file= my_fopen(argument, O_WRONLY | FILE_BINARY,
MYF(MY_WME))))
exit(1);
break;
case 'W':
#ifdef __WIN__
- opt_protocol = MYSQL_PROTOCOL_PIPE;
+ opt_protocol= MYSQL_PROTOCOL_PIPE;
#endif
break;
case 'N':
@@ -700,7 +700,7 @@
#include <sslopt-case.h>
case 'V': print_version(); exit(0);
case 'X':
- opt_xml = 1;
+ opt_xml= 1;
extended_insert= opt_drop= opt_lock=
opt_disable_keys= opt_autocommit= opt_create_db= 0;
break;
@@ -1590,7 +1590,7 @@
const char *insert_option;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];
- FILE *sql_file = md_result_file;
+ FILE *sql_file= md_result_file;
int len;
MYSQL_RES *result;
MYSQL_ROW row;
@@ -1634,7 +1634,7 @@
opt_quoted_table= quote_name(table, table_buff2, 0);
if (opt_order_by_primary)
- order_by = primary_key_fields(result_table);
+ order_by= primary_key_fields(result_table);
if (!opt_xml && !mysql_query_with_error_report(mysql, 0, query_buff))
{
@@ -1686,7 +1686,7 @@
field= mysql_fetch_field_direct(result, 0);
if (strcmp(field->name, "View") == 0)
{
- char *scv_buff = NULL;
+ char *scv_buff= NULL;
verbose_msg("-- It's a view, create dummy table for view\n");
@@ -1723,7 +1723,7 @@
my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
safe_exit(EX_MYSQLERR);
- DBUG_RETURN(0);
+ DBUG_RETURN(0);
}
else
my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
@@ -2093,7 +2093,7 @@
char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
char query_buff[QUERY_LENGTH];
uint old_opt_compatible_mode=opt_compatible_mode;
- FILE *sql_file = md_result_file;
+ FILE *sql_file= md_result_file;
MYSQL_RES *result;
MYSQL_ROW row;
@@ -2337,15 +2337,15 @@
end= strmov(end,buff);
if (where || order_by)
{
- query = alloc_query_str((ulong) ((end - query) + 1 +
+ query= alloc_query_str((ulong) ((end - query) + 1 +
(where ? strlen(where) + 7 : 0) +
(order_by ? strlen(order_by) + 10 : 0)));
- end = strmov(query, query_buf);
+ end= strmov(query, query_buf);
if (where)
- end = strxmov(end, " WHERE ", where, NullS);
+ end= strxmov(end, " WHERE ", where, NullS);
if (order_by)
- end = strxmov(end, " ORDER BY ", order_by, NullS);
+ end= strxmov(end, " ORDER BY ", order_by, NullS);
}
if (mysql_real_query(mysql, query, (uint) (end - query)))
{
@@ -2366,10 +2366,10 @@
result_table);
if (where || order_by)
{
- query = alloc_query_str((ulong) (strlen(query) + 1 +
+ query= alloc_query_str((ulong) (strlen(query) + 1 +
(where ? strlen(where) + 7 : 0) +
(order_by ? strlen(order_by) + 10 : 0)));
- end = strmov(query, query_buf);
+ end= strmov(query, query_buf);
if (where)
{
@@ -2378,7 +2378,7 @@
fprintf(md_result_file, "-- WHERE: %s\n", where);
check_io(md_result_file);
}
- end = strxmov(end, " WHERE ", where, NullS);
+ end= strxmov(end, " WHERE ", where, NullS);
}
if (order_by)
{
@@ -2387,7 +2387,7 @@
fprintf(md_result_file, "-- ORDER BY: %s\n", order_by);
check_io(md_result_file);
}
- end = strxmov(end, " ORDER BY ", order_by, NullS);
+ end= strxmov(end, " ORDER BY ", order_by, NullS);
}
}
if (!opt_xml && !opt_compact)
@@ -2463,12 +2463,12 @@
check_io(md_result_file);
}
- for (i = 0; i < mysql_num_fields(res); i++)
+ for (i= 0; i < mysql_num_fields(res); i++)
{
int is_blob;
ulong length= lengths[i];
- if (!(field = mysql_fetch_field(res)))
+ if (!(field= mysql_fetch_field(res)))
{
my_snprintf(query, QUERY_LENGTH,
"%s: Not enough fields from table %s! Aborting.\n",
@@ -2540,7 +2540,7 @@
else
{
/* change any strings ("inf", "-inf", "nan") into NULL */
- char *ptr = row[i];
+ char *ptr= row[i];
if (my_isalpha(charset_info, *ptr) || (*ptr == '-' &&
my_isalpha(charset_info, ptr[1])))
dynstr_append(&extended_row, "NULL");
@@ -2600,7 +2600,7 @@
else
{
/* change any strings ("inf", "-inf", "nan") into NULL */
- char *ptr = row[i];
+ char *ptr= row[i];
if (opt_xml)
{
print_xml_tag1(md_result_file, "\t\t", "field name=",
@@ -2646,10 +2646,10 @@
{
ulong row_length;
dynstr_append(&extended_row,")");
- row_length = 2 + extended_row.length;
+ row_length= 2 + extended_row.length;
if (total_length + row_length < opt_net_buffer_length)
{
- total_length += row_length;
+ total_length+= row_length;
fputc(',',md_result_file); /* Always row break */
fputs(extended_row.str,md_result_file);
}
@@ -2661,7 +2661,7 @@
fputs(insert_pat.str,md_result_file);
fputs(extended_row.str,md_result_file);
- total_length = row_length+init_length;
+ total_length= row_length+init_length;
}
check_io(md_result_file);
}
@@ -2726,15 +2726,15 @@
static char *getTableName(int reset)
{
- static MYSQL_RES *res = NULL;
+ static MYSQL_RES *res= NULL;
MYSQL_ROW row;
if (!res)
{
- if (!(res = mysql_list_tables(mysql,NullS)))
+ if (!(res= mysql_list_tables(mysql,NullS)))
return(NULL);
}
- if ((row = mysql_fetch_row(res)))
+ if ((row= mysql_fetch_row(res)))
return((char*) row[0]);
if (reset)
@@ -2742,7 +2742,7 @@
else
{
mysql_free_result(res);
- res = NULL;
+ res= NULL;
}
return(NULL);
} /* getTableName */
@@ -3006,7 +3006,7 @@
if (mysql_query_with_error_report(mysql, &tableres, "SHOW DATABASES"))
return 1;
- while ((row = mysql_fetch_row(tableres)))
+ while ((row= mysql_fetch_row(tableres)))
{
if (dump_all_tables_in_db(row[0]))
result=1;
@@ -3014,13 +3014,13 @@
if (seen_views)
{
if (mysql_query(mysql, "SHOW DATABASES") ||
- !(tableres = mysql_store_result(mysql)))
+ !(tableres= mysql_store_result(mysql)))
{
my_printf_error(0, "Error: Couldn't execute 'SHOW DATABASES': %s",
MYF(0), mysql_error(mysql));
return 1;
}
- while ((row = mysql_fetch_row(tableres)))
+ while ((row= mysql_fetch_row(tableres)))
{
if (dump_all_views_in_db(row[0]))
result=1;
@@ -3466,7 +3466,7 @@
}
else
{
- row = mysql_fetch_row(master);
+ row= mysql_fetch_row(master);
if (row && row[0] && row[1])
{
/* SHOW MASTER STATUS reports file and position */
@@ -3593,7 +3593,7 @@
MYSQL_FIELD *field;
mysql_field_seek(result, 0);
- for ( ; (field = mysql_fetch_field(result)) ; row++)
+ for ( ; (field= mysql_fetch_field(result)) ; row++)
{
if (!strcmp(field->name,name))
{
@@ -3721,17 +3721,19 @@
static char *primary_key_fields(const char *table_name)
{
- MYSQL_RES *res = NULL;
+ MYSQL_RES *res= NULL;
MYSQL_ROW row;
/* SHOW KEYS FROM + table name * 2 (escaped) + 2 quotes + \0 */
char show_keys_buff[15 + NAME_LEN * 2 + 3];
- uint result_length = 0;
- char *result = 0;
+ uint result_length= 0;
+ char *result= 0;
+ char buff[NAME_LEN * 2 + 3];
+ char *quoted_field;
my_snprintf(show_keys_buff, sizeof(show_keys_buff),
"SHOW KEYS FROM %s", table_name);
if (mysql_query(mysql, show_keys_buff) ||
- !(res = mysql_store_result(mysql)))
+ !(res= mysql_store_result(mysql)))
{
fprintf(stderr, "Warning: Couldn't read keys from table %s;"
" records are NOT sorted (%s)\n",
@@ -3746,12 +3748,14 @@
* row, and UNIQUE keys come before others. So we only need to check
* the first key, not all keys.
*/
- if ((row = mysql_fetch_row(res)) && atoi(row[1]) == 0)
+ if ((row= mysql_fetch_row(res)) && atoi(row[1]) == 0)
{
/* Key is unique */
do
- result_length += strlen(row[4]) + 1; /* + 1 for ',' or \0 */
- while ((row = mysql_fetch_row(res)) && atoi(row[3]) > 1);
+ {
+ quoted_field= quote_name(row[4], buff, 0);
+ result_length+= strlen(quoted_field) + 1; /* + 1 for ',' or \0 */
+ } while ((row= mysql_fetch_row(res)) && atoi(row[3]) > 1);
}
/* Build the ORDER BY clause result */
@@ -3759,17 +3763,21 @@
{
char *end;
/* result (terminating \0 is already in result_length) */
- result = my_malloc(result_length + 10, MYF(MY_WME));
+ result= my_malloc(result_length + 10, MYF(MY_WME));
if (!result)
{
fprintf(stderr, "Error: Not enough memory to store ORDER BY clause\n");
goto cleanup;
}
mysql_data_seek(res, 0);
- row = mysql_fetch_row(res);
- end = strmov(result, row[4]);
- while ((row = mysql_fetch_row(res)) && atoi(row[3]) > 1)
- end = strxmov(end, ",", row[4], NullS);
+ row= mysql_fetch_row(res);
+ quoted_field= quote_name(row[4], buff, 0);
+ end= strmov(result, quoted_field);
+ while ((row= mysql_fetch_row(res)) && atoi(row[3]) > 1)
+ {
+ quoted_field= quote_name(row[4], buff, 0);
+ end= strxmov(end, ",", quoted_field, NullS);
+ }
}
cleanup:
@@ -3837,7 +3845,7 @@
char table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3];
char query[QUERY_LENGTH];
- FILE *sql_file = md_result_file;
+ FILE *sql_file= md_result_file;
DBUG_ENTER("get_view_structure");
if (opt_no_create_info) /* Don't write table creation info */
--- 1.208/include/my_sys.h 2006-10-26 21:29:36 +10:00
+++ 1.209/include/my_sys.h 2006-10-26 21:29:36 +10:00
@@ -779,6 +779,7 @@
uint length);
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
+extern my_bool dynstr_trunc(DYNAMIC_STRING *str, int n);
extern void dynstr_free(DYNAMIC_STRING *str);
#ifdef HAVE_MLOCK
extern byte *my_malloc_lock(uint length,myf flags);
--- 1.368/sql/sql_show.cc 2006-10-26 21:29:36 +10:00
+++ 1.369/sql/sql_show.cc 2006-10-26 21:29:36 +10:00
@@ -3914,10 +3914,12 @@
}
-static void store_schema_partitions_record(THD *thd, TABLE *table,
+static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
+ TABLE *showing_table,
partition_element *part_elem,
handler *file, uint part_id)
{
+ TABLE* table= schema_table;
CHARSET_INFO *cs= system_charset_info;
PARTITION_INFO stat_info;
TIME time;
@@ -3968,11 +3970,20 @@
table->field[23]->store((longlong) part_elem->nodegroup_id, TRUE);
else
table->field[23]->store(STRING_WITH_LEN("default"), cs);
+
+ table->field[24]->set_notnull();
if (part_elem->tablespace_name)
table->field[24]->store(part_elem->tablespace_name,
strlen(part_elem->tablespace_name), cs);
else
- table->field[24]->store(STRING_WITH_LEN("default"), cs);
+ {
+ char *ts= showing_table->file->get_tablespace_name(thd);
+ if(ts)
+ table->field[24]->store(ts, strlen(ts), cs);
+ else
+ table->field[24]->set_null();
+ my_free(ts, MYF(0));
+ }
}
return;
}
@@ -4155,7 +4166,7 @@
table->field[6]->store((longlong) ++subpart_pos, TRUE);
table->field[6]->set_notnull();
- store_schema_partitions_record(thd, table, subpart_elem,
+ store_schema_partitions_record(thd, table, show_table, subpart_elem,
file, part_id);
part_id++;
if(schema_table_store_record(thd, table))
@@ -4164,7 +4175,7 @@
}
else
{
- store_schema_partitions_record(thd, table, part_elem,
+ store_schema_partitions_record(thd, table, show_table, part_elem,
file, part_id);
part_id++;
if(schema_table_store_record(thd, table))
@@ -4176,7 +4187,7 @@
else
#endif
{
- store_schema_partitions_record(thd, table, 0, file, 0);
+ store_schema_partitions_record(thd, table, show_table, 0, file, 0);
if(schema_table_store_record(thd, table))
DBUG_RETURN(1);
}
@@ -5541,7 +5552,7 @@
{"CHECKSUM", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
{"PARTITION_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, 0},
{"NODEGROUP", 12 , MYSQL_TYPE_STRING, 0, 0, 0},
- {"TABLESPACE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
+ {"TABLESPACE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
--- 1.358/sql/ha_ndbcluster.cc 2006-10-26 21:29:36 +10:00
+++ 1.359/sql/ha_ndbcluster.cc 2006-10-26 21:29:36 +10:00
@@ -74,18 +74,26 @@
static uint ndbcluster_partition_flags();
static uint ndbcluster_alter_table_flags(uint flags);
-static int ndbcluster_init(void);
-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);
+static int ndbcluster_init(void *);
+static int ndbcluster_end(handlerton *hton, ha_panic_function flag);
+static bool ndbcluster_show_status(handlerton *hton, THD*,
+ stat_print_fn *,
+ enum ha_stat_type);
+static int ndbcluster_alter_tablespace(handlerton *hton,
+ THD* thd,
+ st_alter_tablespace *info);
+static int ndbcluster_fill_files_table(handlerton *hton,
+ THD *thd,
+ TABLE_LIST *tables,
+ COND *cond);
-handlerton ndbcluster_hton;
+handlerton *ndbcluster_hton;
-static handler *ndbcluster_create_handler(TABLE_SHARE *table,
+static handler *ndbcluster_create_handler(handlerton *hton,
+ TABLE_SHARE *table,
MEM_ROOT *mem_root)
{
- return new (mem_root) ha_ndbcluster(table);
+ return new (mem_root) ha_ndbcluster(hton, table);
}
static uint ndbcluster_partition_flags()
@@ -144,8 +152,7 @@
static int rename_share(NDB_SHARE *share, const char *new_key);
#endif
static void ndb_set_fragmentation(NDBTAB &tab, TABLE *table, uint pk_len);
-
-static int ndb_get_table_statistics(Ndb*, const NDBTAB *,
+static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*, const NDBTAB *,
struct Ndb_statistics *);
@@ -442,16 +449,13 @@
Ndb *ndb= get_ndb();
ndb->setDatabaseName(m_dbname);
struct Ndb_statistics stat;
- if (ndb_get_table_statistics(ndb, m_table, &stat) == 0)
+ if (ndb_get_table_statistics(this, true, ndb, m_table, &stat) == 0)
{
retval= stat.row_count;
}
else
{
- /**
- * Be consistent with BUG#19914 until we fix it properly
- */
- DBUG_RETURN(-1);
+ DBUG_RETURN(HA_POS_ERROR);
}
THD *thd= current_thd;
@@ -461,11 +465,13 @@
DBUG_RETURN(retval + info->no_uncommitted_rows_count);
}
-void ha_ndbcluster::records_update()
+int ha_ndbcluster::records_update()
{
if (m_ha_not_exact_count)
- return;
+ return 0;
DBUG_ENTER("ha_ndbcluster::records_update");
+ int result= 0;
+
struct Ndb_local_table_statistics *info= m_table_info;
DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d",
((const NDBTAB *)m_table)->getTableId(),
@@ -475,7 +481,8 @@
Ndb *ndb= get_ndb();
struct Ndb_statistics stat;
ndb->setDatabaseName(m_dbname);
- if (ndb_get_table_statistics(ndb, m_table, &stat) == 0)
+ result= ndb_get_table_statistics(this, true, ndb, m_table, &stat);
+ if (result == 0)
{
stats.mean_rec_length= stat.row_size;
stats.data_file_length= stat.fragment_memory;
@@ -487,8 +494,9 @@
if (get_thd_ndb(thd)->error)
info->no_uncommitted_rows_count= 0;
}
- stats.records= info->records+ info->no_uncommitted_rows_count;
- DBUG_VOID_RETURN;
+ if(result==0)
+ stats.records= info->records+ info->no_uncommitted_rows_count;
+ DBUG_RETURN(result);
}
void ha_ndbcluster::no_uncommitted_rows_execute_failure()
@@ -553,7 +561,14 @@
if (res == HA_ERR_FOUND_DUPP_KEY)
{
if (m_rows_to_insert == 1)
- m_dupkey= table_share->primary_key;
+ {
+ /*
+ We can only distinguish between primary and non-primary
+ violations here, so we need to return MAX_KEY for non-primary
+ to signal that key is unknown
+ */
+ m_dupkey= err.code == 630 ? table_share->primary_key : MAX_KEY;
+ }
else
{
/* We are batching inserts, offending key is not available */
@@ -1382,9 +1397,8 @@
ORDERED_INDEX);
}
-int ha_ndbcluster::check_index_fields_not_null(uint inx)
+int ha_ndbcluster::check_index_fields_not_null(KEY* key_info)
{
- KEY* key_info= table->key_info + inx;
KEY_PART_INFO* key_part= key_info->key_part;
KEY_PART_INFO* end= key_part+key_info->key_parts;
DBUG_ENTER("ha_ndbcluster::check_index_fields_not_null");
@@ -1875,7 +1889,8 @@
int res;
DBUG_ENTER("peek_indexed_rows");
- NdbOperation::LockMode lm= NdbOperation::LM_Read;
+ NdbOperation::LockMode lm=
+ (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type);
first= NULL;
if (table->s->primary_key != MAX_KEY)
{
@@ -1899,7 +1914,10 @@
error= m_part_info->get_partition_id(m_part_info, &part_id, &func_value);
dbug_tmp_restore_column_map(table->read_set, old_map);
if (error)
+ {
+ m_part_info->err_value= func_value;
DBUG_RETURN(error);
+ }
op->setPartitionId(part_id);
}
}
@@ -2508,9 +2526,11 @@
if (has_auto_increment)
{
THD *thd= table->in_use;
+ int error;
m_skip_auto_increment= FALSE;
- update_auto_increment();
+ if ((error= update_auto_increment()))
+ DBUG_RETURN(error);
m_skip_auto_increment= (insert_id_for_cur_row == 0);
}
}
@@ -2554,7 +2574,10 @@
error= m_part_info->get_partition_id(m_part_info, &part_id, &func_value);
dbug_tmp_restore_column_map(table->read_set, old_map);
if (error)
+ {
+ m_part_info->err_value= func_value;
DBUG_RETURN(error);
+ }
op->setPartitionId(part_id);
}
@@ -2746,6 +2769,7 @@
m_part_info, &old_part_id, &new_part_id,
&func_value)))
{
+ m_part_info->err_value= func_value;
DBUG_RETURN(error);
}
@@ -3625,8 +3649,9 @@
}
-void ha_ndbcluster::info(uint flag)
+int ha_ndbcluster::info(uint flag)
{
+ int result= 0;
DBUG_ENTER("info");
DBUG_PRINT("enter", ("flag: %d", flag));
@@ -3644,18 +3669,19 @@
if (m_ha_not_exact_count)
stats.records= 100;
else
- records_update();
+ result= records_update();
}
else
{
if ((my_errno= check_ndb_connection()))
- DBUG_VOID_RETURN;
+ DBUG_RETURN(my_errno);
Ndb *ndb= get_ndb();
ndb->setDatabaseName(m_dbname);
struct Ndb_statistics stat;
ndb->setDatabaseName(m_dbname);
if (current_thd->variables.ndb_use_exact_count &&
- ndb_get_table_statistics(ndb, m_table, &stat) == 0)
+ (result= ndb_get_table_statistics(this, true, ndb, m_table, &stat))
+ == 0)
{
stats.mean_rec_length= stat.row_size;
stats.data_file_length= stat.fragment_memory;
@@ -3699,7 +3725,11 @@
stats.auto_increment_value= (ulonglong)auto_increment_value64;
}
}
- DBUG_VOID_RETURN;
+
+ if(result == -1)
+ result= HA_ERR_NO_CONNECTION;
+
+ DBUG_RETURN(result);
}
@@ -4034,7 +4064,7 @@
thd_ndb->init_open_tables();
thd_ndb->stmt= trans;
thd_ndb->query_state&= NDB_QUERY_NORMAL;
- trans_register_ha(thd, FALSE, &ndbcluster_hton);
+ trans_register_ha(thd, FALSE, ndbcluster_hton);
}
else
{
@@ -4050,7 +4080,7 @@
thd_ndb->init_open_tables();
thd_ndb->all= trans;
thd_ndb->query_state&= NDB_QUERY_NORMAL;
- trans_register_ha(thd, TRUE, &ndbcluster_hton);
+ trans_register_ha(thd, TRUE, ndbcluster_hton);
/*
If this is the start of a LOCK TABLE, a table look
@@ -4204,7 +4234,7 @@
ERR_RETURN(ndb->getNdbError());
no_uncommitted_rows_reset(thd);
thd_ndb->stmt= trans;
- trans_register_ha(thd, FALSE, &ndbcluster_hton);
+ trans_register_ha(thd, FALSE, ndbcluster_hton);
}
thd_ndb->query_state&= NDB_QUERY_NORMAL;
m_active_trans= trans;
@@ -4221,7 +4251,7 @@
Commit a transaction started in NDB
*/
-static int ndbcluster_commit(THD *thd, bool all)
+static int ndbcluster_commit(handlerton *hton, THD *thd, bool all)
{
int res= 0;
Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -4272,7 +4302,7 @@
Rollback a transaction started in NDB
*/
-static int ndbcluster_rollback(THD *thd, bool all)
+static int ndbcluster_rollback(handlerton *hton, THD *thd, bool all)
{
int res= 0;
Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -4985,7 +5015,7 @@
error= create_unique_index(unique_name, key_info);
break;
case UNIQUE_INDEX:
- if (!(error= check_index_fields_not_null(idx_no)))
+ if (!(error= check_index_fields_not_null(key_info)))
error= create_unique_index(unique_name, key_info);
break;
case ORDERED_INDEX:
@@ -5572,8 +5602,8 @@
HA_HAS_OWN_BINLOGGING | \
HA_HAS_RECORDS
-ha_ndbcluster::ha_ndbcluster(TABLE_SHARE *table_arg):
- handler(&ndbcluster_hton, table_arg),
+ha_ndbcluster::ha_ndbcluster(handlerton *hton, TABLE_SHARE *table_arg):
+ handler(hton, table_arg),
m_active_trans(NULL),
m_active_cursor(NULL),
m_table(NULL),
@@ -5723,7 +5753,17 @@
res= get_metadata(name);
if (!res)
- info(HA_STATUS_VARIABLE | HA_STATUS_CONST);
+ {
+ Ndb *ndb= get_ndb();
+ ndb->setDatabaseName(m_dbname);
+ struct Ndb_statistics stat;
+ res= ndb_get_table_statistics(NULL, false, ndb, m_table, &stat);
+ stats.mean_rec_length= stat.row_size;
+ stats.data_file_length= stat.fragment_memory;
+ stats.records= stat.row_count;
+ if(!res)
+ res= info(HA_STATUS_CONST);
+ }
#ifdef HAVE_NDB_BINLOG
if (!ndb_binlog_tables_inited && ndb_binlog_running)
@@ -5836,7 +5876,7 @@
}
-static int ndbcluster_close_connection(THD *thd)
+static int ndbcluster_close_connection(handlerton *hton, THD *thd)
{
Thd_ndb *thd_ndb= get_thd_ndb(thd);
DBUG_ENTER("ndbcluster_close_connection");
@@ -5853,8 +5893,10 @@
Try to discover one table from NDB
*/
-int ndbcluster_discover(THD* thd, const char *db, const char *name,
- const void** frmblob, uint* frmlen)
+int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,
+ const char *name,
+ const void** frmblob,
+ uint* frmlen)
{
int error= 0;
NdbError ndb_error;
@@ -5934,7 +5976,8 @@
*/
-int ndbcluster_table_exists_in_engine(THD* thd, const char *db,
+int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd,
+ const char *db,
const char *name)
{
Ndb* ndb;
@@ -6034,7 +6077,7 @@
DBUG_RETURN(ret);
}
-static void ndbcluster_drop_database(char *path)
+static void ndbcluster_drop_database(handlerton *hton, char *path)
{
THD *thd= current_thd;
DBUG_ENTER("ndbcluster_drop_database");
@@ -6195,7 +6238,9 @@
DBUG_RETURN(-(skipped + unhandled));
}
-int ndbcluster_find_files(THD *thd,const char *db,const char *path,
+int ndbcluster_find_files(handlerton *hton, THD *thd,
+ const char *db,
+ const char *path,
const char *wild, bool dir, List<char> *files)
{
DBUG_ENTER("ndbcluster_find_files");
@@ -6305,7 +6350,7 @@
DBUG_PRINT("info", ("%s existed on disk", name));
// The .ndb file exists on disk, but it's not in list of tables in ndb
// Verify that handler agrees table is gone.
- if (ndbcluster_table_exists_in_engine(thd, db, file_name) == 0)
+ if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name) == 0)
{
DBUG_PRINT("info", ("NDB says %s does not exists", file_name));
it.remove();
@@ -6416,35 +6461,36 @@
extern int ndb_dictionary_is_mysqld;
-static int ndbcluster_init()
+static int ndbcluster_init(void *p)
{
int res;
DBUG_ENTER("ndbcluster_init");
ndb_dictionary_is_mysqld= 1;
+ ndbcluster_hton= (handlerton *)p;
{
- handlerton &h= ndbcluster_hton;
- h.state= have_ndbcluster;
- h.db_type= DB_TYPE_NDBCLUSTER;
- h.close_connection= ndbcluster_close_connection;
- h.commit= ndbcluster_commit;
- h.rollback= ndbcluster_rollback;
- h.create= ndbcluster_create_handler; /* Create a new handler */
- h.drop_database= ndbcluster_drop_database; /* Drop a database */
- h.panic= ndbcluster_end; /* Panic call */
- h.show_status= ndbcluster_show_status; /* Show status */
- 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;
+ handlerton *h= ndbcluster_hton;
+ h->state= have_ndbcluster;
+ h->db_type= DB_TYPE_NDBCLUSTER;
+ h->close_connection= ndbcluster_close_connection;
+ h->commit= ndbcluster_commit;
+ h->rollback= ndbcluster_rollback;
+ h->create= ndbcluster_create_handler; /* Create a new handler */
+ h->drop_database= ndbcluster_drop_database; /* Drop a database */
+ h->panic= ndbcluster_end; /* Panic call */
+ h->show_status= ndbcluster_show_status; /* Show status */
+ 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
- h.flags= HTON_CAN_RECREATE | HTON_TEMPORARY_NOT_SUPPORTED;
- h.discover= ndbcluster_discover;
- h.find_files= ndbcluster_find_files;
- h.table_exists_in_engine= ndbcluster_table_exists_in_engine;
+ h->flags= HTON_CAN_RECREATE | HTON_TEMPORARY_NOT_SUPPORTED;
+ h->discover= ndbcluster_discover;
+ h->find_files= ndbcluster_find_files;
+ h->table_exists_in_engine= ndbcluster_table_exists_in_engine;
}
if (have_ndbcluster != SHOW_OPTION_YES)
@@ -6553,10 +6599,12 @@
delete g_ndb_cluster_connection;
g_ndb_cluster_connection= NULL;
have_ndbcluster= SHOW_OPTION_DISABLED; // If we couldn't use handler
+ ndbcluster_hton->state= SHOW_OPTION_DISABLED; // If we couldn't use handler
+
DBUG_RETURN(TRUE);
}
-static int ndbcluster_end(ha_panic_function type)
+static int ndbcluster_end(handlerton *hton, ha_panic_function type)
{
DBUG_ENTER("ndbcluster_end");
@@ -6640,7 +6688,7 @@
share.db.length= 0;
share.table_name.str= (char *) tab_name;
share.table_name.length= strlen(tab_name);
- ha_ndbcluster error_handler(&share);
+ ha_ndbcluster error_handler(ndbcluster_hton, &share);
error_handler.print_error(error, MYF(0));
DBUG_VOID_RETURN;
}
@@ -6780,7 +6828,7 @@
else
{
Ndb_statistics stat;
- if ((res=ndb_get_table_statistics(ndb, m_table, &stat)) != 0)
+ if ((res=ndb_get_table_statistics(this, true, ndb, m_table, &stat)) != 0)
break;
table_rows=stat.row_count;
DBUG_PRINT("info", ("use db row_count: %llu", table_rows));
@@ -6941,7 +6989,7 @@
{
Ndb_table_guard ndbtab_g(ndb->getDictionary(), tabname);
if (ndbtab_g.get_table() == 0
- || ndb_get_table_statistics(ndb, ndbtab_g.get_table(), &stat))
+ || ndb_get_table_statistics(NULL, false, ndb, ndbtab_g.get_table(), &stat))
{
free_share(&share);
DBUG_RETURN(1);
@@ -7507,12 +7555,13 @@
static
int
-ndb_get_table_statistics(Ndb* ndb, const NDBTAB *ndbtab,
+ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, const NDBTAB *ndbtab,
struct Ndb_statistics * ndbstat)
{
NdbTransaction* pTrans;
NdbError error;
int retries= 10;
+ int reterr= 0;
int retry_sleep= 30 * 1000; /* 30 milliseconds */
char buff[22], buff2[22], buff3[22], buff4[22];
DBUG_ENTER("ndb_get_table_statistics");
@@ -7608,6 +7657,22 @@
DBUG_RETURN(0);
retry:
+ if(report_error)
+ {
+ if (file)
+ {
+ reterr= file->ndb_err(pTrans);
+ }
+ else
+ {
+ const NdbError& tmp= error;
+ ERR_PRINT(tmp);
+ reterr= ndb_to_mysql_error(&tmp);
+ }
+ }
+ else
+ reterr= error.code;
+
if (pTrans)
{
ndb->closeTransaction(pTrans);
@@ -7620,8 +7685,9 @@
}
break;
} while(1);
- DBUG_PRINT("exit", ("failed, error %u(%s)", error.code, error.message));
- ERR_RETURN(error);
+ DBUG_PRINT("exit", ("failed, reterr: %u, NdbError %u(%s)", reterr,
+ error.code, error.message));
+ DBUG_RETURN(reterr);
}
/*
@@ -8157,7 +8223,7 @@
Wait for cluster to start
*/
pthread_mutex_lock(&LOCK_ndb_util_thread);
- while (!ndb_cluster_node_id && (ndbcluster_hton.slot != ~(uint)0))
+ while (!ndb_cluster_node_id && (ndbcluster_hton->slot != ~(uint)0))
{
/* ndb not connected yet */
set_timespec(abstime, 1);
@@ -8279,7 +8345,7 @@
{
Ndb_table_guard ndbtab_g(ndb->getDictionary(), share->table_name);
if (ndbtab_g.get_table() &&
- ndb_get_table_statistics(ndb, ndbtab_g.get_table(), &stat) == 0)
+ ndb_get_table_statistics(NULL, false, ndb, ndbtab_g.get_table(), &stat) == 0)
{
char buff[22], buff2[22];
DBUG_PRINT("ndb_util_thread",
@@ -9720,7 +9786,7 @@
Implements the SHOW NDB STATUS command.
*/
bool
-ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
+ndbcluster_show_status(handlerton *hton, THD* thd, stat_print_fn *stat_print,
enum ha_stat_type stat_type)
{
char buf[IO_SIZE];
@@ -10112,6 +10178,8 @@
DBUG_RETURN(COMPATIBLE_DATA_NO);
}
+ int pk= 0;
+ int ai= 0;
for (i= 0; i < table->s->fields; i++)
{
Field *field= table->field[i];
@@ -10127,10 +10195,33 @@
DBUG_PRINT("info", ("add/drop index not supported for disk stored column"));
DBUG_RETURN(COMPATIBLE_DATA_NO);
}
+
+ if (field->flags & PRI_KEY_FLAG)
+ pk=1;
+ if (field->flags & FIELD_IN_ADD_INDEX)
+ ai=1;
}
if (table_changes != IS_EQUAL_YES)
DBUG_RETURN(COMPATIBLE_DATA_NO);
+ /**
+ * Changing from/to primary key
+ *
+ * This is _not_ correct, but check_if_incompatible_data-interface
+ * doesnt give more info, so I guess that we can't do any
+ * online add index if not using primary key
+ *
+ * This as mysql will handle a unique not null index as primary
+ * even wo/ user specifiying it... :-(
+ *
+ */
+ if ((table_share->primary_key == MAX_KEY && pk) ||
+ (table_share->primary_key != MAX_KEY && !pk) ||
+ (table_share->primary_key == MAX_KEY && !pk && ai))
+ {
+ DBUG_RETURN(COMPATIBLE_DATA_NO);
+ }
+
/* Check that auto_increment value was not changed */
if ((info->used_fields & HA_CREATE_USED_AUTO) &&
info->auto_increment_value != 0)
@@ -10184,7 +10275,7 @@
return false;
}
-int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info)
+int ndbcluster_alter_tablespace(handlerton *hton, THD* thd, st_alter_tablespace *info)
{
DBUG_ENTER("ha_ndbcluster::alter_tablespace");
@@ -10445,7 +10536,9 @@
DBUG_RETURN(TRUE);
}
-static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables,
+static int ndbcluster_fill_files_table(handlerton *hton,
+ THD *thd,
+ TABLE_LIST *tables,
COND *cond)
{
TABLE* table= tables->table;
@@ -10672,7 +10765,7 @@
};
struct st_mysql_storage_engine ndbcluster_storage_engine=
-{ MYSQL_HANDLERTON_INTERFACE_VERSION, &ndbcluster_hton };
+{ MYSQL_HANDLERTON_INTERFACE_VERSION };
mysql_declare_plugin(ndbcluster)
{
@@ -10681,6 +10774,7 @@
ndbcluster_hton_name,
"MySQL AB",
"Clustered, fault-tolerant tables",
+ PLUGIN_LICENSE_GPL,
ndbcluster_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
| Thread |
|---|
| • bk commit into 5.1 tree (stewart:1.2309) | Stewart Smith | 26 Oct |