BUG #15738: _SPI_connected fail - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15738: _SPI_connected fail
Date
Msg-id 15738-21723084f3009ceb@postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15738
Logged by:          Geo Sil
Email address:      rekgrpth@gmail.com
PostgreSQL version: 11.2
Operating system:   alpine 3.9
Description:

this code
    int rc;
    char *src = "do $$begin select 1/0;end$$";
    (void)pgstat_report_activity(STATE_RUNNING, src);
    if ((rc = SPI_connect_ext(SPI_OPT_NONATOMIC)) != SPI_OK_CONNECT)
ereport(ERROR, (errmsg("SPI_connect_ext = %s",
SPI_result_code_string(rc))));
    (void)SPI_start_transaction();
    PG_TRY(); if ((rc = SPI_execute(src, false, 0) < 0)) ereport(ERROR,
(errmsg("SPI_execute = %s", SPI_result_code_string(rc)))); else {
        (void)SPI_commit();
    } PG_CATCH(); {
        (void)SPI_rollback();
    } PG_END_TRY();
    if ((rc = SPI_finish()) != SPI_OK_FINISH) ereport(ERROR,
(errmsg("SPI_finish = %s", SPI_result_code_string(rc))));
    (void)ProcessCompletedNotifies();
    (void)pgstat_report_activity(STATE_IDLE, src);
    (void)pgstat_report_stat(true);
emit exception "invalid transaction termination" because plpgsql increase
_SPI_connected and does not decrease it on exception
with char *src = "select 1/0"; all OK


pgsql-bugs by date:

Previous
From: Amit Langote
Date:
Subject: Re: BUG #15733: An insert destined at partition created after acolumn has been dropped from the parent table fails
Next
From: Etsuro Fujita
Date:
Subject: Re: BUG #15724: Can't create foreign table as partition