postgrespro/pg_query_state

create a CURSOR function cause the server to die

liguangxian opened this issue · 1 comments

HI:
I occur a problem about pg_query_state extension and hope receive your replay,
environment context:
1. ENVIRONMENT
postgresql10.5 + pg_query_state(PG10) ;
2.add "shared_preload_libraries = 'pg_query_state' on postgresql.conf.
Whether or not you create an extension will cause this problem.
3. exec the following SQL:

  • create table test(id int, value text);

  • insert into test values(1, 'one'),(2,'two');

  • create or replace function test_fun() returns void AS 'declare cursor_name cursor for select value from test;' LANGUAGE SQL;

  • select test_fun();
    and cause the server to die:
    # select test_fun(); TRAP: FailedAssertion("!(list->type == T_List || list->type == T_IntList || list->type == T_OidList)", File: "list.c", Line: 45) 2018-11-06 16:03:10.157 CST [31276] LOG: server process (PID 31285) was terminated by signal 6: Aborted 2018-11-06 16:03:10.157 CST [31276] DETAIL: Failed process was running: select test_fun(); 2018-11-06 16:03:10.157 CST [31276] LOG: terminating any other active server processes 2018-11-06 16:03:10.159 CST [31281] WARNING: terminating connection because of crash of another server process 2018-11-06 16:03:10.159 CST [31281] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.

  1. Executing the following two SQL will not cause this problem:
  • create or replace function test_fun()
    returns void
    AS 'declare cursor_name cursor for select value from test;
    close cursor_name;' #add more
    LANGUAGE SQL;

  • create or replace function test_fun2()
    RETURNS void AS
    $$
    DECLARE
    cursor_name2 CURSOR FOR select * from test;
    c_id INT;
    c_value TEXT;
    BEGIN
    OPEN cursor_name2;
    FETCH cursor_name2 INTO c_id, c_value;
    close cursor_name2;
    END;
    $$
    LANGUAGE PLPGSQL;

                                                                                                       From  LI Guangxian
    
                                                                                                                 2018-11-07
    

Hi @liguangxian! Your issue was fixed by commit c00cfed . You could check it and close issue