Allow on demand record count setting to be changed per user using preferences. #3275

pull/6129/head
Yogesh Mahajan 2023-04-13 16:43:11 +05:30 committed by GitHub
parent 1131e0f742
commit 993e1eb1b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 184 KiB

View File

@ -440,6 +440,9 @@ preferences for copied data.
* Specify the maximum width of the column in pixels when 'Columns sized by' is
set to *Column data*. If 'Columns sized by' is set to *Column name* then this
setting won't have any effect.
* Specify the number of records to fetch in one batch in query tool when
query result set is large. Changing this value will override
ON_DEMAND_ROW_COUNT setting from config file.
* Use the *Result copy field separator* drop-down listbox to select the field
separator for copied data.
* Use the *Result copy quote character* drop-down listbox to select the quote

View File

@ -16,8 +16,7 @@ from urllib.parse import unquote
from threading import Lock
import json
from config import PG_DEFAULT_DRIVER, ON_DEMAND_RECORD_COUNT,\
ALLOW_SAVE_PASSWORD, SHARED_STORAGE
from config import PG_DEFAULT_DRIVER, ALLOW_SAVE_PASSWORD, SHARED_STORAGE
from werkzeug.user_agent import UserAgent
from flask import Response, url_for, render_template, session, current_app
from flask import request
@ -874,6 +873,8 @@ def poll(trans_id):
additional_messages = None
notifies = None
data_obj = {}
on_demand_record_count = Preferences.module(MODULE_NAME).\
preference('on_demand_record_count').get()
# Check the transaction and connection status
status, error_msg, conn, trans_obj, session_obj = \
@ -910,7 +911,7 @@ def poll(trans_id):
trans_obj.auto_rollback:
conn.execute_void("ROLLBACK;")
st, result = conn.async_fetchmany_2darray(ON_DEMAND_RECORD_COUNT)
st, result = conn.async_fetchmany_2darray(on_demand_record_count)
# There may be additional messages even if result is present
# eg: Function can provide result as well as RAISE messages
@ -986,7 +987,7 @@ def poll(trans_id):
# means nothing to fetch
if result and rows_affected > -1:
res_len = len(result)
if res_len == ON_DEMAND_RECORD_COUNT:
if res_len == on_demand_record_count:
has_more_rows = True
if res_len > 0:
@ -1064,7 +1065,9 @@ def fetch(trans_id, fetch_all=None):
has_more_rows = False
rows_fetched_from = 0
rows_fetched_to = 0
fetch_row_cnt = -1 if fetch_all == 1 else ON_DEMAND_RECORD_COUNT
on_demand_record_count = Preferences.module(MODULE_NAME).preference(
'on_demand_record_count').get()
fetch_row_cnt = -1 if fetch_all == 1 else on_demand_record_count
# Check the transaction and connection status
status, error_msg, conn, trans_obj, session_obj = \
@ -1082,7 +1085,7 @@ def fetch(trans_id, fetch_all=None):
else:
status = 'Success'
res_len = len(result) if result else 0
if fetch_row_cnt != -1 and res_len == ON_DEMAND_RECORD_COUNT:
if fetch_row_cnt != -1 and res_len == on_demand_record_count:
has_more_rows = True
if res_len:

View File

@ -15,6 +15,7 @@ from pgadmin.utils.constants import PREF_LABEL_DISPLAY,\
PREF_LABEL_SQL_FORMATTING, PREF_LABEL_GRAPH_VISUALISER
from pgadmin.utils import SHORTCUT_FIELDS as shortcut_fields, \
ACCESSKEY_FIELDS as accesskey_fields
from config import ON_DEMAND_RECORD_COUNT
def register_query_tool_preferences(self):
@ -292,6 +293,17 @@ def register_query_tool_preferences(self):
),
)
self.on_demand_record_count = self.preference.register(
'Results_grid', 'on_demand_record_count',
gettext("On demand record count"), 'integer', ON_DEMAND_RECORD_COUNT,
min_val=100,
category_label=PREF_LABEL_RESULTS_GRID,
help_str=gettext('Specify the number of records to fetch in one batch '
'in query tool when query result set is large. '
'Changing this value will override '
'ON_DEMAND_ROW_COUNT setting from config file.')
)
self.sql_font_size = self.preference.register(
'Editor', 'sql_font_size',
gettext("Font size"), 'numeric', '1',

View File

@ -569,10 +569,11 @@ def execute_test(test_module_list_passed, server_passed, driver_passed,
print(str(exc))
print("Exception in {0} {1}".format(
threading.current_thread().ident,
threading.current_thread().getName()))
threading.current_thread().name))
# Mark failure as true
global failure
failure = True
if 'is being accessed by other users' not in str(exec):
global failure
failure = True
finally:
# Delete web-driver instance
thread_name = "parallel_tests" + server_passed['name']