backend process crash - PL/pgSQL functions - parsing problem?

From: damonhart(at)yahoo(dot)com (Damon Hart)
To: pgsql-general(at)postgresql(dot)org
Subject: backend process crash - PL/pgSQL functions - parsing problem?
Date: 2003-02-01 00:33:43
Message-ID: 5f569cfd.0301311633.382d6bc8@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

My apologies for the long posting to the general group. Please follow
up via email if appropriate and I will post a summary.

I have a related set of PL/pgSQL functions which, when executed, crash
the backend associated with my connection, dropping me out of the
front end (psql) with the message:

server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

The postgresql log indicates that the backend is crashing with
SIGSEGV. This is postgreSQL 7.2 running on Linux (Intel, roughly
Mandrake 8.2)

I adjusted whatever came to mind in the functions themselves until,
just by luck, I found that if I shortened the length of the function
names, the crash disappeared.

Below follows a simplified rendering of the functions which can
reproduce the crash behavior. Strangely, either shortening the
function names or deleting the filler comments eliminates the
crashing.

Since such changes seem completely textual, I can only speculate that
there is a problem in the parsing. However, it's interesting to note
that the crash only happens when the functions b_345...() and
c_345...() are called from the body of a_345(). They can be
successfully
called independently from psql - in fact, following such a call to
b_345...(), subsequent calls to a_345...() succeed (for the remainder
of the connection.)

I have working versions of my functions, but I'd like to understand
the whys and wherefores of a problem that I'm likely to encounter
again.

thanks,

Damon Hart

/* begin pg_error.sql */

CREATE OR REPLACE FUNCTION a_34567890(INTEGER) RETURNS INTEGER AS '
BEGIN

EXECUTE ''SELECT b_3456789012345678901234567890('' || $1 || '');'';
EXECUTE ''SELECT c_3456789012345678901234567890('' || $1 || '');'';
RETURN $1;
END;
' LANGUAGE 'plpgsql';

CREATE OR REPLACE FUNCTION b_3456789012345678901234567890(INTEGER)
RETURNS INTEGER AS '
BEGIN

CREATE OR REPLACE FUNCTION c_3456789012345678901234567890(INTEGER)
RETURNS INTEGER AS ''
DECLARE

BEGIN

-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments

RETURN $1;

END;
'' LANGUAGE ''plpgsql'';

-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments
-- just a bunch of comments

RETURN $1;

END
' LANGUAGE 'plpgsql';

/* end pg_error.sql */

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Curt Sampson 2003-02-01 01:05:19 Re: Status of tablespaces
Previous Message Sean Chittenden 2003-02-01 00:10:50 Re: Status of tablespaces