Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 1C9A77C454C for ; Wed, 14 Dec 2011 21:48:06 -0400 (AST) Received: from gwmta.wicourts.gov ([165.219.244.99] helo=gw.wicourts.gov) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rb0QU-0006Jp-I2 for pgsql-bugs@postgresql.org; Thu, 15 Dec 2011 01:48:06 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Wed, 14 Dec 2011 19:47:49 -0600 Message-Id: <4EE8FD630200002500043CCD@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Wed, 14 Dec 2011 19:47:46 -0600 From: "Kevin Grittner" To: , Subject: Re: BUG #6336: SQL stored procedure returing 'int' calling into SRF does not raise error ... Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Pg-Spam-Score: -4.4 (----) X-Archive-Number: 201112/105 X-Sequence-Number: 31916 wrote: > calling into generate_series() within a 'returns int' (singular) > SQL stored function doesn't raise error (plpgsql does): > > -- SQL function elides over fact that generate_series() is a SRF > create function foo_sql() > returns int as > $$ > select * from generate_series(1,5) > $$ language sql stable; > > select foo_sql(); > > /* > > whoa --- returns, and just one int. > foo > ----- > 1 > */ This is functioning as designed and documented. The first two sentences of the documentation of SQL functions are: | SQL functions execute an arbitrary list of SQL statements, | returning the result of the last query in the list. In the simple | (non-set) case, the first row of the last query's result will be | returned. http://www.postgresql.org/docs/9.1/interactive/xfunc-sql.html -Kevin