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
80371601
Commit
80371601
authored
Jul 08, 2010
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Install safeguard against running PL/Python 2 and 3 in the same session
parent
c9b142d9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
doc/src/sgml/plpython.sgml
doc/src/sgml/plpython.sgml
+8
-7
src/pl/plpython/plpython.c
src/pl/plpython/plpython.c
+18
-1
No files found.
doc/src/sgml/plpython.sgml
View file @
80371601
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpython.sgml,v 1.5
0 2010/07/06 21:37:31
petere Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpython.sgml,v 1.5
1 2010/07/08 18:42:12
petere Exp $ -->
<chapter id="plpython">
<chapter id="plpython">
<title>PL/Python - Python Procedural Language</title>
<title>PL/Python - Python Procedural Language</title>
...
@@ -154,12 +154,13 @@
...
@@ -154,12 +154,13 @@
</para>
</para>
<para>
<para>
On most (possibly all) platforms, it is not possible to use
It is not allowed to use PL/Python based on Python 2 and PL/Python
PL/Python based on Python 2 and PL/Python based on Python 3 in the
based on Python 3 in the same session, because the symbols in the
same session, because the symbols in the dynamic modules will
dynamic modules would clash, which could result in crashes of the
clash, which will result in crashes of the PostgreSQL server
PostgreSQL server process. There is a check that prevents mixing
process. It is possible, however, to use both PL/Python variants
Python major versions in a session, which will abort the session if
in the same database, from separate sessions.
a mismatch is detected. It is possible, however, to use both
PL/Python variants in the same database, from separate sessions.
</para>
</para>
</sect1>
</sect1>
...
...
src/pl/plpython/plpython.c
View file @
80371601
/**********************************************************************
/**********************************************************************
* plpython.c - python as a procedural language for PostgreSQL
* plpython.c - python as a procedural language for PostgreSQL
*
*
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.14
6 2010/07/06 19:19:01 momjian
Exp $
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.14
7 2010/07/08 18:42:12 petere
Exp $
*
*
*********************************************************************
*********************************************************************
*/
*/
...
@@ -3206,6 +3206,8 @@ PyInit_plpy(void)
...
@@ -3206,6 +3206,8 @@ PyInit_plpy(void)
#endif
#endif
static
const
int
plpython_python_version
=
PY_MAJOR_VERSION
;
/*
/*
* _PG_init() - library load-time initialization
* _PG_init() - library load-time initialization
*
*
...
@@ -3216,6 +3218,21 @@ _PG_init(void)
...
@@ -3216,6 +3218,21 @@ _PG_init(void)
{
{
/* Be sure we do initialization only once (should be redundant now) */
/* Be sure we do initialization only once (should be redundant now) */
static
bool
inited
=
false
;
static
bool
inited
=
false
;
const
int
**
version_ptr
;
/* Be sure we don't run Python 2 and 3 in the same session (might crash) */
version_ptr
=
(
const
int
**
)
find_rendezvous_variable
(
"plpython_python_version"
);
if
(
!
(
*
version_ptr
))
*
version_ptr
=
&
plpython_python_version
;
else
{
if
(
**
version_ptr
!=
plpython_python_version
)
ereport
(
FATAL
,
(
errmsg
(
"Python major version mismatch in session"
),
errdetail
(
"This session has previously used Python major version %d, and it is now attempting to use Python major version %d."
,
**
version_ptr
,
plpython_python_version
),
errhint
(
"Start a new session to use a different Python major version."
)));
}
if
(
inited
)
if
(
inited
)
return
;
return
;
...
...
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