Re: Re: Support plpgsql multi-range in conditional control

From: songjinzhou <2903807914(at)qq(dot)com>
To: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Re: Support plpgsql multi-range in conditional control
Date: 2023-01-25 16:22:06
Message-ID: tencent_F73F65A793C76C98BC361AAF12ACC134A008@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


>Hi

>st 25. 1. 2023 v 16:39 odesílatel songjinzhou <2903807914(at)qq(dot)com> napsal: Hello, my personal understanding is that you can use multiple iterative controls (as a merge) in a fo loop, otherwise we can only separate these iterative controls, but in fact, they may do the same thing.

>1. please, don't use top posting in this mailing list https://en.wikipedia.org/wiki/Posting_styl

>2. I understand the functionality, but I don't think there is a real necessity to support this functionality. Not in this static form, and just for integer type.

>Postgres has a nice generic type "multirange". I can imagine some iterator over the value of multirange, but I cannot imagine the necessity of a richer iterator over just integer range. So the question is, what is the real possible use case of this proposed functionality?

1. I'm very sorry that my personal negligence has caused obstacles to your reading. Thank you for your reminding.
2. With regard to the use of this function, my understanding is relatively simple: there are many for loops that may do the same things. We can reduce our sql redundancy by merging iterative control; It is also more convenient to understand and read logically.

As follows, we can only repeat the for statement before we use such SQL:

begin
for i in 10..20 loop
raise notice '%', i; -- Things to do
end loop;

for i in 100 .. 200 by 10 loop
raise notice '%', i; -- Things to do
end loop;
end;

But now we can simplify it as follows:

begin
for i in 10..20, 100 .. 200 by 10 loop
raise notice '%', i; -- Things to do
end loop;
end;

Although we can only use integer iterative control here, this is just a horizontal expansion of the previous logic. Thank you very much for your reply. I am very grateful!

---

songjinzhou(2903807914(at)qq(dot)com)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-01-25 16:49:27 Re: wake up logical workers after ALTER SUBSCRIPTION
Previous Message Andrew Dunstan 2023-01-25 16:01:14 Re: More pgindent tweaks