Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.
This repository was archived by the owner on Oct 4, 2024. It is now read-only.

alter table if exists <non existant table> drop constraint if exists foo; #19

@blaisn

Description

@blaisn

Version impacted : 14.7 15.2
Problem :
On a database created with AWS console in RDS Service, this command gives an error:

alter table if exists foo drop constraint if exists baz;

Where table foo does not exist and hence constraint baz does not exist.

The documentation says that this instruction issues a warning, not an error:
https://www.postgresql.org/docs/current/sql-altertable.html
IF EXISTS: Do not throw an error if the table does not exist. A notice is issued in this case.

On that database, the commande

Select version() 

gives

PostgreSQL 14.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12), 64-bit

Building a docker with the same postgresql version (14.7) does not issue an error when invoking

alter table if exists foo drop constraint if exists baz;

and respects what the documention states. And

Select version()

gives

PostgreSQL 14.7 (Debian 14.7-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

It then appears that différent compilation parameters could lead to a bug in that circontance.
We use to write defensive/idempotent scripts to prevent errors at runtime when staging. This bug force us to rewrite a lot of them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions