mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
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
This commit is contained in:
@ -10480,3 +10480,22 @@ DROP TABLE result_tbl;
|
||||
DROP TABLE join_tbl;
|
||||
ALTER SERVER loopback OPTIONS (DROP async_capable);
|
||||
ALTER SERVER loopback2 OPTIONS (DROP async_capable);
|
||||
-- ===================================================================
|
||||
-- test invalid server and foreign table options
|
||||
-- ===================================================================
|
||||
-- Invalid fdw_startup_cost option
|
||||
CREATE SERVER inv_scst FOREIGN DATA WRAPPER postgres_fdw
|
||||
OPTIONS(fdw_startup_cost '100$%$#$#');
|
||||
ERROR: invalid value for floating point option "fdw_startup_cost": 100$%$#$#
|
||||
-- Invalid fdw_tuple_cost option
|
||||
CREATE SERVER inv_scst FOREIGN DATA WRAPPER postgres_fdw
|
||||
OPTIONS(fdw_tuple_cost '100$%$#$#');
|
||||
ERROR: invalid value for floating point option "fdw_tuple_cost": 100$%$#$#
|
||||
-- Invalid fetch_size option
|
||||
CREATE FOREIGN TABLE inv_fsz (c1 int )
|
||||
SERVER loopback OPTIONS (fetch_size '100$%$#$#');
|
||||
ERROR: invalid value for integer option "fetch_size": 100$%$#$#
|
||||
-- Invalid batch_size option
|
||||
CREATE FOREIGN TABLE inv_bsz (c1 int )
|
||||
SERVER loopback OPTIONS (batch_size '100$%$#$#');
|
||||
ERROR: invalid value for integer option "batch_size": 100$%$#$#
|
||||
|
Reference in New Issue
Block a user