Skip to content

Fix/bind column value parameters also if null#6

Merged
andinux merged 10 commits intodevfrom
fix/bind-column-value-parameters-also-if-null
Feb 10, 2026
Merged

Fix/bind column value parameters also if null#6
andinux merged 10 commits intodevfrom
fix/bind-column-value-parameters-also-if-null

Conversation

@andinux
Copy link

@andinux andinux commented Feb 10, 2026

No description provided.

Fix parameter binding bug in merge_insert_col that caused SQLite-to-PostgreSQL sync to fail with "there is no parameter $3" when NULL values were synced before non-NULL values for the same column.
…get when the last db_version is not related to a local change
…I plan caching

When syncing NULL values first, PostgreSQL's SPI caches the prepared plan with the NULL's type. If a subsequent non-NULL value decodes to a different type, the plan fails. The fix maps column types to their decoded equivalents so NULL and non-NULL values always use consistent types (e.g., all integers use INT8OID, all floats use FLOAT8OID, most others use TEXTOID).

Add map_column_oid_to_decoded_oid() to map column types to their decoded equivalents (INT2/4/8 → INT8, FLOAT4/8/NUMERIC → FLOAT8, BYTEA → BYTEA, others → TEXT). This ensures NULL and non-NULL values bind with the same type, preventing "there is no parameter $N" errors when NULL is synced before non-NULL values for the same column.

Add tests 23 and 24 for UUID columns and comprehensive nullable type coverage (INT2/4/8, FLOAT4/8, NUMERIC, BYTEA, TEXT, VARCHAR, CHAR, UUID, JSON, JSONB, DATE, TIMESTAMP).
BOOLEAN values are encoded as INT8 in sync payloads for SQLite interoperability, but PostgreSQL has no built-in cast from bigint to boolean. Add a custom ASSIGNMENT cast that enables BOOLEAN columns to sync correctly.

The cast uses ASSIGNMENT context (not IMPLICIT) to avoid unintended conversions in WHERE clauses while still enabling INSERT/UPDATE operations used by merge_insert.

The write direction (BOOL → INT encoding flow) "just works" because DatumGetBool() naturally returns 0 or 1. The problem was only on the read side where PostgreSQL refused to cast the decoded INT8 back to BOOLEAN without our custom cast.
…cker compose (v2 plugin syntax)

Fix the execution in the github actions runner: The GitHub Actions runner has docker compose (v2 plugin) but not the standalone docker-compose (v1)
@andinux andinux merged commit 47180e7 into dev Feb 10, 2026
17 checks passed
@andinux andinux deleted the fix/bind-column-value-parameters-also-if-null branch February 12, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant