Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef4120f

Browse files
author
Marina Polyakova
committed
PGPRO-6866: do not use the function pg_atoi if possible
In PostgreSQL version 12 or higher it's more effecient to use the function pg_strtoint32 instead (see the commit 86eaf208ea048936df6be77276a246d3f92e9620). And in PostgreSQL 15 the function pg_atoi was removed altogether (see the commit 73508475d69e90f98ebd9b7e1a5933a26a49c5e9). Therefore if possible use the function pg_strtoint32 instead.
1 parent 9a911f7 commit ef4120f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tsparser.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ typedef struct TParser
269269
int type;
270270
} TParser;
271271

272+
#if PG_VERSION_NUM < 120000
273+
#define pg_strtoint32(value) pg_atoi((value), sizeof(int32), 0)
274+
#endif
275+
272276

273277
/* forward decls here */
274278
static bool TParserGet(TParser *prs);
@@ -2533,13 +2537,13 @@ tsparser_headline(PG_FUNCTION_ARGS)
25332537
char *val = defGetString(defel);
25342538

25352539
if (pg_strcasecmp(defel->defname, "MaxWords") == 0)
2536-
max_words = pg_atoi(val, sizeof(int32), 0);
2540+
max_words = pg_strtoint32(val);
25372541
else if (pg_strcasecmp(defel->defname, "MinWords") == 0)
2538-
min_words = pg_atoi(val, sizeof(int32), 0);
2542+
min_words = pg_strtoint32(val);
25392543
else if (pg_strcasecmp(defel->defname, "ShortWord") == 0)
2540-
shortword = pg_atoi(val, sizeof(int32), 0);
2544+
shortword = pg_strtoint32(val);
25412545
else if (pg_strcasecmp(defel->defname, "MaxFragments") == 0)
2542-
max_fragments = pg_atoi(val, sizeof(int32), 0);
2546+
max_fragments = pg_strtoint32(val);
25432547
else if (pg_strcasecmp(defel->defname, "StartSel") == 0)
25442548
prs->startsel = pstrdup(val);
25452549
else if (pg_strcasecmp(defel->defname, "StopSel") == 0)

0 commit comments

Comments
 (0)