Re: FOR integer loop bug?
От | Ron |
---|---|
Тема | Re: FOR integer loop bug? |
Дата | |
Msg-id | 373613a6-7e62-1b03-0010-c0ae55541fd8@gmail.com обсуждение исходный текст |
Ответ на | Re: FOR integer loop bug? (Adrian Klaver <adrian.klaver@aklaver.com>) |
Ответы |
Re: FOR integer loop bug?
|
Список | pgsql-general |
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 <a >> >> 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.
В списке pgsql-general по дате отправления: