Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit75abb95

Browse files
committed
Throw suitable error for COPY TO STDOUT/FROM STDIN in a SQL function.
A client copy can't work inside a function because the FE/BE wire protocoldoesn't support nesting of a COPY operation within query results. (Maybeit could, but the protocol spec doesn't suggest that clients should supportthis, and libpq for one certainly doesn't.)In most PLs, this prohibition is enforced by spi.c, but SQL functions don'tuse SPI. A comparison of _SPI_execute_plan() and init_execution_state()shows that rejecting client COPY is the only discrepancy in what theyallow, so there's no other similar bugs.This is an astonishingly ancient oversight, so back-patch to all supportedbranches.Report:https://postgr.es/m/BY2PR05MB2309EABA3DEFA0143F50F0D593780@BY2PR05MB2309.namprd05.prod.outlook.com
1 parentf6d6d29 commit75abb95

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎src/backend/executor/functions.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,16 @@ init_execution_state(List *queryTree_list,
500500
fcache->readonly_func ?CURSOR_OPT_PARALLEL_OK :0,
501501
NULL);
502502

503-
/* Precheck all commands for validity in a function */
503+
/*
504+
* Precheck all commands for validity in a function. This should
505+
* generally match the restrictions spi.c applies.
506+
*/
507+
if (IsA(stmt,CopyStmt)&&
508+
((CopyStmt*)stmt)->filename==NULL)
509+
ereport(ERROR,
510+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
511+
errmsg("cannot COPY to/from client in a SQL function")));
512+
504513
if (IsA(stmt,TransactionStmt))
505514
ereport(ERROR,
506515
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp