Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7d5edf2

Browse files
committed
Add new elog() levels to stored procedure languages. plperl DEBUG hack
still needed because only removed in 7.4.
1 parent9956c56 commit7d5edf2

File tree

10 files changed

+111
-35
lines changed

10 files changed

+111
-35
lines changed

‎src/pl/plperl/SPI.xs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,25 @@ elog_elog(level, message)
5555
intlevel
5656
char*message
5757
CODE:
58-
if (level>0)
59-
return;
60-
else
61-
elog(level,message);
58+
elog(level,message);
6259

6360

6461
int
6562
elog_DEBUG()
6663

6764
int
68-
elog_ERROR()
65+
elog_LOG()
66+
67+
int
68+
elog_INFO()
6969

7070
int
7171
elog_NOTICE()
72+
73+
int
74+
elog_WARNING()
75+
76+
int
77+
elog_ERROR()
78+
79+

‎src/pl/plperl/eloglvl.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,37 @@
1212

1313
int
1414
elog_DEBUG(void)
15+
{
16+
returnDEBUG1;
17+
}
18+
19+
int
20+
elog_LOG(void)
1521
{
1622
returnLOG;
1723
}
1824

1925
int
20-
elog_ERROR(void)
26+
elog_INFO(void)
2127
{
22-
returnERROR;
28+
returnINFO;
2329
}
2430

2531
int
2632
elog_NOTICE(void)
2733
{
2834
returnNOTICE;
2935
}
36+
37+
int
38+
elog_WARNING(void)
39+
{
40+
returnWARNING;
41+
}
42+
43+
int
44+
elog_ERROR(void)
45+
{
46+
returnERROR;
47+
}
48+

‎src/pl/plperl/eloglvl.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11

2-
int
3-
elog_DEBUG(void);
2+
intelog_DEBUG(void);
43

5-
int
6-
elog_ERROR(void);
4+
intelog_LOG(void);
5+
6+
intelog_INFO(void);
7+
8+
intelog_NOTICE(void);
9+
10+
intelog_WARNING(void);
11+
12+
intelog_ERROR(void);
713

8-
intelog_NOTICE(void);

‎src/pl/plperl/plperl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* ENHANCEMENTS, OR MODIFICATIONS.
3434
*
3535
* IDENTIFICATION
36-
* $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.28 2002/01/24 21:40:44 tgl Exp $
36+
* $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.29 2002/03/06 18:50:26 momjian Exp $
3737
*
3838
**********************************************************************/
3939

@@ -210,7 +210,7 @@ plperl_init_interp(void)
210210
*/
211211
"require Safe; SPI::bootstrap();"
212212
"sub ::mksafefunc { my $x = new Safe; $x->permit_only(':default');$x->permit(':base_math');"
213-
"$x->share(qw[&elog &DEBUG &NOTICE &ERROR]);"
213+
"$x->share(qw[&elog &DEBUG &LOG &INFO &NOTICE &WARNING &ERROR]);"
214214
" return $x->reval(qq[sub { $_[0] }]); }"
215215
"sub ::mkunsafefunc {return eval(qq[ sub { $_[0] } ]); }"
216216
};

‎src/pl/plpgsql/src/gram.y

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.30 2002/03/02 21:39:35 momjian Exp $
7+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.31 2002/03/06 18:50:29 momjian Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -161,8 +161,10 @@ staticPLpgSQL_expr*make_tupret_expr(PLpgSQL_row *row);
161161
%tokenK_GET
162162
%tokenK_IF
163163
%tokenK_IN
164+
%tokenK_INFO
164165
%tokenK_INTO
165166
%tokenK_IS
167+
%tokenK_LOG
166168
%tokenK_LOOP
167169
%tokenK_NOT
168170
%tokenK_NOTICE
@@ -180,6 +182,7 @@ staticPLpgSQL_expr*make_tupret_expr(PLpgSQL_row *row);
180182
%tokenK_THEN
181183
%tokenK_TO
182184
%tokenK_TYPE
185+
%tokenK_WARNING
183186
%tokenK_WHEN
184187
%tokenK_WHILE
185188

@@ -1201,10 +1204,22 @@ raise_level: K_EXCEPTION
12011204
{
12021205
$$ = ERROR;
12031206
}
1207+
|K_WARNING
1208+
{
1209+
$$ = WARNING;
1210+
}
12041211
|K_NOTICE
12051212
{
12061213
$$ = NOTICE;
12071214
}
1215+
|K_INFO
1216+
{
1217+
$$ = INFO;
1218+
}
1219+
|K_LOG
1220+
{
1221+
$$ = LOG;
1222+
}
12081223
|K_DEBUG
12091224
{
12101225
$$ = DEBUG5;

‎src/pl/plpgsql/src/scan.l

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* procedural language
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.16 2001/10/09 15:59:56 tgl Exp $
7+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.17 2002/03/06 18:50:29 momjian Exp $
88
*
99
* This software is copyrighted by Jan Wieck - Hamburg.
1010
*
@@ -117,8 +117,10 @@ from{ return K_FROM;}
117117
get{return K_GET;}
118118
if{return K_IF;}
119119
in{return K_IN;}
120+
info{return K_INFO;}
120121
into{return K_INTO;}
121122
is{return K_IS;}
123+
log{return K_LOG;}
122124
loop{return K_LOOP;}
123125
not{return K_NOT;}
124126
notice{return K_NOTICE;}
@@ -136,6 +138,7 @@ select{ return K_SELECT;}
136138
then{return K_THEN;}
137139
to{return K_TO;}
138140
type{return K_TYPE;}
141+
warning{return K_WARNING;}
139142
when{return K_WHEN;}
140143
while{return K_WHILE;}
141144

‎src/pl/plpython/error.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
SELECT invalid_type_uncaught('rick');
2-
NOTICE: plpython: in function __plpython_procedure_invalid_type_uncaught_49801:
2+
WARNING: plpython: in function __plpython_procedure_invalid_type_uncaught_49801:
33
plpy.SPIError: Cache lookup for type `test' failed.
44
SELECT invalid_type_caught('rick');
5-
NOTICE: plpython: in function __plpython_procedure_invalid_type_caught_49802:
5+
WARNING: plpython: in function __plpython_procedure_invalid_type_caught_49802:
66
plpy.SPIError: Cache lookup for type `test' failed.
77
SELECT invalid_type_reraised('rick');
8-
NOTICE: plpython: in function __plpython_procedure_invalid_type_reraised_49803:
8+
WARNING: plpython: in function __plpython_procedure_invalid_type_reraised_49803:
99
plpy.SPIError: Cache lookup for type `test' failed.
1010
SELECT valid_type('rick');
1111
valid_type

‎src/pl/plpython/feature.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SELECT global_test_two();
2929
(1 row)
3030

3131
SELECT import_fail();
32-
NOTICE: ('import socket failed -- untrusted dynamic module: _socket',)
32+
WARNING: ('import socket failed -- untrusted dynamic module: _socket',)
3333
import_fail
3434
--------------------
3535
failed as expected

‎src/pl/plpython/plpython.c

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
3030
*
3131
* IDENTIFICATION
32-
*$Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.15 2002/03/0606:10:47 momjian Exp $
32+
*$Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.16 2002/03/0618:50:32 momjian Exp $
3333
*
3434
*********************************************************************
3535
*/
@@ -1658,9 +1658,12 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
16581658
/* interface to postgresql elog
16591659
*/
16601660
staticPyObject*PLy_debug(PyObject*,PyObject*);
1661+
staticPyObject*PLy_log(PyObject*,PyObject*);
1662+
staticPyObject*PLy_info(PyObject*,PyObject*);
1663+
staticPyObject*PLy_notice(PyObject*,PyObject*);
1664+
staticPyObject*PLy_warning(PyObject*,PyObject*);
16611665
staticPyObject*PLy_error(PyObject*,PyObject*);
16621666
staticPyObject*PLy_fatal(PyObject*,PyObject*);
1663-
staticPyObject*PLy_notice(PyObject*,PyObject*);
16641667

16651668
/* PLyPlanObject, PLyResultObject and SPI interface
16661669
*/
@@ -1782,9 +1785,12 @@ static PyMethodDef PLy_methods[] = {
17821785
* logging methods
17831786
*/
17841787
{"debug",PLy_debug,METH_VARARGS,NULL},
1788+
{"log",PLy_log,METH_VARARGS,NULL},
1789+
{"info",PLy_info,METH_VARARGS,NULL},
1790+
{"notice",PLy_notice,METH_VARARGS,NULL},
1791+
{"warning",PLy_warning,METH_VARARGS,NULL},
17851792
{"error",PLy_error,METH_VARARGS,NULL},
17861793
{"fatal",PLy_fatal,METH_VARARGS,NULL},
1787-
{"notice",PLy_notice,METH_VARARGS,NULL},
17881794

17891795
/*
17901796
* create a stored plan
@@ -2627,35 +2633,53 @@ populate_methods(PyObject *klass, PyMethodDef *methods)
26272633
/* the python interface to the elog function
26282634
* don't confuse these with PLy_elog
26292635
*/
2630-
staticPyObject*PLy_log(int,PyObject*,PyObject*);
2636+
staticPyObject*PLy_output(int,PyObject*,PyObject*);
26312637

26322638
PyObject*
26332639
PLy_debug(PyObject*self,PyObject*args)
26342640
{
2635-
returnPLy_log(LOG,self,args);
2641+
returnPLy_output(DEBUG1,self,args);
26362642
}
26372643

26382644
PyObject*
2639-
PLy_error(PyObject*self,PyObject*args)
2645+
PLy_log(PyObject*self,PyObject*args)
26402646
{
2641-
returnPLy_log(ERROR,self,args);
2647+
returnPLy_output(LOG,self,args);
26422648
}
26432649

26442650
PyObject*
2645-
PLy_fatal(PyObject*self,PyObject*args)
2651+
PLy_info(PyObject*self,PyObject*args)
26462652
{
2647-
returnPLy_log(FATAL,self,args);
2653+
returnPLy_output(INFO,self,args);
26482654
}
26492655

26502656
PyObject*
26512657
PLy_notice(PyObject*self,PyObject*args)
26522658
{
2653-
returnPLy_log(NOTICE,self,args);
2659+
returnPLy_output(NOTICE,self,args);
2660+
}
2661+
2662+
PyObject*
2663+
PLy_warning(PyObject*self,PyObject*args)
2664+
{
2665+
returnPLy_output(WARNING,self,args);
2666+
}
2667+
2668+
PyObject*
2669+
PLy_error(PyObject*self,PyObject*args)
2670+
{
2671+
returnPLy_output(ERROR,self,args);
2672+
}
2673+
2674+
PyObject*
2675+
PLy_fatal(PyObject*self,PyObject*args)
2676+
{
2677+
returnPLy_output(FATAL,self,args);
26542678
}
26552679

26562680

26572681
PyObject*
2658-
PLy_log(volatileintlevel,PyObject*self,PyObject*args)
2682+
PLy_output(volatileintlevel,PyObject*self,PyObject*args)
26592683
{
26602684
DECLARE_EXC();
26612685
PyObject*so;

‎src/pl/tcl/pltcl.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* ENHANCEMENTS, OR MODIFICATIONS.
3232
*
3333
* IDENTIFICATION
34-
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.51 2002/03/0606:10:48 momjian Exp $
34+
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.52 2002/03/0618:50:33 momjian Exp $
3535
*
3636
**********************************************************************/
3737

@@ -1259,7 +1259,11 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
12591259
returnTCL_ERROR;
12601260
}
12611261

1262-
if (strcmp(argv[1],"INFO")==0)
1262+
if (strcmp(argv[1],"DEBUG")==0)
1263+
level=DEBUG1;
1264+
elseif (strcmp(argv[1],"LOG")==0)
1265+
level=LOG;
1266+
elseif (strcmp(argv[1],"INFO")==0)
12631267
level=INFO;
12641268
elseif (strcmp(argv[1],"NOTICE")==0)
12651269
level=NOTICE;
@@ -1269,8 +1273,6 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
12691273
level=ERROR;
12701274
elseif (strcmp(argv[1],"FATAL")==0)
12711275
level=FATAL;
1272-
elseif (strcmp(argv[1],"DEBUG")==0)
1273-
level=DEBUG1;
12741276
else
12751277
{
12761278
Tcl_AppendResult(interp,"Unknown elog level '",argv[1],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp