BUG #16474: Foreign key issue

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: d(dot)a(dot)ignatyev(at)yandex(dot)ru
Subject: BUG #16474: Foreign key issue
Date: 2020-06-01 16:17:28
Message-ID: 16474-03a567470736cd26@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16474
Logged by: Dmitry Ignatyev
Email address: d(dot)a(dot)ignatyev(at)yandex(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-06-01 16:18:11 Re: BUG #16472: Bug in to_timestamp ?
Previous Message Tom Lane 2020-06-01 15:58:57 Re: pgbench bug / limitation