mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure the properties dialogues create objects in a single transaction/statement. Fixes #1107
This commit is contained in:
parent
085f8e198e
commit
d5a91c969c
@ -506,6 +506,7 @@ It may have been removed by another user.
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
self.format_request_acls(data, specific=['nspacl'])
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, 'sql/create.sql']),
|
"/".join([self.template_path, 'sql/create.sql']),
|
||||||
data=data, conn=self.conn, _=gettext
|
data=data, conn=self.conn, _=gettext
|
||||||
@ -518,22 +519,6 @@ It may have been removed by another user.
|
|||||||
errormsg=res + '\n' +
|
errormsg=res + '\n' +
|
||||||
'Operation failed while running create statement'
|
'Operation failed while running create statement'
|
||||||
)
|
)
|
||||||
self.format_request_acls(data, specific=['nspacl'])
|
|
||||||
|
|
||||||
SQL = render_template(
|
|
||||||
"/".join([self.template_path, 'sql/alter.sql']),
|
|
||||||
data=data, conn=self.conn, _=gettext
|
|
||||||
)
|
|
||||||
# Checking if we are not executing empty query
|
|
||||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
|
||||||
if not status:
|
|
||||||
return make_json_response(
|
|
||||||
status=410,
|
|
||||||
success=0,
|
|
||||||
errormsg=res + '\n' +
|
|
||||||
'Operation failed while running alter statement'
|
|
||||||
)
|
|
||||||
|
|
||||||
# we need oid to to add object in tree at browser,
|
# we need oid to to add object in tree at browser,
|
||||||
# below sql will gives the same
|
# below sql will gives the same
|
||||||
@ -727,11 +712,6 @@ It may have been removed by another user.
|
|||||||
"/".join([self.template_path, 'sql/create.sql']),
|
"/".join([self.template_path, 'sql/create.sql']),
|
||||||
data=data, conn=self.conn, _=gettext
|
data=data, conn=self.conn, _=gettext
|
||||||
)
|
)
|
||||||
SQL += "\n"
|
|
||||||
SQL += render_template(
|
|
||||||
"/".join([self.template_path, 'sql/alter.sql']),
|
|
||||||
_=gettext, data=data, conn=self.conn
|
|
||||||
)
|
|
||||||
|
|
||||||
return SQL
|
return SQL
|
||||||
|
|
||||||
@ -774,11 +754,6 @@ It may have been removed by another user.
|
|||||||
"/".join([self.template_path, 'sql/create.sql']),
|
"/".join([self.template_path, 'sql/create.sql']),
|
||||||
_=gettext, data=data, conn=self.conn
|
_=gettext, data=data, conn=self.conn
|
||||||
)
|
)
|
||||||
SQL += "\n"
|
|
||||||
SQL += render_template(
|
|
||||||
"/".join([self.template_path, 'sql/alter.sql']),
|
|
||||||
_=gettext, data=data, conn=self.conn
|
|
||||||
)
|
|
||||||
|
|
||||||
sql_header = """
|
sql_header = """
|
||||||
-- SCHEMA: {0}
|
-- SCHEMA: {0}
|
||||||
@ -867,7 +842,6 @@ It may have been removed by another user.
|
|||||||
return make_json_response(data=nodes)
|
return make_json_response(data=nodes)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CatalogView(SchemaView):
|
class CatalogView(SchemaView):
|
||||||
"""
|
"""
|
||||||
This class is responsible for generating routes for catalog schema node.
|
This class is responsible for generating routes for catalog schema node.
|
||||||
@ -965,11 +939,6 @@ It may have been removed by another user.
|
|||||||
"/".join([self.template_path, 'sql/create.sql']),
|
"/".join([self.template_path, 'sql/create.sql']),
|
||||||
_=gettext, data=old_data, conn=self.conn
|
_=gettext, data=old_data, conn=self.conn
|
||||||
)
|
)
|
||||||
SQL += "\n"
|
|
||||||
SQL += render_template(
|
|
||||||
"/".join([self.template_path, 'sql/alter.sql']),
|
|
||||||
_=gettext, data=old_data, conn=self.conn
|
|
||||||
)
|
|
||||||
|
|
||||||
sql_header = """
|
sql_header = """
|
||||||
-- CATALOG: {0}
|
-- CATALOG: {0}
|
||||||
|
@ -1747,14 +1747,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
|||||||
if ctype == 'p' else 'UNIQUE'
|
if ctype == 'p' else 'UNIQUE'
|
||||||
).strip('\n')
|
).strip('\n')
|
||||||
)
|
)
|
||||||
# sql to update comments
|
|
||||||
sql.append(
|
|
||||||
render_template(
|
|
||||||
"/".join([self.index_constraint_template_path,
|
|
||||||
'alter.sql']),
|
|
||||||
data=c, conn=self.conn
|
|
||||||
).strip('\n')
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
sql.append(
|
sql.append(
|
||||||
gettext(
|
gettext(
|
||||||
@ -1871,14 +1863,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
|||||||
data=c, conn=self.conn
|
data=c, conn=self.conn
|
||||||
).strip('\n')
|
).strip('\n')
|
||||||
)
|
)
|
||||||
# sql to update comments
|
|
||||||
sql.append(
|
|
||||||
render_template(
|
|
||||||
"/".join([self.foreign_key_template_path,
|
|
||||||
'alter.sql']),
|
|
||||||
data=c, conn=self.conn
|
|
||||||
).strip('\n')
|
|
||||||
)
|
|
||||||
|
|
||||||
if c['autoindex']:
|
if c['autoindex']:
|
||||||
sql.append(
|
sql.append(
|
||||||
@ -1963,14 +1947,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
|||||||
data=c, conn=self.conn
|
data=c, conn=self.conn
|
||||||
).strip('\n')
|
).strip('\n')
|
||||||
)
|
)
|
||||||
# sql to update comments
|
|
||||||
sql.append(
|
|
||||||
render_template(
|
|
||||||
"/".join([self.check_constraint_template_path,
|
|
||||||
'alter.sql']),
|
|
||||||
data=c, conn=self.conn
|
|
||||||
).strip('\n')
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(sql) > 0:
|
if len(sql) > 0:
|
||||||
# Join all the sql(s) as single string
|
# Join all the sql(s) as single string
|
||||||
@ -2047,14 +2023,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
|||||||
data=c, conn=self.conn
|
data=c, conn=self.conn
|
||||||
).strip('\n')
|
).strip('\n')
|
||||||
)
|
)
|
||||||
# sql to update comments
|
|
||||||
sql.append(
|
|
||||||
render_template(
|
|
||||||
"/".join([self.exclusion_constraint_template_path,
|
|
||||||
'alter.sql']),
|
|
||||||
data=c, conn=self.conn
|
|
||||||
).strip('\n')
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(sql) > 0:
|
if len(sql) > 0:
|
||||||
# Join all the sql(s) as single string
|
# Join all the sql(s) as single string
|
||||||
|
@ -465,17 +465,6 @@ class CheckConstraintView(PGChildNodeView):
|
|||||||
icon = "icon-check_constraints"
|
icon = "icon-check_constraints"
|
||||||
valid = True
|
valid = True
|
||||||
|
|
||||||
sql = render_template("/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data,
|
|
||||||
conn=self.conn)
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
|
||||||
|
|
||||||
if sql != '':
|
|
||||||
status, result = self.conn.execute_scalar(sql)
|
|
||||||
if not status:
|
|
||||||
self.end_transaction()
|
|
||||||
return internal_server_error(errormsg=result)
|
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
node=self.blueprint.generate_browser_node(
|
node=self.blueprint.generate_browser_node(
|
||||||
res['rows'][0]['oid'],
|
res['rows'][0]['oid'],
|
||||||
@ -638,10 +627,6 @@ class CheckConstraintView(PGChildNodeView):
|
|||||||
SQL = render_template("/".join([self.template_path,
|
SQL = render_template("/".join([self.template_path,
|
||||||
'create.sql']),
|
'create.sql']),
|
||||||
data=data)
|
data=data)
|
||||||
SQL += "\n"
|
|
||||||
SQL += render_template(
|
|
||||||
"/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data)
|
|
||||||
|
|
||||||
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
||||||
|
|
||||||
@ -735,9 +720,6 @@ class CheckConstraintView(PGChildNodeView):
|
|||||||
SQL = render_template("/".join([self.template_path,
|
SQL = render_template("/".join([self.template_path,
|
||||||
'create.sql']),
|
'create.sql']),
|
||||||
data=data)
|
data=data)
|
||||||
SQL += "\n"
|
|
||||||
SQL += render_template("/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data)
|
|
||||||
|
|
||||||
return SQL
|
return SQL
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -506,15 +506,6 @@ class ExclusionConstraintView(PGChildNodeView):
|
|||||||
if not status:
|
if not status:
|
||||||
self.end_transaction()
|
self.end_transaction()
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
if 'name' in data and data['name'] != '':
|
|
||||||
sql = render_template("/".join([self.template_path, 'alter.sql']), data=data, conn=self.conn)
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
|
||||||
|
|
||||||
if sql != '':
|
|
||||||
status, result = self.conn.execute_scalar(sql)
|
|
||||||
if not status:
|
|
||||||
self.end_transaction()
|
|
||||||
return internal_server_error(errormsg=result)
|
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
node=self.blueprint.generate_browser_node(
|
node=self.blueprint.generate_browser_node(
|
||||||
@ -728,9 +719,6 @@ class ExclusionConstraintView(PGChildNodeView):
|
|||||||
|
|
||||||
sql = render_template("/".join([self.template_path, 'create.sql']),
|
sql = render_template("/".join([self.template_path, 'create.sql']),
|
||||||
data=data, conn=self.conn)
|
data=data, conn=self.conn)
|
||||||
sql += "\n"
|
|
||||||
sql += render_template("/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data, conn=self.conn)
|
|
||||||
|
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
@ -795,10 +783,6 @@ class ExclusionConstraintView(PGChildNodeView):
|
|||||||
|
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, 'create.sql']), data=data)
|
"/".join([self.template_path, 'create.sql']), data=data)
|
||||||
SQL += "\n"
|
|
||||||
SQL += render_template(
|
|
||||||
"/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data, conn=self.conn)
|
|
||||||
|
|
||||||
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
||||||
|
|
||||||
|
@ -547,15 +547,6 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
|||||||
icon = "icon-foreign_key"
|
icon = "icon-foreign_key"
|
||||||
valid = True
|
valid = True
|
||||||
|
|
||||||
sql = render_template("/".join([self.template_path, 'alter.sql']), data=data, conn=self.conn)
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
|
||||||
|
|
||||||
if sql != '':
|
|
||||||
status, result = self.conn.execute_scalar(sql)
|
|
||||||
if not status:
|
|
||||||
self.end_transaction()
|
|
||||||
return internal_server_error(errormsg=result)
|
|
||||||
|
|
||||||
if data['autoindex']:
|
if data['autoindex']:
|
||||||
sql = render_template(
|
sql = render_template(
|
||||||
"/".join([self.template_path, 'create_index.sql']),
|
"/".join([self.template_path, 'create_index.sql']),
|
||||||
@ -827,9 +818,6 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
|||||||
|
|
||||||
sql = render_template("/".join([self.template_path, 'create.sql']),
|
sql = render_template("/".join([self.template_path, 'create.sql']),
|
||||||
data=data, conn=self.conn)
|
data=data, conn=self.conn)
|
||||||
sql += "\n"
|
|
||||||
sql += render_template("/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data, conn=self.conn)
|
|
||||||
|
|
||||||
if data['autoindex']:
|
if data['autoindex']:
|
||||||
sql += render_template(
|
sql += render_template(
|
||||||
@ -898,10 +886,6 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
|||||||
|
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, 'create.sql']), data=data)
|
"/".join([self.template_path, 'create.sql']), data=data)
|
||||||
SQL += "\n"
|
|
||||||
SQL += render_template(
|
|
||||||
"/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data, conn=self.conn)
|
|
||||||
|
|
||||||
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
||||||
|
|
||||||
|
@ -526,17 +526,6 @@ class IndexConstraintView(PGChildNodeView):
|
|||||||
self.end_transaction()
|
self.end_transaction()
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
|
||||||
sql = render_template("/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data,
|
|
||||||
conn=self.conn)
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
|
||||||
|
|
||||||
if sql != '':
|
|
||||||
status, result = self.conn.execute_scalar(sql)
|
|
||||||
if not status:
|
|
||||||
self.end_transaction()
|
|
||||||
return internal_server_error(errormsg=result)
|
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
node=self.blueprint.generate_browser_node(
|
node=self.blueprint.generate_browser_node(
|
||||||
res['rows'][0]['oid'],
|
res['rows'][0]['oid'],
|
||||||
@ -768,10 +757,6 @@ class IndexConstraintView(PGChildNodeView):
|
|||||||
data=data,
|
data=data,
|
||||||
conn=self.conn,
|
conn=self.conn,
|
||||||
constraint_name=self.constraint_name)
|
constraint_name=self.constraint_name)
|
||||||
sql += "\n"
|
|
||||||
sql += render_template("/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data,
|
|
||||||
conn=self.conn)
|
|
||||||
|
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
@ -826,10 +811,6 @@ class IndexConstraintView(PGChildNodeView):
|
|||||||
"/".join([self.template_path, 'create.sql']),
|
"/".join([self.template_path, 'create.sql']),
|
||||||
data=data,
|
data=data,
|
||||||
constraint_name=self.constraint_name)
|
constraint_name=self.constraint_name)
|
||||||
SQL += "\n"
|
|
||||||
SQL += render_template(
|
|
||||||
"/".join([self.template_path, 'alter.sql']),
|
|
||||||
data=data, conn=self.conn)
|
|
||||||
|
|
||||||
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
||||||
|
|
||||||
|
@ -557,15 +557,19 @@ class IndexesView(PGChildNodeView):
|
|||||||
data['table'] = self.table
|
data['table'] = self.table
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Start transaction.
|
||||||
|
self.conn.execute_scalar("BEGIN;")
|
||||||
SQL = render_template("/".join([self.template_path,
|
SQL = render_template("/".join([self.template_path,
|
||||||
'create.sql']),
|
'create.sql']),
|
||||||
data=data, conn=self.conn, mode='create')
|
data=data, conn=self.conn, mode='create')
|
||||||
status, res = self.conn.execute_scalar(SQL)
|
status, res = self.conn.execute_scalar(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
|
# End transaction.
|
||||||
|
self.conn.execute_scalar("END;")
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
|
||||||
# If user chooses concurrent index then we can not run it along
|
# If user chooses concurrent index then we can not run it along
|
||||||
# with other alter statments so we will separate alter index part
|
# with other alter statements so we will separate alter index part
|
||||||
SQL = render_template("/".join([self.template_path,
|
SQL = render_template("/".join([self.template_path,
|
||||||
'alter.sql']),
|
'alter.sql']),
|
||||||
data=data, conn=self.conn)
|
data=data, conn=self.conn)
|
||||||
@ -573,6 +577,8 @@ class IndexesView(PGChildNodeView):
|
|||||||
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.
|
||||||
|
self.conn.execute_scalar("END;")
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
|
||||||
# we need oid to to add object in tree at browser
|
# we need oid to to add object in tree at browser
|
||||||
@ -581,8 +587,12 @@ class IndexesView(PGChildNodeView):
|
|||||||
tid=tid, data=data)
|
tid=tid, data=data)
|
||||||
status, idx = self.conn.execute_scalar(SQL)
|
status, idx = self.conn.execute_scalar(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
|
# End transaction.
|
||||||
|
self.conn.execute_scalar("END;")
|
||||||
return internal_server_error(errormsg=tid)
|
return internal_server_error(errormsg=tid)
|
||||||
|
|
||||||
|
# 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,
|
||||||
@ -592,6 +602,8 @@ class IndexesView(PGChildNodeView):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
# 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
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
{% if data.comment %}
|
|
||||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
|
||||||
IS {{ data.comment|qtLiteral }};
|
|
||||||
{% endif %}
|
|
@ -2,3 +2,8 @@
|
|||||||
ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
||||||
ADD{% if data.name %} CONSTRAINT {{ conn|qtIdent(data.name) }}{% endif%} CHECK ({{ data.consrc }});
|
ADD{% if data.name %} CONSTRAINT {{ conn|qtIdent(data.name) }}{% endif%} CHECK ({{ data.consrc }});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if data.comment %}
|
||||||
|
|
||||||
|
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
||||||
|
IS {{ data.comment|qtLiteral }};
|
||||||
|
{% endif %}
|
@ -1,4 +0,0 @@
|
|||||||
{% if data.comment %}
|
|
||||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
|
||||||
IS {{ data.comment|qtLiteral }};
|
|
||||||
{% endif %}
|
|
@ -4,3 +4,8 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
|||||||
|
|
||||||
NOT VALID{% endif %}{% if data.connoinherit %} NO INHERIT{% endif %};
|
NOT VALID{% endif %}{% if data.connoinherit %} NO INHERIT{% endif %};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if data.comment %}
|
||||||
|
|
||||||
|
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
||||||
|
IS {{ data.comment|qtLiteral }};
|
||||||
|
{% endif %}
|
@ -1,4 +0,0 @@
|
|||||||
{% if data.comment %}
|
|
||||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
|
||||||
IS {{ data.comment|qtLiteral }};
|
|
||||||
{% endif %}
|
|
@ -10,3 +10,8 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
|||||||
DEFERRABLE{% if data.condeferred %}
|
DEFERRABLE{% if data.condeferred %}
|
||||||
INITIALLY DEFERRED{% endif%}
|
INITIALLY DEFERRED{% endif%}
|
||||||
{% endif%}{% if data.constraint %} WHERE ({{data.constraint}}){% endif%};
|
{% endif%}{% if data.constraint %} WHERE ({{data.constraint}}){% endif%};
|
||||||
|
{% if data.comment and data.name %}
|
||||||
|
|
||||||
|
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
||||||
|
IS {{ data.comment|qtLiteral }};
|
||||||
|
{% endif %}
|
@ -1,4 +0,0 @@
|
|||||||
{% if data.comment %}
|
|
||||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
|
||||||
IS {{ data.comment|qtLiteral }};
|
|
||||||
{% endif %}
|
|
@ -10,3 +10,8 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
|||||||
DEFERRABLE{% if data.condeferred %}
|
DEFERRABLE{% if data.condeferred %}
|
||||||
INITIALLY DEFERRED{% endif%}
|
INITIALLY DEFERRED{% endif%}
|
||||||
{% endif%}{% if data.constraint %} WHERE ({{data.constraint}}){% endif%};
|
{% endif%}{% if data.constraint %} WHERE ({{data.constraint}}){% endif%};
|
||||||
|
{% if data.comment and data.name %}
|
||||||
|
|
||||||
|
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
||||||
|
IS {{ data.comment|qtLiteral }};
|
||||||
|
{% endif %}
|
@ -1,4 +0,0 @@
|
|||||||
{% if data.comment %}
|
|
||||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
|
||||||
IS {{ data.comment|qtLiteral }};
|
|
||||||
{% endif %}
|
|
@ -25,3 +25,8 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
|||||||
{% if data.convalidated %}
|
{% if data.convalidated %}
|
||||||
|
|
||||||
NOT VALID{% endif%};
|
NOT VALID{% endif%};
|
||||||
|
{% if data.comment and data.name %}
|
||||||
|
|
||||||
|
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
||||||
|
IS {{ data.comment|qtLiteral }};
|
||||||
|
{% endif %}
|
@ -1,4 +0,0 @@
|
|||||||
{% if data.comment %}
|
|
||||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
|
||||||
IS {{ data.comment|qtLiteral }};
|
|
||||||
{% endif %}
|
|
@ -10,3 +10,8 @@ ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }}
|
|||||||
DEFERRABLE{% if data.condeferred %}
|
DEFERRABLE{% if data.condeferred %}
|
||||||
INITIALLY DEFERRED{% endif%}
|
INITIALLY DEFERRED{% endif%}
|
||||||
{% endif%};
|
{% endif%};
|
||||||
|
{% if data.comment and data.name %}
|
||||||
|
|
||||||
|
COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
|
||||||
|
IS {{ data.comment|qtLiteral }};
|
||||||
|
{% endif %}
|
@ -1 +0,0 @@
|
|||||||
{# We have nothing to alter in the catalog #}
|
|
@ -1 +0,0 @@
|
|||||||
{# We have nothing to alter in the catalog #}
|
|
@ -1 +0,0 @@
|
|||||||
{# We have nothing to alter in the catalog #}
|
|
@ -1 +0,0 @@
|
|||||||
{# We have nothing to alter in the catalog #}
|
|
@ -1,35 +0,0 @@
|
|||||||
{% import 'macros/security.macros' as SECLABLE %}
|
|
||||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
|
||||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
|
||||||
{# Alter the comment/description #}
|
|
||||||
{% if data.description %}
|
|
||||||
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
|
||||||
IS {{ data.description|qtLiteral }};
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
{# ACL for the schema #}
|
|
||||||
{% if data.nspacl %}
|
|
||||||
{% for priv in data.nspacl %}
|
|
||||||
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{# Default privileges on tables #}
|
|
||||||
{% for defacl, type in [
|
|
||||||
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
|
||||||
('deffuncacl', 'FUNCTIONS')]
|
|
||||||
%}
|
|
||||||
{% if data[defacl] %}{% set acl = data[defacl] %}
|
|
||||||
{% for priv in data.deftblacl %}
|
|
||||||
{{ DEFAULT_PRIVILEGE.SET(
|
|
||||||
conn, 'SCHEMA', data.name, type, priv.grantee,
|
|
||||||
priv.without_grant, priv.with_grant
|
|
||||||
) }}{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{# Security Labels on schema #}
|
|
||||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
|
||||||
{% for r in data.seclabels %}
|
|
||||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
@ -1,7 +1,44 @@
|
|||||||
|
{% import 'macros/security.macros' as SECLABLE %}
|
||||||
|
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||||
|
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||||
{% if data.name %}
|
{% if data.name %}
|
||||||
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
||||||
|
|
||||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
||||||
|
{# Alter the comment/description #}
|
||||||
|
{% if data.description %}
|
||||||
|
|
||||||
|
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||||
|
IS {{ data.description|qtLiteral }};
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{# ACL for the schema #}
|
||||||
|
{% if data.nspacl %}
|
||||||
|
{% for priv in data.nspacl %}
|
||||||
|
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# Default privileges on tables #}
|
||||||
|
{% for defacl, type in [
|
||||||
|
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
||||||
|
('deffuncacl', 'FUNCTIONS')]
|
||||||
|
%}
|
||||||
|
{% if data[defacl] %}{% set acl = data[defacl] %}
|
||||||
|
{% for priv in data.deftblacl %}
|
||||||
|
{{ DEFAULT_PRIVILEGE.SET(
|
||||||
|
conn, 'SCHEMA', data.name, type, priv.grantee,
|
||||||
|
priv.without_grant, priv.with_grant
|
||||||
|
) }}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{# Security Labels on schema #}
|
||||||
|
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||||
|
{% for r in data.seclabels %}
|
||||||
|
{{ SECLABLE.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ -- _('Incomplete definition') }}
|
{{ -- _('Incomplete definition') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
{% import 'macros/security.macros' as SECLABEL %}
|
|
||||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
|
||||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
|
||||||
{# Alter the comment/description #}
|
|
||||||
{% if data.description %}
|
|
||||||
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
|
||||||
IS {{ data.description|qtLiteral }};
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
{# ACL for the schema #}
|
|
||||||
{% if data.nspacl %}
|
|
||||||
{% for priv in data.nspacl %}
|
|
||||||
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{# Default privileges on tables #}
|
|
||||||
{% for defacl, type in [
|
|
||||||
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
|
||||||
('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')]
|
|
||||||
%}
|
|
||||||
{% if data[defacl] %}{% set acl = data[defacl] %}
|
|
||||||
{% for priv in data.deftblacl %}
|
|
||||||
{{ DEFAULT_PRIVILEGE.SET(
|
|
||||||
conn, 'SCHEMA', data.name, type, priv.grantee,
|
|
||||||
priv.without_grant, priv.with_grant
|
|
||||||
) }}{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{# Security Labels on schema #}
|
|
||||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
|
||||||
{% for r in data.seclabels %}
|
|
||||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
@ -1,7 +1,44 @@
|
|||||||
|
{% import 'macros/security.macros' as SECLABEL %}
|
||||||
|
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||||
|
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||||
{% if data.name %}
|
{% if data.name %}
|
||||||
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
||||||
|
|
||||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
||||||
|
{# Alter the comment/description #}
|
||||||
|
{% if data.description %}
|
||||||
|
|
||||||
|
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||||
|
IS {{ data.description|qtLiteral }};
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{# ACL for the schema #}
|
||||||
|
{% if data.nspacl %}
|
||||||
|
{% for priv in data.nspacl %}
|
||||||
|
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# Default privileges on tables #}
|
||||||
|
{% for defacl, type in [
|
||||||
|
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
||||||
|
('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')]
|
||||||
|
%}
|
||||||
|
{% if data[defacl] %}{% set acl = data[defacl] %}
|
||||||
|
{% for priv in data.deftblacl %}
|
||||||
|
{{ DEFAULT_PRIVILEGE.SET(
|
||||||
|
conn, 'SCHEMA', data.name, type, priv.grantee,
|
||||||
|
priv.without_grant, priv.with_grant
|
||||||
|
) }}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{# Security Labels on schema #}
|
||||||
|
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||||
|
{% for r in data.seclabels %}
|
||||||
|
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ -- _('Incomplete definition') }}
|
{{ -- _('Incomplete definition') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
{% import 'macros/security.macros' as SECLABEL %}
|
|
||||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
|
||||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
|
||||||
{# Alter the comment/description #}
|
|
||||||
{% if data.description %}
|
|
||||||
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
|
||||||
IS {{ data.description|qtLiteral }};
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
{# ACL for the schema #}
|
|
||||||
{% if data.nspacl %}
|
|
||||||
{% for priv in data.nspacl %}
|
|
||||||
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{# Default privileges on tables #}
|
|
||||||
{% for defacl, type in [
|
|
||||||
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
|
||||||
('deffuncacl', 'FUNCTIONS')]
|
|
||||||
%}
|
|
||||||
{% if data[defacl] %}{% set acl = data[defacl] %}
|
|
||||||
{% for priv in data.deftblacl %}
|
|
||||||
{{ DEFAULT_PRIVILEGE.SET(
|
|
||||||
conn, 'SCHEMA', data.name, type, priv.grantee,
|
|
||||||
priv.without_grant, priv.with_grant
|
|
||||||
) }}{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{# Security Labels on schema #}
|
|
||||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
|
||||||
{% for r in data.seclabels %}
|
|
||||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
@ -1,7 +1,44 @@
|
|||||||
|
{% import 'macros/security.macros' as SECLABEL %}
|
||||||
|
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||||
|
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||||
{% if data.name %}
|
{% if data.name %}
|
||||||
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
||||||
|
|
||||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
||||||
|
{# Alter the comment/description #}
|
||||||
|
{% if data.description %}
|
||||||
|
|
||||||
|
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||||
|
IS {{ data.description|qtLiteral }};
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{# ACL for the schema #}
|
||||||
|
{% if data.nspacl %}
|
||||||
|
{% for priv in data.nspacl %}
|
||||||
|
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# Default privileges on tables #}
|
||||||
|
{% for defacl, type in [
|
||||||
|
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
||||||
|
('deffuncacl', 'FUNCTIONS')]
|
||||||
|
%}
|
||||||
|
{% if data[defacl] %}{% set acl = data[defacl] %}
|
||||||
|
{% for priv in data.deftblacl %}
|
||||||
|
{{ DEFAULT_PRIVILEGE.SET(
|
||||||
|
conn, 'SCHEMA', data.name, type, priv.grantee,
|
||||||
|
priv.without_grant, priv.with_grant
|
||||||
|
) }}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{# Security Labels on schema #}
|
||||||
|
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||||
|
{% for r in data.seclabels %}
|
||||||
|
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ -- _('Incomplete definition') }}
|
{{ -- _('Incomplete definition') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
{% import 'macros/security.macros' as SECLABEL %}
|
|
||||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
|
||||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
|
||||||
{# Alter the comment/description #}
|
|
||||||
{% if data.description %}
|
|
||||||
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
|
||||||
IS {{ data.description|qtLiteral }};
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
{# ACL for the schema #}
|
|
||||||
{% if data.nspacl %}
|
|
||||||
{% for priv in data.nspacl %}
|
|
||||||
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{# Default privileges on tables #}
|
|
||||||
{% for defacl, type in [
|
|
||||||
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
|
||||||
('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')]
|
|
||||||
%}
|
|
||||||
{% if data[defacl] %}{% set acl = data[defacl] %}
|
|
||||||
{% for priv in data.deftblacl %}
|
|
||||||
{{ DEFAULT_PRIVILEGE.SET(
|
|
||||||
conn, 'SCHEMA', data.name, type, priv.grantee,
|
|
||||||
priv.without_grant, priv.with_grant
|
|
||||||
) }}{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{# Security Labels on schema #}
|
|
||||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
|
||||||
{% for r in data.seclabels %}
|
|
||||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
@ -1,7 +1,44 @@
|
|||||||
|
{% import 'macros/security.macros' as SECLABEL %}
|
||||||
|
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||||
|
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||||
{% if data.name %}
|
{% if data.name %}
|
||||||
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
||||||
|
|
||||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
||||||
|
{# Alter the comment/description #}
|
||||||
|
{% if data.description %}
|
||||||
|
|
||||||
|
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||||
|
IS {{ data.description|qtLiteral }};
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{# ACL for the schema #}
|
||||||
|
{% if data.nspacl %}
|
||||||
|
{% for priv in data.nspacl %}
|
||||||
|
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# Default privileges on tables #}
|
||||||
|
{% for defacl, type in [
|
||||||
|
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
||||||
|
('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')]
|
||||||
|
%}
|
||||||
|
{% if data[defacl] %}{% set acl = data[defacl] %}
|
||||||
|
{% for priv in data.deftblacl %}
|
||||||
|
{{ DEFAULT_PRIVILEGE.SET(
|
||||||
|
conn, 'SCHEMA', data.name, type, priv.grantee,
|
||||||
|
priv.without_grant, priv.with_grant
|
||||||
|
) }}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{# Security Labels on schema #}
|
||||||
|
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||||
|
{% for r in data.seclabels %}
|
||||||
|
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ -- _('Incomplete definition') }}
|
{{ -- _('Incomplete definition') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{#
|
{#
|
||||||
# CREATE DATABSE does not allow us to run any
|
# CREATE DATABASE does not allow us to run any
|
||||||
# other sql statments along with it, so we wrote
|
# other sql statements along with it, so we wrote
|
||||||
# seprate sql for rest alter sql statments here
|
# separate sql for rest alter sql statements here
|
||||||
#}
|
#}
|
||||||
{% import 'macros/security.macros' as SECLABEL %}
|
{% import 'macros/security.macros' as SECLABEL %}
|
||||||
{% import 'macros/variable.macros' as VARIABLE %}
|
{% import 'macros/variable.macros' as VARIABLE %}
|
||||||
|
Loading…
Reference in New Issue
Block a user