1 /* this must be first: */
10 #include "spi_internal.h"
14 * Implementation of plperl's elog() function
16 * If the error level is less than ERROR, we'll just emit the message and
17 * return. When it is ERROR, elog() will longjmp, which we catch and
18 * turn into a Perl croak(). Note we are assuming that elog() can't have
19 * any internal failures that are so bad as to require a transaction abort.
21 * This is out-of-line to suppress "might be clobbered by longjmp" warnings.
24 do_spi_elog(int level, char *message)
26 MemoryContext oldcontext = CurrentMemoryContext;
30 elog(level, "%s", message);
36 /* Must reset elog.c's state */
37 MemoryContextSwitchTo(oldcontext);
38 edata = CopyErrorData();
41 /* Punt the error to Perl */
42 croak("%s", edata->message);
48 MODULE = SPI PREFIX = spi_
54 spi_elog(level, message)
58 if (level > ERROR) /* no PANIC allowed thanks */
62 do_spi_elog(level, message);
83 spi_spi_exec_query(query, ...)
90 croak("Usage: spi_exec_query(query, limit) or spi_exec_query(query)");
93 ret_hash = plperl_spi_exec(query, limit);
94 RETVAL = newRV_noinc((SV*) ret_hash);
100 items = 0; /* avoid 'unused variable' warning */