mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Hand code string to integer conversion for performance.
As benchmarks show, using libc's string-to-integer conversion is pretty slow. At least part of the reason for that is that strtol[l] have to be more generic than what largely is required inside pg. This patch considerably speeds up int2/int4 input (int8 already was already using hand-rolled code). Most of the existing pg_atoi callers have been converted. But as one requires pg_atoi's custom delimiter functionality, and as it seems likely that there's external pg_atoi users, it seems sensible to just keep pg_atoi around. Author: Andres Freund Reviewed-By: Robert Haas Discussion: https://postgr.es/m/20171208214437.qgn6zdltyq5hmjpk@alap3.anarazel.de
This commit is contained in:
@ -6,7 +6,7 @@ INSERT INTO INT2_TBL(f1) VALUES ('0 ');
|
||||
INSERT INTO INT2_TBL(f1) VALUES (' 1234 ');
|
||||
INSERT INTO INT2_TBL(f1) VALUES (' -1234');
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
|
||||
ERROR: invalid input syntax for type integer: "34.5"
|
||||
ERROR: invalid input syntax for type smallint: "34.5"
|
||||
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('34.5');
|
||||
^
|
||||
-- largest and smallest values
|
||||
@ -18,27 +18,27 @@ ERROR: value "100000" is out of range for type smallint
|
||||
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('100000');
|
||||
^
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
|
||||
ERROR: invalid input syntax for type integer: "asdf"
|
||||
ERROR: invalid input syntax for type smallint: "asdf"
|
||||
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('asdf');
|
||||
^
|
||||
INSERT INTO INT2_TBL(f1) VALUES (' ');
|
||||
ERROR: invalid input syntax for type integer: " "
|
||||
ERROR: invalid input syntax for type smallint: " "
|
||||
LINE 1: INSERT INTO INT2_TBL(f1) VALUES (' ');
|
||||
^
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
|
||||
ERROR: invalid input syntax for type integer: "- 1234"
|
||||
ERROR: invalid input syntax for type smallint: "- 1234"
|
||||
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
|
||||
^
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('4 444');
|
||||
ERROR: invalid input syntax for type integer: "4 444"
|
||||
ERROR: invalid input syntax for type smallint: "4 444"
|
||||
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('4 444');
|
||||
^
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
|
||||
ERROR: invalid input syntax for type integer: "123 dt"
|
||||
ERROR: invalid input syntax for type smallint: "123 dt"
|
||||
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
|
||||
^
|
||||
INSERT INTO INT2_TBL(f1) VALUES ('');
|
||||
ERROR: invalid input syntax for type integer: ""
|
||||
ERROR: invalid input syntax for type smallint: ""
|
||||
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('');
|
||||
^
|
||||
SELECT '' AS five, * FROM INT2_TBL;
|
||||
|
@ -975,7 +975,7 @@ ROLLBACK TO SAVEPOINT settings;
|
||||
SAVEPOINT settings;
|
||||
SET LOCAL force_parallel_mode = 1;
|
||||
select stringu1::int2 from tenk1 where unique1 = 1;
|
||||
ERROR: invalid input syntax for type integer: "BAAAAA"
|
||||
ERROR: invalid input syntax for type smallint: "BAAAAA"
|
||||
CONTEXT: parallel worker
|
||||
ROLLBACK TO SAVEPOINT settings;
|
||||
-- test interaction with set-returning functions
|
||||
|
Reference in New Issue
Block a user