1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-23 14:01:44 +03:00

Add COPY WITH CVS HEADER to allow a heading line as the first line in

COPY.

Andrew Dunstan
This commit is contained in:
Bruce Momjian
2005-05-07 02:22:49 +00:00
parent ce1ab398dd
commit b63990c6a8
6 changed files with 92 additions and 20 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.56 2005/02/22 04:40:54 momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.57 2005/05/07 02:22:49 momjian Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
@ -66,6 +66,7 @@ struct copy_options
bool binary;
bool oids;
bool csv_mode;
bool header;
char *delim;
char *null;
char *quote;
@ -289,6 +290,8 @@ parse_slash_copy(const char *args)
result->oids = true;
else if (pg_strcasecmp(token, "csv") == 0)
result->csv_mode = true;
else if (pg_strcasecmp(token, "header") == 0)
result->header = true;
else if (pg_strcasecmp(token, "delimiter") == 0)
{
token = strtokx(NULL, whitespace, NULL, "'",
@ -481,6 +484,9 @@ do_copy(const char *args)
if (options->csv_mode)
appendPQExpBuffer(&query, " CSV");
if (options->header)
appendPQExpBuffer(&query, " HEADER");
if (options->quote)
{
if (options->quote[0] == '\'')