Search Postgresql Archives

Re: loading a funtion script from a file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Scott Marlowe wrote:
On Nov 21, 2007 11:16 AM, Richard Huxton <dev@xxxxxxxxxxxx> wrote:
Scott Marlowe wrote:
On Nov 21, 2007 10:49 AM, Richard Huxton <dev@xxxxxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux