I am facing an issue with a PostgreSQL extension using plpython3u. I have created a simple extension with a Python function that is supposed to add two numbers. However, when I execute the function, it returns an empty result instead of the expected sum.
Here's the Python function in the SQL script file (pg_py_ext--1.0.sql):
-- pg_py_ext--1.0.sql
-- Create the function that uses the Python script
CREATE OR REPLACE FUNCTION add_numbers(a integer, b integer)
RETURNS integer
LANGUAGE plpython3u
AS $$
def add_numbers(a, b):
return a + b
$$;
I have already verified the Python code, and it appears to be correct. However, the function does not return the expected result (e.g., SELECT add_numbers(3, 5) should return 8, but it returns an empty result).
Output:
spartacus=# SELECT add_numbers(3, 5);
add_numbers
-------------
(1 row)
I have also checked the PostgreSQL logs for any error messages, but there are no relevant entries.
PostgreSQL version: PostgreSQL 15.0
I'm not sure what else could be causing this issue. Any guidance or suggestions on how to troubleshoot and resolve this problem would be greatly appreciated.
Thank you in advance for your help!