[MDEV-5335] Force PK option Created: 2013-11-26 Updated: 2015-08-07 Resolved: 2014-03-11 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | 10.1.0 |
| Type: | Task | Priority: | Major |
| Reporter: | erkan yanar | Assignee: | Jan Lindström (Inactive) |
| Resolution: | Fixed | Votes: | 6 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Have an option to force PK for (innodb) tables. Forcing is quite easy (a poc from 2011): From my point of view a lot of DBA's would love it |
| Comments |
| Comment by Jean Weisbuch [ 2013-11-26 ] |
|
Another possible issue that could be faced when using tables without a PK on a TokuDB table : if you use UNCOMMITED-READ isolation level, you can hit a HA_ERROR_CRASHED error during certain operations : http://www.tokutek.com/2013/11/what-does-the-incorrect-key-file-for-table-error-mean/ |
| Comment by Gokhan Demir [ 2014-01-16 ] |
|
Although I like the idea very much, some of the existing database deployments using InnoDB will be affected badly. I know at least one ERP company with huge number of tables in its multi-platform database, no single table has pk, but each of them have unique indexes that consists of not-null composite columns that are chosen by the InnoDB as the implicit pk. Since innoDB keeps the table sorted according to the primary key, and also since the columns of the primary keys are added to the columns of the secondary indexes, we have marked one of the normally not null columns to accept null values, that way forcing the addition of the documented 6-byte invisible pk column. That saved us and InnoDB is now handling successfully that bad database design. Therefore, I am against this idea. |
| Comment by Jan Lindström (Inactive) [ 2014-01-16 ] |
|
Forcing primary key will affect only new tables not the old ones. But, I would like to have an option e.g. innodb_force_pk with default ON, but option to set it dynamically OFF and with that option to create tables without primary key. |
| Comment by Sergei Golubchik [ 2014-01-16 ] |
|
gokhan of course, the task is about adding an option, so that users could enable it if necessary. We wouldn't think about imposing this "only PK" limitation on all users and all applications. |
| Comment by Gokhan Demir [ 2014-01-16 ] |
|
Thanks for the clarification. +1 from me! |
| Comment by Jan Lindström (Inactive) [ 2014-03-11 ] |
|
Hi, In this description tables created without primary key should be disabled, however in link also unique keys are mentioned. Is the idea to disable create table without primary key or should table without primary key but with unique key accepted ? R: Jan |
| Comment by Sergei Golubchik [ 2014-03-11 ] |
|
unique index with nullable columns is not good enough, the table with such an index but without a primary key should not be accepted. unique index with NOT NULL columns is as good a a primary key. Anyway, this task is about adding HA_REQUIRE_PRIMARY_KEY flag, there's no need to do anything beyond that (and tests, of course). |
| Comment by Jan Lindström (Inactive) [ 2014-03-11 ] |
|
revno: 3984 Setting option on by default is not a option, too many existing tests would fail. |