diff --git a/GitHubActions/detect_targets.sh b/GitHubActions/detect_targets.sh index 5ba069e9..394d27d4 100644 --- a/GitHubActions/detect_targets.sh +++ b/GitHubActions/detect_targets.sh @@ -2,7 +2,7 @@ ################################################################################ # -# This script detects target PostgreSQL versions for sqlite_fdw testing from +# This script detects target PostgreSQL versions for sqlite_fdw testing from # directory names in ./sql directory. Detected versions will be outputed to # the standard output as an array of string like ["15.4","16.0"]. # diff --git a/GitHubActions/install_locales.sh b/GitHubActions/install_locales.sh index a120cfe3..b5a7da07 100644 --- a/GitHubActions/install_locales.sh +++ b/GitHubActions/install_locales.sh @@ -6,7 +6,7 @@ # tests in Ubuntu. # # Usage: ./install_locales.sh -# +# # Requirements: # - having superuser privileges # diff --git a/README.md b/README.md index c9004232..0e8efc1d 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ Features ### Common features - Transactions -- Support `INSERT`/`UPDATE`/`DELETE` (both Direct modification and Foreign modification). -- Support `TRUNCATE` by deparsing into `DELETE` statement without `WHERE` clause -- Allow control over whether foreign servers keep connections open after transaction completion. This is controlled by `keep_connections` and defaults to on +- Support `INSERT`/`UPDATE`/`DELETE` (both Direct modification and Foreign modification), see [access control](#connection-to-sqlite-database-file-and-access-control) about conditions of succesfully data modification. +- Support `TRUNCATE` by deparsing into `DELETE` statement without `WHERE` clause. +- Allow control over whether foreign servers keep connections open after transaction completion. This is controlled by `keep_connections` and defaults to on. - Support list cached connections to foreign servers by using function `sqlite_fdw_get_connections()` - Support discard cached connections to foreign servers by using function `sqlite_fdw_disconnect()`, `sqlite_fdw_disconnect_all()`. - Support Bulk `INSERT` by using `batch_size` option @@ -52,7 +52,7 @@ Features - `CASE` expressions are pushdowned. - `LIMIT` and `OFFSET` are pushdowned (*when all tables queried are fdw) - Support `GROUP BY`, `HAVING` push-down. -- `mod()` is pushdowned. In PostgreSQL gives [argument-dependend data type](https://www.postgresql.org/docs/current/functions-math.html), but result from SQLite always [have `real` affinity](https://www.sqlite.org/lang_mathfunc.html#mod). +- `mod()` is pushdowned. In PostgreSQL this function gives [argument-dependend data type](https://www.postgresql.org/docs/current/functions-math.html), but result from SQLite always [have `real` affinity](https://www.sqlite.org/lang_mathfunc.html#mod). - `upper`, `lower` and other character case functions are **not** pushed down because they does not work with UNICODE character in SQLite. - `WITH TIES` option is **not** pushed down. - Bit string `#` (XOR) operator is **not** pushed down because there is no equal SQLite operator. @@ -65,7 +65,7 @@ Features - SQLite evaluates division by zero as `NULL`. It is different from PostgreSQL, which will display `Division by zero` error. - The data type of column of foreign table should match with data type of column in SQLite to avoid wrong result. For example, if the column of SQLite is `float` (which will be stored as `float8`), the column of foreign table should be `float8`, too. If the column of foreign table is `float4`, it may cause wrong result when `SELECT`. - For `key` option, user needs to specify the primary key column of SQLite table corresponding with the `key` option. If not, wrong result may occur when `UPDATE` or `DELETE`. -- When `Sum` of data in table is out of range, `sqlite_fdw` will display `Infinity` value. It is different from PostgreSQL FDW, which will display `ERROR: value out of range: overflow` error. +- When `sum` function result value is out of range, `sqlite_fdw` will display `Infinity` value. It is different from PostgreSQL, which gives `ERROR: value out of range: overflow` error. - For `numeric` data type, `sqlite_fdw` use `sqlite3_column_double` to get value, while SQLite shell uses `sqlite3_column_text` to get value. Those 2 APIs may return different numeric value. Therefore, for `numeric` data type, the value returned from `sqlite_fdw` may different from the value returned from SQLite shell. - `sqlite_fdw` can return implementation-dependent order for column if the column is not specified in `ORDER BY` clause. - When the column type is `varchar array`, if the string is shorter than the declared length, values of type character will be space-padded; values of type `character varying` will simply store the shorter string. @@ -123,43 +123,6 @@ make install Usage ----- -### Datatypes -**WARNING! The table above represents roadmap**, work still in progress. Untill it will be ended please refer real behaviour in non-obvious cases, where there is no ✔ or ∅ mark. - -This table represents `sqlite_fdw` behaviour if in PostgreSQL foreign table column some [affinity](https://www.sqlite.org/datatype3.html) of SQLite data is detected. Some details about data values support see in [limitations](#limitations). - -* **∅** - no support (runtime error) -* **V** - transparent transformation -* **T** - cast to text in SQLite utf-8 encoding, then to **PostgreSQL text with current encoding of database** and then transparent transformation if applicable -* **✔** - transparent transformation where PostgreSQL datatype is equal to SQLite affinity -* **V+** - transparent transformation if appliacable -* **?** - not described/not tested -* **-** - transparent transformation is possible for PostgreSQL (always or for some special values), but not implemented in `sqlite_fdw`. - -SQLite `NULL` affinity always can be transparent converted for a nullable column in PostgreSQL. - -| PostgreSQL | SQLite
INT | SQLite
REAL | SQLite
BLOB | SQLite
TEXT | SQLite
TEXT but
empty|SQLite
nearest
affinity| -|-------------:|:------------:|:------------:|:------------:|:------------:|:------------:|-------------:| -| bool | V | ∅ | T | V+ | ∅ | INT | -| bit(n) | V n<=64 | ∅ | ∅ | ∅ | ∅ | INT | -| bytea | ∅ | ∅ | ✔ | - | ? | BLOB | -| date | V | V | T | V+ | `NULL` | ? | -| float4 | V+ | ✔ | T | - | `NULL` | REAL | -| float8 | V+ | ✔ | T | - | `NULL` | REAL | -| int2 | V+ | ? | T | - | `NULL` | INT | -| int4 | V+ | ? | T | - | `NULL` | INT | -| int8 | ✔ | ? | T | - | `NULL` | INT | -| json | ? | ? | T | V+ | ? | TEXT | -| name | ? | ? | T | V | `NULL` | TEXT | -| numeric | V | V | T | ∅ | `NULL` | REAL | -| text | ? | ? | T | ✔ | V | TEXT | -| time | V | V | T | V+ | `NULL` | ? | -| timestamp | V | V | T | V+ | `NULL` | ? | -|timestamp + tz| V | V | T | V+ | `NULL` | ? | -| uuid | ∅ | ∅ |V+
(only
16 bytes)| V+ | ∅ | TEXT, BLOB | -| varchar | ? | ? | T | ✔ | V | TEXT | -| varbit(n) | V n<=64 | ∅ | V | ∅ | ∅ | INT | - ### CREATE SERVER options `sqlite_fdw` accepts the following options via the `CREATE SERVER` command: @@ -170,9 +133,13 @@ SQLite `NULL` affinity always can be transparent converted for a nullable column - **updatable** as *boolean*, optional, default *true* - This option allow or disallow write operations on SQLite database file. + This option can allow or disallow data modification on foreign server for all foreign objects by default. Please note, this option can be overwritten on table level or have no effect because of some filesystem restrictions, see [connection to SQLite database file and access control](#connection-to-sqlite-database-file-and-access-control). This is only recommentadion of PostgreSQL foreign server owner user not to modify data in foreign server tables. For strong restriction see the next option `force_readonly`. + +- **force_readonly** as *boolean*, optional, default *false* + + This option is useful if you need grant user permission to create a foreign tables on the foreign server and revoke user permission to modify any table data on this foreign server. This option with `true` value can disallow any write operations on foreign server table data through SQLite file readonly access mode. This option driven only by foreign server owner role can not be overwritten by any `updatable` option value. This is a strong restriction given by PostgreSQL foreign server owner user not to modify data in any foreign server tables. Also see [Connection to SQLite database file and access control](#connection-to-sqlite-database-file-and-access-control). -- **truncatable** as *boolean*, optional, default *true* +- **truncatable** as *boolean*, optional, default *false* Allows foreign tables to be truncated using the `TRUNCATE` command. @@ -188,10 +155,7 @@ SQLite `NULL` affinity always can be transparent converted for a nullable column There is no user or password conceptions in SQLite, hence `sqlite_fdw` no need any `CREATE USER MAPPING` command. -In OS `sqlite_fdw` works as executed code with permissions of user of PostgreSQL server. Usually it is `postgres` OS user. For interacting with SQLite database without access errors ensure this user have follow permissions: -- read permission on all directories by path to the SQLite database file; -- read permission on SQLite database file; -- write permissions both on SQLite database file and *directory it contains* if you need a modification. During `INSERT`, `UPDATE` or `DELETE` in SQLite database, SQLite engine functions makes temporary files with transaction data in the directory near SQLite database file. Hence without write permissions you'll have a message `failed to execute remote SQL: rc=8 attempt to write a readonly database`. +About access model and possible data modifications problems see about [connection to SQLite database file and access control](#connection-to-sqlite-database-file-and-access-control). ### CREATE FOREIGN TABLE options @@ -212,7 +176,7 @@ In OS `sqlite_fdw` works as executed code with permissions of user of PostgreSQL - **updatable** as *boolean*, optional, default *true* - This option can allow or disallow write operations on a SQLite table independed of the same server option. + This option can allow or disallow data modification on separate foreign table. Please note, this option can have no effect if there is foreign server option `force_readonly` = `true` or depends on filesystem context, see about [connection to SQLite database file and access control](#connection-to-sqlite-database-file-and-access-control). `sqlite_fdw` accepts the following column-level options via the `CREATE FOREIGN TABLE` command: @@ -233,6 +197,43 @@ in SQLite (mixed affinity case). Updated and inserted values will have this affi Indicates a column as a part of primary key or unique key of SQLite table. +#### Datatypes +**WARNING! The table below represents roadmap**, work still in progress. Until it will be ended please refer real behaviour in non-obvious cases, where there is no ✔ or ∅ mark. + +This table represents `sqlite_fdw` behaviour if in PostgreSQL foreign table column some [affinity](https://www.sqlite.org/datatype3.html) of SQLite data is detected. Some details about data values support see in [limitations](#limitations). + +* **∅** - no support (runtime error) +* **V** - transparent transformation +* **T** - cast to text in SQLite utf-8 encoding, then to **PostgreSQL text with current encoding of database** and then transparent transformation if applicable +* **✔** - transparent transformation where PostgreSQL datatype is equal to SQLite affinity +* **V+** - transparent transformation if appliacable +* **?** - not described/not tested +* **-** - transparent transformation is possible for PostgreSQL (always or for some special values), but not implemented in `sqlite_fdw`. + +SQLite `NULL` affinity always can be transparent converted for a nullable column in PostgreSQL. + +| PostgreSQL | SQLite
INT | SQLite
REAL | SQLite
BLOB | SQLite
TEXT | SQLite
TEXT but
empty|SQLite
nearest
affinity| +|-------------:|:------------:|:------------:|:------------:|:------------:|:------------:|-------------:| +| bool | V | ∅ | T | V+ | ∅ | INT | +| bit(n) | V n<=64 | ∅ | ∅ | ∅ | ∅ | INT | +| bytea | ∅ | ∅ | ✔ | - | ? | BLOB | +| date | V | V | T | V+ | `NULL` | ? | +| float4 | V+ | ✔ | T | - | `NULL` | REAL | +| float8 | V+ | ✔ | T | - | `NULL` | REAL | +| int2 | V+ | ? | T | - | `NULL` | INT | +| int4 | V+ | ? | T | - | `NULL` | INT | +| int8 | ✔ | ? | T | - | `NULL` | INT | +| json | ? | ? | T | V+ | ? | TEXT | +| name | ? | ? | T | V | `NULL` | TEXT | +| numeric | V | V | T | ∅ | `NULL` | REAL | +| text | ? | ? | T | ✔ | V | TEXT | +| time | V | V | T | V+ | `NULL` | ? | +| timestamp | V | V | T | V+ | `NULL` | ? | +|timestamp + tz| V | V | T | V+ | `NULL` | ? | +| uuid | ∅ | ∅ |V+
(only
16 bytes)| V+ | ∅ | TEXT, BLOB | +| varchar | ? | ? | T | ✔ | V | TEXT | +| varbit(n) | V n<=64 | ∅ | V | ∅ | ∅ | INT | + ### IMPORT FOREIGN SCHEMA options `sqlite_fdw` supports [IMPORT FOREIGN SCHEMA](https://www.postgresql.org/docs/current/sql-importforeignschema.html) @@ -261,13 +262,14 @@ in SQLite (mixed affinity case). Updated and inserted values will have this affi | datetime | timestamp | | time | time | | date | date | +| uuid | uuid | ### TRUNCATE support `sqlite_fdw` implements the foreign data wrapper `TRUNCATE` API, available from PostgreSQL 14. -As SQlite does not provide a `TRUNCATE` command, it is simulated with a +As SQLite does not provide a `TRUNCATE` command, it is simulated with a simple unqualified `DELETE` operation. Actually, `TRUNCATE ... CASCADE` can be simulated if we create child table of SQLite with foreign keys and `ON DELETE CASCADE`, and then executing `TRUNCATE` (which will be deparsed to `DELETE`). @@ -276,6 +278,36 @@ Following restrictions apply: - `TRUNCATE ... RESTART IDENTITY` is not supported - SQLite tables with foreign key references can cause errors during truncating +### Connection to SQLite database file and access control + +In OS `sqlite_fdw` works as executed code with permissions of user of PostgreSQL server. Usually it is `postgres` OS user. + +#### Data read access +For succesfully connection to SQLite database file you must have at least existed and correct SQLite file readable for OS user of PostgreSQL server process. This means all directories by path to the file must be also readable (listable) for OS user of PostgreSQL server process. There are no other conditions for PostreSQL database superuser to read all of SQLite data if there are also `sqlite_fdw` extension in the database and `FOREIGN SERVER` for SQLite database file. + +#### Data change access + +Data modification access in `sqlite_fdw` drived by both operating system and PostgreSQL. + +OS restrictions can disallow any SQLite data modifications. Hence any PostgreSQL `FOREIGN SERVER` or `FOREIGN TABLE` options or `GRANT`s can be absolutely not effective. In this case SQLite data modification operations allowed by PostgreSQL can cause error message from SQLite like `attempt to write a readonly database` with result code `8`. + +Full list of OS-leveled conditions of data modification access to SQLite database file +- Existed SQLite file is not corrupted by SQLite engine conditions. +- All path elements of the file are readable (listable) for OS user of PostgreSQL server process. +- The file and a directory of the file placed on readwrite filesystem. For example `sqashfs` is always read-only, remote `sshfs` can be read-only, a disk partition can be mounted in read-only mode etc. +- The file is writable for OS user of PostgreSQL server process. +- The directory of the file is writable for OS user of PostgreSQL server process because SQLite creates some temporary transaction files. + +Full list of PostgreSQL-leveled conditions of data modification access to SQLite database file +- The `FOREIGN SERVER` of the SQLite file have no `force_readonly` = `true` option value. +- You have `USAGE` right `GRANT` for the `FOREIGN SERVER`. +- The `FOREIGN TABLE` of SQLite table have no `updatable` = `false` option value. +- If the `FOREIGN TABLE` have no `updatable` option, ensure `FOREIGN SERVER` have no `updatable` = `false` option value. + +Generally for `sqlite_fdw` access management `FOREIGN SERVER` owner can be like _remote access manager_ for other FDWs. + +_Remote access manager_ can block any data modififcations in remote database for _remote user_ of a FDW. In this case SQLite have no user or separate access conceptions, hence `FOREIGN SERVER` owner combines _remote access manager_ role with internal PostgreSQL roles such as `FOREIGN SERVER` access management. + Functions --------- @@ -297,11 +329,12 @@ sqlite_fdw_version -------------------- 20400 ``` + Identifier case handling ------------------------ PostgreSQL folds identifiers to lower case by default, SQLite is case insensitive by default -and doesn't differ uppercase and lowercase ASCII base latin letters. It's important +only for uppercase and lowercase ASCII base latin letters. It's important to be aware of potential issues with table and column names. Following SQL isn't correct for SQLite: `Error: duplicate column name: a`, but is correct for PostgreSQL @@ -340,7 +373,7 @@ For SQLite there is no difference between ``` For PostgreSQL the query with comment `№4` is independend query to table `T`, not to table `t` as other queries. Please note this table name composed from ASCII base latin letters *only*. This is not applicable for other -alphabet systems or mixed names. This is because `toLower` operation in PostgreSQL is Unicode opration but +alphabet systems or mixed names. This is because `toLower` operation in PostgreSQL is Unicode operation but ASCII only operation in SQLite, hence other characters will not be changed. ```sql @@ -361,7 +394,7 @@ If there is b REAL ); ``` -in SQLite, both `a` and `A` , `b` and `B` columns will have the same real datasource in SQlite in follow foreign table: +in SQLite, both `a` and `A` , `b` and `B` columns will have the same real datasource in SQLite in follow foreign table: ```sql CREATE FOREIGN TABLE "SQLite test" ( @@ -400,7 +433,7 @@ stored in SQLite, only [`PRAGMA encoding;`](https://www.sqlite.org/pragma.html#p When `sqlite_fdw` connects to a SQLite, all strings are interpreted acording the PostgreSQL database's server encoding. It's not a problem if your PostgreSQL database encoding belongs to Unicode family. Otherewise interpretation transformation problems can occur. Some unproper for PostgreSQL database encoding characters will be replaced to default 'no such character' character or there will error like `character with byte sequence 0x** in encoding "UTF8" has no equivalent in encoding "**"`. -Character case functions such as `upper`, `lower` and other are not pushed down because they does not work with UNICODE character in SQLite. +Character case functions such as `upper`, `lower` and other are not pushed down because they does not work with Unicode character in SQLite. `Sqlite_fdw` tested with PostgreSQL database encodings `EUC_JP`, `EUC_KR`, `ISO_8859_5`, `ISO_8859_6`, `ISO_8859_7`, `ISO_8859_8`, `LATIN1`, `LATIN2`, `LATIN3`, `LATIN4`, `LATIN5`, `LATIN6`, `LATIN7`, `LATIN8`, `LATIN9`, `LATIN9`, `LATIN10`, `WIN1250`, `WIN1251`, `WIN1252`, `WIN1253`, `WIN1254`, `WIN1255`, `WIN1256`, `WIN1257` and it's synomyms. Some other encodings also can be supported, but not tested. diff --git a/connection.c b/connection.c index ce16a07b..2f373217 100644 --- a/connection.c +++ b/connection.c @@ -41,6 +41,7 @@ typedef struct ConnCacheEntry bool keep_connections; /* setting value of keep_connections * server option */ bool truncatable; /* check table can truncate or not */ + bool readonly; /* option force_readonly, readonly SQLite file mode */ bool invalidated; /* true if reconnect is pending */ Oid serverid; /* foreign server OID used to get server name */ List *stmtList; /* list stmt associated with conn */ @@ -60,7 +61,7 @@ PG_FUNCTION_INFO_V1(sqlite_fdw_get_connections); PG_FUNCTION_INFO_V1(sqlite_fdw_disconnect); PG_FUNCTION_INFO_V1(sqlite_fdw_disconnect_all); -static sqlite3 *sqlite_open_db(const char *dbpath); +static sqlite3 *sqlite_open_db(const char *dbpath, int flags); static void sqlite_make_new_connection(ConnCacheEntry *entry, ForeignServer *server); void sqlite_do_sql_command(sqlite3 * conn, const char *sql, int level, List **busy_connection); static void sqlite_begin_remote_xact(ConnCacheEntry *entry); @@ -184,21 +185,21 @@ sqlite_get_connection(ForeignServer *server, bool truncatable) } /* - * Open remote sqlite database using specified database path. + * Open remote sqlite database using specified database path + * and flags of opened file descriptor mode. */ static sqlite3 * -sqlite_open_db(const char *dbpath) +sqlite_open_db(const char *dbpath, int flags) { sqlite3 *conn = NULL; int rc; char *err; - - rc = sqlite3_open(dbpath, &conn); + const char *zVfs = NULL; + rc = sqlite3_open_v2(dbpath, &conn, flags, zVfs); if (rc != SQLITE_OK) ereport(ERROR, (errcode(ERRCODE_FDW_UNABLE_TO_ESTABLISH_CONNECTION), - errmsg("failed to open SQLite DB. rc=%d path=%s", rc, dbpath))); - + errmsg("Failed to open SQLite DB, file '%s', result code %d", dbpath, rc))); /* make 'LIKE' of SQLite case sensitive like PostgreSQL */ rc = sqlite3_exec(conn, "pragma case_sensitive_like=1", NULL, NULL, &err); @@ -208,9 +209,10 @@ sqlite_open_db(const char *dbpath) sqlite3_free(err); sqlite3_close(conn); + conn = NULL; ereport(ERROR, (errcode(ERRCODE_FDW_UNABLE_TO_ESTABLISH_CONNECTION), - errmsg("failed to open SQLite DB. rc=%d err=%s", rc, perr))); + errmsg("Failed to open SQLite DB, file '%s', SQLite error '%s', result code %d", dbpath, perr, rc))); } /* add included inner SQLite functions from separate c file * for using in data unifying during deparsing @@ -219,6 +221,7 @@ sqlite_open_db(const char *dbpath) return conn; } + /* * Reset all transient state fields in the cached connection entry and * establish new connection to the remote server. @@ -228,6 +231,7 @@ sqlite_make_new_connection(ConnCacheEntry *entry, ForeignServer *server) { const char *dbpath = NULL; ListCell *lc; + int flags = 0; Assert(entry->conn == NULL); @@ -236,6 +240,7 @@ sqlite_make_new_connection(ConnCacheEntry *entry, ForeignServer *server) entry->invalidated = false; entry->stmtList = NULL; entry->keep_connections = true; + entry->readonly = false; entry->server_hashvalue = GetSysCacheHashValue1(FOREIGNSERVEROID, ObjectIdGetDatum(server->serverid)); @@ -247,10 +252,13 @@ sqlite_make_new_connection(ConnCacheEntry *entry, ForeignServer *server) dbpath = defGetString(def); else if (strcmp(def->defname, "keep_connections") == 0) entry->keep_connections = defGetBoolean(def); + else if (strcmp(def->defname, "force_readonly") == 0) + entry->readonly = defGetBoolean(def); } + flags = flags | (entry->readonly ? SQLITE_OPEN_READONLY : SQLITE_OPEN_READWRITE); /* Try to make the connection */ - entry->conn = sqlite_open_db(dbpath); + entry->conn = sqlite_open_db(dbpath, flags); } /* @@ -282,8 +290,9 @@ sqlite_cleanup_connection(void) { ereport(ERROR, (errcode(ERRCODE_FDW_UNABLE_TO_CREATE_EXECUTION), - errmsg("close connection failed: %s rc=%d", sqlite3_errmsg(entry->conn), rc) - )); + errmsg("Failed to close SQLite DB"), + errhint("SQLite error '%s', SQLite result code %d", sqlite3_errmsg(entry->conn), rc) + )); } } } @@ -327,15 +336,18 @@ sqlite_do_sql_command(sqlite3 * conn, const char *sql, int level, List **busy_co { ereport(level, (errcode(ERRCODE_FDW_ERROR), - errmsg("SQLite failed to execute sql: %s %s", sql, perr) - )); + errmsg("SQLite failed to execute a query"), + errcontext("SQL query: %s", sql), + errhint("SQLite error '%s'", perr))); + pfree(perr); } } else ereport(level, (errcode(ERRCODE_FDW_ERROR), - errmsg("SQLite failed to execute sql: %s", sql) + errmsg("SQLite failed to execute a query"), + errcontext("SQL query: %s", sql) )); } } @@ -401,10 +413,10 @@ sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn, } ereport(ERROR, (errcode(sqlstate), - errmsg("failed to execute remote SQL: rc=%d %s \n sql=%s", - rc, message ? message : "", sql ? sql : "") - )); - + errmsg("Failed to execute remote SQL"), + errcontext("SQL query: %s", sql ? sql : ""), + errhint("SQLite error '%s', SQLite result code %d", message ? message : "", rc) + )); } @@ -903,9 +915,12 @@ sqlitefdw_abort_cleanup(ConnCacheEntry *entry, bool toplevel, List **busy_connec { char sql[100]; int curlevel = GetCurrentTransactionNestLevel(); - snprintf(sql, sizeof(sql), - "ROLLBACK TO SAVEPOINT s%d; RELEASE SAVEPOINT s%d", - curlevel, curlevel); + snprintf(sql, + sizeof(sql), + "ROLLBACK TO SAVEPOINT s%d; RELEASE SAVEPOINT s%d", + curlevel, + curlevel + ); if (!sqlite3_get_autocommit(entry->conn)) sqlite_do_sql_command(entry->conn, sql, ERROR, busy_connection); } diff --git a/expected/12.16/extra/bool.out b/expected/12.16/extra/bool.out index 45750a6a..ec908ab6 100644 --- a/expected/12.16/extra/bool.out +++ b/expected/12.16/extra/bool.out @@ -238,8 +238,9 @@ INSERT INTO "type_BOOLEANpk" VALUES (TRUE); INSERT INTO "type_BOOLEANpk" VALUES (FALSE); --Testcase 44: ERR - primary key INSERT INTO "type_BOOLEANpk" VALUES (TRUE); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_BOOLEANpk.col - sql=INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_BOOLEANpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) --Testcase 45: DELETE FROM "type_BOOLEANpk"; --Testcase 46: diff --git a/expected/12.16/extra/insert.out b/expected/12.16/extra/insert.out index 19773b50..fa1e72bc 100644 --- a/expected/12.16/extra/insert.out +++ b/expected/12.16/extra/insert.out @@ -10,8 +10,9 @@ OPTIONS (database '/tmp/sqlite_fdw_test/core.db'); CREATE FOREIGN TABLE inserttest01 (col1 int4, col2 int4 NOT NULL, col3 text default 'testing') SERVER sqlite_svr; --Testcase 1: insert into inserttest01 (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT); -ERROR: failed to execute remote SQL: rc=19 NOT NULL constraint failed: inserttest01.col2 - sql=INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'NOT NULL constraint failed: inserttest01.col2', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) --Testcase 2: insert into inserttest01 (col2, col3) values (3, DEFAULT); --Testcase 3: diff --git a/expected/12.16/extra/sqlite_fdw_post.out b/expected/12.16/extra/sqlite_fdw_post.out index 6b683b08..bc27ca17 100644 --- a/expected/12.16/extra/sqlite_fdw_post.out +++ b/expected/12.16/extra/sqlite_fdw_post.out @@ -133,7 +133,7 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work ALTER SERVER sqlite_svr OPTIONS (SET database 'no such database'); --Testcase 7: SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail -ERROR: SQL error during prepare: no such table: main.T 1 SELECT `C 1`, `c3`, `c4` FROM main."T 1" ORDER BY `c3` ASC NULLS LAST, `C 1` ASC NULLS LAST LIMIT 1 +ERROR: Failed to open SQLite DB, file 'no such database', result code 14 DO $d$ BEGIN EXECUTE $$ALTER SERVER sqlite_svr @@ -6424,8 +6424,9 @@ ALTER FOREIGN TABLE ft1 RENAME TO ft1_org; ALTER FOREIGN TABLE ft1_constraint RENAME TO ft1; --Testcase 319: INSERT INTO ft1(c1, c2) VALUES(11, 12); -- duplicate key -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: t1_constraint.c1 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: t1_constraint.c1', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 320: INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO NOTHING; -- unsupported ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification @@ -6434,12 +6435,14 @@ INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO UPDATE SET c3 = ' ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification --Testcase 743: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 744: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) --Testcase 750: ALTER FOREIGN TABLE ft1 RENAME TO ft1_constraint; --Testcase 751: @@ -6840,12 +6843,14 @@ RESET constraint_exclusion; -- check constraint is enforced on the remote side, not locally --Testcase 745: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 746: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2positive; -- But inconsistent check constraints provide inconsistent results ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c2negative CHECK (c2 < 0); diff --git a/expected/12.16/extra/uuid.out b/expected/12.16/extra/uuid.out index e941adb3..2f16427a 100644 --- a/expected/12.16/extra/uuid.out +++ b/expected/12.16/extra/uuid.out @@ -521,8 +521,9 @@ SELECT * FROM "type_UUIDpk"; --Testcase 105: ERR - primary key INSERT INTO "type_UUIDpk" VALUES ('{b0eebc99-9c0b4ef8-bb6d6bb9-bd380a12}'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_UUIDpk.col - sql=INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_UUIDpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) --Testcase 106: ALTER FOREIGN TABLE "type_UUIDpk" ALTER COLUMN col OPTIONS (SET column_type 'BLOB'); --Testcase 107: NO ERR, but the same semantics! diff --git a/expected/12.16/sqlite_fdw.out b/expected/12.16/sqlite_fdw.out index b0f6b693..525744f0 100644 --- a/expected/12.16/sqlite_fdw.out +++ b/expected/12.16/sqlite_fdw.out @@ -575,8 +575,9 @@ SELECT * from numbers; -- duplicate key --Testcase 68: INSERT INTO numbers VALUES(1, 'One'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) --Testcase 69: DELETE from numbers; BEGIN; @@ -588,8 +589,9 @@ COMMIT; -- violate unique constraint --Testcase 72: UPDATE numbers SET b='Two' WHERE a = 1; -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) --Testcase 73: SELECT * from numbers; a | b @@ -1670,27 +1672,43 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -1701,7 +1719,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -1713,7 +1731,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -1724,7 +1742,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -1736,7 +1754,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -1749,7 +1767,7 @@ UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -1758,7 +1776,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -1770,7 +1788,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -1804,8 +1822,265 @@ ERROR: cannot convert constant value to Sqlite value HINT: Constant value data type: "tsquery" in column "b" --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +----+---+-------+--- + 4 | F | 0.005 | 5 + 10 | P | 4.15 | 1 +(2 rows) + +--Testcase 321: +DELETE FROM RO_RW_test; +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +---+---+---+--- +(0 rows) + +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +ERROR: cannot convert constant value to Sqlite value +HINT: Constant value data type: "tsquery" in column "b" +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: diff --git a/expected/12.16/type.out b/expected/12.16/type.out index eb69f1e7..149c87d5 100644 --- a/expected/12.16/type.out +++ b/expected/12.16/type.out @@ -513,8 +513,9 @@ ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; INSERT INTO "type_DOUBLE" VALUES (PI()); --Testcase 109: ERR primary key INSERT INTO "type_DOUBLE" VALUES (PI()); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 110: INSERT INTO "type_DOUBLE" VALUES ('Infinity'); --Testcase 111: @@ -531,12 +532,14 @@ SELECT * FROM "type_DOUBLE"; -- OK, +- Inf --Testcase 114: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 115: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('-Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 116: SELECT * FROM "type_DOUBLE"; -- OK, +- Inf col diff --git a/expected/13.12/extra/bool.out b/expected/13.12/extra/bool.out index 45750a6a..ec908ab6 100644 --- a/expected/13.12/extra/bool.out +++ b/expected/13.12/extra/bool.out @@ -238,8 +238,9 @@ INSERT INTO "type_BOOLEANpk" VALUES (TRUE); INSERT INTO "type_BOOLEANpk" VALUES (FALSE); --Testcase 44: ERR - primary key INSERT INTO "type_BOOLEANpk" VALUES (TRUE); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_BOOLEANpk.col - sql=INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_BOOLEANpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) --Testcase 45: DELETE FROM "type_BOOLEANpk"; --Testcase 46: diff --git a/expected/13.12/extra/insert.out b/expected/13.12/extra/insert.out index 19773b50..fa1e72bc 100644 --- a/expected/13.12/extra/insert.out +++ b/expected/13.12/extra/insert.out @@ -10,8 +10,9 @@ OPTIONS (database '/tmp/sqlite_fdw_test/core.db'); CREATE FOREIGN TABLE inserttest01 (col1 int4, col2 int4 NOT NULL, col3 text default 'testing') SERVER sqlite_svr; --Testcase 1: insert into inserttest01 (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT); -ERROR: failed to execute remote SQL: rc=19 NOT NULL constraint failed: inserttest01.col2 - sql=INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'NOT NULL constraint failed: inserttest01.col2', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) --Testcase 2: insert into inserttest01 (col2, col3) values (3, DEFAULT); --Testcase 3: diff --git a/expected/13.12/extra/sqlite_fdw_post.out b/expected/13.12/extra/sqlite_fdw_post.out index 726222c2..0c262b49 100644 --- a/expected/13.12/extra/sqlite_fdw_post.out +++ b/expected/13.12/extra/sqlite_fdw_post.out @@ -133,7 +133,7 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work ALTER SERVER sqlite_svr OPTIONS (SET database 'no such database'); --Testcase 7: SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail -ERROR: SQL error during prepare: no such table: main.T 1 SELECT `C 1`, `c3`, `c4` FROM main."T 1" ORDER BY `c3` ASC NULLS LAST, `C 1` ASC NULLS LAST LIMIT 1 +ERROR: Failed to open SQLite DB, file 'no such database', result code 14 DO $d$ BEGIN EXECUTE $$ALTER SERVER sqlite_svr @@ -6426,8 +6426,9 @@ ALTER FOREIGN TABLE ft1 RENAME TO ft1_org; ALTER FOREIGN TABLE ft1_constraint RENAME TO ft1; --Testcase 319: INSERT INTO ft1(c1, c2) VALUES(11, 12); -- duplicate key -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: t1_constraint.c1 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: t1_constraint.c1', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 320: INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO NOTHING; -- unsupported ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification @@ -6436,12 +6437,14 @@ INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO UPDATE SET c3 = ' ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification --Testcase 743: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 744: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) --Testcase 750: ALTER FOREIGN TABLE ft1 RENAME TO ft1_constraint; --Testcase 751: @@ -6842,12 +6845,14 @@ RESET constraint_exclusion; -- check constraint is enforced on the remote side, not locally --Testcase 745: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 746: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2positive; -- But inconsistent check constraints provide inconsistent results ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c2negative CHECK (c2 < 0); diff --git a/expected/13.12/extra/uuid.out b/expected/13.12/extra/uuid.out index e941adb3..2f16427a 100644 --- a/expected/13.12/extra/uuid.out +++ b/expected/13.12/extra/uuid.out @@ -521,8 +521,9 @@ SELECT * FROM "type_UUIDpk"; --Testcase 105: ERR - primary key INSERT INTO "type_UUIDpk" VALUES ('{b0eebc99-9c0b4ef8-bb6d6bb9-bd380a12}'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_UUIDpk.col - sql=INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_UUIDpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) --Testcase 106: ALTER FOREIGN TABLE "type_UUIDpk" ALTER COLUMN col OPTIONS (SET column_type 'BLOB'); --Testcase 107: NO ERR, but the same semantics! diff --git a/expected/13.12/sqlite_fdw.out b/expected/13.12/sqlite_fdw.out index b0f6b693..40995678 100644 --- a/expected/13.12/sqlite_fdw.out +++ b/expected/13.12/sqlite_fdw.out @@ -17,7 +17,7 @@ CREATE FOREIGN TABLE numbers(a int OPTIONS (key 'true'), b varchar(255)) SERVER CREATE FOREIGN TABLE multiprimary(a int, b int OPTIONS (key 'true'), c int OPTIONS(key 'true')) SERVER sqlite_svr; --Testcase 136: CREATE FOREIGN TABLE noprimary(a int, b text) SERVER sqlite_svr; --- updatable option test (github pull 59) +--Testcase 137: CREATE FOREIGN TABLE RO_RW_test(i int OPTIONS (key 'true'), a text, b float, c int) SERVER sqlite_svr; --Testcase 1: SELECT * FROM department LIMIT 10; @@ -575,8 +575,9 @@ SELECT * from numbers; -- duplicate key --Testcase 68: INSERT INTO numbers VALUES(1, 'One'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) --Testcase 69: DELETE from numbers; BEGIN; @@ -588,8 +589,9 @@ COMMIT; -- violate unique constraint --Testcase 72: UPDATE numbers SET b='Two' WHERE a = 1; -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) --Testcase 73: SELECT * from numbers; a | b @@ -1670,27 +1672,43 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -1701,7 +1719,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -1713,7 +1731,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -1724,7 +1742,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -1736,7 +1754,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -1749,7 +1767,7 @@ UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -1758,7 +1776,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -1770,7 +1788,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -1804,8 +1822,265 @@ ERROR: cannot convert constant value to Sqlite value HINT: Constant value data type: "tsquery" in column "b" --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +----+---+-------+--- + 4 | F | 0.005 | 5 + 10 | P | 4.15 | 1 +(2 rows) + +--Testcase 321: +DELETE FROM RO_RW_test; +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +---+---+---+--- +(0 rows) + +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +ERROR: cannot convert constant value to Sqlite value +HINT: Constant value data type: "tsquery" in column "b" +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: diff --git a/expected/13.12/type.out b/expected/13.12/type.out index eb69f1e7..149c87d5 100644 --- a/expected/13.12/type.out +++ b/expected/13.12/type.out @@ -513,8 +513,9 @@ ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; INSERT INTO "type_DOUBLE" VALUES (PI()); --Testcase 109: ERR primary key INSERT INTO "type_DOUBLE" VALUES (PI()); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 110: INSERT INTO "type_DOUBLE" VALUES ('Infinity'); --Testcase 111: @@ -531,12 +532,14 @@ SELECT * FROM "type_DOUBLE"; -- OK, +- Inf --Testcase 114: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 115: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('-Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 116: SELECT * FROM "type_DOUBLE"; -- OK, +- Inf col diff --git a/expected/14.9/extra/bool.out b/expected/14.9/extra/bool.out index 45750a6a..ec908ab6 100644 --- a/expected/14.9/extra/bool.out +++ b/expected/14.9/extra/bool.out @@ -238,8 +238,9 @@ INSERT INTO "type_BOOLEANpk" VALUES (TRUE); INSERT INTO "type_BOOLEANpk" VALUES (FALSE); --Testcase 44: ERR - primary key INSERT INTO "type_BOOLEANpk" VALUES (TRUE); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_BOOLEANpk.col - sql=INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_BOOLEANpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) --Testcase 45: DELETE FROM "type_BOOLEANpk"; --Testcase 46: diff --git a/expected/14.9/extra/insert.out b/expected/14.9/extra/insert.out index 7a2c6c77..ae646902 100644 --- a/expected/14.9/extra/insert.out +++ b/expected/14.9/extra/insert.out @@ -10,8 +10,9 @@ OPTIONS (database '/tmp/sqlite_fdw_test/core.db'); CREATE FOREIGN TABLE inserttest01 (col1 int4, col2 int4 NOT NULL, col3 text default 'testing') SERVER sqlite_svr; --Testcase 1: insert into inserttest01 (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT); -ERROR: failed to execute remote SQL: rc=19 NOT NULL constraint failed: inserttest01.col2 - sql=INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'NOT NULL constraint failed: inserttest01.col2', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) --Testcase 2: insert into inserttest01 (col2, col3) values (3, DEFAULT); --Testcase 3: diff --git a/expected/14.9/extra/sqlite_fdw_post.out b/expected/14.9/extra/sqlite_fdw_post.out index c2a72da1..85f777d5 100644 --- a/expected/14.9/extra/sqlite_fdw_post.out +++ b/expected/14.9/extra/sqlite_fdw_post.out @@ -151,7 +151,7 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work ALTER SERVER sqlite_svr OPTIONS (SET database 'no such database'); --Testcase 7: SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail -ERROR: SQL error during prepare: no such table: main.T 1 SELECT `C 1`, `c3`, `c4` FROM main."T 1" ORDER BY `c3` ASC NULLS LAST, `C 1` ASC NULLS LAST LIMIT 1 +ERROR: Failed to open SQLite DB, file 'no such database', result code 14 DO $d$ BEGIN EXECUTE $$ALTER SERVER sqlite_svr @@ -6554,8 +6554,9 @@ ALTER FOREIGN TABLE ft1 RENAME TO ft1_org; ALTER FOREIGN TABLE ft1_constraint RENAME TO ft1; --Testcase 319: INSERT INTO ft1(c1, c2) VALUES(11, 12); -- duplicate key -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: t1_constraint.c1 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: t1_constraint.c1', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 320: INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO NOTHING; -- unsupported ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification @@ -6564,12 +6565,14 @@ INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO UPDATE SET c3 = ' ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification --Testcase 743: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 744: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) --Testcase 750: ALTER FOREIGN TABLE ft1 RENAME TO ft1_constraint; --Testcase 751: @@ -6973,12 +6976,14 @@ RESET constraint_exclusion; -- check constraint is enforced on the remote side, not locally --Testcase 745: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 746: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) --Testcase 817: ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2positive; -- But inconsistent check constraints provide inconsistent results diff --git a/expected/14.9/extra/uuid.out b/expected/14.9/extra/uuid.out index e06558f7..35bf1e87 100644 --- a/expected/14.9/extra/uuid.out +++ b/expected/14.9/extra/uuid.out @@ -523,8 +523,9 @@ SELECT * FROM "type_UUIDpk"; --Testcase 105: ERR - primary key INSERT INTO "type_UUIDpk" VALUES ('{b0eebc99-9c0b4ef8-bb6d6bb9-bd380a12}'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_UUIDpk.col - sql=INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_UUIDpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) --Testcase 106: ALTER FOREIGN TABLE "type_UUIDpk" ALTER COLUMN col OPTIONS (SET column_type 'BLOB'); --Testcase 107: NO ERR, but the same semantics! diff --git a/expected/14.9/sqlite_fdw.out b/expected/14.9/sqlite_fdw.out index 05fee260..2a7a5832 100644 --- a/expected/14.9/sqlite_fdw.out +++ b/expected/14.9/sqlite_fdw.out @@ -17,7 +17,7 @@ CREATE FOREIGN TABLE numbers(a int OPTIONS (key 'true'), b varchar(255)) SERVER CREATE FOREIGN TABLE multiprimary(a int, b int OPTIONS (key 'true'), c int OPTIONS(key 'true')) SERVER sqlite_svr; --Testcase 136: CREATE FOREIGN TABLE noprimary(a int, b text) SERVER sqlite_svr; --- updatable option test (github pull 59) +-- readonly/readwrite test github pull 59 CREATE FOREIGN TABLE RO_RW_test(i int OPTIONS (key 'true'), a text, b float, c int) SERVER sqlite_svr; --Testcase 1: SELECT * FROM department LIMIT 10; @@ -575,8 +575,9 @@ SELECT * from numbers; -- duplicate key --Testcase 68: INSERT INTO numbers VALUES(1, 'One'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) --Testcase 69: DELETE from numbers; BEGIN; @@ -588,8 +589,9 @@ COMMIT; -- violate unique constraint --Testcase 72: UPDATE numbers SET b='Two' WHERE a = 1; -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) --Testcase 73: SELECT * from numbers; a | b @@ -1682,27 +1684,43 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -1713,7 +1731,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -1725,7 +1743,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -1736,7 +1754,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -1748,7 +1766,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -1761,7 +1779,7 @@ UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -1770,7 +1788,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -1782,7 +1800,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -1816,8 +1834,265 @@ ERROR: cannot convert constant value to Sqlite value HINT: Constant value data type: "tsquery" in column "b" --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +----+---+-------+--- + 4 | F | 0.005 | 5 + 10 | P | 4.15 | 1 +(2 rows) + +--Testcase 321: +DELETE FROM RO_RW_test; +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +---+---+---+--- +(0 rows) + +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +ERROR: cannot convert constant value to Sqlite value +HINT: Constant value data type: "tsquery" in column "b" +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: diff --git a/expected/14.9/type.out b/expected/14.9/type.out index eb69f1e7..149c87d5 100644 --- a/expected/14.9/type.out +++ b/expected/14.9/type.out @@ -513,8 +513,9 @@ ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; INSERT INTO "type_DOUBLE" VALUES (PI()); --Testcase 109: ERR primary key INSERT INTO "type_DOUBLE" VALUES (PI()); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 110: INSERT INTO "type_DOUBLE" VALUES ('Infinity'); --Testcase 111: @@ -531,12 +532,14 @@ SELECT * FROM "type_DOUBLE"; -- OK, +- Inf --Testcase 114: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 115: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('-Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 116: SELECT * FROM "type_DOUBLE"; -- OK, +- Inf col diff --git a/expected/15.4/extra/bool.out b/expected/15.4/extra/bool.out index 45750a6a..ec908ab6 100644 --- a/expected/15.4/extra/bool.out +++ b/expected/15.4/extra/bool.out @@ -238,8 +238,9 @@ INSERT INTO "type_BOOLEANpk" VALUES (TRUE); INSERT INTO "type_BOOLEANpk" VALUES (FALSE); --Testcase 44: ERR - primary key INSERT INTO "type_BOOLEANpk" VALUES (TRUE); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_BOOLEANpk.col - sql=INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_BOOLEANpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) --Testcase 45: DELETE FROM "type_BOOLEANpk"; --Testcase 46: diff --git a/expected/15.4/extra/insert.out b/expected/15.4/extra/insert.out index 2d579fbe..f73c0619 100644 --- a/expected/15.4/extra/insert.out +++ b/expected/15.4/extra/insert.out @@ -10,8 +10,9 @@ OPTIONS (database '/tmp/sqlite_fdw_test/core.db'); CREATE FOREIGN TABLE inserttest01 (col1 int4, col2 int4 NOT NULL, col3 text default 'testing') SERVER sqlite_svr; --Testcase 1: insert into inserttest01 (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT); -ERROR: failed to execute remote SQL: rc=19 NOT NULL constraint failed: inserttest01.col2 - sql=INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'NOT NULL constraint failed: inserttest01.col2', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) --Testcase 2: insert into inserttest01 (col2, col3) values (3, DEFAULT); --Testcase 3: diff --git a/expected/15.4/extra/sqlite_fdw_post.out b/expected/15.4/extra/sqlite_fdw_post.out index 545aa866..2528a481 100644 --- a/expected/15.4/extra/sqlite_fdw_post.out +++ b/expected/15.4/extra/sqlite_fdw_post.out @@ -151,7 +151,7 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work ALTER SERVER sqlite_svr OPTIONS (SET database 'no such database'); --Testcase 7: SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail -ERROR: SQL error during prepare: no such table: main.T 1 SELECT `C 1`, `c3`, `c4` FROM main."T 1" ORDER BY `c3` ASC NULLS LAST, `C 1` ASC NULLS LAST LIMIT 1 +ERROR: Failed to open SQLite DB, file 'no such database', result code 14 DO $d$ BEGIN EXECUTE $$ALTER SERVER sqlite_svr @@ -6847,8 +6847,9 @@ ALTER FOREIGN TABLE ft1 RENAME TO ft1_org; ALTER FOREIGN TABLE ft1_constraint RENAME TO ft1; --Testcase 319: INSERT INTO ft1(c1, c2) VALUES(11, 12); -- duplicate key -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: t1_constraint.c1 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: t1_constraint.c1', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 320: INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO NOTHING; -- unsupported ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification @@ -6857,12 +6858,14 @@ INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO UPDATE SET c3 = ' ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification --Testcase 743: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 744: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) --Testcase 750: ALTER FOREIGN TABLE ft1 RENAME TO ft1_constraint; --Testcase 751: @@ -7266,12 +7269,14 @@ RESET constraint_exclusion; -- check constraint is enforced on the remote side, not locally --Testcase 745: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 746: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) --Testcase 817: ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2positive; -- But inconsistent check constraints provide inconsistent results diff --git a/expected/15.4/extra/uuid.out b/expected/15.4/extra/uuid.out index e06558f7..35bf1e87 100644 --- a/expected/15.4/extra/uuid.out +++ b/expected/15.4/extra/uuid.out @@ -523,8 +523,9 @@ SELECT * FROM "type_UUIDpk"; --Testcase 105: ERR - primary key INSERT INTO "type_UUIDpk" VALUES ('{b0eebc99-9c0b4ef8-bb6d6bb9-bd380a12}'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_UUIDpk.col - sql=INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_UUIDpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) --Testcase 106: ALTER FOREIGN TABLE "type_UUIDpk" ALTER COLUMN col OPTIONS (SET column_type 'BLOB'); --Testcase 107: NO ERR, but the same semantics! diff --git a/expected/15.4/sqlite_fdw.out b/expected/15.4/sqlite_fdw.out index 05fee260..9577e4a8 100644 --- a/expected/15.4/sqlite_fdw.out +++ b/expected/15.4/sqlite_fdw.out @@ -575,8 +575,9 @@ SELECT * from numbers; -- duplicate key --Testcase 68: INSERT INTO numbers VALUES(1, 'One'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) --Testcase 69: DELETE from numbers; BEGIN; @@ -588,8 +589,9 @@ COMMIT; -- violate unique constraint --Testcase 72: UPDATE numbers SET b='Two' WHERE a = 1; -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) --Testcase 73: SELECT * from numbers; a | b @@ -1682,27 +1684,43 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -1713,7 +1731,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -1725,7 +1743,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -1736,7 +1754,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -1748,7 +1766,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -1761,7 +1779,7 @@ UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -1770,7 +1788,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -1782,7 +1800,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -1816,8 +1834,265 @@ ERROR: cannot convert constant value to Sqlite value HINT: Constant value data type: "tsquery" in column "b" --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +----+---+-------+--- + 4 | F | 0.005 | 5 + 10 | P | 4.15 | 1 +(2 rows) + +--Testcase 321: +DELETE FROM RO_RW_test; +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +---+---+---+--- +(0 rows) + +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +ERROR: cannot convert constant value to Sqlite value +HINT: Constant value data type: "tsquery" in column "b" +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: diff --git a/expected/15.4/type.out b/expected/15.4/type.out index eb69f1e7..149c87d5 100644 --- a/expected/15.4/type.out +++ b/expected/15.4/type.out @@ -513,8 +513,9 @@ ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; INSERT INTO "type_DOUBLE" VALUES (PI()); --Testcase 109: ERR primary key INSERT INTO "type_DOUBLE" VALUES (PI()); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 110: INSERT INTO "type_DOUBLE" VALUES ('Infinity'); --Testcase 111: @@ -531,12 +532,14 @@ SELECT * FROM "type_DOUBLE"; -- OK, +- Inf --Testcase 114: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 115: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('-Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 116: SELECT * FROM "type_DOUBLE"; -- OK, +- Inf col diff --git a/expected/16.0/extra/bool.out b/expected/16.0/extra/bool.out index 45750a6a..ec908ab6 100644 --- a/expected/16.0/extra/bool.out +++ b/expected/16.0/extra/bool.out @@ -238,8 +238,9 @@ INSERT INTO "type_BOOLEANpk" VALUES (TRUE); INSERT INTO "type_BOOLEANpk" VALUES (FALSE); --Testcase 44: ERR - primary key INSERT INTO "type_BOOLEANpk" VALUES (TRUE); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_BOOLEANpk.col - sql=INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_BOOLEANpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?) --Testcase 45: DELETE FROM "type_BOOLEANpk"; --Testcase 46: diff --git a/expected/16.0/extra/insert.out b/expected/16.0/extra/insert.out index 2d579fbe..f73c0619 100644 --- a/expected/16.0/extra/insert.out +++ b/expected/16.0/extra/insert.out @@ -10,8 +10,9 @@ OPTIONS (database '/tmp/sqlite_fdw_test/core.db'); CREATE FOREIGN TABLE inserttest01 (col1 int4, col2 int4 NOT NULL, col3 text default 'testing') SERVER sqlite_svr; --Testcase 1: insert into inserttest01 (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT); -ERROR: failed to execute remote SQL: rc=19 NOT NULL constraint failed: inserttest01.col2 - sql=INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'NOT NULL constraint failed: inserttest01.col2', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?) --Testcase 2: insert into inserttest01 (col2, col3) values (3, DEFAULT); --Testcase 3: diff --git a/expected/16.0/extra/sqlite_fdw_post.out b/expected/16.0/extra/sqlite_fdw_post.out index 91bef518..3f2c26a3 100644 --- a/expected/16.0/extra/sqlite_fdw_post.out +++ b/expected/16.0/extra/sqlite_fdw_post.out @@ -151,7 +151,7 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work ALTER SERVER sqlite_svr OPTIONS (SET database 'no such database'); --Testcase 7: SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail -ERROR: SQL error during prepare: no such table: main.T 1 SELECT `C 1`, `c3`, `c4` FROM main."T 1" ORDER BY `c3` ASC NULLS LAST, `C 1` ASC NULLS LAST LIMIT 1 +ERROR: Failed to open SQLite DB, file 'no such database', result code 14 DO $d$ BEGIN EXECUTE $$ALTER SERVER sqlite_svr @@ -6943,8 +6943,9 @@ ALTER FOREIGN TABLE ft1 RENAME TO ft1_org; ALTER FOREIGN TABLE ft1_constraint RENAME TO ft1; --Testcase 319: INSERT INTO ft1(c1, c2) VALUES(11, 12); -- duplicate key -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: t1_constraint.c1 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: t1_constraint.c1', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 320: INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO NOTHING; -- unsupported ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification @@ -6953,12 +6954,14 @@ INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO UPDATE SET c3 = ' ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification --Testcase 743: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 744: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) --Testcase 750: ALTER FOREIGN TABLE ft1 RENAME TO ft1_constraint; --Testcase 751: @@ -7362,12 +7365,14 @@ RESET constraint_exclusion; -- check constraint is enforced on the remote side, not locally --Testcase 745: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) --Testcase 746: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive -ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 - sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) --Testcase 817: ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2positive; -- But inconsistent check constraints provide inconsistent results diff --git a/expected/16.0/extra/uuid.out b/expected/16.0/extra/uuid.out index e06558f7..35bf1e87 100644 --- a/expected/16.0/extra/uuid.out +++ b/expected/16.0/extra/uuid.out @@ -523,8 +523,9 @@ SELECT * FROM "type_UUIDpk"; --Testcase 105: ERR - primary key INSERT INTO "type_UUIDpk" VALUES ('{b0eebc99-9c0b4ef8-bb6d6bb9-bd380a12}'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_UUIDpk.col - sql=INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_UUIDpk.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_UUIDpk"(`col`) VALUES (?) --Testcase 106: ALTER FOREIGN TABLE "type_UUIDpk" ALTER COLUMN col OPTIONS (SET column_type 'BLOB'); --Testcase 107: NO ERR, but the same semantics! diff --git a/expected/16.0/sqlite_fdw.out b/expected/16.0/sqlite_fdw.out index 05fee260..cea486ad 100644 --- a/expected/16.0/sqlite_fdw.out +++ b/expected/16.0/sqlite_fdw.out @@ -17,7 +17,7 @@ CREATE FOREIGN TABLE numbers(a int OPTIONS (key 'true'), b varchar(255)) SERVER CREATE FOREIGN TABLE multiprimary(a int, b int OPTIONS (key 'true'), c int OPTIONS(key 'true')) SERVER sqlite_svr; --Testcase 136: CREATE FOREIGN TABLE noprimary(a int, b text) SERVER sqlite_svr; --- updatable option test (github pull 59) +--Testcase 137: CREATE FOREIGN TABLE RO_RW_test(i int OPTIONS (key 'true'), a text, b float, c int) SERVER sqlite_svr; --Testcase 1: SELECT * FROM department LIMIT 10; @@ -575,8 +575,9 @@ SELECT * from numbers; -- duplicate key --Testcase 68: INSERT INTO numbers VALUES(1, 'One'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) --Testcase 69: DELETE from numbers; BEGIN; @@ -588,8 +589,9 @@ COMMIT; -- violate unique constraint --Testcase 72: UPDATE numbers SET b='Two' WHERE a = 1; -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 19 +CONTEXT: SQL query: UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) --Testcase 73: SELECT * from numbers; a | b @@ -1682,27 +1684,43 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -1713,7 +1731,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -1725,7 +1743,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -1736,7 +1754,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -1748,7 +1766,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -1761,7 +1779,7 @@ UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -1770,7 +1788,7 @@ INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -1782,7 +1800,7 @@ ERROR: foreign table "ro_rw_test" does not allow updates --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR ERROR: foreign table "ro_rw_test" does not allow deletes --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -1816,8 +1834,265 @@ ERROR: cannot convert constant value to Sqlite value HINT: Constant value data type: "tsquery" in column "b" --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +----+---+-------+--- + 4 | F | 0.005 | 5 + 10 | P | 4.15 | 1 +(2 rows) + +--Testcase 321: +DELETE FROM RO_RW_test; +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +ERROR: foreign table "ro_rw_test" does not allow inserts +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow updates +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR +ERROR: foreign table "ro_rw_test" does not allow deletes +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; + i | a | b | c +---+---+---+--- +(0 rows) + +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +ERROR: cannot convert constant value to Sqlite value +HINT: Constant value data type: "tsquery" in column "b" +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: diff --git a/expected/16.0/type.out b/expected/16.0/type.out index eb69f1e7..149c87d5 100644 --- a/expected/16.0/type.out +++ b/expected/16.0/type.out @@ -513,8 +513,9 @@ ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; INSERT INTO "type_DOUBLE" VALUES (PI()); --Testcase 109: ERR primary key INSERT INTO "type_DOUBLE" VALUES (PI()); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 110: INSERT INTO "type_DOUBLE" VALUES ('Infinity'); --Testcase 111: @@ -531,12 +532,14 @@ SELECT * FROM "type_DOUBLE"; -- OK, +- Inf --Testcase 114: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 115: ERR primary key INSERT INTO "type_DOUBLE" VALUES ('-Infinity'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: type_DOUBLE.col - sql=INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) +ERROR: Failed to execute remote SQL +HINT: SQLite error 'UNIQUE constraint failed: type_DOUBLE.col', SQLite result code 19 +CONTEXT: SQL query: INSERT INTO main."type_DOUBLE"(`col`) VALUES (?) --Testcase 116: SELECT * FROM "type_DOUBLE"; -- OK, +- Inf col diff --git a/option.c b/option.c index 99c2c999..2672ec15 100644 --- a/option.c +++ b/option.c @@ -43,6 +43,7 @@ static struct SqliteFdwOption valid_options[] = { {"database", ForeignServerRelationId}, {"keep_connections", ForeignServerRelationId}, + {"force_readonly", ForeignServerRelationId}, {"table", ForeignTableRelationId}, {"key", AttributeRelationId}, {"column_name", AttributeRelationId}, @@ -145,7 +146,8 @@ sqlite_fdw_validator(PG_FUNCTION_ARGS) /* Validate option value */ if (strcmp(def->defname, "truncatable") == 0 || strcmp(def->defname, "keep_connections") == 0 || - strcmp(def->defname, "updatable") == 0) + strcmp(def->defname, "updatable") == 0 || + strcmp(def->defname, "force_readonly") == 0) { defGetBoolean(def); } diff --git a/sql/12.16/sqlite_fdw.sql b/sql/12.16/sqlite_fdw.sql index ea2ebc5e..3158a65e 100644 --- a/sql/12.16/sqlite_fdw.sql +++ b/sql/12.16/sqlite_fdw.sql @@ -614,20 +614,37 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false + +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: @@ -635,7 +652,7 @@ UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -646,7 +663,8 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default + +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -656,7 +674,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -668,7 +686,7 @@ UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -678,7 +696,7 @@ UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -692,7 +710,7 @@ DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -702,7 +720,7 @@ UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -712,7 +730,7 @@ UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -738,8 +756,236 @@ INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; + +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); + +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK + +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK + +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK + +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK + +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 321: +DELETE FROM RO_RW_test; + +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); + +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR + +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR + +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR + +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); + +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test + +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); @@ -768,4 +1014,3 @@ DROP FOREIGN TABLE case_exp; DROP SERVER sqlite_svr; --Testcase 152: DROP EXTENSION sqlite_fdw CASCADE; - diff --git a/sql/13.12/sqlite_fdw.sql b/sql/13.12/sqlite_fdw.sql index ea2ebc5e..efd1557e 100644 --- a/sql/13.12/sqlite_fdw.sql +++ b/sql/13.12/sqlite_fdw.sql @@ -17,8 +17,7 @@ CREATE FOREIGN TABLE numbers(a int OPTIONS (key 'true'), b varchar(255)) SERVER CREATE FOREIGN TABLE multiprimary(a int, b int OPTIONS (key 'true'), c int OPTIONS(key 'true')) SERVER sqlite_svr; --Testcase 136: CREATE FOREIGN TABLE noprimary(a int, b text) SERVER sqlite_svr; - --- updatable option test (github pull 59) +--Testcase 137: CREATE FOREIGN TABLE RO_RW_test(i int OPTIONS (key 'true'), a text, b float, c int) SERVER sqlite_svr; --Testcase 1: @@ -614,20 +613,37 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false + +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: @@ -635,7 +651,7 @@ UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -646,7 +662,8 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default + +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -656,7 +673,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -668,7 +685,7 @@ UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -678,7 +695,7 @@ UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -692,7 +709,7 @@ DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -702,7 +719,7 @@ UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -712,7 +729,7 @@ UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -738,8 +755,236 @@ INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; + +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); + +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK + +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK + +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK + +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK + +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 321: +DELETE FROM RO_RW_test; + +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); + +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR + +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR + +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR + +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); + +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test + +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); @@ -768,4 +1013,3 @@ DROP FOREIGN TABLE case_exp; DROP SERVER sqlite_svr; --Testcase 152: DROP EXTENSION sqlite_fdw CASCADE; - diff --git a/sql/14.9/sqlite_fdw.sql b/sql/14.9/sqlite_fdw.sql index eac0b891..45d2054c 100644 --- a/sql/14.9/sqlite_fdw.sql +++ b/sql/14.9/sqlite_fdw.sql @@ -18,7 +18,7 @@ CREATE FOREIGN TABLE multiprimary(a int, b int OPTIONS (key 'true'), c int OPTIO --Testcase 136: CREATE FOREIGN TABLE noprimary(a int, b text) SERVER sqlite_svr; --- updatable option test (github pull 59) +-- readonly/readwrite test github pull 59 CREATE FOREIGN TABLE RO_RW_test(i int OPTIONS (key 'true'), a text, b float, c int) SERVER sqlite_svr; --Testcase 1: @@ -633,20 +633,37 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false + +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: @@ -654,7 +671,7 @@ UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -665,7 +682,8 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default + +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -675,7 +693,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -687,7 +705,7 @@ UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -697,7 +715,7 @@ UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -711,7 +729,7 @@ DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -721,7 +739,7 @@ UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -731,7 +749,7 @@ UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -757,8 +775,236 @@ INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; + +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); + +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK + +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK + +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK + +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK + +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 321: +DELETE FROM RO_RW_test; + +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); + +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR + +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR + +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR + +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); + +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test + +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); diff --git a/sql/15.4/sqlite_fdw.sql b/sql/15.4/sqlite_fdw.sql index 3cfa14d9..9edf92aa 100644 --- a/sql/15.4/sqlite_fdw.sql +++ b/sql/15.4/sqlite_fdw.sql @@ -633,20 +633,37 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false + +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: @@ -654,7 +671,7 @@ UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -665,7 +682,8 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default + +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -675,7 +693,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -687,7 +705,7 @@ UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -697,7 +715,7 @@ UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -711,7 +729,7 @@ DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -721,7 +739,7 @@ UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -731,7 +749,7 @@ UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -757,8 +775,236 @@ INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; + +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); + +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK + +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK + +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK + +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK + +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 321: +DELETE FROM RO_RW_test; + +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); + +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR + +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR + +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR + +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); + +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test + +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); @@ -791,4 +1037,3 @@ DROP FOREIGN TABLE case_exp; DROP SERVER sqlite_svr; --Testcase 152: DROP EXTENSION sqlite_fdw CASCADE; - diff --git a/sql/16.0/sqlite_fdw.sql b/sql/16.0/sqlite_fdw.sql index eac0b891..e6219353 100644 --- a/sql/16.0/sqlite_fdw.sql +++ b/sql/16.0/sqlite_fdw.sql @@ -17,8 +17,7 @@ CREATE FOREIGN TABLE numbers(a int OPTIONS (key 'true'), b varchar(255)) SERVER CREATE FOREIGN TABLE multiprimary(a int, b int OPTIONS (key 'true'), c int OPTIONS(key 'true')) SERVER sqlite_svr; --Testcase 136: CREATE FOREIGN TABLE noprimary(a int, b text) SERVER sqlite_svr; - --- updatable option test (github pull 59) +--Testcase 137: CREATE FOREIGN TABLE RO_RW_test(i int OPTIONS (key 'true'), a text, b float, c int) SERVER sqlite_svr; --Testcase 1: @@ -633,20 +632,37 @@ SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'ba --Testcase 234: DELETE FROM case_exp; --- updatable option test (github pull 59) +-- readonly/readwrite tests -- Full combinations --- D-default, T-true, F-false --- sD+tD - sT+tD - sF+tD - sD+tT - sD+tF - sT+tT - sF+tT - sF+tF - sT+tF --- SERVER default TABLE default --- SERVER true TABLE default --- SERVER false TABLE default --- SERVER default TABLE true --- SERVER default TABLE false --- SERVER true TABLE true --- SERVER false TABLE true --- SERVER false TABLE false --- SERVER true TABLE false --- SERVER default TABLE default +-- force_RO default SERVER default TABLE default +-- force_RO default SERVER true TABLE default +-- force_RO default SERVER false TABLE default +-- force_RO default SERVER default TABLE true +-- force_RO default SERVER default TABLE false +-- force_RO default SERVER true TABLE true +-- force_RO default SERVER false TABLE true +-- force_RO default SERVER false TABLE false +-- force_RO default SERVER true TABLE false +-- force_RO false SERVER default TABLE default +-- force_RO false SERVER true TABLE default +-- force_RO false SERVER false TABLE default +-- force_RO false SERVER default TABLE true +-- force_RO false SERVER default TABLE false +-- force_RO false SERVER true TABLE true +-- force_RO false SERVER false TABLE true +-- force_RO false SERVER false TABLE false +-- force_RO false SERVER true TABLE false +-- force_RO true SERVER default TABLE default +-- force_RO true SERVER true TABLE default +-- force_RO true SERVER false TABLE default +-- force_RO true SERVER default TABLE true +-- force_RO true SERVER default TABLE false +-- force_RO true SERVER true TABLE true +-- force_RO true SERVER false TABLE true +-- force_RO true SERVER false TABLE false +-- force_RO true SERVER true TABLE false + +-- force_RO default SERVER default TABLE default --Testcase 235: INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK --Testcase 236: @@ -654,7 +670,7 @@ UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK --Testcase 237: DELETE FROM RO_RW_test WHERE i=2; -- OK --- SERVER true TABLE default +-- force_RO default SERVER true TABLE default --Testcase 238: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 239: @@ -665,7 +681,8 @@ UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK DELETE FROM RO_RW_test WHERE i=3; -- OK --Testcase 242: INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK --- SERVER false TABLE default + +-- force_RO default SERVER false TABLE default --Testcase 243: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 244: @@ -675,7 +692,7 @@ UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR --Testcase 246: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER default TABLE true +-- force_RO default SERVER default TABLE true --Testcase 247: ALTER SERVER sqlite_svr OPTIONS (DROP updatable); --Testcase 248: @@ -687,7 +704,7 @@ UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK --Testcase 251: DELETE FROM RO_RW_test WHERE i=6; -- OK --- SERVER default TABLE false +-- force_RO default SERVER default TABLE false --Testcase 252: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 253: @@ -697,7 +714,7 @@ UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR --Testcase 255: DELETE FROM RO_RW_test WHERE i=4; -- ERR --- SERVER true TABLE true +-- force_RO default SERVER true TABLE true --Testcase 256: ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); --Testcase 257: @@ -711,7 +728,7 @@ DELETE FROM RO_RW_test WHERE i=8; -- OK --Testcase 261: INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK --- SERVER false TABLE true +-- force_RO default SERVER false TABLE true --Testcase 262: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); --Testcase 263: @@ -721,7 +738,7 @@ UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK --Testcase 265: DELETE FROM RO_RW_test WHERE i=9; -- OK --- SERVER false TABLE false +-- force_RO default SERVER false TABLE false --Testcase 266: ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); --Testcase 267: @@ -731,7 +748,7 @@ UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR --Testcase 269: DELETE FROM RO_RW_test WHERE i=9; -- ERR --- SERVER true TABLE false +-- force_RO default SERVER true TABLE false --Testcase 270: ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); --Testcase 271: @@ -757,8 +774,236 @@ INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); --Testcase 279: ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --- updatable option test (github pull 59) +--Testcase 277: +DELETE FROM RO_RW_test; + +--Testcase 278: +ALTER SERVER sqlite_svr OPTIONS (ADD force_readonly 'false'); + +-- force_RO false SERVER default TABLE default +--Testcase 279: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- OK +--Testcase 280: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- OK +--Testcase 281: +DELETE FROM RO_RW_test WHERE i=2; -- OK + +-- force_RO false SERVER true TABLE default +--Testcase 282: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 283: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- OK +--Testcase 284: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- OK +--Testcase 285: +DELETE FROM RO_RW_test WHERE i=3; -- OK +--Testcase 286: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- OK +-- force_RO false SERVER false TABLE default +--Testcase 287: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 288: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 289: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 290: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER default TABLE true +--Testcase 291: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 292: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 293: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- OK +--Testcase 294: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- OK +--Testcase 295: +DELETE FROM RO_RW_test WHERE i=6; -- OK + +-- force_RO false SERVER default TABLE false +--Testcase 296: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 297: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 298: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 299: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO false SERVER true TABLE true +--Testcase 300: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 301: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); +--Testcase 302: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- OK +--Testcase 303: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 304: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 305: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- OK + +-- force_RO false SERVER false TABLE true +--Testcase 306: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 307: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- OK +--Testcase 308: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- OK +--Testcase 309: +DELETE FROM RO_RW_test WHERE i=9; -- OK + +-- force_RO false SERVER false TABLE false +--Testcase 310: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 311: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 312: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 313: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO false SERVER true TABLE false +--Testcase 314: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 315: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 316: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 317: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 318: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 319: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 320: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 321: +DELETE FROM RO_RW_test; + +--Testcase 322: +ALTER SERVER sqlite_svr OPTIONS (SET force_readonly 'true'); + +-- force_RO true SERVER default TABLE default +--Testcase 323: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (2, 'B', 3.01, 1); -- ERR +--Testcase 324: +UPDATE RO_RW_test SET a='C' WHERE i=2; -- ERR +--Testcase 325: +DELETE FROM RO_RW_test WHERE i=2; -- ERR + +-- force_RO true SERVER true TABLE default +--Testcase 326: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); +--Testcase 327: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (3, 'D', 5.02, 8); -- ERR +--Testcase 328: +UPDATE RO_RW_test SET a='E' WHERE i=3; -- ERR +--Testcase 329: +DELETE FROM RO_RW_test WHERE i=3; -- ERR +--Testcase 330: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (4, 'F', 0.005, 5); -- ERR +-- force_RO true SERVER false TABLE default +--Testcase 331: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 332: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (5, 'H', 0.03, 7); -- ERR +--Testcase 333: +UPDATE RO_RW_test SET a='E' WHERE i=4; -- ERR +--Testcase 334: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER default TABLE true +--Testcase 335: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 336: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (ADD updatable 'true'); +--Testcase 337: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (6, 'I', 1.403, 2); -- ERR +--Testcase 338: +UPDATE RO_RW_test SET a='J' WHERE i=6; -- ERR +--Testcase 339: +DELETE FROM RO_RW_test WHERE i=6; -- ERR + +-- force_RO true SERVER default TABLE false +--Testcase 340: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 341: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (7, 'K', 2.01, 4); -- ERR +--Testcase 342: +UPDATE RO_RW_test SET a='L' WHERE i=4; -- ERR +--Testcase 343: +DELETE FROM RO_RW_test WHERE i=4; -- ERR + +-- force_RO true SERVER true TABLE true +--Testcase 344: +ALTER SERVER sqlite_svr OPTIONS (ADD updatable 'true'); -- ERR +--Testcase 345: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'true'); -- ERR +--Testcase 346: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (8, 'M', 5.02, 8); -- ERR +--Testcase 347: +UPDATE RO_RW_test SET a='N' WHERE i=8; -- OK +--Testcase 348: +DELETE FROM RO_RW_test WHERE i=8; -- OK +--Testcase 349: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (9, 'O', 3.21, 9); -- ERR + +-- force_RO true SERVER false TABLE true +--Testcase 350: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'false'); +--Testcase 351: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (10, 'P', 4.15, 1); -- ERR +--Testcase 352: +UPDATE RO_RW_test SET a='Q' WHERE i=9; -- ERR +--Testcase 353: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER false TABLE false +--Testcase 354: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (SET updatable 'false'); +--Testcase 355: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (11, 'Q', 2.27, 5); -- ERR +--Testcase 356: +UPDATE RO_RW_test SET a='S' WHERE i=9; -- ERR +--Testcase 357: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +-- force_RO true SERVER true TABLE false +--Testcase 358: +ALTER SERVER sqlite_svr OPTIONS (SET updatable 'true'); +--Testcase 359: +INSERT INTO RO_RW_test (i, a, b, c) VALUES (12, 'R', 6.18, 11); -- ERR +--Testcase 360: +UPDATE RO_RW_test SET a='T' WHERE i=9; -- ERR +--Testcase 361: +DELETE FROM RO_RW_test WHERE i=9; -- ERR + +--Testcase 362: +ALTER SERVER sqlite_svr OPTIONS (DROP updatable); +--Testcase 363: +ALTER FOREIGN TABLE RO_RW_test OPTIONS (DROP updatable); + +--Testcase 364: +ALTER SERVER sqlite_svr OPTIONS (DROP force_readonly); + +--Testcase 365: +SELECT * FROM RO_RW_test ORDER BY i; +--Testcase 366: DROP FOREIGN TABLE RO_RW_test; +-- End of RO/RW test + +--Bind error message test for some unsupported data type +--Testcase 366: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE tsquery; +--Testcase 367: +INSERT INTO numbers VALUES(8,'fat & (rat | cat)'); +--Testcase 368: +ALTER FOREIGN TABLE numbers ALTER COLUMN b TYPE varchar(255); --Testcase 142: DROP FUNCTION test_param_WHERE(); diff --git a/sql/init_data/init.sql b/sql/init_data/init.sql index c1c93a80..2498862a 100644 --- a/sql/init_data/init.sql +++ b/sql/init_data/init.sql @@ -60,7 +60,7 @@ CREATE TABLE "A a" (col int primary key); -- test for issue #44 github CREATE VIRTUAL TABLE fts_table USING fts5(name, description, tokenize = porter); --- updatable option test (github pull 59) +-- github.com/pull/59 CREATE TABLE RO_RW_test ( i int primary key not null, a text, diff --git a/sql/init_data/init_core.sql b/sql/init_data/init_core.sql index 5e20da74..ca5e8f14 100644 --- a/sql/init_data/init_core.sql +++ b/sql/init_data/init_core.sql @@ -431,7 +431,6 @@ CREATE TABLE update_test ( ); create table upsert_test (a int primary key, b text); - create table t (a int unique); CREATE TABLE "type_FLOAT_INF" (i int primary key, f float); diff --git a/sqlite_fdw--1.0--1.1.sql b/sqlite_fdw--1.0--1.1.sql index 7d606565..0ab38ec5 100644 --- a/sqlite_fdw--1.0--1.1.sql +++ b/sqlite_fdw--1.0--1.1.sql @@ -14,7 +14,22 @@ RETURNS bool AS 'MODULE_PATHNAME' LANGUAGE C STRICT PARALLEL RESTRICTED; +COMMENT ON FUNCTION sqlite_fdw_disconnect(text) +IS 'closes a SQLite connection by name of FOREIGN SERVER'; + CREATE FUNCTION sqlite_fdw_disconnect_all () RETURNS bool AS 'MODULE_PATHNAME' LANGUAGE C STRICT PARALLEL RESTRICTED; + +COMMENT ON FUNCTION sqlite_fdw_disconnect_all() +IS 'closes all opened SQLite connections'; + +COMMENT ON FUNCTION sqlite_fdw_handler() +IS 'SQLite foreign data wrapper handler'; + +COMMENT ON FUNCTION sqlite_fdw_validator(text[], oid) +IS 'SQLite foreign data wrapper options validator'; + +COMMENT ON FOREIGN DATA WRAPPER sqlite_fdw +IS 'SQLite foreign data wrapper'; diff --git a/sqlite_fdw.c b/sqlite_fdw.c index fa60c408..1a3fc760 100644 --- a/sqlite_fdw.c +++ b/sqlite_fdw.c @@ -5673,14 +5673,18 @@ static int sqliteIsForeignRelUpdatable(Relation rel) { bool updatable; + bool readonly_db_file; ForeignTable *table; ForeignServer *server; ListCell *lc; /* * By default, all sqlite_fdw foreign tables are assumed updatable. + * If force_readonly option is set, foreign server option 'updatable' + * is ignored, table option 'updatable' is also ignored */ updatable = true; + readonly_db_file = false; table = GetForeignTable(RelationGetRelid(rel)); server = GetForeignServer(table->serverid); @@ -5688,16 +5692,22 @@ sqliteIsForeignRelUpdatable(Relation rel) foreach(lc, server->options) { DefElem *def = (DefElem *) lfirst(lc); - - if (strcmp(def->defname, "updatable") == 0) + if (strcmp(def->defname, "force_readonly") == 0) + readonly_db_file = defGetBoolean(def); + else if (strcmp(def->defname, "updatable") == 0) updatable = defGetBoolean(def); } - foreach(lc, table->options) + if (readonly_db_file) + updatable = false; + else { - DefElem *def = (DefElem *) lfirst(lc); + foreach(lc, table->options) + { + DefElem *def = (DefElem *) lfirst(lc); - if (strcmp(def->defname, "updatable") == 0) - updatable = defGetBoolean(def); + if (strcmp(def->defname, "updatable") == 0) + updatable = defGetBoolean(def); + } } /*