summaryrefslogtreecommitdiff
path: root/sql/ha_ndbcluster.cc
diff options
context:
space:
mode:
authorunknown <mskold/marty@mysql.com/linux.site>2006-10-18 14:28:18 +0200
committerunknown <mskold/marty@mysql.com/linux.site>2006-10-18 14:28:18 +0200
commit55ae6636bd7005d2dbd485087b52e0082ea3f87e (patch)
tree01b4222f044ce786b0dd514ddb7d75a35890d52e /sql/ha_ndbcluster.cc
parent4416725b34e9f075cf0087b71b037db72e6075ea (diff)
parent63814890d1126e042ddf2cccb88fe07a1331d997 (diff)
downloadmariadb-git-55ae6636bd7005d2dbd485087b52e0082ea3f87e.tar.gz
Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0
into mysql.com:/windows/Linux_space/MySQL/mysql-5.0-ndb sql/ha_ndbcluster.cc: Auto merged
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r--sql/ha_ndbcluster.cc59
1 files changed, 43 insertions, 16 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 5f18d5534e4..9a7a881d8e0 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -551,7 +551,14 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans)
if (res == HA_ERR_FOUND_DUPP_KEY)
{
if (m_rows_to_insert == 1)
- m_dupkey= table->s->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->s->primary_key : MAX_KEY;
+ }
else
{
/* We are batching inserts, offending key is not available */
@@ -5072,16 +5079,15 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
List<char> delete_list;
while ((file_name=it++))
{
+ bool file_on_disk= false;
DBUG_PRINT("info", ("%s", file_name));
if (hash_search(&ndb_tables, file_name, strlen(file_name)))
{
DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name));
- // File existed in NDB and as frm file, put in ok_tables list
- my_hash_insert(&ok_tables, (byte*)file_name);
- continue;
+ file_on_disk= true;
}
- // File is not in NDB, check for .ndb file with this name
+ // Check for .ndb file with this name
(void)strxnmov(name, FN_REFLEN,
mysql_data_home,"/",db,"/",file_name,ha_ndb_ext,NullS);
DBUG_PRINT("info", ("Check access for %s", name));
@@ -5089,9 +5095,25 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
{
DBUG_PRINT("info", ("%s did not exist on disk", name));
// .ndb file did not exist on disk, another table type
+ if (file_on_disk)
+ {
+ // Ignore this ndb table
+ gptr record= hash_search(&ndb_tables, file_name, strlen(file_name));
+ DBUG_ASSERT(record);
+ hash_delete(&ndb_tables, record);
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TABLE_EXISTS_ERROR,
+ "Local table %s.%s shadows ndb table",
+ db, file_name);
+ }
+ continue;
+ }
+ if (file_on_disk)
+ {
+ // File existed in NDB and as frm file, put in ok_tables list
+ my_hash_insert(&ok_tables, (byte*)file_name);
continue;
}
-
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.
@@ -6896,11 +6918,13 @@ void ndb_serialize_cond(const Item *item, void *arg)
DBUG_PRINT("info", ("FIELD_ITEM"));
DBUG_PRINT("info", ("table %s", tab->getName()));
DBUG_PRINT("info", ("column %s", field->field_name));
+ DBUG_PRINT("info", ("type %d", field->type()));
DBUG_PRINT("info", ("result type %d", field->result_type()));
// Check that we are expecting a field and with the correct
// result type
if (context->expecting(Item::FIELD_ITEM) &&
+ context->expecting_field_type(field->type()) &&
(context->expecting_field_result(field->result_type()) ||
// Date and year can be written as string or int
((type == MYSQL_TYPE_TIME ||
@@ -6923,7 +6947,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
curr_cond->ndb_item= new Ndb_item(field, col->getColumnNo());
context->dont_expect(Item::FIELD_ITEM);
context->expect_no_field_result();
- if (context->expect_mask)
+ if (! context->expecting_nothing())
{
// We have not seen second argument yet
if (type == MYSQL_TYPE_TIME ||
@@ -7120,6 +7144,9 @@ void ndb_serialize_cond(const Item *item, void *arg)
func_item);
context->expect(Item::STRING_ITEM);
context->expect(Item::FIELD_ITEM);
+ context->expect_only_field_type(MYSQL_TYPE_STRING);
+ context->expect_field_type(MYSQL_TYPE_VAR_STRING);
+ context->expect_field_type(MYSQL_TYPE_VARCHAR);
context->expect_field_result(STRING_RESULT);
context->expect(Item::FUNC_ITEM);
break;
@@ -7225,7 +7252,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::STRING_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);
@@ -7255,7 +7282,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::REAL_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);
@@ -7278,7 +7305,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::INT_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);
@@ -7301,7 +7328,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::DECIMAL_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);
@@ -7351,7 +7378,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::STRING_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);
@@ -7384,7 +7411,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::INT_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);
@@ -7411,7 +7438,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::REAL_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);
@@ -7434,7 +7461,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::VARBIN_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);
@@ -7459,7 +7486,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
NDB_ITEM_QUALIFICATION q;
q.value_type= Item::DECIMAL_ITEM;
curr_cond->ndb_item= new Ndb_item(NDB_VALUE, q, item);
- if (context->expect_field_result_mask)
+ if (! context->expecting_no_field_result())
{
// We have not seen the field argument yet
context->expect_only(Item::FIELD_ITEM);