Re: COPY TO looses on view

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: COPY TO looses on view
Дата
Msg-id 200107112153.f6BLrfI26497@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: COPY TO looses on view  (Steve Pothier <pothiers@aries.tucson.saic.com>)
Ответы Re: COPY TO looses on view  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
>
> Thank _you_.
>
> I didn't see anything in the documentation under COPY TO that
> indicated it should not work with views.  Since you say it should
> raise and error, the documentation should probably be updated too.
>
> -Steve Pothier-
>
>    Date: Thu, 28 Jun 2001 10:56:29 -0400
>    From: Tom Lane <tgl@sss.pgh.pa.us>
>    Cc: pgsql-bugs@postgresql.org
>
>    Steve Pothier <pothiers@aries.tucson.saic.com> writes:
>    > I created a simple view from an existing table.  I can select on the
>    > view ok but COPY TO "does nothing" (no error, no output).
>
>    It should raise an error.  Thanks for pointing that out.

OK, the following patch throws an error if you try to COPY TO/FROM
views.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: src/backend/commands/copy.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/commands/copy.c,v
retrieving revision 1.139
diff -c -r1.139 copy.c
*** src/backend/commands/copy.c    2001/06/08 21:16:48    1.139
--- src/backend/commands/copy.c    2001/07/11 21:50:30
***************
*** 307,312 ****
--- 307,314 ----
      {                            /* copy from file to database */
          if (rel->rd_rel->relkind == RELKIND_SEQUENCE)
              elog(ERROR, "You cannot change sequence relation %s", relname);
+         if (rel->rd_rel->relkind == RELKIND_VIEW)
+             elog(ERROR, "You cannot copy view %s", relname);
          if (pipe)
          {
              if (IsUnderPostmaster)
***************
*** 330,335 ****
--- 332,339 ----
      }
      else
      {                            /* copy from database to file */
+         if (rel->rd_rel->relkind == RELKIND_VIEW)
+             elog(ERROR, "You cannot copy view %s", relname);
          if (pipe)
          {
              if (IsUnderPostmaster)

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: order by and union
Следующее
От: Tom Lane
Дата:
Сообщение: Re: COPY TO looses on view