Add Reverse Engineered and Modified SQL tests for Foreign Tables. Fixes #4618.

pull/26/head
Akshay Joshi 2019-09-04 18:33:07 +05:30
parent 2d4429fa64
commit 5e54f20578
58 changed files with 1714 additions and 43 deletions

View File

@ -21,6 +21,7 @@ Housekeeping
| `Issue #4576 <https://redmine.postgresql.org/issues/4576>`_ - Add Reverse Engineered SQL tests for Views. | `Issue #4576 <https://redmine.postgresql.org/issues/4576>`_ - Add Reverse Engineered SQL tests for Views.
| `Issue #4600 <https://redmine.postgresql.org/issues/4600>`_ - Add Reverse Engineered SQL tests for Rules. | `Issue #4600 <https://redmine.postgresql.org/issues/4600>`_ - Add Reverse Engineered SQL tests for Rules.
| `Issue #4617 <https://redmine.postgresql.org/issues/4617>`_ - Add Reverse Engineered and Modified SQL tests for Foreign Servers. | `Issue #4617 <https://redmine.postgresql.org/issues/4617>`_ - Add Reverse Engineered and Modified SQL tests for Foreign Servers.
| `Issue #4618 <https://redmine.postgresql.org/issues/4618>`_ - Add Reverse Engineered and Modified SQL tests for Foreign Tables.
| `Issue #4619 <https://redmine.postgresql.org/issues/4619>`_ - Add Reverse Engineered and Modified SQL tests for FTS Templates. | `Issue #4619 <https://redmine.postgresql.org/issues/4619>`_ - Add Reverse Engineered and Modified SQL tests for FTS Templates.
| `Issue #4627 <https://redmine.postgresql.org/issues/4627>`_ - Add Reverse Engineered and Modified SQL tests for User Mappings. | `Issue #4627 <https://redmine.postgresql.org/issues/4627>`_ - Add Reverse Engineered and Modified SQL tests for User Mappings.
| `Issue #4690 <https://redmine.postgresql.org/issues/4690>`_ - Add Modified SQL tests for Resource Group. | `Issue #4690 <https://redmine.postgresql.org/issues/4690>`_ - Add Modified SQL tests for Resource Group.

View File

@ -827,6 +827,11 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
data['columns'] = col_data data['columns'] = col_data
# Parse Privileges
if 'acl' in data:
data['acl'] = parse_priv_to_db(data['acl'],
["a", "r", "w", "x"])
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)

View File

@ -1,5 +1,6 @@
SELECT SELECT
oid as conoid, conname, contype, pg_get_constraintdef(oid, true) as consrc, oid as conoid, conname, contype,
BTRIM(substring(pg_get_constraintdef(oid, true) from '\(.+\)'), '()') as consrc,
connoinherit, convalidated, conislocal connoinherit, convalidated, conislocal
FROM FROM
pg_constraint pg_constraint

View File

@ -32,4 +32,5 @@ FROM
) d ) d
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname; GROUP BY g.rolname, gt.rolname
ORDER BY grantee;

View File

@ -6,22 +6,22 @@
{% if data.name != o_data.name %} {% if data.name != o_data.name %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}
RENAME TO {{ conn|qtIdent(data.name) }}; RENAME TO {{ conn|qtIdent(data.name) }};
{% set name = data.name %} {% set name = data.name %}
{% endif %} {% endif %}
{% endif -%} {% endif -%}
{% if data.owner %} {% if data.owner %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
OWNER TO {{ data.owner }}; OWNER TO {{ data.owner }};
{% endif -%} {% endif -%}
{% if data.columns %} {% if data.columns %}
{% for c in data.columns.deleted %} {% for c in data.columns.deleted %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
DROP COLUMN {{conn|qtIdent(c.attname)}}; DROP COLUMN {{conn|qtIdent(c.attname)}};
{% endfor -%} {% endfor -%}
{% for c in data.columns.added %} {% for c in data.columns.added %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %} ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}
{% if c.coloptions %} {% if c.coloptions %}
@ -31,38 +31,38 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
{% if c.attnotnull %} NOT NULL{% else %} NULL{% 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.typdefault is defined and c.typdefault is not none %} DEFAULT {{c.typdefault}}{% endif %}
{% if c.collname %} COLLATE {{c.collname}}{% endif %}; {% if c.collname %} COLLATE {{c.collname}}{% endif %};
{% endfor -%} {% endfor -%}
{% for c in data.columns.changed %} {% for c in data.columns.changed %}
{% set col_name = o_data['columns'][c.attnum]['attname'] %} {% set col_name = o_data['columns'][c.attnum]['attname'] %}
{% if c.attname != o_data['columns'][c.attnum]['attname'] %} {% if c.attname != o_data['columns'][c.attnum]['attname'] %}
{% set col_name = c.attname %} {% set col_name = c.attname %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
RENAME COLUMN {{conn|qtIdent(o_data['columns'][c.attnum]['attname'])}} TO {{conn|qtIdent(c.attname)}}; RENAME COLUMN {{conn|qtIdent(o_data['columns'][c.attnum]['attname'])}} TO {{conn|qtIdent(c.attname)}};
{% endif %} {% endif %}
{% if c.attnotnull != o_data['columns'][c.attnum]['attnotnull'] %} {% if c.attnotnull != o_data['columns'][c.attnum]['attnotnull'] %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.attnotnull %} SET{% else %} DROP{% endif %} NOT NULL; ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.attnotnull %} SET{% else %} DROP{% endif %} NOT NULL;
{% endif %} {% endif %}
{% if c.datatype != o_data['columns'][c.attnum]['datatype'] or c.typlen != o_data['columns'][c.attnum]['typlen'] or {% if c.datatype != o_data['columns'][c.attnum]['datatype'] or c.typlen != o_data['columns'][c.attnum]['typlen'] or
c.precision != o_data['columns'][c.attnum]['precision'] %} c.precision != o_data['columns'][c.attnum]['precision'] %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ALTER COLUMN {{conn|qtIdent(col_name)}} TYPE {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}; ALTER COLUMN {{conn|qtIdent(col_name)}} TYPE {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %};
{% endif %} {% endif %}
{% if c.typdefault is defined and c.typdefault != o_data['columns'][c.attnum]['typdefault'] %} {% if c.typdefault is defined and c.typdefault != o_data['columns'][c.attnum]['typdefault'] %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault is defined and c.typdefault != '' %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% endif %}; ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault is defined and c.typdefault != '' %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% endif %};
{% endif %} {% endif %}
{% if c.attstattarget != o_data['columns'][c.attnum]['attstattarget'] %} {% if c.attstattarget != o_data['columns'][c.attnum]['attstattarget'] %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ALTER COLUMN {{conn|qtIdent(col_name)}} SET STATISTICS {% if c.attstattarget %}{{c.attstattarget}}{% else %}-1{% endif %}; ALTER COLUMN {{conn|qtIdent(col_name)}} SET STATISTICS {% if c.attstattarget %}{{c.attstattarget}}{% else %}-1{% endif %};
{% endif %} {% endif %}
{% if c.coloptions_updated %} {% if c.coloptions_updated %}
{% for o in c.coloptions_updated.deleted %} {% for o in c.coloptions_updated.deleted %}
{% if o.option %} {% if o.option %}
{% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} {% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
@ -86,58 +86,58 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
{% endif -%} {% endif -%}
{% if data.constraints %} {% if data.constraints %}
{% for c in data.constraints.deleted %} {% for c in data.constraints.deleted %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
DROP CONSTRAINT {{conn|qtIdent(c.conname)}}; DROP CONSTRAINT {{conn|qtIdent(c.conname)}};
{% endfor %} {% endfor %}
{% for c in data.constraints.added %} {% for c in data.constraints.added %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ADD CONSTRAINT {{conn|qtIdent(c.conname)}} {% if c.consrc %} CHECK ({{c.consrc}}){% endif %} {% if c.connoinherit %} NO INHERIT{% endif %}; ADD CONSTRAINT {{conn|qtIdent(c.conname)}} {% if c.consrc %} CHECK ({{c.consrc}}){% endif %} {% if c.connoinherit %} NO INHERIT{% endif %};
{% endfor %} {% endfor %}
{% 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 %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
OPTIONS ( DROP {{o.option}}); OPTIONS ( DROP {{o.option}});
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% for o in data.ftoptions.added %} {% for o in data.ftoptions.added %}
{% if o.option and o.value %} {% if o.option and o.value %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}}); OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}});
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% for o in data.ftoptions.changed %} {% for o in data.ftoptions.changed %}
{% if o.option and o.value %} {% if o.option and o.value %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
OPTIONS (SET {{o.option}} {{o.value|qtLiteral}}); OPTIONS (SET {{o.option}} {{o.value|qtLiteral}});
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif -%} {% endif -%}
{% if data.acl %} {% if data.acl %}
{% if 'deleted' in data.acl %} {% if 'deleted' in data.acl %}
{% for priv in data.acl.deleted %} {% for priv in data.acl.deleted %}
{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }}
{% endfor %} {% endfor %}
{% endif -%} {% endif -%}
{% if 'changed' in data.acl %} {% if 'changed' in data.acl %}
{% for priv in data.acl.changed %} {% for priv in data.acl.changed %}
{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }}
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }}
{% endfor %} {% endfor %}
{% endif -%} {% endif -%}
{% if 'added' in data.acl %} {% if 'added' in data.acl %}
{% for priv in data.acl.added %} {% for priv in data.acl.added %}
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif -%} {% endif -%}
@ -161,12 +161,11 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
{% endfor %} {% endfor %}
{% endif -%} {% endif -%}
{% if data.description is defined and data.description != o_data.description%} {% if data.description is defined and data.description != o_data.description%}
COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
IS {{ data.description|qtLiteral }}; IS {{ data.description|qtLiteral }};
{% endif -%} {% endif -%}
{% if data.basensp %} {% if data.basensp %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
SET SCHEMA {{ conn|qtIdent(data.basensp) }}; SET SCHEMA {{ conn|qtIdent(data.basensp) }};
{% endif %} {% endif %}

View File

@ -5,23 +5,24 @@
{% if data.name %}{% if data.name != o_data.name %} {% if data.name %}{% if data.name != o_data.name %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }}
RENAME TO {{ conn|qtIdent(data.name) }}; RENAME TO {{ conn|qtIdent(data.name) }};
{% set name = data.name %} {% set name = data.name %}
{% endif %}{% endif %} {% endif %}{% endif %}
{% if data.owner %} {% if data.owner %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
OWNER TO {{ data.owner }}; OWNER TO {{ data.owner }};
{% endif %} {% endif %}
{% if data.columns %} {% if data.columns %}
{% for c in data.columns.deleted %} {% for c in data.columns.deleted %}
{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} {% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
DROP COLUMN {{conn|qtIdent(c.attname)}}; DROP COLUMN {{conn|qtIdent(c.attname)}};
{% endif %} {% endif %}
{% endfor -%} {% endfor -%}
{% for c in data.columns.added %} {% for c in data.columns.added %}
{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} {% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %} ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}
{% if c.coloptions %} {% if c.coloptions %}
@ -31,39 +32,39 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
{% if c.attnotnull %} NOT NULL{% else %} NULL{% 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.typdefault is defined and c.typdefault is not none %} DEFAULT {{c.typdefault}}{% endif %}
{% if c.collname %} COLLATE {{c.collname}}{% endif %}; {% if c.collname %} COLLATE {{c.collname}}{% endif %};
{% endif %} {% endif %}
{% endfor -%} {% endfor -%}
{% for c in data.columns.changed %} {% for c in data.columns.changed %}
{% set col_name = o_data['columns'][c.attnum]['attname'] %} {% set col_name = o_data['columns'][c.attnum]['attname'] %}
{% if c.attname != o_data['columns'][c.attnum]['attname'] %} {% if c.attname != o_data['columns'][c.attnum]['attname'] %}
{% set col_name = c.attname %} {% set col_name = c.attname %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
RENAME COLUMN {{conn|qtIdent(o_data['columns'][c.attnum]['attname'])}} TO {{conn|qtIdent(c.attname)}}; RENAME COLUMN {{conn|qtIdent(o_data['columns'][c.attnum]['attname'])}} TO {{conn|qtIdent(c.attname)}};
{% endif %} {% endif %}
{% if c.attnotnull != o_data['columns'][c.attnum]['attnotnull'] %} {% if c.attnotnull != o_data['columns'][c.attnum]['attnotnull'] %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.attnotnull %} SET{% else %} DROP{% endif %} NOT NULL; ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.attnotnull %} SET{% else %} DROP{% endif %} NOT NULL;
{% endif %} {% endif %}
{% if c.datatype != o_data['columns'][c.attnum]['datatype'] or c.typlen != o_data['columns'][c.attnum]['typlen'] or {% if c.datatype != o_data['columns'][c.attnum]['datatype'] or c.typlen != o_data['columns'][c.attnum]['typlen'] or
c.precision != o_data['columns'][c.attnum]['precision'] %} c.precision != o_data['columns'][c.attnum]['precision'] %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ALTER COLUMN {{conn|qtIdent(col_name)}} TYPE {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}; ALTER COLUMN {{conn|qtIdent(col_name)}} TYPE {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %};
{% endif %} {% endif %}
{% if c.typdefault is defined and c.typdefault != o_data['columns'][c.attnum]['typdefault'] %} {% if c.typdefault is defined and c.typdefault != o_data['columns'][c.attnum]['typdefault'] %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault is defined and c.typdefault != '' %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% endif %}; ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault is defined and c.typdefault != '' %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% endif %};
{% endif %} {% endif %}
{% if c.attstattarget != o_data['columns'][c.attnum]['attstattarget'] %} {% if c.attstattarget != o_data['columns'][c.attnum]['attstattarget'] %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
ALTER COLUMN {{conn|qtIdent(col_name)}} SET STATISTICS {% if c.attstattarget %}{{c.attstattarget}}{% else %}-1{% endif %}; ALTER COLUMN {{conn|qtIdent(col_name)}} SET STATISTICS {% if c.attstattarget %}{{c.attstattarget}}{% else %}-1{% endif %};
{% endif %} {% endif %}
{% if c.coloptions_updated %} {% if c.coloptions_updated %}
{% for o in c.coloptions_updated.deleted %} {% for o in c.coloptions_updated.deleted %}
{% if o.option %} {% if o.option %}
{% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} {% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
@ -93,7 +94,6 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
{% endif %} {% endif %}
{% for i in data.inherits %} {% for i in data.inherits %}
{% if i not in inherits %}{% if i %} {% if i not in inherits %}{% if i %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} INHERIT {{i}}; ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} INHERIT {{i}};
{% endif %} {% endif %}
{% endif %} {% endif %}
@ -106,50 +106,49 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} INHERIT {{i}};
{% set inherits = data.inherits %} {% set inherits = data.inherits %}
{% endif %} {% endif %}
{% for i in o_data.inherits %}{% if i not in inherits %}{% if i %} {% for i in o_data.inherits %}{% if i not in inherits %}{% if i %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} NO INHERIT {{i}};{% endif %} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} NO INHERIT {{i}};{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if data.constraints %} {% if data.constraints %}
{% for c in data.constraints.deleted %} {% for c in data.constraints.deleted %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
DROP CONSTRAINT {{conn|qtIdent(c.conname)}}; DROP CONSTRAINT {{conn|qtIdent(c.conname)}};
{% endfor -%} {% endfor -%}
{% for c in data.constraints.added %} {% for c in data.constraints.added %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} 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 %}
{% 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) }}
VALIDATE CONSTRAINT {{ conn|qtIdent(c.conname) }}; VALIDATE CONSTRAINT {{ conn|qtIdent(c.conname) }};
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% 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 %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
OPTIONS ( DROP {{o.option}}); OPTIONS ( DROP {{o.option}});
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% for o in data.ftoptions.added %} {% for o in data.ftoptions.added %}
{% if o.option and o.value %} {% if o.option and o.value %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}}); OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}});
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% for o in data.ftoptions.changed %} {% for o in data.ftoptions.changed %}
{% if o.option and o.value %} {% if o.option and o.value %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
OPTIONS (SET {{o.option}} {{o.value|qtLiteral}}); OPTIONS (SET {{o.option}} {{o.value|qtLiteral}});
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif -%} {% endif -%}
@ -173,34 +172,33 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
{% endfor %} {% endfor %}
{% endif -%} {% endif -%}
{% if data.description is defined and data.description != o_data.description%} {% if data.description is defined and data.description != o_data.description%}
COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
IS {{ data.description|qtLiteral }}; IS {{ data.description|qtLiteral }};
{% endif -%} {% endif -%}
{% if data.acl %} {% if data.acl %}
{% if 'deleted' in data.acl %} {% if 'deleted' in data.acl %}
{% for priv in data.acl.deleted %} {% for priv in data.acl.deleted %}
{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }}
{% endfor %} {% endfor %}
{% endif -%} {% endif -%}
{% if 'changed' in data.acl %} {% if 'changed' in data.acl %}
{% for priv in data.acl.changed %} {% for priv in data.acl.changed %}
{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }}
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }}
{% endfor %} {% endfor %}
{% endif -%} {% endif -%}
{% if 'added' in data.acl %} {% if 'added' in data.acl %}
{% for priv in data.acl.added %} {% for priv in data.acl.added %}
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif -%} {% endif -%}
{% if data.basensp %} {% if data.basensp %}
ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
SET SCHEMA {{ conn|qtIdent(data.basensp) }}; SET SCHEMA {{ conn|qtIdent(data.basensp) }};
{% endif %} {% endif %}

View File

@ -0,0 +1,16 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,5 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (ADD schema_name 'public');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (ADD table_name 'test_table');

View File

@ -0,0 +1,20 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -0,0 +1 @@
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,19 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 integer NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'test_public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -0,0 +1,14 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
DROP COLUMN col2;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 DROP NOT NULL;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 TYPE integer;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 SET STATISTICS -1;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (SET schema_name 'test_public');

View File

@ -0,0 +1,15 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,8 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD COLUMN col1 bigint NULL;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD COLUMN col2 text NULL;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,17 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 integer NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -0,0 +1,4 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS ( DROP schema_name);
REVOKE ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" FROM PUBLIC;

View File

@ -0,0 +1,20 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -0,0 +1,14 @@
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,242 @@
{
"scenarios": [
{
"type": "create",
"name": "Create FDW for foreign table",
"endpoint": "NODE-foreign_data_wrapper.obj",
"sql_endpoint": "NODE-foreign_data_wrapper.sql_id",
"data": {
"name": "test_fdw_for_foreign_table",
"fdwacl": [],
"fdwoptions": []
},
"store_object_id": "True"
}, {
"type": "create",
"name": "Create foreign server for foreign table",
"endpoint": "NODE-foreign_server.obj",
"sql_endpoint": "NODE-foreign_server.sql_id",
"data": {
"name":"test_fs_for_foreign_table"
},
"store_object_id": "True"
}, {
"type": "create",
"name": "Create Foreign Table with all options",
"endpoint": "NODE-foreign_table.obj",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql",
"data": {
"name": "FT1_$%{}[]()&*^!@\"'`\\/#",
"owner":"postgres",
"schema": "public",
"basensp":"public",
"description":"Test Comment",
"ftsrvname":"test_fs_for_foreign_table",
"columns":[{
"attname":"col1",
"datatype":"bigint",
"coloptions":[]
},{
"attname":"col2",
"datatype":"text",
"coloptions":[]
}],
"ftoptions":[{
"option":"schema_name",
"value":"public"
},{
"option":"table_name",
"value":"test_table"
}],
"acl":[{
"grantee":"PUBLIC",
"grantor":"postgres",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
},{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},{
"privilege_type":"x",
"privilege":true,
"with_grant":false
}]
}]
},
"expected_sql_file": "create_foreign_table_with_all_options.sql",
"expected_msql_file": "create_foreign_table_with_all_options_msql.sql"
}, {
"type": "delete",
"name": "Drop foreign table",
"endpoint": "NODE-foreign_table.delete_id"
},
{
"type": "create",
"name": "Create Foreign Table",
"endpoint": "NODE-foreign_table.obj",
"sql_endpoint": "NODE-foreign_table.sql_id",
"data": {
"name": "FT1_$%{}[]()&*^!@\"'`\\/#",
"owner": "postgres",
"schema": "public",
"basensp": "public",
"ftsrvname": "test_fs_for_foreign_table",
"columns": []
}
}, {
"type": "alter",
"name": "Alter Foreign Table comment and add columns",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"description":"Test Comment",
"columns": {
"added": [{
"attname":"col1",
"datatype":"bigint",
"coloptions":[]
},{
"attname":"col2",
"datatype":"text",
"coloptions":[]
}]
}
},
"expected_sql_file": "alter_comment_add_columns.sql",
"expected_msql_file": "alter_comment_add_columns_msql.sql"
},{
"type": "alter",
"name": "Alter Foreign Table add options",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"ftoptions": {
"added": [{
"option":"schema_name",
"value":"public"
},{
"option":"table_name",
"value":"test_table"
}]
}
},
"expected_sql_file": "alter_add_opts.sql",
"expected_msql_file": "alter_add_opts_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table add privileges",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"acl":{
"added": [{
"grantee":"PUBLIC",
"grantor":"postgres",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
}]
}]
}
},
"expected_sql_file": "alter_add_priv.sql",
"expected_msql_file": "alter_add_priv_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table change option and column",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"ftoptions": {
"changed": [{
"option":"schema_name",
"value":"test_public"
}]
},
"columns": {
"changed": [{
"attname": "col1",
"attnum": 1,
"attoptions": null,
"collname": "",
"coloptions": [],
"datatype": "integer",
"fulltype": "bigint"
}],
"deleted": [{
"attname":"col2",
"datatype":"text"
}]
}
},
"expected_sql_file": "alter_col_opts.sql",
"expected_msql_file": "alter_col_opts_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table remove option, privileges",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"acl":{
"deleted": [{
"grantee":"PUBLIC",
"grantor":"postgres",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
}]
}]
},
"ftoptions": {
"deleted": [{
"option":"schema_name",
"value":"public"
}]
}
},
"expected_sql_file": "alter_remove_opts_priv.sql",
"expected_msql_file": "alter_remove_opts_priv_msql.sql"
}, {
"type": "delete",
"name": "Drop foreign table",
"endpoint": "NODE-foreign_table.delete_id"
}, {
"type": "delete",
"name": "Drop foreign server",
"endpoint": "NODE-foreign_server.delete_id",
"data": {
"name": "test_fs_for_foreign_table"
}
}, {
"type": "delete",
"name": "Drop FDW",
"endpoint": "NODE-foreign_data_wrapper.delete_id",
"data": {
"name": "test_fdw_for_foreign_table"
}
}
]
}

View File

@ -0,0 +1,19 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,8 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (ADD schema_name 'public');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (ADD table_name 'test_table');

View File

@ -0,0 +1,23 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -0,0 +1 @@
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,22 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 integer NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'test_public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -0,0 +1,14 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
DROP COLUMN col2;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 DROP NOT NULL;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 TYPE integer;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 SET STATISTICS -1;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (SET schema_name 'test_public');

View File

@ -0,0 +1,15 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,8 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD COLUMN col1 bigint NULL;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD COLUMN col2 text NULL;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,17 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 integer NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -0,0 +1,7 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
DROP CONSTRAINT cons1;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS ( DROP schema_name);
REVOKE ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" FROM PUBLIC;

View File

@ -0,0 +1,23 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -0,0 +1,17 @@
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO postgres;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,264 @@
{
"scenarios": [
{
"type": "create",
"name": "Create FDW for foreign table",
"endpoint": "NODE-foreign_data_wrapper.obj",
"sql_endpoint": "NODE-foreign_data_wrapper.sql_id",
"data": {
"name": "test_fdw_for_foreign_table",
"fdwacl": [],
"fdwoptions": []
},
"store_object_id": "True"
}, {
"type": "create",
"name": "Create foreign server for foreign table",
"endpoint": "NODE-foreign_server.obj",
"sql_endpoint": "NODE-foreign_server.sql_id",
"data": {
"name":"test_fs_for_foreign_table"
},
"store_object_id": "True"
}, {
"type": "create",
"name": "Create Foreign Table with all options",
"endpoint": "NODE-foreign_table.obj",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql",
"data": {
"name": "FT1_$%{}[]()&*^!@\"'`\\/#",
"owner":"postgres",
"schema": "public",
"basensp":"public",
"description":"Test Comment",
"ftsrvname":"test_fs_for_foreign_table",
"columns":[{
"attname":"col1",
"datatype":"bigint",
"coloptions":[]
},{
"attname":"col2",
"datatype":"text",
"coloptions":[]
}],
"constraints":[{
"conname":"cons1",
"consrc":"true",
"connoinherit":true,
"convalidated":true
}],
"ftoptions":[{
"option":"schema_name",
"value":"public"
},{
"option":"table_name",
"value":"test_table"
}],
"acl":[{
"grantee":"PUBLIC",
"grantor":"postgres",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
},{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},{
"privilege_type":"x",
"privilege":true,
"with_grant":false
}]
}]
},
"expected_sql_file": "create_foreign_table_with_all_options.sql",
"expected_msql_file": "create_foreign_table_with_all_options_msql.sql"
}, {
"type": "delete",
"name": "Drop foreign table",
"endpoint": "NODE-foreign_table.delete_id"
},
{
"type": "create",
"name": "Create Foreign Table",
"endpoint": "NODE-foreign_table.obj",
"sql_endpoint": "NODE-foreign_table.sql_id",
"data": {
"name": "FT1_$%{}[]()&*^!@\"'`\\/#",
"owner": "postgres",
"schema": "public",
"basensp": "public",
"ftsrvname": "test_fs_for_foreign_table",
"columns": []
}
}, {
"type": "alter",
"name": "Alter Foreign Table comment and add columns",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"description":"Test Comment",
"columns": {
"added": [{
"attname":"col1",
"datatype":"bigint",
"coloptions":[]
},{
"attname":"col2",
"datatype":"text",
"coloptions":[]
}]
}
},
"expected_sql_file": "alter_comment_add_columns.sql",
"expected_msql_file": "alter_comment_add_columns_msql.sql"
},{
"type": "alter",
"name": "Alter Foreign Table add constraints and options",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"constraints": {
"added": [{
"conname":"cons1",
"consrc":"true",
"connoinherit":true,
"convalidated":true
}]
},
"ftoptions": {
"added": [{
"option":"schema_name",
"value":"public"
},{
"option":"table_name",
"value":"test_table"
}]
}
},
"expected_sql_file": "alter_add_cons_opts.sql",
"expected_msql_file": "alter_add_cons_opts_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table add privileges",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"acl":{
"added": [{
"grantee":"PUBLIC",
"grantor":"postgres",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
}]
}]
}
},
"expected_sql_file": "alter_add_priv.sql",
"expected_msql_file": "alter_add_priv_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table change option and column",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"ftoptions": {
"changed": [{
"option":"schema_name",
"value":"test_public"
}]
},
"columns": {
"changed": [{
"attname": "col1",
"attnum": 1,
"attoptions": null,
"collname": "",
"coloptions": [],
"datatype": "integer",
"fulltype": "bigint"
}],
"deleted": [{
"attname":"col2",
"datatype":"text"
}]
}
},
"expected_sql_file": "alter_col_opts.sql",
"expected_msql_file": "alter_col_opts_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table remove option, constraint, privileges",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"acl":{
"deleted": [{
"grantee":"PUBLIC",
"grantor":"postgres",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
}]
}]
},
"constraints": {
"deleted": [{
"conname":"cons1",
"consrc":"true",
"connoinherit":true,
"convalidated":true
}]
},
"ftoptions": {
"deleted": [{
"option":"schema_name",
"value":"public"
}]
}
},
"expected_sql_file": "alter_remove_opts_priv_cons.sql",
"expected_msql_file": "alter_remove_opts_priv_cons_msql.sql"
}, {
"type": "delete",
"name": "Drop foreign table",
"endpoint": "NODE-foreign_table.delete_id"
}, {
"type": "delete",
"name": "Drop foreign server",
"endpoint": "NODE-foreign_server.delete_id",
"data": {
"name": "test_fs_for_foreign_table"
}
}, {
"type": "delete",
"name": "Drop FDW",
"endpoint": "NODE-foreign_data_wrapper.delete_id",
"data": {
"name": "test_fdw_for_foreign_table"
}
}
]
}

View File

@ -0,0 +1,16 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,5 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (ADD schema_name 'public');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (ADD table_name 'test_table');

View File

@ -0,0 +1,20 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -0,0 +1 @@
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,19 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 integer NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'test_public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -0,0 +1,14 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
DROP COLUMN col2;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 DROP NOT NULL;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 TYPE integer;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 SET STATISTICS -1;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (SET schema_name 'test_public');

View File

@ -0,0 +1,15 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,8 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD COLUMN col1 bigint NULL;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD COLUMN col2 text NULL;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,17 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 integer NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -0,0 +1,4 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS ( DROP schema_name);
REVOKE ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" FROM PUBLIC;

View File

@ -0,0 +1,20 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -0,0 +1,14 @@
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,242 @@
{
"scenarios": [
{
"type": "create",
"name": "Create FDW for foreign table",
"endpoint": "NODE-foreign_data_wrapper.obj",
"sql_endpoint": "NODE-foreign_data_wrapper.sql_id",
"data": {
"name": "test_fdw_for_foreign_table",
"fdwacl": [],
"fdwoptions": []
},
"store_object_id": "True"
}, {
"type": "create",
"name": "Create foreign server for foreign table",
"endpoint": "NODE-foreign_server.obj",
"sql_endpoint": "NODE-foreign_server.sql_id",
"data": {
"name":"test_fs_for_foreign_table"
},
"store_object_id": "True"
}, {
"type": "create",
"name": "Create Foreign Table with all options",
"endpoint": "NODE-foreign_table.obj",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql",
"data": {
"name": "FT1_$%{}[]()&*^!@\"'`\\/#",
"owner":"enterprisedb",
"schema": "public",
"basensp":"public",
"description":"Test Comment",
"ftsrvname":"test_fs_for_foreign_table",
"columns":[{
"attname":"col1",
"datatype":"bigint",
"coloptions":[]
},{
"attname":"col2",
"datatype":"text",
"coloptions":[]
}],
"ftoptions":[{
"option":"schema_name",
"value":"public"
},{
"option":"table_name",
"value":"test_table"
}],
"acl":[{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
},{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},{
"privilege_type":"x",
"privilege":true,
"with_grant":false
}]
}]
},
"expected_sql_file": "create_foreign_table_with_all_options.sql",
"expected_msql_file": "create_foreign_table_with_all_options_msql.sql"
}, {
"type": "delete",
"name": "Drop foreign table",
"endpoint": "NODE-foreign_table.delete_id"
},
{
"type": "create",
"name": "Create Foreign Table",
"endpoint": "NODE-foreign_table.obj",
"sql_endpoint": "NODE-foreign_table.sql_id",
"data": {
"name": "FT1_$%{}[]()&*^!@\"'`\\/#",
"owner": "enterprisedb",
"schema": "public",
"basensp": "public",
"ftsrvname": "test_fs_for_foreign_table",
"columns": []
}
}, {
"type": "alter",
"name": "Alter Foreign Table comment and add columns",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"description":"Test Comment",
"columns": {
"added": [{
"attname":"col1",
"datatype":"bigint",
"coloptions":[]
},{
"attname":"col2",
"datatype":"text",
"coloptions":[]
}]
}
},
"expected_sql_file": "alter_comment_add_columns.sql",
"expected_msql_file": "alter_comment_add_columns_msql.sql"
},{
"type": "alter",
"name": "Alter Foreign Table add options",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"ftoptions": {
"added": [{
"option":"schema_name",
"value":"public"
},{
"option":"table_name",
"value":"test_table"
}]
}
},
"expected_sql_file": "alter_add_opts.sql",
"expected_msql_file": "alter_add_opts_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table add privileges",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"acl":{
"added": [{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
}]
}]
}
},
"expected_sql_file": "alter_add_priv.sql",
"expected_msql_file": "alter_add_priv_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table change option and column",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"ftoptions": {
"changed": [{
"option":"schema_name",
"value":"test_public"
}]
},
"columns": {
"changed": [{
"attname": "col1",
"attnum": 1,
"attoptions": null,
"collname": "",
"coloptions": [],
"datatype": "integer",
"fulltype": "bigint"
}],
"deleted": [{
"attname":"col2",
"datatype":"text"
}]
}
},
"expected_sql_file": "alter_col_opts.sql",
"expected_msql_file": "alter_col_opts_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table remove option, privileges",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"acl":{
"deleted": [{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
}]
}]
},
"ftoptions": {
"deleted": [{
"option":"schema_name",
"value":"public"
}]
}
},
"expected_sql_file": "alter_remove_opts_priv.sql",
"expected_msql_file": "alter_remove_opts_priv_msql.sql"
}, {
"type": "delete",
"name": "Drop foreign table",
"endpoint": "NODE-foreign_table.delete_id"
}, {
"type": "delete",
"name": "Drop foreign server",
"endpoint": "NODE-foreign_server.delete_id",
"data": {
"name": "test_fs_for_foreign_table"
}
}, {
"type": "delete",
"name": "Drop FDW",
"endpoint": "NODE-foreign_data_wrapper.delete_id",
"data": {
"name": "test_fdw_for_foreign_table"
}
}
]
}

View File

@ -0,0 +1,19 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,8 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (ADD schema_name 'public');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (ADD table_name 'test_table');

View File

@ -0,0 +1,23 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -0,0 +1 @@
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,22 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 integer NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'test_public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT INSERT, SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -0,0 +1,14 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
DROP COLUMN col2;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 DROP NOT NULL;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 TYPE integer;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col1 SET STATISTICS -1;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS (SET schema_name 'test_public');

View File

@ -0,0 +1,15 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,8 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD COLUMN col1 bigint NULL;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD COLUMN col2 text NULL;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';

View File

@ -0,0 +1,17 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 integer NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -0,0 +1,7 @@
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
DROP CONSTRAINT cons1;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OPTIONS ( DROP schema_name);
REVOKE ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" FROM PUBLIC;

View File

@ -0,0 +1,23 @@
-- FOREIGN TABLE: public."FT1_$%{}[]()&*^!@""'`\/#"
-- DROP FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#";
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL COLLATE pg_catalog."default"
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -0,0 +1,17 @@
CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"(
col1 bigint NULL,
col2 text NULL
)
SERVER test_fs_for_foreign_table
OPTIONS (schema_name 'public', table_name 'test_table');
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT cons1 CHECK (true) NO INHERIT;
COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,264 @@
{
"scenarios": [
{
"type": "create",
"name": "Create FDW for foreign table",
"endpoint": "NODE-foreign_data_wrapper.obj",
"sql_endpoint": "NODE-foreign_data_wrapper.sql_id",
"data": {
"name": "test_fdw_for_foreign_table",
"fdwacl": [],
"fdwoptions": []
},
"store_object_id": "True"
}, {
"type": "create",
"name": "Create foreign server for foreign table",
"endpoint": "NODE-foreign_server.obj",
"sql_endpoint": "NODE-foreign_server.sql_id",
"data": {
"name":"test_fs_for_foreign_table"
},
"store_object_id": "True"
}, {
"type": "create",
"name": "Create Foreign Table with all options",
"endpoint": "NODE-foreign_table.obj",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql",
"data": {
"name": "FT1_$%{}[]()&*^!@\"'`\\/#",
"owner":"enterprisedb",
"schema": "public",
"basensp":"public",
"description":"Test Comment",
"ftsrvname":"test_fs_for_foreign_table",
"columns":[{
"attname":"col1",
"datatype":"bigint",
"coloptions":[]
},{
"attname":"col2",
"datatype":"text",
"coloptions":[]
}],
"constraints":[{
"conname":"cons1",
"consrc":"true",
"connoinherit":true,
"convalidated":true
}],
"ftoptions":[{
"option":"schema_name",
"value":"public"
},{
"option":"table_name",
"value":"test_table"
}],
"acl":[{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
},{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},{
"privilege_type":"x",
"privilege":true,
"with_grant":false
}]
}]
},
"expected_sql_file": "create_foreign_table_with_all_options.sql",
"expected_msql_file": "create_foreign_table_with_all_options_msql.sql"
}, {
"type": "delete",
"name": "Drop foreign table",
"endpoint": "NODE-foreign_table.delete_id"
},
{
"type": "create",
"name": "Create Foreign Table",
"endpoint": "NODE-foreign_table.obj",
"sql_endpoint": "NODE-foreign_table.sql_id",
"data": {
"name": "FT1_$%{}[]()&*^!@\"'`\\/#",
"owner": "enterprisedb",
"schema": "public",
"basensp": "public",
"ftsrvname": "test_fs_for_foreign_table",
"columns": []
}
}, {
"type": "alter",
"name": "Alter Foreign Table comment and add columns",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"description":"Test Comment",
"columns": {
"added": [{
"attname":"col1",
"datatype":"bigint",
"coloptions":[]
},{
"attname":"col2",
"datatype":"text",
"coloptions":[]
}]
}
},
"expected_sql_file": "alter_comment_add_columns.sql",
"expected_msql_file": "alter_comment_add_columns_msql.sql"
},{
"type": "alter",
"name": "Alter Foreign Table add constraints and options",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"constraints": {
"added": [{
"conname":"cons1",
"consrc":"true",
"connoinherit":true,
"convalidated":true
}]
},
"ftoptions": {
"added": [{
"option":"schema_name",
"value":"public"
},{
"option":"table_name",
"value":"test_table"
}]
}
},
"expected_sql_file": "alter_add_cons_opts.sql",
"expected_msql_file": "alter_add_cons_opts_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table add privileges",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"acl":{
"added": [{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
}]
}]
}
},
"expected_sql_file": "alter_add_priv.sql",
"expected_msql_file": "alter_add_priv_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table change option and column",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"ftoptions": {
"changed": [{
"option":"schema_name",
"value":"test_public"
}]
},
"columns": {
"changed": [{
"attname": "col1",
"attnum": 1,
"attoptions": null,
"collname": "",
"coloptions": [],
"datatype": "integer",
"fulltype": "bigint"
}],
"deleted": [{
"attname":"col2",
"datatype":"text"
}]
}
},
"expected_sql_file": "alter_col_opts.sql",
"expected_msql_file": "alter_col_opts_msql.sql"
}, {
"type": "alter",
"name": "Alter Foreign Table remove option, constraint, privileges",
"endpoint": "NODE-foreign_table.obj_id",
"sql_endpoint": "NODE-foreign_table.sql_id",
"msql_endpoint": "NODE-foreign_table.msql_id",
"data": {
"acl":{
"deleted": [{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[{
"privilege_type":"a",
"privilege":true,
"with_grant":false
},{
"privilege_type":"r",
"privilege":true,
"with_grant":false
}]
}]
},
"constraints": {
"deleted": [{
"conname":"cons1",
"consrc":"true",
"connoinherit":true,
"convalidated":true
}]
},
"ftoptions": {
"deleted": [{
"option":"schema_name",
"value":"public"
}]
}
},
"expected_sql_file": "alter_remove_opts_priv_cons.sql",
"expected_msql_file": "alter_remove_opts_priv_cons_msql.sql"
}, {
"type": "delete",
"name": "Drop foreign table",
"endpoint": "NODE-foreign_table.delete_id"
}, {
"type": "delete",
"name": "Drop foreign server",
"endpoint": "NODE-foreign_server.delete_id",
"data": {
"name": "test_fs_for_foreign_table"
}
}, {
"type": "delete",
"name": "Drop FDW",
"endpoint": "NODE-foreign_data_wrapper.delete_id",
"data": {
"name": "test_fdw_for_foreign_table"
}
}
]
}