pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: postgres_fdw: Tighten up allowed values for batch_size, fetch_si
Date: Wed, 07 Jul 2021 02:15:20 +0000
Message-ID: <E1m0x5s-0001gM-6m@gemulon.postgresql.org> (raw)

postgres_fdw: Tighten up allowed values for batch_size, fetch_size options.

Previously the values such as '100$%$#$#', '9,223,372,' were accepted and
treated as valid integers for postgres_fdw options batch_size and fetch_size.
Whereas this is not the case with fdw_startup_cost and fdw_tuple_cost options
for which an error is thrown. This was because endptr was not used
while converting strings to integers using strtol.

This commit changes the logic so that it uses parse_int function
instead of strtol as it serves the purpose by returning false in case
if it is unable to convert the string to integer. Note that
this function also rounds off the values such as '100.456' to 100 and
'100.567' or '100.678' to 101.

While on this, use parse_real for fdw_startup_cost and fdw_tuple_cost options.

Since parse_int and parse_real are being used for reloptions and GUCs,
it is more appropriate to use in postgres_fdw rather than using strtol
and strtod directly.

Back-patch to v14.

Author: Bharath Rupireddy
Reviewed-by: Ashutosh Bapat, Tom Lane, Kyotaro Horiguchi, Fujii Masao
Discussion: https://postgr.es/m/CALj2ACVMO6wY5Pc4oe1OCgUOAtdjHuFsBDw8R5uoYR86eWFQDA@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 19 ++++++++++
contrib/postgres_fdw/option.c                  | 52 +++++++++++++++-----------
contrib/postgres_fdw/postgres_fdw.c            | 16 ++++----
contrib/postgres_fdw/sql/postgres_fdw.sql      | 16 ++++++++
doc/src/sgml/postgres-fdw.sgml                 | 14 +++----
5 files changed, 82 insertions(+), 35 deletions(-)



view thread (2+ messages)

Message-ID: <E1m0x5s-0001gM-6m@gemulon.postgresql.org>
Permalink:  ../E1m0x5s-0001gM-6m@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1m0x5s-0001gM-6m@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: fujii@postgresql.org
  Subject: Re: pgsql: postgres_fdw: Tighten up allowed values for batch_size, fetch_si
  In-Reply-To: <E1m0x5s-0001gM-6m@gemulon.postgresql.org>
  References: <E1m0x5s-0001gM-6m@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