Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nctGK-0002bL-L3 for pgsql-general@arkaria.postgresql.org; Fri, 08 Apr 2022 18:23:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nctGI-0004Uq-Uh for pgsql-general@arkaria.postgresql.org; Fri, 08 Apr 2022 18:23:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nctGI-0004Uh-Kc for pgsql-general@lists.postgresql.org; Fri, 08 Apr 2022 18:23:10 +0000 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nctGG-0004lI-BN for pgsql-general@lists.postgresql.org; Fri, 08 Apr 2022 18:23:09 +0000 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-df22f50e0cso10585550fac.3 for ; Fri, 08 Apr 2022 11:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=9j5/9XoQGx9ke11ZLUSHklQhSrHZV3AQW+XRmXi9Tu8=; b=bBTnxqcnxj2nCY4kaW41mXCH9TJdCcbjE68/GDjDdrJJcBTK+r/YYmwRFZHb5F+YAX x36TwHbFdllEedahqcO6VTFPR5nTKB1WRPgB83lXGH+EMDRvorhypjAu72bPRQLM3G65 9lKp3f9cxCDJ15Hs+KLRQunHaD26iKPmf1alLewATQNXBALVPO2MmjzgWH2OO9LZPwXf ivKOr7p0g/9rH+NzC+yTO/+cP1S8Jz0uyC/mRsiPy3/dP2XogxdzP95iaZG8CKsqTxu0 lysJwTg2Icl3JH3puVbuTkKpzg3/Loxs+qBcM7WC/ITgCbLgZN4xPsape7vAtm9AqKvA gBNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=9j5/9XoQGx9ke11ZLUSHklQhSrHZV3AQW+XRmXi9Tu8=; b=49ln/5Imfi9ijtiNgX8jM0qoYxfyf2b98Q0Azn2iop0CsCg5wlJjmLLWV6ZitBoe1/ xD0u598SAE/EutSTI+/ARfot3uxN01uo++8Mfvp2UeX8LhJQ/+rCuhHso9EEtKTvdWr2 zJI2k3QUdZ4bqP3FgjLKmwcJwlbyCmnf8MW8XlGOTh5AjfJIKIslaFbkEf+8QjjZgNxq 3wl8jzOJbvLK68pNvV8ub7okwWgdH9mtvRPuFdAJbyLkAHsz9so0ImVsBaUPiJRNnbzG GZMqYfcSjrzJEstRlh4rYZlSl5P5nSBaULEE8sQZil2QQO6UxgUTnQOFgnm0073rORvf TNSw== X-Gm-Message-State: AOAM5310WcOwwe8FpR+3uBgZS2Qk1YH80qLcBAAAJ1Pv/obFyR0U6zGZ c9R8QVcy17eezDqz7heOc+nyDi65z68= X-Google-Smtp-Source: ABdhPJwxZx8T6Ah1UDzN06cBKID0CzcwDSOYDFw26nB7gRoOUXK2ErU5dNZ083g1DWgeZ0WslM0vtg== X-Received: by 2002:a05:6870:fba7:b0:e2:fa0:e04f with SMTP id kv39-20020a056870fba700b000e20fa0e04fmr9197175oab.230.1649442187301; Fri, 08 Apr 2022 11:23:07 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id p11-20020acabf0b000000b002ef93581a46sm8809198oif.2.2022.04.08.11.23.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Apr 2022 11:23:06 -0700 (PDT) Message-ID: <373613a6-7e62-1b03-0010-c0ae55541fd8@gmail.com> Date: Fri, 8 Apr 2022 13:23:06 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: FOR integer loop bug? Content-Language: en-US To: pgsql-general@lists.postgresql.org References: From: Ron In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/8/22 13:07, Adrian Klaver wrote: > On 4/8/22 10:58 AM, Pavel Stehule wrote: >> >> >> pá 8. 4. 2022 v 19:56 odesílatel Adrian Klaver > >>     Why is the three period form allowed through and why does it produce no >>     result? >> >> >> Maybe >> >> (2022-04-08 19:57:57) postgres=# select .10; >> ┌──────────┐ >> │ ?column? │ >> ╞══════════╡ >> │     0.10 │ >> └──────────┘ >> (1 row) > > Alright so 1...10 is taken as 1::integer .. 0.10::integer CAST results in > 0 and ends up as 1..0. This then is covered by: > > "If the lower bound is greater than the upper bound (or less than, in the > REVERSE case), the loop body is not executed at all. No error is raised." > > Confirmed by: > > CREATE OR REPLACE FUNCTION utility.for_loop_test() >  RETURNS void >  LANGUAGE plpgsql > AS $function$ > BEGIN >     FOR i IN REVERSE  1...10 LOOP >         RAISE NOTICE '%', i; >     END LOOP; > END; > > $function$ > ; > > select for_loop_test(); > NOTICE:  1 > NOTICE:  0 >  for_loop_test > --------------- > > Hmm, I'm going to have to think on this. The only thinking is: "That's a bug waiting to happen!" -- Angular momentum makes the world go 'round.