diff options
Diffstat (limited to 'ext/pgsql')
-rw-r--r-- | ext/pgsql/pgsql.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 4ae0ae63ea..1aa3855af0 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -4122,14 +4122,14 @@ PHP_FUNCTION(pg_copy_to) &pg_delim, &pg_delim_len, &pg_null_as, &pg_null_as_len) == FAILURE) { return; } - if (!pg_delim) { - pg_delim = "\t"; - } if ((pgsql = (PGconn *)zend_fetch_resource2(Z_RES_P(pgsql_link), "PostgreSQL link", le_link, le_plink)) == NULL) { RETURN_FALSE; } + if (!pg_delim) { + pg_delim = "\t"; + } if (!pg_null_as) { pg_null_as = estrdup("\\\\N"); free_pg_null = 1; @@ -4255,6 +4255,11 @@ PHP_FUNCTION(pg_copy_from) &pg_delim, &pg_delim_len, &pg_null_as, &pg_null_as_len) == FAILURE) { return; } + + if ((pgsql = (PGconn *)zend_fetch_resource2(Z_RES_P(pgsql_link), "PostgreSQL link", le_link, le_plink)) == NULL) { + RETURN_FALSE; + } + if (!pg_delim) { pg_delim = "\t"; } @@ -4263,10 +4268,6 @@ PHP_FUNCTION(pg_copy_from) pg_null_as_free = 1; } - if ((pgsql = (PGconn *)zend_fetch_resource2(Z_RES_P(pgsql_link), "PostgreSQL link", le_link, le_plink)) == NULL) { - RETURN_FALSE; - } - spprintf(&query, 0, "COPY %s FROM STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, *pg_delim, pg_null_as); while ((pgsql_result = PQgetResult(pgsql))) { PQclear(pgsql_result); |