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

Commit6281f34

Browse files
committed
Back-patch fix to disallow COPY TO/FROM a view (or anything else that's
not a plain relation).
1 parenta11c8be commit6281f34

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

‎src/backend/commands/copy.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.136 2001/03/22 06:16:11 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.136.2.1 2001/08/08 22:32:29 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -305,8 +305,15 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
305305

306306
if (from)
307307
{/* copy from file to database */
308-
if (rel->rd_rel->relkind==RELKIND_SEQUENCE)
309-
elog(ERROR,"You cannot change sequence relation %s",relname);
308+
if (rel->rd_rel->relkind!=RELKIND_RELATION)
309+
{
310+
if (rel->rd_rel->relkind==RELKIND_VIEW)
311+
elog(ERROR,"You cannot copy view %s",relname);
312+
elseif (rel->rd_rel->relkind==RELKIND_SEQUENCE)
313+
elog(ERROR,"You cannot change sequence relation %s",relname);
314+
else
315+
elog(ERROR,"You cannot copy object %s",relname);
316+
}
310317
if (pipe)
311318
{
312319
if (IsUnderPostmaster)
@@ -330,6 +337,15 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
330337
}
331338
else
332339
{/* copy from database to file */
340+
if (rel->rd_rel->relkind!=RELKIND_RELATION)
341+
{
342+
if (rel->rd_rel->relkind==RELKIND_VIEW)
343+
elog(ERROR,"You cannot copy view %s",relname);
344+
elseif (rel->rd_rel->relkind==RELKIND_SEQUENCE)
345+
elog(ERROR,"You cannot copy sequence %s",relname);
346+
else
347+
elog(ERROR,"You cannot copy object %s",relname);
348+
}
333349
if (pipe)
334350
{
335351
if (IsUnderPostmaster)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp