[Bug]: sql_require_primary_key does not enforce primary keys on CREATE or ALTER TABLE
I maintainer di solito rispondono entro 1 giorno
@matrix-meow ci sta già lavorando.
Dal 25/11/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Description
Tested on MatrixOne commit 568f0f4fdee3c34373f27b04316a2adf7d32a78a.
sql_require_primary_key=1 is accepted and readable but is not enforced. With invisible-primary-key generation explicitly disabled, CREATE TABLE without a primary key and ALTER TABLE ... DROP PRIMARY KEY both succeed and leave a table with no primary key.
Minimal reproduction
DROP DATABASE IF EXISTS repro_require_primary_key;
CREATE DATABASE repro_require_primary_key;
USE repro_require_primary_key;
SET SESSION sql_generate_invisible_primary_key=0;
SET SESSION sql_require_primary_key=1;
SELECT @@sql_require_primary_key,@@sql_generate_invisible_primary_key;
-- ('1','0')
CREATE TABLE no_pk(id INT, v INT); -- unexpectedly succeeds
SHOW CREATE TABLE no_pk; -- definition has no PRIMARY KEY
CREATE TABLE has_pk(id INT PRIMARY KEY, v INT);
ALTER TABLE has_pk DROP PRIMARY KEY; -- unexpectedly succeeds
SHOW CREATE TABLE has_pk; -- PRIMARY KEY has been removed
Expected behavior
MySQL's sql_require_primary_key contract rejects statements that create a table without a primary key or alter a table so that it no longer has one. Both operations above should fail with Error 3750 (ER_TABLE_WITHOUT_PK) while the variable is enabled. Setting sql_generate_invisible_primary_key=0 ensures that an automatically generated key cannot satisfy the requirement.
Actual behavior and controls
- Both prohibited DDL statements succeed, and SHOW CREATE confirms that the resulting tables really have no primary key.
- Creating a table with an explicit primary key succeeds under the same enabled setting.
- After the incorrect DROP, ADD PRIMARY KEY succeeds.
- After
SET SESSION sql_require_primary_key=0, creating a table without a primary key is allowed as expected.
Likely root cause
pkg/frontend/variables.go declares sql_require_primary_key as a dynamic variable, but static inspection found no DDL planner/executor consumer that checks whether CREATE or ALTER would leave the table without a primary key. The admission check needs to cover both table creation and primary-key removal.
- Lingua principale
- Go
- Stelle
- 1.9k
- Fork
- 312
- Merge medio
- 22h 59m
- PR unite (30g)
- 736
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di matrixorigin/matrixone
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
matrixorigin/matrixone#33363 ·
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
matrixorigin/matrixone#33362 ·
I maintainer di solito rispondono entro 1 giorno
-
SLEEP rejects NULL and negative durations that MySQL acceptsForse già presa @XuPeng-SH l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
matrixorigin/matrixone#32653 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CIForse già presa @XuPeng-SH l’ha presa oggi. Apertakind/bug needs-triage
matrixorigin/matrixone#33371 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CIForse già presa @XuPeng-SH l’ha presa oggi. Apertakind/bug needs-triage
matrixorigin/matrixone#33370 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di matrixorigin/matrixone
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pg-sharding/spqr#3314 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
zalando/postgres-operator#3257 ·
I maintainer di solito rispondono entro 2 giorni
-
[inputs.internal] README lists go_version tag on internal_gather instead of internal_agentForse già presa @cvas22 l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
influxdata/telegraf#20264 ·
I maintainer di solito rispondono entro 1 giorno