2017-10-10 10:10:19 |
Iwo |
description |
When pxc_strict_mode is set to enforcing inserting data into a table without a primary key is still possible with insertable views.
mysql> select @@GLOBAL.pxc_strict_mode,@@pxc_strict_mode;
+--------------------------+-------------------+
| @@GLOBAL.pxc_strict_mode | @@pxc_strict_mode |
+--------------------------+-------------------+
| ENFORCING | ENFORCING |
+--------------------------+-------------------+
mysql> create table t_wo_pk (id int);
mysql> INSERT INTO t_wo_pk SET id =1;
ERROR 1105 (HY000): Percona-XtraDB-Cluster prohibits use of DML command on a table (test.t_wo_pk) without an explicit primary key with pxc_strict_mode = ENFORCING or MASTER
mysql> CREATE VIEW v_wo_pk AS SELECT id FROM t_wo_pk;
mysql> INSERT INTO v_wo_pk SET id = 1;
Query OK, 1 row affected (0.01 sec)
mysql> select * from t_wo_pk;
+------+
| id |
+------+
| 1 |
+------+ |
When pxc_strict_mode is set to enforcing inserting data into a table without a primary key is still possible with insertable views.
mysql> select @@GLOBAL.pxc_strict_mode,@@pxc_strict_mode;
+--------------------------+-------------------+
| @@GLOBAL.pxc_strict_mode | @@pxc_strict_mode |
+--------------------------+-------------------+
| ENFORCING | ENFORCING |
+--------------------------+-------------------+
mysql> create table t_wo_pk (id int);
mysql> INSERT INTO t_wo_pk SET id =1;
ERROR 1105 (HY000): Percona-XtraDB-Cluster prohibits use of DML command on a table (test.t_wo_pk) without an explicit primary key with pxc_strict_mode = ENFORCING or MASTER
mysql> CREATE VIEW v_wo_pk AS SELECT id FROM t_wo_pk;
mysql> INSERT INTO v_wo_pk SET id = 1;
Query OK, 1 row affected (0.01 sec)
mysql> select * from t_wo_pk;
+------+
| id |
+------+
| 1 |
+------+
Tested against 5.7.19. |
|