summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormskold@mysql.com <>2004-11-22 12:02:32 +0100
committermskold@mysql.com <>2004-11-22 12:02:32 +0100
commit3455e345b2e9cd0674f3ed4abbebdbef6d5748b8 (patch)
treef9c833194cce943e65363c18040c635d92d08da1
parent64cd633f43bec240df9181f72e63e11ecbf11032 (diff)
parentf0e95c3704b1d473b8096b11b4c0a3306b5dffce (diff)
downloadmariadb-git-3455e345b2e9cd0674f3ed4abbebdbef6d5748b8.tar.gz
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/usr/local/home/marty/MySQL/test/mysql-4.1
-rw-r--r--mysql-test/r/ndb_index_unique.result7
-rw-r--r--mysql-test/t/ndb_index_unique.test8
-rw-r--r--sql/ha_ndbcluster.cc23
-rw-r--r--sql/ha_ndbcluster.h3
4 files changed, 39 insertions, 2 deletions
diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result
index af9b84022ed..9754be84b17 100644
--- a/mysql-test/r/ndb_index_unique.result
+++ b/mysql-test/r/ndb_index_unique.result
@@ -87,6 +87,13 @@ a b c
7 8 3
8 2 3
drop table t2;
+CREATE TABLE t2 (
+a int unsigned NOT NULL PRIMARY KEY,
+b int unsigned not null,
+c int unsigned,
+UNIQUE USING HASH (b, c)
+) engine=ndbcluster;
+ERROR 42000: Column 'c' is used with UNIQUE or INDEX but is not defined as NOT NULL
CREATE TABLE t3 (
a int unsigned NOT NULL,
b int unsigned not null,
diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test
index bdb23949763..3b7cecf6a69 100644
--- a/mysql-test/t/ndb_index_unique.test
+++ b/mysql-test/t/ndb_index_unique.test
@@ -58,6 +58,14 @@ select * from t2 order by a;
drop table t2;
+-- error 1121
+CREATE TABLE t2 (
+ a int unsigned NOT NULL PRIMARY KEY,
+ b int unsigned not null,
+ c int unsigned,
+ UNIQUE USING HASH (b, c)
+) engine=ndbcluster;
+
#
# Show use of PRIMARY KEY USING HASH indexes
#
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index bec4dfd9401..77cc7ce5bc4 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -796,7 +796,8 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
error= create_unique_index(unique_index_name, key_info);
break;
case UNIQUE_INDEX:
- error= create_unique_index(unique_index_name, key_info);
+ if (!(error= check_index_fields_not_null(i)))
+ error= create_unique_index(unique_index_name, key_info);
break;
case ORDERED_INDEX:
error= create_ordered_index(index_name, key_info);
@@ -848,6 +849,26 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_table(uint inx) const
ORDERED_INDEX);
}
+int ha_ndbcluster::check_index_fields_not_null(uint inx)
+{
+ 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("check_index_fields_not_null");
+
+ for (; key_part != end; key_part++)
+ {
+ Field* field= key_part->field;
+ if (field->maybe_null())
+ {
+ my_printf_error(ER_NULL_COLUMN_IN_INDEX,ER(ER_NULL_COLUMN_IN_INDEX),
+ MYF(0),field->field_name);
+ DBUG_RETURN(ER_NULL_COLUMN_IN_INDEX);
+ }
+ }
+
+ DBUG_RETURN(0);
+}
void ha_ndbcluster::release_metadata()
{
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index 9d7cba459cb..1b49aca81e6 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -160,7 +160,8 @@ class ha_ndbcluster: public handler
void release_metadata();
NDB_INDEX_TYPE get_index_type(uint idx_no) const;
NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const;
-
+ int check_index_fields_not_null(uint index_no);
+
int pk_read(const byte *key, uint key_len, byte *buf);
int complemented_pk_read(const byte *old_data, byte *new_data);
int peek_row();