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

Commitedafb4f

Browse files
author
Neil Conway
committed
Index: src/pl/plpython/plpython.c
===================================================================RCS file: /Users/neilc/postgres/cvs_root/pgsql/src/pl/plpython/plpython.c,vretrieving revision 1.67diff -c -r1.67 plpython.c*** src/pl/plpython/plpython.c26 Dec 2005 04:28:48 -00001.67--- src/pl/plpython/plpython.c29 Dec 2005 16:54:57 -0000****************** 2,8 **** * plpython.c - python as a procedural language for PostgreSQL * * This software is copyright by Andrew Bosma! * but is really shameless cribbed from pltcl.c by Jan Weick, and * plperl.c by Mark Hollomon. * * The author hereby grants permission to use, copy, modify,--- 2,8 ---- * plpython.c - python as a procedural language for PostgreSQL * * This software is copyright by Andrew Bosma! * but is really shamelessly cribbed from pltcl.c by Jan Wieck, and * plperl.c by Mark Hollomon. * * The author hereby grants permission to use, copy, modify,****************** 1996,2002 **** inti, rv; PLyPlanObject *plan;- char *nulls; MemoryContext oldcontext; if (list != NULL)--- 1996,2001 ----****************** 2018,2024 **** if (nargs != plan->nargs) { char *sv;- PyObject *so = PyObject_Str(list); if (!so)--- 2017,2022 ----****************** 2036,2048 **** oldcontext = CurrentMemoryContext; PG_TRY(); {! nulls = palloc(nargs * sizeof(char)); for (i = 0; i < nargs; i++) { PyObject *elem, *so;- char *sv; elem = PySequence_GetItem(list, i); if (elem != Py_None)--- 2034,2045 ---- oldcontext = CurrentMemoryContext; PG_TRY(); {! char *nulls = palloc(nargs * sizeof(char)); for (i = 0; i < nargs; i++) { PyObject *elem, *so; elem = PySequence_GetItem(list, i); if (elem != Py_None)****************** 2051,2070 **** if (!so) PLy_elog(ERROR, "function \"%s\" could not execute plan", PLy_procedure_name(PLy_curr_procedure));! sv = PyString_AsString(so);! /*! * FIXME -- if this elogs, we have Python reference leak! */! plan->values[i] =! FunctionCall3(&(plan->args[i].out.d.typfunc),! CStringGetDatum(sv),! ObjectIdGetDatum(plan->args[i].out.d.typioparam),! Int32GetDatum(-1));! Py_DECREF(so);! Py_DECREF(elem); nulls[i] = ' '; } else--- 2048,2073 ---- if (!so) PLy_elog(ERROR, "function \"%s\" could not execute plan", PLy_procedure_name(PLy_curr_procedure));! Py_DECREF(elem);! PG_TRY();! {! char *sv = PyString_AsString(so);! plan->values[i] =! FunctionCall3(&(plan->args[i].out.d.typfunc),! CStringGetDatum(sv),! ObjectIdGetDatum(plan->args[i].out.d.typioparam),! Int32GetDatum(-1));! }! PG_CATCH();! {! Py_DECREF(so);! PG_RE_THROW();! }! PG_END_TRY();+ Py_DECREF(so); nulls[i] = ' '; } else
1 parent195f164 commitedafb4f

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

‎src/pl/plpython/plpython.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* plpython.c - python as a procedural language for PostgreSQL
33
*
44
* This software is copyright by Andrew Bosma
5-
* but is reallyshameless cribbed from pltcl.c by JanWeick, and
5+
* but is reallyshamelessly cribbed from pltcl.c by JanWieck, and
66
* plperl.c by Mark Hollomon.
77
*
88
* The author hereby grants permission to use, copy, modify,
@@ -29,7 +29,7 @@
2929
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
3030
*
3131
* IDENTIFICATION
32-
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.67 2005/12/26 04:28:48 neilc Exp $
32+
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.68 2005/12/29 21:47:32 neilc Exp $
3333
*
3434
*********************************************************************
3535
*/
@@ -1996,7 +1996,6 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
19961996
inti,
19971997
rv;
19981998
PLyPlanObject*plan;
1999-
char*nulls;
20001999
MemoryContextoldcontext;
20012000

20022001
if (list!=NULL)
@@ -2018,7 +2017,6 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
20182017
if (nargs!=plan->nargs)
20192018
{
20202019
char*sv;
2021-
20222020
PyObject*so=PyObject_Str(list);
20232021

20242022
if (!so)
@@ -2036,13 +2034,12 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
20362034
oldcontext=CurrentMemoryContext;
20372035
PG_TRY();
20382036
{
2039-
nulls=palloc(nargs*sizeof(char));
2037+
char*nulls=palloc(nargs*sizeof(char));
20402038

20412039
for (i=0;i<nargs;i++)
20422040
{
20432041
PyObject*elem,
20442042
*so;
2045-
char*sv;
20462043

20472044
elem=PySequence_GetItem(list,i);
20482045
if (elem!=Py_None)
@@ -2051,20 +2048,26 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
20512048
if (!so)
20522049
PLy_elog(ERROR,"function \"%s\" could not execute plan",
20532050
PLy_procedure_name(PLy_curr_procedure));
2054-
sv=PyString_AsString(so);
2051+
Py_DECREF(elem);
20552052

2056-
/*
2057-
* FIXME -- if this elogs, we have Python reference leak
2058-
*/
2059-
plan->values[i]=
2060-
FunctionCall3(&(plan->args[i].out.d.typfunc),
2061-
CStringGetDatum(sv),
2062-
ObjectIdGetDatum(plan->args[i].out.d.typioparam),
2063-
Int32GetDatum(-1));
2053+
PG_TRY();
2054+
{
2055+
char*sv=PyString_AsString(so);
20642056

2065-
Py_DECREF(so);
2066-
Py_DECREF(elem);
2057+
plan->values[i]=
2058+
FunctionCall3(&(plan->args[i].out.d.typfunc),
2059+
CStringGetDatum(sv),
2060+
ObjectIdGetDatum(plan->args[i].out.d.typioparam),
2061+
Int32GetDatum(-1));
2062+
}
2063+
PG_CATCH();
2064+
{
2065+
Py_DECREF(so);
2066+
PG_RE_THROW();
2067+
}
2068+
PG_END_TRY();
20672069

2070+
Py_DECREF(so);
20682071
nulls[i]=' ';
20692072
}
20702073
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp