pgconn.send_describe_prepared(b"prep")
+@pytest.mark.libpq(">= 17")
+def test_send_close_prepared(pgconn):
+ pgconn.send_prepare(b"prep", b"select $1::int8 + $2::int8 as fld")
+ (res,) = execute_wait(pgconn)
+ assert res.status == pq.ExecStatus.COMMAND_OK, res.error_message
+
+ pgconn.send_close_prepared(b"prep")
+ (res,) = execute_wait(pgconn)
+ assert res.status == pq.ExecStatus.COMMAND_OK, res.error_message
+
+ # Because we closed it, describing should not work
+ pgconn.send_describe_prepared(b"prep")
+ (res,) = execute_wait(pgconn)
+ assert res.status == pq.ExecStatus.FATAL_ERROR
+
+
@pytest.mark.crdb_skip("server-side cursor")
def test_send_describe_portal(pgconn):
res = pgconn.exec_(
pgconn.finish()
with pytest.raises(psycopg.OperationalError):
pgconn.send_describe_portal(b"cur")
+
+
+@pytest.mark.crdb_skip("server-side cursor")
+@pytest.mark.libpq(">= 17")
+def test_send_close_portal(pgconn):
+ res = pgconn.exec_(
+ b"""
+ begin;
+ declare cur cursor for select * from generate_series(1,10) foo;
+ """
+ )
+ assert res.status == pq.ExecStatus.COMMAND_OK, res.error_message
+
+ pgconn.send_close_portal(b"cur")
+ (res,) = execute_wait(pgconn)
+ assert res.status == pq.ExecStatus.COMMAND_OK, res.error_message
+
+ # Because we closed it, describing should not work
+ pgconn.send_describe_portal(b"cur")
+ (res,) = execute_wait(pgconn)
+ assert res.status == pq.ExecStatus.FATAL_ERROR
assert res.get_value(0, 0) == out
+@pytest.mark.libpq(">= 17")
+def test_close_prepared(pgconn):
+ res = pgconn.prepare(b"prep", b"select $1::int + $2::int")
+ assert res.status == pq.ExecStatus.COMMAND_OK, res.error_message
+
+ res = pgconn.close_prepared(b"prep")
+ assert res.status == pq.ExecStatus.COMMAND_OK, res.error_message
+
+ # Because we closed it, executing should not work
+ res = pgconn.exec_prepared(b"prep", [b"3", b"5"])
+ assert res.status == pq.ExecStatus.FATAL_ERROR
+
+
@pytest.mark.crdb_skip("server-side cursor")
def test_describe_portal(pgconn):
res = pgconn.exec_(
pgconn.finish()
with pytest.raises(psycopg.OperationalError):
pgconn.describe_portal(b"cur")
+
+
+@pytest.mark.crdb_skip("server-side cursor")
+@pytest.mark.libpq(">= 17")
+def test_close_portal(pgconn):
+ res = pgconn.exec_(
+ b"""
+ begin;
+ declare cur cursor for select * from generate_series(1,10) foo;
+ """
+ )
+ assert res.status == pq.ExecStatus.COMMAND_OK, res.error_message
+
+ res = pgconn.close_portal(b"cur")
+ assert res.status == pq.ExecStatus.COMMAND_OK, res.error_message
+
+ # Because we closed it, describing should not work
+ res = pgconn.describe_portal(b"cur")
+ assert res.status == pq.ExecStatus.FATAL_ERROR