Unexpected behaviour of 'DEFERRABLE INITIALLY DEFERRED' - Mailing list pgsql-general

From Jong-won Choi
Subject Unexpected behaviour of 'DEFERRABLE INITIALLY DEFERRED'
Date
Msg-id 5655AA70.5080709@internode.on.net
Whole thread Raw
Responses Re: Unexpected behaviour of 'DEFERRABLE INITIALLY DEFERRED'
List pgsql-general
Hi all,

This is from my local PostgreSQL log:

====
LOG:  statement: begin;
LOG:  statement: INSERT INTO site_owner (email, name, pwhash, data)
VALUES ('xyz', 'xyz', crypt('xyz', gen_salt('bf', 8)), '{}'::JSONB)
RETURNING id;
LOG:  statement: INSERT INTO site (owner, name, timezone, data) VALUES
('150c2fff-1029-47a5-aaa8-3e974e8442c6', 'sitex', 'Australia/NSW',
'{}'::JSONB) RETURNING id;
LOG:  statement: commit;

----

LOG:  statement: BEGIN
LOG:  execute <unnamed>: INSERT INTO site_owner (email, name, pwhash,
data) VALUES ($1, $2, crypt($3, gen_salt('bf', 8)), $4::JSONB) RETURNING id
DETAIL:  parameters: $1 = 'test@email6', $2 = 'Name', $3 = 'password',
$4 = '{}'
LOG:  execute <unnamed>: INSERT INTO site (owner, name, timezone, data)
VALUES ($1, $2, $3, $4::JSONB) RETURNING id
DETAIL:  parameters: $1 = '3a83db7f-c82e-4b7a-a5c7-c0b43f415b0e', $2 =
'Test', $3 = 'Australia/NSW', $4 = '{}'
ERROR:  insert or update on table "site" violates foreign key constraint
"site_owner_fkey"
DETAIL:  Key (owner)=(3a83db7f-c82e-4b7a-a5c7-c0b43f415b0e) is not
present in table "site_owner".
LOG:  statement: ROLLBACK
====


The first 'successful' part is a result of SQL statements from psql, and
the second 'unsuccessful' part is a result of client library function
calls from my application.

It seems to me they both have the same structure, except the first part
is consist of 'statements' and the second part is consist of
'execute'(prepare statements, I guess).

Any hints which can make the second part successful?

Thanks

- Jong-won


pgsql-general by date:

Previous
From: NTPT
Date:
Subject: Re: full_page_writes on SSD?
Next
From: "FarjadFarid\(ChkNet\)"
Date:
Subject: Re: full_page_writes on SSD?