Re: COPY FROM WHEN condition

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: COPY FROM WHEN condition
Дата
Msg-id c8cee82b-ae71-4153-a29f-fd6f15ff631f@manitou-mail.org
обсуждение исходный текст
Ответ на Re: COPY FROM WHEN condition  (David Fetter <david@fetter.org>)
Ответы Re: COPY FROM WHEN condition  (Adam Berlin <berlin.ab@gmail.com>)
Список pgsql-hackers
    David Fetter wrote:

> It also seems like a violation of separation of concerns to couple
> FEBE to grammar, so there'd need to be some way to do those things
> separately, too.

After re-reading psql/copy.c, I withdraw what I said upthread:
it doesn't appear necessary to add anything to support the WHEN
condition with \copy.

\copy does have a dedicated mini-parser, but it doesn't try to
recognize every option: it's only concerned with getting the bits of
information that are needed to perform the client-side work:
- whether it's a copy from or to
- what exact form and value has the 'filename' argument immediately
 after from or to:
 '<file path>' | PROGRAM '<command>' | stdin | stdout | pstdout | pstdout

It doesn't really care what the options are, just where they are
in the buffer, so they can be copied into the COPY SQL statement.

From the code:
 * The documented syntax is:
 *    \copy tablename [(columnlist)] from|to filename [options]
 *    \copy ( query stmt ) to filename [options]

The WHEN clause would be part of the [options], which
are handled as simply as this in parse_slash_copy():

  /* Collect the rest of the line (COPY options) */
  token = strtokx(NULL, "", NULL, NULL,
      0, false, false, pset.encoding);
  if (token)
      result->after_tofrom = pg_strdup(token);

So unless there's something particular in the WHEN clause
expression that could make this strtokx() invocation error out,
this should work directly.

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite


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

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: partitioned indexes and tablespaces
Следующее
От: Phil Florent
Дата:
Сообщение: RE: Internal error XX000 with enable_partition_pruning=on, pg 11beta1 on Debian