Why does SPI_connect change the memory context?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Why does SPI_connect change the memory context?
Date: 2019-05-29 21:20:43
Message-ID: b715a1eadb4909a7d892c971631391fa95ea63ab.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2019-05-29 21:23:14 Re: Names
Previous Message Robert Haas 2019-05-29 21:03:01 Re: [HACKERS] Runtime Partition Pruning