Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYmJv-0002ID-Nz for pgsql-general@arkaria.postgresql.org; Tue, 09 Jan 2018 05:19:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYmJv-0003ah-9r for pgsql-general@arkaria.postgresql.org; Tue, 09 Jan 2018 05:19:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eYmJu-0003aX-G4 for pgsql-general@lists.postgresql.org; Tue, 09 Jan 2018 05:19:31 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eYmJq-0003Ol-SM for pgsql-general@postgresql.org; Tue, 09 Jan 2018 05:19:29 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 80EEF20C3C; Tue, 9 Jan 2018 00:19:25 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Tue, 09 Jan 2018 00:19:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=TzUzFVabKQEOuFOBor7PsxnLWOLJg Uj9g4an+P5e1p8=; b=Kk2pQpTcYjBMWJgAwr9LzMvBhQXF0AQiZjUYJU0GdNTy0 8r/9Q3IQXa8L+vS2CQDbV7jFy/XCUPNJ2MVEn0PNTV2mnfaK1ErZ7loOfdroMYBN YQYfXTe1QzXGNYZ8Yl9sW/WKccDSmMBaPYCu7SrsfBMCgkdjya8SjQmNQwHQOeCn dVIdPjfpNUkjnFcdAXAmFraJX31yIG56sV8tkmGtQzDdSmgXZiRYUkYZZ06OpVyC FIexjDaUGtFgClxW5HCaaKHlI9AHhLlpJNBMJQBwusFZ/WsiQfEwjLBBwIbfYW/s MmxJUd51BVfOK16CrmsIKq4qUdjSKMr8wUKqOP0Kg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=TzUzFV abKQEOuFOBor7PsxnLWOLJgUj9g4an+P5e1p8=; b=YhGpFNB8TnZk3ePxWPrXeR zbWWXWisGnvqzJTLTshyAM6bTzvGu24REUbEXx4qYOLHKi8InfUfcREiEInenEC6 Q1OIlVmfaVpcxx3VoaT4HRxVIrDGsdQYfbI/h9DLc8cKcsZUwTKIMptUnIM2VJWl VhmRCEXfflKd0wQv4iJK5nsieX/uvef9AWhZWq9qjepCasmp24mhrPYpAg22Tl5A AkIR1GQGA7zUKAP0B95jf+dmBBSZsEZr++VLw3q08XaX/nqavG6knY1LAWCODMv3 Mo1aMNR94VPG9nqozHbTJPTc65y6iZeyPee3wUkBzTK8pkySKCsvbD81b78nY/VQ == X-ME-Sender: Received: from [192.168.1.3] (unknown [67.40.177.89]) by mail.messagingengine.com (Postfix) with ESMTPA id F308F7E353; Tue, 9 Jan 2018 00:19:24 -0500 (EST) Subject: Re: help with generation_series in pg10 To: =?UTF-8?Q?M=c3=a1rcio_A._Sepp?= , 'pgsql-general' References: <00bb01d388e8$c9607b50$5c2171f0$@com.br> From: Adrian Klaver Message-ID: <30ff61ea-448c-0829-fa45-e769d25cfc05@aklaver.com> Date: Mon, 8 Jan 2018 21:19:24 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <00bb01d388e8$c9607b50$5c2171f0$@com.br> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 01/08/2018 05:25 PM, Márcio A. Sepp wrote: > > Hi, > > > In pg10 generation series doesn't work like in 9.5. > Ex. in 9.5: > z=# select generate_series(1, 10), generate_series(1, 5); > generate_series | generate_series > -----------------+----------------- > 1 | 1 > 2 | 2 > 3 | 3 > 4 | 4 > 5 | 5 > 6 | 1 > 7 | 2 > 8 | 3 > 9 | 4 > 10 | 5 > (10 registros) > > > so, in version 10 the same sql show different result set. The reason why: https://www.postgresql.org/docs/10/static/release-10.html#idm46428657945600 Change the implementation of set-returning functions appearing in a query's SELECT list (Andres Freund) Set-returning functions are now evaluated before evaluation of scalar expressions in the SELECT list, much as though they had been placed in a LATERAL FROM-clause item. This allows saner semantics for cases where multiple set-returning functions are present. If they return different numbers of rows, the shorter results are extended to match the longest result by adding nulls. Previously the results were cycled until they all terminated at the same time, producing a number of rows equal to the least common multiple of the functions' periods. In addition, set-returning functions are now disallowed within CASE and COALESCE constructs. For more information see Section 37.4.8. > z=# select generate_series(1, 10), generate_series(1,5); > generate_series | generate_series > -----------------+----------------- > 1 | 1 > 2 | 2 > 3 | 3 > 4 | 4 > 5 | 5 > 6 | > 7 | > 8 | > 9 | > 10 | > (10 registros) > > > how can i have the same in pg10 as i have had in pg 9.x? I went to section 37.4.8: https://www.postgresql.org/docs/10/static/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-SET I am not seeing a solution, but you might see something that would help you. > > I need it to date type to... if possible. > > > -- > Att. > Márcio A. Sepp > > > -- Adrian Klaver adrian.klaver@aklaver.com