greenplum-db/plcontainer

ERROR when mix subtractions and normal spi calls

BaiShaoqi opened this issue · 2 comments

Expected behavior

 i
---
 1
 2
(2 rows)

Actual behavior

WARNING:  forcibly aborting a subtransaction that has not been exited
ERROR:  PL/Container client exception occurred:
DETAIL:  Exception occurred transforming result object to int4
test_plcontainer=# SELECT * FROM subtransaction_tbl;
 i
---
(0 rows)

Step to reproduce the behavior

CREATE TABLE subtransaction_tbl (
    i integer
);

CREATE FUNCTION subtransaction_mix_explicit_and_implicit() RETURNS void
AS $$
# container: plc_python_shared
p = plpy.prepare("INSERT INTO subtransaction_tbl VALUES ($1)", ["integer"])
try:
    with plpy.subtransaction():
        plpy.execute("INSERT INTO subtransaction_tbl VALUES (1)")
        plpy.execute(p, [2])
        plpy.execute(p, ["wrong"])
except plpy.SPIError:
    plpy.warning("Caught a SPI error from an explicit subtransaction")

try:
    plpy.execute("INSERT INTO subtransaction_tbl VALUES (1)")
    plpy.execute(p, [2])
    plpy.execute(p, ["wrong"])
except plpy.SPIError:
    plpy.warning("Caught a SPI error")
$$ LANGUAGE plcontainer;

SELECT subtransaction_mix_explicit_and_implicit();
SELECT * FROM subtransaction_tbl;
TRUNCATE subtransaction_tbl;

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

This is dup to #418
Closed