From: | David Steele <david(at)pgmasters(dot)net> |
---|---|
To: | Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Auditing extension for PostgreSQL (Take 2) |
Date: | 2015-04-01 17:46:51 |
Message-ID: | 551C2F0B.3010305@pgmasters.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Sawada,
On 3/25/15 9:24 AM, David Steele wrote:
> On 3/25/15 7:46 AM, Sawada Masahiko wrote:
>> 2.
>> I got ERROR when executing function uses cursor.
>>
>> 1) create empty table (hoge table)
>> 2) create test function as follows.
>>
>> create function test() returns int as $$
>> declare
>> cur1 cursor for select * from hoge;
>> tmp int;
>> begin
>> open cur1;
>> fetch cur1 into tmp;
>> return tmp;
>> end$$
>> language plpgsql ;
>>
>> 3) execute test function (got ERROR)
>> =# select test();
>> LOG: AUDIT: SESSION,6,1,READ,SELECT,,,selecT test();
>> LOG: AUDIT: SESSION,6,2,FUNCTION,EXECUTE,FUNCTION,public.test,selecT test();
>> LOG: AUDIT: SESSION,6,3,READ,SELECT,,,select * from hoge
>> CONTEXT: PL/pgSQL function test() line 6 at OPEN
>> ERROR: pg_audit stack is already empty
>> STATEMENT: selecT test();
>>
>> It seems like that the item in stack is already freed by deleting
>> pg_audit memory context (in MemoryContextDelete()),
>> before calling stack_pop in dropping of top-level Portal.
This has been fixed and I have attached a new patch. I've seen this
with cursors before where the parent MemoryContext is freed before
control is returned to ProcessUtility. I think that's strange behavior
but there's not a lot I can do about it.
The code I put in to deal with this situation was not quite robust
enough so I had to harden it a bit more.
Let me know if you see any other issues.
Thanks,
--
- David Steele
david(at)pgmasters(dot)net
Attachment | Content-Type | Size |
---|---|---|
pg_audit-v6.patch | text/plain | 101.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-04-01 17:56:10 | Re: Tables cannot have INSTEAD OF triggers |
Previous Message | Andres Freund | 2015-04-01 17:37:15 | Re: Tables cannot have INSTEAD OF triggers |