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

Commitfa8eb8a

Browse files
committed
Add defenses against plpython functions being declared to take or return
pseudotypes. Not sure why I neglected to add these checks at the sametime I added them to the other PLs, but it seems I did.
1 parent84c7cef commitfa8eb8a

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

‎src/pl/plpython/plpython.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
3030
*
3131
* IDENTIFICATION
32-
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.56 2004/09/13 20:09:30 tgl Exp $
32+
*$PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.57 2004/09/19 23:38:21 tgl Exp $
3333
*
3434
*********************************************************************
3535
*/
@@ -976,7 +976,6 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
976976
HeapTupleprocTup,char*key)
977977
{
978978
charprocName[NAMEDATALEN+256];
979-
980979
Form_pg_procprocStruct;
981980
PLyProcedure*volatileproc;
982981
char*volatileprocSource=NULL;
@@ -1035,14 +1034,28 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
10351034
if (!HeapTupleIsValid(rvTypeTup))
10361035
elog(ERROR,"cache lookup failed for type %u",
10371036
procStruct->prorettype);
1038-
10391037
rvTypeStruct= (Form_pg_type)GETSTRUCT(rvTypeTup);
1040-
if (rvTypeStruct->typtype!='c')
1041-
PLy_output_datum_func(&proc->result,rvTypeTup);
1042-
else
1038+
1039+
/* Disallow pseudotype result */
1040+
if (rvTypeStruct->typtype=='p')
1041+
{
1042+
if (procStruct->prorettype==TRIGGEROID)
1043+
ereport(ERROR,
1044+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1045+
errmsg("trigger functions may only be called as triggers")));
1046+
else
1047+
ereport(ERROR,
1048+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1049+
errmsg("plpython functions cannot return type %s",
1050+
format_type_be(procStruct->prorettype))));
1051+
}
1052+
1053+
if (rvTypeStruct->typtype=='c')
10431054
ereport(ERROR,
10441055
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1045-
errmsg("tuple return types are not supported yet")));
1056+
errmsg("plpython functions cannot return tuples yet")));
1057+
else
1058+
PLy_output_datum_func(&proc->result,rvTypeTup);
10461059

10471060
ReleaseSysCache(rvTypeTup);
10481061
}
@@ -1076,6 +1089,13 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
10761089
procStruct->proargtypes[i]);
10771090
argTypeStruct= (Form_pg_type)GETSTRUCT(argTypeTup);
10781091

1092+
/* Disallow pseudotype argument */
1093+
if (argTypeStruct->typtype=='p')
1094+
ereport(ERROR,
1095+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1096+
errmsg("plpython functions cannot take type %s",
1097+
format_type_be(procStruct->proargtypes[i]))));
1098+
10791099
if (argTypeStruct->typtype!='c')
10801100
PLy_input_datum_func(&(proc->args[i]),
10811101
procStruct->proargtypes[i],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp