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

Imply NOT_IN_SAMPLE for GucFlags::NO_SHOW_ALL #1925

Merged

Conversation

Ngalstyan4
Copy link
Contributor

@Ngalstyan4 Ngalstyan4 commented Oct 23, 2024

Hi all,

firstly, thanks for giving pgrx to the world!

We use pgrx at Lantern1 and when configuring GUCs noticed a small issue with GUC flags. Postgres requires GUC_NOT_IN_SAMPLE GUC flag to be set whenever NO_SHOW_ALL is set2. Make applying GucFlags::NO_SHOW_ALL also apply NOT_IN_SAMPLE, as NOT_IN_SAMPLE cannot be set.

After applying this diff, we no longer have a direct name matching between pgrx GUC names and postgres ones. An alternative might be to deprecate NO_SHOW_ALL and introduce something like NO_SHOW_ALL_AND_NO_SAMPLE, but not sure if it is worth it.

Footnotes

  1. https://github.com/lanterndata/lantern

  2. https://github.com/postgres/postgres/blob/dbedc461b4e7a9cb4d6f5777174bdf180edb95fd/src/backend/utils/misc/guc.c#L1506-L1519

@workingjubilee
Copy link
Member

@Ngalstyan4 your "source" link doesn't work at all, it seems.

@Ngalstyan4
Copy link
Contributor Author

sorry, this is what I was referring to: https://github.com/postgres/postgres/blob/dbedc461b4e7a9cb4d6f5777174bdf180edb95fd/src/backend/utils/misc/guc.c#L1506-L1519

Fixed the link in the description above as well.

@workingjubilee
Copy link
Member

Thank you.

...I wonder why they don't just make one flag imply... well, anyway.

/// Flags to control special behaviour for the GUC that these are set on. See their
/// descriptions below for their behaviour.
pub struct GucFlags: i32 {
/// Exclude from SHOW ALL
const NO_SHOW_ALL = pg_sys::GUC_NO_SHOW_ALL as i32;
const NO_SHOW_ALL = pg_sys::GUC_NO_SHOW_ALL as i32 | pg_sys::GUC_NOT_IN_SAMPLE as i32;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This technically prevents independently setting these. Or at least not in an easy and error-free way.

Not sure I or anyone else cares about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, you mean it prevents independently setting pg_sys::NO_SHOW_ALL, right?

pg_sys::GUC_NOT_IN_SAMPLE is not exposed via a safe wrapper as GucFlags member, but my understanding is that if/when that is exposed, then that and all the other flags can still be set independently.

pg_sys::NO_SHOW_ALL cannot be set independently but that seems to be a postgres invariant (even though the invariant is not enforced in C)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by set independently, I mean if one did this:

let guc_flags = GucFlags::NO_SHOW_ALL;
let guc_flags = guc_flags & !GucFlags::NOT_IN_SAMPLE;

that would be obviously incorrect.
more subtle:

let guc_flags = GucFlags::NOT_IN_SAMPLE;
let guc_flags = guc_flags & !GucFlags::NO_SHOW_ALL;

...I think I'd have to use some function calls on the bitflags API surface instead, since I think it doesn't auto-implement operators, but you get the idea. It does implement a trait that has the equivalent functions as those operators.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyways, we will worry this slightly unintuitive behavior if we ever have anyone ask for NOT_IN_SAMPLE.

@workingjubilee workingjubilee changed the title Narek/guc flags Imply NOT_IN_SAMPLE for GucFlags::NO_SHOW_ALL Oct 24, 2024
@workingjubilee workingjubilee merged commit 0193fd0 into pgcentralfoundation:develop Oct 24, 2024
14 checks passed
@Ngalstyan4 Ngalstyan4 deleted the narek/guc-flags branch October 24, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants