Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FATAL: ReleaseSavepoint: unexpected state SUBABORT_RESTART #1

Closed
darold opened this issue Nov 3, 2020 · 0 comments
Closed

FATAL: ReleaseSavepoint: unexpected state SUBABORT_RESTART #1

darold opened this issue Nov 3, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@darold
Copy link
Collaborator

darold commented Nov 3, 2020

When a nested write statement from a SELECT function fail the fatal error in subject is thrown. Code to reproduce:

LOAD 'pg_statement_rollback.so';
SET pg_statement_rollback.enabled TO on;
SET pg_statement_rollback.savepoint_name TO 'aze';
SET pg_statement_rollback.enable_writeonly TO on;

DROP SCHEMA IF EXISTS testrsl CASCADE;
CREATE SCHEMA testrsl;

SET search_path TO testrsl,public;

SET log_min_duration_statement TO -1;
SET log_statement TO 'all';
SET log_duration TO off;
SET client_min_messages TO LOG;

CREATE FUNCTION test_insert_fail() RETURNS integer AS $$
BEGIN
    INSERT INTO tbl_rsl VALUES (2, 'two');
    INSERT INTO tbl_rsl VALUES ('three', 3);
    RETURN 1;
END
$$ LANGUAGE plpgsql;
\echo Test internal automatic savepoint with a failing DO block
BEGIN;
DROP TABLE IF EXISTS tbl_rsl;
CREATE TABLE tbl_rsl(id integer, val varchar(256));
INSERT INTO tbl_rsl VALUES (1, 'one');
DO $$ BEGIN PERFORM test_insert_fail(); END $$;
ROLLBACK TO SAVEPOINT aze;
DELETE FROM tbl_rsl WHERE id = 1;
SELECT * FROM tbl_rsl; -- Should show 0 record
COMMIT;

DROP SCHEMA testrsl CASCADE;
@darold darold added the bug Something isn't working label Nov 3, 2020
@darold darold self-assigned this Nov 3, 2020
@darold darold closed this as completed in 5204d2c Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant