Skip to content

Commit

Permalink
whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pgguru committed Oct 24, 2024
1 parent a496257 commit d25daf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/arrow_parquet/uri_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub(crate) fn ensure_access_privilege_to_uri(uri: &Url, copy_from: bool) {

let user_id = unsafe { GetUserId() };
let is_file = uri.scheme() == "file";

let required_role_name = if is_file {
if copy_from {
"pg_read_server_files"
Expand All @@ -274,12 +274,15 @@ pub(crate) fn ensure_access_privilege_to_uri(uri: &Url, copy_from: bool) {

let operation_str = if copy_from { "from" } else { "to" };
let object_type = if is_file { "file" } else { "remote uri" };

if !unsafe { has_privs_of_role(user_id, required_role_id) } {
ereport!(
pgrx::PgLogLevel::ERROR,
pgrx::PgSqlErrorCode::ERRCODE_INSUFFICIENT_PRIVILEGE,
format!("permission denied to COPY {} a {}", operation_str, object_type),
format!(
"permission denied to COPY {} a {}",
operation_str, object_type
),
format!(
"Only roles with privileges of the \"{}\" role may COPY {} a {}.",
required_role_name, operation_str, object_type
Expand Down
14 changes: 8 additions & 6 deletions src/parquet_copy_hook/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ use pg_sys::{
use pgrx::{prelude::*, GucSetting};

use crate::{
arrow_parquet::{compression::INVALID_COMPRESSION_LEVEL, uri_utils::{uri_as_string,ensure_access_privilege_to_uri}},
parquet_copy_hook::{
copy_to_dest_receiver::create_copy_to_parquet_dest_receiver,
copy_utils::{
arrow_parquet::{
compression::INVALID_COMPRESSION_LEVEL,
uri_utils::{ensure_access_privilege_to_uri, uri_as_string},
},
parquet_copy_hook::{
copy_to_dest_receiver::create_copy_to_parquet_dest_receiver,
copy_utils::{
copy_stmt_uri, copy_to_stmt_compression_level, copy_to_stmt_row_group_size,
copy_to_stmt_row_group_size_bytes, is_copy_from_parquet_stmt, is_copy_to_parquet_stmt,
},
Expand Down Expand Up @@ -57,8 +60,7 @@ extern "C" fn parquet_copy_hook(
let params = unsafe { PgBox::from_pg(params) };
let query_env = unsafe { PgBox::from_pg(query_env) };


if ENABLE_PARQUET_COPY_HOOK.get() && is_copy_to_parquet_stmt(&p_stmt) {
if ENABLE_PARQUET_COPY_HOOK.get() && is_copy_to_parquet_stmt(&p_stmt) {
let uri = copy_stmt_uri(&p_stmt).expect("uri is None");
let copy_from = false;

Expand Down

0 comments on commit d25daf7

Please sign in to comment.