Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"RETURNS SETOF record LANGUAGE" causes error #143

Open
reggi opened this issue Nov 2, 2023 · 1 comment
Open

"RETURNS SETOF record LANGUAGE" causes error #143

reggi opened this issue Nov 2, 2023 · 1 comment

Comments

@reggi
Copy link

reggi commented Nov 2, 2023

CREATE OR REPLACE FUNCTION schema_identifier_split(url_path TEXT, OUT scope TEXT, OUT plugin TEXT, OUT name TEXT, OUT version INT)
RETURNS SETOF record LANGUAGE plpgsql AS $$
DECLARE
  parts TEXT[];
BEGIN
  parts := string_to_array(url_path, '/');
  scope := parts[1];
  plugin := parts[2];
  name := parts[3];
  IF array_length(parts, 1) > 3 THEN
    version := parts[4]::INT;
  ELSE
    version := NULL;
  END IF;
  RETURN NEXT;
END;
$$;
error: Uncaught (in promise) Error: Syntax error at line 2 col 22:

  RETURNS SETOF record LANGUAGE
                       ^
Unexpected word token: "language". I did not expect any more input. Here is the state of my parse table:

    kw_returns → %word ● 
    word → %word ● 
    kw_language → %word ● 
    func_spec$subexpression$2 → word ● 
    func_spec$subexpression$5 → word ● 
    func_spec$subexpression$4 → word ● 
    func_spec$subexpression$3 → word ● 
    func_purity → word ● 

                var err = new Error(this.reportError(token));
                          ^
    at Parser.feed (https://deno.land/x/[email protected]/lib/nearley.js:337:27)
    at _parse (https://deno.land/x/[email protected]/parser.ts:110:16)
    at doParse (https://deno.land/x/[email protected]/parser.ts:57:27)
    at parse (https://deno.land/x/[email protected]/parser.ts:60:11)
    at getSQLFile (file:///Users/thomasreggi/Documents/GitHub/pgrun/mod.ts:35:28)
    at readSqlFile (file:///Users/thomasreggi/Documents/GitHub/pgrun/mod.ts:74:10)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async Promise.all (index 45)
    at async readSQLFiles (file:///Users/thomasreggi/Documents/GitHub/pgrun/mod.ts:86:17)
    at async organizer (file:///Users/thomasreggi/Documents/GitHub/pgrun/mod.ts:266:17)
@alexporrello
Copy link

It seems this is not limited to "LANGUAGE," but rather an issue with SETOF. The following also errors:

RETURNS SETOF refcursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants