From 054821ed3fd6db18ee2040468a639fda036207a4 Mon Sep 17 00:00:00 2001 From: Nguyen Ngoc Son <33323090+jopoly@users.noreply.github.com> Date: Wed, 31 Jan 2024 07:31:30 +0700 Subject: [PATCH] Fix missing protocol header (#46) Co-authored-by: jopoly --- expected/12.16/option.out | 21 +++++++++++++-------- expected/13.12/option.out | 21 +++++++++++++-------- expected/14.9/option.out | 21 +++++++++++++-------- expected/15.4/option.out | 21 +++++++++++++-------- expected/16.0/option.out | 21 +++++++++++++-------- option.c | 25 ++++++++++++++++++++++++- query.cpp | 33 ++++++++++++++++----------------- sql/12.16/option.sql | 15 +++++++++++---- sql/13.12/option.sql | 15 +++++++++++---- sql/14.9/option.sql | 15 +++++++++++---- sql/15.4/option.sql | 15 +++++++++++---- sql/16.0/option.sql | 15 +++++++++++---- 12 files changed, 160 insertions(+), 78 deletions(-) diff --git a/expected/12.16/option.out b/expected/12.16/option.out index 59b83f6..e16fff4 100644 --- a/expected/12.16/option.out +++ b/expected/12.16/option.out @@ -12,7 +12,7 @@ ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or 2. --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -27,20 +27,25 @@ DROP SERVER influxdb_svr CASCADE; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr drop cascades to foreign table optiontbl +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; -ERROR: influxdb_fdw: Server Host not specified +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr -drop cascades to foreign table optiontbl -- dbname must be not NULL or not empty --Testcase 16: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'http://localhost', port '38086', version '2', retention_policy ''); diff --git a/expected/13.12/option.out b/expected/13.12/option.out index 59b83f6..e16fff4 100644 --- a/expected/13.12/option.out +++ b/expected/13.12/option.out @@ -12,7 +12,7 @@ ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or 2. --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -27,20 +27,25 @@ DROP SERVER influxdb_svr CASCADE; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr drop cascades to foreign table optiontbl +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; -ERROR: influxdb_fdw: Server Host not specified +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr -drop cascades to foreign table optiontbl -- dbname must be not NULL or not empty --Testcase 16: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'http://localhost', port '38086', version '2', retention_policy ''); diff --git a/expected/14.9/option.out b/expected/14.9/option.out index 59b83f6..e16fff4 100644 --- a/expected/14.9/option.out +++ b/expected/14.9/option.out @@ -12,7 +12,7 @@ ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or 2. --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -27,20 +27,25 @@ DROP SERVER influxdb_svr CASCADE; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr drop cascades to foreign table optiontbl +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; -ERROR: influxdb_fdw: Server Host not specified +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr -drop cascades to foreign table optiontbl -- dbname must be not NULL or not empty --Testcase 16: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'http://localhost', port '38086', version '2', retention_policy ''); diff --git a/expected/15.4/option.out b/expected/15.4/option.out index 59b83f6..e16fff4 100644 --- a/expected/15.4/option.out +++ b/expected/15.4/option.out @@ -12,7 +12,7 @@ ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or 2. --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -27,20 +27,25 @@ DROP SERVER influxdb_svr CASCADE; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr drop cascades to foreign table optiontbl +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; -ERROR: influxdb_fdw: Server Host not specified +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr -drop cascades to foreign table optiontbl -- dbname must be not NULL or not empty --Testcase 16: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'http://localhost', port '38086', version '2', retention_policy ''); diff --git a/expected/16.0/option.out b/expected/16.0/option.out index 59b83f6..e16fff4 100644 --- a/expected/16.0/option.out +++ b/expected/16.0/option.out @@ -12,7 +12,7 @@ ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); ERROR: InfluxDB only support versions from v1.x to 2.x. "version" must be 1 or 2. --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -27,20 +27,25 @@ DROP SERVER influxdb_svr CASCADE; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr drop cascades to foreign table optiontbl +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); +ERROR: influxdb_fdw: Host address must start with either http:// or https:// --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; -ERROR: influxdb_fdw: Server Host not specified +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to user mapping for vagrant on server influxdb_svr -drop cascades to foreign table optiontbl -- dbname must be not NULL or not empty --Testcase 16: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'http://localhost', port '38086', version '2', retention_policy ''); diff --git a/option.c b/option.c index eea01fd..733cc2a 100644 --- a/option.c +++ b/option.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "funcapi.h" #include "access/reloptions.h" @@ -24,6 +25,7 @@ #include "catalog/pg_foreign_table.h" #include "catalog/pg_user_mapping.h" #include "catalog/pg_type.h" +#include "catalog/pg_collation.h" #include "commands/defrem.h" #include "commands/explain.h" #include "foreign/fdwapi.h" @@ -41,6 +43,7 @@ #include "optimizer/restrictinfo.h" #include "optimizer/planmain.h" #include "utils/varlena.h" +#include "utils/formatting.h" #ifdef CXX_CLIENT #include "query_cxx.h" @@ -212,6 +215,26 @@ influxdb_fdw_validator(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("InfluxDB only support versions from v1.x to 2.x. \"%s\" must be 1 or 2.", def->defname))); } + + /* Validate host address if it is set */ + if (strcmp(def->defname, "host") == 0) + { + regex_t regex; + int ret; + char *host = str_tolower(defGetString(def), strlen(defGetString(def)), C_COLLATION_OID); + + /* Must start with either http:// or https:// */ + ret = regcomp(®ex, "^((http|https)://)", REG_EXTENDED); + Assert(ret == 0); /*for debug invalid regex pattern */ + ret = regexec(®ex, host, 0, NULL, 0); + if (ret == REG_NOMATCH) + { + regfree(®ex); + elog(ERROR, "influxdb_fdw: Host address must start with either http:// or https://"); + } + + regfree(®ex); + } #endif } PG_RETURN_VOID(); @@ -322,7 +345,7 @@ influxdb_get_options(Oid foreignoid, Oid userid) #ifdef CXX_CLIENT /* When using the influxdb-cxx API client, c++ not allow std::string(NULL). */ - if (opt->svr_address == NULL || strcmp(opt->svr_address, "") == 0) + if (opt->svr_address == NULL) elog(ERROR, "influxdb_fdw: Server Host not specified"); if (opt->svr_database == NULL || strcmp(opt->svr_database, "") == 0) diff --git a/query.cpp b/query.cpp index efaa46a..f31cc0f 100644 --- a/query.cpp +++ b/query.cpp @@ -488,28 +488,26 @@ check_connected_influxdb_version(char* addr, int port, char* user, char* pass, c query = "SHOW MEASUREMENTS ON " + std::string(db); - influx = influxdb::InfluxDBFactory::GetV2(std::string(addr), port, std::string(db), std::string(auth_token), std::string(retention_policy)); - try { + influx = influxdb::InfluxDBFactory::GetV2(std::string(addr), port, std::string(db), std::string(auth_token), std::string(retention_policy)); auto measurements = influx->query(query); return INFLUXDB_VERSION_2; } - catch(const std::exception& e) + catch (const std::exception &e) { /* do nothing */ } - influx = influxdb::InfluxDBFactory::GetV1(std::string(addr), port, std::string(db), std::string(user), std::string(pass)); - try { + influx = influxdb::InfluxDBFactory::GetV1(std::string(addr), port, std::string(db), std::string(user), std::string(pass)); auto measurements = influx->query(query); return INFLUXDB_VERSION_1; } catch(const std::exception& e) { - elog(ERROR, "Could not connect to InfluxDB."); + elog(ERROR, "Could not connect to InfluxDB: %s", e.what()); } elog(ERROR, "Could not connect to InfluxDB."); @@ -539,10 +537,10 @@ InfluxDBExecDDLCommand(char* addr, int port, char* user, char* pass, char* db, c if (version != INFLUXDB_VERSION_1 && version != INFLUXDB_VERSION_2) { - /* Automatically detect InfluxDB version 1.x and 2.x: trying to connect InfluxDB v2.x first */ - influx = influxdb::InfluxDBFactory::GetV2(std::string(addr), port, std::string(db), std::string(auth_token), std::string(retention_policy)); try { + /* Automatically detect InfluxDB version 1.x and 2.x: trying to connect InfluxDB v2.x first */ + influx = influxdb::InfluxDBFactory::GetV2(std::string(addr), port, std::string(db), std::string(auth_token), std::string(retention_policy)); auto err = influx->query(cquery); } catch(const std::exception& e) @@ -554,9 +552,9 @@ InfluxDBExecDDLCommand(char* addr, int port, char* user, char* pass, char* db, c if (!retry_connect) return NULL; /* Query successfully */ - influx = influxdb::InfluxDBFactory::GetV1(std::string(addr), port, std::string(db), std::string(user), std::string(pass)); try { + influx = influxdb::InfluxDBFactory::GetV1(std::string(addr), port, std::string(db), std::string(user), std::string(pass)); auto err = influx->query(cquery); } catch(const std::exception& e) @@ -564,17 +562,18 @@ InfluxDBExecDDLCommand(char* addr, int port, char* user, char* pass, char* db, c elog(ERROR, "influxdb_fdw: could not execute query: %s", cquery); } } - /* InfluxDB version is specified */ - else if (version == INFLUXDB_VERSION_1) - influx = influxdb::InfluxDBFactory::GetV1(std::string(addr), port, std::string(db), std::string(user), std::string(pass)); - else if (version == INFLUXDB_VERSION_2) - influx = influxdb::InfluxDBFactory::GetV2(std::string(addr), port, std::string(db), std::string(auth_token), std::string(retention_policy)); - - if (!influx) - elog(ERROR, "Fail to create influxDB client"); try { + /* InfluxDB version is specified */ + if (version == INFLUXDB_VERSION_1) + influx = influxdb::InfluxDBFactory::GetV1(std::string(addr), port, std::string(db), std::string(user), std::string(pass)); + else if (version == INFLUXDB_VERSION_2) + influx = influxdb::InfluxDBFactory::GetV2(std::string(addr), port, std::string(db), std::string(auth_token), std::string(retention_policy)); + + if (!influx) + elog(ERROR, "Fail to create influxDB client"); + auto err = influx->query(cquery); } catch (const std::exception& e) diff --git a/sql/12.16/option.sql b/sql/12.16/option.sql index 35e344b..19c64e6 100644 --- a/sql/12.16/option.sql +++ b/sql/12.16/option.sql @@ -12,7 +12,7 @@ CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'op --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -24,15 +24,22 @@ SELECT * FROM optiontbl; --Testcase 10: DROP SERVER influxdb_svr CASCADE; +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -- dbname must be not NULL or not empty diff --git a/sql/13.12/option.sql b/sql/13.12/option.sql index 35e344b..19c64e6 100644 --- a/sql/13.12/option.sql +++ b/sql/13.12/option.sql @@ -12,7 +12,7 @@ CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'op --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -24,15 +24,22 @@ SELECT * FROM optiontbl; --Testcase 10: DROP SERVER influxdb_svr CASCADE; +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -- dbname must be not NULL or not empty diff --git a/sql/14.9/option.sql b/sql/14.9/option.sql index 35e344b..19c64e6 100644 --- a/sql/14.9/option.sql +++ b/sql/14.9/option.sql @@ -12,7 +12,7 @@ CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'op --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -24,15 +24,22 @@ SELECT * FROM optiontbl; --Testcase 10: DROP SERVER influxdb_svr CASCADE; +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -- dbname must be not NULL or not empty diff --git a/sql/15.4/option.sql b/sql/15.4/option.sql index 35e344b..19c64e6 100644 --- a/sql/15.4/option.sql +++ b/sql/15.4/option.sql @@ -12,7 +12,7 @@ CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'op --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -24,15 +24,22 @@ SELECT * FROM optiontbl; --Testcase 10: DROP SERVER influxdb_svr CASCADE; +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -- dbname must be not NULL or not empty diff --git a/sql/16.0/option.sql b/sql/16.0/option.sql index 35e344b..19c64e6 100644 --- a/sql/16.0/option.sql +++ b/sql/16.0/option.sql @@ -12,7 +12,7 @@ CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'op --Testcase 5: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'http://localhost', port '38086', version '-1', retention_policy ''); --- host must be not NULL or not empty +-- host must be not NULL --Testcase 6: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', port '38086', version '2', retention_policy ''); --Testcase 7: @@ -24,15 +24,22 @@ SELECT * FROM optiontbl; --Testcase 10: DROP SERVER influxdb_svr CASCADE; +-- host must start with either http:// or https:// --Testcase 11: CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host '', port '38086', version '2', retention_policy ''); --Testcase 12: -CREATE USER MAPPING FOR CURRENT_USER SERVER influxdb_svr OPTIONS (auth_token 'mytoken'); +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (dbname 'optiondb', host 'localhost', port '38086', version '2', retention_policy ''); --Testcase 13: -CREATE FOREIGN TABLE optiontbl (tag1 text, version text, value2 int) SERVER influxdb_svr; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTP://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 14: -SELECT * FROM optiontbl; +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'HTTPS://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; --Testcase 15: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'https://localhost', port '38086', version '2', retention_policy ''); +DROP SERVER influxdb_svr CASCADE; +--Testcase 92: +CREATE SERVER influxdb_svr FOREIGN DATA WRAPPER influxdb_fdw OPTIONS (host 'hTTpS://localhost', port '38086', version '2', retention_policy ''); DROP SERVER influxdb_svr CASCADE; -- dbname must be not NULL or not empty