From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: ERROR: query returned no rows |
Date: | 2017-06-26 19:47:38 |
Message-ID: | 9c953e0b-0d95-1e4a-8c25-523382f86c5b@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 06/26/2017 12:03 PM, Paul Jungwirth wrote:
> On 06/26/2017 11:21 AM, Alexander Farber wrote:
>> The error message returned by
>> the database is rather cryptic:
>>
>> words=> select * from words_skip_game(1, 1);
>> ERROR: query returned no rows
>> CONTEXT: PL/pgSQL function words_skip_game(integer,integer) line 85 at
>> SQL statement
>>
>> When I look at my source code
>> ( https://gist.github.com/afarber/cac9a83b7a37307ace8d787be9b8ff4c ) at
>> the line 85, then I am not sure if the line number reported by the error
>> message is correct, because it points into middle of an UPDATE statement:
>
> I agree the line numbers for error messages inside of plpgsql functions
> never seem to make sense, so I wouldn't get too hung up on line 85.
> Perhaps you should see what is line 85 when you do `\sf words_skip_game`
> (rather than line 85 in your own source code). But mostly I would try to
> find some other way of locating the cause of the error.
Or easier yet:
https://www.postgresql.org/docs/9.5/static/app-psql.html
"
\ef [ function_description [ line_number ] ]
This command fetches and edits the definition of the named
function, in the form of a CREATE OR REPLACE FUNCTION command. Editing
is done in the same way as for \edit. After the editor exits, the
updated command waits in the query buffer; type semicolon or \g to send
it, or \r to cancel.
The target function can be specified by name alone, or by name and
arguments, for example foo(integer, text). The argument types must be
given if there is more than one function of the same name.
If no function is specified, a blank CREATE FUNCTION template is
presented for editing.
If a line number is specified, psql will position the cursor on the
specified line of the function body. (Note that the function body
typically does not begin on the first line of the file.)
"
So:
\ef words_skip_game 85
>
> You can read about the "query returned no rows" message here:
>
> https://www.postgresql.org/docs/9.5/static/plpgsql-statements.html
>
> It seems to me you should only see it for `INTO STRICT`, not plain
> `INTO`. I see from your gist that your function *does* have some queries
> that are `INTO STRICT`, so I would focus on those.
>
> That page also describes how to use `print_strict_params` to get a
> little more info about the details of the error.
>
> I hope that helps!
>
> Paul
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Fulton | 2017-06-26 20:06:43 | When inserting from a SELECT with an ORDER BY, are the inserts (and associated triggers) applied in order? |
Previous Message | Paul Jungwirth | 2017-06-26 19:03:30 | Re: ERROR: query returned no rows |