Re: Query generates infinite loop

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Richard Wesley <richard(at)duckdblabs(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Query generates infinite loop
Date: 2022-04-20 16:53:33
Message-ID: CAFj8pRDzVzTfsnxs_T9T7k=HW_gWCryo==rVB-AX4R6pXo85xQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi

st 20. 4. 2022 v 18:42 odesílatel Richard Wesley <richard(at)duckdblabs(dot)com>
napsal:

> Hi All -
>
> I was implementing the infinity time constants in DuckDB when I ran into
> an infinite loop. It seems that PG has the same problem for the same reason
> (adding an interval to an infinite timestamp produces the same timestamp,
> so the increment operation never goes anywhere.) Here is the query:
>
> 1.
>
> select COUNT(*) FROM generate_series('-infinity'::TIMESTAMP, 'epoch'::TIMESTAMP, INTERVAL '1 DAY');
>
>
>
> This seems like a DoS great attack, so we are disallowing infinities as
> bounds for both table and scalar series generation. As an upper bound, it
> eventually gives an error, so it seems there is not much utility anyway.
>

There are more ways to achieve the same effect. The protection is safe
setting of temp_file_limit

2022-04-20 09:59:54) postgres=# set temp_file_limit to '1MB';
SET
(2022-04-20 18:51:48) postgres=# select COUNT(*)
FROM generate_series('-infinity'::TIMESTAMP, 'epoch'::TIMESTAMP, INTERVAL
'1 DAY');
ERROR: temporary file size exceeds temp_file_limit (1024kB)
(2022-04-20 18:51:50) postgres=#

Regards

Pavel

>
> Met vriendelijke groet, best regards, mit freundlichen Grüßen,
>
> *Richard Wesley*
> Group-By Therapist
> richard(at)duckdblabs(dot)com
>
>
>
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-04-20 17:03:45 Re: Query generates infinite loop
Previous Message Peter Eisentraut 2022-04-20 16:24:09 Re: BUG #16866: pg_basebackup Windows Server 20160

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-04-20 16:53:50 Re: Fix NULL pointer reference in _outPathTarget()
Previous Message Richard Wesley 2022-04-20 16:17:32 Query generates infinite loop