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
+109-3
Original file line number
Diff line number
Diff line change
@@ -49,18 +49,20 @@ Features
49
49
- `double precision`, `float` and `numeric`: `real` values and special values with `text` affinity (`+Infinity`, `-Infinity`, `NaN`),
50
50
- `macaddr`: `text`(12..17) or `blob`(6) or `integer`,
51
51
- `macaddr8`: `text`(16..23) or `blob`(8) or `integer`,
52
-
- `json`: `text`(default) or `blob` as SQLite `jsonb` object.
52
+
- `json`: `text`(default) or `blob` as SQLite `jsonb` object,
53
+
- `inet`: `text`(8..49) or `blob`(4..5 IP v4, 16..17 IP v6) or `integer` (IP v4).
53
54
- Support mixed SQLite [data affinity](https://www.sqlite.org/datatype3.html) output (`INSERT`/`UPDATE`) for such data types as
54
55
- `timestamp`: `text`(default) or `int`,
55
56
- `uuid`: `text`(36) or `blob`(16)(default),
56
57
- `macaddr`: `text`(17) or `blob`(6) or `integer`(default),
57
-
- `macaddr8`: `text`(23) or `blob`(8) or `integer`(default).
58
+
- `macaddr8`: `text`(23) or `blob`(8) or `integer`(default),
59
+
- `inet`: `integer` (default for IP v4) or `blob`(4..5 IP v4, 16..17 default for IP v6) or `text`(8..49).
58
60
- Full support for `+Infinity` (means ∞) and `-Infinity` (means -∞) special values for IEEE 754-2008 numbers in `double precision`, `float` and `numeric` columns including such conditions as ` n < '+Infinity'` or ` m > '-Infinity'`.
59
61
- Bidirectional data transformation for `geometry` and `geography` data types for SpatiaLite ↔ PostGIS. [EWKB](https://libgeos.org/specifications/wkb/#extended-wkb) data transport is used. See [GIS support description](GIS.md).
60
62
61
63
### Pushing down
62
64
-`WHERE` clauses are pushdowned
63
-
- Aggregate function are pushdowned
65
+
- Aggregate functions are pushdowned
64
66
-`ORDER BY` is pushdowned
65
67
- Joins (left/right/inner/cross/semi) are pushdowned
66
68
-`CASE` expressions are pushdowned.
@@ -267,6 +269,7 @@ SQLite `NULL` affinity always can be transparent converted for a nullable column
@@ -641,6 +644,17 @@ Array support is experimental. Please be careful.
641
644
-`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.
642
645
- Expected affinity of UUID value in SQLite table determined by `column_type` option of the column
643
646
for `INSERT` and `UPDATE` commands. PostgreSQL supports both `blob` and `text`[affinity](https://www.sqlite.org/datatype3.html).
647
+
- Usual form of UUID from a value with `blob` affinity can be generated with such SQLite query as
648
+
```sql
649
+
select case when typeof(u) ='blob' then
650
+
substr(lower(hex(u)),1,8) ||'-'||
651
+
substr(lower(hex(u)),9,4) ||'-'||
652
+
substr(lower(hex(u)),13,4) ||'-'||
653
+
substr(lower(hex(u)),17,4) ||'-'||
654
+
substr(lower(hex(u)),21,12)
655
+
else null end uuid_canon
656
+
from"type_UUID";
657
+
```
644
658
645
659
### bit and varbit support
646
660
-`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.
@@ -649,6 +663,98 @@ for `INSERT` and `UPDATE` commands. PostgreSQL supports both `blob` and `text` [
649
663
### MAC address support
650
664
-`sqlite_fdw` PostgreSQL `macaddr`/`macaddr8` values support based on `int` SQLite data affinity, because there is no per bit operations for SQLite `blob` affinity data. For `macaddr` out of range error is possible because this type is 6 bytes length, but SQLite `int` can store value up to 8 bytes.
651
665
-`sqlite_fdw` doesn't pushdown any operations with MAC adresses because there is 3 possible affinities for it in SQLite: `integer`, `blob` and `text`.
666
+
### IP address support
667
+
-`sqlite_fdw` PostgreSQL `inet` values support based on `int` SQLite data affinity for IP v4 and `blob` SQLite data affinity for IP v6.
668
+
- Usual form of IP v4 address with cidr from a value with `integer` affinity can be generated with such SQLite query as
- IP address v4 with possible cidr addition enconing as SQLite integer based on such conventions
741
+
```
742
+
m - mask as number of bits
743
+
a - IP address bytes
744
+
745
+
IP v4 + cidr
746
+
┏━━━┳━━━┳━━━┳━━━┳━━━┓
747
+
┃ m ┃ a ┃ a ┃ a ┃ a ┃
748
+
┗━━━┻━━━┻━━━┻━━━┻━━━┛
749
+
0 1 2 3 4 - byte index
750
+
751
+
IP v4
752
+
┏━━━┳━━━┳━━━┳━━━┓
753
+
┃ a ┃ a ┃ a ┃ a ┃
754
+
┗━━━┻━━━┻━━━┻━━━┛
755
+
0 1 2 3 - byte index
756
+
```
757
+
-`sqlite_fdw` doesn't pushdown any operations with IP adresses because there is 3 possible affinities for it in SQLite: `integer`, `blob` and `text`.
652
758
653
759
### JSON support and operators
654
760
- Operators `->` and `->>` for `json` and `jsonb` are pushed down. This means if you deal with a foreign table only, you can use SQLite syntax of `->` and `->>` operators which is more rich than PostgreSQL syntax. In PostgreSQL this operators means only 1-leveled extraction after one call, but possible multilevel extraction in one call of the operator in SQLite. You can extract `'{"a": 2, "c": [4, 5, {"f": 7}]}' ->'c' -> 2` with result `{"f":7}` both for PostgreSQL and SQLite tables, but `'{"a": 2, "c": [4, 5, {"f": 7}]}' ->'$.c[2]'` possible only in SQLite and for a foreign table.
0 commit comments