Skip to content

Commit 7c03bcd

Browse files
committed
Initial RETURNING implementation
1 parent fe112d6 commit 7c03bcd

30 files changed

+10347
-444
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GISTEST=nogis
2323
endif
2424

2525
ifndef REGRESS
26-
REGRESS = extra/sqlite_fdw_post types/bitstring types/bool types/float4 types/float8 types/int4 types/int8 types/numeric types/$(GISTEST) 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_$(GISTEST) aggregate selectfunc
26+
REGRESS = extra/sqlite_fdw_post types/bitstring types/bool types/float4 types/float8 types/int4 types/int8 types/numeric types/$(GISTEST) 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_$(GISTEST) aggregate selectfunc extra/returning
2727
endif
2828

2929
REGRESS_OPTS = --encoding=utf8

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),
@@ -59,7 +61,8 @@ Features
5961

6062
### Pushing down
6163
- `WHERE` clauses are pushdowned
62-
- Aggregate function are pushdowned
64+
- `RETURNING` clauses are pushdowned
65+
- Some aggregate functions are pushdowned
6366
- `ORDER BY` is pushdowned
6467
- Joins (left/right/inner/cross/semi) are pushdowned
6568
- `CASE` expressions are pushdowned.
@@ -700,6 +703,13 @@ funct_name (type arg ...)
700703
}
701704
}
702705
```
706+
707+
To debug, you need to build PostgreSQL in debug mode. Use the following options.
708+
```bash
709+
./configure --prefix=<path_to_postgresql_build_folder> --enable-cassert --enable-debug CFLAGS="-ggdb -O0 -g3 -fno-omit-frame-pointer"
710+
```
711+
Also please refer https://wiki.postgresql.org/wiki/Developer_FAQ#What_debugging_features_are_available.3F
712+
703713
Useful links
704714
------------
705715

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)