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

fix(frontend): require primary key for system table #15126

Merged
merged 3 commits into from
Feb 23, 2024

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Feb 19, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

See #15125 for the background.

We should not default to empty primary key for #[derive(Fields)] without specifying primary keys, or the semantics will be "at most one row".

The ultimate solution could be making the pk field of TableDesc and TableCatalog to be an Option. However, this may require a much more significant refactor. Note that we're only misusing the primary key of the system table, so I simply add a requirement for specifying the primary key for system_table proc macro in this PR.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Copy link
Member Author

BugenZhao commented Feb 19, 2024

@github-actions github-actions bot added the type/fix Bug fix label Feb 19, 2024
@BugenZhao BugenZhao force-pushed the bz/pg-settings-tab-completion branch from 51a0edd to 28364c9 Compare February 19, 2024 08:40
@BugenZhao BugenZhao force-pushed the bz/require-primary-key-for-system-table branch from 32063cc to 70a31db Compare February 19, 2024 08:41
@BugenZhao BugenZhao marked this pull request as ready for review February 19, 2024 08:41
@@ -19,6 +19,7 @@ use crate::catalog::system_catalog::SysCatalogReaderImpl;
use crate::error::Result;

#[derive(Fields)]
#[primary_key(object_id, sst_id)] // TODO: is this correct?
Copy link
Member Author

Choose a reason for hiding this comment

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

cc @zwang28 🥺

@@ -117,7 +117,9 @@ fn get_primary_key(input: &syn::DeriveInput) -> Option<Vec<usize>> {
return Some(
keys.to_string()
.split(',')
.map(|s| index(s.trim()))
.map(|s| s.trim())
.filter(|s| !s.is_empty())
Copy link
Member Author

Choose a reason for hiding this comment

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

So that we can attach #[primary_key()] on the struct to specify empty primary keys.

Copy link
Contributor

@wangrunji0408 wangrunji0408 left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from bz/pg-settings-tab-completion to main February 19, 2024 09:05
@BugenZhao BugenZhao force-pushed the bz/require-primary-key-for-system-table branch from 70a31db to 320f737 Compare February 19, 2024 09:57
@st1page
Copy link
Contributor

st1page commented Feb 20, 2024

So does all systable have one primary key? If not, maybe we do not need this

The ultimate solution could be making the pk field of TableDesc and TableCatalog to be an Option

And if we can add an hidden column for those systable without pk?

@BugenZhao
Copy link
Member Author

So does all systable have one primary key?

What do you mean by "one"? At least after this PR, every system table will have non-empty primary key.

If not, maybe we do not need this

Need what? Can you elaborate more?

@BugenZhao
Copy link
Member Author

we can add an hidden column for those systable without pk

Yeah, this could be another feasible approach.

@st1page
Copy link
Contributor

st1page commented Feb 20, 2024

So does all systable have one primary key?

What do you mean by "one"? At least after this PR, every system table will have non-empty primary key.

If not, maybe we do not need this

Need what? Can you elaborate more?

Sorry, I mean I prefer to make all the table must have a primary key instead of make the field optional.

Signed-off-by: Bugen Zhao <[email protected]>
@BugenZhao BugenZhao enabled auto-merge February 20, 2024 09:25
Copy link
Contributor

@chenzl25 chenzl25 left a comment

Choose a reason for hiding this comment

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

LGTM!

auto-merge was automatically disabled February 22, 2024 06:09

Merge queue setting changed

@BugenZhao BugenZhao added this pull request to the merge queue Feb 23, 2024
Merged via the queue into main with commit b95d9a9 Feb 23, 2024
27 of 28 checks passed
@BugenZhao BugenZhao deleted the bz/require-primary-key-for-system-table branch February 23, 2024 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants