GitXplorerGitXplorer
d

mysql-enforcepk

public
3 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
7c444d5c1b7312847b12efd9bf8f3ed4b6e31200

Initial commit

ddveeden committed 7 years ago

README

The README file for this repository.

Description

The plugin is to prevent creation of tables without a primary key.

See also:

Example

With SUPER:

mysql> CREATE TABLE t1 (id int unsigned);
Query OK, 0 rows affected, 1 warning (0.05 sec)

Warning (Code 1642): Creating tables without primary key is not recommended
mysql> SHOW CREATE TABLE t1\G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `id` int(10) unsigned DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> DROP TABLE t1;
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE t1 (id int unsigned, primary key (id));
Query OK, 0 rows affected (0.03 sec)

mysql> 

Without SUPER:

mysql> CREATE TABLE t1 (id int unsigned);
ERROR 3164 (HY000): Creating tables without primary key requires SUPER privilege
mysql> CREATE TABLE t1 (id int unsigned primary key);
Query OK, 0 rows affected (0.03 sec)

mysql> 

Loading

Copy enforcepk.so to @@plugin_dir. Use install(1) to do this when upgrading.

mysql> install plugin enforcepk soname 'enforcepk.so';

Uninstall

mysql> uninstall plugin enforcepk;