Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Display detailed explanation about tables affected by statement

Aperta
#116 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
postgresql, rust
Ambito
databases, tooling

Direzione di ricerca

Start by tracing the existing messages for foreign-key constraints, SET NOT NULL, and CREATE INDEX statements, using the SQL examples in the issue as entry points. Done means those cases report the affected table names, blocking behavior, and the requested suggestions, including the linked documentation where specified.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

As mentioned in the adding-foreign-key-constraint rule, adding a foreign key like the following will lock both tables.

ALTER TABLE "email" ADD CONSTRAINT "fk_user"
    FOREIGN KEY ("user_id") REFERENCES "user" ("id");

The current error message is general and says,

help: Requires a table scan of the table you're altering and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes to both tables while your table is scanned

Instead, we can provide a more detailed error message:

help: statement will block writes to the "user" and "email" tables while the "email" table is scanned to verify the foreign key constraint.

ALTER TABLE "core_recipe" ALTER COLUMN "foo" SET NOT NULL;

current message:

note: Setting a column NOT NULL blocks reads while the table is scanned.
help: Use a check constraint instead.

better message:

note: Setting the column NOT NULL will block reads and writes to the "core_recipe" table while the table is scanned to verify the NOT NULL constraint.
suggestion: Use a check constraint added as NOT VALID instead. See https://squawkhq.com/docs/adding-not-nullable-field for examples.

CREATE INDEX CONCURRENTLY "email_idx" ON "app_user" ("email");

current message:

help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statment supports it.

better message:

note: Statement will error if index already exists
suggestion: create index with IF NOT EXISTS. For example, CREATE INDEX CONCURRENTLY IF NOT EXISTS ...

CREATE INDEX "email_idx" ON "app_user" ("email");

current message:

note: Creating an index blocks writes.
help: Create the index CONCURRENTLY.

better message:

note: Writes will be blocked for the "app_user" table while the index in built.
suggestion: Create the index CONCURRENTLY to prevent blocking writes. For example, CREATE INDEX CONCURRENTLY ...

Lingua principale
Rust
Stelle
1.2k
Fork
70
Merge medio
54m
PR unite (30g)
45

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sbdchd/squawk

Tutte le issue di sbdchd/squawk

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.