-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38586: pgwire: add some portal tests r=mjibson a=mjibson Co-authored-by: Matt Jibson <[email protected]>
- Loading branch information
Showing
4 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Verify that a completed portal can't be re-executed. | ||
|
||
send | ||
Parse {"Query": "SELECT 1"} | ||
Bind | ||
Execute | ||
Sync | ||
---- | ||
|
||
until | ||
ReadyForQuery | ||
---- | ||
{"Type":"ParseComplete"} | ||
{"Type":"BindComplete"} | ||
{"Type":"DataRow","Values":[{"text":"1"}]} | ||
{"Type":"CommandComplete","CommandTag":"SELECT 1"} | ||
{"Type":"ReadyForQuery","TxStatus":"I"} | ||
|
||
send | ||
Execute | ||
Sync | ||
---- | ||
|
||
until | ||
ErrorResponse | ||
ReadyForQuery | ||
---- | ||
{"Type":"ErrorResponse"} | ||
{"Type":"ReadyForQuery","TxStatus":"I"} | ||
|
||
# Verify that closing a bound portal prevents execution. | ||
|
||
# 80 = ASCII 'P' | ||
send | ||
Parse {"Name": "s", "Query": "SELECT 1"} | ||
Bind {"DestinationPortal": "p", "PreparedStatement": "s"} | ||
Close {"ObjectType": 80, "Name": "p"} | ||
Execute {"Portal": "p"} | ||
Sync | ||
---- | ||
|
||
until | ||
ErrorResponse | ||
ReadyForQuery | ||
---- | ||
{"Type":"ParseComplete"} | ||
{"Type":"BindComplete"} | ||
{"Type":"CloseComplete"} | ||
{"Type":"ErrorResponse"} | ||
{"Type":"ReadyForQuery","TxStatus":"I"} | ||
|
||
# The spec says that closing a prepared statement also closes its portals, | ||
# but that doesn't seem to be the case. Below I would expect that Bind, | ||
# Close, Execute causes the execute to return an error, but it instead | ||
# returns the portal result. This happens in both Postgres and Cockroach. | ||
|
||
# 83 = ASCII 'S' | ||
# After closing, re-parse with the same name to make sure the execute | ||
# happens on the old statement. | ||
send | ||
Bind {"DestinationPortal": "p", "PreparedStatement": "s"} | ||
Close {"ObjectType": 83, "Name": "s"} | ||
Parse {"Name": "s", "Query": "SELECT 2"} | ||
Execute {"Portal": "p"} | ||
Sync | ||
---- | ||
|
||
until | ||
ReadyForQuery | ||
---- | ||
{"Type":"BindComplete"} | ||
{"Type":"CloseComplete"} | ||
{"Type":"ParseComplete"} | ||
{"Type":"DataRow","Values":[{"text":"1"}]} | ||
{"Type":"CommandComplete","CommandTag":"SELECT 1"} | ||
{"Type":"ReadyForQuery","TxStatus":"I"} | ||
|
||
# Portal still isn't destroyed within a transaction either, in PG or CR. | ||
|
||
send | ||
Query {"String": "BEGIN"} | ||
---- | ||
|
||
until | ||
ReadyForQuery | ||
---- | ||
{"Type":"CommandComplete","CommandTag":"BEGIN"} | ||
{"Type":"ReadyForQuery","TxStatus":"T"} | ||
|
||
send | ||
Bind {"DestinationPortal": "p", "PreparedStatement": "s"} | ||
Close {"ObjectType": 83, "Name": "s"} | ||
Parse {"Name": "s", "Query": "SELECT 3"} | ||
Execute {"Portal": "p"} | ||
Sync | ||
---- | ||
|
||
until | ||
ReadyForQuery | ||
---- | ||
{"Type":"BindComplete"} | ||
{"Type":"CloseComplete"} | ||
{"Type":"ParseComplete"} | ||
{"Type":"DataRow","Values":[{"text":"2"}]} | ||
{"Type":"CommandComplete","CommandTag":"SELECT 1"} | ||
{"Type":"ReadyForQuery","TxStatus":"T"} | ||
|
||
send | ||
Query {"String": "COMMIT"} | ||
---- | ||
|
||
until | ||
ReadyForQuery | ||
---- | ||
{"Type":"CommandComplete","CommandTag":"COMMIT"} | ||
{"Type":"ReadyForQuery","TxStatus":"I"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters