Skip to content
Snippets Groups Projects
Commit fa8eb8a7 authored by Tom Lane's avatar Tom Lane
Browse files

Add defenses against plpython functions being declared to take or return

pseudotypes.  Not sure why I neglected to add these checks at the same
time I added them to the other PLs, but it seems I did.
parent 84c7cef5
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.56 2004/09/13 20:09:30 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.57 2004/09/19 23:38:21 tgl Exp $
* *
********************************************************************* *********************************************************************
*/ */
...@@ -976,7 +976,6 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, ...@@ -976,7 +976,6 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
HeapTuple procTup, char *key) HeapTuple procTup, char *key)
{ {
char procName[NAMEDATALEN + 256]; char procName[NAMEDATALEN + 256];
Form_pg_proc procStruct; Form_pg_proc procStruct;
PLyProcedure *volatile proc; PLyProcedure *volatile proc;
char *volatile procSource = NULL; char *volatile procSource = NULL;
...@@ -1035,14 +1034,28 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, ...@@ -1035,14 +1034,28 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
if (!HeapTupleIsValid(rvTypeTup)) if (!HeapTupleIsValid(rvTypeTup))
elog(ERROR, "cache lookup failed for type %u", elog(ERROR, "cache lookup failed for type %u",
procStruct->prorettype); procStruct->prorettype);
rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup); rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup);
if (rvTypeStruct->typtype != 'c')
PLy_output_datum_func(&proc->result, rvTypeTup); /* Disallow pseudotype result */
else if (rvTypeStruct->typtype == 'p')
{
if (procStruct->prorettype == TRIGGEROID)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions may only be called as triggers")));
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpython functions cannot return type %s",
format_type_be(procStruct->prorettype))));
}
if (rvTypeStruct->typtype == 'c')
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("tuple return types are not supported yet"))); errmsg("plpython functions cannot return tuples yet")));
else
PLy_output_datum_func(&proc->result, rvTypeTup);
ReleaseSysCache(rvTypeTup); ReleaseSysCache(rvTypeTup);
} }
...@@ -1076,6 +1089,13 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, ...@@ -1076,6 +1089,13 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
procStruct->proargtypes[i]); procStruct->proargtypes[i]);
argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup); argTypeStruct = (Form_pg_type) GETSTRUCT(argTypeTup);
/* Disallow pseudotype argument */
if (argTypeStruct->typtype == 'p')
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpython functions cannot take type %s",
format_type_be(procStruct->proargtypes[i]))));
if (argTypeStruct->typtype != 'c') if (argTypeStruct->typtype != 'c')
PLy_input_datum_func(&(proc->args[i]), PLy_input_datum_func(&(proc->args[i]),
procStruct->proargtypes[i], procStruct->proargtypes[i],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment