diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a53c4b2..3d3b802 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -31,7 +31,7 @@ RUN mv mc /usr/local/bin/mc # set up pgrx with non-sudo user ARG USERNAME=rust -ARG USER_UID=1000 +ARG USER_UID=501 ARG USER_GID=$USER_UID RUN groupadd --gid $USER_GID $USERNAME \ && useradd --uid $USER_UID --gid $USER_GID -s /bin/bash -m $USERNAME diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c97fcc..0e8d3e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,9 @@ name: CI lints and tests on: push: - branches: - - "*" + branches: [ "main" ] + pull_request: + branches: [ "main" ] concurrency: group: ${{ github.ref }} @@ -40,7 +41,7 @@ jobs: - name: Set up Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.81.0 + toolchain: 1.82.0 target: x86_64-unknown-linux-gnu components: rustfmt, clippy, llvm-tools-preview diff --git a/Cargo.lock b/Cargo.lock index 63a1bfc..f5f042e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2095,8 +2095,6 @@ dependencies = [ "parquet", "pgrx", "pgrx-tests", - "serde", - "serde_json", "tokio", "url", ] diff --git a/Cargo.toml b/Cargo.toml index 60ff94e..2e170fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,6 @@ parquet = {version = "53", default-features = false, features = [ "object_store", ]} pgrx = "=0.12.6" -serde = {version = "1", default-features = false} -serde_json = "1" tokio = {version = "1", default-features = false, features = ["rt", "time", "macros"]} url = "2.5" diff --git a/src/arrow_parquet/parquet_reader.rs b/src/arrow_parquet/parquet_reader.rs index ae930e3..a3cd53b 100644 --- a/src/arrow_parquet/parquet_reader.rs +++ b/src/arrow_parquet/parquet_reader.rs @@ -156,7 +156,7 @@ impl ParquetReaderContext { self.buffer.extend_from_slice(&data_size_bytes); /* variable bytes: attribute's data */ - let data = vardata_any(datum_bytes) as *const u8; + let data = vardata_any(datum_bytes) as _; let data_bytes = std::slice::from_raw_parts(data, data_size); self.buffer.extend_from_slice(data_bytes); }; diff --git a/src/parquet_copy_hook/copy_to.rs b/src/parquet_copy_hook/copy_to.rs index 0711760..1e8df78 100644 --- a/src/parquet_copy_hook/copy_to.rs +++ b/src/parquet_copy_hook/copy_to.rs @@ -1,4 +1,4 @@ -use std::ffi::CStr; +use std::ffi::{c_char, CStr}; use pgrx::{ ereport, is_a, @@ -202,41 +202,41 @@ fn convert_copy_to_relation_to_select_stmt( // Taken from PG COPY TO code path. fn copy_to_stmt_ensure_table_kind(relation: &PgRelation) { let relation_pgclass_entry = relation.rd_rel; - let relation_kind = (unsafe { *relation_pgclass_entry }).relkind as u8; + let relation_kind = (unsafe { *relation_pgclass_entry }).relkind; - if relation_kind == RELKIND_RELATION { + if relation_kind == RELKIND_RELATION as c_char { return; } - if relation_kind == RELKIND_VIEW { + if relation_kind == RELKIND_VIEW as c_char { ereport!( PgLogLevel::ERROR, PgSqlErrorCode::ERRCODE_WRONG_OBJECT_TYPE, format!("cannot copy from view \"{}\"", relation.name()), "Try the COPY (SELECT ...) TO variant.", ); - } else if relation_kind == RELKIND_MATVIEW { + } else if relation_kind == RELKIND_MATVIEW as c_char { ereport!( PgLogLevel::ERROR, PgSqlErrorCode::ERRCODE_WRONG_OBJECT_TYPE, format!("cannot copy from materialized view \"{}\"", relation.name()), "Try the COPY (SELECT ...) TO variant.", ); - } else if relation_kind == RELKIND_FOREIGN_TABLE { + } else if relation_kind == RELKIND_FOREIGN_TABLE as c_char { ereport!( PgLogLevel::ERROR, PgSqlErrorCode::ERRCODE_WRONG_OBJECT_TYPE, format!("cannot copy from foreign table \"{}\"", relation.name()), "Try the COPY (SELECT ...) TO variant.", ); - } else if relation_kind == RELKIND_SEQUENCE { + } else if relation_kind == RELKIND_SEQUENCE as c_char { ereport!( PgLogLevel::ERROR, PgSqlErrorCode::ERRCODE_WRONG_OBJECT_TYPE, format!("cannot copy from sequence \"{}\"", relation.name()), "Try the COPY (SELECT ...) TO variant.", ); - } else if relation_kind == RELKIND_PARTITIONED_TABLE { + } else if relation_kind == RELKIND_PARTITIONED_TABLE as c_char { ereport!( PgLogLevel::ERROR, PgSqlErrorCode::ERRCODE_WRONG_OBJECT_TYPE, diff --git a/src/parquet_copy_hook/copy_to_dest_receiver.rs b/src/parquet_copy_hook/copy_to_dest_receiver.rs index 7ef2572..07fe504 100644 --- a/src/parquet_copy_hook/copy_to_dest_receiver.rs +++ b/src/parquet_copy_hook/copy_to_dest_receiver.rs @@ -1,4 +1,4 @@ -use std::ffi::CStr; +use std::ffi::{c_char, CStr}; use pg_sys::{ get_typlenbyval, slot_getallattrs, toast_raw_datum_size, AllocSetContextCreateExtended, @@ -30,7 +30,7 @@ struct CopyToParquetDestReceiver { collected_tuple_count: i64, collected_tuple_size: i64, collected_tuple_column_sizes: *mut i64, - uri: *mut i8, + uri: *const c_char, compression: PgParquetCompression, compression_level: i32, row_group_size: i64, @@ -292,7 +292,7 @@ extern "C" fn copy_destroy(_dest: *mut DestReceiver) {} #[pg_guard] #[no_mangle] pub extern "C" fn create_copy_to_parquet_dest_receiver( - uri: *mut i8, + uri: *const c_char, row_group_size: *const i64, row_group_size_bytes: *const i64, compression: *const PgParquetCompression, diff --git a/src/parquet_copy_hook/hook.rs b/src/parquet_copy_hook/hook.rs index 5998e29..8d4cea0 100644 --- a/src/parquet_copy_hook/hook.rs +++ b/src/parquet_copy_hook/hook.rs @@ -1,4 +1,4 @@ -use std::ffi::CStr; +use std::ffi::{c_char, CStr}; use pg_sys::{ standard_ProcessUtility, AsPgCStr, CommandTag, DestReceiver, ParamListInfoData, PlannedStmt, @@ -44,7 +44,7 @@ pub(crate) extern "C" fn init_parquet_copy_hook() { #[allow(clippy::too_many_arguments)] extern "C" fn parquet_copy_hook( p_stmt: *mut PlannedStmt, - query_string: *const i8, + query_string: *const c_char, read_only_tree: bool, context: u32, params: *mut ParamListInfoData,