diff options
-rw-r--r-- | ext/pgsql/pgsql.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 313340bac5..22d855cd75 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -3309,12 +3309,13 @@ PHP_FUNCTION(pg_copy_to) if (!pg_delim) { pg_delim = "\t"; } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); + if (!pg_null_as) { pg_null_as = safe_estrdup("\\\\N"); } - ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); - query = (char *)emalloc(strlen(query_template) + strlen(table_name) + strlen(pg_null_as) + 1); sprintf(query, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as); |