Re: PL/Python initialization cleanup - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: PL/Python initialization cleanup
Date
Msg-id 6560d8e8-1af9-492d-a90b-add92285ebad@eisentraut.org
Whole thread Raw
In response to RE: PL/Python initialization cleanup  (li carol <carol.li2025@outlook.com>)
List pgsql-hackers
On 13.01.26 07:15, li carol wrote:
> I have applied and reviewed the v2 patch set. The cleanup of the initialization flow is a very good improvement and
makesthe logic much easier to follow.
 
> In particular, the updated comments in PLy_create_exception regarding the reference counting logic are very helpful
andclarify the previous ambiguity.
 
> I have one minor nitpick in plpy_main.c regarding consistency. In _PG_init(), the import and dictionary insertion of
the"plpy" module is currently split into two checks with the same error message. To make it more consistent with how
the__main__ module is handled earlier in the same function, we could potentially streamline it like this:
 
>     /*
>      * Import plpy.
>      */
>     plpy_mod = PyImport_ImportModule("plpy");
>     if (plpy_mod == NULL || PyDict_SetItemString(main_dict, "plpy", plpy_mod) < 0)
>         PLy_elog(ERROR, "could not import \"plpy\" module");
> 
> This is just a small suggestion for style consistency; the existing logic in v2 is perfectly correct.

Thank you for this suggestion.  I agree that having the same error 
message for two different situations was not good.  I changed the error 
checking of PyDict_SetItemString() like you suggested here, but also 
gave it a separate PLy_elog() call (without a message, since it's pretty 
much "can't happen").

I committed the patches with this change.



pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: [PATCH] psql: add \dcs to list all constraints
Next
From: Álvaro Herrera
Date:
Subject: Re: Refactor replication origin state reset helpers