pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
adding strndup
7+ messages / 3 participants
[nested] [flat]

* adding strndup
@ 2019-12-04 14:40 Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-04 15:54 ` Re: adding strndup Tom Lane <tgl@sss.pgh.pa.us>
  2019-12-04 18:04 ` Re: adding strndup Andres Freund <andres@anarazel.de>
  0 siblings, 2 replies; 7+ messages in thread

From: Alvaro Herrera @ 2019-12-04 14:40 UTC (permalink / raw)
  To: Pg Hackers <pgsql-hackers@lists.postgresql.org>

I just proposed in
https://postgr.es/m/0191204143715.GA17312@alvherre.pgsql the addition of
strndup() to our src/port.

I think this should be pretty uncontroversial, but wanted to give a
heads-up outside that thread.  I attach the patch here for completeness.

-- 
Álvaro Herrera                                http://www.twitter.com/alvherre

Attachments:

v3-0001-Add-strndup-pg_strndup.patch (text/x-diff, 6.8K) download From 9a92076e53a6664ec61c5f475310c5d6edb91d90 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera <alvherre@alvh.no-ip.org> Date: Wed, 4 Dec 2019 11:02:34 -0300 Subject: [PATCH v3 1/3] Add strndup / pg_strndup The former is now a POSIX function. We already had pnstrdup, but it was not offered to frontend code. --- configure | 23 +++++++++++++++++++++++ configure.in | 3 ++- src/common/fe_memutils.c | 26 ++++++++++++++++++++++++++ src/include/common/fe_memutils.h | 2 ++ src/include/pg_config.h.in | 7 +++++++ src/include/pg_config.h.win32 | 7 +++++++ src/include/port.h | 4 ++++ src/port/strndup.c | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/port/strndup.c diff --git a/configure b/configure index 1d88983b34..fd8c759473 100755 --- a/configure +++ b/configure @@ -15482,6 +15482,16 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRLCPY $ac_have_decl _ACEOF +ac_fn_c_check_decl "$LINENO" "strndup" "ac_cv_have_decl_strndup" "$ac_includes_default" +if test "x$ac_cv_have_decl_strndup" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRNDUP $ac_have_decl +_ACEOF ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default" if test "x$ac_cv_have_decl_strnlen" = xyes; then : ac_have_decl=1 @@ -15815,6 +15825,19 @@ esac fi +ac_fn_c_check_func "$LINENO" "strndup" "ac_cv_func_strndup" +if test "x$ac_cv_func_strndup" = xyes; then : + $as_echo "#define HAVE_STRNDUP 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strndup.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strndup.$ac_objext" + ;; +esac + +fi + ac_fn_c_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen" if test "x$ac_cv_func_strnlen" = xyes; then : $as_echo "#define HAVE_STRNLEN 1" >>confdefs.h diff --git a/configure.in b/configure.in index a2cb20b5e3..11f66d19c3 100644 --- a/configure.in +++ b/configure.in @@ -1679,7 +1679,7 @@ AC_CHECK_DECLS(posix_fadvise, [], [], [#include <fcntl.h>]) ]) # fi AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>]) -AC_CHECK_DECLS([strlcat, strlcpy, strnlen]) +AC_CHECK_DECLS([strlcat, strlcpy, strndup, strnlen]) # This is probably only present on macOS, but may as well check always AC_CHECK_DECLS(F_FULLFSYNC, [], [], [#include <fcntl.h>]) @@ -1738,6 +1738,7 @@ AC_REPLACE_FUNCS(m4_normalize([ srandom strlcat strlcpy + strndup strnlen strtof ])) diff --git a/src/common/fe_memutils.c b/src/common/fe_memutils.c index ce99b4f4da..896e5d46ca 100644 --- a/src/common/fe_memutils.c +++ b/src/common/fe_memutils.c @@ -101,6 +101,26 @@ pg_strdup(const char *in) return tmp; } +char * +pg_strndup(const char *in, size_t size) +{ + char *tmp; + + if (!in) + { + fprintf(stderr, + _("cannot duplicate null pointer (internal error)\n")); + exit(EXIT_FAILURE); + } + tmp = strndup(in, size); + if (!tmp) + { + fprintf(stderr, _("out of memory\n")); + exit(EXIT_FAILURE); + } + return tmp; +} + void pg_free(void *ptr) { @@ -142,6 +162,12 @@ pstrdup(const char *in) return pg_strdup(in); } +char * +pnstrdup(const char *in, Size size) +{ + return pg_strndup(in, size); +} + void * repalloc(void *pointer, Size size) { diff --git a/src/include/common/fe_memutils.h b/src/include/common/fe_memutils.h index a1e5940d31..c8797ffe38 100644 --- a/src/include/common/fe_memutils.h +++ b/src/include/common/fe_memutils.h @@ -23,6 +23,7 @@ * (except pg_malloc_extended with MCXT_ALLOC_NO_OOM) */ extern char *pg_strdup(const char *in); +extern char *pg_strndup(const char *in, size_t size); extern void *pg_malloc(size_t size); extern void *pg_malloc0(size_t size); extern void *pg_malloc_extended(size_t size, int flags); @@ -31,6 +32,7 @@ extern void pg_free(void *pointer); /* Equivalent functions, deliberately named the same as backend functions */ extern char *pstrdup(const char *in); +extern char *pnstrdup(const char *in, Size size); extern void *palloc(Size size); extern void *palloc0(Size size); extern void *palloc_extended(Size size, int flags); diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index c208dcdfc7..1db3f1b1e8 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -170,6 +170,10 @@ don't. */ #undef HAVE_DECL_STRLCPY +/* Define to 1 if you have the declaration of `strndup', and to 0 if you + don't. */ +#undef HAVE_DECL_STRNDUP + /* Define to 1 if you have the declaration of `strnlen', and to 0 if you don't. */ #undef HAVE_DECL_STRNLEN @@ -545,6 +549,9 @@ /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY +/* Define to 1 if you have the `strndup' function. */ +#undef HAVE_STRNDUP + /* Define to 1 if you have the `strnlen' function. */ #undef HAVE_STRNLEN diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index 6c98ef4916..2ff2c3d4a8 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -129,6 +129,10 @@ don't. */ #define HAVE_DECL_RTLD_NOW 0 +/* Define to 1 if you have the declaration of `strndup', and to 0 if you + don't. */ +#undef HAVE_DECL_STRNDUP + /* Define to 1 if you have the declaration of `strnlen', and to 0 if you don't. */ #define HAVE_DECL_STRNLEN 1 @@ -297,6 +301,9 @@ /* Define to 1 if you have the <pam/pam_appl.h> header file. */ /* #undef HAVE_PAM_PAM_APPL_H */ +/* Define to 1 if you have the `strndup' function. */ +#undef HAVE_STRNDUP + /* Define to 1 if you have the `strnlen' function. */ #define HAVE_STRNLEN 1 diff --git a/src/include/port.h b/src/include/port.h index 10dcb5f0a6..e5d4486eb2 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -430,6 +430,10 @@ extern size_t strlcat(char *dst, const char *src, size_t siz); extern size_t strlcpy(char *dst, const char *src, size_t siz); #endif +#if !HAVE_DECL_STRNDUP +extern char *strndup(char *src, size_t siz); +#endif + #if !HAVE_DECL_STRNLEN extern size_t strnlen(const char *str, size_t maxlen); #endif diff --git a/src/port/strndup.c b/src/port/strndup.c new file mode 100644 index 0000000000..eba41a0498 --- /dev/null +++ b/src/port/strndup.c @@ -0,0 +1,32 @@ +/* + * strndup.c + * Fallback implementation of strndup(). + * + * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * src/port/strndup.c + */ + +#include "c.h" + +/* + * Implementation of posix' strndup for systems where it's not available. + */ +char * +strndup(const char *str, size_t siz) +{ + char *dst; + int len; + + len = strnlen(str, siz); + dst = malloc(len + 1); + if (dst == NULL) + return NULL; + + memcpy(dst, str, len); + dst[len + 1] = '\0'; + + return dst; +} -- 2.20.1
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: adding strndup
  2019-12-04 14:40 adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2019-12-04 15:54 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 7+ messages in thread

From: Tom Lane @ 2019-12-04 15:54 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> I just proposed in
> https://postgr.es/m/0191204143715.GA17312@alvherre.pgsql the addition of
> strndup() to our src/port.
> I think this should be pretty uncontroversial, but wanted to give a
> heads-up outside that thread.  I attach the patch here for completeness.

Grepping, I notice that ecpg has an ecpg_strndup; should that be
replaced with this?

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: adding strndup
  2019-12-04 14:40 adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2019-12-04 18:04 ` Andres Freund <andres@anarazel.de>
  2019-12-04 18:58   ` Re: adding strndup Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 7+ messages in thread

From: Andres Freund @ 2019-12-04 18:04 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>

Hi,

On 2019-12-04 11:40:21 -0300, Alvaro Herrera wrote:
> I just proposed in
> https://postgr.es/m/0191204143715.GA17312@alvherre.pgsql the addition of
> strndup() to our src/port.
> 
> I think this should be pretty uncontroversial, but wanted to give a
> heads-up outside that thread.  I attach the patch here for completeness.

Well, I personally think it's a bad idea to add further implementations
for functions that are in standar libraries on some systems. Especially,
but not exclusively, when made available for frontend code, where it's
not unlikely that there might be other applications having their own
implementations of strndup/whatever.

Besides that reason, I think AC_REPLACE_FUNCS is just a bad mechanism,
that yields fragmented source code and needs to implemented differently
for windows.  The code additionally often will also be badly optimized
in general, due to tiny translation units without relevant functions
having knoweldge about each other.

I'd just provide pnstrdup() in the frontend, without adding strndup().

I also see no point in adding both pnstrdup() and pg_strndup(). I'm fine
with moving towards pg_strndup(), but then we just ought to remove
pnstrdup().

- Andres





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: adding strndup
  2019-12-04 14:40 adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-04 18:04 ` Re: adding strndup Andres Freund <andres@anarazel.de>
@ 2019-12-04 18:58   ` Tom Lane <tgl@sss.pgh.pa.us>
  2019-12-04 19:05     ` Re: adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2019-12-04 18:58 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Pg Hackers <pgsql-hackers@lists.postgresql.org>

Andres Freund <andres@anarazel.de> writes:
> On 2019-12-04 11:40:21 -0300, Alvaro Herrera wrote:
>> I think this should be pretty uncontroversial, but wanted to give a
>> heads-up outside that thread.  I attach the patch here for completeness.

> I'd just provide pnstrdup() in the frontend, without adding strndup().

+1 --- seems like a bunch more mechanism than is warranted.  Let's
just open-code it in pnstrdup.  We can rely on strnlen, since that's
already supported, and there's not much more there beyond that.

> I also see no point in adding both pnstrdup() and pg_strndup(). I'm fine
> with moving towards pg_strndup(), but then we just ought to remove
> pnstrdup().

There's a fair number of uses of pnstrdup in the backend.  While it
wouldn't be too painful to rename them, I'm not sure I see the point.
(What I'd really argue for, if we did rename, is "pstrndup".)

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: adding strndup
  2019-12-04 14:40 adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-04 18:04 ` Re: adding strndup Andres Freund <andres@anarazel.de>
  2019-12-04 18:58   ` Re: adding strndup Tom Lane <tgl@sss.pgh.pa.us>
@ 2019-12-04 19:05     ` Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-04 22:01       ` Re: adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Alvaro Herrera @ 2019-12-04 19:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andres Freund <andres@anarazel.de>; Pg Hackers <pgsql-hackers@lists.postgresql.org>

On 2019-Dec-04, Tom Lane wrote:

> Andres Freund <andres@anarazel.de> writes:
> > On 2019-12-04 11:40:21 -0300, Alvaro Herrera wrote:
> >> I think this should be pretty uncontroversial, but wanted to give a
> >> heads-up outside that thread.  I attach the patch here for completeness.
> 
> > I'd just provide pnstrdup() in the frontend, without adding strndup().
> 
> +1 --- seems like a bunch more mechanism than is warranted.  Let's
> just open-code it in pnstrdup.  We can rely on strnlen, since that's
> already supported, and there's not much more there beyond that.

I can get behind that ... it makes the patch a lot smaller.  I'm gonna
send an updated version in a jiffy.

> > I also see no point in adding both pnstrdup() and pg_strndup(). I'm fine
> > with moving towards pg_strndup(), but then we just ought to remove
> > pnstrdup().
> 
> There's a fair number of uses of pnstrdup in the backend.  While it
> wouldn't be too painful to rename them, I'm not sure I see the point.
> (What I'd really argue for, if we did rename, is "pstrndup".)

*shrug*  I also looked for pstrndup() first.  And Peter E also in
https://postgr.es/m/1339713732.11971.79.camel@vanquo.pezone.net
submitted an implementation of pstrndup().  I'm not opposed to renaming
it, but I hesitate to do it at the same time as putting it in pgport.

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





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: adding strndup
  2019-12-04 14:40 adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-04 18:04 ` Re: adding strndup Andres Freund <andres@anarazel.de>
  2019-12-04 18:58   ` Re: adding strndup Tom Lane <tgl@sss.pgh.pa.us>
  2019-12-04 19:05     ` Re: adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2019-12-04 22:01       ` Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-04 22:17         ` Re: adding strndup Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Alvaro Herrera @ 2019-12-04 22:01 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andres Freund <andres@anarazel.de>; Pg Hackers <pgsql-hackers@lists.postgresql.org>

On 2019-Dec-04, Alvaro Herrera wrote:

> On 2019-Dec-04, Tom Lane wrote:
> 
> > Andres Freund <andres@anarazel.de> writes:
> > > On 2019-12-04 11:40:21 -0300, Alvaro Herrera wrote:
> > >> I think this should be pretty uncontroversial, but wanted to give a
> > >> heads-up outside that thread.  I attach the patch here for completeness.
> > 
> > > I'd just provide pnstrdup() in the frontend, without adding strndup().
> > 
> > +1 --- seems like a bunch more mechanism than is warranted.  Let's
> > just open-code it in pnstrdup.  We can rely on strnlen, since that's
> > already supported, and there's not much more there beyond that.
> 
> I can get behind that ... it makes the patch a lot smaller.

Here it is.

I noticed that ECPG's copy was setting errno.  I had forgot to do that
in my previous patch, but on second look, malloc failure already sets
it, so doing it again is pointless.

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

Attachments:

v4-0001-Offer-pnstrdup-to-frontend-code.patch (text/x-diff, 5.0K) download From c4dc0fd76e86bf97cb612bafe30847c47b77813e Mon Sep 17 00:00:00 2001 From: Alvaro Herrera <alvherre@alvh.no-ip.org> Date: Wed, 4 Dec 2019 11:02:34 -0300 Subject: [PATCH v4] Offer pnstrdup to frontend code We already had it on the backend. Frontend can also use it now. Discussion: https://postgr.es/m/20191204144021.GA17976@alvherre.pgsql --- src/bin/pg_waldump/pg_waldump.c | 3 +-- src/bin/psql/prompt.c | 16 +++++--------- src/bin/scripts/common.c | 3 +-- src/common/fe_memutils.c | 27 ++++++++++++++++++++++++ src/include/common/fe_memutils.h | 1 + src/interfaces/ecpg/compatlib/informix.c | 21 +----------------- 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 30a5851d87..a05fbe6938 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -114,8 +114,7 @@ split_path(const char *path, char **dir, char **fname) /* directory path */ if (sep != NULL) { - *dir = pg_strdup(path); - (*dir)[(sep - path) + 1] = '\0'; /* no strndup */ + *dir = pnstrdup(path, sep - path); *fname = pg_strdup(sep + 1); } /* local directory */ diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index 41c6f21ecf..1199181521 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -270,13 +270,10 @@ get_prompt(promptStatus_t status, ConditionalStack cstack) /* execute command */ case '`': { - FILE *fd; - char *file = pg_strdup(p + 1); - int cmdend; + int cmdend = strcspn(p + 1, "`"); + char *file = pnstrdup(p + 1, cmdend); + FILE *fd = popen(file, "r"); - cmdend = strcspn(file, "`"); - file[cmdend] = '\0'; - fd = popen(file, "r"); if (fd) { if (fgets(buf, sizeof(buf), fd) == NULL) @@ -295,13 +292,10 @@ get_prompt(promptStatus_t status, ConditionalStack cstack) /* interpolate variable */ case ':': { - char *name; + int nameend = strcspn(p + 1, ":"); + char *name = pnstrdup(p + 1, nameend); const char *val; - int nameend; - name = pg_strdup(p + 1); - nameend = strcspn(name, ":"); - name[nameend] = '\0'; val = GetVariable(pset.vars, name); if (val) strlcpy(buf, val, sizeof(buf)); diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index d2a7547441..d919c1cc0b 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -352,8 +352,7 @@ splitTableColumnsSpec(const char *spec, int encoding, else cp += PQmblen(cp, encoding); } - *table = pg_strdup(spec); - (*table)[cp - spec] = '\0'; /* no strndup */ + *table = pnstrdup(spec, cp - spec); *columns = cp; } diff --git a/src/common/fe_memutils.c b/src/common/fe_memutils.c index ce99b4f4da..2bc6606b80 100644 --- a/src/common/fe_memutils.c +++ b/src/common/fe_memutils.c @@ -142,6 +142,33 @@ pstrdup(const char *in) return pg_strdup(in); } +char * +pnstrdup(const char *in, Size size) +{ + char *tmp; + int len; + + if (!in) + { + fprintf(stderr, + _("cannot duplicate null pointer (internal error)\n")); + exit(EXIT_FAILURE); + } + + len = strnlen(in, size); + tmp = malloc(len + 1); + if (tmp == NULL) + { + fprintf(stderr, _("out of memory\n")); + exit(EXIT_FAILURE); + } + + memcpy(tmp, in, len); + tmp[len] = '\0'; + + return tmp; +} + void * repalloc(void *pointer, Size size) { diff --git a/src/include/common/fe_memutils.h b/src/include/common/fe_memutils.h index a1e5940d31..3181ee17dd 100644 --- a/src/include/common/fe_memutils.h +++ b/src/include/common/fe_memutils.h @@ -31,6 +31,7 @@ extern void pg_free(void *pointer); /* Equivalent functions, deliberately named the same as backend functions */ extern char *pstrdup(const char *in); +extern char *pnstrdup(const char *in, Size size); extern void *palloc(Size size); extern void *palloc0(Size size); extern void *palloc_extended(Size size, int flags); diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index a7bbeb9223..b2a19a1dd3 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -175,25 +175,6 @@ deccopy(decimal *src, decimal *target) memcpy(target, src, sizeof(decimal)); } -static char * -ecpg_strndup(const char *str, size_t len) -{ - size_t real_len = strlen(str); - int use_len = (int) ((real_len > len) ? len : real_len); - - char *new = malloc(use_len + 1); - - if (new) - { - memcpy(new, str, use_len); - new[use_len] = '\0'; - } - else - errno = ENOMEM; - - return new; -} - int deccvasc(const char *cp, int len, decimal *np) { @@ -205,7 +186,7 @@ deccvasc(const char *cp, int len, decimal *np) if (risnull(CSTRINGTYPE, cp)) return 0; - str = ecpg_strndup(cp, len); /* decimal_in always converts the complete + str = pnstrdup(cp, len); /* decimal_in always converts the complete * string */ if (!str) ret = ECPG_INFORMIX_NUM_UNDERFLOW; -- 2.20.1
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: adding strndup
  2019-12-04 14:40 adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-04 18:04 ` Re: adding strndup Andres Freund <andres@anarazel.de>
  2019-12-04 18:58   ` Re: adding strndup Tom Lane <tgl@sss.pgh.pa.us>
  2019-12-04 19:05     ` Re: adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
  2019-12-04 22:01       ` Re: adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2019-12-04 22:17         ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2019-12-04 22:17 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Andres Freund <andres@anarazel.de>; Pg Hackers <pgsql-hackers@lists.postgresql.org>

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
>> I can get behind that ... it makes the patch a lot smaller.

> Here it is.

LGTM.

> I noticed that ECPG's copy was setting errno.  I had forgot to do that
> in my previous patch, but on second look, malloc failure already sets
> it, so doing it again is pointless.

Right.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2019-12-04 22:17 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04 14:40 adding strndup Alvaro Herrera <alvherre@2ndquadrant.com>
2019-12-04 15:54 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-12-04 18:04 ` Andres Freund <andres@anarazel.de>
2019-12-04 18:58   ` Tom Lane <tgl@sss.pgh.pa.us>
2019-12-04 19:05     ` Alvaro Herrera <alvherre@2ndquadrant.com>
2019-12-04 22:01       ` Alvaro Herrera <alvherre@2ndquadrant.com>
2019-12-04 22:17         ` Tom Lane <tgl@sss.pgh.pa.us>

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