Why is hstore_to_json_loose not like hstore_to_jsonb_loose?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Why is hstore_to_json_loose not like hstore_to_jsonb_loose?
Date: 2016-02-02 23:21:27
Message-ID: 23389.1454455287@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hstore_to_json_loose() contains a heuristic that says that an hstore value
that looks like a JSON number should be treated as a number (and hence not
quoted). That logic has an oversight in it, as per bug #13906, but it's
straightforward to fix.

However, I noticed that hstore_to_jsonb_loose() has completely different
(and much uglier) code to make the identical decision. Is there a good
reason for that? It seems to have avoided the bug in IsValidJsonNumber,
but looking at it doesn't fill me with confidence that it has no other
bugs, and anyway it's not clear why these two functions should have
different edge-case behaviors about what is a number and what is not.
So I am very sorely tempted to replace hstore_to_jsonb_loose()'s heuristic
with IsValidJsonNumber().

Comments, objections?

regards, tom lane

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-02-03 00:39:23 Re: Integer overflow in timestamp_part()
Previous Message Robert Haas 2016-02-02 23:05:19 Re: [POC] FETCH limited by bytes.