diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx index 78f03a41d..3cd612dc0 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx @@ -18,7 +18,7 @@ import { MainToolBar } from './sections/MainToolBar'; import { Messages } from './sections/Messages'; import getApiInstance, {callFetch, parseApiError} from '../../../../../static/js/api_instance'; import url_for from 'sources/url_for'; -import { PANELS, QUERY_TOOL_EVENTS, CONNECTION_STATUS } from './QueryToolConstants'; +import { PANELS, QUERY_TOOL_EVENTS, CONNECTION_STATUS, MAX_QUERY_LENGTH } from './QueryToolConstants'; import { useInterval } from '../../../../../static/js/custom_hooks'; import { Box } from '@material-ui/core'; import { getDatabaseLabel, getTitle, setQueryToolDockerTitle } from '../sqleditor_title'; @@ -391,6 +391,13 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN window.addEventListener('unload', closeConn); const pushHistory = (h)=>{ + // Do not store query text if max lenght exceeds. + if(h?.query?.length > MAX_QUERY_LENGTH) { + h = { + ...h, + query: gettext(`-- Query text not stored as it exceeds maximum length of ${MAX_QUERY_LENGTH}`) + }; + } api.post( url_for('sqleditor.add_query_history', { 'trans_id': qtState.params.trans_id, diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js index a17d4ed31..e959223ca 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolConstants.js @@ -101,3 +101,5 @@ export const PANELS = { HISTORY: 'id-history', GRAPH_VISUALISER: 'id-graph-visualiser', }; + +export const MAX_QUERY_LENGTH = 1000000; \ No newline at end of file diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/QueryHistory.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/QueryHistory.jsx index 8ca7c890f..09421928d 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/QueryHistory.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/QueryHistory.jsx @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////// import { makeStyles } from '@material-ui/styles'; import React from 'react'; -import { PANELS, QUERY_TOOL_EVENTS } from '../QueryToolConstants'; +import { PANELS, QUERY_TOOL_EVENTS, MAX_QUERY_LENGTH } from '../QueryToolConstants'; import gettext from 'sources/gettext'; import pgAdmin from 'sources/pgadmin'; import _ from 'lodash'; @@ -418,6 +418,13 @@ export function QueryHistory() { setLoaderText(''); const pushHistory = (h)=>{ + // Do not store query text if max lenght exceeds. + if(h?.query?.length > MAX_QUERY_LENGTH) { + h = { + ...h, + query: gettext(`-- Query text not stored as it exceeds maximum length of ${MAX_QUERY_LENGTH}`) + }; + } qhu.current.addEntry(h); refresh({}); };