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

importccl: support unchecked foreign keys in IMPORT PGDUMP #27425

Merged
merged 1 commit into from
Jul 12, 2018
Merged

importccl: support unchecked foreign keys in IMPORT PGDUMP #27425

merged 1 commit into from
Jul 12, 2018

Conversation

maddyblue
Copy link
Contributor

We achieve this by implementing sql.SchemaResolver with a map from the
found tables in the IMPORT and using that to resolve table names during
FK creation.

Release note (sql change): support foreign keys in IMPORT PGDUMP.

@maddyblue maddyblue requested review from dt and a team July 12, 2018 05:46
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@dt dt left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 6 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/ccl/importccl/import_stmt.go, line 259 at r1 (raw file):

// Implements the sql.SchemaResolver interface.
func (r fkResolver) LogicalSchemaAccessor() sql.SchemaAccessor {
	return nil

I'm a little wary of returning zero values rather than panicking if we think we'll never be called, just in case we start silently returning non-sense later and it goes undetected. /¢2.


pkg/ccl/importccl/read_import_pgdump.go, line 254 at r1 (raw file):

				switch cmd := cmd.(type) {
				case *tree.AlterTableAddConstraint:
					create.Defs = append(create.Defs, cmd.ConstraintDef)

this is going to break on circular reference relationships.

I think we'll need to evaluate all the CREATEs into descs, then modify the descs to add the FKs rather than letting MakeSimpleTableDesc do it for us.

More than happy to punt that to a follow up though.

Copy link
Contributor Author

@maddyblue maddyblue left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/ccl/importccl/import_stmt.go, line 259 at r1 (raw file):

Previously, dt (David Taylor) wrote…

I'm a little wary of returning zero values rather than panicking if we think we'll never be called, just in case we start silently returning non-sense later and it goes undetected. /¢2.

I agree. And it's unclear what to do here. I feel like explicitly panicking here is wrong, but returning a nil will just panic somewhere else for maybe an unclear reason? Dunno. I'm going to merge as is and we can change it if we need to.

@maddyblue
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 12, 2018

Build failed

@maddyblue maddyblue requested a review from a team July 12, 2018 18:55
@maddyblue
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 12, 2018

Build failed

We achieve this by implementing sql.SchemaResolver with a map from the
found tables in the IMPORT and using that to resolve table names during
FK creation.

Release note (sql change): support foreign keys in IMPORT PGDUMP.
@maddyblue
Copy link
Contributor Author

bors r+

craig bot pushed a commit that referenced this pull request Jul 12, 2018
27425: importccl: support unchecked foreign keys in IMPORT PGDUMP r=mjibson a=mjibson

We achieve this by implementing sql.SchemaResolver with a map from the
found tables in the IMPORT and using that to resolve table names during
FK creation.

Release note (sql change): support foreign keys in IMPORT PGDUMP.

Co-authored-by: Matt Jibson <[email protected]>
@craig
Copy link
Contributor

craig bot commented Jul 12, 2018

Build succeeded

@craig craig bot merged commit 9c852c0 into cockroachdb:master Jul 12, 2018
@maddyblue maddyblue deleted the import-pgdump-fk branch July 12, 2018 21:10
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.

3 participants