-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
workload/schemachange: screen for errors in operations #56184
workload/schemachange: screen for errors in operations #56184
Conversation
23b6a30
to
2f1f2cc
Compare
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 made it through 2 commits
Reviewed 2 of 2 files at r1, 2 of 2 files at r2.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @jayshrivastava)
pkg/workload/schemachange/error_screening.go, line 90 at r1 (raw file):
Quoted 13 lines of code…
return scanBool(tx, `SELECT EXISTS ( SELECT fd.descriptor_name FROM crdb_internal.forward_dependencies AS fd WHERE fd.descriptor_id = ( SELECT c.oid FROM pg_catalog.pg_class AS c JOIN pg_catalog.pg_namespace AS ns ON ns.oid = c.relnamespace WHERE c.relname = $1 AND ns.nspname = $2 ) )`, tableName.Object(), tableName.Schema())
nit: sqlfum.pt
SELECT EXISTS(
SELECT fd.descriptor_name
FROM crdb_internal.forward_dependencies AS fd
WHERE fd.descriptor_id
= (
SELECT c.oid
FROM pg_catalog.pg_class AS c
JOIN pg_catalog.pg_namespace AS ns ON
ns.oid = c.relnamespace
WHERE c.relname = $1 AND ns.nspname = $2
)
);
pkg/workload/schemachange/error_screening.go, line 95 at r2 (raw file):
} func columnIsDependedOn(tx *pgx.Tx, tableName *tree.TableName, columnName string) (bool, error) {
commentary on how this works would be helpful. Namely explain the structure of the data you are picking apart.
Also, it feels like you could do this is sql with only modestly more clunkiness.
Also, this doesn't seem to work on foreign key references :(
pkg/workload/schemachange/error_screening.go, line 154 at r2 (raw file):
func colIsPrimaryKey(tx *pgx.Tx, tableName *tree.TableName, columnName string) (bool, error) { return scanBool(tx, `SELECT EXISTS(
nit: sqlfumpt
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.
Okay, made it through all of it. Mostly just would like to see a bit more commentary where stuff is getting big. Otherwise
Reviewed 1 of 1 files at r11.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @jayshrivastava)
pkg/workload/schemachange/error_screening.go, line 95 at r2 (raw file):
Previously, ajwerner wrote…
commentary on how this works would be helpful. Namely explain the structure of the data you are picking apart.
Also, it feels like you could do this is sql with only modestly more clunkiness.
Also, this doesn't seem to work on foreign key references :(
yeah I'm worried you may also need a join on pg_constraint, depending on what you're intending to use this for eventually. Comment that this is about dependencies which prevent drops and not foreign keys.
pkg/workload/schemachange/operation_generator.go, line 567 at r11 (raw file):
} uniqueColumnNames := map[string]bool{}
commentary here is starting to be in order.
b312e93
to
410a96e
Compare
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.
Reviewed 1 of 2 files at r13, 1 of 1 files at r22.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @jayshrivastava)
Release note: None
Release note: None
Duplicate and/or ambiguous columns can exist in createView and createTableAs statements because tables and views can now be generated from others which may have columns in common. This commit adds error handling for duplicate columns and also qualifies column names in createTableAs or createView statements to remove ambiguity. Release note: None
Release note: None
Release note: None
Release note: None
Release note: None
Release note: None
Release note: None
Release note: None
Release note: None
410a96e
to
6ebfb07
Compare
bors r=ajwerner |
Build failed: |
bors retry |
Build succeeded: |
workload/schemachange: screen for errors in operations
These changes add error screening for the following (#56119):
Also, errors caused by schema changes after writes in the same txn are handled (#56230)
It also resolves a bug related to ambiguity in column names that was caused by views/tables referencing the same columns (#56235).