[bug report] A sql statements make query hang

Started by Rui Zhongover 6 years ago2 messagesbugs
Jump to latest
#1Rui Zhong
reversezr33@gmail.com

Hi,

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;

-------

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

Best,

Yongheng & Rui

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rui Zhong (#1)
Re: [bug report] A sql statements make query hang

Rui Zhong <reversezr33@gmail.com> 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