MySQL Forums
Forum List  »  NDB clusters

Re: Prefixed indexes
Posted by: Jonathan Stephens
Date: September 14, 2015 05:38AM

This is expected behaviour; the server parses the SQL before the storage engine takes any action on it, so the statement must still be a valid one. Example:

1. The MySQL server reads this statement, sees it is valid, so it's OK to execute; then it executes the statement, and NDB ignores that part of it:

mysql> create table t ( c1 int not null, c2 varchar(100), index i1 (c2(50)) )engine=ndb;
Query OK, 0 rows affected (0.79 sec)

mysql> show create table t\G
*************************** 1. row ***************************
       Table: t
Create Table: CREATE TABLE `t` (
  `c1` int(11) NOT NULL,
  `c2` varchar(100) DEFAULT NULL,
  KEY `i1` (`c2`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

2. The MySQL server attempts to parse the following statement, which is invalid; it rejects the statement with an error, and never tries to execute it:

mysql> create table t1 ( c1 int not null, c2 varchar(100), index i1 (c2(500)) )engine=ndb;
ERROR 1089 (HY000): Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
mysql>

That being said, I'll take a look at the documentation and see if we can't make that a bit clearer. Thanks!

Jon Stephens
MySQL Documentation Team @ Oracle

MySQL Dev Zone
MySQL Server Documentation
Oracle

Options: ReplyQuote


Subject
Views
Written By
Posted
1974
September 11, 2015 04:21AM
Re: Prefixed indexes
879
September 14, 2015 05:38AM
812
September 14, 2015 06:18AM
557
September 14, 2015 11:28AM
500
September 15, 2015 02:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.