Skip to content

Review #2311 for code improvements: ON DELETE / ON UPDATE actions accepted but not applied #2656

Open

Description

@mathiasrw

This is not a bug report. It is an invitation to look at #2311 again, because it adds syntax without the behaviour behind it. The goal is to understand the change and decide whether anything should be improved. The notes below come from a quick read of the diff and one check, not from a full analysis.

The concerns:

  • Accepted and then ignored. The grammar now accepts ON DELETE / ON UPDATE with CASCADE, SET NULL, SET DEFAULT, RESTRICT and NO ACTION, and stores them on the foreign key (ondelete, onupdate). Nothing reads them. Checked on develop: with pid INT REFERENCES p(id) ON DELETE CASCADE, deleting the parent row succeeds and the child row stays, now pointing to nothing. A user who writes ON DELETE CASCADE reasonably expects the cascade.
  • Until the behaviour exists (Implement CASCADE behavior enforcement for FOREIGN KEY constraints #2337), it might be safer to throw "not supported" for actions other than NO ACTION than to accept them silently.
  • What happens on delete without any ON DELETE clause is worth checking in the same go: SQL's default (NO ACTION) refuses to delete a referenced row.

Related: #897, #2337.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions