diff --git a/expected/blazegraph-wikidata.out b/expected/blazegraph-wikidata.out
index e06e68c..f968ab9 100644
--- a/expected/blazegraph-wikidata.out
+++ b/expected/blazegraph-wikidata.out
@@ -414,3 +414,8 @@ LIMIT 15
----+------
(0 rows)
+DROP SERVER wikidata CASCADE;
+NOTICE: drop cascades to 3 other objects
+DETAIL: drop cascades to foreign table atms_munich
+drop cascades to foreign table places_below_sea_level
+drop cascades to foreign table european_countries
diff --git a/expected/exceptions.out b/expected/exceptions.out
index d0c56e6..3277f70 100644
--- a/expected/exceptions.out
+++ b/expected/exceptions.out
@@ -131,22 +131,25 @@ EXPLAIN SELECT * FROM t1;
Foreign Scan on t1 (cost=10000.00..20000.00 rows=1000 width=32)
(1 row)
+CREATE TABLE public.t1_local(id serial, c1_null text, c2_null text);
/*
empty target_table
*/
SELECT
rdf_fdw_clone_table(
foreign_table => 't1'::regclass::oid,
- target_table => ''
+ target_table => ''::regclass::oid
);
-ERROR: no target table provided
+ERROR: invalid name syntax
+LINE 7: target_table => ''::regclass::oid
+ ^
/*
negative fetch_size
*/
SELECT
rdf_fdw_clone_table(
foreign_table => 't1'::regclass::oid,
- target_table => 't',
+ target_table => 't1_local'::regclass::oid,
fetch_size => -1
);
ERROR: invalid fetch_size: -1
@@ -157,7 +160,7 @@ HINT: the page size corresponds to the number of records that are retrieved aft
SELECT
rdf_fdw_clone_table(
foreign_table => 't1'::regclass::oid,
- target_table => 't',
+ target_table => 't1_local'::regclass::oid,
begin_offset => -1
);
ERROR: invalid begin_offset: -1
@@ -167,10 +170,21 @@ ERROR: invalid begin_offset: -1
SELECT
rdf_fdw_clone_table(
foreign_table => 't1'::regclass::oid,
- target_table => 't',
+ target_table => 't1_local'::regclass::oid,
ordering_column => 'foo'
);
-ERROR: invalid ordering_column 'foo'
+ERROR: invalid target table
+HINT: at least one column of 't1_local' must match with the FOREIGN TABLE 't1'
+/*
+ target table does not match any column of t1
+ */
+SELECT
+ rdf_fdw_clone_table(
+ foreign_table => 't1'::regclass::oid,
+ target_table => 't1_local'::regclass::oid
+ );
+ERROR: invalid target table
+HINT: at least one column of 't1_local' must match with the FOREIGN TABLE 't1'
/* invalid SPARQL - missing closing curly braces (\n)*/
CREATE FOREIGN TABLE t2 (s text OPTIONS (variable '?s')
) SERVER testserver2 OPTIONS (sparql '
@@ -279,3 +293,5 @@ CREATE FOREIGN TABLE t15 (
) SERVER testserver2 OPTIONS (sparql 'SELECT ?s {?s ?p ?o}', fetch_size '-1');
ERROR: invalid fetch_size: '-1'
HINT: expected values are positive integers
+DROP FOREIGN TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1_local;
diff --git a/expected/graphdb-getty.out b/expected/graphdb-getty.out
index a15e26d..d3d3c8f 100644
--- a/expected/graphdb-getty.out
+++ b/expected/graphdb-getty.out
@@ -296,3 +296,7 @@ INFO: SPARQL query sent to 'http://vocab.getty.edu/sparql.xml':
Vaucher, Gabriel Constant | Swiss artist, 1768-1814 | 1768
(10 rows)
+DROP SERVER getty CASCADE;
+NOTICE: drop cascades to 2 other objects
+DETAIL: drop cascades to foreign table getty_places
+drop cascades to foreign table getty_non_italians
diff --git a/expected/table-clone.out b/expected/table-clone.out
new file mode 100644
index 0000000..5fae0e8
--- /dev/null
+++ b/expected/table-clone.out
@@ -0,0 +1,215 @@
+CREATE SERVER dbpedia
+FOREIGN DATA WRAPPER rdf_fdw
+OPTIONS (endpoint 'https://dbpedia.org/sparql');
+CREATE FOREIGN TABLE public.dbpedia_cities (
+ uri text OPTIONS (variable '?city', nodetype 'iri'),
+ city_name text OPTIONS (variable '?name', nodetype 'literal', literaltype 'xsd:string')
+)
+SERVER dbpedia OPTIONS (
+ log_sparql 'true',
+ sparql '
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+ SELECT ?name
+ {
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ ORDER BY ?name
+ OFFSET 73 LIMIT 1042
+');
+SELECT
+ rdf_fdw_clone_table(
+ foreign_table => 'public.dbpedia_cities'::regclass::oid,
+ target_table => 't_dbpedia1',
+ page_size => 2,
+ max_records => 9,
+ create_table => true,
+ verbose => true
+ );
+INFO: Target TABLE "t_dbpedia1" created based on FOREIGN TABLE "dbpedia_cities":
+
+ CREATE TABLE t_dbpedia1 AS SELECT * FROM dbpedia_cities WITH NO DATA;
+
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?city
+OFFSET 0 LIMIT 2
+
+INFO: page (0 - 2) stored: 2 records successfully inserted
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?city
+OFFSET 2 LIMIT 2
+
+INFO: page (2 - 4) stored: 2 records successfully inserted
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?city
+OFFSET 4 LIMIT 2
+
+INFO: page (4 - 6) stored: 2 records successfully inserted
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?city
+OFFSET 6 LIMIT 2
+
+INFO: page (6 - 8) stored: 2 records successfully inserted
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?city
+OFFSET 8 LIMIT 1
+
+INFO: page (8 - 10) stored: 1 records successfully inserted
+INFO: Total inserted records: 9
+ rdf_fdw_clone_table
+---------------------
+
+(1 row)
+
+SELECT * FROM t_local1;
+ERROR: relation "t_local1" does not exist
+LINE 1: SELECT * FROM t_local1;
+ ^
+SELECT
+ rdf_fdw_clone_table(
+ foreign_table => 'public.dbpedia_cities'::regclass::oid,
+ ordering_column => 'city_name',
+ target_table => 't_dbpedia2',
+ page_size => 6,
+ create_table => true,
+ verbose => true
+ );
+INFO: Target TABLE "t_dbpedia2" created based on FOREIGN TABLE "dbpedia_cities":
+
+ CREATE TABLE t_dbpedia2 AS SELECT * FROM dbpedia_cities WITH NO DATA;
+
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?name
+OFFSET 0 LIMIT 6
+
+INFO: page (0 - 6) stored: 6 records successfully inserted
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?name
+OFFSET 6 LIMIT 6
+
+INFO: page (6 - 12) stored: 6 records successfully inserted
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?name
+OFFSET 12 LIMIT 6
+
+INFO: page (12 - 18) stored: 2 records successfully inserted
+INFO: SPARQL query sent to 'https://dbpedia.org/sparql':
+
+ PREFIX dbo:
+ PREFIX foaf:
+ PREFIX dbr:
+
+SELECT ?city ?name
+{
+ ?city a dbo:City ;
+ foaf:name ?name ;
+ dbo:federalState dbr:North_Rhine-Westphalia
+ }
+ORDER BY ?name
+OFFSET 18 LIMIT 6
+
+INFO: Total inserted records: 14
+ rdf_fdw_clone_table
+---------------------
+
+(1 row)
+
+SELECT * FROM t_local2;
+ERROR: relation "t_local2" does not exist
+LINE 1: SELECT * FROM t_local2;
+ ^
+DROP SERVER dbpedia CASCADE;
+NOTICE: drop cascades to foreign table dbpedia_cities
+DROP TABLE IF EXISTS t_dbpedia1;
+DROP TABLE IF EXISTS t_dbpedia2;
diff --git a/expected/virtuoso-dbpedia.out b/expected/virtuoso-dbpedia.out
index 226e73e..25d81db 100644
--- a/expected/virtuoso-dbpedia.out
+++ b/expected/virtuoso-dbpedia.out
@@ -1826,3 +1826,23 @@ LIMIT 10
JapĆ³n
(1 row)
+DROP SERVER dbpedia CASCADE;
+NOTICE: drop cascades to 18 other objects
+DETAIL: drop cascades to foreign table film
+drop cascades to foreign table politicians
+drop cascades to foreign table party_members
+drop cascades to foreign table chanceler_candidates
+drop cascades to foreign table german_public_universities
+drop cascades to foreign table person1
+drop cascades to foreign table person2
+drop cascades to foreign table person3
+drop cascades to foreign table politicians_germany
+drop cascades to foreign table dbpedia_limit
+drop cascades to foreign table dbpedia_orderby
+drop cascades to foreign table dbpedia_distinct
+drop cascades to foreign table dbpedia_groupby
+drop cascades to foreign table musical_artists
+drop cascades to foreign table generic_rdf_table
+drop cascades to foreign table generic_rdf_table2
+drop cascades to foreign table generic_rdf_table3
+drop cascades to foreign table generic_rdf_table4
diff --git a/sql/blazegraph-wikidata.sql b/sql/blazegraph-wikidata.sql
index 256fd19..3e7ab8c 100644
--- a/sql/blazegraph-wikidata.sql
+++ b/sql/blazegraph-wikidata.sql
@@ -214,4 +214,6 @@ SELECT uri, nativename
ORDER BY uri
LIMIT 15
)
-SELECT * FROM local EXCEPT SELECT * FROM j;
\ No newline at end of file
+SELECT * FROM local EXCEPT SELECT * FROM j;
+
+DROP SERVER wikidata CASCADE;
\ No newline at end of file
diff --git a/sql/exceptions.sql b/sql/exceptions.sql
index e2da3e8..efd8d0b 100644
--- a/sql/exceptions.sql
+++ b/sql/exceptions.sql
@@ -125,13 +125,15 @@ DELETE FROM t1;
/* EXPLAIN isn't supported*/
EXPLAIN SELECT * FROM t1;
+CREATE TABLE public.t1_local(id serial, c1_null text, c2_null text);
+
/*
empty target_table
*/
SELECT
rdf_fdw_clone_table(
foreign_table => 't1'::regclass::oid,
- target_table => ''
+ target_table => ''::regclass::oid
);
/*
@@ -140,7 +142,7 @@ SELECT
SELECT
rdf_fdw_clone_table(
foreign_table => 't1'::regclass::oid,
- target_table => 't',
+ target_table => 't1_local'::regclass::oid,
fetch_size => -1
);
@@ -150,7 +152,7 @@ SELECT
SELECT
rdf_fdw_clone_table(
foreign_table => 't1'::regclass::oid,
- target_table => 't',
+ target_table => 't1_local'::regclass::oid,
begin_offset => -1
);
@@ -160,10 +162,18 @@ SELECT
SELECT
rdf_fdw_clone_table(
foreign_table => 't1'::regclass::oid,
- target_table => 't',
+ target_table => 't1_local'::regclass::oid,
ordering_column => 'foo'
);
+/*
+ target table does not match any column of t1
+ */
+SELECT
+ rdf_fdw_clone_table(
+ foreign_table => 't1'::regclass::oid,
+ target_table => 't1_local'::regclass::oid
+ );
/* invalid SPARQL - missing closing curly braces (\n)*/
CREATE FOREIGN TABLE t2 (s text OPTIONS (variable '?s')
@@ -247,4 +257,7 @@ CREATE FOREIGN TABLE t14 (
*/
CREATE FOREIGN TABLE t15 (
name text OPTIONS (variable '?s')
-) SERVER testserver2 OPTIONS (sparql 'SELECT ?s {?s ?p ?o}', fetch_size '-1');
\ No newline at end of file
+) SERVER testserver2 OPTIONS (sparql 'SELECT ?s {?s ?p ?o}', fetch_size '-1');
+
+DROP FOREIGN TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1_local;
\ No newline at end of file
diff --git a/sql/graphdb-getty.sql b/sql/graphdb-getty.sql
index 80056c3..1315207 100644
--- a/sql/graphdb-getty.sql
+++ b/sql/graphdb-getty.sql
@@ -96,4 +96,6 @@ SELECT name, bio, birth
FROM getty_non_italians
WHERE bio ~~* '%artist%'
ORDER BY birth
-LIMIT 10;
\ No newline at end of file
+LIMIT 10;
+
+DROP SERVER getty CASCADE;
\ No newline at end of file
diff --git a/sql/virtuoso-dbpedia.sql b/sql/virtuoso-dbpedia.sql
index 4c212d6..67d3640 100644
--- a/sql/virtuoso-dbpedia.sql
+++ b/sql/virtuoso-dbpedia.sql
@@ -814,4 +814,6 @@ SERVER dbpedia OPTIONS (
SELECT name
FROM generic_rdf_table4
WHERE uri = 'http://dbpedia.org/resource/Japan'
-LIMIT 10;
\ No newline at end of file
+LIMIT 10;
+
+DROP SERVER dbpedia CASCADE;
\ No newline at end of file