diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 34743d2d9..93a34ce1c 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -1080,7 +1080,10 @@ def poll(trans_id): rows_affected = conn.rows_affected() st, result = \ - conn.async_fetchmany_2darray(data_result_rows_per_page) + conn.async_fetchmany_2darray(data_result_rows_per_page + 1 + if trans_obj.server_cursor + else data_result_rows_per_page + ) # There may be additional messages even if result is present # eg: Function can provide result as well as RAISE messages @@ -1201,12 +1204,22 @@ def poll(trans_id): if trans_obj is not None and hasattr(trans_obj, 'did') else 0 page_size = rows_fetched_to - rows_fetched_from + 1 + + # Check the next recordset/page is available or not for the server cursor + next_page = 0 + if (trans_obj.server_cursor and result and len(result) > 0 and + len(result) > data_result_rows_per_page): + result = result[0:len(result) - 1] + next_page = 1 + rows_fetched_to = rows_fetched_to - 1 + pagination = { 'page_size': page_size, 'page_count': math.ceil(conn.total_rows / page_size), 'page_no': math.floor((rows_fetched_from - 1) / page_size) + 1, 'rows_from': rows_fetched_from, - 'rows_to': rows_fetched_to + 'rows_to': rows_fetched_to, + 'next_page': next_page } return make_json_response( @@ -1275,7 +1288,7 @@ def fetch_window(trans_id, from_rownum=0, to_rownum=0): page_size = to_rownum - from_rownum + 1 - # Check whether the next recordset/page is available or not + # Check the next recordset/page is available or not for the server cursor next_page = 0 if trans_obj.server_cursor and len(result) > 0 and len(result) > page_size: result = result[0:len(result) - 1] diff --git a/web/pgadmin/utils/driver/psycopg3/cursor.py b/web/pgadmin/utils/driver/psycopg3/cursor.py index 6b00dc8ac..5ab2fa6f2 100644 --- a/web/pgadmin/utils/driver/psycopg3/cursor.py +++ b/web/pgadmin/utils/driver/psycopg3/cursor.py @@ -401,8 +401,8 @@ class AsyncDictServerCursor(AsyncDictCursor, _async_server_cursor): def __init__(self, *args, name=None, **kwargs): self._odt_desc = None - _async_server_cursor.__init__(self, name=name, *args, - row_factory=dict_row) + kwargs['row_factory'] = dict_row + _async_server_cursor.__init__(self, name=name, *args, **kwargs) self.cursor = _async_server_cursor def get_rowcount(self):