From f1c0d09389cde6a61266b0e186d170d1b5a4616f Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Fri, 29 Sep 2023 07:46:05 +0900 Subject: [PATCH] Test: add test case 080 for commit "Fix Describe() so that it does not abort with portal created by DECLARE." --- .../regression/tests/080.declare/expected.txt | 34 ++++++++++++++++ .../regression/tests/080.declare/pgproto.data | 28 +++++++++++++ src/test/regression/tests/080.declare/test.sh | 39 +++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 src/test/regression/tests/080.declare/expected.txt create mode 100644 src/test/regression/tests/080.declare/pgproto.data create mode 100755 src/test/regression/tests/080.declare/test.sh diff --git a/src/test/regression/tests/080.declare/expected.txt b/src/test/regression/tests/080.declare/expected.txt new file mode 100644 index 000000000..414f4e406 --- /dev/null +++ b/src/test/regression/tests/080.declare/expected.txt @@ -0,0 +1,34 @@ +FE=> Query (query="BEGIN") +<= BE CommandComplete(BEGIN) +<= BE ReadyForQuery(T) +FE=> Query (query="DECLARE "serverside-cursor-broken" CURSOR FOR SELECT 3") +<= BE CommandComplete(DECLARE CURSOR) +<= BE ReadyForQuery(T) +FE=> Describe(portal="serverside-cursor-broken") +FE=> Sync +<= BE RowDescription +<= BE ReadyForQuery(T) +FE=> Query (query="END") +<= BE CommandComplete(COMMIT) +<= BE ReadyForQuery(I) +FE=> Sync +<= BE ReadyForQuery(I) +FE=> Query (query="BEGIN") +<= BE CommandComplete(BEGIN) +<= BE ReadyForQuery(T) +FE=> Parse(stmt="", query="DECLARE "serverside-cursor-broken" CURSOR FOR SELECT 3") +FE=> Bind(stmt="", portal="") +FE=> Execute(portal="") +FE=> Describe(portal="serverside-cursor-broken") +FE=> Sync +<= BE ParseComplete +<= BE BindComplete +<= BE CommandComplete(DECLARE CURSOR) +<= BE RowDescription +<= BE ReadyForQuery(T) +FE=> Query (query="END") +<= BE CommandComplete(COMMIT) +<= BE ReadyForQuery(I) +FE=> Sync +<= BE ReadyForQuery(I) +FE=> Terminate diff --git a/src/test/regression/tests/080.declare/pgproto.data b/src/test/regression/tests/080.declare/pgproto.data new file mode 100644 index 000000000..5cfadf410 --- /dev/null +++ b/src/test/regression/tests/080.declare/pgproto.data @@ -0,0 +1,28 @@ +# test for simple query DECLARE +'Q' "BEGIN" +'Y' +'Q' "DECLARE "serverside-cursor-broken" CURSOR FOR SELECT 3" +'Y' +# Describe message should return RowDescription without error +'D' 'P' "serverside-cursor-broken" +'S' +'Y' +'Q' "END" +'Y' +'S' +'Y' +# test for extended query DECLARE +'Q' "BEGIN" +'Y' +'P' "" "DECLARE "serverside-cursor-broken" CURSOR FOR SELECT 3" 0 +'B' "" "" 0 0 0 +'E' "" 0 +# Describe message should return RowDescription without error +'D' 'P' "serverside-cursor-broken" +'S' +'Y' +'Q' "END" +'Y' +'S' +'Y' +'X' diff --git a/src/test/regression/tests/080.declare/test.sh b/src/test/regression/tests/080.declare/test.sh new file mode 100755 index 000000000..65e00d571 --- /dev/null +++ b/src/test/regression/tests/080.declare/test.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------- +# Test script for the case that Describe portal created by DECLARE +# CUSOR causes FATAL error. +# Discussion: [pgpool-general: 8934] DECLARE "serverside-cursor-broken" NO SCROLL CURSOR FOR SELECT +# +source $TESTLIBS +TESTDIR=testdir +PSQL=$PGBIN/psql +PG_CTL=$PGBIN/pg_ctl +PGPROTO=$PGPOOL_INSTALL_DIR/bin/pgproto +export PGDATABASE=test + +for mode in s i r n +do + rm -fr $TESTDIR + mkdir $TESTDIR + cd $TESTDIR + + echo -n "creating test environment..." + $PGPOOL_SETUP -m $mode || exit 1 + echo "done." + source ./bashrc.ports + ./startall + wait_for_pgpool_startup + + $PGPROTO -d $PGDATABASE -p $PGPOOL_PORT -f ../pgproto.data > results.txt 2>&1 + cmp ../expected.txt results.txt + + if [ $? != 0 ];then + echo "test failed in mode: $mode". + ./shutdownall + exit 1 + fi + ./shutdownall + cd .. +done + +exit 0 -- 2.39.5