On Mon, Sep 11, 2017 at 5:19 PM, Robert Haas <robertmh...@gmail.com> wrote: > On Mon, Sep 11, 2017 at 6:45 AM, Ashutosh Bapat > <ashutosh.ba...@enterprisedb.com> wrote: >> So, all partitioned partitions are getting locked correctly. Am I >> missing something? > > That's not a valid test. In that scenario, you're going to hold all > the locks acquired by the planner, all the locks acquired by the > rewriter, and all the locks acquired by the executor, but when using > prepared queries, it's possible to execute the plan after the planner > and rewriter locks are no longer held. >
I see the same thing when I use prepare and execute Session 1 postgres=# prepare stmt as select 1 from t1 union all select 2 from t1; PREPARE postgres=# select pg_backend_pid(); pg_backend_pid ---------------- 50912 (1 row) postgres=# begin; BEGIN postgres=# execute stmt; ?column? ---------- (0 rows) Session 2 postgres=# select locktype, relation::regclass, virtualxid, virtualtransaction, pid, mode, granted, fastpath from pg_locks; locktype | relation | virtualxid | virtualtransaction | pid | mode | granted | fastpath ------------+----------+------------+--------------------+-------+-----------------+---------+---------- relation | pg_locks | | 4/4 | 50914 | AccessShareLock | t | t virtualxid | | 4/4 | 4/4 | 50914 | ExclusiveLock | t | t relation | t1p1p1 | | 3/12 | 50912 | AccessShareLock | t | t relation | t1p1 | | 3/12 | 50912 | AccessShareLock | t | t relation | t1 | | 3/12 | 50912 | AccessShareLock | t | t virtualxid | | 3/12 | 3/12 | 50912 | ExclusiveLock | t | t (6 rows) -- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers