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

Commit4ddf151

Browse files
committed
Fix quite-bogus handling of arrays in plpython datum-to-PyObject
conversion. Per bug #5497 from David Gardner.
1 parent932de89 commit4ddf151

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

‎src/pl/plpython/plpython.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plpython.c - python as a procedural language for PostgreSQL
33
*
4-
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.143 2010/05/01 17:04:38 tgl Exp $
4+
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.144 2010/06/1004:05:01 tgl Exp $
55
*
66
*********************************************************************
77
*/
@@ -1838,6 +1838,7 @@ PLy_input_datum_func2(PLyDatumToOb *arg, Oid typeOid, HeapTuple typeTup)
18381838
arg->typioparam=getTypeIOParam(typeTup);
18391839
arg->typbyval=typeStruct->typbyval;
18401840
arg->typlen=typeStruct->typlen;
1841+
arg->typalign=typeStruct->typalign;
18411842

18421843
/* Determine which kind of Python object we will convert to */
18431844
switch (getBaseType(element_type ?element_type :typeOid))
@@ -1873,10 +1874,17 @@ PLy_input_datum_func2(PLyDatumToOb *arg, Oid typeOid, HeapTuple typeTup)
18731874

18741875
if (element_type)
18751876
{
1877+
chardummy_delim;
1878+
Oidfuncid;
1879+
18761880
arg->elm=PLy_malloc0(sizeof(*arg->elm));
18771881
arg->elm->func=arg->func;
18781882
arg->func=PLyList_FromArray;
1879-
get_typlenbyvalalign(element_type,&arg->elm->typlen,&arg->elm->typbyval,&arg->elm->typalign);
1883+
arg->elm->typoid=element_type;
1884+
get_type_io_data(element_type,IOFunc_output,
1885+
&arg->elm->typlen,&arg->elm->typbyval,&arg->elm->typalign,&dummy_delim,
1886+
&arg->elm->typioparam,&funcid);
1887+
perm_fmgr_info(funcid,&arg->elm->typfunc);
18801888
}
18811889
}
18821890

@@ -1986,6 +1994,7 @@ static PyObject *
19861994
PLyList_FromArray(PLyDatumToOb*arg,Datumd)
19871995
{
19881996
ArrayType*array=DatumGetArrayTypeP(d);
1997+
PLyDatumToOb*elm=arg->elm;
19891998
PyObject*list;
19901999
intlength;
19912000
intlbound;
@@ -2011,11 +2020,13 @@ PLyList_FromArray(PLyDatumToOb *arg, Datum d)
20112020
intoffset;
20122021

20132022
offset=lbound+i;
2014-
elem=array_ref(array,1,&offset,arg->typlen,arg->elm->typlen,arg->elm->typbyval,arg->elm->typalign,&isnull);
2023+
elem=array_ref(array,1,&offset,arg->typlen,
2024+
elm->typlen,elm->typbyval,elm->typalign,
2025+
&isnull);
20152026
if (isnull)
20162027
PyList_SET_ITEM(list,i,Py_None);
20172028
else
2018-
PyList_SET_ITEM(list,i,arg->elm->func(arg,elem));
2029+
PyList_SET_ITEM(list,i,elm->func(elm,elem));
20192030
}
20202031

20212032
returnlist;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp