Added support of Foreign Tables to the Schema Diff. Fixes #5263

This commit is contained in:
Akshay Joshi
2020-04-09 21:03:12 +05:30
parent fecf3915c5
commit 31f255b541
22 changed files with 1510 additions and 31 deletions

View File

@@ -12,6 +12,7 @@ New features
| `Issue #2172 <https://redmine.postgresql.org/issues/2172>`_ - Added search object functionality. | `Issue #2172 <https://redmine.postgresql.org/issues/2172>`_ - Added search object functionality.
| `Issue #2186 <https://redmine.postgresql.org/issues/2186>`_ - Added LDAP authentication support. | `Issue #2186 <https://redmine.postgresql.org/issues/2186>`_ - Added LDAP authentication support.
| `Issue #5184 <https://redmine.postgresql.org/issues/5184>`_ - Added support for parameter toast_tuple_target and parallel_workers of the table. | `Issue #5184 <https://redmine.postgresql.org/issues/5184>`_ - Added support for parameter toast_tuple_target and parallel_workers of the table.
| `Issue #5263 <https://redmine.postgresql.org/issues/5263>`_ - Added support of Foreign Tables to the Schema Diff.
| `Issue #5264 <https://redmine.postgresql.org/issues/5264>`_ - Added support of Packages, Sequences and Synonyms to the Schema Diff. | `Issue #5264 <https://redmine.postgresql.org/issues/5264>`_ - Added support of Packages, Sequences and Synonyms to the Schema Diff.
| `Issue #5353 <https://redmine.postgresql.org/issues/5353>`_ - Added an option to prevent a browser tab being opened at startup. | `Issue #5353 <https://redmine.postgresql.org/issues/5353>`_ - Added an option to prevent a browser tab being opened at startup.

View File

@@ -223,6 +223,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
'compare': [{'get': 'compare'}, {'get': 'compare'}] 'compare': [{'get': 'compare'}, {'get': 'compare'}]
}) })
keys_to_ignore = ['oid', 'basensp', 'oid-2', 'attnum', 'strftoptions',
'relacl']
def validate_request(f): def validate_request(f):
""" """
Works as a decorator. Works as a decorator.
@@ -697,7 +700,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
@check_precondition @check_precondition
def delete(self, gid, sid, did, scid, foid=None): def delete(self, gid, sid, did, scid, foid=None, only_sql=False):
""" """
Drops the Foreign Table. Drops the Foreign Table.
@@ -707,6 +710,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
did: Database Id did: Database Id
scid: Schema Id scid: Schema Id
foid: Foreign Table Id foid: Foreign Table Id
only_sql: Return only sql if True
""" """
if foid is None: if foid is None:
data = request.form if request.form else json.loads( data = request.form if request.form else json.loads(
@@ -750,6 +754,11 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
name=name, name=name,
basensp=basensp, basensp=basensp,
cascade=cascade) cascade=cascade)
# Used for schema diff tool
if only_sql:
return SQL
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@@ -808,7 +817,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
@check_precondition @check_precondition
def sql(self, gid, sid, did, scid, foid=None): def sql(self, gid, sid, did, scid, foid=None, diff_schema=None,
json_resp=True):
""" """
Returns the SQL for the Foreign Table object. Returns the SQL for the Foreign Table object.
@@ -818,12 +828,17 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
did: Database Id did: Database Id
scid: Schema Id scid: Schema Id
foid: Foreign Table Id foid: Foreign Table Id
diff_schema: Target Schema for schema diff
json_resp: True then return json response
""" """
status, data = self._fetch_properties(gid, sid, did, scid, foid, status, data = self._fetch_properties(gid, sid, did, scid, foid,
inherits=True) inherits=True)
if not status: if not status:
return data return data
if diff_schema:
data['basensp'] = diff_schema
col_data = [] col_data = []
for c in data['columns']: for c in data['columns']:
if ('inheritedfrom' not in c) or (c['inheritedfrom'] is None): if ('inheritedfrom' not in c) or (c['inheritedfrom'] is None):
@@ -839,6 +854,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), data=data, is_sql=True) 'create.sql']), data=data, is_sql=True)
if not json_resp:
return SQL.strip('\n')
sql_header = u"""-- FOREIGN TABLE: {0} sql_header = u"""-- FOREIGN TABLE: {0}
-- DROP FOREIGN TABLE {0}; -- DROP FOREIGN TABLE {0};
@@ -883,7 +901,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
except Exception as e: except Exception as e:
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
def get_sql(self, gid, sid, did, scid, data, foid=None): def get_sql(self, gid, sid, did, scid, data, foid=None,
is_schema_diff=False):
""" """
Genrates the SQL statements to create/update the Foreign Table. Genrates the SQL statements to create/update the Foreign Table.
@@ -893,6 +912,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
did: Database Id did: Database Id
scid: Schema Id scid: Schema Id
foid: Foreign Table Id foid: Foreign Table Id
is_schema_diff: True is function gets called from schema diff
""" """
if foid is not None: if foid is not None:
status, old_data = self._fetch_properties(gid, sid, did, scid, status, old_data = self._fetch_properties(gid, sid, did, scid,
@@ -900,6 +920,10 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if not status: if not status:
return old_data return old_data
if is_schema_diff:
data['is_schema_diff'] = True
old_data['columns_for_schema_diff'] = old_data['columns']
# Prepare dict of columns with key = column's attnum # Prepare dict of columns with key = column's attnum
# Will use this in the update template when any column is # Will use this in the update template when any column is
# changed, to identify the columns. # changed, to identify the columns.
@@ -960,10 +984,21 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
data['acl']['deleted'] = parse_priv_to_db( data['acl']['deleted'] = parse_priv_to_db(
data['acl']['deleted'], ["a", "r", "w", "x"]) data['acl']['deleted'], ["a", "r", "w", "x"])
SQL = render_template( # If ftsrvname is changed while comparing two schemas
"/".join([self.template_path, 'update.sql']), # then we need to drop foreign table and recreate it
data=data, o_data=old_data if is_schema_diff and 'ftsrvname' in data:
) # Modify the data required to recreate the foreign table.
self.modify_data_for_schema_diff(data, old_data)
SQL = render_template(
"/".join([self.template_path,
'foreign_table_schema_diff.sql']),
data=data, o_data=old_data)
else:
SQL = render_template(
"/".join([self.template_path, 'update.sql']),
data=data, o_data=old_data
)
return SQL, data['name'] if 'name' in data else old_data['name'] return SQL, data['name'] if 'name' in data else old_data['name']
else: else:
data['columns'] = self._format_columns(data['columns']) data['columns'] = self._format_columns(data['columns'])
@@ -1328,7 +1363,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
return ajax_response(response=sql) return ajax_response(response=sql)
@check_precondition @check_precondition
def delete_sql(self, gid, sid, did, scid, foid): def delete_sql(self, gid, sid, did, scid, foid, only_sql=False):
""" """
DELETE script sql for the object DELETE script sql for the object
@@ -1338,6 +1373,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
did: Database Id did: Database Id
scid: Schema Id scid: Schema Id
foid: Foreign Table Id foid: Foreign Table Id
only_sql: Return only sql if True
Returns: Returns:
DELETE Script sql for the object DELETE Script sql for the object
@@ -1350,6 +1386,10 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
self.qtIdent(self.conn, data['basensp'], data['name']) self.qtIdent(self.conn, data['basensp'], data['name'])
) )
# Used for schema diff tool
if only_sql:
return sql
return ajax_response(response=sql) return ajax_response(response=sql)
@check_precondition @check_precondition
@@ -1384,5 +1424,86 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
diff_schema=None, drop_sql=False):
"""
This function is used to get the DDL/DML statements.
:param gid: Group ID
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the domains
:return:
"""
sql = ''
if data:
if diff_schema:
data['schema'] = diff_schema
sql, name = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=data, foid=oid,
is_schema_diff=True)
else:
if drop_sql:
sql = self.delete(gid=gid, sid=sid, did=did,
scid=scid, foid=oid, only_sql=True)
elif diff_schema:
sql = self.sql(gid=gid, sid=sid, did=did, scid=scid, foid=oid,
diff_schema=diff_schema, json_resp=False)
else:
sql = self.sql(gid=gid, sid=sid, did=did, scid=scid, foid=oid,
json_resp=False)
return sql
def modify_data_for_schema_diff(self, data, old_data):
"""
This function modifies the data for columns, constraints, options
etc...
:param data:
:return:
"""
tmp_columns = []
if 'columns_for_schema_diff' in old_data:
tmp_columns = old_data['columns_for_schema_diff']
if 'columns' in data:
if 'added' in data['columns']:
for item in data['columns']['added']:
tmp_columns.append(item)
if 'changed' in data['columns']:
for item in data['columns']['changed']:
tmp_columns.append(item)
if 'deleted' in data['columns']:
for item in data['columns']['deleted']:
tmp_columns.remove(item)
data['columns'] = tmp_columns
tmp_constraints = []
if 'constraints' in data:
if 'added' in data['constraints']:
for item in data['constraints']['added']:
tmp_constraints.append(item)
if 'changed' in data['constraints']:
for item in data['constraints']['changed']:
tmp_constraints.append(item)
data['constraints'] = tmp_constraints
tmp_ftoptions = []
if 'ftoptions' in old_data:
tmp_ftoptions = old_data['ftoptions']
if 'ftoptions' in data:
if 'added' in data['ftoptions']:
for item in data['ftoptions']['added']:
tmp_ftoptions.append(item)
if 'changed' in data['ftoptions']:
for item in data['ftoptions']['changed']:
tmp_ftoptions.append(item)
if 'deleted' in data['ftoptions']:
for item in data['ftoptions']['deleted']:
tmp_ftoptions.remove(item)
data['ftoptions'] = tmp_ftoptions
SchemaDiffRegistry(blueprint.node_type, ForeignTableView)
ForeignTableView.register_node_view(blueprint) ForeignTableView.register_node_view(blueprint)

View File

@@ -16,7 +16,7 @@ LEFT OUTER JOIN
LEFT OUTER JOIN LEFT OUTER JOIN
pg_type b ON t.typelem=b.oid pg_type b ON t.typelem=b.oid
LEFT OUTER JOIN LEFT OUTER JOIN
pg_collation cl ON t.typcollation=cl.oid pg_collation cl ON att.attcollation=cl.oid
LEFT OUTER JOIN LEFT OUTER JOIN
pg_namespace cn ON cl.collnamespace=cn.oid pg_namespace cn ON cl.collnamespace=cn.oid
WHERE WHERE

View File

@@ -0,0 +1,76 @@
{% import 'macros/schemas/security.macros' as SECLABEL %}
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
{% set is_columns = [] %}
{% if data.columns %}{% set columns = data.columns %}{% elif o_data.columns %}{% set columns = o_data.columns %}{% endif %}
{% if data.inherits %}{% set inherits = data.inherits %}{% elif o_data.columns %}{% set inherits = o_data.inherits %}{% endif %}
{% if data.ftoptions %}{% set ftoptions = data.ftoptions %}{% elif o_data.ftoptions %}{% set ftoptions = o_data.ftoptions %}{% endif %}
{% if data.constraints %}{% set constraints = data.constraints %}{% elif o_data.constraints %}{% set constraints = o_data.constraints %}{% endif %}
{% if data.acl %}{% set acl = data.acl %}{% elif o_data.acl %}{% set acl = o_data.acl %}{% endif %}
-- WARNING:
-- We have found the difference in foreign server
-- so we need to drop the existing foreign table first and re-create it.
DROP FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }};
CREATE FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}(
{% if columns %}
{% for c in columns %}
{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %}
{% if is_columns.append('1') %}{% endif %}
{{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.coloptions %}
{% for o in c.coloptions %}{% if o.option and o.value %}
{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %}
{% endfor %}{% endif %}
{% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %}
{% if c.typdefault is defined and c.typdefault is not none %} DEFAULT {{c.typdefault}}{% endif %}
{% if c.collname %} COLLATE {{c.collname}}{% endif %}
{% if not loop.last %},
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
)
{% if inherits %}
INHERITS ({% for i in inherits %}{% if i %}{{i}}{% if not loop.last %}, {% endif %}{% endif %}{% endfor %})
{% endif %}
SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if ftoptions %}
{% for o in ftoptions %}
{% if o.option and o.value %}
{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %}
{% endfor %}{% endif %};
{% if data.owner %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}
OWNER TO {{ data.owner }};
{% endif -%}
{% if constraints %}
{% for c in constraints %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %};
{% endfor %}
{% endif %}
{% if data.description %}
COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}
IS '{{ data.description }}';
{ % elif o_data.description %}
COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}
IS '{{ o_data.description }}';
{% endif -%}
{% if acl %}
{% for priv in acl %}
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, o_data.name, priv.without_grant, priv.with_grant, o_data.basensp) }}
{% endfor -%}
{% endif -%}
{% if data.seclabels %}
{% for r in data.seclabels %}
{% if r.label and r.provider %}
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', o_data.name, r.provider, r.label, o_data.basensp) }}
{% endif %}
{% endfor %}
{% endif %}

View File

@@ -34,7 +34,7 @@ LEFT OUTER JOIN
LEFT OUTER JOIN LEFT OUTER JOIN
pg_type b ON t.typelem=b.oid pg_type b ON t.typelem=b.oid
LEFT OUTER JOIN LEFT OUTER JOIN
pg_collation cl ON t.typcollation=cl.oid pg_collation cl ON att.attcollation=cl.oid
LEFT OUTER JOIN LEFT OUTER JOIN
pg_namespace cn ON cl.collnamespace=cn.oid pg_namespace cn ON cl.collnamespace=cn.oid
WHERE WHERE

View File

@@ -121,6 +121,16 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %}; ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %};
{% endfor %} {% endfor %}
{% if data.is_schema_diff is defined and data.is_schema_diff %}
{% for c in data.constraints.changed %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
DROP CONSTRAINT {{conn|qtIdent(c.conname)}};
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %};
{% endfor %}
{% else %}
{% for c in data.constraints.changed %} {% for c in data.constraints.changed %}
{% if c.convalidated %} {% if c.convalidated %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
@@ -129,6 +139,7 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif %}
{% if data.ftoptions %} {% if data.ftoptions %}
{% for o in data.ftoptions.deleted %} {% for o in data.ftoptions.deleted %}
{% if o.option and o.value %} {% if o.option and o.value %}

View File

@@ -30,7 +30,7 @@ from pgadmin.utils.compile_template_name import compile_template_path
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
from pgadmin.tools.schema_diff.directory_compare import directory_diff,\ from pgadmin.tools.schema_diff.directory_compare import directory_diff,\
parce_acl parse_acl
# If we are in Python3 # If we are in Python3
@@ -1012,7 +1012,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
source, target, source, target,
ignore_keys=self.keys_to_ignore, difference={} ignore_keys=self.keys_to_ignore, difference={}
) )
diff_dict.update(parce_acl(source, target)) parse_acl(source, target, diff_dict)
diff = self.get_sql_from_diff(gid=tgt_params['gid'], diff = self.get_sql_from_diff(gid=tgt_params['gid'],
sid=tgt_params['sid'], sid=tgt_params['sid'],

View File

@@ -29,7 +29,7 @@ from pgadmin.utils import IS_PY2
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
from pgadmin.tools.schema_diff.directory_compare import directory_diff,\ from pgadmin.tools.schema_diff.directory_compare import directory_diff,\
parce_acl parse_acl
# If we are in Python3 # If we are in Python3
if not IS_PY2: if not IS_PY2:
@@ -680,7 +680,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
source, target, source, target,
ignore_keys=self.keys_to_ignore, difference={} ignore_keys=self.keys_to_ignore, difference={}
) )
diff_dict.update(parce_acl(source, target)) parse_acl(source, target, diff_dict)
diff = self.get_sql_from_diff(gid=tgt_params['gid'], diff = self.get_sql_from_diff(gid=tgt_params['gid'],
sid=tgt_params['sid'], sid=tgt_params['sid'],

View File

@@ -30,7 +30,7 @@ from pgadmin.utils import IS_PY2
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
from pgadmin.tools.schema_diff.directory_compare import directory_diff,\ from pgadmin.tools.schema_diff.directory_compare import directory_diff,\
parce_acl parse_acl
# If we are in Python3 # If we are in Python3
if not IS_PY2: if not IS_PY2:
@@ -1007,7 +1007,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
source, target, source, target,
ignore_keys=self.keys_to_ignore, difference={} ignore_keys=self.keys_to_ignore, difference={}
) )
diff_dict.update(parce_acl(source, target)) parse_acl(source, target, diff_dict)
diff = self.get_sql_from_diff(gid=tgt_params['gid'], diff = self.get_sql_from_diff(gid=tgt_params['gid'],
sid=tgt_params['sid'], sid=tgt_params['sid'],

View File

@@ -171,7 +171,7 @@ def compare_dictionaries(view_object, source_params, target_params,
ignore_keys=temp_ignore_keys, ignore_keys=temp_ignore_keys,
difference={} difference={}
) )
diff_dict.update(parce_acl(dict1[key], dict2[key])) parse_acl(dict1[key], dict2[key], diff_dict)
temp_src_params['tid'] = source_object_id temp_src_params['tid'] = source_object_id
temp_tgt_params['tid'] = target_object_id temp_tgt_params['tid'] = target_object_id
@@ -192,7 +192,7 @@ def compare_dictionaries(view_object, source_params, target_params,
dict1[key], dict2[key], dict1[key], dict2[key],
ignore_keys=view_object.keys_to_ignore, difference={} ignore_keys=view_object.keys_to_ignore, difference={}
) )
diff_dict.update(parce_acl(dict1[key], dict2[key])) parse_acl(dict1[key], dict2[key], diff_dict)
temp_src_params['oid'] = source_object_id temp_src_params['oid'] = source_object_id
temp_tgt_params['oid'] = target_object_id temp_tgt_params['oid'] = target_object_id
@@ -351,7 +351,7 @@ def directory_diff(source_dict, target_dict, ignore_keys=[], difference={}):
elif type(source) is dict: elif type(source) is dict:
tmp_key_array = ['name', 'colname', 'argid', 'token', tmp_key_array = ['name', 'colname', 'argid', 'token',
'option', 'conname', 'member_name', 'option', 'conname', 'member_name',
'label'] 'label', 'attname']
# Check the above keys are exist in the dictionary # Check the above keys are exist in the dictionary
tmp_key = is_key_exists(tmp_key_array, source) tmp_key = is_key_exists(tmp_key_array, source)
if tmp_key is not None: if tmp_key is not None:
@@ -400,6 +400,9 @@ def directory_diff(source_dict, target_dict, ignore_keys=[], difference={}):
elif tmp_target and type(tmp_target) is list: elif tmp_target and type(tmp_target) is list:
difference[key]['deleted'] = tmp_target difference[key]['deleted'] = tmp_target
# No point adding empty list into difference.
if key in difference and len(difference[key]) == 0:
difference.pop(key)
else: else:
if source_dict[key] != target_dict[key]: if source_dict[key] != target_dict[key]:
if (key == 'comment' or key == 'description') and \ if (key == 'comment' or key == 'description') and \
@@ -426,13 +429,13 @@ def is_key_exists(key_list, target_dict):
return None return None
def parce_acl(source, target): def parse_acl(source, target, diff_dict):
""" """
This function is used to parse acl. This function is used to parse acl.
:param source: :param source: Source Dict
:param target: :param target: Target Dict
:return: :param diff_dict: Difference Dict
""" """
acl_keys = ['datacl', 'relacl', 'typacl', 'pkgacl'] acl_keys = ['datacl', 'relacl', 'typacl', 'pkgacl']
key = is_key_exists(acl_keys, source) key = is_key_exists(acl_keys, source)
@@ -443,6 +446,8 @@ def parce_acl(source, target):
key = is_key_exists(acl_keys, target) key = is_key_exists(acl_keys, target)
if key is None: if key is None:
key = 'acl' key = 'acl'
elif key is not None and type(source[key]) != list:
key = 'acl'
tmp_source = source[key] if\ tmp_source = source[key] if\
key in source and source[key] is not None else [] key in source and source[key] is not None else []
@@ -457,4 +462,9 @@ def parce_acl(source, target):
diff['added'].append(acl) diff['added'].append(acl)
diff['deleted'] = tmp_target diff['deleted'] = tmp_target
return {key: diff} # Update the key if there are some element in added or deleted
# else remove that key from diff dict
if len(diff['added']) > 0 or len(diff['deleted']) > 0:
diff_dict.update({key: diff})
elif key in diff_dict:
diff_dict.pop(key)

View File

@@ -735,3 +735,107 @@ CREATE SEQUENCE source.seq_diff
CACHE 2; CACHE 2;
ALTER SEQUENCE source.seq_diff ALTER SEQUENCE source.seq_diff
OWNER TO postgres; OWNER TO postgres;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO postgres;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO postgres;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO postgres;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to postgres;
CREATE FOREIGN TABLE source.ft_src(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_src
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_src
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_src
IS 'Test Comment';
GRANT INSERT ON TABLE source.ft_src TO pg_monitor;
GRANT ALL ON TABLE source.ft_src TO postgres;
CREATE FOREIGN TABLE source.ft_diff_col(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default",
fcity character varying(40) NULL COLLATE pg_catalog."POSIX"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_col
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_diff_col
IS 'Test Comment';
CREATE FOREIGN TABLE source.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_const
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 1000)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20));
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck_src CHECK ((fid > 50));
GRANT INSERT ON TABLE source.ft_diff_const TO pg_monitor;
GRANT ALL ON TABLE source.ft_diff_const TO postgres;
CREATE FOREIGN TABLE source.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val20', opt_src 'val_src');
ALTER FOREIGN TABLE source.ft_diff_opt
OWNER TO postgres;
CREATE FOREIGN TABLE source.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_foreign_server
OWNER TO postgres;
CREATE FOREIGN TABLE source.ft_diff_foreign_server_1(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1');
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
ADD CONSTRAINT cs1 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -686,3 +686,109 @@ CREATE SEQUENCE target.seq_diff
ALTER SEQUENCE target.seq_diff ALTER SEQUENCE target.seq_diff
OWNER TO postgres; OWNER TO postgres;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO postgres;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO postgres;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO postgres;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to postgres;
CREATE FOREIGN TABLE target.ft_tar(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_tar
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_tar
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_tar
IS 'Test Comment';
GRANT INSERT ON TABLE target.ft_tar TO pg_monitor;
GRANT ALL ON TABLE target.ft_tar TO postgres;
CREATE FOREIGN TABLE target.ft_diff_col(
fid bigint NULL,
fname text NOT NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_col
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_diff_col
IS 'Comment';
GRANT INSERT ON TABLE target.ft_diff_col TO pg_monitor;
GRANT ALL ON TABLE target.ft_diff_col TO postgres;
CREATE FOREIGN TABLE target.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_const
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 50)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck_tar CHECK ((fid > 50));
GRANT INSERT ON TABLE target.ft_diff_const TO pg_monitor;
GRANT ALL ON TABLE target.ft_diff_const TO postgres;
CREATE FOREIGN TABLE target.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val30', opt_tar 'val_tar');
ALTER FOREIGN TABLE target.ft_diff_opt
OWNER TO postgres;
CREATE FOREIGN TABLE target.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_foreign_server
OWNER TO postgres;
CREATE FOREIGN TABLE target.ft_diff_foreign_server_1(
fid bigint NULL,
fcity text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val2');
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
ADD CONSTRAINT cs2 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -698,3 +698,107 @@ CREATE SEQUENCE source.seq_diff
CACHE 2; CACHE 2;
ALTER SEQUENCE source.seq_diff ALTER SEQUENCE source.seq_diff
OWNER TO postgres; OWNER TO postgres;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO postgres;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO postgres;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO postgres;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to postgres;
CREATE FOREIGN TABLE source.ft_src(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_src
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_src
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_src
IS 'Test Comment';
GRANT INSERT ON TABLE source.ft_src TO pg_monitor;
GRANT ALL ON TABLE source.ft_src TO postgres;
CREATE FOREIGN TABLE source.ft_diff_col(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default",
fcity character varying(40) NULL COLLATE pg_catalog."POSIX"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_col
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_diff_col
IS 'Test Comment';
CREATE FOREIGN TABLE source.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_const
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 1000)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20));
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck_src CHECK ((fid > 50));
GRANT INSERT ON TABLE source.ft_diff_const TO pg_monitor;
GRANT ALL ON TABLE source.ft_diff_const TO postgres;
CREATE FOREIGN TABLE source.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val20', opt_src 'val_src');
ALTER FOREIGN TABLE source.ft_diff_opt
OWNER TO postgres;
CREATE FOREIGN TABLE source.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_foreign_server
OWNER TO postgres;
CREATE FOREIGN TABLE source.ft_diff_foreign_server_1(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1');
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
ADD CONSTRAINT cs1 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -685,3 +685,109 @@ CREATE SEQUENCE target.seq_diff
ALTER SEQUENCE target.seq_diff ALTER SEQUENCE target.seq_diff
OWNER TO postgres; OWNER TO postgres;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO postgres;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO postgres;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO postgres;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to postgres;
CREATE FOREIGN TABLE target.ft_tar(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_tar
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_tar
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_tar
IS 'Test Comment';
GRANT INSERT ON TABLE target.ft_tar TO pg_monitor;
GRANT ALL ON TABLE target.ft_tar TO postgres;
CREATE FOREIGN TABLE target.ft_diff_col(
fid bigint NULL,
fname text NOT NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_col
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_diff_col
IS 'Comment';
GRANT INSERT ON TABLE target.ft_diff_col TO pg_monitor;
GRANT ALL ON TABLE target.ft_diff_col TO postgres;
CREATE FOREIGN TABLE target.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_const
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 50)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck_tar CHECK ((fid > 50));
GRANT INSERT ON TABLE target.ft_diff_const TO pg_monitor;
GRANT ALL ON TABLE target.ft_diff_const TO postgres;
CREATE FOREIGN TABLE target.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val30', opt_tar 'val_tar');
ALTER FOREIGN TABLE target.ft_diff_opt
OWNER TO postgres;
CREATE FOREIGN TABLE target.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_foreign_server
OWNER TO postgres;
CREATE FOREIGN TABLE target.ft_diff_foreign_server_1(
fid bigint NULL,
fcity text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val2');
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
ADD CONSTRAINT cs2 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -699,3 +699,107 @@ CREATE SEQUENCE source.seq_diff
CACHE 2; CACHE 2;
ALTER SEQUENCE source.seq_diff ALTER SEQUENCE source.seq_diff
OWNER TO postgres; OWNER TO postgres;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO postgres;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO postgres;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO postgres;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to postgres;
CREATE FOREIGN TABLE source.ft_src(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_src
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_src
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_src
IS 'Test Comment';
GRANT INSERT ON TABLE source.ft_src TO pg_monitor;
GRANT ALL ON TABLE source.ft_src TO postgres;
CREATE FOREIGN TABLE source.ft_diff_col(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default",
fcity character varying(40) NULL COLLATE pg_catalog."POSIX"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_col
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_diff_col
IS 'Test Comment';
CREATE FOREIGN TABLE source.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_const
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 1000)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20));
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck_src CHECK ((fid > 50));
GRANT INSERT ON TABLE source.ft_diff_const TO pg_monitor;
GRANT ALL ON TABLE source.ft_diff_const TO postgres;
CREATE FOREIGN TABLE source.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val20', opt_src 'val_src');
ALTER FOREIGN TABLE source.ft_diff_opt
OWNER TO postgres;
CREATE FOREIGN TABLE source.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_foreign_server
OWNER TO postgres;
CREATE FOREIGN TABLE source.ft_diff_foreign_server_1(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1');
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
ADD CONSTRAINT cs1 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -674,3 +674,109 @@ CREATE SEQUENCE target.seq_diff
ALTER SEQUENCE target.seq_diff ALTER SEQUENCE target.seq_diff
OWNER TO postgres; OWNER TO postgres;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO postgres;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO postgres;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO postgres;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to postgres;
CREATE FOREIGN TABLE target.ft_tar(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_tar
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_tar
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_tar
IS 'Test Comment';
GRANT INSERT ON TABLE target.ft_tar TO pg_monitor;
GRANT ALL ON TABLE target.ft_tar TO postgres;
CREATE FOREIGN TABLE target.ft_diff_col(
fid bigint NULL,
fname text NOT NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_col
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_diff_col
IS 'Comment';
GRANT INSERT ON TABLE target.ft_diff_col TO pg_monitor;
GRANT ALL ON TABLE target.ft_diff_col TO postgres;
CREATE FOREIGN TABLE target.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_const
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 50)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck_tar CHECK ((fid > 50));
GRANT INSERT ON TABLE target.ft_diff_const TO pg_monitor;
GRANT ALL ON TABLE target.ft_diff_const TO postgres;
CREATE FOREIGN TABLE target.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val30', opt_tar 'val_tar');
ALTER FOREIGN TABLE target.ft_diff_opt
OWNER TO postgres;
CREATE FOREIGN TABLE target.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_foreign_server
OWNER TO postgres;
CREATE FOREIGN TABLE target.ft_diff_foreign_server_1(
fid bigint NULL,
fcity text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val2');
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
ADD CONSTRAINT cs2 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -568,3 +568,107 @@ CREATE SEQUENCE source.seq_diff
CACHE 2; CACHE 2;
ALTER SEQUENCE source.seq_diff ALTER SEQUENCE source.seq_diff
OWNER TO postgres; OWNER TO postgres;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO postgres;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO postgres;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO postgres;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to postgres;
CREATE FOREIGN TABLE source.ft_src(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_src
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_src
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_src
IS 'Test Comment';
GRANT INSERT ON TABLE source.ft_src TO PUBLIC;
GRANT ALL ON TABLE source.ft_src TO postgres;
CREATE FOREIGN TABLE source.ft_diff_col(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default",
fcity character varying(40) NULL COLLATE pg_catalog."POSIX"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_col
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_diff_col
IS 'Test Comment';
CREATE FOREIGN TABLE source.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_const
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 1000)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20));
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck_src CHECK ((fid > 50));
GRANT INSERT ON TABLE source.ft_diff_const TO PUBLIC;
GRANT ALL ON TABLE source.ft_diff_const TO postgres;
CREATE FOREIGN TABLE source.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val20', opt_src 'val_src');
ALTER FOREIGN TABLE source.ft_diff_opt
OWNER TO postgres;
CREATE FOREIGN TABLE source.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_foreign_server
OWNER TO postgres;
CREATE FOREIGN TABLE source.ft_diff_foreign_server_1(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1');
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
OWNER TO postgres;
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
ADD CONSTRAINT cs1 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -592,3 +592,109 @@ CREATE SEQUENCE target.seq_diff
ALTER SEQUENCE target.seq_diff ALTER SEQUENCE target.seq_diff
OWNER TO postgres; OWNER TO postgres;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO postgres;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO postgres;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO postgres;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to postgres;
CREATE FOREIGN TABLE target.ft_tar(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_tar
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_tar
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_tar
IS 'Test Comment';
GRANT INSERT ON TABLE target.ft_tar TO PUBLIC;
GRANT ALL ON TABLE target.ft_tar TO postgres;
CREATE FOREIGN TABLE target.ft_diff_col(
fid bigint NULL,
fname text NOT NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_col
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_diff_col
IS 'Comment';
GRANT INSERT ON TABLE target.ft_diff_col TO PUBLIC;
GRANT ALL ON TABLE target.ft_diff_col TO postgres;
CREATE FOREIGN TABLE target.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_const
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 50)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck_tar CHECK ((fid > 50));
GRANT INSERT ON TABLE target.ft_diff_const TO PUBLIC;
GRANT ALL ON TABLE target.ft_diff_const TO postgres;
CREATE FOREIGN TABLE target.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val30', opt_tar 'val_tar');
ALTER FOREIGN TABLE target.ft_diff_opt
OWNER TO postgres;
CREATE FOREIGN TABLE target.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_foreign_server
OWNER TO postgres;
CREATE FOREIGN TABLE target.ft_diff_foreign_server_1(
fid bigint NULL,
fcity text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val2');
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
OWNER TO postgres;
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
ADD CONSTRAINT cs2 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -1,5 +1,5 @@
-- --
-- PostgreSQL database dump -- enterprisedbQL database dump
-- --
-- Dumped from database version 10.7 -- Dumped from database version 10.7
@@ -519,11 +519,11 @@ CREATE TYPE source.typ_range_col_diff AS RANGE
SUBTYPE_OPCLASS = text_ops SUBTYPE_OPCLASS = text_ops
); );
ALTER TYPE source.typ_range_col_diff ALTER TYPE source.typ_range_col_diff
OWNER TO pg_monitor; OWNER TO PUBLIC;
COMMENT ON TYPE source.typ_range_col_diff COMMENT ON TYPE source.typ_range_col_diff
IS 'Test Comment'; IS 'Test Comment';
GRANT USAGE ON TYPE source.typ_range_col_diff TO PUBLIC; GRANT USAGE ON TYPE source.typ_range_col_diff TO PUBLIC;
GRANT USAGE ON TYPE source.typ_range_col_diff TO pg_monitor WITH GRANT OPTION; GRANT USAGE ON TYPE source.typ_range_col_diff TO PUBLIC WITH GRANT OPTION;
CREATE TYPE source.typ_range_subtype_diff AS RANGE CREATE TYPE source.typ_range_subtype_diff AS RANGE
( (
@@ -796,3 +796,107 @@ CREATE SEQUENCE source.seq_diff
CACHE 2; CACHE 2;
ALTER SEQUENCE source.seq_diff ALTER SEQUENCE source.seq_diff
OWNER TO enterprisedb; OWNER TO enterprisedb;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO enterprisedb;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO enterprisedb;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO enterprisedb;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to enterprisedb;
CREATE FOREIGN TABLE source.ft_src(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_src
OWNER TO enterprisedb;
ALTER FOREIGN TABLE source.ft_src
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_src
IS 'Test Comment';
GRANT INSERT ON TABLE source.ft_src TO PUBLIC;
GRANT ALL ON TABLE source.ft_src TO enterprisedb;
CREATE FOREIGN TABLE source.ft_diff_col(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default",
fcity character varying(40) NULL COLLATE pg_catalog."POSIX"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_col
OWNER TO enterprisedb;
ALTER FOREIGN TABLE source.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_diff_col
IS 'Test Comment';
CREATE FOREIGN TABLE source.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_const
OWNER TO enterprisedb;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 1000)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20));
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck_src CHECK ((fid > 50));
GRANT INSERT ON TABLE source.ft_diff_const TO PUBLIC;
GRANT ALL ON TABLE source.ft_diff_const TO enterprisedb;
CREATE FOREIGN TABLE source.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val20', opt_src 'val_src');
ALTER FOREIGN TABLE source.ft_diff_opt
OWNER TO enterprisedb;
CREATE FOREIGN TABLE source.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_foreign_server
OWNER TO enterprisedb;
CREATE FOREIGN TABLE source.ft_diff_foreign_server_1(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1');
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
OWNER TO enterprisedb;
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
ADD CONSTRAINT cs1 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -1,5 +1,5 @@
-- --
-- PostgreSQL database dump -- enterprisedbQL database dump
-- --
-- Dumped from database version 10.7 -- Dumped from database version 10.7
@@ -531,7 +531,7 @@ ALTER TYPE target.typ_shell_tar
CREATE TYPE target.typ_shell_diff; CREATE TYPE target.typ_shell_diff;
ALTER TYPE target.typ_shell_diff ALTER TYPE target.typ_shell_diff
OWNER TO pg_monitor; OWNER TO PUBLIC;
-- Type script to test when Type is different -- Type script to test when Type is different
CREATE TYPE target.typ_comp_range_diff AS RANGE CREATE TYPE target.typ_comp_range_diff AS RANGE
@@ -773,3 +773,109 @@ CREATE SEQUENCE target.seq_diff
ALTER SEQUENCE target.seq_diff ALTER SEQUENCE target.seq_diff
OWNER TO enterprisedb; OWNER TO enterprisedb;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO enterprisedb;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO enterprisedb;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO enterprisedb;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to enterprisedb;
CREATE FOREIGN TABLE target.ft_tar(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_tar
OWNER TO enterprisedb;
ALTER FOREIGN TABLE target.ft_tar
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_tar
IS 'Test Comment';
GRANT INSERT ON TABLE target.ft_tar TO PUBLIC;
GRANT ALL ON TABLE target.ft_tar TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_col(
fid bigint NULL,
fname text NOT NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_col
OWNER TO enterprisedb;
ALTER FOREIGN TABLE target.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_diff_col
IS 'Comment';
GRANT INSERT ON TABLE target.ft_diff_col TO PUBLIC;
GRANT ALL ON TABLE target.ft_diff_col TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_const
OWNER TO enterprisedb;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 50)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck_tar CHECK ((fid > 50));
GRANT INSERT ON TABLE target.ft_diff_const TO PUBLIC;
GRANT ALL ON TABLE target.ft_diff_const TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val30', opt_tar 'val_tar');
ALTER FOREIGN TABLE target.ft_diff_opt
OWNER TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_foreign_server
OWNER TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_foreign_server_1(
fid bigint NULL,
fcity text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val2');
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
OWNER TO enterprisedb;
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
ADD CONSTRAINT cs2 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -1,5 +1,5 @@
-- --
-- PostgreSQL database dump -- enterprisedbQL database dump
-- --
-- Dumped from database version 10.7 -- Dumped from database version 10.7
@@ -728,3 +728,107 @@ CREATE SEQUENCE source.seq_diff
CACHE 2; CACHE 2;
ALTER SEQUENCE source.seq_diff ALTER SEQUENCE source.seq_diff
OWNER TO enterprisedb; OWNER TO enterprisedb;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO enterprisedb;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO enterprisedb;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO enterprisedb;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to enterprisedb;
CREATE FOREIGN TABLE source.ft_src(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_src
OWNER TO enterprisedb;
ALTER FOREIGN TABLE source.ft_src
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_src
IS 'Test Comment';
GRANT INSERT ON TABLE source.ft_src TO PUBLIC;
GRANT ALL ON TABLE source.ft_src TO enterprisedb;
CREATE FOREIGN TABLE source.ft_diff_col(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default",
fcity character varying(40) NULL COLLATE pg_catalog."POSIX"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_col
OWNER TO enterprisedb;
ALTER FOREIGN TABLE source.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE source.ft_diff_col
IS 'Test Comment';
CREATE FOREIGN TABLE source.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_const
OWNER TO enterprisedb;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 1000)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20));
ALTER FOREIGN TABLE source.ft_diff_const
ADD CONSTRAINT fcheck_src CHECK ((fid > 50));
GRANT INSERT ON TABLE source.ft_diff_const TO PUBLIC;
GRANT ALL ON TABLE source.ft_diff_const TO enterprisedb;
CREATE FOREIGN TABLE source.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val20', opt_src 'val_src');
ALTER FOREIGN TABLE source.ft_diff_opt
OWNER TO enterprisedb;
CREATE FOREIGN TABLE source.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE source.ft_diff_foreign_server
OWNER TO enterprisedb;
CREATE FOREIGN TABLE source.ft_diff_foreign_server_1(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1');
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
OWNER TO enterprisedb;
ALTER FOREIGN TABLE source.ft_diff_foreign_server_1
ADD CONSTRAINT cs1 CHECK ((fid > 200)) NO INHERIT;

View File

@@ -1,5 +1,5 @@
-- --
-- PostgreSQL database dump -- enterprisedbQL database dump
-- --
-- Dumped from database version 10.7 -- Dumped from database version 10.7
@@ -742,3 +742,109 @@ CREATE SEQUENCE target.seq_diff
ALTER SEQUENCE target.seq_diff ALTER SEQUENCE target.seq_diff
OWNER TO enterprisedb; OWNER TO enterprisedb;
-- Foreign Data Wrapper to test foreign table
CREATE FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER FOREIGN DATA WRAPPER test_fdw_for_foreign_table
OWNER TO enterprisedb;
-- Foreign Server to test foreign table
CREATE SERVER test_fs_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs_for_foreign_table
OWNER TO enterprisedb;
CREATE SERVER test_fs2_for_foreign_table
FOREIGN DATA WRAPPER test_fdw_for_foreign_table;
ALTER SERVER test_fs2_for_foreign_table
OWNER TO enterprisedb;
-- Table to test inheritance in foreign table
CREATE TABLE public.test_table_for_foreign_table
(
tid bigint NOT NULL,
tname text COLLATE pg_catalog."default",
CONSTRAINT test_table_for_foreign_table_pkey PRIMARY KEY (tid)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.test_table_for_foreign_table
OWNER to enterprisedb;
CREATE FOREIGN TABLE target.ft_tar(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_tar
OWNER TO enterprisedb;
ALTER FOREIGN TABLE target.ft_tar
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_tar
IS 'Test Comment';
GRANT INSERT ON TABLE target.ft_tar TO PUBLIC;
GRANT ALL ON TABLE target.ft_tar TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_col(
fid bigint NULL,
fname text NOT NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_col
OWNER TO enterprisedb;
ALTER FOREIGN TABLE target.ft_diff_col
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
COMMENT ON FOREIGN TABLE target.ft_diff_col
IS 'Comment';
GRANT INSERT ON TABLE target.ft_diff_col TO PUBLIC;
GRANT ALL ON TABLE target.ft_diff_col TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_const(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_const
OWNER TO enterprisedb;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck CHECK ((fid > 1000)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck1 CHECK ((fid > 50)) NO INHERIT NOT VALID;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck2 CHECK ((fid > 20)) NO INHERIT;
ALTER FOREIGN TABLE target.ft_diff_const
ADD CONSTRAINT fcheck_tar CHECK ((fid > 50));
GRANT INSERT ON TABLE target.ft_diff_const TO PUBLIC;
GRANT ALL ON TABLE target.ft_diff_const TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_opt(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val30', opt_tar 'val_tar');
ALTER FOREIGN TABLE target.ft_diff_opt
OWNER TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_foreign_server(
fid bigint NULL,
fname text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table;
ALTER FOREIGN TABLE target.ft_diff_foreign_server
OWNER TO enterprisedb;
CREATE FOREIGN TABLE target.ft_diff_foreign_server_1(
fid bigint NULL,
fcity text NULL COLLATE pg_catalog."default"
)
SERVER test_fs2_for_foreign_table
OPTIONS (opt1 'val1', opt2 'val2');
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
OWNER TO enterprisedb;
ALTER FOREIGN TABLE target.ft_diff_foreign_server_1
ADD CONSTRAINT cs2 CHECK ((fid > 200)) NO INHERIT;