Re: BUG #10989: log_statement = ddl does not log ddl statements from stored functions

Поиск
Список
Период
Сортировка
От Amit Kapila
Тема Re: BUG #10989: log_statement = ddl does not log ddl statements from stored functions
Дата
Msg-id CAA4eK1LVuirQnMjV1vTMrG_F+1F9e9-8RDGnwiDsCqVTps1ptQ@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #10989: log_statement = ddl does not log ddl statements from stored functions  (eshkinkot@gmail.com)
Список pgsql-bugs
On Fri, Jul 18, 2014 at 5:59 PM, <eshkinkot@gmail.com> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference:      10989
> Logged by:          Sergey Burladyan
> Email address:      eshkinkot@gmail.com
> PostgreSQL version: 9.3.4
> Operating system:   Debian testing
> Description:
>
> If I run DROP directly, it logged:
> drop view test_view ;
> 2014-07-18 16:20:51 MSK LOG:  statement: drop view test_view ;
>
> but this query is not:
> do $ begin execute 'drop view test_view'; end $;

The reason for not logging this statement is that as per current design
postgres only logs top level statements that get executed with
log_statement settings.

Example:
1. Create table t1(c1 int, c2 char(30));

2.
CREATE OR REPLACE FUNCTION test_func() RETURNS int AS
$BODY$
DECLARE
    r int;
BEGIN
    FOR r IN 1 .. 10
    LOOP
        insert into t1 values(1,'aaa');
        update t1 set c1=10;
        delete from t1;
    END LOOP;
    RETURN 1;
END
$BODY$
LANGUAGE plpgsql;

3. Change log_statement = 'all'

4. Execute the function:
select test_func();

Now the result will be that in logs you will just see 'select test_func();'.

I think this is not a bug, rather if you want such functionality, this will
be a new feature in itself "log statements executed as part of function
execution" for which if there is a good use case then we need to discuss
it on -hackers (pgsql-hackers(at)postgresql(dot)org) mailing list.


With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Arthur O'Dwyer"
Дата:
Сообщение: Re: BUG #10976: Two memory leaks in regcomp cleanup
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_upgrade < 9.3 -> >=9.3 misses a step around multixacts