Fix not-quite-right string comparison in parse_jsonb_index_flags().

This code would accept "strinX", where X is any 1-byte character,
as meaning "string".  Clearly it wasn't meant to do that.

No back-patch, since this doesn't affect correct queries and
there's some tiny chance we'd break somebody's incorrect query
in a minor release.

Report and patch by Dominik Czarnota.

Discussion: https://postgr.es/m/CABEVAa1dU0mDCAfaT8WF2adVXTDsLVJy_izotg6ze_hh-cn8qQ@mail.gmail.com
This commit is contained in:
Tom Lane 2020-01-31 17:26:40 -05:00
parent 74b35eb468
commit 870ad6a59b
1 changed files with 1 additions and 1 deletions

View File

@ -5125,7 +5125,7 @@ parse_jsonb_index_flags(Jsonb *jb)
pg_strncasecmp(v.val.string.val, "key", 3) == 0)
flags |= jtiKey;
else if (v.val.string.len == 6 &&
pg_strncasecmp(v.val.string.val, "string", 5) == 0)
pg_strncasecmp(v.val.string.val, "string", 6) == 0)
flags |= jtiString;
else if (v.val.string.len == 7 &&
pg_strncasecmp(v.val.string.val, "numeric", 7) == 0)