Steps to reproduce:
DECLARE ctest SCROLL CURSOR FOR SELECT 'aaaaa' FROM(SELECT relname FROM pg_class LIMIT 1) subquery;
FETCH NEXT FROM ctest;
Expected:
DECLARE CURSOR
?column?
----------
aaaaa
(1 row)
Actual:
ERROR: cache lookup failed for relation 0
This reproduced only for LIMIT in subquery. Cursors with subquery without LIMIT or LIMIT not in subquery are processed as expected