handle XLOG_DBASE_CREATE in waldecoder

This commit is contained in:
anastasia
2021-04-23 14:06:09 +03:00
parent 573f1ada83
commit b64bd2a8af
2 changed files with 44 additions and 0 deletions

View File

@@ -49,8 +49,17 @@ pub const RM_XLOG_ID: u8 = 0;
pub const RM_XACT_ID: u8 = 1;
pub const RM_SMGR_ID: u8 = 2;
pub const RM_CLOG_ID: u8 = 3;
pub const RM_DBASE_ID: u8 = 4;
pub const RM_TBLSPC_ID: u8 = 5;
// pub const RM_MULTIXACT_ID:u8 = 6;
// from xlogreader.h
pub const XLR_INFO_MASK: u8 = 0x0F;
pub const XLR_RMGR_INFO_MASK: u8 = 0xF0;
// from dbcommands_xlog.h
pub const XLOG_DBASE_CREATE: u8 = 0x00;
pub const XLOG_DBASE_DROP: u8 = 0x10;
pub const XLOG_TBLSPC_CREATE: u8 = 0x00;
pub const XLOG_TBLSPC_DROP: u8 = 0x10;

View File

@@ -3,6 +3,7 @@ use bytes::{Buf, BufMut, Bytes, BytesMut};
use log::*;
use std::cmp::min;
use thiserror::Error;
use std::str;
const XLOG_BLCKSZ: u32 = 8192;
@@ -678,6 +679,40 @@ pub fn decode_wal_record(record: Bytes) -> DecodedWALRecord {
//TODO parse abort record to extract subtrans entries
}
}
else if xl_rmid == pg_constants::RM_DBASE_ID
{
let info = xl_info & !pg_constants::XLR_INFO_MASK;
if info == pg_constants::XLOG_DBASE_CREATE
{
//buf points to main_data
let db_id = buf.get_u32_le();
let tablespace_id = buf.get_u32_le();
let src_db_id = buf.get_u32_le();
let src_tablespace_id = buf.get_u32_le();
trace!("XLOG_DBASE_CREATE db_id {} src_db_id {}", db_id, src_db_id);
// in postgres it is implemented as copydir
// we need to copy all pages in page_cache
}
else
{
trace!("XLOG_DBASE_DROP is not handled yet");
}
}
else if xl_rmid == pg_constants::RM_TBLSPC_ID
{
let info = xl_info & !pg_constants::XLR_INFO_MASK;
if info == pg_constants::XLOG_TBLSPC_CREATE
{
//buf points to main_data
let ts_id = buf.get_u32_le();
let ts_path = str::from_utf8(&buf).unwrap();
trace!("XLOG_TBLSPC_CREATE ts_id {} ts_path {}", ts_id, ts_path);
}
else
{
trace!("XLOG_TBLSPC_DROP is not handled yet");
}
}
DecodedWALRecord {
xl_info,