-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql/pgwire: fix encoding of int4 and bpchar in tuples #61013
Conversation
There are a few minor differences: dataTypeSize is different for tuples, and PG does not show seconds offset for times if it is zero. Release note: None
Release note (bug fix): Integers inside of tuples were not being encoded properly when using the binary format for retrieving data. This is now fixed, and the proper integer width is reported.
Release note (bug fix): Blank-padded chars (e.g. CHAR(3)) were not being encoded correctly when returning results to the client. Now they correctly include blank-padding when appropriate.
98df18a
to
f970cac
Compare
pkg/sql/pgwire/types.go
Outdated
@@ -422,7 +410,7 @@ func (b *writeBuffer) writeBinaryDatum( | |||
b.writeLengthPrefixedString(v.LogicalRep) | |||
|
|||
case *tree.DString: | |||
b.writeLengthPrefixedString(resolveBlankPaddedChar(string(*v), t)) | |||
b.writeLengthPrefixedString(tree.ResolveBlankPaddedChar(string(*v), t)) | |||
|
|||
case *tree.DCollatedString: | |||
b.writeLengthPrefixedString(v.Contents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to resolve blank padded chars for collated strings too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think i should add it
Release note (bug fix): Collated strings were not encoded with the proper type OID when sending results to the client if the OID was for the `char` type. This is now fixed.
e561c73
to
837efef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. are we backporting this?
@@ -184,6 +184,11 @@ func TestEncodings(t *testing.T) { | |||
case *tree.DTuple: | |||
// Unsupported. | |||
continue | |||
case *tree.DCollatedString: | |||
// Decoding collated strings is unsupported by this test. The encoded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treating collated strings differently to postgres has truly been a pain :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah the gift that keeps giving
tftr! bors r=otan |
Build failed (retrying...): |
bors r=otan |
Already running a review |
This PR was included in a batch that was canceled, it will be automatically retried |
Build succeeded: |
fixes #58069
This includes 3 commits:
sql/pgwire: make PGTest pass against PostgresSQL
There are a few minor differences: dataTypeSize is different for tuples,
and PG does not show seconds offset for times if it is zero.
sql/pgwire: fix binary encoding of ints in tuples
sql/pgwire: fix text encoding of bpchar in tuples
sql/pgwire: fix encoding of collated strings
Release note (bug fix): Integers inside of tuples were not being encoded
properly when using the binary format for retrieving data. This is now
fixed, and the proper integer width is reported.
Release note (bug fix): Blank-padded chars (e.g. CHAR(3)) were not being
encoded correctly when returning results to the client. Now they
correctly include blank-padding when appropriate.
Release note (bug fix): Collated strings were not encoded with the
proper type OID when sending results to the client if the OID was
for the
char
type. This is now fixed.