Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/wal/processor/postgres/postgres_wal_dml_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ func (a *dmlAdapter) updateValueForCopy(value any, colType string) any {
return getInfinityValueForDateTime(value, colType)
case "tstzrange":
return getTypedTSTZRange(value)
case "tsvector":
if b, ok := value.([]byte); ok {
return string(b)
}
return value
}

// Handle array types
Expand Down
52 changes: 52 additions & 0 deletions pkg/wal/processor/postgres/postgres_wal_dml_adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,58 @@ func TestDMLAdapter_walDataToQueries(t *testing.T) {
},
},
},
{
name: "insert with tsvector - for copy enabled",
walData: &wal.Data{
Action: "I",
Schema: testSchema,
Table: testTable,
Columns: []wal.Column{
{ID: columnID(1), Name: "id", Value: 1},
{ID: columnID(2), Name: "search_vec", Value: []byte("'hello':1 'world':2"), Type: "tsvector"},
},
Metadata: wal.Metadata{
InternalColIDs: []string{columnID(1)},
},
},
forCopy: true,

wantQueries: []*query{
{
schema: testSchema,
table: testTable,
columnNames: []string{`"id"`, `"search_vec"`},
sql: fmt.Sprintf("INSERT INTO %s(\"id\", \"search_vec\") OVERRIDING SYSTEM VALUE VALUES($1, $2)", quotedTestTable),
args: []any{1, "'hello':1 'world':2"},
},
},
},
{
name: "insert with tsvector string - for copy enabled",
walData: &wal.Data{
Action: "I",
Schema: testSchema,
Table: testTable,
Columns: []wal.Column{
{ID: columnID(1), Name: "id", Value: 1},
{ID: columnID(2), Name: "search_vec", Value: "'hello':1 'world':2", Type: "tsvector"},
},
Metadata: wal.Metadata{
InternalColIDs: []string{columnID(1)},
},
},
forCopy: true,

wantQueries: []*query{
{
schema: testSchema,
table: testTable,
columnNames: []string{`"id"`, `"search_vec"`},
sql: fmt.Sprintf("INSERT INTO %s(\"id\", \"search_vec\") OVERRIDING SYSTEM VALUE VALUES($1, $2)", quotedTestTable),
args: []any{1, "'hello':1 'world':2"},
},
},
},
{
name: "insert with enum array - for copy enabled",
walData: &wal.Data{
Expand Down
Loading