|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)|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
On 3/25/15 9:24 AM, David Steele wrote:
> On 3/25/15 7:46 AM, Sawada Masahiko wrote:
>> 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 $$
>> cur1 cursor for select * from hoge;
>> tmp int;
>> open cur1;
>> fetch cur1 into tmp;
>> return tmp;
>> 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.
- David Steele
|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|