Fails to add function from file with \i in psql

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Fails to add function from file with \i in psql
Date: 2000-11-26 20:28:24
Message-ID: 200011262028.eAQKSOa69700@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Roland Szabo (szroland(at)freemail(dot)hu) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Fails to add function from file with \i in psql

Long Description
For maintainance reasons, sql statements for our databases are saved in files, and upon installation, are executed via \i file.sql from psql. In postgres 7.3, we've encountered the following problem:

In file trigger.sql, we create a trigger, and the function to be executed. (The list is in the example code part).
We execute this with \i trigger.sql. No problems so far. Trying a simple insert statement though (from triggertest.sql):

insert into pszlfej
(szsuf, szsth, szsui, szuuf, szuth, szuui)
values
(1,1,1,1,1,1);

yields to an error:
psql:triggertest.sql:4: NOTICE: plpgsql: ERROR during compile of c_fnc
near line 1
"sql:triggertest.sql:4: ERROR: parse error at or near "

You say, there must be a syntax error in trigger.sql. But if we copy-paste the content of trigger.sql into psql, and execute it there (same as typing it), the function and trigger are created, and the insert statement also works.

That means, the statements work just fine, and the error is most likely to be in psql.

Sample Code
trigger.sql:
drop function c_fnc();
create function c_fnc() returns opaque as '
begin
new.cdat := ''now'';
new.cusr := getpgusername();
return new;
end;
' language 'plpgsql';

drop trigger pszt_c_trig on pszltet;
create trigger pszt_c_trig before insert
on pszltet for each row execute procedure c_fnc();

No file was uploaded with this report

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2000-11-26 20:46:52 Special character pervents psql from parsing?
Previous Message Tom Lane 2000-11-26 18:27:25 Re: CHECK evaluation error when using more than one table