ExecuteTruncate quirk: expects a unique list of relations

Started by NikhilSalmost 18 years ago2 messageshackers
Jump to latest
#1NikhilS
nikkhils@gmail.com

Hi,

Consider this simple case:

postgres=# TRUNCATE foo, foo;
ERROR: cannot TRUNCATE "foo" because it is being used by active queries in
this session

The above occurs because the ExecuteTruncate() function invokes
truncate_check_rel() in a loop. Since the same table name appears twice, the
rd_refcnt for table "foo" is bumped up to 2, causing the above failure.

We might want to add a step to ExecuteTruncate(), or whatever calls it, to
make the list unique.

Regards,
Nikhils
--
EnterpriseDB http://www.enterprisedb.com

#2Bruce Momjian
bruce@momjian.us
In reply to: NikhilS (#1)
Re: ExecuteTruncate quirk: expects a unique list of relations

Nikhils wrote:

Hi,

Consider this simple case:

postgres=# TRUNCATE foo, foo;
ERROR: cannot TRUNCATE "foo" because it is being used by active queries in
this session

The above occurs because the ExecuteTruncate() function invokes
truncate_check_rel() in a loop. Since the same table name appears twice, the
rd_refcnt for table "foo" is bumped up to 2, causing the above failure.

We might want to add a step to ExecuteTruncate(), or whatever calls it, to
make the list unique.

Fixed with attached, applied patch. I didn't see any other cases that
need fixing; LOCK foo, foo already works fine.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachments:

/rtmp/difftext/x-diffDownload+3-0