Skip to content

Commit 9ec7b00

Browse files
committed
Initial RETURNING implementation
1 parent af42d07 commit 9ec7b00

File tree

25 files changed

+9679
-446
lines changed

25 files changed

+9679
-446
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ EXTENSION = sqlite_fdw
1616
DATA = sqlite_fdw--1.0.sql sqlite_fdw--1.0--1.1.sql
1717

1818
ifndef REGRESS
19-
REGRESS = extra/sqlite_fdw_post types/bitstring types/bool types/float4 types/float8 types/int4 types/int8 types/numeric types/macaddr types/macaddr8 types/out_of_range types/timestamp types/uuid extra/join extra/limit extra/aggregates extra/prepare extra/select_having extra/select extra/insert extra/update extra/encodings sqlite_fdw type aggregate selectfunc
19+
REGRESS = extra/sqlite_fdw_post types/bitstring types/bool types/float4 types/float8 types/int4 types/int8 types/numeric types/macaddr types/macaddr8 types/out_of_range types/timestamp types/uuid extra/join extra/limit extra/aggregates extra/prepare extra/select_having extra/select extra/insert extra/update extra/encodings sqlite_fdw type aggregate selectfunc extra/returning
2020
endif
2121

2222
REGRESS_OPTS = --encoding=utf8

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ Features
2929
### Common features
3030
- Transactions
3131
- 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.
32+
- Support `RETURNING` for `INSERT`/`UPDATE`/`DELETE`.
3233
- Support `TRUNCATE` by deparsing into `DELETE` statement without `WHERE` clause.
3334
- Allow control over whether foreign servers keep connections open after transaction completion. This is controlled by `keep_connections` and defaults to on.
3435
- Support list cached connections to foreign servers by using function `sqlite_fdw_get_connections()`
3536
- Support discard cached connections to foreign servers by using function `sqlite_fdw_disconnect()`, `sqlite_fdw_disconnect_all()`.
3637
- Support Bulk `INSERT` by using `batch_size` option
3738
- Support `INSERT`/`UPDATE` with generated column
38-
- Support `ON CONFLICT DO NOTHING`
39+
- Support `INSERT` ... `ON CONFLICT DO NOTHING`
40+
- Support `WITH CHECK OPTION` views after a foreign table
3941
- Support mixed SQLite [data affinity](https://www.sqlite.org/datatype3.html) input and filtering (`SELECT`/`WHERE` usage) for such data types as
4042
- `timestamp`: `text` and `int`,
4143
- `uuid`: `text`(32..39) and `blob`(16),
@@ -52,7 +54,8 @@ Features
5254

5355
### Pushdowning
5456
- `WHERE` clauses are pushdowned
55-
- Aggregate function are pushdowned
57+
- `RETURNING` clauses are pushdowned
58+
- Some aggregate functions are pushdowned
5659
- `ORDER BY` is pushdowned
5760
- Joins (left/right/inner/cross/semi) are pushdowned
5861
- `CASE` expressions are pushdowned.
@@ -666,6 +669,13 @@ funct_name (type arg ...)
666669
}
667670
}
668671
```
672+
673+
To debug, you need to build PostgreSQL in debug mode. Use the following options.
674+
```bash
675+
./configure --prefix=<path_to_postgresql_build_folder> --enable-cassert --enable-debug CFLAGS="-ggdb -O0 -g3 -fno-omit-frame-pointer"
676+
```
677+
Also please refer https://wiki.postgresql.org/wiki/Developer_FAQ#What_debugging_features_are_available.3F
678+
669679
Useful links
670680
------------
671681

connection.c

Lines changed: 7 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,8 +390,8 @@ sqlite_begin_remote_xact(ConnCacheEntry *entry)
389390
}
390391
}
391392

392-
393393
/*
394+
* sqlitefdw_report_error
394395
* Report an sqlite execution error
395396
*/
396397
void
@@ -400,7 +401,7 @@ sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn,
400401
const char *message = sqlite3_errmsg(conn);
401402
int sqlstate = ERRCODE_FDW_ERROR;
402403

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

@@ -418,9 +419,9 @@ sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn,
418419
));
419420
}
420421

421-
422422
/*
423-
* sqlitefdw_xact_callback --- cleanup at main-transaction end.
423+
* sqlitefdw_xact_callback
424+
* cleanup at main-transaction end.
424425
*/
425426
static void
426427
sqlitefdw_xact_callback(XactEvent event, void *arg)
@@ -1038,7 +1039,7 @@ sqlite_cache_stmt(ForeignServer *server, sqlite3_stmt * *stmt)
10381039
}
10391040

10401041
/*
1041-
* finalize all sqlite statement
1042+
* finalize all SQLite statement
10421043
*/
10431044
static void
10441045
sqlite_finalize_list_stmt(List **list)

0 commit comments

Comments
 (0)