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

Function PLy_generate_spi_exceptions

src/pl/plpython/plpy_plpymodule.c:255–286  ·  view source on GitHub ↗

* Add all the autogenerated exceptions as subclasses of SPIError */

Source from the content-addressed store, hash-verified

253 * Add all the autogenerated exceptions as subclasses of SPIError
254 */
255static void
256PLy_generate_spi_exceptions(PyObject *mod, PyObject *base)
257{
258 int i;
259
260 for (i = 0; exception_map[i].name != NULL; i++)
261 {
262 bool found;
263 PyObject *exc;
264 PLyExceptionEntry *entry;
265 PyObject *sqlstate;
266 PyObject *dict = PyDict_New();
267
268 if (dict == NULL)
269 PLy_elog(ERROR, NULL);
270
271 sqlstate = PyString_FromString(unpack_sql_state(exception_map[i].sqlstate));
272 if (sqlstate == NULL)
273 PLy_elog(ERROR, "could not generate SPI exceptions");
274
275 PyDict_SetItemString(dict, "sqlstate", sqlstate);
276 Py_DECREF(sqlstate);
277
278 exc = PLy_create_exception(exception_map[i].name, base, dict,
279 exception_map[i].classname, mod);
280
281 entry = hash_search(PLy_spi_exceptions, &exception_map[i].sqlstate,
282 HASH_ENTER, &found);
283 Assert(!found);
284 entry->exc = exc;
285 }
286}
287
288
289/*

Callers 1

PLy_add_exceptionsFunction · 0.85

Calls 3

PLy_create_exceptionFunction · 0.85
hash_searchFunction · 0.85
unpack_sql_stateFunction · 0.50

Tested by

no test coverage detected