Commit 7d5edf2b authored by Bruce Momjian's avatar Bruce Momjian

Add new elog() levels to stored procedure languages. plperl DEBUG hack

still needed because only removed in 7.4.
parent 9956c566
...@@ -55,17 +55,25 @@ elog_elog(level, message) ...@@ -55,17 +55,25 @@ elog_elog(level, message)
int level int level
char* message char* message
CODE: CODE:
if (level > 0) elog(level, message);
return;
else
elog(level, message);
int int
elog_DEBUG() elog_DEBUG()
int int
elog_ERROR() elog_LOG()
int
elog_INFO()
int int
elog_NOTICE() elog_NOTICE()
int
elog_WARNING()
int
elog_ERROR()
...@@ -12,14 +12,20 @@ ...@@ -12,14 +12,20 @@
int int
elog_DEBUG(void) elog_DEBUG(void)
{
return DEBUG1;
}
int
elog_LOG(void)
{ {
return LOG; return LOG;
} }
int int
elog_ERROR(void) elog_INFO(void)
{ {
return ERROR; return INFO;
} }
int int
...@@ -27,3 +33,16 @@ elog_NOTICE(void) ...@@ -27,3 +33,16 @@ elog_NOTICE(void)
{ {
return NOTICE; return NOTICE;
} }
int
elog_WARNING(void)
{
return WARNING;
}
int
elog_ERROR(void)
{
return ERROR;
}
int int elog_DEBUG(void);
elog_DEBUG(void);
int int elog_LOG(void);
elog_ERROR(void);
int elog_INFO(void);
int elog_NOTICE(void);
int elog_WARNING(void);
int elog_ERROR(void);
int elog_NOTICE(void);
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.28 2002/01/24 21:40:44 tgl Exp $ * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.29 2002/03/06 18:50:26 momjian Exp $
* *
**********************************************************************/ **********************************************************************/
...@@ -210,7 +210,7 @@ plperl_init_interp(void) ...@@ -210,7 +210,7 @@ plperl_init_interp(void)
*/ */
"require Safe; SPI::bootstrap();" "require Safe; SPI::bootstrap();"
"sub ::mksafefunc { my $x = new Safe; $x->permit_only(':default');$x->permit(':base_math');" "sub ::mksafefunc { my $x = new Safe; $x->permit_only(':default');$x->permit(':base_math');"
"$x->share(qw[&elog &DEBUG &NOTICE &ERROR]);" "$x->share(qw[&elog &DEBUG &LOG &INFO &NOTICE &WARNING &ERROR]);"
" return $x->reval(qq[sub { $_[0] }]); }" " return $x->reval(qq[sub { $_[0] }]); }"
"sub ::mkunsafefunc {return eval(qq[ sub { $_[0] } ]); }" "sub ::mkunsafefunc {return eval(qq[ sub { $_[0] } ]); }"
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.30 2002/03/02 21:39:35 momjian Exp $ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.31 2002/03/06 18:50:29 momjian Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -161,8 +161,10 @@ static PLpgSQL_expr *make_tupret_expr(PLpgSQL_row *row); ...@@ -161,8 +161,10 @@ static PLpgSQL_expr *make_tupret_expr(PLpgSQL_row *row);
%token K_GET %token K_GET
%token K_IF %token K_IF
%token K_IN %token K_IN
%token K_INFO
%token K_INTO %token K_INTO
%token K_IS %token K_IS
%token K_LOG
%token K_LOOP %token K_LOOP
%token K_NOT %token K_NOT
%token K_NOTICE %token K_NOTICE
...@@ -180,6 +182,7 @@ static PLpgSQL_expr *make_tupret_expr(PLpgSQL_row *row); ...@@ -180,6 +182,7 @@ static PLpgSQL_expr *make_tupret_expr(PLpgSQL_row *row);
%token K_THEN %token K_THEN
%token K_TO %token K_TO
%token K_TYPE %token K_TYPE
%token K_WARNING
%token K_WHEN %token K_WHEN
%token K_WHILE %token K_WHILE
...@@ -1201,10 +1204,22 @@ raise_level : K_EXCEPTION ...@@ -1201,10 +1204,22 @@ raise_level : K_EXCEPTION
{ {
$$ = ERROR; $$ = ERROR;
} }
| K_WARNING
{
$$ = WARNING;
}
| K_NOTICE | K_NOTICE
{ {
$$ = NOTICE; $$ = NOTICE;
} }
| K_INFO
{
$$ = INFO;
}
| K_LOG
{
$$ = LOG;
}
| K_DEBUG | K_DEBUG
{ {
$$ = DEBUG5; $$ = DEBUG5;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.16 2001/10/09 15:59:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.17 2002/03/06 18:50:29 momjian Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -117,8 +117,10 @@ from { return K_FROM; } ...@@ -117,8 +117,10 @@ from { return K_FROM; }
get { return K_GET; } get { return K_GET; }
if { return K_IF; } if { return K_IF; }
in { return K_IN; } in { return K_IN; }
info { return K_INFO; }
into { return K_INTO; } into { return K_INTO; }
is { return K_IS; } is { return K_IS; }
log { return K_LOG; }
loop { return K_LOOP; } loop { return K_LOOP; }
not { return K_NOT; } not { return K_NOT; }
notice { return K_NOTICE; } notice { return K_NOTICE; }
...@@ -136,6 +138,7 @@ select { return K_SELECT; } ...@@ -136,6 +138,7 @@ select { return K_SELECT; }
then { return K_THEN; } then { return K_THEN; }
to { return K_TO; } to { return K_TO; }
type { return K_TYPE; } type { return K_TYPE; }
warning { return K_WARNING; }
when { return K_WHEN; } when { return K_WHEN; }
while { return K_WHILE; } while { return K_WHILE; }
......
SELECT invalid_type_uncaught('rick'); SELECT invalid_type_uncaught('rick');
NOTICE: plpython: in function __plpython_procedure_invalid_type_uncaught_49801: WARNING: plpython: in function __plpython_procedure_invalid_type_uncaught_49801:
plpy.SPIError: Cache lookup for type `test' failed. plpy.SPIError: Cache lookup for type `test' failed.
SELECT invalid_type_caught('rick'); SELECT invalid_type_caught('rick');
NOTICE: plpython: in function __plpython_procedure_invalid_type_caught_49802: WARNING: plpython: in function __plpython_procedure_invalid_type_caught_49802:
plpy.SPIError: Cache lookup for type `test' failed. plpy.SPIError: Cache lookup for type `test' failed.
SELECT invalid_type_reraised('rick'); SELECT invalid_type_reraised('rick');
NOTICE: plpython: in function __plpython_procedure_invalid_type_reraised_49803: WARNING: plpython: in function __plpython_procedure_invalid_type_reraised_49803:
plpy.SPIError: Cache lookup for type `test' failed. plpy.SPIError: Cache lookup for type `test' failed.
SELECT valid_type('rick'); SELECT valid_type('rick');
valid_type valid_type
......
...@@ -29,7 +29,7 @@ SELECT global_test_two(); ...@@ -29,7 +29,7 @@ SELECT global_test_two();
(1 row) (1 row)
SELECT import_fail(); SELECT import_fail();
NOTICE: ('import socket failed -- untrusted dynamic module: _socket',) WARNING: ('import socket failed -- untrusted dynamic module: _socket',)
import_fail import_fail
-------------------- --------------------
failed as expected failed as expected
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.15 2002/03/06 06:10:47 momjian Exp $ * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.16 2002/03/06 18:50:32 momjian Exp $
* *
********************************************************************* *********************************************************************
*/ */
...@@ -1658,9 +1658,12 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc) ...@@ -1658,9 +1658,12 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
/* interface to postgresql elog /* interface to postgresql elog
*/ */
static PyObject *PLy_debug(PyObject *, PyObject *); static PyObject *PLy_debug(PyObject *, PyObject *);
static PyObject *PLy_log(PyObject *, PyObject *);
static PyObject *PLy_info(PyObject *, PyObject *);
static PyObject *PLy_notice(PyObject *, PyObject *);
static PyObject *PLy_warning(PyObject *, PyObject *);
static PyObject *PLy_error(PyObject *, PyObject *); static PyObject *PLy_error(PyObject *, PyObject *);
static PyObject *PLy_fatal(PyObject *, PyObject *); static PyObject *PLy_fatal(PyObject *, PyObject *);
static PyObject *PLy_notice(PyObject *, PyObject *);
/* PLyPlanObject, PLyResultObject and SPI interface /* PLyPlanObject, PLyResultObject and SPI interface
*/ */
...@@ -1782,9 +1785,12 @@ static PyMethodDef PLy_methods[] = { ...@@ -1782,9 +1785,12 @@ static PyMethodDef PLy_methods[] = {
* logging methods * logging methods
*/ */
{"debug", PLy_debug, METH_VARARGS, NULL}, {"debug", PLy_debug, METH_VARARGS, NULL},
{"log", PLy_log, METH_VARARGS, NULL},
{"info", PLy_info, METH_VARARGS, NULL},
{"notice", PLy_notice, METH_VARARGS, NULL},
{"warning", PLy_warning, METH_VARARGS, NULL},
{"error", PLy_error, METH_VARARGS, NULL}, {"error", PLy_error, METH_VARARGS, NULL},
{"fatal", PLy_fatal, METH_VARARGS, NULL}, {"fatal", PLy_fatal, METH_VARARGS, NULL},
{"notice", PLy_notice, METH_VARARGS, NULL},
/* /*
* create a stored plan * create a stored plan
...@@ -2627,35 +2633,53 @@ populate_methods(PyObject *klass, PyMethodDef *methods) ...@@ -2627,35 +2633,53 @@ populate_methods(PyObject *klass, PyMethodDef *methods)
/* the python interface to the elog function /* the python interface to the elog function
* don't confuse these with PLy_elog * don't confuse these with PLy_elog
*/ */
static PyObject *PLy_log(int, PyObject *, PyObject *); static PyObject *PLy_output(int, PyObject *, PyObject *);
PyObject * PyObject *
PLy_debug(PyObject * self, PyObject * args) PLy_debug(PyObject * self, PyObject * args)
{ {
return PLy_log(LOG, self, args); return PLy_output(DEBUG1, self, args);
} }
PyObject * PyObject *
PLy_error(PyObject * self, PyObject * args) PLy_log(PyObject * self, PyObject * args)
{ {
return PLy_log(ERROR, self, args); return PLy_output(LOG, self, args);
} }
PyObject * PyObject *
PLy_fatal(PyObject * self, PyObject * args) PLy_info(PyObject * self, PyObject * args)
{ {
return PLy_log(FATAL, self, args); return PLy_output(INFO, self, args);
} }
PyObject * PyObject *
PLy_notice(PyObject * self, PyObject * args) PLy_notice(PyObject * self, PyObject * args)
{ {
return PLy_log(NOTICE, self, args); return PLy_output(NOTICE, self, args);
}
PyObject *
PLy_warning(PyObject * self, PyObject * args)
{
return PLy_output(WARNING, self, args);
}
PyObject *
PLy_error(PyObject * self, PyObject * args)
{
return PLy_output(ERROR, self, args);
}
PyObject *
PLy_fatal(PyObject * self, PyObject * args)
{
return PLy_output(FATAL, self, args);
} }
PyObject * PyObject *
PLy_log(volatile int level, PyObject * self, PyObject * args) PLy_output(volatile int level, PyObject * self, PyObject * args)
{ {
DECLARE_EXC(); DECLARE_EXC();
PyObject *so; PyObject *so;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.51 2002/03/06 06:10:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.52 2002/03/06 18:50:33 momjian Exp $
* *
**********************************************************************/ **********************************************************************/
...@@ -1259,7 +1259,11 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp, ...@@ -1259,7 +1259,11 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
return TCL_ERROR; return TCL_ERROR;
} }
if (strcmp(argv[1], "INFO") == 0) if (strcmp(argv[1], "DEBUG") == 0)
level = DEBUG1;
else if (strcmp(argv[1], "LOG") == 0)
level = LOG;
else if (strcmp(argv[1], "INFO") == 0)
level = INFO; level = INFO;
else if (strcmp(argv[1], "NOTICE") == 0) else if (strcmp(argv[1], "NOTICE") == 0)
level = NOTICE; level = NOTICE;
...@@ -1269,8 +1273,6 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp, ...@@ -1269,8 +1273,6 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
level = ERROR; level = ERROR;
else if (strcmp(argv[1], "FATAL") == 0) else if (strcmp(argv[1], "FATAL") == 0)
level = FATAL; level = FATAL;
else if (strcmp(argv[1], "DEBUG") == 0)
level = DEBUG1;
else else
{ {
Tcl_AppendResult(interp, "Unknown elog level '", argv[1], Tcl_AppendResult(interp, "Unknown elog level '", argv[1],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment