Skip to content

Commit

Permalink
Merge pull request #82647 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…22.1-82641

release-22.1: sql: check for nils when adding placeholder types
  • Loading branch information
rafiss authored Jun 9, 2022
2 parents a03914a + a848998 commit 6bd74ff
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/sql/conn_executor_prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ func (ex *connExecutor) addPreparedStmt(
for i, it := range prepared.InferredTypes {
// If the client did not provide an OID type hint, then infer the OID.
if it == 0 || it == oid.T_unknown {
t, _ := prepared.ValueType(tree.PlaceholderIdx(i))
prepared.InferredTypes[i] = t.Oid()
if t, ok := prepared.ValueType(tree.PlaceholderIdx(i)); ok {
prepared.InferredTypes[i] = t.Oid()
}
}
}

Expand Down
34 changes: 34 additions & 0 deletions pkg/sql/pgwire/testdata/pgtest/as_of_system_time
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,37 @@ ReadyForQuery
{"Type":"DataRow","Values":[{"text":"1"}]}
{"Type":"CommandComplete","CommandTag":"SELECT 1"}
{"Type":"ReadyForQuery","TxStatus":"I"}

send
Query {"String": "BEGIN"}
----

until
ReadyForQuery
----
{"Type":"CommandComplete","CommandTag":"BEGIN"}
{"Type":"ReadyForQuery","TxStatus":"T"}

send
Parse {"Name": "s1", "Query": "SET TRANSACTION AS OF SYSTEM TIME $1"}
Describe {"ObjectType": "S", "Name": "s1"}
Sync
----

until
ReadyForQuery
----
{"Type":"ParseComplete"}
{"Type":"ParameterDescription","ParameterOIDs":[0]}
{"Type":"NoData"}
{"Type":"ReadyForQuery","TxStatus":"T"}

send
Query {"String": "COMMIT"}
----

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

0 comments on commit 6bd74ff

Please sign in to comment.