Skip to content

Conversation

Tishj
Copy link
Contributor

@Tishj Tishj commented Feb 15, 2024

Supersedes #8619

This PR fixes https://github.com/duckdblabs/duckdb-internal/issues/120
This PR fixes #8496
This PR fixes #9713

This PR will:

  • Remove limitations on Alter, no Alter will be blocked by existing dependencies anymore(1)
  • Add dependencies for Foreign Key constraints.
  • Contain all the improvements regarding EXPORT DATABASE and Dependency management made by Fix EXPORT/IMPORT DATABASE schema.sql order #8619

We introduce LogicalDependency as a precursor to PhysicalDependency, this merely contains the information needed to look up the catalog entry, so it's safe to serialize/deserialize

Inside SingleFileCheckpointWriter::CreateCheckpoint() there was a duplicate of GetNaiveExportOrder, this now uses the DependencyManager::GetExportOrder method

Views now create a dependency on the table they're referencing (as long as they are in the same catalog)
This changes some existing behavior, but is in line with postgres behavior

postgres=# drop table tbl;
ERROR:  cannot drop table tbl because other objects depend on it
DETAIL:  view vw depends on table tbl
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

1: Indexes are not included in this, this requires some additional work that needs to be done outside of this PR

Tishj added 30 commits August 17, 2023 16:24
…inders CatalogEntryRetriever, add tests with created types and dependencies created by them
… dependencies of the generated columns are registered as dependencies of the table
…, don't make any cross-catalog dependencies, detect and properly error when CREATE OR REPLACE statements depend on itself
@Tishj Tishj requested a review from Mytherin February 15, 2024 11:55
Copy link
Contributor Author

@Tishj Tishj left a comment

Choose a reason for hiding this comment

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

Some things I noticed:
(been a while since I actively worked on this)

@github-actions github-actions bot marked this pull request as draft February 19, 2024 12:43
@Tishj
Copy link
Contributor Author

Tishj commented Mar 13, 2024

# Because this is part of a CTAS we don't register this as a dependency..
statement maybe
CREATE OR REPLACE TABLE t2 AS (
	SELECT struct_pack(a := -54124033386577348004002656426531535114)::my_struct FROM t2 LIMIT 70%
);
----
write-write conflict

One thing I discovered while playing around with this, in this case we would want to register the type as a dependency, but not the table used, currently we don't register any of them as a dependency.

@Tishj Tishj closed this May 30, 2024
Mytherin added a commit that referenced this pull request Oct 11, 2024
…s before export (#14196)

This PR fixes duckdblabs/duckdb-internal#3050
This PR is a revival of #10677

We use GetNaiveExportOrder as we already do, but now we use
`DependencyManager::ReorderEntries` to make sure a dependent entry gets
exported first if the dependency manager is aware that there is a
dependency on the entry.
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.

Cannot alter entry on valid(?) syntax export database can save views out of order breaking import.
1 participant