public inbox for [email protected]
help / color / mirror / Atom feed[PATCH v28 5/5] Doc: Add Collation Versions section.
3+ messages / 2 participants
[nested] [flat]
* [PATCH v28 5/5] Doc: Add Collation Versions section.
@ 2020-03-11 02:01 Thomas Munro <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Munro @ 2020-03-11 02:01 UTC (permalink / raw)
Supply a brief introduction to collation version concepts.
Author: Thomas Munro <[email protected]>
Reviewed-by: Julien Rouhaud <[email protected]>
Discussion: https://postgr.es/m/CAEepm%3D0uEQCpfq_%2BLYFBdArCe4Ot98t1aR4eYiYTe%3DyavQygiQ%40mail.gmail.com
---
doc/src/sgml/charset.sgml | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/doc/src/sgml/charset.sgml b/doc/src/sgml/charset.sgml
index 4b4563c5b9..12a82ff18c 100644
--- a/doc/src/sgml/charset.sgml
+++ b/doc/src/sgml/charset.sgml
@@ -948,6 +948,41 @@ CREATE COLLATION ignore_accents (provider = icu, locale = 'und-u-ks-level1-kc-tr
</tip>
</sect3>
</sect2>
+
+ <sect2 id="collation-versions">
+ <title>Collation Versions</title>
+
+ <para>
+ The ordering defined by a collation is not necessarily fixed over time.
+ If a collation changes for any reason, persistent data structures such as
+ b-trees that depend on a stable ordering of text might be corrupted.
+ <productname>PostgreSQL</productname> defends against this by recording
+ the current version of each referenced collation for any index that
+ depends on it in the
+ <link linkend="catalog-pg-depend"><structname>pg_depend</structname></link>
+ catalog, if the collation provider makes it available. If the provider
+ later begins to report a different version, a warning will be issued
+ when the index is accessed, until either the <xref linkend="sql-reindex"/>
+ or the <xref linkend="sql-alterindex"/> command is used to update the
+ version.
+ </para>
+ <para>
+ Version information is available for collations from the
+ <literal>icu</literal> provider on all operating systems. For the
+ <literal>libc</literal> provider, versions are currently only available
+ on systems using the GNU C library (most Linux systems).
+ </para>
+
+ <note>
+ <para>
+ When using the GNU C library for collations, the C library's version
+ is used as a proxy for the collation version. Many Linux distributions
+ change collation definitions only when upgrading the C library, but this
+ approach is imperfect as maintainers are free to back-port newer
+ collation definitions to older C library releases.
+ </para>
+ </note>
+ </sect2>
</sect1>
<sect1 id="multibyte">
--
2.20.1
--gclmslubawp3yaq7--
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: json_object returning jsonb reuslt different from returning json, returning text
@ 2022-04-25 14:14 Andrew Dunstan <[email protected]>
2022-04-28 19:35 ` Re: json_object returning jsonb reuslt different from returning json, returning text Andrew Dunstan <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Dunstan @ 2022-04-25 14:14 UTC (permalink / raw)
To: alias <[email protected]>; PostgreSQL Hackers <[email protected]>
On 2022-04-25 Mo 01:19, alias wrote:
>
> seems it's a bug around value 0.
>
> SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING
> jsonb)
> FROM (VALUES (1, 1), (10, NULL),(4, null), (5, null),(6, null),(2, 2))
> foo(k, v);
> return:
> {"1": 1, "2": 2}
>
> SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING
> jsonb)
> FROM (VALUES (1, 1), (0, NULL),(4, null), (5, null),(6, null),(2, 2))
> foo(k, v);
>
> return
> {"0": null, "1": 1, "2": 2}
Thanks for the report.
I don't think there's anything special about '0' except that it sorts
first. There appears to be a bug in the uniquefying code where the first
item(s) have nulls. The attached appears to fix it. Please test and see
if you can break it.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Attachments:
[text/x-patch] jsonb-uniquefy-fix.patch (865B, ../../[email protected]/2-jsonb-uniquefy-fix.patch)
download | inline diff:
diff --git a/src/backend/utils/adt/jsonb_util.c b/src/backend/utils/adt/jsonb_util.c
index aa151a53d6..21d874c098 100644
--- a/src/backend/utils/adt/jsonb_util.c
+++ b/src/backend/utils/adt/jsonb_util.c
@@ -1959,8 +1959,18 @@ uniqueifyJsonbObject(JsonbValue *object, bool unique_keys, bool skip_nulls)
if (hasNonUniq || skip_nulls)
{
- JsonbPair *ptr = object->val.object.pairs + 1,
- *res = object->val.object.pairs;
+ JsonbPair *ptr, *res;
+
+ while (skip_nulls && object->val.object.nPairs > 0 &&
+ object->val.object.pairs->value.type == jbvNull)
+ {
+ /* If skip_nulls is true, remove leading items with null */
+ object->val.object.pairs++;
+ object->val.object.nPairs--;
+ }
+
+ ptr = object->val.object.pairs + 1;
+ res = object->val.object.pairs;
while (ptr - object->val.object.pairs < object->val.object.nPairs)
{
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: json_object returning jsonb reuslt different from returning json, returning text
2022-04-25 14:14 Re: json_object returning jsonb reuslt different from returning json, returning text Andrew Dunstan <[email protected]>
@ 2022-04-28 19:35 ` Andrew Dunstan <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Dunstan @ 2022-04-28 19:35 UTC (permalink / raw)
To: alias <[email protected]>; PostgreSQL Hackers <[email protected]>
On 2022-04-25 Mo 10:14, Andrew Dunstan wrote:
> On 2022-04-25 Mo 01:19, alias wrote:
>> seems it's a bug around value 0.
>>
>> SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING
>> jsonb)
>> FROM (VALUES (1, 1), (10, NULL),(4, null), (5, null),(6, null),(2, 2))
>> foo(k, v);
>> return:
>> {"1": 1, "2": 2}
>>
>> SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING
>> jsonb)
>> FROM (VALUES (1, 1), (0, NULL),(4, null), (5, null),(6, null),(2, 2))
>> foo(k, v);
>>
>> return
>> {"0": null, "1": 1, "2": 2}
>
> Thanks for the report.
>
> I don't think there's anything special about '0' except that it sorts
> first. There appears to be a bug in the uniquefying code where the first
> item(s) have nulls. The attached appears to fix it. Please test and see
> if you can break it.
Fix pushed.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-04-28 19:35 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 02:01 [PATCH v28 5/5] Doc: Add Collation Versions section. Thomas Munro <[email protected]>
2022-04-25 14:14 Re: json_object returning jsonb reuslt different from returning json, returning text Andrew Dunstan <[email protected]>
2022-04-28 19:35 ` Re: json_object returning jsonb reuslt different from returning json, returning text Andrew Dunstan <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox