Commit 774ea01
feat: propagate GEOMETRY CRS as PostGIS SRID via EWKB
DuckDB 1.5 introduced CRS metadata on the GEOMETRY type (e.g.,
GEOMETRY('EPSG:4326')). When writing to PostGIS via binary COPY,
the SRID was lost because the writer sent plain WKB.
This change detects CRS on the GEOMETRY LogicalType and writes
EWKB (WKB with SRID header) instead:
WKB: [byte_order:1] [type:4] [payload...]
EWKB: [byte_order:1] [type|0x20000000:4] [srid:4] [payload...]
The SRID is extracted from the CRS identifier (e.g., "EPSG:4326" → 4326).
If no CRS is set, plain WKB is sent (preserving current behavior).
Before: DuckDB GEOMETRY('EPSG:4326') → PostGIS geometry(SRID=0)
After: DuckDB GEOMETRY('EPSG:4326') → PostGIS geometry(SRID=4326)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c0e9256 commit 774ea01
1 file changed
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
210 | 249 | | |
211 | 250 | | |
212 | 251 | | |
| |||
354 | 393 | | |
355 | 394 | | |
356 | 395 | | |
357 | | - | |
| 396 | + | |
358 | 397 | | |
359 | 398 | | |
360 | 399 | | |
| |||
0 commit comments