Skip to content

Instantly share code, notes, and snippets.

@disconnect3d
Created April 13, 2020 11:28
Show Gist options
  • Save disconnect3d/dcfccfc1102c4f46417f5e71922aacea to your computer and use it in GitHub Desktop.
Save disconnect3d/dcfccfc1102c4f46417f5e71922aacea to your computer and use it in GitHub Desktop.
Random bug found in PostgreSQL database

Bug PoC below. Reported in https://www.postgresql.org/message-id/CABEVAa1dU0mDCAfaT8WF2adVXTDsLVJy_izotg6ze_hh-cn8qQ%40mail.gmail.com and fixed in https://www.postgresql.org/message-id/23800.1580509696%40sss.pgh.pa.us

This is correct:

> select json_to_tsvector('"abc"'::json, '"string"')
json_to_tsvector
--
'abc':1

Here, we changed the type name from "string" to "strinA":

> select json_to_tsvector('"abc"'::json, '"strinA"')
json_to_tsvector
--
'abc':1

But it should crash like this one:

> select json_to_tsvector('"abc"'::json, '"stringX"')
Query Error: error: wrong flag in flag array: "stringX"

The same bug applies to the jsonb_to_tsvector function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment