From: | Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> |
---|---|
To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se> |
Subject: | Re: [PoC] Federated Authn/z with OAUTHBEARER |
Date: | 2024-09-03 20:56:07 |
Message-ID: | CAOYmi+k6oSACjoFvCUPipeLJBOrH=OgaeY9BeN1Mpsjna8taZg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Aug 30, 2024 at 2:49 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> This looks pretty good to me. Maybe on the naming side, this seems like
> a gratuitous divergence:
>
> +#define jsonapi_createStringInfo makeStringInfo
Whoops, fixed.
> Seems ok to me as is. I think the purpose of JSONAPI_USE_PQEXPBUFFER is
> adequately explained by this comment
>
> +/*
> + * By default, we will use palloc/pfree along with StringInfo. In libpq,
> + * use malloc and PQExpBuffer, and return JSON_OUT_OF_MEMORY on
> out-of-memory.
> + */
> +#ifdef JSONAPI_USE_PQEXPBUFFER
>
> For some of the other proposed names, I'd be afraid that someone might
> think you are free to mix and match APIs, OOM behavior, and compilation
> options.
Yeah, that's fair.
> Some comments on src/include/common/jsonapi.h:
>
> -#include "lib/stringinfo.h"
>
> I suspect this will fail headerscheck? Probably needs an exception
> added there.
Currently it passes on my machine and the cfbot. The
forward-declaration of the struct should be enough to make clients
happy. Or was there a different way to break it?
> +#ifdef JSONAPI_USE_PQEXPBUFFER
> +#define StrValType PQExpBufferData
> +#else
> +#define StrValType StringInfoData
> +#endif
>
> Maybe use jsonapi_StrValType here.
Done.
> +typedef struct StrValType StrValType;
>
> I don't think that is needed. It would just duplicate typedefs that
> already exist elsewhere, depending on what StrValType is set to.
Okay, removed.
> The parse_strval field could use a better explanation.
>
> I actually don't understand the need for this field. AFAICT, this is
> just used to record whether strval is valid.
No, it's meant to track the value of the need_escapes argument to the
constructor. I've renamed it and moved the assignment to hopefully
make that a little more obvious. WDYT?
> But in the cases where
> it's not valid, why do we need to record that? Couldn't you just return
> failed_oom in those cases?
We can do that if you'd like. I was just worried about using a valid
(broken) value of PQExpBuffer as a sentinel instead of a separate
flag. It would work as long as reviewers stay vigilant, but if we go
that direction and someone adds an unchecked
lex->strval = jsonapi_makeStringInfo();
// should check for NULL now, but we forgot
into a future patch, an allocation failure in _shlib builds would
silently disable string escaping instead of resulting in a
JSON_OUT_OF_MEMORY later.
Thanks,
--Jacob
Attachment | Content-Type | Size |
---|---|---|
since-v27.diff.txt | text/plain | 8.7 KB |
v28-0001-common-jsonapi-support-libpq-as-a-client.patch | application/octet-stream | 46.3 KB |
v28-0002-libpq-add-OAUTHBEARER-SASL-mechanism.patch | application/octet-stream | 118.6 KB |
v28-0003-backend-add-OAUTHBEARER-SASL-mechanism.patch | application/octet-stream | 67.8 KB |
v28-0004-Review-comments.patch | application/octet-stream | 6.3 KB |
v28-0005-DO-NOT-MERGE-Add-pytest-suite-for-OAuth.patch | application/octet-stream | 180.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-09-03 21:19:14 | Re: [PATCH] Add min/max aggregate functions to BYTEA |
Previous Message | Nathan Bossart | 2024-09-03 20:40:53 | Re: Pgstattuple on Sequences: Seeking Community Feedback on Potential Patch |