Skip to content

Commit

Permalink
readyset-psql: Pass through table OID and column ID from upstream
Browse files Browse the repository at this point in the history
Bump tokio-postgres to the version with
readysettech/rust-postgres#7 exposing the table
OID and column ID on columnns returned from upstream, and pass those
through to the psql_srv::Column we construct for queries that're proxied
upstream.

Refs: REA-3380
Change-Id: I72c7d0e21192f581cf06f49effca3be1a25c0c92
  • Loading branch information
glittershark committed Aug 22, 2023
1 parent ae5b696 commit 9f80799
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions readyset-psql/src/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,8 @@ impl UpstreamDatabase for PostgreSqlUpstream {
Ok(Column {
name: col.name().into(),
col_type: col.type_().clone(),
// TODO: Load the following two fields from upstream, once tokio-postgres
// provides them
table_oid: None,
attnum: None,
table_oid: col.table_oid(),
attnum: col.column_id(),
})
})
.collect::<Result<Vec<_>, _>>()?,
Expand Down
22 changes: 22 additions & 0 deletions readyset-psql/tests/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1652,3 +1652,25 @@ async fn start_replication_in_middle_of_commit() {

shutdown_tx.shutdown().await;
}

#[tokio::test(flavor = "multi_thread")]
async fn column_metadata() {
let (config, _handle, shutdown_tx) = setup().await;
let client = connect(config).await;
client.simple_query("create table t(a int)").await.unwrap();
let table_oid = client
.query_one("select 't'::regclass::oid", &[])
.await
.unwrap()
.get::<_, u32>(0);

let cached_stmt = client.prepare("select a from t").await.unwrap();
assert_eq!(cached_stmt.columns()[0].table_oid(), Some(table_oid));
assert_eq!(cached_stmt.columns()[0].column_id(), Some(1));

let proxied_stmt = client.prepare("select a, now() from t").await.unwrap();
assert_eq!(proxied_stmt.columns()[0].table_oid(), Some(table_oid));
assert_eq!(proxied_stmt.columns()[0].column_id(), Some(1));

shutdown_tx.shutdown().await;
}

0 comments on commit 9f80799

Please sign in to comment.