Skip to content

Split static and dynamic namespace contexts#2600

Merged
ChristianGruen merged 2 commits intoBaseXdb:mainfrom
GuntherRademacher:namespace-context
Mar 17, 2026
Merged

Split static and dynamic namespace contexts#2600
ChristianGruen merged 2 commits intoBaseXdb:mainfrom
GuntherRademacher:namespace-context

Conversation

@GuntherRademacher
Copy link
Member

The namespace context previously mixed statically declared and dynamically scoped namespaces in NSContext. As NSContext instances are shared per compiled module, this led to concurrency issues when dynamic namespace bindings were modified at runtime via xquery:fork-join.

This change separates concerns:

  • NSContext now holds only statically declared (module) namespaces
  • the new NSDynContext maintains the dynamic namespace stack and is owned by QueryContext
  • NSDynContext instances are duplicated when QueryContext is forked, ensuring thread isolation
  • namespace resolution now combines dynamic and static parts explicitly

This fixes concurrency issues with dynamic namespace handling. It handles all existing BaseX and QT4 tests in the same way as before. However this new test would fail:

    query("<x xmlns:x=\"X\">{#x:b = text{'x:b'}}</x>", "<x xmlns:x=\"X\">true</x>");

The reason is in QNm.compare: it needs access to the dynamic namespaces, which it does no longer have with the changes presented here. And adding QueryContext qc to the signature will cause a whole lot of further changes.

@GuntherRademacher
Copy link
Member Author

@ChristianGruen Merge conflicts have been resolved.

@ChristianGruen ChristianGruen merged commit a784669 into BaseXdb:main Mar 17, 2026
1 check passed
@ChristianGruen ChristianGruen deleted the namespace-context branch March 17, 2026 11:23
@ChristianGruen
Copy link
Member

Thanks. I think we can perfectly live with the unresolved corner case for the moment.

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.

2 participants