Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correctly spanned fcinfo #433

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use correctly spanned fcinfo
Signed-off-by: Ana Hobden <operator@hoverbear.org>
Hoverbear committed Feb 10, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 09508b7a6699ef411b0e56d0d761515dc3f1716b
25 changes: 1 addition & 24 deletions pgx-macros/src/rewriter.rs
Original file line number Diff line number Diff line change
@@ -723,30 +723,7 @@ impl FunctionSignatureRewriter {

let mut stream = proc_macro2::TokenStream::new();
let mut i = 0usize;
let mut fcinfo_ident = None;

// Get the fcinfo ident, if it exists.
// We do this because we need to get the **right** ident, if it exists, so Rustc
// doesn't think we're pointing at the fcinfo module path.
for arg in &self.func.sig.inputs {
match arg {
FnArg::Typed(ty) => match ty.pat.deref() {
Pat::Ident(ident) => {
if type_matches(&ty.ty, "pg_sys :: FunctionCallInfo")
|| type_matches(&ty.ty, "pgx :: pg_sys :: FunctionCallInfo")
{
if fcinfo_ident.is_some() {
panic!("When using `pg_sys::FunctionCallInfo` as an argument it must be the last argument");
}
fcinfo_ident = Some(ident.ident.clone());
}
},
_ => (),
},
_ => ()
}
}
let fcinfo_ident = fcinfo_ident.unwrap_or(syn::Ident::new("fcinfo", Span::call_site()));
let fcinfo_ident: syn::Ident = syn::parse_quote! { fcinfo };

for arg in &self.func.sig.inputs {
match arg {
6 changes: 6 additions & 0 deletions pgx-tests/src/tests/fcinfo_tests.rs
Original file line number Diff line number Diff line change
@@ -96,6 +96,12 @@ fn same_name(same_name: &str) -> &str {
same_name
}

// Tests for regression of https://github.com/zombodb/pgx/issues/432
#[pg_extern]
fn bar_func(_x: PgBox<pg_sys::IndexAmRoutine>, _fcinfo: pg_sys::FunctionCallInfo) -> PgBox<pg_sys::IndexAmRoutine> {
todo!()
}

#[cfg(any(test, feature = "pg_test"))]
#[pgx::pg_schema]
mod tests {