Re: [bug report] A sql statements make query hang

Tom Lane <[email protected]> Mon, 06 Jan 2020 01:50:33 -0500
Newsgroups gmane.comp.db.postgresql.bugs
Message-ID <[email protected]>
Rui Zhong <[email protected]> writes:
> When we run follow statements make query hang and never return in
> PostgreSQL 13devel, we consider it might be a bug of PostgreSQL and report
> it.

> CREATE TEMPORARY TABLE v0 ( v1 INT UNIQUE ) ;

> WITH RECURSIVE v0 ( v1 ) AS ( SELECT -128 UNION SELECT v1 + 33 FROM v0 )
> SELECT 'x' from v0;

That's an infinite recursion, so I'm not sure why you think there's
a server bug here.

In practice, I think you'd get an integer overflow error after
awhile, where "awhile" is defined as INT_MAX/33 recursions.
It might take considerable patience to reach that point though.
(And when you did, it still wouldn't be a bug.  The calculation
specified by this query must eventually overflow any finite
arithmetic.)

> When we run in mysql, it suddenly return an empty set.

Hardly requires commentary.

			regards, tom lane