Skip to content

Commit

Permalink
sql/pgwire: add regression test for varchar OIDs in RowDescription
Browse files Browse the repository at this point in the history
See issue #51360. The bug described in it was fixed somewhat
accidentally, do this test will verify that we don't regress again.

Release note: None
  • Loading branch information
rafiss committed Aug 4, 2020
1 parent 470510e commit b960095
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/pgwire/testdata/pgtest/char
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ send
Query {"String": "DROP TABLE IF EXISTS a"}
----

until
until ignore=NoticeResponse
ReadyForQuery
----
{"Type":"CommandComplete","CommandTag":"DROP TABLE"}
Expand Down
62 changes: 61 additions & 1 deletion pkg/sql/pgwire/testdata/pgtest/row_description
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Prepare the environment.
send
Query {"String": "DROP VIEW IF EXISTS v; DROP TABLE IF EXISTS tab3; DROP TABLE IF EXISTS tab2; DROP TABLE IF EXISTS tab1"}
Query {"String": "DROP VIEW IF EXISTS v; DROP TABLE IF EXISTS tab4; DROP TABLE IF EXISTS tab3; DROP TABLE IF EXISTS tab2; DROP TABLE IF EXISTS tab1"}
----

until ignore=NoticeResponse
Expand All @@ -14,6 +14,7 @@ ReadyForQuery
{"Type":"CommandComplete","CommandTag":"DROP TABLE"}
{"Type":"CommandComplete","CommandTag":"DROP TABLE"}
{"Type":"CommandComplete","CommandTag":"DROP TABLE"}
{"Type":"CommandComplete","CommandTag":"DROP TABLE"}
{"Type":"ReadyForQuery","TxStatus":"I"}

# Start of test.
Expand Down Expand Up @@ -215,3 +216,62 @@ ReadyForQuery
----
{"Type":"CommandComplete","CommandTag":"SELECT 1"}
{"Type":"ReadyForQuery","TxStatus":"I"}

# tab4 is a regression test for #51360 -- verify that VARCHAR(n) columns
# have the correct DataTypeOID in RowDescription.
send
Query {"String": "CREATE TABLE tab4 (a INT8 PRIMARY KEY, b VARCHAR(256)[] NOT NULL)"}
----

until
ReadyForQuery
----
{"Type":"CommandComplete","CommandTag":"CREATE TABLE"}
{"Type":"ReadyForQuery","TxStatus":"I"}

send
Query {"String": "INSERT INTO tab4 VALUES(4, ARRAY['hello', 'goodbye'])"}
----

until
ReadyForQuery
----
{"Type":"CommandComplete","CommandTag":"INSERT 0 1"}
{"Type":"ReadyForQuery","TxStatus":"I"}

# 80 = ASCII 'P' for Portal
send
Parse {"Name": "s2", "Query": "SELECT b FROM tab4"}
Bind {"DestinationPortal": "p2", "PreparedStatement": "s2"}
Describe {"ObjectType": 80, "Name": "p2"}
Execute {"Portal": "p2"}
Sync
----

until
BindComplete
----
{"Type":"ParseComplete"}
{"Type":"BindComplete"}

until noncrdb_only ignore_table_oids
RowDescription
----
{"Type":"RowDescription","Fields":[{"Name":"b","TableOID":0,"TableAttributeNumber":2,"DataTypeOID":1015,"DataTypeSize":-1,"TypeModifier":260,"Format":0}]}

until crdb_only
RowDescription
----
{"Type":"RowDescription","Fields":[{"Name":"b","TableOID":56,"TableAttributeNumber":2,"DataTypeOID":1015,"DataTypeSize":-1,"TypeModifier":-1,"Format":0}]}


until
DataRow
----
{"Type":"DataRow","Values":[{"text":"{hello,goodbye}"}]}

until
ReadyForQuery
----
{"Type":"CommandComplete","CommandTag":"SELECT 1"}
{"Type":"ReadyForQuery","TxStatus":"I"}

0 comments on commit b960095

Please sign in to comment.