Example in "42.8. Transaction Management" doesn't work for PostgreSQL v 12.7

Поиск
Список
Период
Сортировка
От Vladimir Shvartsgor
Тема Example in "42.8. Transaction Management" doesn't work for PostgreSQL v 12.7
Дата
Msg-id CALMFUmmsSMD4pJgZgA3XiYxP0hwkcN9w379Yw8Qu=xixfJw3JA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Example in "42.8. Transaction Management" doesn't work for PostgreSQL v 12.7
Список pgsql-bugs
Hi,


--run before:
--create table test1(a int);

CREATE PROCEDURE transaction_test1()
LANGUAGE plpgsql
AS $$
BEGIN
    FOR i IN 0..9 LOOP
        INSERT INTO test1 (a) VALUES (i);
        IF i % 2 = 0 THEN
            COMMIT;
        ELSE
            ROLLBACK;
        END IF;
    END LOOP;
END;
$$;

CALL transaction_test1();

The CALL fails with error:
ERROR: invalid transaction termination
CONTEXT: PL/pgSQL function transaction_test1() line 6 at COMMIT
SQL state: 2D000

The exact version of PostgreSQL: PostgreSQL 12.7 (Ubuntu 12.7-0ubuntu0.20.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit

Regards,
Vladimir

P.S. Generally, I need the option to execute commit/rollback inside a loop , is there a way? 

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

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: Unicode FFFF Special Codepoint should always collate high.
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17070: Sometimes copy from ingnores transaction