Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteec6108

Browse files
committed
+ SPI_palloc(), SPI_repalloc(), SPI_pfree() - for allocations
in upper Executor memory context.
1 parentaf5c86e commiteec6108

File tree

1 file changed

+65
-0
lines changed
  • src/backend/executor

1 file changed

+65
-0
lines changed

‎src/backend/executor/spi.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ extern void ShowUsage(void);
6969

7070
#endif
7171

72+
/* =================== interface functions =================== */
73+
7274
int
7375
SPI_connect()
7476
{
@@ -487,6 +489,69 @@ SPI_getrelname(Relation rel)
487489
return (pstrdup(rel->rd_rel->relname.data));
488490
}
489491

492+
void*
493+
SPI_palloc (Sizesize)
494+
{
495+
MemoryContextoldcxt=NULL;
496+
void*pointer;
497+
498+
if (_SPI_curid+1==_SPI_connected)/* connected */
499+
{
500+
if (_SPI_current!=&(_SPI_stack[_SPI_curid+1]))
501+
elog(FATAL,"SPI: stack corrupted");
502+
oldcxt=MemoryContextSwitchTo(_SPI_current->savedcxt);
503+
}
504+
505+
pointer=palloc (size);
506+
507+
if (oldcxt)
508+
MemoryContextSwitchTo(oldcxt);
509+
510+
return (pointer);
511+
}
512+
513+
void*
514+
SPI_repalloc (void*pointer,Sizesize)
515+
{
516+
MemoryContextoldcxt=NULL;
517+
518+
if (_SPI_curid+1==_SPI_connected)/* connected */
519+
{
520+
if (_SPI_current!=&(_SPI_stack[_SPI_curid+1]))
521+
elog(FATAL,"SPI: stack corrupted");
522+
oldcxt=MemoryContextSwitchTo(_SPI_current->savedcxt);
523+
}
524+
525+
pointer=repalloc (pointer,size);
526+
527+
if (oldcxt)
528+
MemoryContextSwitchTo(oldcxt);
529+
530+
return (pointer);
531+
}
532+
533+
void
534+
SPI_pfree (void*pointer)
535+
{
536+
MemoryContextoldcxt=NULL;
537+
538+
if (_SPI_curid+1==_SPI_connected)/* connected */
539+
{
540+
if (_SPI_current!=&(_SPI_stack[_SPI_curid+1]))
541+
elog(FATAL,"SPI: stack corrupted");
542+
oldcxt=MemoryContextSwitchTo(_SPI_current->savedcxt);
543+
}
544+
545+
pfree (pointer);
546+
547+
if (oldcxt)
548+
MemoryContextSwitchTo(oldcxt);
549+
550+
return;
551+
}
552+
553+
/* =================== private functions =================== */
554+
490555
/*
491556
* spi_printtup --
492557
*store tuple retrieved by Executor into SPITupleTable

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp