From 25eaaa39afe2bc5bdf8ed1a06d76db48af050dc9 Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Fri, 19 Aug 2022 18:00:34 -0400 Subject: [PATCH 01/12] Extract pg-config wrapper --- Cargo.lock | 20 ++++++++++++++ Cargo.toml | 1 + cargo-pgx/Cargo.toml | 1 + cargo-pgx/src/command/connect.rs | 2 +- cargo-pgx/src/command/init.rs | 6 ++--- cargo-pgx/src/command/install.rs | 2 +- cargo-pgx/src/command/package.rs | 3 ++- cargo-pgx/src/command/run.rs | 6 ++--- cargo-pgx/src/command/schema.rs | 2 +- cargo-pgx/src/command/start.rs | 2 +- cargo-pgx/src/command/status.rs | 2 +- cargo-pgx/src/command/stop.rs | 2 +- cargo-pgx/src/command/test.rs | 6 ++--- cargo-pgx/src/command/version.rs | 4 +-- pgx-pg-config/Cargo.toml | 26 +++++++++++++++++++ .../pg_config.rs => pgx-pg-config/src/lib.rs | 4 ++- pgx-pg-sys/Cargo.toml | 1 + pgx-pg-sys/build.rs | 2 +- pgx-tests/Cargo.toml | 1 + pgx-tests/src/framework.rs | 2 +- pgx-utils/Cargo.toml | 1 + pgx-utils/src/lib.rs | 6 ++--- 22 files changed, 74 insertions(+), 28 deletions(-) create mode 100644 pgx-pg-config/Cargo.toml rename pgx-utils/src/pg_config.rs => pgx-pg-config/src/lib.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index d1189940e..844d3dcee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -294,6 +294,7 @@ dependencies = [ "object", "once_cell", "owo-colors", + "pgx-pg-config", "pgx-utils", "proc-macro2", "quote", @@ -1447,6 +1448,22 @@ dependencies = [ "unescape", ] +[[package]] +name = "pgx-pg-config" +version = "0.5.0-beta.0" +dependencies = [ + "dirs", + "eyre", + "owo-colors", + "serde", + "serde_derive", + "serde_json", + "toml", + "tracing", + "tracing-error", + "url", +] + [[package]] name = "pgx-pg-sys" version = "0.5.0-beta.0" @@ -1460,6 +1477,7 @@ dependencies = [ "once_cell", "owo-colors", "pgx-macros", + "pgx-pg-config", "pgx-utils", "proc-macro2", "quote", @@ -1479,6 +1497,7 @@ dependencies = [ "owo-colors", "pgx", "pgx-macros", + "pgx-pg-config", "pgx-utils", "postgres", "regex", @@ -1500,6 +1519,7 @@ dependencies = [ "eyre", "owo-colors", "petgraph", + "pgx-pg-config", "prettyplease", "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 50df078bb..9885e0da7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "cargo-pgx", "pgx", "pgx-macros", + "pgx-pg-config", "pgx-pg-sys", "pgx-tests", "pgx-utils", diff --git a/cargo-pgx/Cargo.toml b/cargo-pgx/Cargo.toml index 0cb2c8a53..dbf66c49a 100644 --- a/cargo-pgx/Cargo.toml +++ b/cargo-pgx/Cargo.toml @@ -24,6 +24,7 @@ semver = "1.0.9" owo-colors = { version = "3.4.0", features = [ "supports-colors" ] } env_proxy = "0.4.1" num_cpus = "1.13.1" +pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils", version = "=0.5.0-beta.0" } proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] } quote = "1.0.18" diff --git a/cargo-pgx/src/command/connect.rs b/cargo-pgx/src/command/connect.rs index 090f8dcdc..e7dd73b55 100644 --- a/cargo-pgx/src/command/connect.rs +++ b/cargo-pgx/src/command/connect.rs @@ -14,8 +14,8 @@ use crate::{ use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; +use pgx_pg_config::{PgConfig, Pgx}; use pgx_utils::createdb; -use pgx_utils::pg_config::{PgConfig, Pgx}; use std::path::PathBuf; /// Connect, via psql, to a Postgres instance diff --git a/cargo-pgx/src/command/init.rs b/cargo-pgx/src/command/init.rs index 4e91058ac..e60485c9b 100644 --- a/cargo-pgx/src/command/init.rs +++ b/cargo-pgx/src/command/init.rs @@ -12,10 +12,8 @@ use crate::command::version::pgx_default; use crate::CommandExecute; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_utils::{ - pg_config::{PgConfig, PgConfigSelector, Pgx}, - prefix_path, SUPPORTED_MAJOR_VERSIONS, -}; +use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; +use pgx_utils::{prefix_path, SUPPORTED_MAJOR_VERSIONS}; use rayon::prelude::*; use std::collections::HashMap; diff --git a/cargo-pgx/src/command/install.rs b/cargo-pgx/src/command/install.rs index 3a114e31c..b62175f8a 100644 --- a/cargo-pgx/src/command/install.rs +++ b/cargo-pgx/src/command/install.rs @@ -14,7 +14,7 @@ use crate::{ use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_utils::pg_config::PgConfig; +use pgx_pg_config::PgConfig; use pgx_utils::{get_target_dir, versioned_so_name}; use std::{ io::BufReader, diff --git a/cargo-pgx/src/command/package.rs b/cargo-pgx/src/command/package.rs index 63cb317c6..820a90a37 100644 --- a/cargo-pgx/src/command/package.rs +++ b/cargo-pgx/src/command/package.rs @@ -13,7 +13,8 @@ use crate::{ }; use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; -use pgx_utils::{get_target_dir, pg_config::PgConfig}; +use pgx_pg_config::PgConfig; +use pgx_utils::get_target_dir; use std::path::{Path, PathBuf}; /// Create an installation package directory. diff --git a/cargo-pgx/src/command/run.rs b/cargo-pgx/src/command/run.rs index 8137c692c..35a5d4f64 100644 --- a/cargo-pgx/src/command/run.rs +++ b/cargo-pgx/src/command/run.rs @@ -16,10 +16,8 @@ use crate::{ use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_utils::{ - createdb, - pg_config::{PgConfig, Pgx}, -}; +use pgx_pg_config::{PgConfig, Pgx}; +use pgx_utils::createdb; use std::{os::unix::process::CommandExt, path::Path, process::Command}; /// Compile/install extension to a pgx-managed Postgres instance and start psql #[derive(clap::Args, Debug)] diff --git a/cargo-pgx/src/command/schema.rs b/cargo-pgx/src/command/schema.rs index a41b57d62..acf4819c5 100644 --- a/cargo-pgx/src/command/schema.rs +++ b/cargo-pgx/src/command/schema.rs @@ -18,8 +18,8 @@ use eyre::{eyre, WrapErr}; use object::Object; use once_cell::sync::OnceCell; use owo_colors::OwoColorize; +use pgx_pg_config::{PgConfig, Pgx}; use pgx_utils::{ - pg_config::{PgConfig, Pgx}, sql_entity_graph::{PgxSql, SqlGraphEntity}, PgxPgSysStub, }; diff --git a/cargo-pgx/src/command/start.rs b/cargo-pgx/src/command/start.rs index ab7469aee..5b9c63a26 100644 --- a/cargo-pgx/src/command/start.rs +++ b/cargo-pgx/src/command/start.rs @@ -13,7 +13,7 @@ use crate::CommandExecute; use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_utils::pg_config::{PgConfig, PgConfigSelector, Pgx}; +use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; use std::{os::unix::process::CommandExt, path::PathBuf, process::Stdio}; /// Start a pgx-managed Postgres instance diff --git a/cargo-pgx/src/command/status.rs b/cargo-pgx/src/command/status.rs index 0eddcdb42..3077328a1 100644 --- a/cargo-pgx/src/command/status.rs +++ b/cargo-pgx/src/command/status.rs @@ -9,7 +9,7 @@ Use of this source code is governed by the MIT license that can be found in the use eyre::eyre; use owo_colors::OwoColorize; -use pgx_utils::pg_config::{PgConfig, PgConfigSelector, Pgx}; +use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; use std::{path::PathBuf, process::Stdio}; use crate::CommandExecute; diff --git a/cargo-pgx/src/command/stop.rs b/cargo-pgx/src/command/stop.rs index 7b8984b6b..fcef67c8d 100644 --- a/cargo-pgx/src/command/stop.rs +++ b/cargo-pgx/src/command/stop.rs @@ -11,7 +11,7 @@ use crate::{command::status::status_postgres, CommandExecute}; use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_utils::pg_config::{PgConfig, PgConfigSelector, Pgx}; +use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; use std::{path::PathBuf, process::Stdio}; /// Stop a pgx-managed Postgres instance diff --git a/cargo-pgx/src/command/test.rs b/cargo-pgx/src/command/test.rs index f35402bae..8c68c3b78 100644 --- a/cargo-pgx/src/command/test.rs +++ b/cargo-pgx/src/command/test.rs @@ -9,10 +9,8 @@ Use of this source code is governed by the MIT license that can be found in the use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; -use pgx_utils::{ - get_target_dir, - pg_config::{PgConfig, PgConfigSelector, Pgx}, -}; +use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; +use pgx_utils::get_target_dir; use std::{ path::{Path, PathBuf}, process::{Command, Stdio}, diff --git a/cargo-pgx/src/command/version.rs b/cargo-pgx/src/command/version.rs index bcc8415b7..326eadf22 100644 --- a/cargo-pgx/src/command/version.rs +++ b/cargo-pgx/src/command/version.rs @@ -1,4 +1,4 @@ -use pgx_utils::pg_config::{PgConfig, Pgx}; +use pgx_pg_config::{PgConfig, Pgx}; pub(crate) fn pgx_default(supported_major_versions: &[u16]) -> eyre::Result { let mut pgx = Pgx::new(); @@ -13,7 +13,7 @@ mod rss { use env_proxy::for_url_str; use eyre::WrapErr; use owo_colors::OwoColorize; - use pgx_utils::pg_config::PgVersion; + use pgx_pg_config::PgVersion; use serde_derive::Deserialize; use ureq::{Agent, AgentBuilder, Proxy}; use url::Url; diff --git a/pgx-pg-config/Cargo.toml b/pgx-pg-config/Cargo.toml new file mode 100644 index 000000000..79ea8f6e2 --- /dev/null +++ b/pgx-pg-config/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "pgx-pg-config" +version = "0.5.0-beta.0" +authors = ["ZomboDB, LLC "] +license = "MIT" +description = "A Postgres pg_config wrapper for 'pgx'" +homepage = "https://github.com/zombodb/pgx" +repository = "https://github.com/zombodb/pgx" +#documentation = "https://docs.rs/pgx-utils" +readme = "README.md" +edition = "2021" +rust-version = "1.58" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +dirs = "4.0.0" +eyre = "0.6.8" +owo-colors = "3.4.0" +serde = { version = "1.0.137", features = [ "derive" ] } +serde_derive = "1.0.137" +serde_json = "1.0.81" +toml = "0.5.9" +tracing = "0.1.34" +tracing-error = "0.2.0" +url = "2.2.2" diff --git a/pgx-utils/src/pg_config.rs b/pgx-pg-config/src/lib.rs similarity index 99% rename from pgx-utils/src/pg_config.rs rename to pgx-pg-config/src/lib.rs index cd3c09594..eef02315e 100644 --- a/pgx-utils/src/pg_config.rs +++ b/pgx-pg-config/src/lib.rs @@ -7,7 +7,6 @@ All rights reserved. Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ //! Wrapper around Postgres' `pg_config` command-line tool -use crate::{BASE_POSTGRES_PORT_NO, BASE_POSTGRES_TESTING_PORT_NO}; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; use serde_derive::{Deserialize, Serialize}; @@ -21,6 +20,9 @@ use std::{ }; use url::Url; +pub static BASE_POSTGRES_PORT_NO: u16 = 28800; +pub static BASE_POSTGRES_TESTING_PORT_NO: u16 = 32200; + #[derive(Clone)] pub struct PgVersion { major: u16, diff --git a/pgx-pg-sys/Cargo.toml b/pgx-pg-sys/Cargo.toml index 3987c4324..49e8de37b 100644 --- a/pgx-pg-sys/Cargo.toml +++ b/pgx-pg-sys/Cargo.toml @@ -40,6 +40,7 @@ bindgen = { version = "0.59.2", default-features = false, features = ["runtime"] build-deps = "0.1.4" owo-colors = "3.4.0" num_cpus = "1.13.1" +pgx-pg-config= { path = "../pgx-pg-config/", version = "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils/", version = "=0.5.0-beta.0" } proc-macro2 = "1.0.39" quote = "1.0.18" diff --git a/pgx-pg-sys/build.rs b/pgx-pg-sys/build.rs index 82532c211..9e79a4870 100644 --- a/pgx-pg-sys/build.rs +++ b/pgx-pg-sys/build.rs @@ -11,7 +11,7 @@ extern crate build_deps; use bindgen::callbacks::MacroParsingBehavior; use eyre::{eyre, WrapErr}; -use pgx_utils::pg_config::{PgConfig, PgConfigSelector, Pgx}; +use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; use pgx_utils::prefix_path; use pgx_utils::rewriter::PgGuardRewriter; use quote::{quote, ToTokens}; diff --git a/pgx-tests/Cargo.toml b/pgx-tests/Cargo.toml index c4844de7d..645d0390f 100644 --- a/pgx-tests/Cargo.toml +++ b/pgx-tests/Cargo.toml @@ -37,6 +37,7 @@ once_cell = "1.10.0" libc = "0.2.126" pgx = { path = "../pgx", default-features = false, version= "=0.5.0-beta.0" } pgx-macros = { path = "../pgx-macros", version= "=0.5.0-beta.0" } +pgx-pg-config = { path = "../pgx-pg-config", version= "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils", version= "=0.5.0-beta.0" } postgres = "0.19.3" regex = "1.5.5" diff --git a/pgx-tests/src/framework.rs b/pgx-tests/src/framework.rs index 01953610e..6897fbf7a 100644 --- a/pgx-tests/src/framework.rs +++ b/pgx-tests/src/framework.rs @@ -10,12 +10,12 @@ Use of this source code is governed by the MIT license that can be found in the use std::process::{Command, Stdio}; use once_cell::sync::Lazy; +use pgx_pg_config::{PgConfig, Pgx}; use std::sync::{Arc, Mutex}; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; use pgx::*; -use pgx_utils::pg_config::{PgConfig, Pgx}; use pgx_utils::{createdb, get_named_capture, get_target_dir}; use postgres::error::DbError; use postgres::Client; diff --git a/pgx-utils/Cargo.toml b/pgx-utils/Cargo.toml index 5b1f3f2d2..ca67c5d1d 100644 --- a/pgx-utils/Cargo.toml +++ b/pgx-utils/Cargo.toml @@ -17,6 +17,7 @@ owo-colors = "3.4.0" convert_case = "0.5.0" dirs = "4.0.0" env_proxy = "0.4.1" +pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" } proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] } quote = "1.0.18" regex = "1.5.5" diff --git a/pgx-utils/src/lib.rs b/pgx-utils/src/lib.rs index 5733f2db6..a5b201bea 100644 --- a/pgx-utils/src/lib.rs +++ b/pgx-utils/src/lib.rs @@ -7,9 +7,10 @@ All rights reserved. Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ -use crate::{pg_config::PgConfig, sql_entity_graph::PositioningRef}; +use crate::sql_entity_graph::PositioningRef; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; +use pgx_pg_config::PgConfig; use proc_macro2::{TokenStream, TokenTree}; use quote::{format_ident, quote, ToTokens, TokenStreamExt}; use serde_json::value::Value as JsonValue; @@ -24,7 +25,6 @@ use syn::{GenericArgument, ItemFn, PathArguments, ReturnType, Type, TypeParamBou mod pgx_pg_sys_stub; pub mod operator_common; -pub mod pg_config; pub mod rewriter; pub mod sql_entity_graph; @@ -42,8 +42,6 @@ pub mod __reexports { } pub const SUPPORTED_MAJOR_VERSIONS: &[u16] = &[10, 11, 12, 13, 14]; -pub static BASE_POSTGRES_PORT_NO: u16 = 28800; -pub static BASE_POSTGRES_TESTING_PORT_NO: u16 = 32200; pub fn get_target_dir() -> eyre::Result { let mut command = Command::new("cargo"); From a3da773f90520db4b40258006584f136dd9645c4 Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Mon, 22 Aug 2022 11:09:27 -0400 Subject: [PATCH 02/12] Moves "common operators" out of pgx-utils The only place they're seemingly used is in pgx-macros, so extracting them out of pgx-utils and putting them into macros might be ideal. --- pgx-macros/src/operators.rs | 150 +++++++++++++++++++++++++++++- pgx-utils/src/lib.rs | 1 - pgx-utils/src/operator_common.rs | 153 ------------------------------- 3 files changed, 146 insertions(+), 158 deletions(-) delete mode 100644 pgx-utils/src/operator_common.rs diff --git a/pgx-macros/src/operators.rs b/pgx-macros/src/operators.rs index 8c2594ea3..65e4c5ceb 100644 --- a/pgx-macros/src/operators.rs +++ b/pgx-macros/src/operators.rs @@ -6,11 +6,10 @@ All rights reserved. Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ -use pgx_utils::{ - operator_common::*, - sql_entity_graph::{PostgresHash, PostgresOrd}, -}; +use pgx_utils::sql_entity_graph::{PostgresHash, PostgresOrd}; +use proc_macro2::Ident; +use quote::quote; use quote::ToTokens; use syn::DeriveInput; @@ -48,3 +47,146 @@ pub(crate) fn impl_postgres_hash(ast: DeriveInput) -> syn::Result proc_macro2::TokenStream { + let pg_name = Ident::new( + &format!("{}_eq", type_name).to_lowercase(), + type_name.span(), + ); + quote! { + #[allow(non_snake_case)] + #[pg_operator(immutable, parallel_safe)] + #[opname(=)] + #[negator(<>)] + #[restrict(eqsel)] + #[join(eqjoinsel)] + #[merges] + #[hashes] + fn #pg_name(left: #type_name, right: #type_name) -> bool { + left == right + } + } +} + +pub fn ne(type_name: &Ident) -> proc_macro2::TokenStream { + let pg_name = Ident::new( + &format!("{}_ne", type_name).to_lowercase(), + type_name.span(), + ); + quote! { + #[allow(non_snake_case)] + #[pg_operator(immutable, parallel_safe)] + #[opname(<>)] + #[negator(=)] + #[restrict(neqsel)] + #[join(neqjoinsel)] + fn #pg_name(left: #type_name, right: #type_name) -> bool { + left != right + } + } +} + +pub fn lt(type_name: &Ident) -> proc_macro2::TokenStream { + let pg_name = Ident::new( + &format!("{}_lt", type_name).to_lowercase(), + type_name.span(), + ); + quote! { + #[allow(non_snake_case)] + #[pg_operator(immutable, parallel_safe)] + #[opname(<)] + #[negator(>=)] + #[commutator(>)] + #[restrict(scalarltsel)] + #[join(scalarltjoinsel)] + fn #pg_name(left: #type_name, right: #type_name) -> bool { + left < right + } + + } +} + +pub fn gt(type_name: &Ident) -> proc_macro2::TokenStream { + let pg_name = Ident::new( + &format!("{}_gt", type_name).to_lowercase(), + type_name.span(), + ); + quote! { + #[allow(non_snake_case)] + #[pg_operator(immutable, parallel_safe)] + #[opname(>)] + #[negator(<=)] + #[commutator(<)] + #[restrict(scalargtsel)] + #[join(scalargtjoinsel)] + fn #pg_name(left: #type_name, right: #type_name) -> bool { + left > right + } + } +} + +pub fn le(type_name: &Ident) -> proc_macro2::TokenStream { + let pg_name = Ident::new( + &format!("{}_le", type_name).to_lowercase(), + type_name.span(), + ); + quote! { + #[allow(non_snake_case)] + #[pg_operator(immutable, parallel_safe)] + #[opname(<=)] + #[negator(>)] + #[commutator(>=)] + #[restrict(scalarlesel)] + #[join(scalarlejoinsel)] + fn #pg_name(left: #type_name, right: #type_name) -> bool { + left <= right + } + } +} + +pub fn ge(type_name: &Ident) -> proc_macro2::TokenStream { + let pg_name = Ident::new( + &format!("{}_ge", type_name).to_lowercase(), + type_name.span(), + ); + quote! { + #[allow(non_snake_case)] + #[pg_operator(immutable, parallel_safe)] + #[opname(>=)] + #[negator(<)] + #[commutator(<=)] + #[restrict(scalargesel)] + #[join(scalargejoinsel)] + fn #pg_name(left: #type_name, right: #type_name) -> bool { + left >= right + } + } +} + +pub fn cmp(type_name: &Ident) -> proc_macro2::TokenStream { + let pg_name = Ident::new( + &format!("{}_cmp", type_name).to_lowercase(), + type_name.span(), + ); + quote! { + #[allow(non_snake_case)] + #[pg_extern(immutable, parallel_safe)] + fn #pg_name(left: #type_name, right: #type_name) -> i32 { + left.cmp(&right) as i32 + } + } +} + +pub fn hash(type_name: &Ident) -> proc_macro2::TokenStream { + let pg_name = Ident::new( + &format!("{}_hash", type_name).to_lowercase(), + type_name.span(), + ); + quote! { + #[allow(non_snake_case)] + #[pg_extern(immutable, parallel_safe)] + fn #pg_name(value: #type_name) -> i32 { + pgx::misc::pgx_seahash(&value) as i32 + } + } +} diff --git a/pgx-utils/src/lib.rs b/pgx-utils/src/lib.rs index a5b201bea..631f7ae14 100644 --- a/pgx-utils/src/lib.rs +++ b/pgx-utils/src/lib.rs @@ -24,7 +24,6 @@ use syn::{GenericArgument, ItemFn, PathArguments, ReturnType, Type, TypeParamBou mod pgx_pg_sys_stub; -pub mod operator_common; pub mod rewriter; pub mod sql_entity_graph; diff --git a/pgx-utils/src/operator_common.rs b/pgx-utils/src/operator_common.rs deleted file mode 100644 index 49878e32c..000000000 --- a/pgx-utils/src/operator_common.rs +++ /dev/null @@ -1,153 +0,0 @@ -/* -Portions Copyright 2019-2021 ZomboDB, LLC. -Portions Copyright 2021-2022 Technology Concepts & Design, Inc. - -All rights reserved. - -Use of this source code is governed by the MIT license that can be found in the LICENSE file. -*/ -use proc_macro2::Ident; -use quote::quote; - -pub fn eq(type_name: &Ident) -> proc_macro2::TokenStream { - let pg_name = Ident::new( - &format!("{}_eq", type_name).to_lowercase(), - type_name.span(), - ); - quote! { - #[allow(non_snake_case)] - #[pg_operator(immutable, parallel_safe)] - #[opname(=)] - #[negator(<>)] - #[restrict(eqsel)] - #[join(eqjoinsel)] - #[merges] - #[hashes] - fn #pg_name(left: #type_name, right: #type_name) -> bool { - left == right - } - } -} - -pub fn ne(type_name: &Ident) -> proc_macro2::TokenStream { - let pg_name = Ident::new( - &format!("{}_ne", type_name).to_lowercase(), - type_name.span(), - ); - quote! { - #[allow(non_snake_case)] - #[pg_operator(immutable, parallel_safe)] - #[opname(<>)] - #[negator(=)] - #[restrict(neqsel)] - #[join(neqjoinsel)] - fn #pg_name(left: #type_name, right: #type_name) -> bool { - left != right - } - } -} - -pub fn lt(type_name: &Ident) -> proc_macro2::TokenStream { - let pg_name = Ident::new( - &format!("{}_lt", type_name).to_lowercase(), - type_name.span(), - ); - quote! { - #[allow(non_snake_case)] - #[pg_operator(immutable, parallel_safe)] - #[opname(<)] - #[negator(>=)] - #[commutator(>)] - #[restrict(scalarltsel)] - #[join(scalarltjoinsel)] - fn #pg_name(left: #type_name, right: #type_name) -> bool { - left < right - } - - } -} - -pub fn gt(type_name: &Ident) -> proc_macro2::TokenStream { - let pg_name = Ident::new( - &format!("{}_gt", type_name).to_lowercase(), - type_name.span(), - ); - quote! { - #[allow(non_snake_case)] - #[pg_operator(immutable, parallel_safe)] - #[opname(>)] - #[negator(<=)] - #[commutator(<)] - #[restrict(scalargtsel)] - #[join(scalargtjoinsel)] - fn #pg_name(left: #type_name, right: #type_name) -> bool { - left > right - } - } -} - -pub fn le(type_name: &Ident) -> proc_macro2::TokenStream { - let pg_name = Ident::new( - &format!("{}_le", type_name).to_lowercase(), - type_name.span(), - ); - quote! { - #[allow(non_snake_case)] - #[pg_operator(immutable, parallel_safe)] - #[opname(<=)] - #[negator(>)] - #[commutator(>=)] - #[restrict(scalarlesel)] - #[join(scalarlejoinsel)] - fn #pg_name(left: #type_name, right: #type_name) -> bool { - left <= right - } - } -} - -pub fn ge(type_name: &Ident) -> proc_macro2::TokenStream { - let pg_name = Ident::new( - &format!("{}_ge", type_name).to_lowercase(), - type_name.span(), - ); - quote! { - #[allow(non_snake_case)] - #[pg_operator(immutable, parallel_safe)] - #[opname(>=)] - #[negator(<)] - #[commutator(<=)] - #[restrict(scalargesel)] - #[join(scalargejoinsel)] - fn #pg_name(left: #type_name, right: #type_name) -> bool { - left >= right - } - } -} - -pub fn cmp(type_name: &Ident) -> proc_macro2::TokenStream { - let pg_name = Ident::new( - &format!("{}_cmp", type_name).to_lowercase(), - type_name.span(), - ); - quote! { - #[allow(non_snake_case)] - #[pg_extern(immutable, parallel_safe)] - fn #pg_name(left: #type_name, right: #type_name) -> i32 { - left.cmp(&right) as i32 - } - } -} - -pub fn hash(type_name: &Ident) -> proc_macro2::TokenStream { - let pg_name = Ident::new( - &format!("{}_hash", type_name).to_lowercase(), - type_name.span(), - ); - quote! { - #[allow(non_snake_case)] - #[pg_extern(immutable, parallel_safe)] - fn #pg_name(value: #type_name) -> i32 { - pgx::misc::pgx_seahash(&value) as i32 - } - } -} From 099b3ff3244680e1c3b89122f6baa987a331b965 Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Mon, 22 Aug 2022 12:00:26 -0400 Subject: [PATCH 03/12] Extracts out paths-related functions from utils --- Cargo.lock | 13 ++++++++ Cargo.toml | 1 + cargo-pgx/Cargo.toml | 1 + cargo-pgx/src/command/init.rs | 3 +- cargo-pgx/src/command/install.rs | 3 +- cargo-pgx/src/command/package.rs | 2 +- cargo-pgx/src/command/schema.rs | 3 +- cargo-pgx/src/command/test.rs | 2 +- pgx-paths/Cargo.toml | 20 +++++++++++++ pgx-paths/src/lib.rs | 51 ++++++++++++++++++++++++++++++++ pgx-pg-sys/Cargo.toml | 1 + pgx-pg-sys/build.rs | 2 +- pgx-tests/Cargo.toml | 1 + pgx-tests/src/framework.rs | 3 +- pgx-utils/src/lib.rs | 41 ------------------------- 15 files changed, 99 insertions(+), 48 deletions(-) create mode 100644 pgx-paths/Cargo.toml create mode 100644 pgx-paths/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 844d3dcee..1a1f5b71e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -294,6 +294,7 @@ dependencies = [ "object", "once_cell", "owo-colors", + "pgx-paths", "pgx-pg-config", "pgx-utils", "proc-macro2", @@ -1448,6 +1449,16 @@ dependencies = [ "unescape", ] +[[package]] +name = "pgx-paths" +version = "0.5.0-beta.0" +dependencies = [ + "eyre", + "serde", + "serde_derive", + "serde_json", +] + [[package]] name = "pgx-pg-config" version = "0.5.0-beta.0" @@ -1477,6 +1488,7 @@ dependencies = [ "once_cell", "owo-colors", "pgx-macros", + "pgx-paths", "pgx-pg-config", "pgx-utils", "proc-macro2", @@ -1497,6 +1509,7 @@ dependencies = [ "owo-colors", "pgx", "pgx-macros", + "pgx-paths", "pgx-pg-config", "pgx-utils", "postgres", diff --git a/Cargo.toml b/Cargo.toml index 9885e0da7..122697fe4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ resolver = "2" members = [ "cargo-pgx", "pgx", + "pgx-paths", "pgx-macros", "pgx-pg-config", "pgx-pg-sys", diff --git a/cargo-pgx/Cargo.toml b/cargo-pgx/Cargo.toml index dbf66c49a..7fd22affc 100644 --- a/cargo-pgx/Cargo.toml +++ b/cargo-pgx/Cargo.toml @@ -24,6 +24,7 @@ semver = "1.0.9" owo-colors = { version = "3.4.0", features = [ "supports-colors" ] } env_proxy = "0.4.1" num_cpus = "1.13.1" +pgx-paths = { path = "../pgx-paths", version = "=0.5.0-beta.0" } pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils", version = "=0.5.0-beta.0" } proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] } diff --git a/cargo-pgx/src/command/init.rs b/cargo-pgx/src/command/init.rs index e60485c9b..bda756656 100644 --- a/cargo-pgx/src/command/init.rs +++ b/cargo-pgx/src/command/init.rs @@ -12,8 +12,9 @@ use crate::command::version::pgx_default; use crate::CommandExecute; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; +use pgx_paths::prefix_path; use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; -use pgx_utils::{prefix_path, SUPPORTED_MAJOR_VERSIONS}; +use pgx_utils::SUPPORTED_MAJOR_VERSIONS; use rayon::prelude::*; use std::collections::HashMap; diff --git a/cargo-pgx/src/command/install.rs b/cargo-pgx/src/command/install.rs index b62175f8a..9b709367b 100644 --- a/cargo-pgx/src/command/install.rs +++ b/cargo-pgx/src/command/install.rs @@ -14,8 +14,9 @@ use crate::{ use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; +use pgx_paths::get_target_dir; use pgx_pg_config::PgConfig; -use pgx_utils::{get_target_dir, versioned_so_name}; +use pgx_utils::versioned_so_name; use std::{ io::BufReader, path::{Path, PathBuf}, diff --git a/cargo-pgx/src/command/package.rs b/cargo-pgx/src/command/package.rs index 820a90a37..bf65aaf33 100644 --- a/cargo-pgx/src/command/package.rs +++ b/cargo-pgx/src/command/package.rs @@ -13,8 +13,8 @@ use crate::{ }; use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; +use pgx_paths::get_target_dir; use pgx_pg_config::PgConfig; -use pgx_utils::get_target_dir; use std::path::{Path, PathBuf}; /// Create an installation package directory. diff --git a/cargo-pgx/src/command/schema.rs b/cargo-pgx/src/command/schema.rs index acf4819c5..2d7aea59f 100644 --- a/cargo-pgx/src/command/schema.rs +++ b/cargo-pgx/src/command/schema.rs @@ -18,6 +18,7 @@ use eyre::{eyre, WrapErr}; use object::Object; use once_cell::sync::OnceCell; use owo_colors::OwoColorize; +use pgx_paths::get_target_dir; use pgx_pg_config::{PgConfig, Pgx}; use pgx_utils::{ sql_entity_graph::{PgxSql, SqlGraphEntity}, @@ -178,7 +179,7 @@ pub(crate) fn generate_schema( let flags = std::env::var("PGX_BUILD_FLAGS").unwrap_or_default(); - let mut target_dir_with_profile = pgx_utils::get_target_dir()?; + let mut target_dir_with_profile = get_target_dir()?; target_dir_with_profile.push(if is_release { "release" } else { "debug" }); // First, build the SQL generator so we can get a look at the symbol table diff --git a/cargo-pgx/src/command/test.rs b/cargo-pgx/src/command/test.rs index 8c68c3b78..c8fc370b0 100644 --- a/cargo-pgx/src/command/test.rs +++ b/cargo-pgx/src/command/test.rs @@ -9,8 +9,8 @@ Use of this source code is governed by the MIT license that can be found in the use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; +use pgx_paths::get_target_dir; use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; -use pgx_utils::get_target_dir; use std::{ path::{Path, PathBuf}, process::{Command, Stdio}, diff --git a/pgx-paths/Cargo.toml b/pgx-paths/Cargo.toml new file mode 100644 index 000000000..6ac667df2 --- /dev/null +++ b/pgx-paths/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "pgx-paths" +edition = "2021" +version = "0.5.0-beta.0" +authors = ["ZomboDB, LLC "] +license = "MIT" +description = "A crate containing path and directory helpers for 'pgx'" +homepage = "https://github.com/zombodb/pgx" +repository = "https://github.com/zombodb/pgx" +#documentation = "https://docs.rs/pgx-utils" +readme = "README.md" +rust-version = "1.58" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +eyre = "0.6.8" +serde = { version = "1.0.137", features = [ "derive" ] } +serde_derive = "1.0.137" +serde_json = "1.0.81" diff --git a/pgx-paths/src/lib.rs b/pgx-paths/src/lib.rs new file mode 100644 index 000000000..90304137f --- /dev/null +++ b/pgx-paths/src/lib.rs @@ -0,0 +1,51 @@ +/* +Portions Copyright 2019-2021 ZomboDB, LLC. +Portions Copyright 2021-2022 Technology Concepts & Design, Inc. + +All rights reserved. + +Use of this source code is governed by the MIT license that can be found in the LICENSE file. +*/ + +use eyre::{eyre, WrapErr}; +use serde_json::value::Value as JsonValue; +use std::{path::PathBuf, process::Command}; + +pub fn get_target_dir() -> eyre::Result { + let mut command = Command::new("cargo"); + command + .arg("metadata") + .arg("--format-version=1") + .arg("--no-deps"); + let output = command + .output() + .wrap_err("Unable to get target directory from `cargo metadata`")?; + if !output.status.success() { + return Err(eyre!( + "'cargo metadata' failed with exit code: {}", + output.status + )); + } + + let json: JsonValue = + serde_json::from_slice(&output.stdout).wrap_err("Invalid `cargo metada` response")?; + let target_dir = json.get("target_directory"); + match target_dir { + Some(JsonValue::String(target_dir)) => Ok(target_dir.into()), + v => Err(eyre!( + "could not read target dir from `cargo metadata` got: {:?}", + v, + )), + } +} + +pub fn prefix_path>(dir: P) -> String { + let mut path = std::env::split_paths(&std::env::var_os("PATH").expect("failed to get $PATH")) + .collect::>(); + + path.insert(0, dir.into()); + std::env::join_paths(path) + .expect("failed to join paths") + .into_string() + .expect("failed to construct path") +} diff --git a/pgx-pg-sys/Cargo.toml b/pgx-pg-sys/Cargo.toml index 49e8de37b..43b9109b6 100644 --- a/pgx-pg-sys/Cargo.toml +++ b/pgx-pg-sys/Cargo.toml @@ -40,6 +40,7 @@ bindgen = { version = "0.59.2", default-features = false, features = ["runtime"] build-deps = "0.1.4" owo-colors = "3.4.0" num_cpus = "1.13.1" +pgx-paths = { path = "../pgx-paths/", version = "=0.5.0-beta.0" } pgx-pg-config= { path = "../pgx-pg-config/", version = "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils/", version = "=0.5.0-beta.0" } proc-macro2 = "1.0.39" diff --git a/pgx-pg-sys/build.rs b/pgx-pg-sys/build.rs index 9e79a4870..8b14463ea 100644 --- a/pgx-pg-sys/build.rs +++ b/pgx-pg-sys/build.rs @@ -11,8 +11,8 @@ extern crate build_deps; use bindgen::callbacks::MacroParsingBehavior; use eyre::{eyre, WrapErr}; +use pgx_paths::prefix_path; use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; -use pgx_utils::prefix_path; use pgx_utils::rewriter::PgGuardRewriter; use quote::{quote, ToTokens}; use rayon::prelude::*; diff --git a/pgx-tests/Cargo.toml b/pgx-tests/Cargo.toml index 645d0390f..c316eb30d 100644 --- a/pgx-tests/Cargo.toml +++ b/pgx-tests/Cargo.toml @@ -36,6 +36,7 @@ owo-colors = "3.4.0" once_cell = "1.10.0" libc = "0.2.126" pgx = { path = "../pgx", default-features = false, version= "=0.5.0-beta.0" } +pgx-paths = { path = "../pgx-paths", version= "=0.5.0-beta.0" } pgx-macros = { path = "../pgx-macros", version= "=0.5.0-beta.0" } pgx-pg-config = { path = "../pgx-pg-config", version= "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils", version= "=0.5.0-beta.0" } diff --git a/pgx-tests/src/framework.rs b/pgx-tests/src/framework.rs index 6897fbf7a..a0f0fd19d 100644 --- a/pgx-tests/src/framework.rs +++ b/pgx-tests/src/framework.rs @@ -10,13 +10,14 @@ Use of this source code is governed by the MIT license that can be found in the use std::process::{Command, Stdio}; use once_cell::sync::Lazy; +use pgx_paths::get_target_dir; use pgx_pg_config::{PgConfig, Pgx}; use std::sync::{Arc, Mutex}; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; use pgx::*; -use pgx_utils::{createdb, get_named_capture, get_target_dir}; +use pgx_utils::{createdb, get_named_capture}; use postgres::error::DbError; use postgres::Client; use std::collections::HashMap; diff --git a/pgx-utils/src/lib.rs b/pgx-utils/src/lib.rs index 631f7ae14..96af5c68d 100644 --- a/pgx-utils/src/lib.rs +++ b/pgx-utils/src/lib.rs @@ -13,10 +13,8 @@ use owo_colors::OwoColorize; use pgx_pg_config::PgConfig; use proc_macro2::{TokenStream, TokenTree}; use quote::{format_ident, quote, ToTokens, TokenStreamExt}; -use serde_json::value::Value as JsonValue; use std::{ collections::HashSet, - path::PathBuf, process::{Command, Stdio}, str::FromStr, }; @@ -42,45 +40,6 @@ pub mod __reexports { pub const SUPPORTED_MAJOR_VERSIONS: &[u16] = &[10, 11, 12, 13, 14]; -pub fn get_target_dir() -> eyre::Result { - let mut command = Command::new("cargo"); - command - .arg("metadata") - .arg("--format-version=1") - .arg("--no-deps"); - let output = command - .output() - .wrap_err("Unable to get target directory from `cargo metadata`")?; - if !output.status.success() { - return Err(eyre!( - "'cargo metadata' failed with exit code: {}", - output.status - )); - } - - let json: JsonValue = - serde_json::from_slice(&output.stdout).wrap_err("Invalid `cargo metada` response")?; - let target_dir = json.get("target_directory"); - match target_dir { - Some(JsonValue::String(target_dir)) => Ok(target_dir.into()), - v => Err(eyre!( - "could not read target dir from `cargo metadata` got: {:?}", - v, - )), - } -} - -pub fn prefix_path>(dir: P) -> String { - let mut path = std::env::split_paths(&std::env::var_os("PATH").expect("failed to get $PATH")) - .collect::>(); - - path.insert(0, dir.into()); - std::env::join_paths(path) - .expect("failed to join paths") - .into_string() - .expect("failed to construct path") -} - pub fn createdb( pg_config: &PgConfig, dbname: &str, From 9b04bd0bbf14e83f8633bac287a721e1aac3f06f Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Mon, 22 Aug 2022 12:21:05 -0400 Subject: [PATCH 04/12] Extract createdb methods out of pgx-utils --- cargo-pgx/src/command/connect.rs | 3 +- cargo-pgx/src/command/init.rs | 3 +- cargo-pgx/src/command/run.rs | 3 +- cargo-pgx/src/manifest.rs | 2 +- pgx-pg-config/src/lib.rs | 83 +++++++++++++++++++++++++++++ pgx-pg-sys/build.rs | 6 +-- pgx-tests/src/framework.rs | 4 +- pgx-utils/src/lib.rs | 91 +------------------------------- 8 files changed, 93 insertions(+), 102 deletions(-) diff --git a/cargo-pgx/src/command/connect.rs b/cargo-pgx/src/command/connect.rs index e7dd73b55..12fdd11e1 100644 --- a/cargo-pgx/src/command/connect.rs +++ b/cargo-pgx/src/command/connect.rs @@ -14,8 +14,7 @@ use crate::{ use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_pg_config::{PgConfig, Pgx}; -use pgx_utils::createdb; +use pgx_pg_config::{createdb, PgConfig, Pgx}; use std::path::PathBuf; /// Connect, via psql, to a Postgres instance diff --git a/cargo-pgx/src/command/init.rs b/cargo-pgx/src/command/init.rs index bda756656..9cbe033a5 100644 --- a/cargo-pgx/src/command/init.rs +++ b/cargo-pgx/src/command/init.rs @@ -13,8 +13,7 @@ use crate::CommandExecute; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; use pgx_paths::prefix_path; -use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; -use pgx_utils::SUPPORTED_MAJOR_VERSIONS; +use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS}; use rayon::prelude::*; use std::collections::HashMap; diff --git a/cargo-pgx/src/command/run.rs b/cargo-pgx/src/command/run.rs index 35a5d4f64..87569eaf2 100644 --- a/cargo-pgx/src/command/run.rs +++ b/cargo-pgx/src/command/run.rs @@ -16,8 +16,7 @@ use crate::{ use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_pg_config::{PgConfig, Pgx}; -use pgx_utils::createdb; +use pgx_pg_config::{createdb, PgConfig, Pgx}; use std::{os::unix::process::CommandExt, path::Path, process::Command}; /// Compile/install extension to a pgx-managed Postgres instance and start psql #[derive(clap::Args, Debug)] diff --git a/cargo-pgx/src/manifest.rs b/cargo-pgx/src/manifest.rs index 201ec9309..0d8547228 100644 --- a/cargo-pgx/src/manifest.rs +++ b/cargo-pgx/src/manifest.rs @@ -9,7 +9,7 @@ Use of this source code is governed by the MIT license that can be found in the use cargo_metadata::Metadata; use cargo_toml::Manifest; use eyre::eyre; -use pgx_utils::SUPPORTED_MAJOR_VERSIONS; +use pgx_pg_config::SUPPORTED_MAJOR_VERSIONS; use std::path::PathBuf; #[tracing::instrument(skip_all)] diff --git a/pgx-pg-config/src/lib.rs b/pgx-pg-config/src/lib.rs index eef02315e..9f4282ad8 100644 --- a/pgx-pg-config/src/lib.rs +++ b/pgx-pg-config/src/lib.rs @@ -11,6 +11,7 @@ use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; use serde_derive::{Deserialize, Serialize}; use std::fmt::{self, Display, Formatter}; +use std::process::Stdio; use std::{ collections::HashMap, io::ErrorKind, @@ -412,3 +413,85 @@ impl Pgx { Ok(path) } } + +pub const SUPPORTED_MAJOR_VERSIONS: &[u16] = &[10, 11, 12, 13, 14]; + +pub fn createdb( + pg_config: &PgConfig, + dbname: &str, + is_test: bool, + if_not_exists: bool, +) -> eyre::Result { + if if_not_exists && does_db_exist(pg_config, dbname)? { + return Ok(false); + } + + println!("{} database {}", " Creating".bold().green(), dbname); + let mut command = Command::new(pg_config.createdb_path()?); + command + .env_remove("PGDATABASE") + .env_remove("PGHOST") + .env_remove("PGPORT") + .env_remove("PGUSER") + .arg("-h") + .arg(pg_config.host()) + .arg("-p") + .arg(if is_test { + pg_config.test_port()?.to_string() + } else { + pg_config.port()?.to_string() + }) + .arg(dbname) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + let command_str = format!("{:?}", command); + + let output = command.output()?; + + if !output.status.success() { + return Err(eyre!( + "problem running createdb: {}\n\n{}{}", + command_str, + String::from_utf8(output.stdout).unwrap(), + String::from_utf8(output.stderr).unwrap() + )); + } + + Ok(true) +} + +fn does_db_exist(pg_config: &PgConfig, dbname: &str) -> eyre::Result { + let mut command = Command::new(pg_config.psql_path()?); + command + .arg("-XqAt") + .env_remove("PGUSER") + .arg("-h") + .arg(pg_config.host()) + .arg("-p") + .arg(pg_config.port()?.to_string()) + .arg("template1") + .arg("-c") + .arg(&format!( + "select count(*) from pg_database where datname = '{}';", + dbname.replace("'", "''") + )) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + + let command_str = format!("{:?}", command); + let output = command.output()?; + + if !output.status.success() { + return Err(eyre!( + "problem checking if database '{}' exists: {}\n\n{}{}", + dbname, + command_str, + String::from_utf8(output.stdout).unwrap(), + String::from_utf8(output.stderr).unwrap() + )); + } else { + let count = i32::from_str(&String::from_utf8(output.stdout).unwrap().trim()) + .wrap_err("result is not a number")?; + Ok(count > 0) + } +} diff --git a/pgx-pg-sys/build.rs b/pgx-pg-sys/build.rs index 8b14463ea..32fd51aaf 100644 --- a/pgx-pg-sys/build.rs +++ b/pgx-pg-sys/build.rs @@ -12,7 +12,7 @@ extern crate build_deps; use bindgen::callbacks::MacroParsingBehavior; use eyre::{eyre, WrapErr}; use pgx_paths::prefix_path; -use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; +use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS}; use pgx_utils::rewriter::PgGuardRewriter; use quote::{quote, ToTokens}; use rayon::prelude::*; @@ -110,7 +110,7 @@ fn main() -> color_eyre::Result<()> { .collect::>>()? } else { let mut found = None; - for version in pgx_utils::SUPPORTED_MAJOR_VERSIONS { + for version in SUPPORTED_MAJOR_VERSIONS { if let Err(_) = std::env::var(&format!("CARGO_FEATURE_PG{}", version)) { continue; } @@ -122,7 +122,7 @@ fn main() -> color_eyre::Result<()> { let found = found.ok_or_else(|| { eyre!( "Did not find `pg$VERSION` feature. `pgx-pg-sys` requires one of {} to be set", - pgx_utils::SUPPORTED_MAJOR_VERSIONS + SUPPORTED_MAJOR_VERSIONS .iter() .map(|x| format!("`pg{}`", x)) .collect::>() diff --git a/pgx-tests/src/framework.rs b/pgx-tests/src/framework.rs index a0f0fd19d..ac572b70a 100644 --- a/pgx-tests/src/framework.rs +++ b/pgx-tests/src/framework.rs @@ -11,13 +11,13 @@ use std::process::{Command, Stdio}; use once_cell::sync::Lazy; use pgx_paths::get_target_dir; -use pgx_pg_config::{PgConfig, Pgx}; +use pgx_pg_config::{createdb, PgConfig, Pgx}; use std::sync::{Arc, Mutex}; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; use pgx::*; -use pgx_utils::{createdb, get_named_capture}; +use pgx_utils::get_named_capture; use postgres::error::DbError; use postgres::Client; use std::collections::HashMap; diff --git a/pgx-utils/src/lib.rs b/pgx-utils/src/lib.rs index 96af5c68d..7d7030024 100644 --- a/pgx-utils/src/lib.rs +++ b/pgx-utils/src/lib.rs @@ -8,16 +8,9 @@ Use of this source code is governed by the MIT license that can be found in the */ use crate::sql_entity_graph::PositioningRef; -use eyre::{eyre, WrapErr}; -use owo_colors::OwoColorize; -use pgx_pg_config::PgConfig; use proc_macro2::{TokenStream, TokenTree}; use quote::{format_ident, quote, ToTokens, TokenStreamExt}; -use std::{ - collections::HashSet, - process::{Command, Stdio}, - str::FromStr, -}; +use std::collections::HashSet; use syn::{GenericArgument, ItemFn, PathArguments, ReturnType, Type, TypeParamBound}; mod pgx_pg_sys_stub; @@ -38,88 +31,6 @@ pub mod __reexports { } } -pub const SUPPORTED_MAJOR_VERSIONS: &[u16] = &[10, 11, 12, 13, 14]; - -pub fn createdb( - pg_config: &PgConfig, - dbname: &str, - is_test: bool, - if_not_exists: bool, -) -> eyre::Result { - if if_not_exists && does_db_exist(pg_config, dbname)? { - return Ok(false); - } - - println!("{} database {}", " Creating".bold().green(), dbname); - let mut command = Command::new(pg_config.createdb_path()?); - command - .env_remove("PGDATABASE") - .env_remove("PGHOST") - .env_remove("PGPORT") - .env_remove("PGUSER") - .arg("-h") - .arg(pg_config.host()) - .arg("-p") - .arg(if is_test { - pg_config.test_port()?.to_string() - } else { - pg_config.port()?.to_string() - }) - .arg(dbname) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()); - let command_str = format!("{:?}", command); - - let output = command.output()?; - - if !output.status.success() { - return Err(eyre!( - "problem running createdb: {}\n\n{}{}", - command_str, - String::from_utf8(output.stdout).unwrap(), - String::from_utf8(output.stderr).unwrap() - )); - } - - Ok(true) -} - -fn does_db_exist(pg_config: &PgConfig, dbname: &str) -> eyre::Result { - let mut command = Command::new(pg_config.psql_path()?); - command - .arg("-XqAt") - .env_remove("PGUSER") - .arg("-h") - .arg(pg_config.host()) - .arg("-p") - .arg(pg_config.port()?.to_string()) - .arg("template1") - .arg("-c") - .arg(&format!( - "select count(*) from pg_database where datname = '{}';", - dbname.replace("'", "''") - )) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()); - - let command_str = format!("{:?}", command); - let output = command.output()?; - - if !output.status.success() { - return Err(eyre!( - "problem checking if database '{}' exists: {}\n\n{}{}", - dbname, - command_str, - String::from_utf8(output.stdout).unwrap(), - String::from_utf8(output.stderr).unwrap() - )); - } else { - let count = i32::from_str(&String::from_utf8(output.stdout).unwrap().trim()) - .wrap_err("result is not a number")?; - Ok(count > 0) - } -} - pub fn get_named_capture( regex: ®ex::Regex, name: &'static str, From d47154545210b0f10b5ebc716731dee95d68ee5e Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Mon, 22 Aug 2022 12:32:46 -0400 Subject: [PATCH 05/12] Extracts out get_named_capture out of utils --- pgx-tests/src/framework.rs | 21 +++++++++++++++------ pgx-tests/src/tests/struct_type_tests.rs | 3 ++- pgx-utils/src/lib.rs | 11 ----------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/pgx-tests/src/framework.rs b/pgx-tests/src/framework.rs index ac572b70a..07278e485 100644 --- a/pgx-tests/src/framework.rs +++ b/pgx-tests/src/framework.rs @@ -9,21 +9,19 @@ Use of this source code is governed by the MIT license that can be found in the use std::process::{Command, Stdio}; -use once_cell::sync::Lazy; -use pgx_paths::get_target_dir; -use pgx_pg_config::{createdb, PgConfig, Pgx}; -use std::sync::{Arc, Mutex}; - use eyre::{eyre, WrapErr}; +use once_cell::sync::Lazy; use owo_colors::OwoColorize; use pgx::*; -use pgx_utils::get_named_capture; +use pgx_paths::get_target_dir; +use pgx_pg_config::{createdb, PgConfig, Pgx}; use postgres::error::DbError; use postgres::Client; use std::collections::HashMap; use std::fmt::Write as _; use std::io::{BufRead, BufReader, Write}; use std::path::PathBuf; +use std::sync::{Arc, Mutex}; type LogLines = Arc>>>; @@ -543,3 +541,14 @@ fn get_pg_user() -> String { std::env::var("USER") .unwrap_or_else(|_| panic!("USER environment var is unset or invalid UTF-8")) } + +pub fn get_named_capture( + regex: ®ex::Regex, + name: &'static str, + against: &str, +) -> Option { + match regex.captures(against) { + Some(cap) => Some(cap[name].to_string()), + None => None, + } +} diff --git a/pgx-tests/src/tests/struct_type_tests.rs b/pgx-tests/src/tests/struct_type_tests.rs index ee8e4ffee..3722b77ac 100644 --- a/pgx-tests/src/tests/struct_type_tests.rs +++ b/pgx-tests/src/tests/struct_type_tests.rs @@ -9,7 +9,8 @@ Use of this source code is governed by the MIT license that can be found in the use pgx::stringinfo::StringInfo; use pgx::*; -use pgx_utils::get_named_capture; + +use crate::get_named_capture; #[derive(Debug)] #[repr(C)] diff --git a/pgx-utils/src/lib.rs b/pgx-utils/src/lib.rs index 7d7030024..7b73eeb8c 100644 --- a/pgx-utils/src/lib.rs +++ b/pgx-utils/src/lib.rs @@ -31,17 +31,6 @@ pub mod __reexports { } } -pub fn get_named_capture( - regex: ®ex::Regex, - name: &'static str, - against: &str, -) -> Option { - match regex.captures(against) { - Some(cap) => Some(cap[name].to_string()), - None => None, - } -} - #[derive(Debug, Hash, Eq, PartialEq, Clone, PartialOrd, Ord)] pub enum ExternArgs { Immutable, From 70e3c9659bbef2f9082ab899aa1576f780ba9623 Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Mon, 22 Aug 2022 12:45:06 -0400 Subject: [PATCH 06/12] Extract versioned_so_name out of utils --- Cargo.lock | 1 + cargo-pgx/src/command/install.rs | 3 +-- pgx-paths/src/lib.rs | 4 ++++ pgx-utils/Cargo.toml | 1 + pgx-utils/src/lib.rs | 4 ---- pgx-utils/src/sql_entity_graph/pgx_sql.rs | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a1f5b71e..b183e3a65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1532,6 +1532,7 @@ dependencies = [ "eyre", "owo-colors", "petgraph", + "pgx-paths", "pgx-pg-config", "prettyplease", "proc-macro2", diff --git a/cargo-pgx/src/command/install.rs b/cargo-pgx/src/command/install.rs index 9b709367b..7e78cd0d5 100644 --- a/cargo-pgx/src/command/install.rs +++ b/cargo-pgx/src/command/install.rs @@ -14,9 +14,8 @@ use crate::{ use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_paths::get_target_dir; +use pgx_paths::{get_target_dir, versioned_so_name}; use pgx_pg_config::PgConfig; -use pgx_utils::versioned_so_name; use std::{ io::BufReader, path::{Path, PathBuf}, diff --git a/pgx-paths/src/lib.rs b/pgx-paths/src/lib.rs index 90304137f..2c77eda49 100644 --- a/pgx-paths/src/lib.rs +++ b/pgx-paths/src/lib.rs @@ -49,3 +49,7 @@ pub fn prefix_path>(dir: P) -> String { .into_string() .expect("failed to construct path") } + +pub fn versioned_so_name(extension_name: &str, extension_version: &str) -> String { + format!("{}-{}", extension_name, extension_version) +} diff --git a/pgx-utils/Cargo.toml b/pgx-utils/Cargo.toml index ca67c5d1d..e0d3f4d50 100644 --- a/pgx-utils/Cargo.toml +++ b/pgx-utils/Cargo.toml @@ -17,6 +17,7 @@ owo-colors = "3.4.0" convert_case = "0.5.0" dirs = "4.0.0" env_proxy = "0.4.1" +pgx-paths = { path = "../pgx-paths", version = "=0.5.0-beta.0" } pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" } proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] } quote = "1.0.18" diff --git a/pgx-utils/src/lib.rs b/pgx-utils/src/lib.rs index 7b73eeb8c..2b0b79996 100644 --- a/pgx-utils/src/lib.rs +++ b/pgx-utils/src/lib.rs @@ -420,10 +420,6 @@ pub fn staticize_lifetimes(value: &mut syn::Type) { } } -pub fn versioned_so_name(extension_name: &str, extension_version: &str) -> String { - format!("{}-{}", extension_name, extension_version) -} - /// Roughly `pgx::pg_sys::NAMEDATALEN` /// /// Technically it **should** be that exactly, however this is `pgx-utils` and a this data is used at macro time. diff --git a/pgx-utils/src/sql_entity_graph/pgx_sql.rs b/pgx-utils/src/sql_entity_graph/pgx_sql.rs index 9adc1c106..b3a6dda6a 100644 --- a/pgx-utils/src/sql_entity_graph/pgx_sql.rs +++ b/pgx-utils/src/sql_entity_graph/pgx_sql.rs @@ -7,6 +7,7 @@ All rights reserved. Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ use eyre::{eyre, WrapErr}; +use pgx_paths::versioned_so_name; use std::{any::TypeId, collections::HashMap, fmt::Debug, path::Path}; use owo_colors::{OwoColorize, XtermColors}; @@ -32,7 +33,6 @@ use crate::sql_entity_graph::{ to_sql::ToSql, SqlGraphEntity, SqlGraphIdentifier, }; -use crate::versioned_so_name; use super::pg_extern::entity::PgExternReturnEntityIteratedItem; From 38311f9b133a6b7cbd3216dc34c761e50da64557 Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Mon, 22 Aug 2022 17:19:24 -0400 Subject: [PATCH 07/12] Extracts pgx-pg-sys-stub out of utils --- Cargo.lock | 11 ++++++++++ Cargo.toml | 1 + cargo-pgx/Cargo.toml | 1 + cargo-pgx/src/command/schema.rs | 6 ++---- pgx-pg-sys-stub/Cargo.toml | 20 +++++++++++++++++++ .../mod.rs => pgx-pg-sys-stub/src/lib.rs | 0 pgx-utils/src/lib.rs | 4 ---- 7 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 pgx-pg-sys-stub/Cargo.toml rename pgx-utils/src/pgx_pg_sys_stub/mod.rs => pgx-pg-sys-stub/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index b183e3a65..445eee45e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -296,6 +296,7 @@ dependencies = [ "owo-colors", "pgx-paths", "pgx-pg-config", + "pgx-pg-sys-stub", "pgx-utils", "proc-macro2", "quote", @@ -1499,6 +1500,16 @@ dependencies = [ "syn", ] +[[package]] +name = "pgx-pg-sys-stub" +version = "0.5.0-beta.0" +dependencies = [ + "eyre", + "prettyplease", + "syn", + "tracing", +] + [[package]] name = "pgx-tests" version = "0.5.0-beta.0" diff --git a/Cargo.toml b/Cargo.toml index 122697fe4..589f9f0df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ "pgx-macros", "pgx-pg-config", "pgx-pg-sys", + "pgx-pg-sys-stub", "pgx-tests", "pgx-utils", "pgx-examples/aggregate", diff --git a/cargo-pgx/Cargo.toml b/cargo-pgx/Cargo.toml index 7fd22affc..f5758ff34 100644 --- a/cargo-pgx/Cargo.toml +++ b/cargo-pgx/Cargo.toml @@ -26,6 +26,7 @@ env_proxy = "0.4.1" num_cpus = "1.13.1" pgx-paths = { path = "../pgx-paths", version = "=0.5.0-beta.0" } pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" } +pgx-pg-sys-stub = { path = "../pgx-pg-sys-stub", version = "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils", version = "=0.5.0-beta.0" } proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] } quote = "1.0.18" diff --git a/cargo-pgx/src/command/schema.rs b/cargo-pgx/src/command/schema.rs index 2d7aea59f..974dcca62 100644 --- a/cargo-pgx/src/command/schema.rs +++ b/cargo-pgx/src/command/schema.rs @@ -20,10 +20,8 @@ use once_cell::sync::OnceCell; use owo_colors::OwoColorize; use pgx_paths::get_target_dir; use pgx_pg_config::{PgConfig, Pgx}; -use pgx_utils::{ - sql_entity_graph::{PgxSql, SqlGraphEntity}, - PgxPgSysStub, -}; +use pgx_pg_sys_stub::PgxPgSysStub; +use pgx_utils::sql_entity_graph::{PgxSql, SqlGraphEntity}; use std::{ collections::HashSet, hash::{Hash, Hasher}, diff --git a/pgx-pg-sys-stub/Cargo.toml b/pgx-pg-sys-stub/Cargo.toml new file mode 100644 index 000000000..6b4f1b9d8 --- /dev/null +++ b/pgx-pg-sys-stub/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "pgx-pg-sys-stub" +edition = "2021" +version = "0.5.0-beta.0" +authors = ["ZomboDB, LLC "] +license = "MIT" +description = "A Postgres pg_config wrapper for 'pgx'" +homepage = "https://github.com/zombodb/pgx" +repository = "https://github.com/zombodb/pgx" +#documentation = "https://docs.rs/pgx-utils" +readme = "README.md" +rust-version = "1.58" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +eyre = "0.6.8" +prettyplease = "0.1.10" +syn = { version = "1.0.95", features = [ "extra-traits", "full", "fold", "parsing" ] } +tracing = "0.1.34" diff --git a/pgx-utils/src/pgx_pg_sys_stub/mod.rs b/pgx-pg-sys-stub/src/lib.rs similarity index 100% rename from pgx-utils/src/pgx_pg_sys_stub/mod.rs rename to pgx-pg-sys-stub/src/lib.rs diff --git a/pgx-utils/src/lib.rs b/pgx-utils/src/lib.rs index 2b0b79996..24bfd4e4b 100644 --- a/pgx-utils/src/lib.rs +++ b/pgx-utils/src/lib.rs @@ -13,13 +13,9 @@ use quote::{format_ident, quote, ToTokens, TokenStreamExt}; use std::collections::HashSet; use syn::{GenericArgument, ItemFn, PathArguments, ReturnType, Type, TypeParamBound}; -mod pgx_pg_sys_stub; - pub mod rewriter; pub mod sql_entity_graph; -pub use pgx_pg_sys_stub::PgxPgSysStub; - #[doc(hidden)] pub mod __reexports { pub use eyre; From 25e4aac58c24a70f8bba4a6e4e2d782569082c4e Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Mon, 22 Aug 2022 17:41:38 -0400 Subject: [PATCH 08/12] Remove unused deps as per `cargo udeps` --- Cargo.lock | 8 -------- pgx-pg-config/Cargo.toml | 2 -- pgx-utils/Cargo.toml | 12 +++--------- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 445eee45e..d324effbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1469,10 +1469,8 @@ dependencies = [ "owo-colors", "serde", "serde_derive", - "serde_json", "toml", "tracing", - "tracing-error", "url", ] @@ -1538,14 +1536,10 @@ version = "0.5.0-beta.0" dependencies = [ "atty", "convert_case", - "dirs", - "env_proxy", "eyre", "owo-colors", "petgraph", "pgx-paths", - "pgx-pg-config", - "prettyplease", "proc-macro2", "quote", "regex", @@ -1554,12 +1548,10 @@ dependencies = [ "serde_json", "syn", "syntect", - "toml", "tracing", "tracing-error", "tracing-subscriber", "unescape", - "url", ] [[package]] diff --git a/pgx-pg-config/Cargo.toml b/pgx-pg-config/Cargo.toml index 79ea8f6e2..10c5307f9 100644 --- a/pgx-pg-config/Cargo.toml +++ b/pgx-pg-config/Cargo.toml @@ -19,8 +19,6 @@ eyre = "0.6.8" owo-colors = "3.4.0" serde = { version = "1.0.137", features = [ "derive" ] } serde_derive = "1.0.137" -serde_json = "1.0.81" toml = "0.5.9" tracing = "0.1.34" -tracing-error = "0.2.0" url = "2.2.2" diff --git a/pgx-utils/Cargo.toml b/pgx-utils/Cargo.toml index e0d3f4d50..8ddcfc8cf 100644 --- a/pgx-utils/Cargo.toml +++ b/pgx-utils/Cargo.toml @@ -13,12 +13,11 @@ rust-version = "1.58" [dependencies] atty = "0.2.14" -owo-colors = "3.4.0" convert_case = "0.5.0" -dirs = "4.0.0" -env_proxy = "0.4.1" +eyre = "0.6.8" +owo-colors = "3.4.0" +petgraph = "0.6.0" pgx-paths = { path = "../pgx-paths", version = "=0.5.0-beta.0" } -pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" } proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] } quote = "1.0.18" regex = "1.5.5" @@ -27,12 +26,7 @@ serde_derive = "1.0.137" serde_json = "1.0.81" syn = { version = "1.0.95", features = [ "extra-traits", "full", "fold", "parsing" ] } syntect = { version = "5.0.0", default-features = false, features = ["default-fancy"] } -toml = "0.5.9" unescape = "0.1.0" -url = "2.2.2" -eyre = "0.6.8" tracing = "0.1.34" tracing-error = "0.2.0" tracing-subscriber = { version = "0.3.11", features = [ "env-filter" ] } -petgraph = "0.6.0" -prettyplease = "0.1.10" From 1e3ba412937a0f3f247ae5a8b1e97067c6f39137 Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Tue, 23 Aug 2022 12:09:00 -0400 Subject: [PATCH 09/12] Adds readme files to new crates --- pgx-paths/README.md | 3 +++ pgx-pg-config/README.md | 3 +++ pgx-pg-sys-stub/README.md | 3 +++ 3 files changed, 9 insertions(+) create mode 100644 pgx-paths/README.md create mode 100644 pgx-pg-config/README.md create mode 100644 pgx-pg-sys-stub/README.md diff --git a/pgx-paths/README.md b/pgx-paths/README.md new file mode 100644 index 000000000..ed5d2a15d --- /dev/null +++ b/pgx-paths/README.md @@ -0,0 +1,3 @@ +# pgx-paths + +A crate containing various helper methods dealing with paths for [`pgx`](https://crates.io/crates/pgx/) and ['cargo pgx'](https://crates.io/crates/cargo-pgx) diff --git a/pgx-pg-config/README.md b/pgx-pg-config/README.md new file mode 100644 index 000000000..da89c7c5a --- /dev/null +++ b/pgx-pg-config/README.md @@ -0,0 +1,3 @@ +# pgx-pg-config + +A crate containing an abstraction/wrapper over Postgres' `pg_config` to be used with [`pgx`](https://crates.io/crates/pgx/) diff --git a/pgx-pg-sys-stub/README.md b/pgx-pg-sys-stub/README.md new file mode 100644 index 000000000..6e268eeea --- /dev/null +++ b/pgx-pg-sys-stub/README.md @@ -0,0 +1,3 @@ +# pgx-pg-sys-stub + +A crate containing structures which can generate 'stubs' of the bindings generated by `pgx-pg-sys`'s build script. From 70db9362708ea0283dbd9474ffb01541f7d2ddfb Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Tue, 23 Aug 2022 17:10:01 -0400 Subject: [PATCH 10/12] Some refactorings: * Removed pgx-paths (yes!) * Inlined versioned_so_name * Added "paths" methods into pgx-pg-config and exported appropriately --- Cargo.lock | 15 +------- Cargo.toml | 1 - cargo-pgx/Cargo.toml | 1 - cargo-pgx/src/command/init.rs | 3 +- cargo-pgx/src/command/install.rs | 8 ++-- cargo-pgx/src/command/package.rs | 3 +- cargo-pgx/src/command/schema.rs | 3 +- cargo-pgx/src/command/test.rs | 3 +- pgx-paths/Cargo.toml | 20 ---------- pgx-paths/README.md | 3 -- pgx-pg-config/Cargo.toml | 1 + pgx-pg-config/src/lib.rs | 7 ++++ .../src/path_methods.rs | 37 +++++++------------ pgx-pg-sys/Cargo.toml | 1 - pgx-pg-sys/build.rs | 3 +- pgx-tests/Cargo.toml | 1 - pgx-tests/src/framework.rs | 3 +- pgx-utils/Cargo.toml | 1 - pgx-utils/src/sql_entity_graph/pgx_sql.rs | 6 ++- 19 files changed, 37 insertions(+), 83 deletions(-) delete mode 100644 pgx-paths/Cargo.toml delete mode 100644 pgx-paths/README.md rename pgx-paths/src/lib.rs => pgx-pg-config/src/path_methods.rs (77%) diff --git a/Cargo.lock b/Cargo.lock index d324effbf..74be74074 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -294,7 +294,6 @@ dependencies = [ "object", "once_cell", "owo-colors", - "pgx-paths", "pgx-pg-config", "pgx-pg-sys-stub", "pgx-utils", @@ -1450,16 +1449,6 @@ dependencies = [ "unescape", ] -[[package]] -name = "pgx-paths" -version = "0.5.0-beta.0" -dependencies = [ - "eyre", - "serde", - "serde_derive", - "serde_json", -] - [[package]] name = "pgx-pg-config" version = "0.5.0-beta.0" @@ -1469,6 +1458,7 @@ dependencies = [ "owo-colors", "serde", "serde_derive", + "serde_json", "toml", "tracing", "url", @@ -1487,7 +1477,6 @@ dependencies = [ "once_cell", "owo-colors", "pgx-macros", - "pgx-paths", "pgx-pg-config", "pgx-utils", "proc-macro2", @@ -1518,7 +1507,6 @@ dependencies = [ "owo-colors", "pgx", "pgx-macros", - "pgx-paths", "pgx-pg-config", "pgx-utils", "postgres", @@ -1539,7 +1527,6 @@ dependencies = [ "eyre", "owo-colors", "petgraph", - "pgx-paths", "proc-macro2", "quote", "regex", diff --git a/Cargo.toml b/Cargo.toml index 589f9f0df..2a36cec2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ resolver = "2" members = [ "cargo-pgx", "pgx", - "pgx-paths", "pgx-macros", "pgx-pg-config", "pgx-pg-sys", diff --git a/cargo-pgx/Cargo.toml b/cargo-pgx/Cargo.toml index f5758ff34..35ed420a0 100644 --- a/cargo-pgx/Cargo.toml +++ b/cargo-pgx/Cargo.toml @@ -24,7 +24,6 @@ semver = "1.0.9" owo-colors = { version = "3.4.0", features = [ "supports-colors" ] } env_proxy = "0.4.1" num_cpus = "1.13.1" -pgx-paths = { path = "../pgx-paths", version = "=0.5.0-beta.0" } pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" } pgx-pg-sys-stub = { path = "../pgx-pg-sys-stub", version = "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils", version = "=0.5.0-beta.0" } diff --git a/cargo-pgx/src/command/init.rs b/cargo-pgx/src/command/init.rs index 9cbe033a5..bb8dc289b 100644 --- a/cargo-pgx/src/command/init.rs +++ b/cargo-pgx/src/command/init.rs @@ -12,8 +12,7 @@ use crate::command::version::pgx_default; use crate::CommandExecute; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_paths::prefix_path; -use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS}; +use pgx_pg_config::{prefix_path, PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS}; use rayon::prelude::*; use std::collections::HashMap; diff --git a/cargo-pgx/src/command/install.rs b/cargo-pgx/src/command/install.rs index 7e78cd0d5..424770603 100644 --- a/cargo-pgx/src/command/install.rs +++ b/cargo-pgx/src/command/install.rs @@ -14,8 +14,7 @@ use crate::{ use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; use owo_colors::OwoColorize; -use pgx_paths::{get_target_dir, versioned_so_name}; -use pgx_pg_config::PgConfig; +use pgx_pg_config::{get_target_dir, PgConfig}; use std::{ io::BufReader, path::{Path, PathBuf}, @@ -156,7 +155,10 @@ pub(crate) fn install_extension( dest.push(&pkgdir); let so_name = if versioned_so { let extver = get_version(&package_manifest_path)?; - versioned_so_name(&extname, &extver) + // Note: This originally was a call into versioned_so_name, but in an effort to eliminate crate dependencies, + // and because it was a single format! line, it was decided that inlining the single format! line was best in + // order to reduce a dependency. + format!("{}-{}", &extname, &extver) } else { extname.clone() }; diff --git a/cargo-pgx/src/command/package.rs b/cargo-pgx/src/command/package.rs index bf65aaf33..d34acaabb 100644 --- a/cargo-pgx/src/command/package.rs +++ b/cargo-pgx/src/command/package.rs @@ -13,8 +13,7 @@ use crate::{ }; use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; -use pgx_paths::get_target_dir; -use pgx_pg_config::PgConfig; +use pgx_pg_config::{get_target_dir, PgConfig}; use std::path::{Path, PathBuf}; /// Create an installation package directory. diff --git a/cargo-pgx/src/command/schema.rs b/cargo-pgx/src/command/schema.rs index 974dcca62..002982bce 100644 --- a/cargo-pgx/src/command/schema.rs +++ b/cargo-pgx/src/command/schema.rs @@ -18,8 +18,7 @@ use eyre::{eyre, WrapErr}; use object::Object; use once_cell::sync::OnceCell; use owo_colors::OwoColorize; -use pgx_paths::get_target_dir; -use pgx_pg_config::{PgConfig, Pgx}; +use pgx_pg_config::{get_target_dir, PgConfig, Pgx}; use pgx_pg_sys_stub::PgxPgSysStub; use pgx_utils::sql_entity_graph::{PgxSql, SqlGraphEntity}; use std::{ diff --git a/cargo-pgx/src/command/test.rs b/cargo-pgx/src/command/test.rs index c8fc370b0..b0bdde374 100644 --- a/cargo-pgx/src/command/test.rs +++ b/cargo-pgx/src/command/test.rs @@ -9,8 +9,7 @@ Use of this source code is governed by the MIT license that can be found in the use cargo_toml::Manifest; use eyre::{eyre, WrapErr}; -use pgx_paths::get_target_dir; -use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx}; +use pgx_pg_config::{get_target_dir, PgConfig, PgConfigSelector, Pgx}; use std::{ path::{Path, PathBuf}, process::{Command, Stdio}, diff --git a/pgx-paths/Cargo.toml b/pgx-paths/Cargo.toml deleted file mode 100644 index 6ac667df2..000000000 --- a/pgx-paths/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "pgx-paths" -edition = "2021" -version = "0.5.0-beta.0" -authors = ["ZomboDB, LLC "] -license = "MIT" -description = "A crate containing path and directory helpers for 'pgx'" -homepage = "https://github.com/zombodb/pgx" -repository = "https://github.com/zombodb/pgx" -#documentation = "https://docs.rs/pgx-utils" -readme = "README.md" -rust-version = "1.58" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -eyre = "0.6.8" -serde = { version = "1.0.137", features = [ "derive" ] } -serde_derive = "1.0.137" -serde_json = "1.0.81" diff --git a/pgx-paths/README.md b/pgx-paths/README.md deleted file mode 100644 index ed5d2a15d..000000000 --- a/pgx-paths/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# pgx-paths - -A crate containing various helper methods dealing with paths for [`pgx`](https://crates.io/crates/pgx/) and ['cargo pgx'](https://crates.io/crates/cargo-pgx) diff --git a/pgx-pg-config/Cargo.toml b/pgx-pg-config/Cargo.toml index 10c5307f9..6a2960a26 100644 --- a/pgx-pg-config/Cargo.toml +++ b/pgx-pg-config/Cargo.toml @@ -19,6 +19,7 @@ eyre = "0.6.8" owo-colors = "3.4.0" serde = { version = "1.0.137", features = [ "derive" ] } serde_derive = "1.0.137" +serde_json = "1.0.81" toml = "0.5.9" tracing = "0.1.34" url = "2.2.2" diff --git a/pgx-pg-config/src/lib.rs b/pgx-pg-config/src/lib.rs index 9f4282ad8..4d207f4ad 100644 --- a/pgx-pg-config/src/lib.rs +++ b/pgx-pg-config/src/lib.rs @@ -24,6 +24,13 @@ use url::Url; pub static BASE_POSTGRES_PORT_NO: u16 = 28800; pub static BASE_POSTGRES_TESTING_PORT_NO: u16 = 32200; +// These methods were originally in `pgx-utils`, but in an effort to consolidate +// dependencies, the decision was made to package them into wherever made the +// most sense. In this case, it made the most sense to put them into this +// pgx-pg-config crate. That doesnt mean they can't be moved at a later date. +mod path_methods; +pub use path_methods::{get_target_dir, prefix_path}; + #[derive(Clone)] pub struct PgVersion { major: u16, diff --git a/pgx-paths/src/lib.rs b/pgx-pg-config/src/path_methods.rs similarity index 77% rename from pgx-paths/src/lib.rs rename to pgx-pg-config/src/path_methods.rs index 2c77eda49..ba081896d 100644 --- a/pgx-paths/src/lib.rs +++ b/pgx-pg-config/src/path_methods.rs @@ -1,16 +1,20 @@ -/* -Portions Copyright 2019-2021 ZomboDB, LLC. -Portions Copyright 2021-2022 Technology Concepts & Design, Inc. - -All rights reserved. - -Use of this source code is governed by the MIT license that can be found in the LICENSE file. -*/ - use eyre::{eyre, WrapErr}; use serde_json::value::Value as JsonValue; use std::{path::PathBuf, process::Command}; +// Originally part of `pgx-utils` +pub fn prefix_path>(dir: P) -> String { + let mut path = std::env::split_paths(&std::env::var_os("PATH").expect("failed to get $PATH")) + .collect::>(); + + path.insert(0, dir.into()); + std::env::join_paths(path) + .expect("failed to join paths") + .into_string() + .expect("failed to construct path") +} + +// Originally part of `pgx-utils` pub fn get_target_dir() -> eyre::Result { let mut command = Command::new("cargo"); command @@ -38,18 +42,3 @@ pub fn get_target_dir() -> eyre::Result { )), } } - -pub fn prefix_path>(dir: P) -> String { - let mut path = std::env::split_paths(&std::env::var_os("PATH").expect("failed to get $PATH")) - .collect::>(); - - path.insert(0, dir.into()); - std::env::join_paths(path) - .expect("failed to join paths") - .into_string() - .expect("failed to construct path") -} - -pub fn versioned_so_name(extension_name: &str, extension_version: &str) -> String { - format!("{}-{}", extension_name, extension_version) -} diff --git a/pgx-pg-sys/Cargo.toml b/pgx-pg-sys/Cargo.toml index 43b9109b6..49e8de37b 100644 --- a/pgx-pg-sys/Cargo.toml +++ b/pgx-pg-sys/Cargo.toml @@ -40,7 +40,6 @@ bindgen = { version = "0.59.2", default-features = false, features = ["runtime"] build-deps = "0.1.4" owo-colors = "3.4.0" num_cpus = "1.13.1" -pgx-paths = { path = "../pgx-paths/", version = "=0.5.0-beta.0" } pgx-pg-config= { path = "../pgx-pg-config/", version = "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils/", version = "=0.5.0-beta.0" } proc-macro2 = "1.0.39" diff --git a/pgx-pg-sys/build.rs b/pgx-pg-sys/build.rs index 32fd51aaf..0f1329685 100644 --- a/pgx-pg-sys/build.rs +++ b/pgx-pg-sys/build.rs @@ -11,8 +11,7 @@ extern crate build_deps; use bindgen::callbacks::MacroParsingBehavior; use eyre::{eyre, WrapErr}; -use pgx_paths::prefix_path; -use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS}; +use pgx_pg_config::{prefix_path, PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS}; use pgx_utils::rewriter::PgGuardRewriter; use quote::{quote, ToTokens}; use rayon::prelude::*; diff --git a/pgx-tests/Cargo.toml b/pgx-tests/Cargo.toml index c316eb30d..645d0390f 100644 --- a/pgx-tests/Cargo.toml +++ b/pgx-tests/Cargo.toml @@ -36,7 +36,6 @@ owo-colors = "3.4.0" once_cell = "1.10.0" libc = "0.2.126" pgx = { path = "../pgx", default-features = false, version= "=0.5.0-beta.0" } -pgx-paths = { path = "../pgx-paths", version= "=0.5.0-beta.0" } pgx-macros = { path = "../pgx-macros", version= "=0.5.0-beta.0" } pgx-pg-config = { path = "../pgx-pg-config", version= "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils", version= "=0.5.0-beta.0" } diff --git a/pgx-tests/src/framework.rs b/pgx-tests/src/framework.rs index 07278e485..443bd0fb9 100644 --- a/pgx-tests/src/framework.rs +++ b/pgx-tests/src/framework.rs @@ -13,8 +13,7 @@ use eyre::{eyre, WrapErr}; use once_cell::sync::Lazy; use owo_colors::OwoColorize; use pgx::*; -use pgx_paths::get_target_dir; -use pgx_pg_config::{createdb, PgConfig, Pgx}; +use pgx_pg_config::{createdb, get_target_dir, PgConfig, Pgx}; use postgres::error::DbError; use postgres::Client; use std::collections::HashMap; diff --git a/pgx-utils/Cargo.toml b/pgx-utils/Cargo.toml index 8ddcfc8cf..62dc3f37a 100644 --- a/pgx-utils/Cargo.toml +++ b/pgx-utils/Cargo.toml @@ -17,7 +17,6 @@ convert_case = "0.5.0" eyre = "0.6.8" owo-colors = "3.4.0" petgraph = "0.6.0" -pgx-paths = { path = "../pgx-paths", version = "=0.5.0-beta.0" } proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] } quote = "1.0.18" regex = "1.5.5" diff --git a/pgx-utils/src/sql_entity_graph/pgx_sql.rs b/pgx-utils/src/sql_entity_graph/pgx_sql.rs index b3a6dda6a..8c662e59b 100644 --- a/pgx-utils/src/sql_entity_graph/pgx_sql.rs +++ b/pgx-utils/src/sql_entity_graph/pgx_sql.rs @@ -7,7 +7,6 @@ All rights reserved. Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ use eyre::{eyre, WrapErr}; -use pgx_paths::versioned_so_name; use std::{any::TypeId, collections::HashMap, fmt::Debug, path::Path}; use owo_colors::{OwoColorize, XtermColors}; @@ -548,7 +547,10 @@ impl PgxSql { return if self.versioned_so { let extname = &self.extension_name; let extver = &self.control.default_version; - format!("$libdir/{}", versioned_so_name(extname, extver)) + // Note: This originally was a call into versioned_so_name, but in an effort to eliminate crate dependencies, + // and because it was a single format! line, it was decided that inlining the single format! line was best in + // order to reduce a dependency. + format!("$libdir/{}-{}", extname, extver) } else { String::from("MODULE_PATHNAME") }; From 0078eea6c499c9d7ba5779eeaa4093f6bc7c8979 Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Wed, 24 Aug 2022 10:38:19 -0400 Subject: [PATCH 11/12] Small tweaks to comments as per GH --- cargo-pgx/src/command/install.rs | 4 +--- pgx-utils/src/sql_entity_graph/pgx_sql.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/cargo-pgx/src/command/install.rs b/cargo-pgx/src/command/install.rs index 424770603..5975ee8fe 100644 --- a/cargo-pgx/src/command/install.rs +++ b/cargo-pgx/src/command/install.rs @@ -155,9 +155,7 @@ pub(crate) fn install_extension( dest.push(&pkgdir); let so_name = if versioned_so { let extver = get_version(&package_manifest_path)?; - // Note: This originally was a call into versioned_so_name, but in an effort to eliminate crate dependencies, - // and because it was a single format! line, it was decided that inlining the single format! line was best in - // order to reduce a dependency. + // note: versioned so-name format must agree with pgx-utils format!("{}-{}", &extname, &extver) } else { extname.clone() diff --git a/pgx-utils/src/sql_entity_graph/pgx_sql.rs b/pgx-utils/src/sql_entity_graph/pgx_sql.rs index 8c662e59b..298163891 100644 --- a/pgx-utils/src/sql_entity_graph/pgx_sql.rs +++ b/pgx-utils/src/sql_entity_graph/pgx_sql.rs @@ -547,9 +547,7 @@ impl PgxSql { return if self.versioned_so { let extname = &self.extension_name; let extver = &self.control.default_version; - // Note: This originally was a call into versioned_so_name, but in an effort to eliminate crate dependencies, - // and because it was a single format! line, it was decided that inlining the single format! line was best in - // order to reduce a dependency. + // Note: versioned so-name format must agree with cargo pgx format!("$libdir/{}-{}", extname, extver) } else { String::from("MODULE_PATHNAME") From 09da15c9709c6d04ea7fd3f04e3ad968b651a22c Mon Sep 17 00:00:00 2001 From: Brady Bonnette Date: Wed, 24 Aug 2022 11:01:45 -0400 Subject: [PATCH 12/12] pgx-pg-sys-stub crate to cargo-pgx submodule --- Cargo.lock | 16 +++------------ Cargo.toml | 1 - cargo-pgx/Cargo.toml | 2 +- cargo-pgx/src/command/schema.rs | 2 +- cargo-pgx/src/main.rs | 1 + .../src/pgx_pg_sys_stub.rs | 0 pgx-pg-sys-stub/Cargo.toml | 20 ------------------- pgx-pg-sys-stub/README.md | 3 --- 8 files changed, 6 insertions(+), 39 deletions(-) rename pgx-pg-sys-stub/src/lib.rs => cargo-pgx/src/pgx_pg_sys_stub.rs (100%) delete mode 100644 pgx-pg-sys-stub/Cargo.toml delete mode 100644 pgx-pg-sys-stub/README.md diff --git a/Cargo.lock b/Cargo.lock index 74be74074..6dffb8999 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -295,8 +295,8 @@ dependencies = [ "once_cell", "owo-colors", "pgx-pg-config", - "pgx-pg-sys-stub", "pgx-utils", + "prettyplease", "proc-macro2", "quote", "rayon", @@ -1487,16 +1487,6 @@ dependencies = [ "syn", ] -[[package]] -name = "pgx-pg-sys-stub" -version = "0.5.0-beta.0" -dependencies = [ - "eyre", - "prettyplease", - "syn", - "tracing", -] - [[package]] name = "pgx-tests" version = "0.5.0-beta.0" @@ -1642,9 +1632,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "prettyplease" -version = "0.1.11" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28f53e8b192565862cf99343194579a022eb9c7dd3a8d03134734803c7b3125" +checksum = "697ae720ee02011f439e0701db107ffe2916d83f718342d65d7f8bf7b8a5fee9" dependencies = [ "proc-macro2", "syn", diff --git a/Cargo.toml b/Cargo.toml index 2a36cec2c..9885e0da7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ members = [ "pgx-macros", "pgx-pg-config", "pgx-pg-sys", - "pgx-pg-sys-stub", "pgx-tests", "pgx-utils", "pgx-examples/aggregate", diff --git a/cargo-pgx/Cargo.toml b/cargo-pgx/Cargo.toml index 35ed420a0..fb8ba306d 100644 --- a/cargo-pgx/Cargo.toml +++ b/cargo-pgx/Cargo.toml @@ -25,8 +25,8 @@ owo-colors = { version = "3.4.0", features = [ "supports-colors" ] } env_proxy = "0.4.1" num_cpus = "1.13.1" pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" } -pgx-pg-sys-stub = { path = "../pgx-pg-sys-stub", version = "=0.5.0-beta.0" } pgx-utils = { path = "../pgx-utils", version = "=0.5.0-beta.0" } +prettyplease = "0.1.10" proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] } quote = "1.0.18" rayon = "1.5.3" diff --git a/cargo-pgx/src/command/schema.rs b/cargo-pgx/src/command/schema.rs index 002982bce..77bbf0848 100644 --- a/cargo-pgx/src/command/schema.rs +++ b/cargo-pgx/src/command/schema.rs @@ -11,6 +11,7 @@ use crate::{ get::{find_control_file, get_property}, install::format_display_path, }, + pgx_pg_sys_stub::PgxPgSysStub, CommandExecute, }; use cargo_toml::Manifest; @@ -19,7 +20,6 @@ use object::Object; use once_cell::sync::OnceCell; use owo_colors::OwoColorize; use pgx_pg_config::{get_target_dir, PgConfig, Pgx}; -use pgx_pg_sys_stub::PgxPgSysStub; use pgx_utils::sql_entity_graph::{PgxSql, SqlGraphEntity}; use std::{ collections::HashSet, diff --git a/cargo-pgx/src/main.rs b/cargo-pgx/src/main.rs index 0ae74adf5..a8c89f583 100644 --- a/cargo-pgx/src/main.rs +++ b/cargo-pgx/src/main.rs @@ -10,6 +10,7 @@ Use of this source code is governed by the MIT license that can be found in the mod command; mod manifest; mod metadata; +mod pgx_pg_sys_stub; use atty::Stream; use clap::Parser; diff --git a/pgx-pg-sys-stub/src/lib.rs b/cargo-pgx/src/pgx_pg_sys_stub.rs similarity index 100% rename from pgx-pg-sys-stub/src/lib.rs rename to cargo-pgx/src/pgx_pg_sys_stub.rs diff --git a/pgx-pg-sys-stub/Cargo.toml b/pgx-pg-sys-stub/Cargo.toml deleted file mode 100644 index 6b4f1b9d8..000000000 --- a/pgx-pg-sys-stub/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "pgx-pg-sys-stub" -edition = "2021" -version = "0.5.0-beta.0" -authors = ["ZomboDB, LLC "] -license = "MIT" -description = "A Postgres pg_config wrapper for 'pgx'" -homepage = "https://github.com/zombodb/pgx" -repository = "https://github.com/zombodb/pgx" -#documentation = "https://docs.rs/pgx-utils" -readme = "README.md" -rust-version = "1.58" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -eyre = "0.6.8" -prettyplease = "0.1.10" -syn = { version = "1.0.95", features = [ "extra-traits", "full", "fold", "parsing" ] } -tracing = "0.1.34" diff --git a/pgx-pg-sys-stub/README.md b/pgx-pg-sys-stub/README.md deleted file mode 100644 index 6e268eeea..000000000 --- a/pgx-pg-sys-stub/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# pgx-pg-sys-stub - -A crate containing structures which can generate 'stubs' of the bindings generated by `pgx-pg-sys`'s build script.