From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
Cc: | "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>, Andreas Kretschmer <akretschmer(at)spamfence(dot)net>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: loading a funtion script from a file |
Date: | 2007-11-21 17:51:03 |
Message-ID: | 47447007.6000908@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Scott Marlowe wrote:
> On Nov 21, 2007 11:16 AM, Richard Huxton <dev(at)archonet(dot)com> wrote:
>> Scott Marlowe wrote:
>>> On Nov 21, 2007 10:49 AM, Richard Huxton <dev(at)archonet(dot)com> wrote:
>>>> Or just put everything in one file and use -f <filename>
>>> And from the more than one way to skin a cat department:
>>>
>>> cat my.sql | psql mydb
>>> psql mydb < my.sql
>> Bearing in mind that although both mine and Scott's cats are skinless,
>> mine gave me line numbers in error messages.
>
> So do both of mine... In fact, trying all four ways (\i, cat | psql,
> psql < file.sql, and psql -f file) gave me the same error output.
Hmm - never used to... (checks)
Can't get the same here (v8.2) apart from the COPY errors.
=== begin test1.sql ===
BEGIN;
CREATE TABLE test1 (a int, b text, PRIMARY KEY (a)) ;
COPY test1 FROM STDIN;
1 AAA
2 BBB
3 CCC
1 AAA
\.
SELCT true;
ROLLBACK;
=== end test1.sql ===
$ psql82 -U richardh -f test1.sql
BEGIN
psql:test1.sql:3: NOTICE: CREATE TABLE / PRIMARY KEY will create
implicit index "test1_pkey" for table "test1"
CREATE TABLE
psql:test1.sql:10: ERROR: duplicate key violates unique constraint
"test1_pkey"
CONTEXT: COPY test1, line 4: "1 AAA"
psql:test1.sql:12: ERROR: syntax error at or near "SELCT"
LINE 1: SELCT true;
^
ROLLBACK
$ cat test1.sql | psql82 -U richardh
BEGIN
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"test1_pkey" for table "test1"
CREATE TABLE
ERROR: duplicate key violates unique constraint "test1_pkey"
CONTEXT: COPY test1, line 4: "1 AAA"
ERROR: syntax error at or near "SELCT"
LINE 1: SELCT true;
^
ROLLBACK
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | SHARMILA JOTHIRAJAH | 2007-11-21 17:51:22 | Re: Postgres table size |
Previous Message | Marco Colombo | 2007-11-21 17:44:22 | Re: Restart a sequence regularly |