Commit graph

49 commits

Author SHA1 Message Date
Yorhel
3e84a4f4d3 FU: Implement --monitor, add some docs; FU::Util: add fdpass functions 2025-02-15 15:09:56 +01:00
Yorhel
09fe50d2a2 FU: Add supervisor daemon thingy
A little tricky to get right, but it works pretty well.

TODO: Do something with --monitor.

I initially wanted to avoid the exec() and just let Perl continue
running the rest of the script after fork(), but that runs into the
problem that perl really doesn't like it when you fork() in BEGIN.
2025-02-14 14:39:44 +01:00
Yorhel
08410e56f5 FU: More frameworking stuff
It's actually somewhat usable already.

Except this a lot of code without documentation or tests...
2025-02-14 06:42:51 +01:00
Yorhel
b15c70d3c6 FU: Small start on the actual website framework
Not fully done with FU::Pg yet, but could use a change of pace.
2025-02-13 14:48:54 +01:00
Yorhel
d5401674f9 pg: Minor docs + tests 2025-02-13 08:50:40 +01:00
Yorhel
867543267f Fixes for perl 5.36 with multiplicity + memleak in $st->kv methods
I always keep messing up the aTHX_ and pTHX_ stuff because my system
perl isn't built with multiplicity, and I still haven't found a
satisfactory way of finding SV leaks. Valgrind can't track those :(
2025-02-13 06:26:58 +01:00
Yorhel
1f7e2de9a0 pg: Add prepared statement caching
The tests are not as thourough as I would like. There's many ways to
mess this up.

I was initially planning to drop the ref on the prepared statement
immediately after executing the query, so that the $st object can be
kept around for introspection without consuming excess resources.
Unfortunately, PQcopyResult does not copy over information about bind
parameters, so we need another way to keep that information alive. I
ended up going for the simple solution: keep the ref on the prepared
statement...
2025-02-12 17:19:20 +01:00
Yorhel
87d99e412b pg: Add support for record/composite types
This is simply magical. \o/

Vendored in khashl.h. I wouldn't have used it if this were the only
place where I'd need a custom hash table, but it should come in handy
for other tasks as well, especially when I get to implementing an LRU
for prepared statement caching.

(Can all be done with Perl HV's, but they're less efficient and more
cumbersome for these tasks)
2025-02-11 16:04:10 +01:00
Yorhel
33fe0d98a8 pg: Module rename + more docs 2025-02-11 11:04:03 +01:00
Yorhel
ccc2f1dbf0 pg: Some refactoring + more result fetching methods 2025-02-10 15:48:08 +01:00
Yorhel
d95ff76d43 pg: Add support for domain types
+ refactor things a bit so that send & recv functions use the same
context struct, because the way they're setup is pretty much the same
for both. This also adds recursive type resolution for bind parameters.
2025-02-10 14:27:39 +01:00
Yorhel
7515032261 pgtypes: Support uuid and xid8 2025-02-10 11:41:22 +01:00
Yorhel
7076714296 pgtypes: Support cidr and inet 2025-02-10 10:54:25 +01:00
Yorhel
b66610e25a pgtypes: Cleaner error reporting 2025-02-10 09:46:11 +01:00
Yorhel
d5f593387a Abstract and cleanup ugly byte swapping code
These macros don't assume alignment and may be somewhat inefficient with
all that copying. I'm hoping GCC is able to optimize that crap somewhat.

Also the pg type receive functions can not, in fact, assume that their
input buffers are properly aligned. That won't necessarily be the case
for array elements.
2025-02-10 07:35:34 +01:00
Yorhel
7d71e446d0 pg: Support array types
That wasn't quite as painful as I had anticipated. \o/
2025-02-09 17:20:48 +01:00
Yorhel
b6517cf05a pg: Pipeline prepare + describeprepared 2025-02-09 09:26:01 +01:00
Yorhel
7b76d94719 pg: Add dynamic type loading & support enum types
Least efficient way to support enums, really. *shrug*
2025-02-08 17:24:52 +01:00
Yorhel
2aaec6a218 pg: Add json, jsonb, jsonpath support
NOW we're really getting to the part where this module is more awesome
than DBD::Pg.

(When I started working on this module I was expecting that the Postgres
binary protocol would send jsonb in a binary format as well and that I'd
be duplicating parts of the JSON parser/formatter to make that work, but
it turns out that Postgres just uses plain json for exchange. Saves me
some trouble, I guess)
2025-02-08 15:16:47 +01:00
Yorhel
7f1c48e0cf pg: Add send/recv support for a few more easy types 2025-02-08 14:03:35 +01:00
Yorhel
30b457d2b8 pg: Support binary bind params 2025-02-08 10:35:43 +01:00
Yorhel
166744dd51 pg: Rework txn implementation + statement config API
I liked the Perl implementation of transactions, but managing state
between Perl and C is a bit cumbersome, so I've moved the whole thing
into C.

Also added a few statement configuration methods that currently don't do
anything yet.
2025-02-07 18:30:36 +01:00
Yorhel
8f94dd0921 pg: Initial support for receiving binary results
Just the initial framework stuff and a few types to test with.
2025-02-07 15:18:45 +01:00
Yorhel
7c8473533d pg: More verbose error traces
Partly because some errors currently appeared to come from within FU::PG
itself, which is useless, and partly because it's common to wrap
database access methods, while that's exactly the kind of operation
where you *really* want to know where the error originated from.

(Source: too much time wasted debugging VNDB errors)
2025-02-07 11:06:56 +01:00
Yorhel
96aee880ce pg: ->disconnect() and docs 2025-02-07 10:49:47 +01:00
Yorhel
171afc0268 pg: Add transaction & subtransaction support
Was expecting the implementation of this to get overly complicated and
brittle, but using a counter-based cookie and doing parts of it in Perl
made it pretty easy actually.  Pretty happy with how this turned out so
far.

TODO: documentation -.-
2025-02-06 19:12:52 +01:00
Yorhel
9d5905e3b4 pg: Add a few result fetching methods
I'm not sure if these are free from memory leaks, need to find a way to
test for that.
2025-02-06 13:38:07 +01:00
Yorhel
711300b227 pg: Statement execution + better error reporting 2025-02-06 09:05:05 +01:00
Yorhel
922f19e39b pg: Some initial documentation 2025-02-05 14:18:01 +01:00
Yorhel
187417f160 pg: Statement preparing + inspection; less wonky object handling? 2025-02-05 11:49:22 +01:00
Yorhel
c51b5f3598 pg: Better error reporting + basic exec() method 2025-02-03 16:59:18 +01:00
Yorhel
b242176071 pg: Adventures in writing a new postgresql client 2025-02-02 16:22:15 +01:00
Yorhel
0d19ccdc1b Fix build for threaded perl + additional project idea 2025-02-01 13:39:58 +01:00
Yorhel
13eaeb1d4a jsonparse: Add max_depth, max_size and offset options
This completes all the functionality that I wanted from the JSON parser.
2025-02-01 11:01:49 +01:00
Yorhel
abfbba3c10 Add some tests and move some docs 2025-02-01 07:00:09 +01:00
Yorhel
ebe84167e7 jsonparse: A bunch of performance improvements
Turrns out JSON::XS had some pretty good ideas that I could borrow.
2025-01-31 18:42:21 +01:00
Yorhel
ca8d1b72be bench: Add JSON parsing benchmarks + nicer formatting
This shows I got some optimizing to do. I was expecting integer parsing
to be slower, though, but it looks like it can compete with JSON::XS's
specialized small-int parsing code anyway.
2025-01-31 10:36:06 +01:00
Yorhel
7cdc02e399 jsonparse: Add basic JSON parser
Some TODO's left and this needs benchmarking.
2025-01-31 07:29:06 +01:00
Yorhel
aebe5a93dc jsonfmt: Add pretty option
That completes the json_format() function for now. At least, it now does
everything I had planned for it.

Ended up at a bit over 300 LOC. That's larger than I had expected, but
still alright.
2025-01-30 09:11:34 +01:00
Yorhel
1a0fb03205 jsonfmt: Add canonical option
Not as bad as I had expected it to be; managed to keep the
implementation a little bit simpler and cleaner than JSON::XS.
2025-01-29 18:46:27 +01:00
Yorhel
163a60b4ba jsonfmt: Add max_size and max_depth options 2025-01-29 15:05:48 +01:00
Yorhel
a85ff98914 jsonfmt: Add TO_JSON convert_blessed support 2025-01-29 14:16:59 +01:00
Yorhel
8ef2a724d1 jsonfmt: Move arg parsing into XS
Going to need a way to pass arguments into the XS function anyway, so
might as well do the entire arg parsing step in XS while we're at it.
Provides a significant speedup for tiny inputs as well, but I don't find
that too interesting.
2025-01-29 11:42:15 +01:00
Yorhel
e0161cd22c jsonfmt: Add error reporting 2025-01-29 11:02:35 +01:00
Yorhel
3ae9347ad2 bench: Cache benchmark results + better re-run filtering 2025-01-29 10:19:51 +01:00
Yorhel
12326ca8e4 jsonfmt: Fix threading support + memory leak bug 2025-01-28 19:20:46 +01:00
Yorhel
9c8ce3f782 Add benchmarking tool + improve integer formatting performance
Typical priorities: make it fast before fixing all the bugs. *shrug*
2025-01-28 15:02:32 +01:00
Yorhel
c16a9fa493 Add initial JSON formatter
It works and can format all "plain" Perl data, but has a few known bugs
and limitations that still need to be worked out.

It's about 8x smaller than JSON::XS's encoder and *much* smaller than
Cpanel::JSON::XS, but this is just a first attempt, it'll grow.
2025-01-28 09:33:29 +01:00
Yorhel
9c80f2465a Init 2025-01-26 15:32:47 +01:00