Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 4D12843CEB9 for ; Thu, 19 Jan 2012 15:42:33 -0400 (AST) Received: from mail-gx0-f174.google.com ([209.85.161.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RnxsT-0003bm-M3 for pgsql-sql@postgresql.org; Thu, 19 Jan 2012 19:42:33 +0000 Received: by ggnb1 with SMTP id b1so229815ggn.19 for ; Thu, 19 Jan 2012 11:42:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=sKRHC42vr1yDIgCqxJl91QUs71fUoc2OKtFvUatDcnk=; b=En2kAOHhhAuT0r7CtIW6Q2eaf4sWdWxPZvlwWo++1BCkD1Mnqi40vOjHcGGhz8ChEU 9AVvtOKa6w4wijl24vfcGEg1mHouxDEQjFuDNdRe0bNxIGrnaRIKmbSk7u4udc40gdL1 8svjoZHfcRI2E92pLF1vqyDGZgyPBgHUo91y4= Received: by 10.50.222.193 with SMTP id qo1mr29306898igc.22.1327002136929; Thu, 19 Jan 2012 11:42:16 -0800 (PST) Received: from [192.168.200.17] ([74.94.73.222]) by mx.google.com with ESMTPS id h9sm1093416ibh.11.2012.01.19.11.42.15 (version=SSLv3 cipher=OTHER); Thu, 19 Jan 2012 11:42:16 -0800 (PST) Message-ID: <4F187214.1010306@gmail.com> Date: Thu, 19 Jan 2012 11:42:12 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Samuel Gendler CC: pgsql-sql@postgresql.org, Gary Stainburn Subject: Re: date range to set of dates expansion References: <201201190713.34333.gary.stainburn@ringways.co.uk> <201201191516.16802.gary.stainburn@ringways.co.uk> <201201191559.27698.gary.stainburn@ringways.co.uk> <201201190820.06564.adrian.klaver@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201201/95 X-Sequence-Number: 36266 On 01/19/2012 09:17 AM, Samuel Gendler wrote: > > > On Thu, Jan 19, 2012 at 8:20 AM, Adrian Klaver > wrote: > > On Thursday, January 19, 2012 7:59:27 am Gary Stainburn wrote: > > The following code works in 8.4 but not 8.3. > > Anyone know why, or what I need to do to change it? > > > > SELECT aid, asid, > > date_range (asdate, afdate)::date AS asdate, > > acomments > > FROM availability > > > > In 8.4 it returns the expanded dataset as required. In 8.3 I get: > > > > ERROR: set-valued function called in context that cannot accept > a set > > CONTEXT: PL/pgSQL function "date_range" line 4 at RETURN NEXT > > As to why it works in 8.4 vs 8.3 > > http://www.postgresql.org/docs/8.4/interactive/release-8-4.html > > "Support set-returning functions in SELECT result lists even for > functions that > return their result via a tuplestore (Tom) > > In particular, this means that functions written in PL/pgSQL and > other PL > languages can now be called this way.' > > In 8.3- I believe you could only call it as > > SELECT * from date_range (asdate, afdate)::date AS asdate; > > > I don't think you can have that cast there when it is in the > from-clause. That was a cut and paste error on my part, I just copied that line from the original query. > -- Adrian Klaver adrian.klaver@gmail.com