pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rob Sargent <robjsargent@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: query has no destination for result data
Date: Wed, 06 Mar 2019 09:29:03 -0500
Message-ID: <16224.1551882543@sss.pgh.pa.us> (raw)
In-Reply-To: <A8036BFA-C490-4E2E-819D-BD655CDAC364@gmail.com>
References: <A8036BFA-C490-4E2E-819D-BD655CDAC364@gmail.com>

Rob Sargent <robjsargent@gmail.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




view thread (12+ messages)  latest in thread

Message-ID: <16224.1551882543@sss.pgh.pa.us>
Permalink:  ../16224.1551882543@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16224.1551882543@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robjsargent@gmail.com
  Subject: Re: query has no destination for result data
  In-Reply-To: <16224.1551882543@sss.pgh.pa.us>
  References: <A8036BFA-C490-4E2E-819D-BD655CDAC364@gmail.com> <16224.1551882543@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox