mirror of https://github.com/jackc/pgx.git
Fix hstore binary null decoding
Bug was advancing the read pointer by the length of the value even if it was a NULL value. Since NULL is indicated by a -1 length it actually decremented the read pointer.non-blocking
parent
e26c6b4e3d
commit
6bda09691d
|
@ -142,8 +142,8 @@ func (dst *Hstore) DecodeBinary(ci *ConnInfo, src []byte) error {
|
||||||
var valueBuf []byte
|
var valueBuf []byte
|
||||||
if valueLen >= 0 {
|
if valueLen >= 0 {
|
||||||
valueBuf = src[rp : rp+valueLen]
|
valueBuf = src[rp : rp+valueLen]
|
||||||
|
rp += valueLen
|
||||||
}
|
}
|
||||||
rp += valueLen
|
|
||||||
|
|
||||||
var value Text
|
var value Text
|
||||||
err := value.DecodeBinary(ci, valueBuf)
|
err := value.DecodeBinary(ci, valueBuf)
|
||||||
|
|
|
@ -21,6 +21,10 @@ func TestHstoreTranscode(t *testing.T) {
|
||||||
&pgtype.Hstore{Map: map[string]pgtype.Text{"NULL": text("bar")}, Status: pgtype.Present},
|
&pgtype.Hstore{Map: map[string]pgtype.Text{"NULL": text("bar")}, Status: pgtype.Present},
|
||||||
&pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("NULL")}, Status: pgtype.Present},
|
&pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("NULL")}, Status: pgtype.Present},
|
||||||
&pgtype.Hstore{Map: map[string]pgtype.Text{"": text("bar")}, Status: pgtype.Present},
|
&pgtype.Hstore{Map: map[string]pgtype.Text{"": text("bar")}, Status: pgtype.Present},
|
||||||
|
&pgtype.Hstore{
|
||||||
|
Map: map[string]pgtype.Text{"a": text("a"), "b": {Status: pgtype.Null}, "c": text("c"), "d": {Status: pgtype.Null}, "e": text("e")},
|
||||||
|
Status: pgtype.Present,
|
||||||
|
},
|
||||||
&pgtype.Hstore{Status: pgtype.Null},
|
&pgtype.Hstore{Status: pgtype.Null},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue