Skip to content

sqlbase: add validation for type cross references in table descs#51149

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rohany:validate-col-types
Jul 13, 2020
Merged

sqlbase: add validation for type cross references in table descs#51149
craig[bot] merged 1 commit intocockroachdb:masterfrom
rohany:validate-col-types

Conversation

@rohany
Copy link
Copy Markdown
Contributor

@rohany rohany commented Jul 8, 2020

This PR adds validation for any referenced types within a table
descriptor.

Release note: None

@rohany rohany requested review from jordanlewis and otan July 8, 2020 15:37
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

if typeDesc, ok := typeMap[id]; ok {
return typeDesc, nil
}
typeDesc, err := GetTypeDescFromID(ctx, txn, codec, id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wonder if we need to batch fetch these at one point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah jordan brought up on a different PR to pass in an interface here rather than a txn to be smarter about the lookups done.

// TODO(dan): Also validate SharedPrefixLen in the interleaves.

// Validate the all types present in the descriptor exist.
typeMap := make(map[ID]*TypeDescriptor)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if we're not using the return value, any reason to not just do util.FastIntSet?
also add a comment the function is a wrapper to do caching?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not useful to use FastIntSet for things like descriptor ID's, since they are usually larger than 64. Also, the call to GetAllReferencedTypeIDs needs the TypeDescriptors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a comment

@rohany rohany force-pushed the validate-col-types branch 2 times, most recently from 64fcdb8 to 901d323 Compare July 8, 2020 15:45
@rohany rohany force-pushed the validate-col-types branch from 901d323 to 304cd9c Compare July 8, 2020 19:21
@rohany rohany requested review from a team and dt and removed request for a team July 8, 2020 19:21
@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Jul 8, 2020

cc @dt for the discussion we had on slack.

@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Jul 13, 2020

@dt can you take a look at the import changes here?

This PR adds validation for any referenced types within a table
descriptor.

Release note (enterprise change): Disables the use of `IMPORT` with user
defined types. Users should use `IMPORT INTO` instead.
@rohany rohany force-pushed the validate-col-types branch from 304cd9c to bffe18e Compare July 13, 2020 18:37
@dt
Copy link
Copy Markdown
Contributor

dt commented Jul 13, 2020

IMPORT changes look good to me.

@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Jul 13, 2020

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jul 13, 2020

Build succeeded

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.

5 participants