Skip to content

Functions that declare a non-trivial cursor fail to compile #45

@hawicz

Description

@hawicz

A function that looks like this:

create or replace function foo()
returns void
language plpgsql
as $$
DECLARE
   DECLARE mycur CURSOR FOR SELECT * from pg_database;
BEGIN
   return;
END;
$$;

Results in:

        ****
        Error compiling procedure public.foo
        Source: /home/user/piggly/cache/Dumper/511efb81e82810ddd8b9359d7c6a7758.plpgsql
        Exception Message:
        Expected one of [ \t\n\v\f\r], 'as', 'not', ':=', '=', '(', '[', [a-z\200-\377_0-9$%], '/*', '--', ';' at line 2, column 36 (byte 44) after declare

declare mycur cursor for select
****

On the other hand, changing it to say "... SELECT 1..." instead of "...SELECT *..." works (though of course it's not very useful to have a query that does effectively nothing).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions