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

node: Introduce new module for working with postgres Node types #68

Merged
merged 1 commit into from
Jun 23, 2024

Conversation

urso
Copy link
Collaborator

@urso urso commented Jun 21, 2024

Requires #67

Closes #66

Postgres sources use tagging and the Node (and NodeTag) types for many internal types. Unfortunately the macros did not translate well to Zig, which makes it annoying to work with the low level types.

We introduce the pgzx.node module that provides a list of helper functions like pgzx.node.make, pgzx.node.create, pgzx.node.tag, or pgzx.node.isA.

We also wrap the constants into our own pgzx.node.Tag enum, so you can use pgzx.node.isA(node, .Query) in code.

Postgres uses code generation to collect the node tags and supported types into nodetags.h. We also use code generation to produce the list of tags and type mappings. The generated module is then imported by pgzx.node.

The tools/gennodetags tool imports the nodes/nodes.h header file at compile time and uses comptime to collect all known tags into an ArrayList which is then used to produce the sources for the anonymous module imported into pgzx.

@urso urso requested a review from tsg June 21, 2024 15:17
@urso urso marked this pull request as ready for review June 22, 2024 17:56
@urso urso merged commit a1f6f4c into xataio:main Jun 23, 2024
1 check passed
@urso urso deleted the mod-node branch June 23, 2024 18:13
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.

Improve nodes support
2 participants