Commit graph

41 commits

Author SHA1 Message Date
Yorhel
b3281924d1 Pg: Add escape_literal() and escape_identifier()
Didn't expect I'd ever need these, but they're useful for generating SQL
scripts.
2025-04-07 13:45:33 +02:00
Yorhel
6159b33950 FU::Util: Add brotli_compress() and use it for FU output compression
Seems to compresses and perform better than libdeflate at level 6, so
certainly worth using.
2025-03-19 10:12:20 +01:00
Yorhel
bc33fe53f0 FU::Util: Add gzip_compress() wrapper for libdeflate/zlib-ng/zlib
And use it for automatic output compression in FU, as (potentially)
faster alternative to Compress::Raw::Zlib.

Was also planning to maybe add support for Zstd or Brotli, but given the
performance of libdeflate, I'm not sure that's really necessary. Brotli
does tend to do a better job at compressing HTML, though.
2025-03-18 16:59:43 +01:00
Yorhel
d9d2ad0434 Pg: Add COPY support 2025-03-10 12:32:14 +01:00
Yorhel
3fd424c6e3 Compat fixes + 0.2 release 2025-02-28 14:05:48 +01:00
Yorhel
15954f4ad5 Pg: Add "$hex" pseudo-type 2025-02-28 13:49:07 +01:00
Yorhel
0734bc4991 Pg: Skip query preparation when we can 2025-02-28 12:33:30 +01:00
Yorhel
4686097d00 Pg: Support custom type overrides with callbacks 2025-02-28 11:23:42 +01:00
Yorhel
327fd9ea50 Pg: Support type override configuration 2025-02-27 18:24:14 +01:00
Yorhel
43928b91e8 Fix two memory leaks 2025-02-26 08:53:16 +01:00
Yorhel
7b0ba45346 Docs, compatibility fixes again, 0.1 release 2025-02-25 17:02:33 +01:00
Yorhel
c7a3415485 Util: Add to_bool() and use it for JSON, Pg & query encoding
To improve interop with legacy modules.
2025-02-25 09:33:33 +01:00
Yorhel
18e642290d Some fixes and framework docs 2025-02-23 14:05:43 +01:00
Yorhel
b2d676b1ed pg: Add query tracing & prepare/execute time measurements
What I'd really like, in addition to this, is a way to extract a query
from an $st object that can be run in the psql CLI. VNDB has a debugging
feature for that, but it's less trivial to make that work with binary
query parameters.
2025-02-22 15:15:16 +01:00
Yorhel
9014e2900c Add FU::XMLWriter
And remove UTF-8 check in JSON writer. It honestly feels kind of silly
to do that validation there while I've never done similar validations in
any other output routines - including this XML writer.

FU::XMLWriter is a copy of TUWF::XMLXS with a bunch of improvements
applied: now uses refcounts to determine the current output instance,
auto-generates XS functions and has faster escaped string output -
inspired by the JSON writer.

TODO:
- Integrate into FU
- Do something with bool attribute values
- Benchmarks
- Should $content be optional for all tags? The reason they weren't in
  TUWF::XMLXS is because TUWF::XML supports opening tags without closing
  them, but that idea turned out to suck and isn't supported anymore.

This is hopefully the last XS module for the FU framework. The only C
code being written now should be bug fixes and extending FU::Pg with
some planned features. Already ended up with more C than I had
planned...
2025-02-19 12:01:24 +01:00
Yorhel
90cfd66069 FU: Some FastCGI fixes; FU::Util: utf8_decode & URI escaping 2025-02-18 10:27:58 +01:00
Yorhel
d9fba4e8d8 FU: Add FastCGI support + bunch of fixes
I initially planned to only implement the bare minimum to support
FastCGI under nginx, but ended up implementing the full protocol
instead. This is more code than I had expected and the code is also less
trivial than I had hoped. Will need to do more testing, pretty sure
there's bugs left.

Also TODO: test under alternative process managers + document
FU_LISTEN_PROTO.

I've also removed the max_request_body setting, this is something that
really ought to be configured in the web server instead.
2025-02-17 15:15:38 +01:00
Yorhel
3e84a4f4d3 FU: Implement --monitor, add some docs; FU::Util: add fdpass functions 2025-02-15 15:09:56 +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
7076714296 pgtypes: Support cidr and inet 2025-02-10 10:54:25 +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
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
7cdc02e399 jsonparse: Add basic JSON parser
Some TODO's left and this needs benchmarking.
2025-01-31 07:29:06 +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
12326ca8e4 jsonfmt: Fix threading support + memory leak bug 2025-01-28 19:20:46 +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