| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | li carol <carol(dot)li2025(at)outlook(dot)com>, Matheus Alcantara <matheusssilv97(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: PL/Python initialization cleanup |
| Date: | 2026-01-15 11:21:56 |
| Message-ID: | 6560d8e8-1af9-492d-a90b-add92285ebad@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 makes the logic much easier to follow.
> In particular, the updated comments in PLy_create_exception regarding the reference counting logic are very helpful and clarify 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2026-01-15 11:22:41 | Re: Refactor replication origin state reset helpers |
| Previous Message | Chao Li | 2026-01-15 10:49:15 | Re: [PATCH] psql: add \dcs to list all constraints |