Skip to content

Commit 833b7b3

Browse files
committed
postgres: Add replication support for tsvector
This CL "allows" snapshot/replication to occur for postgres `tsvector` types, but we intentionally throw away the data (and store NULL). This is because Readyset has no intention of supporting `tsvector` data types as they will never be a good candidate for caching, at least not for a very long time. Discarding the data allows us to import the rest of the table's data, which can be used for proper cached queries in Readyset. Fixes: REA-5734 Release-Note-Core: Support replication of postgres `tsvector` data types. Readyset interntionally discards the data as we will not support tsvector queries in the product. Change-Id: I28f209a96939f1cc58fd616b5cd5e07d8c0ddb23 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/9511 Tested-by: Buildkite CI Reviewed-by: Michael Zink <michael.z@readyset.io>
1 parent 122c386 commit 833b7b3

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
statement ok
2+
create table documents (id int primary key, content_vector tsvector);
3+
4+
statement ok
5+
insert into documents values
6+
(1, to_tsvector('english', 'The quick brown fox jumps over the lazy dog'));
7+
8+
sleep 1000
9+
10+
query T nosort
11+
select content_vector from documents where id = 1
12+
----
13+
NULL
14+
15+
statement ok
16+
update documents values set content_vector = to_tsvector('english', 'A fast white rabbit jumps over the fence') where id = 1;
17+
18+
sleep 1000
19+
20+
query T nosort
21+
select content_vector from documents where id = 1
22+
----
23+
NULL
24+
25+
26+
27+
28+

readyset-data/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,8 @@ impl<'a> FromSql<'a> for DfValue {
22052205
Ok(DfValue::from(out))
22062206
}
22072207
Type::BIT | Type::VARBIT => mk_from_sql!(BitVec),
2208+
// we intentionally throw away the tsvector data.
2209+
Type::TS_VECTOR => Ok(DfValue::None),
22082210
ref ty if ty.name() == "citext" => Ok(DfValue::from_str_and_collation(
22092211
<&str>::from_sql(ty, raw)?,
22102212
Collation::Citext,

replicators/src/postgres_connector/wal_reader.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ impl wal::TupleData {
627627
PGType::UUID => DfType::Uuid,
628628
PGType::BIT => DfType::DEFAULT_BIT,
629629
PGType::VARBIT => DfType::VarBit(None),
630+
PGType::TS_VECTOR => DfType::Tsvector,
630631
ref ty => {
631632
trace!("got unsupported type '{}'", ty.to_string());
632633
return Err(unsupported_type_err());
@@ -847,6 +848,8 @@ impl wal::TupleData {
847848
}
848849
DfValue::from(bits)
849850
}
851+
// we intentionally throw away the tsvector data.
852+
PGType::TS_VECTOR => DfValue::None,
850853
_ => return Err(unsupported_type_err()),
851854
},
852855
}

0 commit comments

Comments
 (0)