pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Preserve integer and float values accurately in (de)serialize_de
Date: Tue, 10 Mar 2020 16:30:22 +0000
Message-ID: <E1jBhlu-0000GH-Q1@gemulon.postgresql.org> (raw)

Preserve integer and float values accurately in (de)serialize_deflist.

Previously, this code just smashed all types of DefElem values to
strings, cavalierly reasoning that nobody would care.  But in point of
fact, most of the defGetFoo functions do distinguish among different
input syntaxes; for instance defGetBoolean will accept 1 as an integer
but not "1" as a string.  This led to CREATE/ALTER TEXT SEARCH
DICTIONARY accepting 0 and 1 as values for boolean dictionary
properties, only to have the dictionary fail at runtime.

We can upgrade this behavior by teaching serialize_deflist that it
does not need to quote T_Integer or T_Float nodes' values on output,
and then teaching deserialize_deflist to restore unquoted integer or
float values as the appropriate node type.  This should not break
anything using pg_ts_dict.dictinitoption, since that field is just
defined as being something valid to include in CREATE TEXT SEARCH
DICTIONARY.

deserialize_deflist is also used to parse the options arguments
for the ts_headline family of functions, but so far as I can see
this won't cause any problems there either: the only consumer of
that output is prsd_headline which always uses defGetString.
(Really that's a bad idea, but I won't risk changing it here.)

This is surely a bug fix, but given the lack of field complaints
I don't think it's necessary to back-patch.

Discussion: https://postgr.es/m/CAMkU=1xRcs_BUPzR0+V3WndaCAv0E_m3h6aUEJ8NF-sY1nnHsw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d01f03a495294f726001a90ec27a675428d9fc45

Modified Files
--------------
contrib/dict_int/expected/dict_int.out | 29 ++++++++++-
contrib/dict_int/sql/dict_int.sql      | 10 +++-
src/backend/commands/tsearchcmds.c     | 90 ++++++++++++++++++++++++++--------
src/test/regress/expected/tsdicts.out  | 35 +++++++++++++
src/test/regress/sql/tsdicts.sql       | 13 +++++
5 files changed, 154 insertions(+), 23 deletions(-)



Message-ID: <E1jBhlu-0000GH-Q1@gemulon.postgresql.org>
Permalink:  ../E1jBhlu-0000GH-Q1@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jBhlu-0000GH-Q1@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Preserve integer and float values accurately in (de)serialize_de
  In-Reply-To: <E1jBhlu-0000GH-Q1@gemulon.postgresql.org>
  References: <E1jBhlu-0000GH-Q1@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox