It seems that 8.0B4's plpgsql does not diagnose 'ELSIF' being misspelled as 'ELSEIF' nearly as readily as did 7.4.x. 7.4 emits a compile error at the right place, whereas 8.0b4 seems to treat misspelled 'ELSEIF' blocks as unreachable code, making it quite hard to diagnose what is actually amiss. If not plpgsql coding often, the difference in spelling can be rather hard to see even when staring at the docs.

Attached is a sample script used to massage data in a table from a bad representation to a little better one (with misspellings in place). Here's a minimal table definition to run it:

        create table unit (
                id int8 not null primary key,
                pets boolean not null,
                petscondition text
        );

        insert into unit values (1, true, 'Outside Only');

8.0B4 results:
[dynamic-94:~/cvs/social/misc-db-utils] jlrobins% psql < pets.sql
BEGIN
ALTER TABLE
CREATE FUNCTION
ERROR: No code determined for unit 1, t, "Outside Only"
ERROR: current transaction is aborted, commands ignored until end of transaction block
ERROR: current transaction is aborted, commands ignored until end of transaction block
ERROR: current transaction is aborted, commands ignored until end of transaction block
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK


7.4.6 results:
xs2 /tmp> psql ssc_sav < pets.sql
BEGIN
ALTER TABLE
CREATE FUNCTION
ERROR: syntax error at or near "ELSEIF" at character 1
CONTEXT: PL/pgSQL function "fix_pets" line 16 at SQL statement
ERROR: current transaction is aborted, commands ignored until end of transaction block
ERROR: current transaction is aborted, commands ignored until end of transaction block
ERROR: current transaction is aborted, commands ignored until end of transaction block
ERROR: current transaction is aborted, commands ignored until end of transaction block
COMMIT

Many thanks in advance,

James



Attachment: pets.sql
Description: Binary data



----
James Robinson
Socialserve.com
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to