Psql Native PostgreSQL client library with Zig, stable and upstream support

gitlab link

I have created a posqtgresql client for zig with support for zig stable in dev-zig-stable branche
and zig upstream in dev-zig-upstream

how can I make it std-like in its style and code structure?

1 Like

I haven’t reviewed your project, but I’d say that’s a question best answered by yourself and applied during design and implementation rather than after the fact.

In general:

  • Format the code using the Zig formatter
  • Make your containers unmanaged: don’t embed allocators.
  • Use the documented naming conventions
  • Prefer DOD over OOP

However “being like std” really shouldn’t be the primary hoal. The primary goals should be simplicity, clarity, and efficiency in the applicable domain.

2 Likes

PostgresQL is crazy work on the capitalization!

you can see an example dir if you want to see it in action, no need for an actual review :heart:

The API accepts an allocator in its functions with an internal allocator only used for the reader’s buffer

Yeah thanks, I have value.zig and Message.zig separated from the rest. but having less allocations is the goal

“PosthreSQL“ right?

Recently I have revisited my EDSM stuff

and, as a part of the activity, I decomposed connector machine into two “layers“:

  • L1 - pure TCP-connector
  • L2 - service specific (PG, AMQP, MQTT etc) layer

Source (C, but I do not see no problem to translate that into Zig) attached.

Note that

  • it’s able to use MD5 or SCRAM-SHA-256 auth methods only, add another if you want, it’s pretty simple
  • there is no I/O in the code, only MEM/CPU bound stuff, I/O is a task for TX/RX machines

pgcx.c (13.7 KB)