MCPcopy Create free account
hub / github.com/apache/cloudberry / PLy_output

Function PLy_output

src/pl/plpython/plpy_plpymodule.c:413–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413static PyObject *
414PLy_output(volatile int level, PyObject *self, PyObject *args, PyObject *kw)
415{
416 int sqlstate = 0;
417 char *volatile sqlstatestr = NULL;
418 char *volatile message = NULL;
419 char *volatile detail = NULL;
420 char *volatile hint = NULL;
421 char *volatile column_name = NULL;
422 char *volatile constraint_name = NULL;
423 char *volatile datatype_name = NULL;
424 char *volatile table_name = NULL;
425 char *volatile schema_name = NULL;
426 volatile MemoryContext oldcontext;
427 PyObject *key,
428 *value;
429 PyObject *volatile so;
430 Py_ssize_t pos = 0;
431
432 PLy_enter_python_intepreter = false;
433 if (PyTuple_Size(args) == 1)
434 {
435 /*
436 * Treat single argument specially to avoid undesirable ('tuple',)
437 * decoration.
438 */
439 PyObject *o;
440
441 if (!PyArg_UnpackTuple(args, "plpy.elog", 1, 1, &o))
442 PLy_elog(ERROR, "could not unpack arguments in plpy.elog");
443 so = PyObject_Str(o);
444 }
445 else
446 so = PyObject_Str(args);
447
448 if (so == NULL || ((message = PyString_AsString(so)) == NULL))
449 {
450 level = ERROR;
451 message = dgettext(TEXTDOMAIN, "could not parse error message in plpy.elog");
452 }
453 message = pstrdup(message);
454
455 Py_XDECREF(so);
456
457 if (kw != NULL)
458 {
459 while (PyDict_Next(kw, &pos, &key, &value))
460 {
461 char *keyword = PyString_AsString(key);
462
463 if (strcmp(keyword, "message") == 0)
464 {
465 /* the message should not be overwritten */
466 if (PyTuple_Size(args) != 0)
467 {
468 PLy_exception_set(PyExc_TypeError, "argument 'message' given by name and position");
469 return NULL;
470 }

Callers 7

PLy_debugFunction · 0.85
PLy_logFunction · 0.85
PLy_infoFunction · 0.85
PLy_noticeFunction · 0.85
PLy_warningFunction · 0.85
PLy_errorFunction · 0.85
PLy_fatalFunction · 0.85

Calls 15

PLy_exception_setFunction · 0.85
object_to_stringFunction · 0.85
pg_verifymbstrFunction · 0.85
MemoryContextSwitchToFunction · 0.85
pstrdupFunction · 0.50
pfreeFunction · 0.50
errcodeFunction · 0.50
errmsg_internalFunction · 0.50
errdetail_internalFunction · 0.50
errhintFunction · 0.50
err_generic_stringFunction · 0.50

Tested by

no test coverage detected