On Fri, Jun 17, 2022 at 06:59:29AM +0000, Hamid Maadani wrote: > > You need to use a static variable to record whether you've already > > initialised the library, and do it just once. No need to worry about > > threads or locks. Postfix is single-threaded. > > This is also done.
Also, the "client pool" is pointless, Postfix processes are not multi-threaded. Instead use a single dedicated (long-term) connection per open table, but be prepared to retry if the connection was unilaterally closed on the server side. I'd rename "result_key" to "result_attribute" and allow it to be multi-valued (multiple potential columns to retrieve from the returned object, either alternatives, or sometimes many from the same object). Also, your parsing of the search_keys is hand-rolled, but should be using mystrtok(3) to split the list on commas/whitespace, and split_nameval(3) to split "key = value" pairs on "=". Also vstring allocation is not an upper bound, but a guestimated size, and you should be appending to them via vstring_sprintf_append(3) and the like, not poking bytes directly into the buffer... Also the docs have: search_keys = username:"%s", active:1 Your code is responsible for proving a JSON-compatible quoting function that encodes the string interpolated via the "%s". This needs to be passed to db_common_expand(). Otherwise the query can easily be malformed/manipulated: https://xkcd.com/327/ -- Viktor.