Repository navigation
Conversation
…xists
The parent-namespace check uses LIKE, which SQLite evaluates
case-insensitively for ASCII. With only `sales.eu` present,
`namespace_exists("SALES")` returned True, so `create_table("SALES.t")`
succeeded in a namespace that does not exist and `create_namespace("SALES")`
failed with NamespaceAlreadyExistsError. Re-check the LIKE matches with a
case-sensitive prefix comparison so the result matches the exact-equality
lookups used elsewhere in the catalog.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4163
Rationale for this change
SqlCatalog.namespace_existsalso reports a namespace as existing when a child namespace exists, usingLIKE '<namespace>.%'. SQLite evaluatesLIKEcase-insensitively for ASCII characters, so with onlysales.euin the catalog,namespace_exists("SALES")returned True. As a resultcreate_table("SALES.orders")succeeded in a namespace that does not exist, andcreate_namespace("SALES")failed withNamespaceAlreadyExistsError. The exact-match comparisons elsewhere in the catalog are case-sensitive, and PostgreSQL'sLIKEis case-sensitive too.This keeps the
LIKEfilter in the query and re-checks the matched namespace names with a case-sensitive prefix comparison in Python.list_namespacesalready filters the same way after itsLIKEquery. The queries now select only the namespace column withDISTINCTinstead of whole rows withLIMIT 1, because a row whose case differs could come back first.Are these changes tested?
Yes.
test_namespace_existsintests/catalog/test_catalog_behaviors.pynow also checks thatDB2anddb3.NS1are not reported as existing whendb2.ns1anddb3.ns1.ns2exist. It fails on main for thememory,sqlandsql_without_rowcountcatalogs and passes with this change.make testandmake lintpass.Are there any user-facing changes?
On SQLite,
namespace_existsand the operations that depend on it no longer treat a namespace as existing just because a child namespace with a different case exists.