diff --git a/pageserver/src/page_service.rs b/pageserver/src/page_service.rs index b070d3dad8..1cc8080928 100644 --- a/pageserver/src/page_service.rs +++ b/pageserver/src/page_service.rs @@ -685,54 +685,14 @@ impl postgres_backend::Handler for PageServerHandler { let result = timeline.gc_iteration(gc_horizon, true)?; pgb.write_message_noflush(&BeMessage::RowDescription(&[ - RowDescriptor { - name: b"n_relations", - typoid: 20, - typlen: 8, - ..Default::default() - }, - RowDescriptor { - name: b"truncated", - typoid: 20, - typlen: 8, - ..Default::default() - }, - RowDescriptor { - name: b"deleted", - typoid: 20, - typlen: 8, - ..Default::default() - }, - RowDescriptor { - name: b"prep_deleted", - typoid: 20, - typlen: 8, - ..Default::default() - }, - RowDescriptor { - name: b"slru_deleted", - typoid: 20, - typlen: 8, - ..Default::default() - }, - RowDescriptor { - name: b"chkp_deleted", - typoid: 20, - typlen: 8, - ..Default::default() - }, - RowDescriptor { - name: b"dropped", - typoid: 20, - typlen: 8, - ..Default::default() - }, - RowDescriptor { - name: b"elapsed", - typoid: 20, - typlen: 8, - ..Default::default() - }, + RowDescriptor::int8_col(b"n_relations"), + RowDescriptor::int8_col(b"truncated"), + RowDescriptor::int8_col(b"deleted"), + RowDescriptor::int8_col(b"prep_deleted"), + RowDescriptor::int8_col(b"slru_deleted"), + RowDescriptor::int8_col(b"chkp_deleted"), + RowDescriptor::int8_col(b"dropped"), + RowDescriptor::int8_col(b"elapsed"), ]))? .write_message_noflush(&BeMessage::DataRow(&[ Some(&result.n_relations.to_string().as_bytes()), diff --git a/zenith_utils/src/pq_proto.rs b/zenith_utils/src/pq_proto.rs index 0d1fa9d236..780474a4b9 100644 --- a/zenith_utils/src/pq_proto.rs +++ b/zenith_utils/src/pq_proto.rs @@ -15,6 +15,9 @@ use std::str; pub type Oid = u32; pub type SystemId = u64; +pub const TEXT_OID: Oid = 25; +pub const INT8_OID: Oid = 20; + #[derive(Debug)] pub enum FeMessage { StartupMessage(FeStartupMessage), @@ -380,6 +383,21 @@ impl Default for RowDescriptor<'_> { } } +impl RowDescriptor<'_> { + /// Convenience function to create a RowDescriptor message for an int8 column + pub const fn int8_col(name: &[u8]) -> RowDescriptor { + RowDescriptor { + name, + tableoid: 0, + attnum: 0, + typoid: INT8_OID, + typlen: 8, + typmod: 0, + formatcode: 0, + } + } +} + #[derive(Debug)] pub struct XLogDataBody<'a> { pub wal_start: u64, @@ -389,7 +407,7 @@ pub struct XLogDataBody<'a> { } pub static HELLO_WORLD_ROW: BeMessage = BeMessage::DataRow(&[Some(b"hello world")]); -pub const TEXT_OID: Oid = 25; + // single text column pub static SINGLE_COL_ROWDESC: BeMessage = BeMessage::RowDescription(&[RowDescriptor { name: b"data",