-
+
PL/Python - Python Procedural Language
builtin str, and the result is passed to the
input function of the PostgreSQL data type.
+
+ Strings in Python 2 are required to be in the PostgreSQL server
+ encoding when they are passed to PostgreSQL. Strings that are
+ not valid in the current server encoding will raise an error,
+ but not all encoding mismatches can be detected, so garbage
+ data can still result when this is not done correctly. Unicode
+ strings are converted to the correct encoding automatically, so
+ it can be safer and more convenient to use those. In Python 3,
+ all strings are Unicode strings.
+
/**********************************************************************
* plpython.c - python as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.140 2010/03/18 13:23:56 petere Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.141 2010/03/18 19:43:03 petere Exp $
*
*********************************************************************
*/
errmsg("could not convert Python object into cstring: Python string representation appears to contain null bytes")));
else if (slen > plen)
elog(ERROR, "could not convert Python object into cstring: Python string longer than reported length");
+ pg_verifymbstr(plrv_sc, slen, false);
rv = InputFunctionCall(&arg->typfunc, plrv_sc, arg->typioparam, -1);
}
PG_CATCH();
}
}
+ pg_verifymbstr(query, strlen(query), false);
plan->plan = SPI_prepare(query, plan->nargs, plan->types);
if (plan->plan == NULL)
elog(ERROR, "SPI_prepare failed: %s",
oldcontext = CurrentMemoryContext;
PG_TRY();
{
+ pg_verifymbstr(query, strlen(query), false);
rv = SPI_execute(query, PLy_curr_procedure->fn_readonly, limit);
}
PG_CATCH();
oldcontext = CurrentMemoryContext;
PG_TRY();
{
+ pg_verifymbstr(sv, strlen(sv), false);
elog(level, "%s", sv);
}
PG_CATCH();