Issue #22222:fix recursive query for older pgsql versions