Skip site navigation (1) Skip section navigation (2)

Re: Transaction oddity with list partition of a list partition

From: David Fetter <david(at)fetter(dot)org>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Transaction oddity with list partition of a list partition
Date: 2016-12-15 09:09:16
Message-ID: 20161215090916.GB20659@fetter.org (view raw or whole thread)
Thread:
Lists: pgsql-hackers
On Thu, Dec 15, 2016 at 12:23:24AM -0800, David Fetter wrote:
> Folks,
> 
> I'm having some trouble understanding what's going on here.  When I \i
> the file in 55caaaeba877eac1feb6481fb413fa04ae9046ac without starting
> a transaction explicitly, it produces the expected results.  When I \i
> it after a BEGIN, not so much.


I've managed to get a shorter repro for the issue:

BEGIN;
CREATE TABLE the_log (
    ts TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "user" TEXT NOT NULL DEFAULT current_user,
    action TEXT NOT NULL,
    table_schema TEXT NOT NULL,
    table_name TEXT NOT NULL,
    old_row JSONB,
    new_row JSONB,
    CHECK(
        CASE action
            WHEN 'INSERT' THEN old_row IS NULL AND new_row IS NOT NULL
            WHEN 'UPDATE' THEN old_row IS NOT NULL AND new_row IS NOT NULL
            ELSE /*DELETE, and maybe TRUNCATE, if that's supported by access to old rows */
                old_row IS NOT NULL AND new_row IS NULL
        END
    )
) PARTITION BY LIST(table_schema);
CREATE TABLE public_log
    PARTITION OF the_log FOR VALUES IN ('public');
INSERT INTO the_log (action, table_schema, table_name, new_row)
VALUES ('INSERT','public','city','{"name": "Oakland", "population": 419267}');

leads to:

ERROR:  no partition of relation "the_log" found for row
DETAIL:  Failing row contains (2016-12-15 00:59:17.980094-08, shackle, INSERT, public, city, null, {"name": "Oakland", "population": 419267}).

Per Thomas Munro, could it be that the CREATE ... PARTITION OF ... code
fails to run CacheInvalidateRelcache on its parent(s)?

Best,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


In response to

Responses

pgsql-hackers by date

Next:From: Amit KapilaDate: 2016-12-15 09:17:31
Subject: Re: Hang in pldebugger after git commit : 98a64d0
Previous:From: Masahiko SawadaDate: 2016-12-15 09:08:25
Subject: Re: Quorum commit for multiple synchronous replication.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group