Why does SPI_connect change the memory context? - Mailing list pgsql-hackers

From Jeff Davis
Subject Why does SPI_connect change the memory context?
Date
Msg-id b715a1eadb4909a7d892c971631391fa95ea63ab.camel@j-davis.com
Whole thread Raw
Responses Re: Why does SPI_connect change the memory context?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
SPI_connect() changes the memory context to a newly-created one, and
then SPI_finish() restores it. That seems a bit dangerous because the
caller might not be expecting it. Is there a reason it doesn't just
change to the new memory context as-needed?

spi.c:161:

   /* ... and switch to procedure's context */
    _SPI_current->savedcxt = MemoryContextSwitchTo(_SPI_current-
>procCxt);

Regards,
    Jeff Davis





pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] Runtime Partition Pruning
Next
From: Robert Haas
Date:
Subject: Re: Names