Skip to content

Commit 8a2d1cd

Browse files
committed
revert pg13
1 parent 14c704f commit 8a2d1cd

File tree

7 files changed

+27
-173
lines changed

7 files changed

+27
-173
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
postgres: [ 13, 14, 15, 16, 17 ]
23+
postgres: [ 14, 15, 16, 17 ]
2424
env:
2525
PG_MAJOR: ${{ matrix.postgres }}
2626

@@ -91,7 +91,7 @@ jobs:
9191
- name: Install and configure pgrx
9292
run: |
9393
cargo install --locked [email protected]
94-
cargo pgrx init --pg${{ env.PG_MAJOR }} /usr/lib/postgresql/${{ env.PG_MAJOR }}/bin/pg_config
94+
cargo pgrx init --pg${{ env.PG_MAJOR }} $(which pg_config)
9595
9696
- name: Install cargo-llvm-cov for coverage report
9797
run: cargo install --locked [email protected]
@@ -104,9 +104,9 @@ jobs:
104104
- name: Run tests
105105
run: |
106106
# Set up permissions so that the current user below can create extensions
107-
sudo chmod a+rwx $(/usr/lib/postgresql/${{ env.PG_MAJOR }}/bin/pg_config --pkglibdir) \
108-
$(/usr/lib/postgresql/${{ env.PG_MAJOR }}/bin/pg_config --sharedir)/extension \
109-
/var/run/postgresql/
107+
sudo chmod a+rwx $(pg_config --pkglibdir) \
108+
$(pg_config --sharedir)/extension \
109+
/var/run/postgresql/
110110
111111
# pgrx tests with runas argument ignores environment variables, so
112112
# we read env vars from .env file in tests (https://github.com/pgcentralfoundation/pgrx/pull/1674)

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pg17 = ["pgrx/pg17", "pgrx-tests/pg17"]
1717
pg16 = ["pgrx/pg16", "pgrx-tests/pg16"]
1818
pg15 = ["pgrx/pg15", "pgrx-tests/pg15"]
1919
pg14 = ["pgrx/pg14", "pgrx-tests/pg14"]
20-
pg13 = ["pgrx/pg13", "pgrx-tests/pg13"]
2120
pg_test = []
2221

2322
[dependencies]

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ There is currently only one GUC parameter to enable/disable the `pg_parquet`:
238238
`pg_parquet` supports the following PostgreSQL versions:
239239
| PostgreSQL Major Version | Supported |
240240
|--------------------------|-----------|
241-
| 13 ||
242241
| 14 ||
243242
| 15 ||
244243
| 16 ||

src/parquet_copy_hook/copy_from.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use pgrx::{
55
pg_sys::{
66
addNSItemToQuery, assign_expr_collations, canonicalize_qual, check_enable_rls,
77
coerce_to_boolean, eval_const_expressions, make_ands_implicit, transformExpr, AsPgCStr,
8-
CheckEnableRlsResult, CopyFrom, CopyStmt, EndCopyFrom, InvalidOid, Node, Oid,
9-
ParseExprKind, ParseNamespaceItem, ParseState, PlannedStmt, QueryEnvironment,
8+
BeginCopyFrom, CheckEnableRlsResult, CopyFrom, CopyStmt, EndCopyFrom, InvalidOid, Node,
9+
Oid, ParseExprKind, ParseNamespaceItem, ParseState, PlannedStmt, QueryEnvironment,
1010
},
1111
void_mut_ptr, PgBox, PgLogLevel, PgRelation, PgSqlErrorCode,
1212
};
@@ -19,12 +19,9 @@ use crate::{
1919
},
2020
};
2121

22-
use super::{
23-
copy_utils::{
24-
copy_stmt_attribute_list, copy_stmt_create_namespace_item, copy_stmt_create_parse_state,
25-
create_filtered_tupledesc_for_relation,
26-
},
27-
pg_compat::BeginCopyFrom,
22+
use super::copy_utils::{
23+
copy_stmt_attribute_list, copy_stmt_create_namespace_item, copy_stmt_create_parse_state,
24+
create_filtered_tupledesc_for_relation,
2825
};
2926

3027
// stack to store parquet reader contexts for COPY FROM.
@@ -146,6 +143,8 @@ pub(crate) fn execute_copy_from(
146143
p_state.as_ptr(),
147144
relation.as_ptr(),
148145
where_clause,
146+
std::ptr::null(),
147+
false,
149148
Some(copy_parquet_data_to_buffer),
150149
attribute_list,
151150
copy_options.as_ptr(),

src/parquet_copy_hook/hook.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ fn process_copy_from_parquet(
109109
.execute()
110110
}
111111

112-
#[cfg(any(feature = "pg14", feature = "pg15", feature = "pg16", feature = "pg17"))]
113112
#[pg_guard]
114113
#[allow(clippy::too_many_arguments)]
115114
extern "C" fn parquet_copy_hook(
@@ -172,64 +171,3 @@ extern "C" fn parquet_copy_hook(
172171
}
173172
}
174173
}
175-
176-
#[cfg(feature = "pg13")]
177-
#[pg_guard]
178-
#[allow(clippy::too_many_arguments)]
179-
extern "C" fn parquet_copy_hook(
180-
p_stmt: *mut PlannedStmt,
181-
query_string: *const c_char,
182-
context: u32,
183-
params: *mut ParamListInfoData,
184-
query_env: *mut QueryEnvironment,
185-
dest: *mut DestReceiver,
186-
completion_tag: *mut QueryCompletion,
187-
) {
188-
let p_stmt = unsafe { PgBox::from_pg(p_stmt) };
189-
let query_string = unsafe { CStr::from_ptr(query_string) };
190-
let params = unsafe { PgBox::from_pg(params) };
191-
let query_env = unsafe { PgBox::from_pg(query_env) };
192-
let mut completion_tag = unsafe { PgBox::from_pg(completion_tag) };
193-
194-
if ENABLE_PARQUET_COPY_HOOK.get() && is_copy_to_parquet_stmt(&p_stmt) {
195-
let nprocessed = process_copy_to_parquet(&p_stmt, query_string, &params, &query_env);
196-
197-
if !completion_tag.is_null() {
198-
completion_tag.nprocessed = nprocessed;
199-
completion_tag.commandTag = CommandTag::CMDTAG_COPY;
200-
}
201-
return;
202-
} else if ENABLE_PARQUET_COPY_HOOK.get() && is_copy_from_parquet_stmt(&p_stmt) {
203-
let nprocessed = process_copy_from_parquet(&p_stmt, query_string, &query_env);
204-
205-
if !completion_tag.is_null() {
206-
completion_tag.nprocessed = nprocessed;
207-
completion_tag.commandTag = CommandTag::CMDTAG_COPY;
208-
}
209-
return;
210-
}
211-
212-
unsafe {
213-
if let Some(prev_hook) = PREV_PROCESS_UTILITY_HOOK {
214-
prev_hook(
215-
p_stmt.into_pg(),
216-
query_string.as_ptr(),
217-
context,
218-
params.into_pg(),
219-
query_env.into_pg(),
220-
dest,
221-
completion_tag.into_pg(),
222-
)
223-
} else {
224-
standard_ProcessUtility(
225-
p_stmt.into_pg(),
226-
query_string.as_ptr(),
227-
context,
228-
params.into_pg(),
229-
query_env.into_pg(),
230-
dest,
231-
completion_tag.into_pg(),
232-
)
233-
}
234-
}
235-
}

src/parquet_copy_hook/pg_compat.rs

Lines changed: 4 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
use std::ffi::{c_char, CStr};
22

3-
use pgrx::{
4-
datum::TimeWithTimeZone,
5-
direct_function_call,
6-
pg_sys::{
7-
copy_data_source_cb, AsPgCStr, List, Node, ParseState, QueryEnvironment, RawStmt, Relation,
8-
},
9-
IntoDatum,
10-
};
11-
12-
#[cfg(any(feature = "pg14", feature = "pg15", feature = "pg16", feature = "pg17"))]
13-
use pgrx::AnyNumeric;
3+
use pgrx::pg_sys::{AsPgCStr, List, Node, QueryEnvironment, RawStmt};
144

155
pub(crate) fn pg_analyze_and_rewrite(
166
raw_stmt: *mut RawStmt,
177
query_string: *const c_char,
188
query_env: *mut QueryEnvironment,
199
) -> *mut List {
20-
#[cfg(any(feature = "pg13", feature = "pg14"))]
10+
#[cfg(feature = "pg14")]
2111
unsafe {
2212
pgrx::pg_sys::pg_analyze_and_rewrite(
2313
raw_stmt,
@@ -42,7 +32,7 @@ pub(crate) fn pg_analyze_and_rewrite(
4232

4333
#[allow(non_snake_case)]
4434
pub(crate) fn strVal(val: *mut Node) -> String {
45-
#[cfg(any(feature = "pg13", feature = "pg14"))]
35+
#[cfg(feature = "pg14")]
4636
unsafe {
4737
let val = (*(val as *mut pgrx::pg_sys::Value)).val.str_;
4838

@@ -63,88 +53,9 @@ pub(crate) fn strVal(val: *mut Node) -> String {
6353
}
6454
}
6555

66-
#[cfg(feature = "pg13")]
67-
#[allow(non_snake_case)]
68-
pub(crate) fn BeginCopyFrom(
69-
pstate: *mut ParseState,
70-
relation: Relation,
71-
_where_clause: *mut Node,
72-
data_source_cb: copy_data_source_cb,
73-
attribute_list: *mut List,
74-
copy_options: *mut List,
75-
) -> *mut pgrx::pg_sys::CopyStateData {
76-
unsafe {
77-
pgrx::pg_sys::BeginCopyFrom(
78-
pstate,
79-
relation,
80-
std::ptr::null(),
81-
false,
82-
data_source_cb,
83-
attribute_list,
84-
copy_options,
85-
)
86-
}
87-
}
88-
89-
#[cfg(any(feature = "pg14", feature = "pg15", feature = "pg16", feature = "pg17"))]
90-
#[allow(non_snake_case)]
91-
pub(crate) fn BeginCopyFrom(
92-
pstate: *mut ParseState,
93-
relation: Relation,
94-
_where_clause: *mut Node,
95-
data_source_cb: copy_data_source_cb,
96-
attribute_list: *mut List,
97-
copy_options: *mut List,
98-
) -> *mut pgrx::pg_sys::CopyFromStateData {
99-
unsafe {
100-
pgrx::pg_sys::BeginCopyFrom(
101-
pstate,
102-
relation,
103-
_where_clause,
104-
std::ptr::null(),
105-
false,
106-
data_source_cb,
107-
attribute_list,
108-
copy_options,
109-
)
110-
}
111-
}
112-
113-
pub(crate) fn extract_timezone_from_timetz(timetz: TimeWithTimeZone) -> f64 {
114-
#[cfg(feature = "pg13")]
115-
{
116-
let timezone_as_secs: f64 = unsafe {
117-
direct_function_call(
118-
pgrx::pg_sys::timetz_part,
119-
&["timezone".into_datum(), timetz.into_datum()],
120-
)
121-
}
122-
.expect("cannot extract timezone from timetz");
123-
124-
timezone_as_secs
125-
}
126-
127-
#[cfg(any(feature = "pg14", feature = "pg15", feature = "pg16", feature = "pg17"))]
128-
{
129-
let timezone_as_secs: AnyNumeric = unsafe {
130-
direct_function_call(
131-
pgrx::pg_sys::extract_timetz,
132-
&["timezone".into_datum(), timetz.into_datum()],
133-
)
134-
}
135-
.expect("cannot extract timezone from timetz");
136-
137-
let timezone_as_secs: f64 = timezone_as_secs
138-
.try_into()
139-
.unwrap_or_else(|e| panic!("{}", e));
140-
141-
timezone_as_secs
142-
}
143-
}
144-
14556
#[allow(non_snake_case)]
14657
pub(crate) fn MarkGUCPrefixReserved(guc_prefix: &str) {
147-
#[cfg(any(feature = "pg13", feature = "pg14"))]
58+
#[cfg(feature = "pg14")]
14859
unsafe {
14960
pgrx::pg_sys::EmitWarningsOnPlaceholders(guc_prefix.as_pg_cstr())
15061
}

src/type_compat/pg_arrow_type_conversions.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use pgrx::{
55
direct_function_call, pg_sys, AnyNumeric, IntoDatum,
66
};
77

8-
use crate::parquet_copy_hook::pg_compat::extract_timezone_from_timetz;
9-
108
pub(crate) const MAX_DECIMAL_PRECISION: usize = 38;
119

1210
pub(crate) fn date_to_i32(date: Date) -> i32 {
@@ -130,7 +128,17 @@ pub(crate) fn i64_to_time(i64_time: i64) -> Time {
130128
}
131129

132130
pub(crate) fn timetz_to_i64(timetz: TimeWithTimeZone) -> i64 {
133-
let timezone_as_secs = extract_timezone_from_timetz(timetz);
131+
let timezone_as_secs: AnyNumeric = unsafe {
132+
direct_function_call(
133+
pg_sys::extract_timetz,
134+
&["timezone".into_datum(), timetz.into_datum()],
135+
)
136+
}
137+
.expect("cannot extract timezone from timetz");
138+
139+
let timezone_as_secs: f64 = timezone_as_secs
140+
.try_into()
141+
.unwrap_or_else(|e| panic!("{}", e));
134142

135143
let timezone_as_interval = Interval::from_seconds(timezone_as_secs);
136144
let adjusted_timetz: TimeWithTimeZone = unsafe {

0 commit comments

Comments
 (0)