Re: query has no destination for result data

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: query has no destination for result data
Date: 2019-03-06 14:37:05
Message-ID: E95DE63B-0119-401C-94B7-5FFDB3F1F0B1@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Mar 6, 2019, at 6:29 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Rob Sargent <robjsargent(at)gmail(dot)com> writes:
>> One of my plpgsql functions is now throwing this error:
>
>> ERROR: query has no destination for result data
>> HINT: If you want to discard the results of a SELECT, use PERFORM instead.
>> CONTEXT: PL/pgSQL function optimal_pvalue_mono(text,text,integer,double precision,integer) line 65 at SQL statement
>
>> The code referenced at line 65 is the last line in a "for row in query” construct as follows:
>> 54 for segp in
>> 55 select s.id, s.firstmarker, s.lastmarker,
>> 56 v.ipv,
>> 57 array_length(p.probands,1) as pbs,
>> 58 s.lastmarker - s.firstmarker as mks
>> 59 from segment s
>> 60 join imputed_pvalue_t v on s.id = v.segment_id
>> 61 join probandset p on s.probandset_id = p.id
>> 62 join probandset_group_member m on p.id = m.member_id
>> 63 where s.markerset_id = mkset
>> 64 and m.group_id = pbsgid
>> 65 order by ipv, pbs, mks
>> 66 LOOP
>
> I think perhaps you've miscounted lines somehow, or are looking into
> the wrong function. The "at SQL statement" bit indicates that plpgsql
> thinks it's dealing with a run-of-the-mill SQL command, not a FOR loop;
> moreover, looking at the source code shows that "query has no destination
> for result data" is thrown only in exec_stmt_execsql, which ditto.
>
> Another possibility, perhaps, is that there's some syntax error a little
> bit above what you've shown us, such that this stanza isn't being seen
> as a FOR loop at all, but as more lines in a SQL command that started
> earlier. I'm not entirely sure how such a case would have got past
> parsing and into execution, but it's worth thinking about.
>
> In any case, this isn't solvable with just what you've shown us here.
>
> regards, tom lane

Thank you sir, I shall keep digging. If it comes to that I can certainly share all three functions involved. I presume the answer to the issue of a zero row result is No it won’t cause this error.

@Ron: Did you hit send a little early?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2019-03-06 15:12:53 Re: query has no destination for result data
Previous Message Ron 2019-03-06 14:32:51 Re: query has no destination for result data