While defining a PL/Python function in psql, I get the error:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The function:
CREATE OR REPLACE FUNCTION pymax (a integer, b integer) RETURNS integer AS
$$
if a > b:
return a
return b
$$ LANGUAGE plpython3u;
The PostgreSQL log:
2018-01-16 17:17:57.296 IST [8164] LOG: server process (PID 5128) was terminated by exception 0xC0000409
2018-01-16 17:17:57.296 IST [8164] DETAIL: Failed process was running: CREATE OR REPLACE FUNCTION pymax (a integer, b integer) RETURNS integer AS
$$
if a > b:
return a
return b
$$ LANGUAGE plpython3u;
2018-01-16 17:17:57.296 IST [8164] HINT: See C include file "ntstatus.h" for a description of the hexadecimal value.
2018-01-16 17:17:57.296 IST [8164] LOG: terminating any other active server processes
2018-01-16 17:17:57.300 IST [5484] WARNING: terminating connection because of crash of another server process
2018-01-16 17:17:57.300 IST [5484] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2018-01-16 17:17:57.300 IST [5484] HINT: In a moment you should be able to reconnect to the database and repeat your command.
2018-01-16 17:17:57.324 IST [920] FATAL: the database system is in recovery mode
2018-01-16 17:17:57.342 IST [8164] LOG: all server processes terminated; reinitializing
2018-01-16 17:17:57.373 IST [5700] LOG: database system was interrupted; last known up at 2018-01-16 17:17:41 IST
2018-01-16 17:17:57.993 IST [5700] LOG: database system was not properly shut down; automatic recovery in progress
2018-01-16 17:17:58.022 IST [5700] LOG: redo starts at 0/279BA58
2018-01-16 17:17:58.023 IST [5700] LOG: invalid record length at 0/279BA90: wanted 24, got 0
2018-01-16 17:17:58.023 IST [5700] LOG: redo done at 0/279BA58
2018-01-16 17:17:58.247 IST [8164] LOG: database system is ready to accept connections