Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
25ee08e1
Commit
25ee08e1
authored
Jun 01, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If spi.c wants to use malloc, it better test for malloc failure.
parent
7748e9e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
src/backend/executor/spi.c
src/backend/executor/spi.c
+17
-7
No files found.
src/backend/executor/spi.c
View file @
25ee08e1
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* spi.c
* spi.c
* Server Programming Interface
* Server Programming Interface
*
*
* $
Id: spi.c,v 1.54 2001/05/21 14:22:17 wieck
Exp $
* $
Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.55 2001/06/01 19:43:55 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -48,8 +48,9 @@ extern void ShowUsage(void);
...
@@ -48,8 +48,9 @@ extern void ShowUsage(void);
/* =================== interface functions =================== */
/* =================== interface functions =================== */
int
int
SPI_connect
()
SPI_connect
(
void
)
{
{
_SPI_connection
*
new_SPI_stack
;
/*
/*
* When procedure called by Executor _SPI_curid expected to be equal
* When procedure called by Executor _SPI_curid expected to be equal
...
@@ -62,19 +63,23 @@ SPI_connect()
...
@@ -62,19 +63,23 @@ SPI_connect()
{
{
if
(
_SPI_connected
!=
-
1
)
if
(
_SPI_connected
!=
-
1
)
elog
(
FATAL
,
"SPI_connect: no connection(s) expected"
);
elog
(
FATAL
,
"SPI_connect: no connection(s) expected"
);
_SPI_stack
=
(
_SPI_connection
*
)
malloc
(
sizeof
(
_SPI_connection
));
new
_SPI_stack
=
(
_SPI_connection
*
)
malloc
(
sizeof
(
_SPI_connection
));
}
}
else
else
{
{
if
(
_SPI_connected
<=
-
1
)
if
(
_SPI_connected
<=
-
1
)
elog
(
FATAL
,
"SPI_connect: some connection(s) expected"
);
elog
(
FATAL
,
"SPI_connect: some connection(s) expected"
);
_SPI_stack
=
(
_SPI_connection
*
)
realloc
(
_SPI_stack
,
new
_SPI_stack
=
(
_SPI_connection
*
)
realloc
(
_SPI_stack
,
(
_SPI_connected
+
2
)
*
sizeof
(
_SPI_connection
));
(
_SPI_connected
+
2
)
*
sizeof
(
_SPI_connection
));
}
}
if
(
new_SPI_stack
==
NULL
)
elog
(
ERROR
,
"Memory exhausted in SPI_connect"
);
/*
/*
* We' returning to procedure where _SPI_curid == _SPI_connected - 1
* We' returning to procedure where _SPI_curid == _SPI_connected - 1
*/
*/
_SPI_stack
=
new_SPI_stack
;
_SPI_connected
++
;
_SPI_connected
++
;
_SPI_current
=
&
(
_SPI_stack
[
_SPI_connected
]);
_SPI_current
=
&
(
_SPI_stack
[
_SPI_connected
]);
...
@@ -104,7 +109,7 @@ SPI_connect()
...
@@ -104,7 +109,7 @@ SPI_connect()
}
}
int
int
SPI_finish
()
SPI_finish
(
void
)
{
{
int
res
;
int
res
;
...
@@ -136,8 +141,14 @@ SPI_finish()
...
@@ -136,8 +141,14 @@ SPI_finish()
}
}
else
else
{
{
_SPI_stack
=
(
_SPI_connection
*
)
realloc
(
_SPI_stack
,
_SPI_connection
*
new_SPI_stack
;
new_SPI_stack
=
(
_SPI_connection
*
)
realloc
(
_SPI_stack
,
(
_SPI_connected
+
1
)
*
sizeof
(
_SPI_connection
));
(
_SPI_connected
+
1
)
*
sizeof
(
_SPI_connection
));
/* This could only fail with a pretty stupid malloc package ... */
if
(
new_SPI_stack
==
NULL
)
elog
(
ERROR
,
"Memory exhausted in SPI_finish"
);
_SPI_stack
=
new_SPI_stack
;
_SPI_current
=
&
(
_SPI_stack
[
_SPI_connected
]);
_SPI_current
=
&
(
_SPI_stack
[
_SPI_connected
]);
}
}
...
@@ -151,7 +162,6 @@ SPI_finish()
...
@@ -151,7 +162,6 @@ SPI_finish()
void
void
AtEOXact_SPI
(
void
)
AtEOXact_SPI
(
void
)
{
{
/*
/*
* Note that memory contexts belonging to SPI stack entries will be
* Note that memory contexts belonging to SPI stack entries will be
* freed automatically, so we can ignore them here. We just need to
* freed automatically, so we can ignore them here. We just need to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment