From: | Christophe Pettus <xof(at)thebuild(dot)com> |
---|---|
To: | huangning0722(at)gmail(dot)com |
Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>, "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
Subject: | Re: how to check if the license is expired. |
Date: | 2024-03-31 20:09:43 |
Message-ID: | 617A959E-97FB-49A6-A12B-3C3878657AE4@thebuild.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On Mar 31, 2024, at 09:59, Peter J. Holzer <hjp-pgsql(at)hjp(dot)at> wrote:
> Is this an acceptable performance penalty per API call? If not, is it
> really necessary to check this on every call? Maybe it can be done just
> once per session or once per hour.
It's probably not required to check it every API call. Two places come to mind:
_PG_init -- Although I don't know the possibility or wisdom of reading from a file there.
shmem_startup_hook -- It's definitely OK to read from a file there.
Remember that you have the full ability to crash PostgreSQL in an extension, so it really needs to be bulletproof. You don't want the shared library to fail to load if the license isn't valid. Instead:
-- If the functionality is exposed as functions, return an error when one of those functions is used, if the extension is not licensed.
-- If the functionality modifies PostgreSQL behavior, disable that modification.
If you are validating the license via a network call... I would counsel against having a network call as part of PostgreSQL's startup process. It might work to make the call on-demand the first time the extension is used, and the result stored locally, although I would limit that to function calls rather than, say, a hook into the planner.
You also need to decide exactly how you want to distribute this extension. Most PostgreSQL extensions are supplied as source and built against PostgreSQL.
From | Date | Subject | |
---|---|---|---|
Next Message | Hans Schou | 2024-03-31 23:26:54 | Re: Feature request: pg_get_tabledef(text) |
Previous Message | Peter J. Holzer | 2024-03-31 16:59:51 | Re: how to check if the license is expired. |