From b49164a1d4717c4db97f3be6b844d9b71f92028b Mon Sep 17 00:00:00 2001 From: anastasia Date: Wed, 28 Apr 2021 13:58:27 +0300 Subject: [PATCH] cargo fmt --- pageserver/src/waldecoder.rs | 13 ++++++++----- pageserver/src/walreceiver.rs | 2 +- pageserver/src/walredo.rs | 4 ++-- postgres_ffi/src/lib.rs | 2 +- postgres_ffi/src/pg_constants.rs | 1 - postgres_ffi/src/xlog_utils.rs | 3 +-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pageserver/src/waldecoder.rs b/pageserver/src/waldecoder.rs index bbe9cd2fd8..f3a646aaf5 100644 --- a/pageserver/src/waldecoder.rs +++ b/pageserver/src/waldecoder.rs @@ -1,6 +1,6 @@ -use postgres_ffi::pg_constants; use bytes::{Buf, BufMut, Bytes, BytesMut}; use log::*; +use postgres_ffi::pg_constants; use postgres_ffi::xlog_utils::XLogRecord; use std::cmp::min; use std::str; @@ -312,11 +312,10 @@ pub struct DecodedWALRecord { // // FIXME: refactor this and decode_wal_record() below to avoid the duplication. // fn is_xlog_switch_record(rec: &Bytes) -> bool { // let mut buf = rec.clone(); - + // let xlogrec = XLogRecord::from_bytes(&mut buf); // xlogrec.xl_info == pg_constants::XLOG_SWITCH && xlogrec.xl_rmid == pg_constants::RM_XLOG_ID // } - pub type Oid = u32; pub type BlockNumber = u32; @@ -510,7 +509,9 @@ pub fn decode_wal_record(record: Bytes) -> DecodedWALRecord { * bimg_len < BLCKSZ if the HAS_HOLE flag is set. */ if blk.bimg_info & pg_constants::BKPIMAGE_HAS_HOLE != 0 - && (blk.hole_offset == 0 || blk.hole_length == 0 || blk.bimg_len == pg_constants::BLCKSZ) + && (blk.hole_offset == 0 + || blk.hole_length == 0 + || blk.bimg_len == pg_constants::BLCKSZ) { // TODO /* @@ -546,7 +547,9 @@ pub fn decode_wal_record(record: Bytes) -> DecodedWALRecord { * cross-check that bimg_len < BLCKSZ if the IS_COMPRESSED * flag is set. */ - if (blk.bimg_info & pg_constants::BKPIMAGE_IS_COMPRESSED == 0) && blk.bimg_len == pg_constants::BLCKSZ { + if (blk.bimg_info & pg_constants::BKPIMAGE_IS_COMPRESSED == 0) + && blk.bimg_len == pg_constants::BLCKSZ + { // TODO /* report_invalid_record(state, diff --git a/pageserver/src/walreceiver.rs b/pageserver/src/walreceiver.rs index e97f7c7c9b..4868395738 100644 --- a/pageserver/src/walreceiver.rs +++ b/pageserver/src/walreceiver.rs @@ -14,8 +14,8 @@ use crate::ZTimelineId; use anyhow::Error; use lazy_static::lazy_static; use log::*; -use postgres_ffi::xlog_utils::*; use postgres_ffi::pg_constants; +use postgres_ffi::xlog_utils::*; use postgres_protocol::message::backend::ReplicationMessage; use postgres_types::PgLsn; use std::collections::HashMap; diff --git a/pageserver/src/walredo.rs b/pageserver/src/walredo.rs index 8f2eb33b3a..c21629850a 100644 --- a/pageserver/src/walredo.rs +++ b/pageserver/src/walredo.rs @@ -36,10 +36,10 @@ use zenith_utils::lsn::Lsn; use crate::page_cache::BufferTag; use crate::page_cache::WALRecord; -use crate::ZTimelineId; use crate::PageServerConf; -use postgres_ffi::xlog_utils::{XLogRecord}; +use crate::ZTimelineId; use postgres_ffi::pg_constants; +use postgres_ffi::xlog_utils::XLogRecord; static TIMEOUT: Duration = Duration::from_secs(20); diff --git a/postgres_ffi/src/lib.rs b/postgres_ffi/src/lib.rs index 61bdd398be..8513261caf 100644 --- a/postgres_ffi/src/lib.rs +++ b/postgres_ffi/src/lib.rs @@ -3,8 +3,8 @@ #![allow(non_snake_case)] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); -pub mod xlog_utils; pub mod pg_constants; +pub mod xlog_utils; use bytes::{Buf, Bytes, BytesMut}; diff --git a/postgres_ffi/src/pg_constants.rs b/postgres_ffi/src/pg_constants.rs index a43aab1633..4acfa7a7ce 100644 --- a/postgres_ffi/src/pg_constants.rs +++ b/postgres_ffi/src/pg_constants.rs @@ -71,7 +71,6 @@ pub const XLOG_TBLSPC_DROP: u8 = 0x10; pub const SIZEOF_XLOGRECORD: u32 = 24; - // FIXME: pub const BLCKSZ: u16 = 8192; diff --git a/postgres_ffi/src/xlog_utils.rs b/postgres_ffi/src/xlog_utils.rs index 85a0ae2f63..bbc71be7ac 100644 --- a/postgres_ffi/src/xlog_utils.rs +++ b/postgres_ffi/src/xlog_utils.rs @@ -299,7 +299,6 @@ impl XLogRecord { // Is this record an XLOG_SWITCH record? They need some special processing, pub fn is_xlog_switch_record(&self) -> bool { - - self.xl_info == pg_constants::XLOG_SWITCH && self.xl_rmid == pg_constants::RM_XLOG_ID + self.xl_info == pg_constants::XLOG_SWITCH && self.xl_rmid == pg_constants::RM_XLOG_ID } }