mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where the user is unable to create an index with concurrently keyword. Fixes #6790
This commit is contained in:
parent
9fd9ca2673
commit
5b9383c880
@ -23,6 +23,7 @@ Bug fixes
|
|||||||
|
|
||||||
| `Issue #6719 <https://redmine.postgresql.org/issues/6719>`_ - Fixed OAuth2 integration redirect issue.
|
| `Issue #6719 <https://redmine.postgresql.org/issues/6719>`_ - Fixed OAuth2 integration redirect issue.
|
||||||
| `Issue #6754 <https://redmine.postgresql.org/issues/6754>`_ - Ensure that query highlighting color in the query tool should be less intensive.
|
| `Issue #6754 <https://redmine.postgresql.org/issues/6754>`_ - Ensure that query highlighting color in the query tool should be less intensive.
|
||||||
|
| `Issue #6790 <https://redmine.postgresql.org/issues/6790>`_ - Fixed an issue where the user is unable to create an index with concurrently keyword.
|
||||||
| `Issue #6797 <https://redmine.postgresql.org/issues/6797>`_ - Remove an extra blank line at the start of the SQL for function, procedure, and trigger function.
|
| `Issue #6797 <https://redmine.postgresql.org/issues/6797>`_ - Remove an extra blank line at the start of the SQL for function, procedure, and trigger function.
|
||||||
| `Issue #6828 <https://redmine.postgresql.org/issues/6828>`_ - Fixed an issue where the tree is not scrolling to the object selected from the search result.
|
| `Issue #6828 <https://redmine.postgresql.org/issues/6828>`_ - Fixed an issue where the tree is not scrolling to the object selected from the search result.
|
||||||
| `Issue #6881 <https://redmine.postgresql.org/issues/6881>`_ - Fixed an issue where the browser tree doesn't show all contents on changing resolution.
|
| `Issue #6881 <https://redmine.postgresql.org/issues/6881>`_ - Fixed an issue where the browser tree doesn't show all contents on changing resolution.
|
||||||
|
@ -605,8 +605,12 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
return gone(gettext(self.not_found_error_msg('Table')))
|
return gone(gettext(self.not_found_error_msg('Table')))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Start transaction.
|
# If user chooses concurrent index then we cannot run it inside
|
||||||
self.conn.execute_scalar("BEGIN;")
|
# a transaction block.
|
||||||
|
# Don't start transaction if isconcurrent is True
|
||||||
|
if hasattr(data, "isconcurrent") and not data['isconcurrent']:
|
||||||
|
# Start transaction.
|
||||||
|
self.conn.execute_scalar("BEGIN;")
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._CREATE_SQL]),
|
"/".join([self.template_path, self._CREATE_SQL]),
|
||||||
data=data, conn=self.conn, mode='create'
|
data=data, conn=self.conn, mode='create'
|
||||||
@ -614,7 +618,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
# End transaction.
|
# End transaction.
|
||||||
self.conn.execute_scalar("END;")
|
if hasattr(data, "isconcurrent") and not data['isconcurrent']:
|
||||||
|
self.conn.execute_scalar("END;")
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
|
||||||
# If user chooses concurrent index then we cannot run it along
|
# If user chooses concurrent index then we cannot run it along
|
||||||
@ -627,8 +632,10 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
if SQL != '':
|
if SQL != '':
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
# End transaction.
|
if hasattr(data, "isconcurrent") and not data[
|
||||||
self.conn.execute_scalar("END;")
|
'isconcurrent']:
|
||||||
|
# End transaction.
|
||||||
|
self.conn.execute_scalar("END;")
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
|
||||||
# we need oid to add object in tree at browser
|
# we need oid to add object in tree at browser
|
||||||
@ -638,12 +645,14 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
status, idx = self.conn.execute_scalar(SQL)
|
status, idx = self.conn.execute_scalar(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
# End transaction.
|
if hasattr(data, "isconcurrent") and not data['isconcurrent']:
|
||||||
self.conn.execute_scalar("END;")
|
# End transaction.
|
||||||
|
self.conn.execute_scalar("END;")
|
||||||
return internal_server_error(errormsg=tid)
|
return internal_server_error(errormsg=tid)
|
||||||
|
|
||||||
# End transaction.
|
if hasattr(data, "isconcurrent") and not data['isconcurrent']:
|
||||||
self.conn.execute_scalar("END;")
|
# End transaction.
|
||||||
|
self.conn.execute_scalar("END;")
|
||||||
return jsonify(
|
return jsonify(
|
||||||
node=self.blueprint.generate_browser_node(
|
node=self.blueprint.generate_browser_node(
|
||||||
idx,
|
idx,
|
||||||
@ -653,8 +662,9 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# End transaction.
|
if hasattr(data, "isconcurrent") and not data['isconcurrent']:
|
||||||
self.conn.execute_scalar("END;")
|
# End transaction.
|
||||||
|
self.conn.execute_scalar("END;")
|
||||||
return internal_server_error(errormsg=str(e))
|
return internal_server_error(errormsg=str(e))
|
||||||
|
|
||||||
@check_precondition
|
@check_precondition
|
||||||
|
@ -113,7 +113,7 @@ export class ColumnSchema extends BaseUISchema {
|
|||||||
* to access method selected by user if not selected
|
* to access method selected by user if not selected
|
||||||
* send btree related op_class options
|
* send btree related op_class options
|
||||||
*/
|
*/
|
||||||
var amname = columnSchemaObj._top._sessData ? columnSchemaObj._top._sessData.amname : columnSchemaObj._top._origData.amname;
|
var amname = columnSchemaObj._top?._sessData ? columnSchemaObj._top?._sessData.amname : columnSchemaObj._top?._origData.amname;
|
||||||
|
|
||||||
if(_.isUndefined(amname))
|
if(_.isUndefined(amname))
|
||||||
return options;
|
return options;
|
||||||
@ -315,13 +315,8 @@ export default class IndexSchema extends BaseUISchema {
|
|||||||
return Promise.resolve(()=>{});
|
return Promise.resolve(()=>{});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},{
|
},
|
||||||
id: 'columns_csv', label: gettext('Columns'), cell: 'string',
|
{
|
||||||
type: 'text',
|
|
||||||
disabled: () => inSchema(indexSchemaObj.node_info),
|
|
||||||
mode: ['properties'],
|
|
||||||
group: gettext('Definition'),
|
|
||||||
},{
|
|
||||||
id: 'include', label: gettext('Include columns'),
|
id: 'include', label: gettext('Include columns'),
|
||||||
group: gettext('Definition'),
|
group: gettext('Definition'),
|
||||||
editable: false, canDelete: true, canAdd: true, mode: ['properties'],
|
editable: false, canDelete: true, canAdd: true, mode: ['properties'],
|
||||||
@ -394,7 +389,7 @@ export default class IndexSchema extends BaseUISchema {
|
|||||||
readonly: function (state) {
|
readonly: function (state) {
|
||||||
return !indexSchemaObj.isNew(state);
|
return !indexSchemaObj.isNew(state);
|
||||||
},
|
},
|
||||||
mode: ['create', 'edit'], group: gettext('Definition'),
|
mode: ['create'], group: gettext('Definition'),
|
||||||
},{
|
},{
|
||||||
id: 'indconstraint', label: gettext('Constraint'), cell: 'string',
|
id: 'indconstraint', label: gettext('Constraint'), cell: 'string',
|
||||||
type: 'sql', controlProps: {className:['custom_height_css_class']},
|
type: 'sql', controlProps: {className:['custom_height_css_class']},
|
||||||
@ -407,7 +402,7 @@ export default class IndexSchema extends BaseUISchema {
|
|||||||
}, {
|
}, {
|
||||||
id: 'columns', label: gettext('Columns'), type: 'collection', deps: ['amname'],
|
id: 'columns', label: gettext('Columns'), type: 'collection', deps: ['amname'],
|
||||||
group: gettext('Definition'), schema: indexSchemaObj.getColumnSchema(),
|
group: gettext('Definition'), schema: indexSchemaObj.getColumnSchema(),
|
||||||
mode: ['edit', 'create'],
|
mode: ['edit', 'create', 'properties'],
|
||||||
canAdd: function(state) {
|
canAdd: function(state) {
|
||||||
// We will disable it if it's in 'edit' mode
|
// We will disable it if it's in 'edit' mode
|
||||||
return indexSchemaObj.isNew(state);
|
return indexSchemaObj.isNew(state);
|
||||||
|
@ -27,6 +27,34 @@
|
|||||||
"test_result_data": {}
|
"test_result_data": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Create index concurrently: With valid data.",
|
||||||
|
"is_positive_test": true,
|
||||||
|
"inventory_data": {},
|
||||||
|
"test_data": {
|
||||||
|
"name": "test_index_add",
|
||||||
|
"spcname": "pg_default",
|
||||||
|
"amname": "btree",
|
||||||
|
"isconcurrent": true,
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"colname": "id",
|
||||||
|
"sort_order": false,
|
||||||
|
"nulls": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"name"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mocking_required": false,
|
||||||
|
"mock_data": {},
|
||||||
|
"expected_data": {
|
||||||
|
"status_code": 200,
|
||||||
|
"error_msg": null,
|
||||||
|
"test_result_data": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Create index: With valid data mumtiple.",
|
"name": "Create index: With valid data mumtiple.",
|
||||||
"is_positive_test": true,
|
"is_positive_test": true,
|
||||||
@ -114,6 +142,7 @@
|
|||||||
"name": "test_index_add",
|
"name": "test_index_add",
|
||||||
"spcname": "pg_default",
|
"spcname": "pg_default",
|
||||||
"amname": "btree",
|
"amname": "btree",
|
||||||
|
"isconcurrent": false,
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"colname": "id",
|
"colname": "id",
|
||||||
@ -128,7 +157,7 @@
|
|||||||
"mocking_required": true,
|
"mocking_required": true,
|
||||||
"mock_data": {
|
"mock_data": {
|
||||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar",
|
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar",
|
||||||
"return_value": "[(True, True),(False, 'Mocked Internal Server Error'),(True,True)]"
|
"return_value": "[(False, 'Mocked Internal Server Error'),(True,True)]"
|
||||||
},
|
},
|
||||||
"expected_data": {
|
"expected_data": {
|
||||||
"status_code": 500,
|
"status_code": 500,
|
||||||
@ -144,6 +173,7 @@
|
|||||||
"name": "test_index_add",
|
"name": "test_index_add",
|
||||||
"spcname": "pg_default",
|
"spcname": "pg_default",
|
||||||
"amname": "btree",
|
"amname": "btree",
|
||||||
|
"isconcurrent": false,
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"colname": "id",
|
"colname": "id",
|
||||||
@ -158,7 +188,7 @@
|
|||||||
"mocking_required": true,
|
"mocking_required": true,
|
||||||
"mock_data": {
|
"mock_data": {
|
||||||
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar",
|
"function_name": "pgadmin.utils.driver.psycopg2.connection.Connection.execute_scalar",
|
||||||
"return_value": "[(True, True),(True, True),(False, 'Mocked Internal Server Error'),(False, 'Mocked Internal Server Error')]"
|
"return_value": "[(True, True),(False, 'Mocked Internal Server Error'),(False, 'Mocked Internal Server Error')]"
|
||||||
},
|
},
|
||||||
"expected_data": {
|
"expected_data": {
|
||||||
"status_code": 500,
|
"status_code": 500,
|
||||||
|
@ -183,7 +183,7 @@ function DataTableRow({row, totalRows, isResizing, schema, schemaRef, accessPath
|
|||||||
schemaRef.current.fields.forEach((field)=>{
|
schemaRef.current.fields.forEach((field)=>{
|
||||||
/* Self change is also dep change */
|
/* Self change is also dep change */
|
||||||
if(field.depChange || field.deferredDepChange) {
|
if(field.depChange || field.deferredDepChange) {
|
||||||
depListener.addDepListener(accessPath.concat(field.id), accessPath.concat(field.id), field.depChange, field.deferredDepChange);
|
depListener?.addDepListener(accessPath.concat(field.id), accessPath.concat(field.id), field.depChange, field.deferredDepChange);
|
||||||
}
|
}
|
||||||
(evalFunc(null, field.deps) || []).forEach((dep)=>{
|
(evalFunc(null, field.deps) || []).forEach((dep)=>{
|
||||||
let source = accessPath.concat(dep);
|
let source = accessPath.concat(dep);
|
||||||
@ -191,7 +191,7 @@ function DataTableRow({row, totalRows, isResizing, schema, schemaRef, accessPath
|
|||||||
source = dep;
|
source = dep;
|
||||||
}
|
}
|
||||||
if(field.depChange) {
|
if(field.depChange) {
|
||||||
depListener.addDepListener(source, accessPath.concat(field.id), field.depChange);
|
depListener?.addDepListener(source, accessPath.concat(field.id), field.depChange);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user