postgres/contrib/hstore
David Rowley 17a5871d9d Optimize escaping of JSON strings
There were quite a few places where we either had a non-NUL-terminated
string or a text Datum which we needed to call escape_json() on.  Many of
these places required that a temporary string was created due to the fact
that escape_json() needs a NUL-terminated cstring.  For text types, those
first had to be converted to cstring before calling escape_json() on them.

Here we introduce two new functions to make escaping JSON more optimal:

escape_json_text() can be given a text Datum to append onto the given
buffer.  This is more optimal as it foregoes the need to convert the text
Datum into a cstring.  A temporary allocation is only required if the text
Datum needs to be detoasted.

escape_json_with_len() can be used when the length of the cstring is
already known or the given string isn't NUL-terminated.  Having this
allows various places which were creating a temporary NUL-terminated
string to just call escape_json_with_len() without any temporary memory
allocations.

Discussion: https://postgr.es/m/CAApHDvpLXwMZvbCKcdGfU9XQjGCDm7tFpRdTXuB9PVgpNUYfEQ@mail.gmail.com
Reviewed-by: Melih Mutlu, Heikki Linnakangas
2024-07-27 23:46:07 +12:00
..
data Add GIN support for pg_trgm. From Guillaume Smet <guillaume.smet@gmail.com> 2007-03-14 14:21:53 +00:00
expected Handle \v as a whitespace character in parsers 2023-07-06 08:16:24 +09:00
sql Handle \v as a whitespace character in parsers 2023-07-06 08:16:24 +09:00
.gitignore Support "make check" in contrib 2011-04-25 22:27:11 +03:00
Makefile hstore: Tighten key/value parsing check for whitespaces 2023-06-12 09:14:03 +09:00
hstore--1.1--1.2.sql Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
hstore--1.2--1.3.sql Introduce jsonb, a structured format for storing json. 2014-03-23 16:40:19 -04:00
hstore--1.3--1.4.sql Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
hstore--1.4--1.5.sql Distinguish selectivity of < from <= and > from >=. 2017-09-13 11:12:39 -04:00
hstore--1.4.sql Update extensions with GIN/GIST support for parallel query. 2016-06-14 13:34:37 -04:00
hstore--1.5--1.6.sql Add a 64-bit hash function for type hstore. 2018-11-23 13:37:34 -05:00
hstore--1.6--1.7.sql Improve selectivity estimation for assorted match-style operators. 2020-04-01 10:32:33 -04:00
hstore--1.7--1.8.sql Remove deprecated containment operators for contrib types. 2021-03-05 10:45:41 -05:00
hstore.control Allow subscripting of hstore values. 2020-12-11 18:58:21 -05:00
hstore.h Fix final warnings produced by -Wshadow=compatible-local 2022-10-07 13:13:27 +13:00
hstore_compat.c Fix most -Wundef warnings 2019-10-19 18:31:38 +02:00
hstore_gin.c Add construct_array_builtin, deconstruct_array_builtin 2022-07-01 11:23:15 +02:00
hstore_gist.c Use new overflow-safe integer comparison functions. 2024-02-16 14:05:36 -06:00
hstore_io.c Optimize escaping of JSON strings 2024-07-27 23:46:07 +12:00
hstore_op.c Fix incorrect uses of Datum conversion macros 2022-09-05 13:30:44 +02:00
hstore_subs.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00