Skip to content

Add support for ltree data type#834

Merged
kvch merged 2 commits into
mainfrom
feat/ltree-text-copy
Jun 4, 2026
Merged

Add support for ltree data type#834
kvch merged 2 commits into
mainfrom
feat/ltree-text-copy

Conversation

@kvch
Copy link
Copy Markdown
Collaborator

@kvch kvch commented Jun 2, 2026

Description

This PR adds support for the ltree data type: https://www.postgresql.org/docs/current/ltree.html

It came up during the investigation into cube data type.

Type of Change

Please select the relevant option(s):

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test coverage improvement
  • 🔨 Build/CI changes
  • 🧹 Code cleanup

Changes Made

  • internal/postgres/pg_utils.go — add {name: "ltree", register: registerWithCodec("ltree", pgtype.TextCodec{})} to extensionTypes so source reads return ltree values as strings.
  • pkg/wal/processor/postgres/postgres_wal_dml_adapter.go — add "ltree": {} to textOnlyCopyTypes so bulk ingest dispatches affected batches to Txn.CopyFromText.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Code is well-commented
  • Documentation updated where necessary

@kvch kvch requested a review from exekias June 3, 2026 14:51
Copy link
Copy Markdown
Member

@exekias exekias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always byte us with every new/missing data type, I wonder if there could be a generic way to copy "anything"

@kvch
Copy link
Copy Markdown
Collaborator Author

kvch commented Jun 4, 2026

This will always byte us with every new/missing data type, I wonder if there could be a generic way to copy "anything"

Unfortunately, pgx Copy functionality has some limitations when it comes to parsing custom data types. I will look into handling these issues more gracefully and/or finding a way to parse the data in a more robust manner.

@kvch kvch enabled auto-merge (squash) June 4, 2026 15:41
@kvch kvch merged commit 459eee9 into main Jun 4, 2026
9 checks passed
@kvch kvch deleted the feat/ltree-text-copy branch June 4, 2026 15:45
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/xataio/pgstream/internal/postgres 29.31% (ø)
github.com/xataio/pgstream/pkg/stream/integration 0.00% (ø)
github.com/xataio/pgstream/pkg/wal/processor/postgres 79.34% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/xataio/pgstream/internal/postgres/pg_utils.go 47.37% (ø) 114 54 60
github.com/xataio/pgstream/pkg/wal/processor/postgres/postgres_wal_dml_adapter.go 94.64% (ø) 168 159 9

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/xataio/pgstream/pkg/stream/integration/snapshot_pg_integration_test.go

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.

2 participants