Bug #73498 [Com]: Incorrect SQL generated for pg_copy_to()

From: Date: Sun, 20 Nov 2016 20:54:54 +0000
Subject: Bug #73498 [Com]: Incorrect SQL generated for pg_copy_to()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205491@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73498&edit=1

 ID:                 73498
 Comment by:         php at duncanc dot co dot uk
 Reported by:        cward at titanhq dot com
 Summary:            Incorrect SQL generated for pg_copy_to()
 Status:             Open
 Type:               Bug
 Package:            PostgreSQL related
 Operating System:   FreeBSD
 PHP Version:        5.6.28
 Block user comment: N
 Private report:     N

 New Comment:

The postgres docs also say that DELIMITERS is still supported, could the error message
be misleading and the actual error be caused by some of the surrounding syntax?


Previous Comments:
------------------------------------------------------------------------
[2016-11-11 13:44:04] cward at titanhq dot com

Description:
------------
pg_copy_to generates incorrect SQL for the Postgresql COPY TO statement.

For instance: 
pg_copy_to($connection, 'test');
generates:
COPY test TO STDOUT DELIMITERS E'	' WITH NULL AS E'\\N'

"DELIMITERS" is incorrect; it should be "DELIMITER". See Postgresql manual:
https://www.postgresql.org/docs/current/static/sql-copy.html#AEN77298

However, this defect is only apparent if you try to use pg_copy_to on a view, which is perfectly
legal as documented here: 
https://www.postgresql.org/docs/current/static/sql-copy.html#AEN77520


Test script:
---------------
pg_copy_to($connection, '(select * from test'));


Expected result:
----------------
Return the contents of the view into a formatted array

Actual result:
--------------
ERROR:  syntax error at or near "DELIMITERS" at character 129


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73498&edit=1


Thread (4 messages)

« previous php.bugs (#205491) next »