mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-27 16:12:56 +00:00
Run 'cargo fmt'.
Fixes a few formatting discrepancies had crept in recently.
This commit is contained in:
@@ -297,9 +297,7 @@ impl PostgresNode {
|
||||
"shared_preload_libraries = zenith \n\
|
||||
zenith.page_server_connstring = 'host={} port={}'\n\
|
||||
zenith.zenith_timeline='{}'\n",
|
||||
host,
|
||||
port,
|
||||
self.timelineid
|
||||
host, port, self.timelineid
|
||||
),
|
||||
)?;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
use std::net::{TcpStream};
|
||||
use std::net::TcpStream;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::thread;
|
||||
@@ -12,8 +12,8 @@ use postgres::{Config, NoTls};
|
||||
|
||||
use crate::local_env::LocalEnv;
|
||||
use crate::read_pidfile;
|
||||
use zenith_utils::connstring::connection_address;
|
||||
use pageserver::branches::BranchInfo;
|
||||
use zenith_utils::connstring::connection_address;
|
||||
|
||||
//
|
||||
// Control routines for pageserver.
|
||||
@@ -36,7 +36,9 @@ impl PageServerNode {
|
||||
}
|
||||
|
||||
fn default_config() -> Config {
|
||||
"postgresql://no_user@localhost:64000/no_db".parse().unwrap()
|
||||
"postgresql://no_user@localhost:64000/no_db"
|
||||
.parse()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn connection_config(&self) -> Config {
|
||||
|
||||
@@ -642,7 +642,12 @@ impl ObjectTimeline {
|
||||
return Ok(page_img);
|
||||
}
|
||||
static ZERO_PAGE: [u8; 8192] = [0u8; 8192];
|
||||
trace!("page {} blk {} at {} not found", tag.rel, tag.blknum, req_lsn);
|
||||
trace!(
|
||||
"page {} blk {} at {} not found",
|
||||
tag.rel,
|
||||
tag.blknum,
|
||||
req_lsn
|
||||
);
|
||||
Ok(Bytes::from_static(&ZERO_PAGE))
|
||||
/* return Err("could not find page image")?; */
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ mod tests {
|
||||
// Create another relation
|
||||
let buftag2 = BufferTag {
|
||||
rel: TESTREL_B,
|
||||
blknum : 0,
|
||||
blknum: 0,
|
||||
};
|
||||
tline.put_page_image(buftag2, Lsn(2), TEST_IMG("foobar blk 0 at 2"))?;
|
||||
|
||||
@@ -509,10 +509,7 @@ mod tests {
|
||||
TEST_IMG("foobar blk 0 at 2")
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
newtline.get_rel_size(TESTREL_B, Lsn(4))?,
|
||||
1
|
||||
);
|
||||
assert_eq!(newtline.get_rel_size(TESTREL_B, Lsn(4))?, 1);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ pub fn get_current_timestamp() -> TimestampTz {
|
||||
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
|
||||
Ok(n) => {
|
||||
((n.as_secs() - ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY))
|
||||
* USECS_PER_SEC
|
||||
+ n.subsec_micros() as u64) as i64
|
||||
* USECS_PER_SEC
|
||||
+ n.subsec_micros() as u64) as i64
|
||||
}
|
||||
Err(_) => panic!("SystemTime before UNIX EPOCH!"),
|
||||
}
|
||||
|
||||
2
vendor/postgres
vendored
2
vendor/postgres
vendored
Submodule vendor/postgres updated: a08f50cba2...40465243d6
@@ -6,7 +6,6 @@ use anyhow::{bail, Result};
|
||||
use log::*;
|
||||
use postgres::{Client, Config, NoTls};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use zenith_utils::connstring::connection_host_port;
|
||||
use std::cmp::{max, min};
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::io::{BufReader, Read, Seek, SeekFrom, Write};
|
||||
@@ -16,6 +15,7 @@ use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::thread::sleep;
|
||||
use zenith_utils::bin_ser::LeSer;
|
||||
use zenith_utils::connstring::connection_host_port;
|
||||
use zenith_utils::lsn::Lsn;
|
||||
|
||||
use crate::replication::HotStandbyFeedback;
|
||||
@@ -159,10 +159,7 @@ fn request_callback(conf: WalAcceptorConf, timelineid: ZTimelineId) {
|
||||
let (host, port) = connection_host_port(&me_conf);
|
||||
let callme = format!(
|
||||
"callmemaybe {} host={} port={} options='-c ztimelineid={}'",
|
||||
timelineid,
|
||||
host,
|
||||
port,
|
||||
timelineid
|
||||
timelineid, host, port, timelineid
|
||||
);
|
||||
loop {
|
||||
info!(
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
use postgres::Config;
|
||||
|
||||
pub fn connection_host_port(config: &Config) -> (String, u16) {
|
||||
assert_eq!(config.get_hosts().len(), 1, "only one pair of host and port is supported in connection string");
|
||||
assert_eq!(config.get_ports().len(), 1, "only one pair of host and port is supported in connection string");
|
||||
assert_eq!(
|
||||
config.get_hosts().len(),
|
||||
1,
|
||||
"only one pair of host and port is supported in connection string"
|
||||
);
|
||||
assert_eq!(
|
||||
config.get_ports().len(),
|
||||
1,
|
||||
"only one pair of host and port is supported in connection string"
|
||||
);
|
||||
let host = match &config.get_hosts()[0] {
|
||||
postgres::config::Host::Tcp(host) => host.as_ref(),
|
||||
postgres::config::Host::Unix(host) => host.to_str().unwrap(),
|
||||
@@ -21,14 +29,24 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_connection_host_port() {
|
||||
let config: Config = "postgresql://no_user@localhost:64000/no_db".parse().unwrap();
|
||||
assert_eq!(connection_host_port(&config), ("localhost".to_owned(), 64000));
|
||||
let config: Config = "postgresql://no_user@localhost:64000/no_db"
|
||||
.parse()
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
connection_host_port(&config),
|
||||
("localhost".to_owned(), 64000)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "only one pair of host and port is supported in connection string")]
|
||||
fn test_connection_host_port_multiple_ports() {
|
||||
let config: Config = "postgresql://no_user@localhost:64000,localhost:64001/no_db".parse().unwrap();
|
||||
assert_eq!(connection_host_port(&config), ("localhost".to_owned(), 64000));
|
||||
let config: Config = "postgresql://no_user@localhost:64000,localhost:64001/no_db"
|
||||
.parse()
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
connection_host_port(&config),
|
||||
("localhost".to_owned(), 64000)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user