summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorRaghav Kapoor <raghav.kapoor@oracle.com>2014-06-25 18:06:28 +0530
committerRaghav Kapoor <raghav.kapoor@oracle.com>2014-06-25 18:06:28 +0530
commitf499292522c70f8f618d5ac41febc93022fc2d07 (patch)
treee8010dce623c94162e25a3479aa7d290baaf0132 /sql/table.cc
parentb278384f64277adf4b0280ae35fffa5a53f5b761 (diff)
downloadmariadb-git-f499292522c70f8f618d5ac41febc93022fc2d07.tar.gz
BUG#17665767 - FAILING ASSERTION: PRIMARY_KEY_NO == -1 || PRIMARY_KEY_NO == 0
BACKGROUND: This bug is a followup on Bug#16368875. The assertion failure happens because in SQL layer the key does not get promoted to PRIMARY KEY but InnoDB takes it as PRIMARY KEY. ANALYSIS: Here we are trying to create an index on POINT (GEOMETRY) data type which is a type of BLOB (since GEOMETRY is a subclass of BLOB). In general, we can't create an index over GEOMETRY family type field unless we specify the length of the keypart (similar to BLOB fields). Only exception is the POINT field type. The POINT column max size is 25. The problem is that the field is not treated as PRIMARY KEY when we create a index on POINT column using its max column size as key part prefix. The fix would allow index on POINT column to be treated as PRIMARY KEY. FIX: Patch for Bug#16368875 is extended to take into account GEOMETRY datatype, POINT in particular to consider it as PRIMARY KEY in SQL layer.
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/table.cc b/sql/table.cc
index ba1839bb6ec..b24e03fbe1a 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1539,6 +1539,17 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
table_field->type() == MYSQL_TYPE_BLOB &&
table_field->field_length == key_part[i].length)
continue;
+ /*
+ If the key column is of NOT NULL GEOMETRY type, specifically POINT
+ type whose length is known internally (which is 25). And key part
+ prefix size is equal to the POINT column max size, then we can
+ promote it to primary key.
+ */
+ if (!table_field->real_maybe_null() &&
+ table_field->type() == MYSQL_TYPE_GEOMETRY &&
+ table_field->get_geometry_type() == Field::GEOM_POINT &&
+ key_part[i].length == MAX_LEN_GEOM_POINT_FIELD)
+ continue;
if (table_field->real_maybe_null() ||
table_field->key_length() != key_part[i].length)