BUG #16474: Foreign key issue - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16474: Foreign key issue
Date
Msg-id 16474-03a567470736cd26@postgresql.org
Whole thread Raw
Responses Re: BUG #16474: Foreign key issue
Re: BUG #16474: Foreign key issue
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16474
Logged by:          Dmitry Ignatyev
Email address:      d.a.ignatyev@yandex.ru
PostgreSQL version: 12.2
Operating system:   Windows 10
Description:

Hey, guys,

A few lines of SQL to clarify the situation:

        /* Here we make sure there is a value in parent table */

    select source from shelf.r_source where source = 'PPDM39RNEX' \gset

       /* And here we try to use it in an insert */

    INSERT INTO ppdm.ppdm_rule_remark
        (rule_id, 
        remark_type, 
        remark_seq_no, 
        remark_date, 
        "source")
    VALUES
        (:'ppdm_rule_id',
        :'remark_type',
        nextval('shelf.id_sequence'),
        NOW(),
        :'source');

This kind of code produces an SQLSTATE 23503

START TRANSACTION
psql:rule_run.sql:43: ОШИБКА:  INSERT или UPDATE в таблице
"ppdm_rule_remark" нарушает ограничение внешнего ключа "prr_r_s_fk"
ПОДРОБНОСТИ:  Ключ (source)=(PPDM39RNEX) отсутствует в таблице "r_source".
ROLLBACK

This is a foreign key violation message in Russian reporting an absence of
an existing value PPDM39RNEX.

Any quick workaround?

Best regards, Dmitry


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgbench bug / limitation
Next
From: Tom Lane
Date:
Subject: Re: BUG #16472: Bug in to_timestamp ?