Re: Bug #933: Too many inserts crash server - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Bug #933: Too many inserts crash server
Date
Msg-id 3936.1049441987@sss.pgh.pa.us
Whole thread Raw
In response to Bug #933: Too many inserts crash server  (pgsql-bugs@postgresql.org)
Responses Re: Bug #933: Too many inserts crash server  (Mark Pether <mutex@redsheriff.com>)
List pgsql-bugs
pgsql-bugs@postgresql.org writes:
> If I create an external C function consisting of a
> simple loop that inserts 250000 records into a table
> the server process eventually crashes.

The memory leak goes away if you add

    SPI_freetuptable(SPI_tuptable);

after the SPI_exec() call.

I am not sure whether to consider this an SPI bug or not.  It's possibly
surprising that a non-SELECT query generates an empty tuple table; but
on the other hand, it's hard to say that no non-SELECT query can ever
generate a tuple table.  (EXPLAIN is a counterexample, for instance.)

It may be better to document that you should always do
SPI_freetuptable() no matter what kind of query you executed.

            regards, tom lane

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #933: Too many inserts crash server
Next
From: "Robert John Shepherd"
Date:
Subject: Rapid deteriation of performance (might be caused by tsearch?) in 7.3.2