/* * What rdf_fdw puts into an HTTP request. These tests need no network: the * servers below point at a port nothing listens on, with retries off, so a * request that gets as far as being sent fails at once. */ SET client_min_messages TO WARNING; /* * Control characters in values that end up in a header. A CR or LF there * would add header lines -- or a second request -- of the user's choosing, * so such a header is refused before the request is sent. */ CREATE SERVER hs_ctl FOREIGN DATA WRAPPER rdf_fdw OPTIONS (endpoint 'http://127.0.0.1:1/sparql', connect_retry '0', connect_timeout '1'); /* the SPARQL query itself may span lines */ CREATE FOREIGN TABLE hs_ft (s rdfnode OPTIONS (variable '?s')) SERVER hs_ctl OPTIONS (sparql E'SELECT ?s\nWHERE {\r\n ?s ?p ?o\n}'); /* the Accept header, from the format option */ ALTER SERVER hs_ctl OPTIONS (ADD format E'application/sparql-results+xml\r\nX-Injected: 1'); SELECT * FROM hs_ft; ALTER SERVER hs_ctl OPTIONS (DROP format); /* the Authorization header, from the token of a user mapping */ CREATE USER MAPPING FOR CURRENT_USER SERVER hs_ctl OPTIONS (token E'abc\r\nX-Injected: 1'); SELECT * FROM hs_ft; /* * An IRI an endpoint returns may hold characters the SPARQL grammar does not * allow in one. It is read as an IRI, but refused before it is written back. */ CREATE FOREIGN TABLE hs_w ( s rdfnode OPTIONS (variable '?s'), p rdfnode OPTIONS (variable '?p'), o rdfnode OPTIONS (variable '?o')) SERVER hs_ctl OPTIONS (sparql 'SELECT * {?s ?p ?o}', sparql_update_pattern '?s ?p ?o .'); SELECT sparql.isiri(''::rdfnode); INSERT INTO hs_w VALUES ('', '', '"x"'); INSERT INTO hs_w VALUES ('', '', '"x"^^'); DROP SERVER hs_ctl CASCADE;