Skip to content

Commit

Permalink
Bumps rust to 1.82 (#53)
Browse files Browse the repository at this point in the history
Use portable *const ffi::c_char instead of *const i8 or *const u8.

Fixes #52
  • Loading branch information
aykut-bozkurt authored Oct 24, 2024
1 parent 0bfc8b6 commit 7b2d965
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: CI lints and tests
on:
push:
branches:
- "*"
branches: [ "main" ]
pull_request:
branches: [ "main" ]

concurrency:
group: ${{ github.ref }}
Expand Down Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/arrow_parquet/parquet_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
16 changes: 8 additions & 8 deletions src/parquet_copy_hook/copy_to.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ffi::CStr;
use std::ffi::{c_char, CStr};

use pgrx::{
ereport, is_a,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/parquet_copy_hook/copy_to_dest_receiver.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/parquet_copy_hook/hook.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ffi::CStr;
use std::ffi::{c_char, CStr};

use pg_sys::{
standard_ProcessUtility, AsPgCStr, CommandTag, DestReceiver, ParamListInfoData, PlannedStmt,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7b2d965

Please sign in to comment.