Skip to content

Commit cd3eaf6

Browse files
committed
Initial RETURNING implementation
1 parent ea52a24 commit cd3eaf6

File tree

20 files changed

+10294
-416
lines changed

20 files changed

+10294
-416
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ GIS_DEP_TESTS = $(GIS_DEP_TESTS_DIR)/type $(GIS_DEP_TESTS_DIR)/auto_import $(GIS
3333

3434
ifndef REGRESS
3535
# System tests, full default sequence
36-
REGRESS = libsqlite extra/sqlite_fdw_post $(DATA_TYPE_TESTS) extra/join extra/limit extra/aggregates extra/prepare extra/select_having extra/select extra/insert extra/update extra/encodings sqlite_fdw aggregate selectfunc $(GIS_DEP_TESTS)
36+
REGRESS = libsqlite extra/sqlite_fdw_post $(DATA_TYPE_TESTS) extra/join extra/limit extra/aggregates extra/prepare extra/select_having extra/select extra/insert extra/update extra/encodings sqlite_fdw aggregate selectfunc extra/returning $(GIS_DEP_TESTS)
3737
endif
3838

3939
# Other encodings also are tested. Client encoding should be UTF-8.

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ Features
3535
### Common features
3636
- Transactions
3737
- 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.
38+
- Support `RETURNING` for `INSERT`/`UPDATE`/`DELETE`.
3839
- Support `TRUNCATE` by deparsing into `DELETE` statement without `WHERE` clause.
3940
- Allow control over whether foreign servers keep connections open after transaction completion. This is controlled by `keep_connections` and defaults to on.
4041
- Support list cached connections to foreign servers by using function `sqlite_fdw_get_connections()`
4142
- Support discard cached connections to foreign servers by using function `sqlite_fdw_disconnect()`, `sqlite_fdw_disconnect_all()`.
4243
- Support Bulk `INSERT` by using `batch_size` option
4344
- Support `INSERT`/`UPDATE` with generated column
44-
- Support `ON CONFLICT DO NOTHING`
45+
- Support `INSERT` ... `ON CONFLICT DO NOTHING`
46+
- Support `WITH CHECK OPTION` views after a foreign table
4547
- Support mixed SQLite [data affinity](https://www.sqlite.org/datatype3.html) input and filtering (`SELECT`/`WHERE` usage) for such data types as
4648
- `timestamp`: `text` and `int`,
4749
- `uuid`: `text`(32..39) and `blob`(16),
@@ -60,7 +62,8 @@ Features
6062

6163
### Pushing down
6264
- `WHERE` clauses are pushdowned
63-
- Aggregate function are pushdowned
65+
- `RETURNING` clauses are pushdowned
66+
- Some aggregate functions are pushdowned
6467
- `ORDER BY` is pushdowned
6568
- Joins (left/right/inner/cross/semi) are pushdowned
6669
- `CASE` expressions are pushdowned.
@@ -744,6 +747,13 @@ funct_name (type arg ...)
744747
}
745748
}
746749
```
750+
751+
To debug, you need to build PostgreSQL in debug mode. Use the following options.
752+
```bash
753+
./configure --prefix=<path_to_postgresql_build_folder> --enable-cassert --enable-debug CFLAGS="-ggdb -O0 -g3 -fno-omit-frame-pointer"
754+
```
755+
Also please refer https://wiki.postgresql.org/wiki/Developer_FAQ#What_debugging_features_are_available.3F
756+
747757
Useful links
748758
------------
749759

connection.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ sqlite_get_connection(ForeignServer *server, bool truncatable)
184184
}
185185

186186
/*
187+
* sqlite_open_db
187188
* Open remote sqlite database using specified database path
188189
* and flags of opened file descriptor mode.
189190
*/
@@ -230,7 +231,7 @@ sqlite_make_new_connection(ConnCacheEntry *entry, ForeignServer *server)
230231
{
231232
const char *dbpath = NULL;
232233
ListCell *lc;
233-
int flags = 0;
234+
int flags = 0;
234235

235236
Assert(entry->conn == NULL);
236237

@@ -389,9 +390,9 @@ sqlite_begin_remote_xact(ConnCacheEntry *entry)
389390
}
390391
}
391392

392-
393393
/*
394-
* Report an SQLite execution error.
394+
* sqlitefdw_report_error
395+
* Report an sqlite execution error
395396
*/
396397
void
397398
sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn,
@@ -401,7 +402,7 @@ sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn,
401402
int erc = sqlite3_extended_errcode(conn);
402403
int sqlstate = ERRCODE_FDW_ERROR;
403404

404-
/* copy sql before callling another SQLite API */
405+
/* copy sql before calling another SQLite API */
405406
if (message)
406407
message = pstrdup(message);
407408

@@ -420,7 +421,8 @@ sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn,
420421
}
421422

422423
/*
423-
* sqlitefdw_xact_callback --- cleanup at main-transaction end.
424+
* sqlitefdw_xact_callback
425+
* cleanup at main-transaction end.
424426
*/
425427
static void
426428
sqlitefdw_xact_callback(XactEvent event, void *arg)
@@ -1038,7 +1040,7 @@ sqlite_cache_stmt(ForeignServer *server, sqlite3_stmt * *stmt)
10381040
}
10391041

10401042
/*
1041-
* finalize all sqlite statement
1043+
* finalize all SQLite statement
10421044
*/
10431045
static void
10441046
sqlite_finalize_list_stmt(List **list)

0 commit comments

Comments
 (0)