diff options
| author | Bruce Momjian | 2001-03-22 04:01:46 +0000 |
|---|---|---|
| committer | Bruce Momjian | 2001-03-22 04:01:46 +0000 |
| commit | 9e1552607a9dc6bc23e43d46770a9063ade4f3f0 (patch) | |
| tree | 6a230d81917ebc004e40cd46c48f2aa27eec153e /src/pl | |
| parent | 6cf8707b828b14b5c2336076ce358b18b67829d6 (diff) | |
pgindent run. Make it all clean.
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plperl/plperl.c | 55 | ||||
| -rw-r--r-- | src/pl/plperl/ppport.h | 183 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_comp.c | 26 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 91 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_funcs.c | 10 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_handler.c | 6 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/plpgsql.h | 10 | ||||
| -rw-r--r-- | src/pl/tcl/pltcl.c | 88 |
8 files changed, 240 insertions, 229 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 21a78bdfaec..091b4e4071d 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -33,7 +33,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.18 2001/01/19 16:14:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.19 2001/03/22 04:01:40 momjian Exp $ * **********************************************************************/ @@ -135,7 +135,7 @@ static Tcl_HashTable *plperl_query_hash = NULL; static void plperl_init_all(void); static void plperl_init_safe_interp(void); -Datum plperl_call_handler(PG_FUNCTION_ARGS); +Datum plperl_call_handler(PG_FUNCTION_ARGS); static Datum plperl_func_handler(PG_FUNCTION_ARGS); @@ -223,14 +223,17 @@ plperl_init_safe_interp(void) { char *embedding[3] = { - "", "-e", - /* no commas between the next 4 please. They are supposed to be one string + "", "-e", + + /* + * no commas between the next 4 please. They are supposed to be + * one string */ "require Safe; SPI::bootstrap();" "sub ::mksafefunc { my $x = new Safe; $x->permit_only(':default');$x->permit(':base_math');" "$x->share(qw[&elog &DEBUG &NOTICE &NOIND &ERROR]);" " return $x->reval(qq[sub { $_[0] }]); }" - }; + }; plperl_safe_interp = perl_alloc(); if (!plperl_safe_interp) @@ -312,17 +315,17 @@ plperl_call_handler(PG_FUNCTION_ARGS) **********************************************************************/ static SV * -plperl_create_sub(char * s) +plperl_create_sub(char *s) { dSP; SV *subref = NULL; - int count; + int count; ENTER; SAVETMPS; PUSHMARK(SP); - XPUSHs(sv_2mortal(newSVpv(s,0))); + XPUSHs(sv_2mortal(newSVpv(s, 0))); PUTBACK; count = perl_call_pv("mksafefunc", G_SCALAR | G_EVAL | G_KEEPERR); SPAGAIN; @@ -336,9 +339,8 @@ plperl_create_sub(char * s) elog(ERROR, "creation of function failed: %s", SvPV(ERRSV, PL_na)); } - if (count != 1) { + if (count != 1) elog(ERROR, "creation of function failed - no return from mksafefunc"); - } /* * need to make a deep copy of the return. it comes off the stack as a @@ -412,28 +414,27 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo) TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i]; SV *hashref; - Assert(slot != NULL && ! fcinfo->argnull[i]); + Assert(slot != NULL && !fcinfo->argnull[i]); + /* * plperl_build_tuple_argument better return a mortal SV. */ hashref = plperl_build_tuple_argument(slot->val, - slot->ttc_tupleDescriptor); + slot->ttc_tupleDescriptor); XPUSHs(hashref); } else { if (fcinfo->argnull[i]) - { XPUSHs(&PL_sv_undef); - } else { char *tmp; tmp = DatumGetCString(FunctionCall3(&(desc->arg_out_func[i]), - fcinfo->arg[i], - ObjectIdGetDatum(desc->arg_out_elem[i]), - Int32GetDatum(desc->arg_out_len[i]))); + fcinfo->arg[i], + ObjectIdGetDatum(desc->arg_out_elem[i]), + Int32GetDatum(desc->arg_out_len[i]))); XPUSHs(sv_2mortal(newSVpv(tmp, 0))); pfree(tmp); } @@ -607,7 +608,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) * ************************************************************/ proc_source = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(&procStruct->prosrc))); + PointerGetDatum(&procStruct->prosrc))); /************************************************************ * Create the procedure in the interpreter @@ -804,7 +805,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) "unset i v\n\n", -1); proc_source = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(&procStruct->prosrc))); + PointerGetDatum(&procStruct->prosrc))); Tcl_DStringAppend(&proc_internal_body, proc_source, -1); pfree(proc_source); Tcl_DStringAppendElement(&proc_internal_def, @@ -876,7 +877,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) /* The oid of the trigger relation for argument TG_relid */ stroid = DatumGetCString(DirectFunctionCall1(oidout, - ObjectIdGetDatum(trigdata->tg_relation->rd_id))); + ObjectIdGetDatum(trigdata->tg_relation->rd_id))); Tcl_DStringAppendElement(&tcl_cmd, stroid); pfree(stroid); @@ -1104,7 +1105,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) FunctionCall3(&finfo, CStringGetDatum(ret_values[i++]), ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[attnum-1]->atttypmod)); + Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod)); } @@ -2124,9 +2125,9 @@ plperl_set_tuple_values(Tcl_Interp *interp, char *arrayname, if (!isnull && OidIsValid(typoutput)) { outputstr = DatumGetCString(OidFunctionCall3(typoutput, - attr, - ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[i]->attlen))); + attr, + ObjectIdGetDatum(typelem), + Int32GetDatum(tupdesc->attrs[i]->attlen))); Tcl_SetVar2(interp, *arrptr, *nameptr, outputstr, 0); pfree(outputstr); } @@ -2194,9 +2195,9 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) if (!isnull && OidIsValid(typoutput)) { outputstr = DatumGetCString(OidFunctionCall3(typoutput, - attr, - ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[i]->attlen))); + attr, + ObjectIdGetDatum(typelem), + Int32GetDatum(tupdesc->attrs[i]->attlen))); sv_catpvf(output, "'%s' => '%s',", attname, outputstr); pfree(outputstr); } diff --git a/src/pl/plperl/ppport.h b/src/pl/plperl/ppport.h index 7a3c59fc9a6..be5f99087ab 100644 --- a/src/pl/plperl/ppport.h +++ b/src/pl/plperl/ppport.h @@ -6,11 +6,11 @@ /* Copyright (C) 1999, Kenneth Albanowski. This code may be used and distributed under the same license as any version of Perl. */ - + /* For the latest version of this code, please retreive the Devel::PPPort module from CPAN, contact the author at <kjahds@kjahds.com>, or check with the Perl maintainers. */ - + /* If you needed to customize this file for your project, please mention your changes, and visible alter the version number. */ @@ -29,29 +29,29 @@ for a static include, or use the GLOBAL request in a single module to produce a global definition that can be referenced from the other modules. - - Function: Static define: Extern define: - newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL + + Function: Static define: Extern define: + newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL */ - + /* To verify whether ppport.h is needed for your module, and whether any special defines should be used, ppport.h can be run through Perl to check your source code. Simply say: - - perl -x ppport.h *.c *.h *.xs foo/*.c [etc] - + + perl -x ppport.h *.c *.h *.xs foo/*.c [etc] + The result will be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. It won't catch where dTHR is needed, and doesn't attempt to account for global macro or function definitions, nested includes, typemaps, etc. - + In order to test for the need of dTHR, please try your module under a recent version of Perl that has threading compiled-in. - -*/ + +*/ /* @@ -109,11 +109,11 @@ foreach $filename (map(glob($_),@ARGV)) { $need_include = 1; } } - + if (scalar(keys %add_func) or $need_include != $has_include) { if (!$has_include) { $inc = join('',map("#define NEED_$_\n", sort keys %add_func)). - "#include \"ppport.h\"\n"; + "#include \"ppport.h\"\n"; $c = "$inc$c" unless $c =~ s/#.*include.*XSUB.*\n/$&$inc/m; } elsif (keys %add_func) { $inc = join('',map("#define NEED_$_\n", sort keys %add_func)); @@ -125,7 +125,7 @@ foreach $filename (map(glob($_),@ARGV)) { } $changes++; } - + if ($changes) { open(OUT,">/tmp/ppport.h.$$"); print OUT $c; @@ -142,87 +142,90 @@ __DATA__ */ #ifndef PERL_REVISION -# ifndef __PATCHLEVEL_H_INCLUDED__ -# include "patchlevel.h" -# endif -# ifndef PERL_REVISION -# define PERL_REVISION (5) - /* Replace: 1 */ -# define PERL_VERSION PATCHLEVEL -# define PERL_SUBVERSION SUBVERSION - /* Replace PERL_PATCHLEVEL with PERL_VERSION */ - /* Replace: 0 */ -# endif +#ifndef __PATCHLEVEL_H_INCLUDED__ +#include "patchlevel.h" +#endif +#ifndef PERL_REVISION +#define PERL_REVISION (5) + /* Replace: 1 */ +#define PERL_VERSION PATCHLEVEL +#define PERL_SUBVERSION SUBVERSION + /* Replace PERL_PATCHLEVEL with PERL_VERSION */ + /* Replace: 0 */ +#endif #endif #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION) #ifndef ERRSV -# define ERRSV perl_get_sv("@",FALSE) +#define ERRSV perl_get_sv("@",FALSE) #endif #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5)) /* Replace: 1 */ -# define PL_sv_undef sv_undef -# define PL_sv_yes sv_yes -# define PL_sv_no sv_no -# define PL_na na -# define PL_stdingv stdingv -# define PL_hints hints -# define PL_curcop curcop -# define PL_curstash curstash -# define PL_copline copline -# define PL_Sv Sv +#define PL_sv_undef sv_undef +#define PL_sv_yes sv_yes +#define PL_sv_no sv_no +#define PL_na na +#define PL_stdingv stdingv +#define PL_hints hints +#define PL_curcop curcop +#define PL_curstash curstash +#define PL_copline copline +#define PL_Sv Sv /* Replace: 0 */ #endif #ifndef dTHR -# ifdef WIN32 -# define dTHR extern int Perl___notused -# else -# define dTHR extern int errno -# endif +#ifdef WIN32 +#define dTHR extern int Perl___notused +#else +#define dTHR extern int errno +#endif #endif #ifndef boolSV -# define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) +#define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif #ifndef gv_stashpvn -# define gv_stashpvn(str,len,flags) gv_stashpv(str,flags) +#define gv_stashpvn(str,len,flags) gv_stashpv(str,flags) #endif #ifndef newSVpvn -# define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0)) +#define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0)) #endif #ifndef newRV_inc /* Replace: 1 */ -# define newRV_inc(sv) newRV(sv) +#define newRV_inc(sv) newRV(sv) /* Replace: 0 */ #endif #ifndef newRV_noinc -# ifdef __GNUC__ -# define newRV_noinc(sv) \ - ({ \ - SV *nsv = (SV*)newRV(sv); \ - SvREFCNT_dec(sv); \ - nsv; \ - }) -# else -# if defined(CRIPPLED_CC) || defined(USE_THREADS) -static SV * newRV_noinc (SV * sv) +#ifdef __GNUC__ +#define newRV_noinc(sv) \ + ({ \ + SV *nsv = (SV*)newRV(sv); \ + SvREFCNT_dec(sv); \ + nsv; \ + }) +#else +#if defined(CRIPPLED_CC) || defined(USE_THREADS) +static SV * +newRV_noinc(SV * sv) { - SV *nsv = (SV*)newRV(sv); - SvREFCNT_dec(sv); - return nsv; + SV *nsv = (SV *) newRV(sv); + + SvREFCNT_dec(sv); + return nsv; } -# else -# define newRV_noinc(sv) \ - ((PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv) -# endif -# endif + +#else +#define newRV_noinc(sv) \ + ((PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv) +#endif +#endif #endif /* Provide: newCONSTSUB */ @@ -233,20 +236,22 @@ static SV * newRV_noinc (SV * sv) #if defined(NEED_newCONSTSUB) static #else -extern void newCONSTSUB _((HV * stash, char * name, SV *sv)); +extern void newCONSTSUB _((HV * stash, char *name, SV * sv)); + #endif #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) void -newCONSTSUB(stash,name,sv) -HV *stash; -char *name; -SV *sv; +newCONSTSUB(stash, name, sv) +HV *stash; +char *name; +SV *sv; { - U32 oldhints = PL_hints; - HV *old_cop_stash = PL_curcop->cop_stash; - HV *old_curstash = PL_curstash; - line_t oldline = PL_curcop->cop_line; + U32 oldhints = PL_hints; + HV *old_cop_stash = PL_curcop->cop_stash; + HV *old_curstash = PL_curstash; + line_t oldline = PL_curcop->cop_line; + PL_curcop->cop_line = PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; @@ -256,31 +261,33 @@ SV *sv; newSUB( #if (PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22)) - /* before 5.003_22 */ - start_subparse(), + /* before 5.003_22 */ + start_subparse(), #else -# if (PERL_VERSION == 3) && (PERL_SUBVERSION == 22) - /* 5.003_22 */ - start_subparse(0), -# else - /* 5.003_23 onwards */ - start_subparse(FALSE, 0), -# endif +#if (PERL_VERSION == 3) && (PERL_SUBVERSION == 22) + /* 5.003_22 */ + start_subparse(0), +#else + /* 5.003_23 onwards */ + start_subparse(FALSE, 0), +#endif #endif - newSVOP(OP_CONST, 0, newSVpv(name,0)), - newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ - newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) - ); + newSVOP(OP_CONST, 0, newSVpv(name, 0)), + newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" + * -- GMB */ + newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) + ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } + #endif -#endif /* newCONSTSUB */ +#endif /* newCONSTSUB */ -#endif /* _P_P_PORTABILITY_H_ */ +#endif /* _P_P_PORTABILITY_H_ */ diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index ffcb7d72d6f..1ea7a58aac1 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.26 2001/02/09 03:26:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.27 2001/03/22 04:01:41 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -135,10 +135,10 @@ plpgsql_compile(Oid fn_oid, int functype) */ procStruct = (Form_pg_proc) GETSTRUCT(procTup); proc_source = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(&procStruct->prosrc))); + PointerGetDatum(&procStruct->prosrc))); plpgsql_setinput(proc_source, functype); plpgsql_error_funcname = DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&(procStruct->proname)))); + NameGetDatum(&(procStruct->proname)))); plpgsql_error_lineno = 0; /* ---------- @@ -152,7 +152,7 @@ plpgsql_compile(Oid fn_oid, int functype) function->fn_functype = functype; function->fn_oid = fn_oid; function->fn_name = strdup(DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&(procStruct->proname))))); + NameGetDatum(&(procStruct->proname))))); switch (functype) { @@ -169,7 +169,7 @@ plpgsql_compile(Oid fn_oid, int functype) * ---------- */ typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), + ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -206,7 +206,7 @@ plpgsql_compile(Oid fn_oid, int functype) * ---------- */ typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->proargtypes[i]), + ObjectIdGetDatum(procStruct->proargtypes[i]), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -228,7 +228,7 @@ plpgsql_compile(Oid fn_oid, int functype) */ sprintf(buf, "%s%%rowtype", DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&(typeStruct->typname))))); + NameGetDatum(&(typeStruct->typname))))); if (plpgsql_parse_wordrowtype(buf) != T_ROW) { plpgsql_comperrinfo(); @@ -262,7 +262,7 @@ plpgsql_compile(Oid fn_oid, int functype) var->refname = strdup(buf); var->lineno = 0; var->datatype->typname = DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&(typeStruct->typname)))); + NameGetDatum(&(typeStruct->typname)))); var->datatype->typoid = procStruct->proargtypes[i]; fmgr_info(typeStruct->typinput, &(var->datatype->typinput)); var->datatype->typelem = typeStruct->typelem; @@ -630,7 +630,7 @@ plpgsql_parse_word(char *word) typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type)); typ->typname = DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&(typeStruct->typname)))); + NameGetDatum(&(typeStruct->typname)))); typ->typoid = typeTup->t_data->t_oid; fmgr_info(typeStruct->typinput, &(typ->typinput)); typ->typelem = typeStruct->typelem; @@ -958,7 +958,7 @@ plpgsql_parse_wordtype(char *word) typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type)); typ->typname = DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&(typeStruct->typname)))); + NameGetDatum(&(typeStruct->typname)))); typ->typoid = typeTup->t_data->t_oid; fmgr_info(typeStruct->typinput, &(typ->typinput)); typ->typelem = typeStruct->typelem; @@ -1109,7 +1109,7 @@ plpgsql_parse_dblwordtype(char *string) typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type)); typ->typname = DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&(typeStruct->typname)))); + NameGetDatum(&(typeStruct->typname)))); typ->typoid = typetup->t_data->t_oid; fmgr_info(typeStruct->typinput, &(typ->typinput)); typ->typelem = typeStruct->typelem; @@ -1205,7 +1205,7 @@ plpgsql_parse_wordrowtype(char *string) * ---------- */ attrtup = SearchSysCache(ATTNUM, - ObjectIdGetDatum(classtup->t_data->t_oid), + ObjectIdGetDatum(classtup->t_data->t_oid), Int16GetDatum(i + 1), 0, 0); if (!HeapTupleIsValid(attrtup)) @@ -1217,7 +1217,7 @@ plpgsql_parse_wordrowtype(char *string) attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup); cp = DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&(attrStruct->attname)))); + NameGetDatum(&(attrStruct->attname)))); typetup = SearchSysCache(TYPEOID, ObjectIdGetDatum(attrStruct->atttypid), diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 94dc0be45de..c51a633af85 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.38 2001/02/19 19:49:53 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.39 2001/03/22 04:01:41 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -82,7 +82,7 @@ static int exec_stmt(PLpgSQL_execstate * estate, static int exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt); static int exec_stmt_getdiag(PLpgSQL_execstate * estate, - PLpgSQL_stmt_getdiag * stmt); + PLpgSQL_stmt_getdiag * stmt); static int exec_stmt_if(PLpgSQL_execstate * estate, PLpgSQL_stmt_if * stmt); static int exec_stmt_loop(PLpgSQL_execstate * estate, @@ -104,9 +104,9 @@ static int exec_stmt_raise(PLpgSQL_execstate * estate, static int exec_stmt_execsql(PLpgSQL_execstate * estate, PLpgSQL_stmt_execsql * stmt); static int exec_stmt_dynexecute(PLpgSQL_execstate * estate, - PLpgSQL_stmt_dynexecute * stmt); + PLpgSQL_stmt_dynexecute * stmt); static int exec_stmt_dynfors(PLpgSQL_execstate * estate, - PLpgSQL_stmt_dynfors * stmt); + PLpgSQL_stmt_dynfors * stmt); static void exec_prepare_plan(PLpgSQL_execstate * estate, PLpgSQL_expr * expr); @@ -330,7 +330,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) HeapTuple tup; TupleDesc tupdesc; - Assert(slot != NULL && ! fcinfo->argnull[i]); + Assert(slot != NULL && !fcinfo->argnull[i]); tup = slot->val; tupdesc = slot->ttc_tupleDescriptor; exec_move_row(&estate, NULL, row, tup, tupdesc); @@ -663,7 +663,7 @@ plpgsql_exec_trigger(PLpgSQL_function * func, var = (PLpgSQL_var *) (estate.datums[func->tg_name_varno]); var->isnull = false; var->value = DirectFunctionCall1(namein, - CStringGetDatum(trigdata->tg_trigger->tgname)); + CStringGetDatum(trigdata->tg_trigger->tgname)); var = (PLpgSQL_var *) (estate.datums[func->tg_when_varno]); var->isnull = false; @@ -690,7 +690,7 @@ plpgsql_exec_trigger(PLpgSQL_function * func, var = (PLpgSQL_var *) (estate.datums[func->tg_relname_varno]); var->isnull = false; var->value = DirectFunctionCall1(namein, - CStringGetDatum(RelationGetRelationName(trigdata->tg_relation))); + CStringGetDatum(RelationGetRelationName(trigdata->tg_relation))); var = (PLpgSQL_var *) (estate.datums[func->tg_nargs_varno]); var->isnull = false; @@ -710,7 +710,7 @@ plpgsql_exec_trigger(PLpgSQL_function * func, estate.trig_argv = palloc(sizeof(Datum) * estate.trig_nargs); for (i = 0; i < trigdata->tg_trigger->tgnargs; i++) estate.trig_argv[i] = DirectFunctionCall1(textin, - CStringGetDatum(trigdata->tg_trigger->tgargs[i])); + CStringGetDatum(trigdata->tg_trigger->tgargs[i])); } /* ---------- @@ -1060,24 +1060,24 @@ exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt) } /* ---------- - * exec_stmt_getdiag Put internal PG information into - * specified variables. + * exec_stmt_getdiag Put internal PG information into + * specified variables. * ---------- */ static int exec_stmt_getdiag(PLpgSQL_execstate * estate, PLpgSQL_stmt_getdiag * stmt) { - int i; - PLpgSQL_datum *var; - bool isnull = false; + int i; + PLpgSQL_datum *var; + bool isnull = false; - for ( i=0 ; i < stmt->ndtitems ; i++) + for (i = 0; i < stmt->ndtitems; i++) { - PLpgSQL_diag_item *dtitem = & stmt->dtitems[i]; + PLpgSQL_diag_item *dtitem = &stmt->dtitems[i]; if (dtitem->target <= 0) continue; - + var = (estate->datums[dtitem->target]); if (var == NULL) @@ -1098,12 +1098,12 @@ exec_stmt_getdiag(PLpgSQL_execstate * estate, PLpgSQL_stmt_getdiag * stmt) break; default: - + elog(ERROR, "unknown attribute request %d in get_diagnostic", dtitem->item); } } - + return PLPGSQL_RC_OK; } @@ -1647,7 +1647,7 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) else { typetup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(var->datatype->typoid), + ObjectIdGetDatum(var->datatype->typoid), 0, 0, 0); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup for type %u failed (1)", @@ -1656,9 +1656,9 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) fmgr_info(typeStruct->typoutput, &finfo_output); extval = DatumGetCString(FunctionCall3(&finfo_output, - var->value, - ObjectIdGetDatum(typeStruct->typelem), - Int32GetDatum(var->datatype->atttypmod))); + var->value, + ObjectIdGetDatum(typeStruct->typelem), + Int32GetDatum(var->datatype->atttypmod))); ReleaseSysCache(typetup); } plpgsql_dstring_append(&ds, extval); @@ -1702,7 +1702,7 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) extval = "<OUT_OF_RANGE>"; else extval = DatumGetCString(DirectFunctionCall1(textout, - estate->trig_argv[value])); + estate->trig_argv[value])); } plpgsql_dstring_append(&ds, extval); } @@ -1945,7 +1945,7 @@ exec_stmt_execsql(PLpgSQL_execstate * estate, */ static int exec_stmt_dynexecute(PLpgSQL_execstate * estate, - PLpgSQL_stmt_dynexecute * stmt) + PLpgSQL_stmt_dynexecute * stmt) { Datum query; bool isnull = false; @@ -1980,16 +1980,16 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate, fmgr_info(typeStruct->typoutput, &finfo_output); querystr = DatumGetCString(FunctionCall3(&finfo_output, query, - ObjectIdGetDatum(typeStruct->typelem), + ObjectIdGetDatum(typeStruct->typelem), Int32GetDatum(-1))); - if(!typeStruct->typbyval) - pfree((void *)query); + if (!typeStruct->typbyval) + pfree((void *) query); ReleaseSysCache(typetup); /* ---------- - * Call SPI_exec() without preparing a saved plan. + * Call SPI_exec() without preparing a saved plan. * The returncode can be any standard OK. Note that * while a SELECT is allowed, its results will be discarded. * ---------- @@ -2005,17 +2005,20 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate, break; case 0: - /* Also allow a zero return, which implies the querystring + + /* + * Also allow a zero return, which implies the querystring * contained no commands. */ break; case SPI_OK_SELINTO: + /* - * Disallow this for now, because its behavior is not consistent - * with SELECT INTO in a normal plpgsql context. We need to - * reimplement EXECUTE to parse the string as a plpgsql command, - * not just feed it to SPI_exec. + * Disallow this for now, because its behavior is not + * consistent with SELECT INTO in a normal plpgsql context. + * We need to reimplement EXECUTE to parse the string as a + * plpgsql command, not just feed it to SPI_exec. */ elog(ERROR, "EXECUTE of SELECT ... INTO is not implemented yet"); break; @@ -2098,12 +2101,12 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) fmgr_info(typeStruct->typoutput, &finfo_output); querystr = DatumGetCString(FunctionCall3(&finfo_output, - query, - ObjectIdGetDatum(typeStruct->typelem), - Int32GetDatum(-1))); + query, + ObjectIdGetDatum(typeStruct->typelem), + Int32GetDatum(-1))); - if(!typeStruct->typbyval) - pfree((void *)query); + if (!typeStruct->typbyval) + pfree((void *) query); ReleaseSysCache(typetup); @@ -2632,10 +2635,10 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, SPI_pop(); /* - * Copy the result out of the expression-evaluation memory context, - * so that we can free the expression context. + * Copy the result out of the expression-evaluation memory context, so + * that we can free the expression context. */ - if (! *isNull) + if (!*isNull) { int16 typeLength; bool byValue; @@ -2772,9 +2775,9 @@ exec_cast_value(Datum value, Oid valtype, fmgr_info(typeStruct->typoutput, &finfo_output); extval = DatumGetCString(FunctionCall3(&finfo_output, - value, - ObjectIdGetDatum(typeStruct->typelem), - Int32GetDatum(-1))); + value, + ObjectIdGetDatum(typeStruct->typelem), + Int32GetDatum(-1))); value = FunctionCall3(reqinput, CStringGetDatum(extval), ObjectIdGetDatum(reqtypelem), diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c index 2b3605d2a10..ac069fec4a5 100644 --- a/src/pl/plpgsql/src/pl_funcs.c +++ b/src/pl/plpgsql/src/pl_funcs.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.10 2001/02/19 19:49:53 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.11 2001/03/22 04:01:41 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -711,16 +711,16 @@ dump_getdiag(PLpgSQL_stmt_getdiag * stmt) printf("GET DIAGNOSTICS "); for (i = 0; i < stmt->ndtitems; i++) { - PLpgSQL_diag_item *dtitem = & stmt->dtitems[i]; + PLpgSQL_diag_item *dtitem = &stmt->dtitems[i]; if (i != 0) printf(", "); printf("{var %d} = ", dtitem->target); - switch (dtitem->item) + switch (dtitem->item) { - case PLPGSQL_GETDIAG_ROW_COUNT: + case PLPGSQL_GETDIAG_ROW_COUNT: printf("ROW_COUNT"); break; @@ -729,7 +729,7 @@ dump_getdiag(PLpgSQL_stmt_getdiag * stmt) break; default: - printf("???"); + printf("???"); break; } } diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index d9e208ee98b..ee6542f608f 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.6 2000/11/20 20:36:52 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.7 2001/03/22 04:01:42 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -94,7 +94,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) * Check if we already compiled this function * ---------- */ - Oid funcOid = fcinfo->flinfo->fn_oid; + Oid funcOid = fcinfo->flinfo->fn_oid; for (func = compiled_functions; func != NULL; func = func->next) { @@ -128,7 +128,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) */ if (isTrigger) retval = PointerGetDatum(plpgsql_exec_trigger(func, - (TriggerData *) fcinfo->context)); + (TriggerData *) fcinfo->context)); else retval = plpgsql_exec_function(func, fcinfo); diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index 727035bbb61..f364b39e12c 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.12 2001/02/19 19:49:53 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.13 2001/03/22 04:01:42 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -115,8 +115,8 @@ enum */ enum { - PLPGSQL_GETDIAG_ROW_COUNT, - PLPGSQL_GETDIAG_RESULT_OID + PLPGSQL_GETDIAG_ROW_COUNT, + PLPGSQL_GETDIAG_RESULT_OID }; @@ -512,9 +512,9 @@ extern Datum plpgsql_call_handler(PG_FUNCTION_ARGS); * ---------- */ extern Datum plpgsql_exec_function(PLpgSQL_function * func, - FunctionCallInfo fcinfo); + FunctionCallInfo fcinfo); extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function * func, - TriggerData *trigdata); + TriggerData *trigdata); /* ---------- diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index a13ad19f984..1fd8d67a468 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -1,6 +1,6 @@ /********************************************************************** * pltcl.c - PostgreSQL support for Tcl as - * procedural language (PL) + * procedural language (PL) * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -31,7 +31,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.33 2001/03/07 16:18:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.34 2001/03/22 04:01:42 momjian Exp $ * **********************************************************************/ @@ -116,8 +116,8 @@ static void pltcl_init_load_unknown(Tcl_Interp *interp); #endif /* PLTCL_UNKNOWN_SUPPORT */ -Datum pltcl_call_handler(PG_FUNCTION_ARGS); -Datum pltclu_call_handler(PG_FUNCTION_ARGS); +Datum pltcl_call_handler(PG_FUNCTION_ARGS); +Datum pltclu_call_handler(PG_FUNCTION_ARGS); static Datum pltcl_func_handler(PG_FUNCTION_ARGS); @@ -128,9 +128,9 @@ static int pltcl_elog(ClientData cdata, Tcl_Interp *interp, static int pltcl_quote(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); static int pltcl_argisnull(ClientData cdata, Tcl_Interp *interp, - int argc, char *argv[]); + int argc, char *argv[]); static int pltcl_returnnull(ClientData cdata, Tcl_Interp *interp, - int argc, char *argv[]); + int argc, char *argv[]); static int pltcl_SPI_exec(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); @@ -178,7 +178,7 @@ pltcl_init_all(void) Tcl_CreateSlave(pltcl_hold_interp, "norm", 0)) == NULL) { elog(ERROR, - "pltcl: internal error - cannot create 'normal' interpreter"); + "pltcl: internal error - cannot create 'normal' interpreter"); } pltcl_init_interp(pltcl_norm_interp); @@ -360,7 +360,9 @@ pltcl_call_handler(PG_FUNCTION_ARGS) { pltcl_current_fcinfo = NULL; retval = PointerGetDatum(pltcl_trigger_handler(fcinfo)); - } else { + } + else + { pltcl_current_fcinfo = fcinfo; retval = pltcl_func_handler(fcinfo); } @@ -422,17 +424,17 @@ pltcl_func_handler(PG_FUNCTION_ARGS) * * Then we load the procedure into the safe interpreter. ************************************************************/ - HeapTuple procTup; - HeapTuple langTup; - HeapTuple typeTup; - Form_pg_proc procStruct; + HeapTuple procTup; + HeapTuple langTup; + HeapTuple typeTup; + Form_pg_proc procStruct; Form_pg_language langStruct; - Form_pg_type typeStruct; - Tcl_DString proc_internal_def; - Tcl_DString proc_internal_body; - char proc_internal_args[4096]; - char *proc_source; - char buf[512]; + Form_pg_type typeStruct; + Tcl_DString proc_internal_def; + Tcl_DString proc_internal_body; + char proc_internal_args[4096]; + char *proc_source; + char buf[512]; /************************************************************ * Allocate a new procedure description block @@ -584,7 +586,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) Tcl_DStringAppend(&proc_internal_body, buf, -1); } proc_source = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(&procStruct->prosrc))); + PointerGetDatum(&procStruct->prosrc))); Tcl_DStringAppend(&proc_internal_body, proc_source, -1); pfree(proc_source); Tcl_DStringAppendElement(&proc_internal_def, @@ -622,9 +624,9 @@ pltcl_func_handler(PG_FUNCTION_ARGS) prodesc = (pltcl_proc_desc *) Tcl_GetHashValue(hashent); if (prodesc->lanpltrusted) - interp = pltcl_safe_interp; + interp = pltcl_safe_interp; else - interp = pltcl_norm_interp; + interp = pltcl_norm_interp; } /************************************************************ @@ -662,7 +664,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) **************************************************/ TupleTableSlot *slot = (TupleTableSlot *) fcinfo->arg[i]; - Assert(slot != NULL && ! fcinfo->argnull[i]); + Assert(slot != NULL && !fcinfo->argnull[i]); Tcl_DStringInit(&list_tmp); pltcl_build_tuple_argument(slot->val, slot->ttc_tupleDescriptor, @@ -678,17 +680,15 @@ pltcl_func_handler(PG_FUNCTION_ARGS) * of their external representation **************************************************/ if (fcinfo->argnull[i]) - { Tcl_DStringAppendElement(&tcl_cmd, ""); - } else { char *tmp; tmp = DatumGetCString(FunctionCall3(&prodesc->arg_out_func[i], - fcinfo->arg[i], - ObjectIdGetDatum(prodesc->arg_out_elem[i]), - Int32GetDatum(prodesc->arg_out_len[i]))); + fcinfo->arg[i], + ObjectIdGetDatum(prodesc->arg_out_elem[i]), + Int32GetDatum(prodesc->arg_out_len[i]))); Tcl_DStringAppendElement(&tcl_cmd, tmp); pfree(tmp); } @@ -902,7 +902,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) "unset i v\n\n", -1); proc_source = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(&procStruct->prosrc))); + PointerGetDatum(&procStruct->prosrc))); Tcl_DStringAppend(&proc_internal_body, proc_source, -1); pfree(proc_source); Tcl_DStringAppendElement(&proc_internal_def, @@ -979,7 +979,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) /* The oid of the trigger relation for argument TG_relid */ stroid = DatumGetCString(DirectFunctionCall1(oidout, - ObjectIdGetDatum(trigdata->tg_relation->rd_id))); + ObjectIdGetDatum(trigdata->tg_relation->rd_id))); Tcl_DStringAppendElement(&tcl_cmd, stroid); pfree(stroid); @@ -1208,7 +1208,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) FunctionCall3(&finfo, CStringGetDatum(ret_values[i++]), ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[attnum-1]->atttypmod)); + Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod)); } rettup = SPI_modifytuple(trigdata->tg_relation, rettup, tupdesc->natts, @@ -1352,9 +1352,9 @@ pltcl_quote(ClientData cdata, Tcl_Interp *interp, **********************************************************************/ static int pltcl_argisnull(ClientData cdata, Tcl_Interp *interp, - int argc, char *argv[]) + int argc, char *argv[]) { - int argno; + int argno; FunctionCallInfo fcinfo = pltcl_current_fcinfo; /************************************************************ @@ -1371,7 +1371,7 @@ pltcl_argisnull(ClientData cdata, Tcl_Interp *interp, ************************************************************/ if (fcinfo == NULL) { - Tcl_SetResult(interp, "argisnull cannot be used in triggers", + Tcl_SetResult(interp, "argisnull cannot be used in triggers", TCL_VOLATILE); return TCL_ERROR; } @@ -1409,9 +1409,9 @@ pltcl_argisnull(ClientData cdata, Tcl_Interp *interp, **********************************************************************/ static int pltcl_returnnull(ClientData cdata, Tcl_Interp *interp, - int argc, char *argv[]) + int argc, char *argv[]) { - int argno; + int argno; FunctionCallInfo fcinfo = pltcl_current_fcinfo; /************************************************************ @@ -1428,7 +1428,7 @@ pltcl_returnnull(ClientData cdata, Tcl_Interp *interp, ************************************************************/ if (fcinfo == NULL) { - Tcl_SetResult(interp, "return_null cannot be used in triggers", + Tcl_SetResult(interp, "return_null cannot be used in triggers", TCL_VOLATILE); return TCL_ERROR; } @@ -1851,9 +1851,9 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, * the key to the caller ************************************************************/ if (interp == pltcl_norm_interp) - query_hash = pltcl_norm_query_hash; + query_hash = pltcl_norm_query_hash; else - query_hash = pltcl_safe_query_hash; + query_hash = pltcl_safe_query_hash; memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart)); hashent = Tcl_CreateHashEntry(query_hash, qdesc->qname, &hashnew); @@ -2335,9 +2335,9 @@ pltcl_set_tuple_values(Tcl_Interp *interp, char *arrayname, if (!isnull && OidIsValid(typoutput)) { outputstr = DatumGetCString(OidFunctionCall3(typoutput, - attr, - ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[i]->attlen))); + attr, + ObjectIdGetDatum(typelem), + Int32GetDatum(tupdesc->attrs[i]->attlen))); Tcl_SetVar2(interp, *arrptr, *nameptr, outputstr, 0); pfree(outputstr); } @@ -2405,9 +2405,9 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, if (!isnull && OidIsValid(typoutput)) { outputstr = DatumGetCString(OidFunctionCall3(typoutput, - attr, - ObjectIdGetDatum(typelem), - Int32GetDatum(tupdesc->attrs[i]->attlen))); + attr, + ObjectIdGetDatum(typelem), + Int32GetDatum(tupdesc->attrs[i]->attlen))); Tcl_DStringAppendElement(retval, attname); Tcl_DStringAppendElement(retval, outputstr); pfree(outputstr); |
