Re: pgbench - test whether a variable exists - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: pgbench - test whether a variable exists
Date
Msg-id 20180301182524.7zr3qb2sog5e7wh7@alvherre.pgsql
Whole thread Raw
In response to pgbench - test whether a variable exists  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
re. pg_strndup() the following places could use it (skim of a very quick grep
for pg_strdup):

src/bin/pg_waldump/pg_waldump.c:        *dir = pg_strdup(path);
src/bin/pg_waldump/pg_waldump.c-        (*dir)[(sep - path) + 1] = '\0';    /* no strndup */

src/bin/psql/prompt.c:                      name = pg_strdup(p + 1);
src/bin/psql/prompt.c-                      nameend = strcspn(name, ":");
src/bin/psql/prompt.c-                      name[nameend] = '\0';

src/bin/scripts/common.c:   *table = pg_strdup(spec);
src/bin/scripts/common.c-   (*table)[cp - spec] = '\0'; /* no strndup */

Not a lot.  It takes more code to add pg_strndup() that we would save by
adding it.

.oO(I wonder why strcspn and not strrchr ...)

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Jesper Pedersen
Date:
Subject: Re: [HACKERS] Runtime Partition Pruning
Next
From: Andres Freund
Date:
Subject: Re: Sample values for pg_stat_statements