-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Imply NOT_IN_SAMPLE
for GucFlags::NO_SHOW_ALL
#1925
Conversation
Postgres requires this as invariant[1] and not following causes an assertion failure in debug builds. [1]: https://github.com/postgres/postgres/blob/dbedc461b4e7a9cb4d6f5777174bdf180edb95fd/src/backend/utils/misc/guc.c#L1506-L1519
@Ngalstyan4 your "source" link doesn't work at all, it seems. |
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. |
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
NOT_IN_SAMPLE
for GucFlags::NO_SHOW_ALL
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 wheneverNO_SHOW_ALL
is set2. Make applyingGucFlags::NO_SHOW_ALL
also applyNOT_IN_SAMPLE
, asNOT_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 likeNO_SHOW_ALL_AND_NO_SAMPLE
, but not sure if it is worth it.Footnotes
https://github.com/lanterndata/lantern ↩
https://github.com/postgres/postgres/blob/dbedc461b4e7a9cb4d6f5777174bdf180edb95fd/src/backend/utils/misc/guc.c#L1506-L1519 ↩