You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-15Lines changed: 35 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,14 @@ Features
35
35
- Support discard cached connections to foreign servers by using function `sqlite_fdw_disconnect()`, `sqlite_fdw_disconnect_all()`.
36
36
- Support Bulk `INSERT` by using `batch_size` option
37
37
- Support `INSERT`/`UPDATE` with generated column
38
-
- Support `ON CONFLICT DO NOTHING`.
38
+
- Support `ON CONFLICT DO NOTHING`
39
+
- Support mixed SQLite [data affinity](https://www.sqlite.org/datatype3.html) input and filtering (`SELECT`/`WHERE` usage) for such dataypes as
40
+
- `timestamp`: `text` and `int`,
41
+
- `uuid`: `text`(32..39) and `blob`(16),
42
+
- `bool`: `text`(1..5) and `int`.
43
+
- Support mixed SQLite [data affinity](https://www.sqlite.org/datatype3.html) output (`INSERT`/`UPDATE`) for such dataypes as
44
+
- `timestamp`: `text`(default) or `int`,
45
+
- `uuid`: `text`(36) or `blob`(16)(default).
39
46
40
47
### Pushdowning
41
48
-`WHERE` clauses are pushdowned
@@ -62,6 +69,7 @@ Features
62
69
- 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.
63
70
-`sqlite_fdw` can return implementation-dependent order for column if the column is not specified in `ORDER BY` clause.
64
71
- 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.
72
+
-[String literals for `boolean`](https://www.postgresql.org/docs/current/datatype-boolean.html) (`t`, `f`, `y`, `n`, `yes`, `no`, `on`, `off` etc. case insensetive) can be readed and filtred but cannot writed, because SQLite documentation recommends only `int` affinity values (`0` or `1`) for boolean data and usually text boolean data belongs to legacy datasets.
65
73
66
74
Also see [Limitations](#limitations)
67
75
@@ -122,7 +130,6 @@ This table represents `sqlite_fdw` behaviour if in PostgreSQL foreign table colu
122
130
123
131
***∅** - no support (runtime error)
124
132
***V** - transparent transformation
125
-
***b** - show per-bit form
126
133
***T** - cast to text in SQLite utf-8 encoding, then to **PostgreSQL text with current encoding of database** and then transparent transformation if applicable
127
134
***✔** - transparent transformation where PostgreSQL datatype is equal to SQLite affinity
128
135
***V+** - transparent transformation if appliacable
@@ -133,14 +140,14 @@ SQLite `NULL` affinity always can be transparent converted for a nullable column
133
140
134
141
| PostgreSQL | SQLite <br> INT | SQLite <br> REAL | SQLite <br> BLOB | SQLite <br> TEXT | SQLite <br> TEXT but <br>empty|SQLite<br>nearest<br>affinity|
@@ -216,10 +223,11 @@ In OS `sqlite_fdw` works as executed code with permissions of user of PostgreSQL
216
223
217
224
-**column_type** as *string*, optional, no default
218
225
219
-
Gives preferred SQLite affinity for some PostgreSQL data types can be stored in different ways in SQLite. Default preferred SQLite affinity for this types is `text`.
226
+
Set preferred SQLite affinity for some PostgreSQL data types can be stored in different ways
227
+
in SQLite (mixed affinity case). Updated and inserted values will have this affinity. Default preferred SQLite affinity for `timestamp` and `uuid` PostgreSQL data types is `text`.
220
228
221
229
- Use `INT` value for SQLite column (epoch Unix Time) to be treated/visualized as `timestamp` in PostgreSQL.
222
-
- Use `BLOB` value for SQLite column to be treated/visualized as `uuid` in PostgreSQL.
230
+
- Use `BLOB` value for SQLite column to be treated/visualized as `uuid` in PostgreSQL 14+.
223
231
224
232
-**key** as *boolean*, optional, default *false*
225
233
@@ -305,7 +313,7 @@ Following SQL isn't correct for SQLite: `Error: duplicate column name: a`, but i
305
313
);
306
314
```
307
315
Following SQLs is correct for both SQLite and PostgreSQL because there is no column
308
-
names with ASCII base latin letters *only*.
316
+
with names composed from ASCII base latin letters *only*.
309
317
310
318
```sql
311
319
CREATETABLET_кир (
@@ -331,6 +339,19 @@ For SQLite there is no difference between
331
339
SELECT*FROM"T"; -- №4
332
340
```
333
341
For PostgreSQL the query with comment `№4` is independend query to table `T`, not to table `t` as other queries.
342
+
Please note this table name composed from ASCII base latin letters *only*. This is not applicable for other
343
+
alphabet systems or mixed names. This is because `toLower` operation in PostgreSQL is Unicode opration but
344
+
ASCII only operation in SQLite, hence other characters will not be changed.
345
+
346
+
```sql
347
+
SELECT*FROM т; -- №5
348
+
SELECT*FROM Т; -- №6
349
+
SELECT*FROM"т"; -- №7
350
+
SELECT*FROM"Т"; -- №8
351
+
```
352
+
In this case for PostgreSQL the query with comment `№8` is independend query to table `Т`, not to table `т`
353
+
as other queries. But for SQLite the queries with comments `№6` and `№8` belongs to table `Т`, and the queries with
354
+
comments `№5` and `№7` belongs to table `т`.
334
355
335
356
If there is
336
357
@@ -521,7 +542,7 @@ Limitations
521
542
### UUID values
522
543
-`sqlite_fdw` UUID values support exists only for `uuid` columns in foreign table. SQLite documentation recommends to store UUID as value with both `blob` and `text`[affinity](https://www.sqlite.org/datatype3.html). `sqlite_fdw` can pushdown both reading and filtering both `text` and `blob` values.
523
544
- Expected affinity of UUID value in SQLite table determined by `column_type` option of the column
524
-
for `INSERT` and `UPDATE` commands.
545
+
for `INSERT` and `UPDATE` commands. In PostgreSQL 14- only `text` data affinity is availlable, PostgreSQL 14+ supports also `blob` data affinity.
525
546
526
547
### bit and varbit support
527
548
-`sqlite_fdw` PostgreSQL `bit`/`varbit` values support based on `int` SQLite data affinity, because there is no per bit operations for SQLite `blob` affinity data. Maximum SQLite `int` affinity value is 8 bytes length, hence maximum `bit`/`varbit` values length is 64 bits.
Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
0 commit comments