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

Commitb6f0c50

Browse files
committed
Small update for the removal of some memory leaks in plpython SGML example.
Nigel J. Andrews
1 parentb825a8f commitb6f0c50

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

‎doc/src/sgml/plpython.sgml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/plpython.sgml,v 1.14 2002/09/23 01:51:02 momjian Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/plpython.sgml,v 1.15 2002/10/21 20:34:09 momjian Exp $ -->
22

33
<chapter id="plpython">
44
<title>PL/Python - Python Procedural Language</title>
@@ -198,15 +198,24 @@ rv = plpy.execute(plan, [ "name" ], 5)
198198
<para>
199199
When you prepare a plan using the PL/Python module it is
200200
automatically saved. Read the SPI documentation (<xref
201-
linkend="spi">) for a description of what this means. The take
202-
home message is if you do
201+
linkend="spi">) for a description of what this means.
202+
</para>
203+
204+
<para>
205+
In order to make effective use of this across function calls
206+
one needs to use one of the persistent storage dictionaries
207+
<literal>SD</literal> or <literal>GD</literal>, see
208+
<xref linkend="plpython-funcs">. For example:
203209
<programlisting>
204-
plan = plpy.prepare("SOME QUERY")
205-
plan = plpy.prepare("SOME OTHER QUERY")
210+
CREATE FUNCTION usesavedplan ( ) RETURNS TRIGGER AS '
211+
if SD.has_key("plan"):
212+
plan = SD["plan"]
213+
else:
214+
plan = plpy.prepare("SELECT 1")
215+
SD["plan"] = plan
216+
# rest of function
217+
' LANGUAGE 'plpython';
206218
</programlisting>
207-
you are leaking memory, as I know of no way to free a saved plan.
208-
The alternative of using unsaved plans it even more painful (for
209-
me).
210219
</para>
211220
</sect1>
212221

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp