summaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
authorBruce Momjian2005-10-15 02:49:52 +0000
committerBruce Momjian2005-10-15 02:49:52 +0000
commit1dc34982511d91ef8a2b71bdcb870f067c1b3da9 (patch)
tree1046adab1d4b964e0c38afeec0ee6546f61d9a8a /src/pl
parent790c01d28099587bbe2c623d4389b62ee49b1dee (diff)
Standard pgindent run for 8.1.
Diffstat (limited to 'src/pl')
-rw-r--r--src/pl/plperl/plperl.c245
-rw-r--r--src/pl/plperl/ppport.h14
-rw-r--r--src/pl/plperl/spi_internal.h6
-rw-r--r--src/pl/plpgsql/src/pl_comp.c268
-rw-r--r--src/pl/plpgsql/src/pl_exec.c893
-rw-r--r--src/pl/plpgsql/src/pl_funcs.c134
-rw-r--r--src/pl/plpgsql/src/pl_handler.c8
-rw-r--r--src/pl/plpgsql/src/plpgsql.h131
-rw-r--r--src/pl/plpython/plpython.c100
-rw-r--r--src/pl/tcl/pltcl.c137
10 files changed, 965 insertions, 971 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 5f9246187c9..5bd2943dd52 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.92 2005/08/24 19:06:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.93 2005/10/15 02:49:49 momjian Exp $
*
**********************************************************************/
@@ -82,15 +82,15 @@ typedef struct plperl_proc_desc
bool lanpltrusted;
bool fn_retistuple; /* true, if function returns tuple */
bool fn_retisset; /* true, if function returns set */
- bool fn_retisarray; /* true if function returns array */
+ bool fn_retisarray; /* true if function returns array */
Oid result_oid; /* Oid of result type */
- FmgrInfo result_in_func; /* I/O function and arg for result type */
+ FmgrInfo result_in_func; /* I/O function and arg for result type */
Oid result_typioparam;
int nargs;
FmgrInfo arg_out_func[FUNC_MAX_ARGS];
bool arg_is_rowtype[FUNC_MAX_ARGS];
SV *reference;
-} plperl_proc_desc;
+} plperl_proc_desc;
/**********************************************************************
@@ -131,7 +131,7 @@ static SV *plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc);
static void plperl_init_shared_libs(pTHX);
static HV *plperl_spi_execute_fetch_result(SPITupleTable *, int, int);
-void plperl_return_next(SV *);
+void plperl_return_next(SV *);
/*
* This routine is a crock, and so is everyplace that calls it. The problem
@@ -160,12 +160,12 @@ plperl_init(void)
return;
DefineCustomBoolVariable(
- "plperl.use_strict",
- "If true, will compile trusted and untrusted perl code in strict mode",
- NULL,
- &plperl_use_strict,
- PGC_USERSET,
- NULL, NULL);
+ "plperl.use_strict",
+ "If true, will compile trusted and untrusted perl code in strict mode",
+ NULL,
+ &plperl_use_strict,
+ PGC_USERSET,
+ NULL, NULL);
EmitWarningsOnPlaceholders("plperl");
@@ -240,7 +240,7 @@ plperl_init_all(void)
"$PLContainer->deny('require');" \
"sub ::mk_strict_safefunc {" \
" my $ret = $PLContainer->reval(qq[sub { BEGIN { strict->import(); } $_[0] $_[1] }]); " \
- " $@ =~ s/\\(eval \\d+\\) //g if $@; return $ret; }"
+ " $@ =~ s/\\(eval \\d+\\) //g if $@; return $ret; }"
#define SAFE_BAD \
"use vars qw($PLContainer); $PLContainer = new Safe('PLPerl');" \
@@ -257,7 +257,7 @@ plperl_init_all(void)
static void
plperl_init_interp(void)
{
- static char *embedding[3] = {
+ static char *embedding[3] = {
"", "-e", PERLBOOT
};
@@ -288,7 +288,7 @@ plperl_safe_init(void)
* assume that floating-point comparisons are exact, so use a slightly
* smaller comparison value.
*/
- if (safe_version < 2.0899 )
+ if (safe_version < 2.0899)
{
/* not safe, so disallow all trusted funcs */
eval_pv(SAFE_BAD, FALSE);
@@ -308,10 +308,10 @@ plperl_safe_init(void)
static char *
strip_trailing_ws(const char *msg)
{
- char *res = pstrdup(msg);
- int len = strlen(res);
+ char *res = pstrdup(msg);
+ int len = strlen(res);
- while (len > 0 && isspace((unsigned char) res[len-1]))
+ while (len > 0 && isspace((unsigned char) res[len - 1]))
res[--len] = '\0';
return res;
}
@@ -320,7 +320,7 @@ strip_trailing_ws(const char *msg)
/* Build a tuple from a hash. */
static HeapTuple
-plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta)
+plperl_build_tuple_result(HV * perlhash, AttInMetadata *attinmeta)
{
TupleDesc td = attinmeta->tupdesc;
char **values;
@@ -334,7 +334,7 @@ plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta)
hv_iterinit(perlhash);
while ((val = hv_iternextsv(perlhash, &key, &klen)))
{
- int attn = SPI_fnumber(td, key);
+ int attn = SPI_fnumber(td, key);
if (attn <= 0 || td->attrs[attn - 1]->attisdropped)
ereport(ERROR,
@@ -354,29 +354,30 @@ plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta)
/*
* convert perl array to postgres string representation
*/
-static SV*
-plperl_convert_to_pg_array(SV *src)
+static SV *
+plperl_convert_to_pg_array(SV * src)
{
- SV* rv;
- int count;
- dSP ;
+ SV *rv;
+ int count;
+
+ dSP;
- PUSHMARK(SP) ;
+ PUSHMARK(SP);
XPUSHs(src);
- PUTBACK ;
+ PUTBACK;
count = call_pv("::_plperl_to_pg_array", G_SCALAR);
- SPAGAIN ;
+ SPAGAIN;
if (count != 1)
elog(ERROR, "unexpected _plperl_to_pg_array failure");
rv = POPs;
-
- PUTBACK ;
- return rv;
+ PUTBACK;
+
+ return rv;
}
@@ -400,10 +401,10 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
tupdesc = tdata->tg_relation->rd_att;
relid = DatumGetCString(
- DirectFunctionCall1(oidout,
- ObjectIdGetDatum(tdata->tg_relation->rd_id)
- )
- );
+ DirectFunctionCall1(oidout,
+ ObjectIdGetDatum(tdata->tg_relation->rd_id)
+ )
+ );
hv_store(hv, "name", 4, newSVpv(tdata->tg_trigger->tgname, 0), 0);
hv_store(hv, "relid", 5, newSVpv(relid, 0), 0);
@@ -445,10 +446,11 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
if (tdata->tg_trigger->tgnargs > 0)
{
- AV *av = newAV();
- for (i=0; i < tdata->tg_trigger->tgnargs; i++)
+ AV *av = newAV();
+
+ for (i = 0; i < tdata->tg_trigger->tgnargs; i++)
av_push(av, newSVpv(tdata->tg_trigger->tgargs[i], 0));
- hv_store(hv, "args", 4, newRV_noinc((SV *)av), 0);
+ hv_store(hv, "args", 4, newRV_noinc((SV *) av), 0);
}
hv_store(hv, "relname", 7,
@@ -470,14 +472,14 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
level = "UNKNOWN";
hv_store(hv, "level", 5, newSVpv(level, 0), 0);
- return newRV_noinc((SV*)hv);
+ return newRV_noinc((SV *) hv);
}
/* Set up the new tuple returned from a trigger. */
static HeapTuple
-plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup)
+plperl_modify_tuple(HV * hvTD, TriggerData *tdata, HeapTuple otup)
{
SV **svp;
HV *hvNew;
@@ -531,8 +533,8 @@ plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup)
&typinput, &typioparam);
fmgr_info(typinput, &finfo);
modvalues[slotsused] = FunctionCall3(&finfo,
- CStringGetDatum(SvPV(val, PL_na)),
- ObjectIdGetDatum(typioparam),
+ CStringGetDatum(SvPV(val, PL_na)),
+ ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[attn - 1]->atttypmod));
modnulls[slotsused] = ' ';
}
@@ -571,11 +573,11 @@ PG_FUNCTION_INFO_V1(plperl_call_handler);
Datum
plperl_call_handler(PG_FUNCTION_ARGS)
{
- Datum retval;
+ Datum retval;
plperl_proc_desc *save_prodesc;
FunctionCallInfo save_caller_info;
Tuplestorestate *save_tuple_store;
- TupleDesc save_tuple_desc;
+ TupleDesc save_tuple_desc;
plperl_init_all();
@@ -657,7 +659,7 @@ plperl_create_sub(char *s, bool trusted)
dSP;
SV *subref;
int count;
- char *compile_sub;
+ char *compile_sub;
if (trusted && !plperl_safe_init_done)
{
@@ -674,8 +676,8 @@ plperl_create_sub(char *s, bool trusted)
/*
* G_KEEPERR seems to be needed here, else we don't recognize compile
- * errors properly. Perhaps it's because there's another level of
- * eval inside mksafefunc?
+ * errors properly. Perhaps it's because there's another level of eval
+ * inside mksafefunc?
*/
if (trusted && plperl_use_strict)
@@ -746,8 +748,8 @@ plperl_create_sub(char *s, bool trusted)
*
**********************************************************************/
-EXTERN_C void boot_DynaLoader(pTHX_ CV *cv);
-EXTERN_C void boot_SPI(pTHX_ CV *cv);
+EXTERN_C void boot_DynaLoader(pTHX_ CV * cv);
+EXTERN_C void boot_SPI(pTHX_ CV * cv);
static void
plperl_init_shared_libs(pTHX)
@@ -760,20 +762,20 @@ plperl_init_shared_libs(pTHX)
static SV *
-plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
+plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo)
{
dSP;
SV *retval;
int i;
int count;
- SV *sv;
+ SV *sv;
ENTER;
SAVETMPS;
PUSHMARK(SP);
- XPUSHs(&PL_sv_undef); /* no trigger data */
+ XPUSHs(&PL_sv_undef); /* no trigger data */
for (i = 0; i < desc->nargs; i++)
{
@@ -808,7 +810,8 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
fcinfo->arg[i]));
sv = newSVpv(tmp, 0);
#if PERL_BCDVERSION >= 0x5006000L
- if (GetDatabaseEncoding() == PG_UTF8) SvUTF8_on(sv);
+ if (GetDatabaseEncoding() == PG_UTF8)
+ SvUTF8_on(sv);
#endif
XPUSHs(sv_2mortal(sv));
pfree(tmp);
@@ -852,8 +855,8 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
static SV *
-plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo,
- SV *td)
+plperl_call_perl_trigger_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo,
+ SV * td)
{
dSP;
SV *retval;
@@ -915,7 +918,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
SV *perlret;
Datum retval;
ReturnSetInfo *rsi;
- SV* array_ret = NULL;
+ SV *array_ret = NULL;
if (SPI_connect() != SPI_OK_CONNECT)
elog(ERROR, "could not connect to SPI manager");
@@ -927,7 +930,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
plperl_current_tuple_store = 0;
plperl_current_tuple_desc = 0;
- rsi = (ReturnSetInfo *)fcinfo->resultinfo;
+ rsi = (ReturnSetInfo *) fcinfo->resultinfo;
if (prodesc->fn_retisset)
{
@@ -956,17 +959,18 @@ plperl_func_handler(PG_FUNCTION_ARGS)
{
/*
* If the Perl function returned an arrayref, we pretend that it
- * called return_next() for each element of the array, to handle
- * old SRFs that didn't know about return_next(). Any other sort
- * of return value is an error.
+ * called return_next() for each element of the array, to handle old
+ * SRFs that didn't know about return_next(). Any other sort of return
+ * value is an error.
*/
if (SvTYPE(perlret) == SVt_RV &&
SvTYPE(SvRV(perlret)) == SVt_PVAV)
{
- int i = 0;
- SV **svp = 0;
- AV *rav = (AV *)SvRV(perlret);
- while ((svp = av_fetch(rav, i, FALSE)) != NULL)
+ int i = 0;
+ SV **svp = 0;
+ AV *rav = (AV *) SvRV(perlret);
+
+ while ((svp = av_fetch(rav, i, FALSE)) != NULL)
{
plperl_return_next(*svp);
i++;
@@ -981,12 +985,12 @@ plperl_func_handler(PG_FUNCTION_ARGS)
}
rsi->returnMode = SFRM_Materialize;
- if (plperl_current_tuple_store)
+ if (plperl_current_tuple_store)
{
rsi->setResult = plperl_current_tuple_store;
rsi->setDesc = plperl_current_tuple_desc;
}
- retval = (Datum)0;
+ retval = (Datum) 0;
}
else if (SvTYPE(perlret) == SVt_NULL)
{
@@ -994,14 +998,14 @@ plperl_func_handler(PG_FUNCTION_ARGS)
if (rsi && IsA(rsi, ReturnSetInfo))
rsi->isDone = ExprEndResult;
fcinfo->isnull = true;
- retval = (Datum)0;
+ retval = (Datum) 0;
}
else if (prodesc->fn_retistuple)
{
/* Return a perl hash converted to a Datum */
- TupleDesc td;
+ TupleDesc td;
AttInMetadata *attinmeta;
- HeapTuple tup;
+ HeapTuple tup;
if (!SvOK(perlret) || SvTYPE(perlret) != SVt_RV ||
SvTYPE(SvRV(perlret)) != SVt_PVHV)
@@ -1022,21 +1026,21 @@ plperl_func_handler(PG_FUNCTION_ARGS)
}
attinmeta = TupleDescGetAttInMetadata(td);
- tup = plperl_build_tuple_result((HV *)SvRV(perlret), attinmeta);
+ tup = plperl_build_tuple_result((HV *) SvRV(perlret), attinmeta);
retval = HeapTupleGetDatum(tup);
}
else
{
- /* Return a perl string converted to a Datum */
- char *val;
-
- if (prodesc->fn_retisarray && SvROK(perlret) &&
+ /* Return a perl string converted to a Datum */
+ char *val;
+
+ if (prodesc->fn_retisarray && SvROK(perlret) &&
SvTYPE(SvRV(perlret)) == SVt_PVAV)
- {
- array_ret = plperl_convert_to_pg_array(perlret);
- SvREFCNT_dec(perlret);
- perlret = array_ret;
- }
+ {
+ array_ret = plperl_convert_to_pg_array(perlret);
+ SvREFCNT_dec(perlret);
+ perlret = array_ret;
+ }
val = SvPV(perlret, PL_na);
@@ -1047,7 +1051,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
}
if (array_ret == NULL)
- SvREFCNT_dec(perlret);
+ SvREFCNT_dec(perlret);
return retval;
}
@@ -1096,7 +1100,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
retval = (Datum) trigdata->tg_trigtuple;
else
- retval = (Datum) 0; /* can this happen? */
+ retval = (Datum) 0; /* can this happen? */
}
else
{
@@ -1121,7 +1125,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
{
ereport(WARNING,
(errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
- errmsg("ignoring modified tuple in DELETE trigger")));
+ errmsg("ignoring modified tuple in DELETE trigger")));
trv = NULL;
}
}
@@ -1153,7 +1157,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
int proname_len;
plperl_proc_desc *prodesc = NULL;
int i;
- SV **svp;
+ SV **svp;
/* We'll need the pg_proc tuple in any case... */
procTup = SearchSysCache(PROCOID,
@@ -1189,7 +1193,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
* function's pg_proc entry without changing its OID.
************************************************************/
uptodate = (prodesc->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
- prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data));
+ prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data));
if (!uptodate)
{
@@ -1257,7 +1261,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
if (!is_trigger)
{
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->prorettype),
+ ObjectIdGetDatum(procStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
@@ -1289,8 +1293,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("plperl functions cannot return type %s",
- format_type_be(procStruct->prorettype))));
+ errmsg("plperl functions cannot return type %s",
+ format_type_be(procStruct->prorettype))));
}
}
@@ -1299,8 +1303,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
prodesc->fn_retistuple = (typeStruct->typtype == 'c' ||
procStruct->prorettype == RECORDOID);
- prodesc->fn_retisarray =
- (typeStruct->typlen == -1 && typeStruct->typelem) ;
+ prodesc->fn_retisarray =
+ (typeStruct->typlen == -1 && typeStruct->typelem);
perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
prodesc->result_typioparam = getTypeIOParam(typeTup);
@@ -1318,7 +1322,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
for (i = 0; i < prodesc->nargs; i++)
{
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->proargtypes.values[i]),
+ ObjectIdGetDatum(procStruct->proargtypes.values[i]),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
@@ -1336,8 +1340,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("plperl functions cannot take type %s",
- format_type_be(procStruct->proargtypes.values[i]))));
+ errmsg("plperl functions cannot take type %s",
+ format_type_be(procStruct->proargtypes.values[i]))));
}
if (typeStruct->typtype == 'c')
@@ -1370,7 +1374,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
************************************************************/
prodesc->reference = plperl_create_sub(proc_source, prodesc->lanpltrusted);
pfree(proc_source);
- if (!prodesc->reference) /* can this happen? */
+ if (!prodesc->reference) /* can this happen? */
{
free(prodesc->proname);
free(prodesc);
@@ -1407,7 +1411,7 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
Oid typoutput;
bool typisvarlena;
int namelen;
- SV *sv;
+ SV *sv;
if (tupdesc->attrs[i]->attisdropped)
continue;
@@ -1416,7 +1420,8 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
namelen = strlen(attname);
attr = heap_getattr(tuple, i + 1, tupdesc, &isnull);
- if (isnull) {
+ if (isnull)
+ {
/* Store (attname => undef) and move on. */
hv_store(hv, attname, namelen, newSV(0), 0);
continue;
@@ -1449,8 +1454,8 @@ plperl_spi_exec(char *query, int limit)
HV *ret_hv;
/*
- * Execute the query inside a sub-transaction, so we can cope with
- * errors sanely
+ * Execute the query inside a sub-transaction, so we can cope with errors
+ * sanely
*/
MemoryContext oldcontext = CurrentMemoryContext;
ResourceOwner oldowner = CurrentResourceOwner;
@@ -1472,9 +1477,10 @@ plperl_spi_exec(char *query, int limit)
ReleaseCurrentSubTransaction();
MemoryContextSwitchTo(oldcontext);
CurrentResourceOwner = oldowner;
+
/*
- * AtEOSubXact_SPI() should not have popped any SPI context,
- * but just in case it did, make sure we remain connected.
+ * AtEOSubXact_SPI() should not have popped any SPI context, but just
+ * in case it did, make sure we remain connected.
*/
SPI_restore_connection();
}
@@ -1493,9 +1499,9 @@ plperl_spi_exec(char *query, int limit)
CurrentResourceOwner = oldowner;
/*
- * If AtEOSubXact_SPI() popped any SPI context of the subxact,
- * it will have left us in a disconnected state. We need this
- * hack to return to connected state.
+ * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will
+ * have left us in a disconnected state. We need this hack to return
+ * to connected state.
*/
SPI_restore_connection();
@@ -1547,14 +1553,14 @@ plperl_spi_execute_fetch_result(SPITupleTable *tuptable, int processed,
void
-plperl_return_next(SV *sv)
+plperl_return_next(SV * sv)
{
plperl_proc_desc *prodesc = plperl_current_prodesc;
FunctionCallInfo fcinfo = plperl_current_caller_info;
- ReturnSetInfo *rsi = (ReturnSetInfo *)fcinfo->resultinfo;
+ ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo;
MemoryContext cxt;
- HeapTuple tuple;
- TupleDesc tupdesc;
+ HeapTuple tuple;
+ TupleDesc tupdesc;
if (!sv)
return;
@@ -1578,7 +1584,7 @@ plperl_return_next(SV *sv)
cxt = MemoryContextSwitchTo(rsi->econtext->ecxt_per_query_memory);
if (!plperl_current_tuple_store)
- plperl_current_tuple_store =
+ plperl_current_tuple_store =
tuplestore_begin_heap(true, false, work_mem);
if (prodesc->fn_retistuple)
@@ -1589,26 +1595,28 @@ plperl_return_next(SV *sv)
rettype = get_call_result_type(fcinfo, NULL, &tupdesc);
tupdesc = CreateTupleDescCopy(tupdesc);
attinmeta = TupleDescGetAttInMetadata(tupdesc);
- tuple = plperl_build_tuple_result((HV *)SvRV(sv), attinmeta);
+ tuple = plperl_build_tuple_result((HV *) SvRV(sv), attinmeta);
}
else
{
- Datum ret;
- bool isNull;
+ Datum ret;
+ bool isNull;
tupdesc = CreateTupleDescCopy(rsi->expectedDesc);
if (SvOK(sv) && SvTYPE(sv) != SVt_NULL)
{
- char *val = SvPV(sv, PL_na);
+ char *val = SvPV(sv, PL_na);
+
ret = FunctionCall3(&prodesc->result_in_func,
PointerGetDatum(val),
ObjectIdGetDatum(prodesc->result_typioparam),
Int32GetDatum(-1));
isNull = false;
}
- else {
- ret = (Datum)0;
+ else
+ {
+ ret = (Datum) 0;
isNull = true;
}
@@ -1627,7 +1635,7 @@ plperl_return_next(SV *sv)
SV *
plperl_spi_query(char *query)
{
- SV *cursor;
+ SV *cursor;
MemoryContext oldcontext = CurrentMemoryContext;
ResourceOwner oldowner = CurrentResourceOwner;
@@ -1637,8 +1645,8 @@ plperl_spi_query(char *query)
PG_TRY();
{
- void *plan;
- Portal portal = NULL;
+ void *plan;
+ Portal portal = NULL;
plan = SPI_prepare(query, 0, NULL);
if (plan)
@@ -1678,14 +1686,15 @@ plperl_spi_query(char *query)
SV *
plperl_spi_fetchrow(char *cursor)
{
- SV *row = newSV(0);
- Portal p = SPI_cursor_find(cursor);
+ SV *row = newSV(0);
+ Portal p = SPI_cursor_find(cursor);
if (!p)
return row;
SPI_cursor_fetch(p, true, 1);
- if (SPI_processed == 0) {
+ if (SPI_processed == 0)
+ {
SPI_cursor_close(p);
return row;
}
diff --git a/src/pl/plperl/ppport.h b/src/pl/plperl/ppport.h
index 592908f27fe..d9c64deabf4 100644
--- a/src/pl/plperl/ppport.h
+++ b/src/pl/plperl/ppport.h
@@ -344,14 +344,13 @@ typedef NVTYPE NV;
#else
#if defined(USE_THREADS)
static SV *
-newRV_noinc(SV *sv)
+newRV_noinc(SV * sv)
{
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)
@@ -367,7 +366,7 @@ 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)
@@ -404,8 +403,8 @@ SV *sv;
#endif
newSVOP(OP_CONST, 0, newSVpv(name, 0)),
- newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == ""
- * -- GMB */
+ newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" --
+ * GMB */
newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
);
@@ -484,7 +483,6 @@ SV *sv;
#define aMY_CXT my_cxtp
#define aMY_CXT_ aMY_CXT,
#define _aMY_CXT ,aMY_CXT
-
#else /* single interpreter */
#define START_MY_CXT static my_cxt_t my_cxt;
@@ -545,7 +543,7 @@ SV *sv;
((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
? ((lp = SvCUR(sv)), SvPVX(sv)) : my_sv_2pvbyte(aTHX_ sv, &lp))
static char *
-my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
+my_sv_2pvbyte(pTHX_ register SV * sv, STRLEN * lp)
{
sv_utf8_downgrade(sv, 0);
return SvPV(sv, *lp);
@@ -560,7 +558,7 @@ my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
? SvPVX(sv) : sv_2pv_nolen(sv))
static char *
-sv_2pv_nolen(pTHX_ register SV *sv)
+sv_2pv_nolen(pTHX_ register SV * sv)
{
STRLEN n_a;
diff --git a/src/pl/plperl/spi_internal.h b/src/pl/plperl/spi_internal.h
index 5c511fce47b..4d2c407ee16 100644
--- a/src/pl/plperl/spi_internal.h
+++ b/src/pl/plperl/spi_internal.h
@@ -17,6 +17,6 @@ int spi_ERROR(void);
/* this is actually in plperl.c */
HV *plperl_spi_exec(char *, int);
-void plperl_return_next(SV *);
-SV *plperl_spi_query(char *);
-SV *plperl_spi_fetchrow(char *);
+void plperl_return_next(SV *);
+SV *plperl_spi_query(char *);
+SV *plperl_spi_fetchrow(char *);
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 1f1d03b8790..2c84899519b 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.93 2005/09/24 22:54:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.94 2005/10/15 02:49:49 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -95,7 +95,7 @@ typedef struct plpgsql_hashent
{
PLpgSQL_func_hashkey key;
PLpgSQL_function *function;
-} plpgsql_HashEnt;
+} plpgsql_HashEnt;
#define FUNCS_PER_USER 128 /* initial table size */
@@ -107,7 +107,7 @@ typedef struct
{
const char *label;
int sqlerrstate;
-} ExceptionLabelMap;
+} ExceptionLabelMap;
static const ExceptionLabelMap exception_label_map[] = {
#include "plerrcodes.h"
@@ -121,27 +121,27 @@ static const ExceptionLabelMap exception_label_map[] = {
*/
static PLpgSQL_function *do_compile(FunctionCallInfo fcinfo,
HeapTuple procTup,
- PLpgSQL_func_hashkey *hashkey,
+ PLpgSQL_func_hashkey * hashkey,
bool forValidator);
-static int fetchArgInfo(HeapTuple procTup,
- Oid **p_argtypes, char ***p_argnames,
- char **p_argmodes);
+static int fetchArgInfo(HeapTuple procTup,
+ Oid **p_argtypes, char ***p_argnames,
+ char **p_argmodes);
static PLpgSQL_row *build_row_from_class(Oid classOid);
-static PLpgSQL_row *build_row_from_vars(PLpgSQL_variable **vars, int numvars);
+static PLpgSQL_row *build_row_from_vars(PLpgSQL_variable ** vars, int numvars);
static PLpgSQL_type *build_datatype(HeapTuple typeTup, int32 typmod);
static void compute_function_hashkey(FunctionCallInfo fcinfo,
Form_pg_proc procStruct,
- PLpgSQL_func_hashkey *hashkey,
+ PLpgSQL_func_hashkey * hashkey,
bool forValidator);
static void plpgsql_resolve_polymorphic_argtypes(int numargs,
Oid *argtypes, char *argmodes,
Node *call_expr, bool forValidator,
const char *proname);
-static PLpgSQL_function *plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key);
-static void plpgsql_HashTableInsert(PLpgSQL_function *function,
- PLpgSQL_func_hashkey *func_key);
-static void plpgsql_HashTableDelete(PLpgSQL_function *function);
-static void delete_function(PLpgSQL_function *func);
+static PLpgSQL_function *plpgsql_HashTableLookup(PLpgSQL_func_hashkey * func_key);
+static void plpgsql_HashTableInsert(PLpgSQL_function * function,
+ PLpgSQL_func_hashkey * func_key);
+static void plpgsql_HashTableDelete(PLpgSQL_function * function);
+static void delete_function(PLpgSQL_function * func);
/* ----------
* plpgsql_compile Make an execution tree for a PL/pgSQL function.
@@ -174,8 +174,8 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
procStruct = (Form_pg_proc) GETSTRUCT(procTup);
/*
- * See if there's already a cache entry for the current FmgrInfo. If
- * not, try to find one in the hash table.
+ * See if there's already a cache entry for the current FmgrInfo. If not,
+ * try to find one in the hash table.
*/
function = (PLpgSQL_function *) fcinfo->flinfo->fn_extra;
@@ -193,7 +193,7 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
{
/* We have a compiled function, but is it still valid? */
if (!(function->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
- function->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data)))
+ function->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data)))
{
/* Nope, drop the function and associated storage */
delete_function(function);
@@ -202,14 +202,13 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
}
/*
- * If the function wasn't found or was out-of-date, we have to compile
- * it
+ * If the function wasn't found or was out-of-date, we have to compile it
*/
if (!function)
{
/*
- * Calculate hashkey if we didn't already; we'll need it to store
- * the completed function.
+ * Calculate hashkey if we didn't already; we'll need it to store the
+ * completed function.
*/
if (!hashkey_valid)
compute_function_hashkey(fcinfo, procStruct, &hashkey,
@@ -253,7 +252,7 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator)
static PLpgSQL_function *
do_compile(FunctionCallInfo fcinfo,
HeapTuple procTup,
- PLpgSQL_func_hashkey *hashkey,
+ PLpgSQL_func_hashkey * hashkey,
bool forValidator)
{
Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
@@ -281,9 +280,9 @@ do_compile(FunctionCallInfo fcinfo,
MemoryContext func_cxt;
/*
- * Setup the scanner input and error info. We assume that this
- * function cannot be invoked recursively, so there's no need to save
- * and restore the static variables used here.
+ * Setup the scanner input and error info. We assume that this function
+ * cannot be invoked recursively, so there's no need to save and restore
+ * the static variables used here.
*/
prosrcdatum = SysCacheGetAttr(PROCOID, procTup,
Anum_pg_proc_prosrc, &isnull);
@@ -317,17 +316,16 @@ do_compile(FunctionCallInfo fcinfo,
datums_last = 0;
/*
- * Do extra syntax checks when validating the function
- * definition. We skip this when actually compiling functions for
- * execution, for performance reasons.
+ * Do extra syntax checks when validating the function definition. We skip
+ * this when actually compiling functions for execution, for performance
+ * reasons.
*/
plpgsql_check_syntax = forValidator;
/*
- * Create the new function node. We allocate the function and all
- * of its compile-time storage (e.g. parse tree) in its own memory
- * context. This allows us to reclaim the function's storage
- * cleanly.
+ * Create the new function node. We allocate the function and all of its
+ * compile-time storage (e.g. parse tree) in its own memory context. This
+ * allows us to reclaim the function's storage cleanly.
*/
func_cxt = AllocSetContextCreate(TopMemoryContext,
"PL/PgSQL function context",
@@ -344,18 +342,19 @@ do_compile(FunctionCallInfo fcinfo,
function->fn_cmin = HeapTupleHeaderGetCmin(procTup->t_data);
function->fn_functype = functype;
function->fn_cxt = func_cxt;
- function->out_param_varno = -1; /* set up for no OUT param */
+ function->out_param_varno = -1; /* set up for no OUT param */
switch (functype)
{
case T_FUNCTION:
+
/*
- * Fetch info about the procedure's parameters. Allocations
- * aren't needed permanently, so make them in tmp cxt.
+ * Fetch info about the procedure's parameters. Allocations aren't
+ * needed permanently, so make them in tmp cxt.
*
- * We also need to resolve any polymorphic input or output
- * argument types. In validation mode we won't be able to,
- * so we arbitrarily assume we are dealing with integers.
+ * We also need to resolve any polymorphic input or output argument
+ * types. In validation mode we won't be able to, so we
+ * arbitrarily assume we are dealing with integers.
*/
MemoryContextSwitchTo(compile_tmp_cxt);
@@ -396,8 +395,8 @@ do_compile(FunctionCallInfo fcinfo,
argdtype->ttype != PLPGSQL_TTYPE_ROW)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("plpgsql functions cannot take type %s",
- format_type_be(argtypeid))));
+ errmsg("plpgsql functions cannot take type %s",
+ format_type_be(argtypeid))));
/* Build variable and add to datum list */
argvariable = plpgsql_build_variable(buf, 0,
@@ -433,8 +432,8 @@ do_compile(FunctionCallInfo fcinfo,
/*
* If there's just one OUT parameter, out_param_varno points
- * directly to it. If there's more than one, build a row
- * that holds all of them.
+ * directly to it. If there's more than one, build a row that
+ * holds all of them.
*/
if (num_out_args == 1)
function->out_param_varno = out_arg_variables[0]->dno;
@@ -448,14 +447,14 @@ do_compile(FunctionCallInfo fcinfo,
}
/*
- * Check for a polymorphic returntype. If found, use the
- * actual returntype type from the caller's FuncExpr node, if
- * we have one. (In validation mode we arbitrarily assume we
- * are dealing with integers.)
+ * Check for a polymorphic returntype. If found, use the actual
+ * returntype type from the caller's FuncExpr node, if we have
+ * one. (In validation mode we arbitrarily assume we are dealing
+ * with integers.)
*
- * Note: errcode is FEATURE_NOT_SUPPORTED because it should
- * always work; if it doesn't we're in some context that fails
- * to make the info available.
+ * Note: errcode is FEATURE_NOT_SUPPORTED because it should always
+ * work; if it doesn't we're in some context that fails to make
+ * the info available.
*/
rettypeid = procStruct->prorettype;
if (rettypeid == ANYARRAYOID || rettypeid == ANYELEMENTOID)
@@ -473,9 +472,9 @@ do_compile(FunctionCallInfo fcinfo,
if (!OidIsValid(rettypeid))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("could not determine actual return type "
- "for polymorphic function \"%s\"",
- plpgsql_error_funcname)));
+ errmsg("could not determine actual return type "
+ "for polymorphic function \"%s\"",
+ plpgsql_error_funcname)));
}
}
@@ -509,8 +508,8 @@ do_compile(FunctionCallInfo fcinfo,
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("plpgsql functions cannot return type %s",
- format_type_be(rettypeid))));
+ errmsg("plpgsql functions cannot return type %s",
+ format_type_be(rettypeid))));
}
if (typeStruct->typrelid != InvalidOid ||
@@ -533,7 +532,7 @@ do_compile(FunctionCallInfo fcinfo,
num_out_args == 0)
{
(void) plpgsql_build_variable("$0", 0,
- build_datatype(typeTup, -1),
+ build_datatype(typeTup, -1),
true);
}
}
@@ -551,7 +550,7 @@ do_compile(FunctionCallInfo fcinfo,
if (procStruct->pronargs != 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
- errmsg("trigger functions cannot have declared arguments"),
+ errmsg("trigger functions cannot have declared arguments"),
errhint("You probably want to use TG_NARGS and TG_ARGV instead.")));
/* Add the record for referencing NEW */
@@ -578,43 +577,43 @@ do_compile(FunctionCallInfo fcinfo,
/* Add the variable tg_name */
var = plpgsql_build_variable("tg_name", 0,
- plpgsql_build_datatype(NAMEOID, -1),
+ plpgsql_build_datatype(NAMEOID, -1),
true);
function->tg_name_varno = var->dno;
/* Add the variable tg_when */
var = plpgsql_build_variable("tg_when", 0,
- plpgsql_build_datatype(TEXTOID, -1),
+ plpgsql_build_datatype(TEXTOID, -1),
true);
function->tg_when_varno = var->dno;
/* Add the variable tg_level */
var = plpgsql_build_variable("tg_level", 0,
- plpgsql_build_datatype(TEXTOID, -1),
+ plpgsql_build_datatype(TEXTOID, -1),
true);
function->tg_level_varno = var->dno;
/* Add the variable tg_op */
var = plpgsql_build_variable("tg_op", 0,
- plpgsql_build_datatype(TEXTOID, -1),
+ plpgsql_build_datatype(TEXTOID, -1),
true);
function->tg_op_varno = var->dno;
/* Add the variable tg_relid */
var = plpgsql_build_variable("tg_relid", 0,
- plpgsql_build_datatype(OIDOID, -1),
+ plpgsql_build_datatype(OIDOID, -1),
true);
function->tg_relid_varno = var->dno;
/* Add the variable tg_relname */
var = plpgsql_build_variable("tg_relname", 0,
- plpgsql_build_datatype(NAMEOID, -1),
+ plpgsql_build_datatype(NAMEOID, -1),
true);
function->tg_relname_varno = var->dno;
/* Add the variable tg_nargs */
var = plpgsql_build_variable("tg_nargs", 0,
- plpgsql_build_datatype(INT4OID, -1),
+ plpgsql_build_datatype(INT4OID, -1),
true);
function->tg_nargs_varno = var->dno;
@@ -654,11 +653,11 @@ do_compile(FunctionCallInfo fcinfo,
/*
* If it has OUT parameters or returns VOID or returns a set, we allow
- * control to fall off the end without an explicit RETURN statement.
- * The easiest way to implement this is to add a RETURN statement to the
- * end of the statement list during parsing. However, if the outer block
- * has an EXCEPTION clause, we need to make a new outer block, since the
- * added RETURN shouldn't act like it is inside the EXCEPTION clause.
+ * control to fall off the end without an explicit RETURN statement. The
+ * easiest way to implement this is to add a RETURN statement to the end
+ * of the statement list during parsing. However, if the outer block has
+ * an EXCEPTION clause, we need to make a new outer block, since the added
+ * RETURN shouldn't act like it is inside the EXCEPTION clause.
*/
if (num_out_args > 0 || function->fn_rettype == VOIDOID ||
function->fn_retset)
@@ -668,8 +667,8 @@ do_compile(FunctionCallInfo fcinfo,
PLpgSQL_stmt_block *new;
new = palloc0(sizeof(PLpgSQL_stmt_block));
- new->cmd_type = PLPGSQL_STMT_BLOCK;
- new->body = list_make1(function->action);
+ new->cmd_type = PLPGSQL_STMT_BLOCK;
+ new->body = list_make1(function->action);
function->action = new;
}
@@ -734,15 +733,15 @@ plpgsql_compile_error_callback(void *arg)
if (arg)
{
/*
- * Try to convert syntax error position to reference text of
- * original CREATE FUNCTION command.
+ * Try to convert syntax error position to reference text of original
+ * CREATE FUNCTION command.
*/
if (function_parse_error_transpose((const char *) arg))
return;
/*
- * Done if a syntax error position was reported; otherwise we have
- * to fall back to a "near line N" report.
+ * Done if a syntax error position was reported; otherwise we have to
+ * fall back to a "near line N" report.
*/
}
@@ -784,7 +783,7 @@ fetchArgInfo(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames,
* deconstruct_array() since the array data is just going to look like
* a C array of values.
*/
- arr = DatumGetArrayTypeP(proallargtypes); /* ensure not toasted */
+ arr = DatumGetArrayTypeP(proallargtypes); /* ensure not toasted */
numargs = ARR_DIMS(arr)[0];
if (ARR_NDIM(arr) != 1 ||
numargs < 0 ||
@@ -816,7 +815,7 @@ fetchArgInfo(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames,
deconstruct_array(DatumGetArrayTypeP(proargnames),
TEXTOID, -1, false, 'i',
&elems, &nelems);
- if (nelems != numargs) /* should not happen */
+ if (nelems != numargs) /* should not happen */
elog(ERROR, "proargnames must have the same number of elements as the function has arguments");
*p_argnames = (char **) palloc(sizeof(char *) * numargs);
for (i = 0; i < numargs; i++)
@@ -868,7 +867,7 @@ plpgsql_parse_word(char *word)
{
if (strcmp(cp[0], "tg_argv") == 0)
{
- bool save_spacescanned = plpgsql_SpaceScanned;
+ bool save_spacescanned = plpgsql_SpaceScanned;
PLpgSQL_trigarg *trigarg;
trigarg = palloc0(sizeof(PLpgSQL_trigarg));
@@ -918,8 +917,8 @@ plpgsql_parse_word(char *word)
}
/*
- * Nothing found - up to now it's a word without any special meaning
- * for us.
+ * Nothing found - up to now it's a word without any special meaning for
+ * us.
*/
pfree(cp[0]);
return T_WORD;
@@ -988,8 +987,8 @@ plpgsql_parse_dblword(char *word)
case PLPGSQL_NSTYPE_REC:
{
/*
- * First word is a record name, so second word must be a
- * field in this record.
+ * First word is a record name, so second word must be a field
+ * in this record.
*/
PLpgSQL_recfield *new;
@@ -1010,8 +1009,8 @@ plpgsql_parse_dblword(char *word)
case PLPGSQL_NSTYPE_ROW:
{
/*
- * First word is a row name, so second word must be a
- * field in this row.
+ * First word is a row name, so second word must be a field in
+ * this row.
*/
PLpgSQL_row *row;
int i;
@@ -1094,8 +1093,8 @@ plpgsql_parse_tripword(char *word)
case PLPGSQL_NSTYPE_REC:
{
/*
- * This word is a record name, so third word must be a
- * field in this record.
+ * This word is a record name, so third word must be a field
+ * in this record.
*/
PLpgSQL_recfield *new;
@@ -1118,8 +1117,8 @@ plpgsql_parse_tripword(char *word)
case PLPGSQL_NSTYPE_ROW:
{
/*
- * This word is a row name, so third word must be a field
- * in this row.
+ * This word is a row name, so third word must be a field in
+ * this row.
*/
PLpgSQL_row *row;
int i;
@@ -1180,8 +1179,8 @@ plpgsql_parse_wordtype(char *word)
pfree(cp[1]);
/*
- * Do a lookup on the compiler's namestack. But ensure it moves up to
- * the toplevel.
+ * Do a lookup on the compiler's namestack. But ensure it moves up to the
+ * toplevel.
*/
old_nsstate = plpgsql_ns_setlocal(false);
nse = plpgsql_ns_lookup(cp[0], NULL);
@@ -1204,8 +1203,8 @@ plpgsql_parse_wordtype(char *word)
}
/*
- * Word wasn't found on the namestack. Try to find a data type with
- * that name, but ignore pg_type entries that are in fact class types.
+ * Word wasn't found on the namestack. Try to find a data type with that
+ * name, but ignore pg_type entries that are in fact class types.
*/
typeOid = LookupTypeName(makeTypeName(cp[0]));
if (OidIsValid(typeOid))
@@ -1236,8 +1235,8 @@ plpgsql_parse_wordtype(char *word)
}
/*
- * Nothing found - up to now it's a word without any special meaning
- * for us.
+ * Nothing found - up to now it's a word without any special meaning for
+ * us.
*/
pfree(cp[0]);
return T_ERROR;
@@ -1281,8 +1280,8 @@ plpgsql_parse_dblwordtype(char *word)
nse = plpgsql_ns_lookup(cp[0], NULL);
/*
- * If this is a label lookup the second word in that label's
- * namestack level
+ * If this is a label lookup the second word in that label's namestack
+ * level
*/
if (nse != NULL)
{
@@ -1341,8 +1340,8 @@ plpgsql_parse_dblwordtype(char *word)
elog(ERROR, "cache lookup failed for type %u", attrStruct->atttypid);
/*
- * Found that - build a compiler type struct in the caller's cxt
- * and return it
+ * Found that - build a compiler type struct in the caller's cxt and
+ * return it
*/
MemoryContextSwitchTo(oldCxt);
plpgsql_yylval.dtype = build_datatype(typetup, attrStruct->atttypmod);
@@ -1383,7 +1382,7 @@ plpgsql_parse_tripwordtype(char *word)
int i;
RangeVar *relvar;
MemoryContext oldCxt;
- int result = T_ERROR;
+ int result = T_ERROR;
/* Avoid memory leaks in the long-term function context */
oldCxt = MemoryContextSwitchTo(compile_tmp_cxt);
@@ -1410,7 +1409,7 @@ plpgsql_parse_tripwordtype(char *word)
cp[1][qualified_att_len - i - 1] = '\0';
relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp[0],
- "plpgsql_parse_tripwordtype"));
+ "plpgsql_parse_tripwordtype"));
classOid = RangeVarGetRelid(relvar, true);
if (!OidIsValid(classOid))
goto done;
@@ -1447,8 +1446,8 @@ plpgsql_parse_tripwordtype(char *word)
elog(ERROR, "cache lookup failed for type %u", attrStruct->atttypid);
/*
- * Found that - build a compiler type struct in the caller's cxt
- * and return it
+ * Found that - build a compiler type struct in the caller's cxt and
+ * return it
*/
MemoryContextSwitchTo(oldCxt);
plpgsql_yylval.dtype = build_datatype(typetup, attrStruct->atttypmod);
@@ -1555,11 +1554,11 @@ plpgsql_parse_dblwordrowtype(char *word)
*
* The returned struct may be a PLpgSQL_var, PLpgSQL_row, or
* PLpgSQL_rec depending on the given datatype, and is allocated via
- * palloc. The struct is automatically added to the current datum
+ * palloc. The struct is automatically added to the current datum
* array, and optionally to the current namespace.
*/
PLpgSQL_variable *
-plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype,
+plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type * dtype,
bool add2namespace)
{
PLpgSQL_variable *result;
@@ -1613,8 +1612,7 @@ plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype,
case PLPGSQL_TTYPE_REC:
{
/*
- * "record" type -- build a variable-contents record
- * variable
+ * "record" type -- build a variable-contents record variable
*/
PLpgSQL_rec *rec;
@@ -1636,7 +1634,7 @@ plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("variable \"%s\" has pseudo-type %s",
refname, format_type_be(dtype->typoid))));
- result = NULL; /* keep compiler quiet */
+ result = NULL; /* keep compiler quiet */
break;
default:
elog(ERROR, "unrecognized ttype: %d", dtype->ttype);
@@ -1676,8 +1674,8 @@ build_row_from_class(Oid classOid)
errmsg("relation \"%s\" is not a table", relname)));
/*
- * Create a row datum entry and all the required variables that it
- * will point to.
+ * Create a row datum entry and all the required variables that it will
+ * point to.
*/
row = palloc0(sizeof(PLpgSQL_row));
row->dtype = PLPGSQL_DTYPE_ROW;
@@ -1707,16 +1705,16 @@ build_row_from_class(Oid classOid)
/*
* Create the internal variable for the field
*
- * We know if the table definitions contain a default value or if
- * the field is declared in the table as NOT NULL. But it's
- * possible to create a table field as NOT NULL without a
- * default value and that would lead to problems later when
- * initializing the variables due to entering a block at
- * execution time. Thus we ignore this information for now.
+ * We know if the table definitions contain a default value or if the
+ * field is declared in the table as NOT NULL. But it's possible
+ * to create a table field as NOT NULL without a default value and
+ * that would lead to problems later when initializing the
+ * variables due to entering a block at execution time. Thus we
+ * ignore this information for now.
*/
var = plpgsql_build_variable(refname, 0,
- plpgsql_build_datatype(attrStruct->atttypid,
- attrStruct->atttypmod),
+ plpgsql_build_datatype(attrStruct->atttypid,
+ attrStruct->atttypmod),
false);
/* Add the variable to the row */
@@ -1740,7 +1738,7 @@ build_row_from_class(Oid classOid)
* Build a row-variable data structure given the component variables.
*/
static PLpgSQL_row *
-build_row_from_vars(PLpgSQL_variable **vars, int numvars)
+build_row_from_vars(PLpgSQL_variable ** vars, int numvars)
{
PLpgSQL_row *row;
int i;
@@ -1755,8 +1753,8 @@ build_row_from_vars(PLpgSQL_variable **vars, int numvars)
for (i = 0; i < numvars; i++)
{
PLpgSQL_variable *var = vars[i];
- Oid typoid = RECORDOID;
- int32 typmod = -1;
+ Oid typoid = RECORDOID;
+ int32 typmod = -1;
switch (var->dtype)
{
@@ -1783,7 +1781,7 @@ build_row_from_vars(PLpgSQL_variable **vars, int numvars)
row->fieldnames[i] = var->refname;
row->varnos[i] = var->dno;
- TupleDescInitEntry(row->rowtupdesc, i+1,
+ TupleDescInitEntry(row->rowtupdesc, i + 1,
var->refname,
typoid, typmod,
0);
@@ -1899,8 +1897,8 @@ plpgsql_parse_err_condition(char *condname)
PLpgSQL_condition *prev;
/*
- * XXX Eventually we will want to look for user-defined exception
- * names here.
+ * XXX Eventually we will want to look for user-defined exception names
+ * here.
*/
/*
@@ -1944,7 +1942,7 @@ plpgsql_parse_err_condition(char *condname)
* ----------
*/
void
-plpgsql_adddatum(PLpgSQL_datum *new)
+plpgsql_adddatum(PLpgSQL_datum * new)
{
if (plpgsql_nDatums == datums_alloc)
{
@@ -2020,7 +2018,7 @@ plpgsql_add_initdatums(int **varnos)
static void
compute_function_hashkey(FunctionCallInfo fcinfo,
Form_pg_proc procStruct,
- PLpgSQL_func_hashkey *hashkey,
+ PLpgSQL_func_hashkey * hashkey,
bool forValidator)
{
/* Make sure any unused bytes of the struct are zero */
@@ -2030,9 +2028,9 @@ compute_function_hashkey(FunctionCallInfo fcinfo,
hashkey->funcOid = fcinfo->flinfo->fn_oid;
/*
- * if trigger, get relation OID. In validation mode we do not know
- * what relation is intended to be used, so we leave trigrelOid zero;
- * the hash entry built in this case will never really be used.
+ * if trigger, get relation OID. In validation mode we do not know what
+ * relation is intended to be used, so we leave trigrelOid zero; the hash
+ * entry built in this case will never really be used.
*/
if (CALLED_AS_TRIGGER(fcinfo) && !forValidator)
{
@@ -2103,7 +2101,7 @@ plpgsql_resolve_polymorphic_argtypes(int numargs,
}
static void
-delete_function(PLpgSQL_function *func)
+delete_function(PLpgSQL_function * func)
{
/* remove function from hash table */
plpgsql_HashTableDelete(func);
@@ -2112,8 +2110,8 @@ delete_function(PLpgSQL_function *func)
MemoryContextDelete(func->fn_cxt);
/*
- * Caller should be sure not to use passed-in pointer, as it now
- * points to pfree'd storage
+ * Caller should be sure not to use passed-in pointer, as it now points to
+ * pfree'd storage
*/
}
@@ -2137,7 +2135,7 @@ plpgsql_HashTableInit(void)
}
static PLpgSQL_function *
-plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key)
+plpgsql_HashTableLookup(PLpgSQL_func_hashkey * func_key)
{
plpgsql_HashEnt *hentry;
@@ -2152,8 +2150,8 @@ plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key)
}
static void
-plpgsql_HashTableInsert(PLpgSQL_function *function,
- PLpgSQL_func_hashkey *func_key)
+plpgsql_HashTableInsert(PLpgSQL_function * function,
+ PLpgSQL_func_hashkey * func_key)
{
plpgsql_HashEnt *hentry;
bool found;
@@ -2171,12 +2169,12 @@ plpgsql_HashTableInsert(PLpgSQL_function *function,
}
static void
-plpgsql_HashTableDelete(PLpgSQL_function *function)
+plpgsql_HashTableDelete(PLpgSQL_function * function)
{
plpgsql_HashEnt *hentry;
hentry = (plpgsql_HashEnt *) hash_search(plpgsql_HashTable,
- (void *) function->fn_hashkey,
+ (void *) function->fn_hashkey,
HASH_REMOVE,
NULL);
if (hentry == NULL)
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 6238aef0eba..721b1014fdc 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.152 2005/09/13 16:16:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.153 2005/10/15 02:49:49 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -75,97 +75,97 @@ static PLpgSQL_expr *active_simple_exprs = NULL;
* Local function forward declarations
************************************************************/
static void plpgsql_exec_error_callback(void *arg);
-static PLpgSQL_datum *copy_plpgsql_datum(PLpgSQL_datum *datum);
-
-static int exec_stmt_block(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_block *block);
-static int exec_stmts(PLpgSQL_execstate *estate,
- List *stmts);
-static int exec_stmt(PLpgSQL_execstate *estate,
- PLpgSQL_stmt *stmt);
-static int exec_stmt_assign(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_assign *stmt);
-static int exec_stmt_perform(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_perform *stmt);
-static int exec_stmt_getdiag(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_getdiag *stmt);
-static int exec_stmt_if(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_if *stmt);
-static int exec_stmt_loop(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_loop *stmt);
-static int exec_stmt_while(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_while *stmt);
-static int exec_stmt_fori(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_fori *stmt);
-static int exec_stmt_fors(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_fors *stmt);
-static int exec_stmt_select(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_select *stmt);
-static int exec_stmt_open(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_open *stmt);
-static int exec_stmt_fetch(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_fetch *stmt);
-static int exec_stmt_close(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_close *stmt);
-static int exec_stmt_exit(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_exit *stmt);
-static int exec_stmt_return(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_return *stmt);
-static int exec_stmt_return_next(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_return_next *stmt);
-static int exec_stmt_raise(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_raise *stmt);
-static int exec_stmt_execsql(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_execsql *stmt);
-static int exec_stmt_dynexecute(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_dynexecute *stmt);
-static int exec_stmt_dynfors(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_dynfors *stmt);
-
-static void plpgsql_estate_setup(PLpgSQL_execstate *estate,
- PLpgSQL_function *func,
+static PLpgSQL_datum *copy_plpgsql_datum(PLpgSQL_datum * datum);
+
+static int exec_stmt_block(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_block * block);
+static int exec_stmts(PLpgSQL_execstate * estate,
+ List *stmts);
+static int exec_stmt(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt * stmt);
+static int exec_stmt_assign(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_assign * stmt);
+static int exec_stmt_perform(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_perform * stmt);
+static int exec_stmt_getdiag(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_getdiag * stmt);
+static int exec_stmt_if(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_if * stmt);
+static int exec_stmt_loop(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_loop * stmt);
+static int exec_stmt_while(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_while * stmt);
+static int exec_stmt_fori(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_fori * stmt);
+static int exec_stmt_fors(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_fors * stmt);
+static int exec_stmt_select(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_select * stmt);
+static int exec_stmt_open(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_open * stmt);
+static int exec_stmt_fetch(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_fetch * stmt);
+static int exec_stmt_close(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_close * stmt);
+static int exec_stmt_exit(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_exit * stmt);
+static int exec_stmt_return(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_return * stmt);
+static int exec_stmt_return_next(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_return_next * stmt);
+static int exec_stmt_raise(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_raise * stmt);
+static int exec_stmt_execsql(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_execsql * stmt);
+static int exec_stmt_dynexecute(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_dynexecute * stmt);
+static int exec_stmt_dynfors(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_dynfors * stmt);
+
+static void plpgsql_estate_setup(PLpgSQL_execstate * estate,
+ PLpgSQL_function * func,
ReturnSetInfo *rsi);
-static void exec_eval_cleanup(PLpgSQL_execstate *estate);
+static void exec_eval_cleanup(PLpgSQL_execstate * estate);
-static void exec_prepare_plan(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr);
+static void exec_prepare_plan(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr);
static bool exec_simple_check_node(Node *node);
-static void exec_simple_check_plan(PLpgSQL_expr *expr);
-static Datum exec_eval_simple_expr(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr,
+static void exec_simple_check_plan(PLpgSQL_expr * expr);
+static Datum exec_eval_simple_expr(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr,
bool *isNull,
Oid *rettype);
-static void exec_assign_expr(PLpgSQL_execstate *estate,
- PLpgSQL_datum *target,
- PLpgSQL_expr *expr);
-static void exec_assign_value(PLpgSQL_execstate *estate,
- PLpgSQL_datum *target,
+static void exec_assign_expr(PLpgSQL_execstate * estate,
+ PLpgSQL_datum * target,
+ PLpgSQL_expr * expr);
+static void exec_assign_value(PLpgSQL_execstate * estate,
+ PLpgSQL_datum * target,
Datum value, Oid valtype, bool *isNull);
-static void exec_eval_datum(PLpgSQL_execstate *estate,
- PLpgSQL_datum *datum,
+static void exec_eval_datum(PLpgSQL_execstate * estate,
+ PLpgSQL_datum * datum,
Oid expectedtypeid,
Oid *typeid,
Datum *value,
bool *isnull);
-static int exec_eval_integer(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr,
+static int exec_eval_integer(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr,
bool *isNull);
-static bool exec_eval_boolean(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr,
+static bool exec_eval_boolean(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr,
bool *isNull);
-static Datum exec_eval_expr(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr,
+static Datum exec_eval_expr(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr,
bool *isNull,
Oid *rettype);
-static int exec_run_select(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr, long maxtuples, Portal *portalP);
-static void exec_move_row(PLpgSQL_execstate *estate,
- PLpgSQL_rec *rec,
- PLpgSQL_row *row,
+static int exec_run_select(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr, long maxtuples, Portal *portalP);
+static void exec_move_row(PLpgSQL_execstate * estate,
+ PLpgSQL_rec * rec,
+ PLpgSQL_row * row,
HeapTuple tup, TupleDesc tupdesc);
-static HeapTuple make_tuple_from_row(PLpgSQL_execstate *estate,
- PLpgSQL_row *row,
+static HeapTuple make_tuple_from_row(PLpgSQL_execstate * estate,
+ PLpgSQL_row * row,
TupleDesc tupdesc);
static char *convert_value_to_string(Datum value, Oid valtype);
static Datum exec_cast_value(Datum value, Oid valtype,
@@ -177,10 +177,10 @@ static Datum exec_cast_value(Datum value, Oid valtype,
static Datum exec_simple_cast_value(Datum value, Oid valtype,
Oid reqtype, int32 reqtypmod,
bool isnull);
-static void exec_init_tuple_store(PLpgSQL_execstate *estate);
+static void exec_init_tuple_store(PLpgSQL_execstate * estate);
static bool compatible_tupdesc(TupleDesc td1, TupleDesc td2);
-static void exec_set_found(PLpgSQL_execstate *estate, bool state);
-static void free_var(PLpgSQL_var *var);
+static void exec_set_found(PLpgSQL_execstate * estate, bool state);
+static void free_var(PLpgSQL_var * var);
/* ----------
@@ -189,7 +189,7 @@ static void free_var(PLpgSQL_var *var);
* ----------
*/
Datum
-plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
+plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
{
PLpgSQL_execstate estate;
ErrorContextCallback plerrcontext;
@@ -290,8 +290,8 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
estate.err_text = NULL;
/*
- * Provide a more helpful message if a CONTINUE has been used
- * outside a loop.
+ * Provide a more helpful message if a CONTINUE has been used outside
+ * a loop.
*/
if (rc == PLPGSQL_RC_CONTINUE)
ereport(ERROR,
@@ -299,8 +299,8 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
errmsg("CONTINUE cannot be used outside a loop")));
else
ereport(ERROR,
- (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
- errmsg("control reached end of function without RETURN")));
+ (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
+ errmsg("control reached end of function without RETURN")));
}
/*
@@ -399,7 +399,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
* ----------
*/
HeapTuple
-plpgsql_exec_trigger(PLpgSQL_function *func,
+plpgsql_exec_trigger(PLpgSQL_function * func,
TriggerData *trigdata)
{
PLpgSQL_execstate estate;
@@ -493,7 +493,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
var = (PLpgSQL_var *) (estate.datums[func->tg_name_varno]);
var->value = DirectFunctionCall1(namein,
- CStringGetDatum(trigdata->tg_trigger->tgname));
+ CStringGetDatum(trigdata->tg_trigger->tgname));
var->isnull = false;
var->freeval = true;
@@ -524,7 +524,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
var = (PLpgSQL_var *) (estate.datums[func->tg_relname_varno]);
var->value = DirectFunctionCall1(namein,
- CStringGetDatum(RelationGetRelationName(trigdata->tg_relation)));
+ CStringGetDatum(RelationGetRelationName(trigdata->tg_relation)));
var->isnull = false;
var->freeval = true;
@@ -534,8 +534,8 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
var->freeval = false;
/*
- * Store the trigger argument values into the special execution
- * state variables
+ * Store the trigger argument values into the special execution state
+ * variables
*/
estate.err_text = gettext_noop("while storing call arguments into local variables");
estate.trig_nargs = trigdata->tg_trigger->tgnargs;
@@ -546,7 +546,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]));
}
/*
@@ -566,8 +566,8 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
estate.err_text = NULL;
/*
- * Provide a more helpful message if a CONTINUE has been used
- * outside a loop.
+ * Provide a more helpful message if a CONTINUE has been used outside
+ * a loop.
*/
if (rc == PLPGSQL_RC_CONTINUE)
ereport(ERROR,
@@ -575,8 +575,8 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
errmsg("CONTINUE cannot be used outside a loop")));
else
ereport(ERROR,
- (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
- errmsg("control reached end of trigger procedure without RETURN")));
+ (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
+ errmsg("control reached end of trigger procedure without RETURN")));
}
if (estate.retisset)
@@ -585,14 +585,14 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
errmsg("trigger procedure cannot return a set")));
/*
- * Check that the returned tuple structure has the same attributes,
- * the relation that fired the trigger has. A per-statement trigger
- * always needs to return NULL, so we ignore any return value the
- * function itself produces (XXX: is this a good idea?)
+ * Check that the returned tuple structure has the same attributes, the
+ * relation that fired the trigger has. A per-statement trigger always
+ * needs to return NULL, so we ignore any return value the function itself
+ * produces (XXX: is this a good idea?)
*
* XXX This way it is possible, that the trigger returns a tuple where
- * attributes don't have the correct atttypmod's length. It's up to
- * the trigger's programmer to ensure that this doesn't happen. Jan
+ * attributes don't have the correct atttypmod's length. It's up to the
+ * trigger's programmer to ensure that this doesn't happen. Jan
*/
if (estate.retisnull || TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
rettup = NULL;
@@ -652,10 +652,10 @@ plpgsql_exec_error_callback(void *arg)
else if (estate->err_text != NULL)
{
/*
- * We don't expend the cycles to run gettext() on err_text unless
- * we actually need it. Therefore, places that set up err_text
- * should use gettext_noop() to ensure the strings get recorded in
- * the message dictionary.
+ * We don't expend the cycles to run gettext() on err_text unless we
+ * actually need it. Therefore, places that set up err_text should
+ * use gettext_noop() to ensure the strings get recorded in the
+ * message dictionary.
*/
/*
@@ -677,48 +677,49 @@ plpgsql_exec_error_callback(void *arg)
* ----------
*/
static PLpgSQL_datum *
-copy_plpgsql_datum(PLpgSQL_datum *datum)
+copy_plpgsql_datum(PLpgSQL_datum * datum)
{
PLpgSQL_datum *result;
switch (datum->dtype)
{
case PLPGSQL_DTYPE_VAR:
- {
- PLpgSQL_var *new = palloc(sizeof(PLpgSQL_var));
+ {
+ PLpgSQL_var *new = palloc(sizeof(PLpgSQL_var));
- memcpy(new, datum, sizeof(PLpgSQL_var));
- /* Ensure the value is null (possibly not needed?) */
- new->value = 0;
- new->isnull = true;
- new->freeval = false;
+ memcpy(new, datum, sizeof(PLpgSQL_var));
+ /* Ensure the value is null (possibly not needed?) */
+ new->value = 0;
+ new->isnull = true;
+ new->freeval = false;
- result = (PLpgSQL_datum *) new;
- }
- break;
+ result = (PLpgSQL_datum *) new;
+ }
+ break;
case PLPGSQL_DTYPE_REC:
- {
- PLpgSQL_rec *new = palloc(sizeof(PLpgSQL_rec));
+ {
+ PLpgSQL_rec *new = palloc(sizeof(PLpgSQL_rec));
- memcpy(new, datum, sizeof(PLpgSQL_rec));
- /* Ensure the value is null (possibly not needed?) */
- new->tup = NULL;
- new->tupdesc = NULL;
- new->freetup = false;
- new->freetupdesc = false;
+ memcpy(new, datum, sizeof(PLpgSQL_rec));
+ /* Ensure the value is null (possibly not needed?) */
+ new->tup = NULL;
+ new->tupdesc = NULL;
+ new->freetup = false;
+ new->freetupdesc = false;
- result = (PLpgSQL_datum *) new;
- }
- break;
+ result = (PLpgSQL_datum *) new;
+ }
+ break;
case PLPGSQL_DTYPE_ROW:
case PLPGSQL_DTYPE_RECFIELD:
case PLPGSQL_DTYPE_ARRAYELEM:
case PLPGSQL_DTYPE_TRIGARG:
+
/*
- * These datum records are read-only at runtime, so no need
- * to copy them
+ * These datum records are read-only at runtime, so no need to
+ * copy them
*/
result = datum;
break;
@@ -734,7 +735,7 @@ copy_plpgsql_datum(PLpgSQL_datum *datum)
static bool
-exception_matches_conditions(ErrorData *edata, PLpgSQL_condition *cond)
+exception_matches_conditions(ErrorData *edata, PLpgSQL_condition * cond)
{
for (; cond != NULL; cond = cond->next)
{
@@ -766,7 +767,7 @@ exception_matches_conditions(ErrorData *edata, PLpgSQL_condition *cond)
* ----------
*/
static int
-exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
+exec_stmt_block(PLpgSQL_execstate * estate, PLpgSQL_stmt_block * block)
{
volatile int rc = -1;
int i;
@@ -794,9 +795,9 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
var->isnull = true;
if (var->notnull)
ereport(ERROR,
- (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
- errmsg("variable \"%s\" declared NOT NULL cannot default to NULL",
- var->refname)));
+ (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
+ errmsg("variable \"%s\" declared NOT NULL cannot default to NULL",
+ var->refname)));
}
else
{
@@ -836,8 +837,7 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
if (block->exceptions)
{
/*
- * Execute the statements in the block's body inside a
- * sub-transaction
+ * Execute the statements in the block's body inside a sub-transaction
*/
MemoryContext oldcontext = CurrentMemoryContext;
ResourceOwner oldowner = CurrentResourceOwner;
@@ -856,15 +856,15 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
CurrentResourceOwner = oldowner;
/*
- * AtEOSubXact_SPI() should not have popped any SPI context,
- * but just in case it did, make sure we remain connected.
+ * AtEOSubXact_SPI() should not have popped any SPI context, but
+ * just in case it did, make sure we remain connected.
*/
SPI_restore_connection();
}
PG_CATCH();
{
- ErrorData *edata;
- ListCell *e;
+ ErrorData *edata;
+ ListCell *e;
/* Save error info */
MemoryContextSwitchTo(oldcontext);
@@ -877,24 +877,23 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
CurrentResourceOwner = oldowner;
/*
- * If AtEOSubXact_SPI() popped any SPI context of the subxact,
- * it will have left us in a disconnected state. We need this
- * hack to return to connected state.
+ * If AtEOSubXact_SPI() popped any SPI context of the subxact, it
+ * will have left us in a disconnected state. We need this hack
+ * to return to connected state.
*/
SPI_restore_connection();
/* Look for a matching exception handler */
- foreach (e, block->exceptions->exc_list)
+ foreach(e, block->exceptions->exc_list)
{
PLpgSQL_exception *exception = (PLpgSQL_exception *) lfirst(e);
if (exception_matches_conditions(edata, exception->conditions))
{
/*
- * Initialize the magic SQLSTATE and SQLERRM
- * variables for the exception block. We needn't
- * do this until we have found a matching
- * exception.
+ * Initialize the magic SQLSTATE and SQLERRM variables for
+ * the exception block. We needn't do this until we have
+ * found a matching exception.
*/
PLpgSQL_var *state_var;
PLpgSQL_var *errm_var;
@@ -902,14 +901,14 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
state_var = (PLpgSQL_var *)
estate->datums[block->exceptions->sqlstate_varno];
state_var->value = DirectFunctionCall1(textin,
- CStringGetDatum(unpack_sql_state(edata->sqlerrcode)));
+ CStringGetDatum(unpack_sql_state(edata->sqlerrcode)));
state_var->freeval = true;
state_var->isnull = false;
errm_var = (PLpgSQL_var *)
estate->datums[block->exceptions->sqlerrm_varno];
errm_var->value = DirectFunctionCall1(textin,
- CStringGetDatum(edata->message));
+ CStringGetDatum(edata->message));
errm_var->freeval = true;
errm_var->isnull = false;
@@ -956,7 +955,7 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
return PLPGSQL_RC_EXIT;
estate->exitlabel = NULL;
return PLPGSQL_RC_OK;
-
+
default:
elog(ERROR, "unrecognized rc: %d", rc);
}
@@ -971,14 +970,15 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
* ----------
*/
static int
-exec_stmts(PLpgSQL_execstate *estate, List *stmts)
+exec_stmts(PLpgSQL_execstate * estate, List *stmts)
{
ListCell *s;
- foreach (s, stmts)
+ foreach(s, stmts)
{
PLpgSQL_stmt *stmt = (PLpgSQL_stmt *) lfirst(s);
- int rc = exec_stmt(estate, stmt);
+ int rc = exec_stmt(estate, stmt);
+
if (rc != PLPGSQL_RC_OK)
return rc;
}
@@ -993,7 +993,7 @@ exec_stmts(PLpgSQL_execstate *estate, List *stmts)
* ----------
*/
static int
-exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
+exec_stmt(PLpgSQL_execstate * estate, PLpgSQL_stmt * stmt)
{
PLpgSQL_stmt *save_estmt;
int rc = -1;
@@ -1102,7 +1102,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
* ----------
*/
static int
-exec_stmt_assign(PLpgSQL_execstate *estate, PLpgSQL_stmt_assign *stmt)
+exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt)
{
Assert(stmt->varno >= 0);
@@ -1118,7 +1118,7 @@ exec_stmt_assign(PLpgSQL_execstate *estate, PLpgSQL_stmt_assign *stmt)
* ----------
*/
static int
-exec_stmt_perform(PLpgSQL_execstate *estate, PLpgSQL_stmt_perform *stmt)
+exec_stmt_perform(PLpgSQL_execstate * estate, PLpgSQL_stmt_perform * stmt)
{
PLpgSQL_expr *expr = stmt->expr;
@@ -1135,15 +1135,15 @@ exec_stmt_perform(PLpgSQL_execstate *estate, PLpgSQL_stmt_perform *stmt)
* ----------
*/
static int
-exec_stmt_getdiag(PLpgSQL_execstate *estate, PLpgSQL_stmt_getdiag *stmt)
+exec_stmt_getdiag(PLpgSQL_execstate * estate, PLpgSQL_stmt_getdiag * stmt)
{
- ListCell *lc;
+ ListCell *lc;
- foreach (lc, stmt->diag_items)
+ foreach(lc, stmt->diag_items)
{
- PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
- PLpgSQL_datum *var;
- bool isnull = false;
+ PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
+ PLpgSQL_datum *var;
+ bool isnull = false;
if (diag_item->target <= 0)
continue;
@@ -1185,7 +1185,7 @@ exec_stmt_getdiag(PLpgSQL_execstate *estate, PLpgSQL_stmt_getdiag *stmt)
* ----------
*/
static int
-exec_stmt_if(PLpgSQL_execstate *estate, PLpgSQL_stmt_if *stmt)
+exec_stmt_if(PLpgSQL_execstate * estate, PLpgSQL_stmt_if * stmt)
{
bool value;
bool isnull;
@@ -1214,11 +1214,11 @@ exec_stmt_if(PLpgSQL_execstate *estate, PLpgSQL_stmt_if *stmt)
* ----------
*/
static int
-exec_stmt_loop(PLpgSQL_execstate *estate, PLpgSQL_stmt_loop *stmt)
+exec_stmt_loop(PLpgSQL_execstate * estate, PLpgSQL_stmt_loop * stmt)
{
for (;;)
{
- int rc = exec_stmts(estate, stmt->body);
+ int rc = exec_stmts(estate, stmt->body);
switch (rc)
{
@@ -1234,7 +1234,7 @@ exec_stmt_loop(PLpgSQL_execstate *estate, PLpgSQL_stmt_loop *stmt)
return PLPGSQL_RC_EXIT;
estate->exitlabel = NULL;
return PLPGSQL_RC_OK;
-
+
case PLPGSQL_RC_CONTINUE:
if (estate->exitlabel == NULL)
/* anonymous continue, so re-run the loop */
@@ -1267,7 +1267,7 @@ exec_stmt_loop(PLpgSQL_execstate *estate, PLpgSQL_stmt_loop *stmt)
* ----------
*/
static int
-exec_stmt_while(PLpgSQL_execstate *estate, PLpgSQL_stmt_while *stmt)
+exec_stmt_while(PLpgSQL_execstate * estate, PLpgSQL_stmt_while * stmt)
{
for (;;)
{
@@ -1330,7 +1330,7 @@ exec_stmt_while(PLpgSQL_execstate *estate, PLpgSQL_stmt_while *stmt)
* ----------
*/
static int
-exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
+exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt)
{
PLpgSQL_var *var;
Datum value;
@@ -1413,9 +1413,9 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
}
/*
- * otherwise, this is a labelled exit that does not match
- * the current statement's label, if any: return RC_EXIT
- * so that the EXIT continues to propagate up the stack.
+ * otherwise, this is a labelled exit that does not match the
+ * current statement's label, if any: return RC_EXIT so that the
+ * EXIT continues to propagate up the stack.
*/
break;
@@ -1435,12 +1435,11 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
else
{
/*
- * otherwise, this is a named continue that does not
- * match the current statement's label, if any: return
- * RC_CONTINUE so that the CONTINUE will propagate up
- * the stack.
+ * otherwise, this is a named continue that does not match the
+ * current statement's label, if any: return RC_CONTINUE so
+ * that the CONTINUE will propagate up the stack.
*/
- break;
+ break;
}
}
@@ -1455,9 +1454,9 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
/*
* Set the FOUND variable to indicate the result of executing the loop
- * (namely, whether we looped one or more times). This must be set
- * here so that it does not interfere with the value of the FOUND
- * variable inside the loop processing itself.
+ * (namely, whether we looped one or more times). This must be set here so
+ * that it does not interfere with the value of the FOUND variable inside
+ * the loop processing itself.
*/
exec_set_found(estate, found);
@@ -1473,7 +1472,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
* ----------
*/
static int
-exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt)
+exec_stmt_fors(PLpgSQL_execstate * estate, PLpgSQL_stmt_fors * stmt)
{
PLpgSQL_rec *rec = NULL;
PLpgSQL_row *row = NULL;
@@ -1505,8 +1504,8 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt)
n = SPI_processed;
/*
- * If the query didn't return any rows, set the target to NULL and
- * return with FOUND = false.
+ * If the query didn't return any rows, set the target to NULL and return
+ * with FOUND = false.
*/
if (n == 0)
exec_move_row(estate, rec, row, NULL, tuptab->tupdesc);
@@ -1545,10 +1544,9 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt)
}
/*
- * otherwise, we processed a labelled exit that does
- * not match the current statement's label, if any:
- * return RC_EXIT so that the EXIT continues to
- * recurse upward.
+ * otherwise, we processed a labelled exit that does not
+ * match the current statement's label, if any: return
+ * RC_EXIT so that the EXIT continues to recurse upward.
*/
}
else if (rc == PLPGSQL_RC_CONTINUE)
@@ -1569,16 +1567,16 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt)
}
/*
- * otherwise, we processed a named continue
- * that does not match the current statement's
- * label, if any: return RC_CONTINUE so that the
- * CONTINUE will propagate up the stack.
+ * otherwise, we processed a named continue that does not
+ * match the current statement's label, if any: return
+ * RC_CONTINUE so that the CONTINUE will propagate up the
+ * stack.
*/
}
/*
- * We're aborting the loop, so cleanup and set FOUND.
- * (This code should match the code after the loop.)
+ * We're aborting the loop, so cleanup and set FOUND. (This
+ * code should match the code after the loop.)
*/
SPI_freetuptable(tuptab);
SPI_cursor_close(portal);
@@ -1610,9 +1608,9 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt)
/*
* Set the FOUND variable to indicate the result of executing the loop
- * (namely, whether we looped one or more times). This must be set
- * here so that it does not interfere with the value of the FOUND
- * variable inside the loop processing itself.
+ * (namely, whether we looped one or more times). This must be set here so
+ * that it does not interfere with the value of the FOUND variable inside
+ * the loop processing itself.
*/
exec_set_found(estate, found);
@@ -1626,7 +1624,7 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt)
* ----------
*/
static int
-exec_stmt_select(PLpgSQL_execstate *estate, PLpgSQL_stmt_select *stmt)
+exec_stmt_select(PLpgSQL_execstate * estate, PLpgSQL_stmt_select * stmt)
{
PLpgSQL_rec *rec = NULL;
PLpgSQL_row *row = NULL;
@@ -1656,8 +1654,7 @@ exec_stmt_select(PLpgSQL_execstate *estate, PLpgSQL_stmt_select *stmt)
n = estate->eval_processed;
/*
- * If the query didn't return any rows, set the target to NULL and
- * return.
+ * If the query didn't return any rows, set the target to NULL and return.
*/
if (n == 0)
{
@@ -1685,7 +1682,7 @@ exec_stmt_select(PLpgSQL_execstate *estate, PLpgSQL_stmt_select *stmt)
* ----------
*/
static int
-exec_stmt_exit(PLpgSQL_execstate *estate, PLpgSQL_stmt_exit *stmt)
+exec_stmt_exit(PLpgSQL_execstate * estate, PLpgSQL_stmt_exit * stmt)
{
/*
* If the exit / continue has a condition, evaluate it
@@ -1715,12 +1712,12 @@ exec_stmt_exit(PLpgSQL_execstate *estate, PLpgSQL_stmt_exit *stmt)
* ----------
*/
static int
-exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt)
+exec_stmt_return(PLpgSQL_execstate * estate, PLpgSQL_stmt_return * stmt)
{
/*
* If processing a set-returning PL/PgSQL function, the final RETURN
- * indicates that the function is finished producing tuples. The rest
- * of the work will be done at the top level.
+ * indicates that the function is finished producing tuples. The rest of
+ * the work will be done at the top level.
*/
if (estate->retisset)
return PLPGSQL_RC_RETURN;
@@ -1737,41 +1734,41 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt)
switch (retvar->dtype)
{
case PLPGSQL_DTYPE_VAR:
- {
- PLpgSQL_var *var = (PLpgSQL_var *) retvar;
+ {
+ PLpgSQL_var *var = (PLpgSQL_var *) retvar;
- estate->retval = var->value;
- estate->retisnull = var->isnull;
- estate->rettype = var->datatype->typoid;
- }
- break;
+ estate->retval = var->value;
+ estate->retisnull = var->isnull;
+ estate->rettype = var->datatype->typoid;
+ }
+ break;
case PLPGSQL_DTYPE_REC:
- {
- PLpgSQL_rec *rec = (PLpgSQL_rec *) retvar;
-
- if (HeapTupleIsValid(rec->tup))
{
- estate->retval = (Datum) rec->tup;
- estate->rettupdesc = rec->tupdesc;
- estate->retisnull = false;
+ PLpgSQL_rec *rec = (PLpgSQL_rec *) retvar;
+
+ if (HeapTupleIsValid(rec->tup))
+ {
+ estate->retval = (Datum) rec->tup;
+ estate->rettupdesc = rec->tupdesc;
+ estate->retisnull = false;
+ }
}
- }
- break;
+ break;
case PLPGSQL_DTYPE_ROW:
- {
- PLpgSQL_row *row = (PLpgSQL_row *) retvar;
-
- Assert(row->rowtupdesc);
- estate->retval = (Datum) make_tuple_from_row(estate, row,
- row->rowtupdesc);
- if (estate->retval == (Datum) NULL) /* should not happen */
- elog(ERROR, "row not compatible with its own tupdesc");
- estate->rettupdesc = row->rowtupdesc;
- estate->retisnull = false;
- }
- break;
+ {
+ PLpgSQL_row *row = (PLpgSQL_row *) retvar;
+
+ Assert(row->rowtupdesc);
+ estate->retval = (Datum) make_tuple_from_row(estate, row,
+ row->rowtupdesc);
+ if (estate->retval == (Datum) NULL) /* should not happen */
+ elog(ERROR, "row not compatible with its own tupdesc");
+ estate->rettupdesc = row->rowtupdesc;
+ estate->retisnull = false;
+ }
+ break;
default:
elog(ERROR, "unrecognized dtype: %d", retvar->dtype);
@@ -1806,8 +1803,8 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt)
/*
* Special hack for function returning VOID: instead of NULL, return a
* non-null VOID value. This is of dubious importance but is kept for
- * backwards compatibility. Note that the only other way to get here
- * is to have written "RETURN NULL" in a function returning tuple.
+ * backwards compatibility. Note that the only other way to get here is
+ * to have written "RETURN NULL" in a function returning tuple.
*/
if (estate->fn_rettype == VOIDOID)
{
@@ -1826,8 +1823,8 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt)
* ----------
*/
static int
-exec_stmt_return_next(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_return_next *stmt)
+exec_stmt_return_next(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_return_next * stmt)
{
TupleDesc tupdesc;
int natts;
@@ -1837,7 +1834,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate,
if (!estate->retisset)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("cannot use RETURN NEXT in a non-SETOF function")));
+ errmsg("cannot use RETURN NEXT in a non-SETOF function")));
if (estate->tuple_store == NULL)
exec_init_tuple_store(estate);
@@ -1853,59 +1850,59 @@ exec_stmt_return_next(PLpgSQL_execstate *estate,
switch (retvar->dtype)
{
case PLPGSQL_DTYPE_VAR:
- {
- PLpgSQL_var *var = (PLpgSQL_var *) retvar;
- Datum retval = var->value;
- bool isNull = var->isnull;
+ {
+ PLpgSQL_var *var = (PLpgSQL_var *) retvar;
+ Datum retval = var->value;
+ bool isNull = var->isnull;
- if (natts != 1)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("wrong result type supplied in RETURN NEXT")));
+ if (natts != 1)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("wrong result type supplied in RETURN NEXT")));
- /* coerce type if needed */
- retval = exec_simple_cast_value(retval,
- var->datatype->typoid,
- tupdesc->attrs[0]->atttypid,
+ /* coerce type if needed */
+ retval = exec_simple_cast_value(retval,
+ var->datatype->typoid,
+ tupdesc->attrs[0]->atttypid,
tupdesc->attrs[0]->atttypmod,
- isNull);
+ isNull);
- tuple = heap_form_tuple(tupdesc, &retval, &isNull);
+ tuple = heap_form_tuple(tupdesc, &retval, &isNull);
- free_tuple = true;
- }
- break;
+ free_tuple = true;
+ }
+ break;
case PLPGSQL_DTYPE_REC:
- {
- PLpgSQL_rec *rec = (PLpgSQL_rec *) retvar;
+ {
+ PLpgSQL_rec *rec = (PLpgSQL_rec *) retvar;
- if (!HeapTupleIsValid(rec->tup))
- ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("record \"%s\" is not assigned yet",
- rec->refname),
- errdetail("The tuple structure of a not-yet-assigned record is indeterminate.")));
- if (!compatible_tupdesc(tupdesc, rec->tupdesc))
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("wrong record type supplied in RETURN NEXT")));
- tuple = rec->tup;
- }
- break;
+ if (!HeapTupleIsValid(rec->tup))
+ ereport(ERROR,
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("record \"%s\" is not assigned yet",
+ rec->refname),
+ errdetail("The tuple structure of a not-yet-assigned record is indeterminate.")));
+ if (!compatible_tupdesc(tupdesc, rec->tupdesc))
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("wrong record type supplied in RETURN NEXT")));
+ tuple = rec->tup;
+ }
+ break;
case PLPGSQL_DTYPE_ROW:
- {
- PLpgSQL_row *row = (PLpgSQL_row *) retvar;
+ {
+ PLpgSQL_row *row = (PLpgSQL_row *) retvar;
- tuple = make_tuple_from_row(estate, row, tupdesc);
- if (tuple == NULL)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("wrong record type supplied in RETURN NEXT")));
- free_tuple = true;
- }
- break;
+ tuple = make_tuple_from_row(estate, row, tupdesc);
+ if (tuple == NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("wrong record type supplied in RETURN NEXT")));
+ free_tuple = true;
+ }
+ break;
default:
elog(ERROR, "unrecognized dtype: %d", retvar->dtype);
@@ -1922,7 +1919,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate,
if (natts != 1)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("wrong result type supplied in RETURN NEXT")));
+ errmsg("wrong result type supplied in RETURN NEXT")));
retval = exec_eval_expr(estate,
stmt->expr,
@@ -1966,7 +1963,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate,
}
static void
-exec_init_tuple_store(PLpgSQL_execstate *estate)
+exec_init_tuple_store(PLpgSQL_execstate * estate)
{
ReturnSetInfo *rsi = estate->rsi;
MemoryContext oldcxt;
@@ -1995,7 +1992,7 @@ exec_init_tuple_store(PLpgSQL_execstate *estate)
* ----------
*/
static int
-exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt)
+exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt)
{
char *cp;
PLpgSQL_dstring ds;
@@ -2030,7 +2027,7 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt)
errmsg("too few parameters specified for RAISE")));
paramvalue = exec_eval_expr(estate,
- (PLpgSQL_expr *) lfirst(current_param),
+ (PLpgSQL_expr *) lfirst(current_param),
&paramisnull,
&paramtypeid);
@@ -2048,8 +2045,8 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt)
}
/*
- * If more parameters were specified than were required to process
- * the format string, throw an error
+ * If more parameters were specified than were required to process the
+ * format string, throw an error
*/
if (current_param != NULL)
ereport(ERROR,
@@ -2062,8 +2059,8 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt)
estate->err_text = raise_skip_msg; /* suppress traceback of raise */
ereport(stmt->elog_level,
- ((stmt->elog_level >= ERROR) ? errcode(ERRCODE_RAISE_EXCEPTION) : 0,
- errmsg_internal("%s", plpgsql_dstring_get(&ds))));
+ ((stmt->elog_level >= ERROR) ? errcode(ERRCODE_RAISE_EXCEPTION) : 0,
+ errmsg_internal("%s", plpgsql_dstring_get(&ds))));
estate->err_text = NULL; /* un-suppress... */
@@ -2078,8 +2075,8 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt)
* ----------
*/
static void
-plpgsql_estate_setup(PLpgSQL_execstate *estate,
- PLpgSQL_function *func,
+plpgsql_estate_setup(PLpgSQL_execstate * estate,
+ PLpgSQL_function * func,
ReturnSetInfo *rsi)
{
estate->retval = (Datum) 0;
@@ -2116,9 +2113,9 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
estate->err_text = NULL;
/*
- * Create an EState for evaluation of simple expressions, if there's
- * not one already in the current transaction. The EState is made a
- * child of TopTransactionContext so it will have the right lifespan.
+ * Create an EState for evaluation of simple expressions, if there's not
+ * one already in the current transaction. The EState is made a child of
+ * TopTransactionContext so it will have the right lifespan.
*/
if (simple_eval_estate == NULL)
{
@@ -2130,8 +2127,8 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
}
/*
- * Create an expression context for simple expressions.
- * This must be a child of simple_eval_estate.
+ * Create an expression context for simple expressions. This must be a
+ * child of simple_eval_estate.
*/
estate->eval_econtext = CreateExprContext(simple_eval_estate);
}
@@ -2144,7 +2141,7 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
* ----------
*/
static void
-exec_eval_cleanup(PLpgSQL_execstate *estate)
+exec_eval_cleanup(PLpgSQL_execstate * estate)
{
/* Clear result of a full SPI_execute */
if (estate->eval_tuptable != NULL)
@@ -2162,8 +2159,8 @@ exec_eval_cleanup(PLpgSQL_execstate *estate)
* ----------
*/
static void
-exec_prepare_plan(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr)
+exec_prepare_plan(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr)
{
int i;
_SPI_plan *spi_plan;
@@ -2198,16 +2195,16 @@ exec_prepare_plan(PLpgSQL_execstate *estate,
case SPI_ERROR_COPY:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot COPY to/from client in PL/pgSQL")));
+ errmsg("cannot COPY to/from client in PL/pgSQL")));
case SPI_ERROR_CURSOR:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot manipulate cursors directly in PL/pgSQL"),
- errhint("Use PL/pgSQL's cursor features instead.")));
+ errmsg("cannot manipulate cursors directly in PL/pgSQL"),
+ errhint("Use PL/pgSQL's cursor features instead.")));
case SPI_ERROR_TRANSACTION:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot begin/end transactions in PL/pgSQL"),
+ errmsg("cannot begin/end transactions in PL/pgSQL"),
errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
default:
elog(ERROR, "SPI_prepare failed for \"%s\": %s",
@@ -2231,8 +2228,8 @@ exec_prepare_plan(PLpgSQL_execstate *estate,
* ----------
*/
static int
-exec_stmt_execsql(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_execsql *stmt)
+exec_stmt_execsql(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_execsql * stmt)
{
int i;
Datum *values;
@@ -2282,9 +2279,9 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
case SPI_OK_UPDATE:
/*
- * If the INSERT, DELETE, or UPDATE query affected at least
- * one tuple, set the magic 'FOUND' variable to true. This
- * conforms with the behavior of PL/SQL.
+ * If the INSERT, DELETE, or UPDATE query affected at least one
+ * tuple, set the magic 'FOUND' variable to true. This conforms
+ * with the behavior of PL/SQL.
*/
exec_set_found(estate, (SPI_processed != 0));
break;
@@ -2292,7 +2289,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
case SPI_OK_SELECT:
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("SELECT query has no destination for result data"),
+ errmsg("SELECT query has no destination for result data"),
errhint("If you want to discard the results, use PERFORM instead.")));
default:
@@ -2323,8 +2320,8 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
* ----------
*/
static int
-exec_stmt_dynexecute(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_dynexecute *stmt)
+exec_stmt_dynexecute(PLpgSQL_execstate * estate,
+ PLpgSQL_stmt_dynexecute * stmt)
{
Datum query;
bool isnull = false;
@@ -2340,8 +2337,8 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
row = (PLpgSQL_row *) (estate->datums[stmt->row->rowno]);
/*
- * First we evaluate the string expression after the EXECUTE keyword.
- * It's result is the querystring we have to execute.
+ * First we evaluate the string expression after the EXECUTE keyword. It's
+ * result is the querystring we have to execute.
*/
query = exec_eval_expr(estate, stmt->query, &isnull, &restype);
if (isnull)
@@ -2356,8 +2353,8 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
/*
* Call SPI_execute() without preparing a saved plan. The returncode can
- * be any standard OK. Note that while a SELECT is allowed, its
- * results will be discarded unless an INTO clause is specified.
+ * be any standard OK. Note that while a SELECT is allowed, its results
+ * will be discarded unless an INTO clause is specified.
*/
exec_res = SPI_execute(querystr, estate->readonly_func, 0);
@@ -2398,14 +2395,13 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
case SPI_OK_SELINTO:
/*
- * We want to disallow SELECT INTO 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_execute.) However, CREATE AS should be allowed ... and
- * since it produces the same parsetree as SELECT INTO,
- * there's no way to tell the difference except to look at the
- * source text. Wotta kluge!
+ * We want to disallow SELECT INTO 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_execute.) However,
+ * CREATE AS should be allowed ... and since it produces the same
+ * parsetree as SELECT INTO, there's no way to tell the difference
+ * except to look at the source text. Wotta kluge!
*/
{
char *ptr;
@@ -2428,13 +2424,13 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
case SPI_ERROR_CURSOR:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot manipulate cursors directly in PL/pgSQL"),
+ errmsg("cannot manipulate cursors directly in PL/pgSQL"),
errhint("Use PL/pgSQL's cursor features instead.")));
case SPI_ERROR_TRANSACTION:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot begin/end transactions in PL/pgSQL"),
- errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
+ errhint("Use a BEGIN block with an EXCEPTION clause instead.")));
default:
elog(ERROR, "SPI_execute failed executing query \"%s\": %s",
@@ -2462,7 +2458,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
* ----------
*/
static int
-exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt)
+exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt)
{
Datum query;
bool isnull;
@@ -2487,8 +2483,8 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt)
elog(ERROR, "unsupported target");
/*
- * Evaluate the string expression after the EXECUTE keyword. It's
- * result is the querystring we have to execute.
+ * Evaluate the string expression after the EXECUTE keyword. It's result
+ * is the querystring we have to execute.
*/
query = exec_eval_expr(estate, stmt->query, &isnull, &restype);
if (isnull)
@@ -2524,8 +2520,8 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt)
n = SPI_processed;
/*
- * If the query didn't return any rows, set the target to NULL and
- * return with FOUND = false.
+ * If the query didn't return any rows, set the target to NULL and return
+ * with FOUND = false.
*/
if (n == 0)
exec_move_row(estate, rec, row, NULL, tuptab->tupdesc);
@@ -2541,7 +2537,7 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt)
for (i = 0; i < n; i++)
{
- int rc;
+ int rc;
/*
* Assign the tuple to the target
@@ -2569,10 +2565,9 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt)
}
/*
- * otherwise, we processed a labelled exit that does
- * not match the current statement's label, if any:
- * return RC_EXIT so that the EXIT continues to
- * recurse upward.
+ * otherwise, we processed a labelled exit that does not
+ * match the current statement's label, if any: return
+ * RC_EXIT so that the EXIT continues to recurse upward.
*/
}
else if (rc == PLPGSQL_RC_CONTINUE)
@@ -2589,15 +2584,15 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt)
}
/*
- * otherwise, we process a labelled continue that
- * does not match the current statement's label,
- * so propagate RC_CONTINUE upward in the stack.
+ * otherwise, we process a labelled continue that does not
+ * match the current statement's label, so propagate
+ * RC_CONTINUE upward in the stack.
*/
}
/*
- * We're aborting the loop, so cleanup and set FOUND.
- * (This code should match the code after the loop.)
+ * We're aborting the loop, so cleanup and set FOUND. (This
+ * code should match the code after the loop.)
*/
SPI_freetuptable(tuptab);
SPI_cursor_close(portal);
@@ -2629,9 +2624,9 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt)
/*
* Set the FOUND variable to indicate the result of executing the loop
- * (namely, whether we looped one or more times). This must be set
- * here so that it does not interfere with the value of the FOUND
- * variable inside the loop processing itself.
+ * (namely, whether we looped one or more times). This must be set here so
+ * that it does not interfere with the value of the FOUND variable inside
+ * the loop processing itself.
*/
exec_set_found(estate, found);
@@ -2644,7 +2639,7 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt)
* ----------
*/
static int
-exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt)
+exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt)
{
PLpgSQL_var *curvar = NULL;
char *curname = NULL;
@@ -2765,7 +2760,7 @@ exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt)
if (curvar->cursor_explicit_argrow < 0)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("arguments given for cursor without arguments")));
+ errmsg("arguments given for cursor without arguments")));
memset(&set_args, 0, sizeof(set_args));
set_args.cmd_type = PLPGSQL_STMT_SELECT;
@@ -2846,7 +2841,7 @@ exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt)
* ----------
*/
static int
-exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt)
+exec_stmt_fetch(PLpgSQL_execstate * estate, PLpgSQL_stmt_fetch * stmt)
{
PLpgSQL_var *curvar = NULL;
PLpgSQL_rec *rec = NULL;
@@ -2864,7 +2859,7 @@ exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt)
if (curvar->isnull)
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
- errmsg("cursor variable \"%s\" is NULL", curvar->refname)));
+ errmsg("cursor variable \"%s\" is NULL", curvar->refname)));
curname = DatumGetCString(DirectFunctionCall1(textout, curvar->value));
portal = SPI_cursor_find(curname);
@@ -2919,7 +2914,7 @@ exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt)
* ----------
*/
static int
-exec_stmt_close(PLpgSQL_execstate *estate, PLpgSQL_stmt_close *stmt)
+exec_stmt_close(PLpgSQL_execstate * estate, PLpgSQL_stmt_close * stmt)
{
PLpgSQL_var *curvar = NULL;
Portal portal;
@@ -2933,7 +2928,7 @@ exec_stmt_close(PLpgSQL_execstate *estate, PLpgSQL_stmt_close *stmt)
if (curvar->isnull)
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
- errmsg("cursor variable \"%s\" is NULL", curvar->refname)));
+ errmsg("cursor variable \"%s\" is NULL", curvar->refname)));
curname = DatumGetCString(DirectFunctionCall1(textout, curvar->value));
portal = SPI_cursor_find(curname);
@@ -2959,8 +2954,8 @@ exec_stmt_close(PLpgSQL_execstate *estate, PLpgSQL_stmt_close *stmt)
* ----------
*/
static void
-exec_assign_expr(PLpgSQL_execstate *estate, PLpgSQL_datum *target,
- PLpgSQL_expr *expr)
+exec_assign_expr(PLpgSQL_execstate * estate, PLpgSQL_datum * target,
+ PLpgSQL_expr * expr)
{
Datum value;
Oid valtype;
@@ -2977,8 +2972,8 @@ exec_assign_expr(PLpgSQL_execstate *estate, PLpgSQL_datum *target,
* ----------
*/
static void
-exec_assign_value(PLpgSQL_execstate *estate,
- PLpgSQL_datum *target,
+exec_assign_value(PLpgSQL_execstate * estate,
+ PLpgSQL_datum * target,
Datum value, Oid valtype, bool *isNull)
{
switch (target->dtype)
@@ -3005,10 +3000,10 @@ exec_assign_value(PLpgSQL_execstate *estate,
/*
* If type is by-reference, make sure we have a freshly
- * palloc'd copy; the originally passed value may not live
- * as long as the variable! But we don't need to re-copy
- * if exec_cast_value performed a conversion; its output
- * must already be palloc'd.
+ * palloc'd copy; the originally passed value may not live as
+ * long as the variable! But we don't need to re-copy if
+ * exec_cast_value performed a conversion; its output must
+ * already be palloc'd.
*/
if (!var->datatype->typbyval && !*isNull)
{
@@ -3019,10 +3014,10 @@ exec_assign_value(PLpgSQL_execstate *estate,
}
/*
- * Now free the old value. (We can't do this any earlier
- * because of the possibility that we are assigning the
- * var's old value to it, eg "foo := foo". We could optimize
- * out the assignment altogether in such cases, but it's too
+ * Now free the old value. (We can't do this any earlier
+ * because of the possibility that we are assigning the var's
+ * old value to it, eg "foo := foo". We could optimize out
+ * the assignment altogether in such cases, but it's too
* infrequent to be worth testing for.)
*/
free_var(var);
@@ -3139,16 +3134,16 @@ exec_assign_value(PLpgSQL_execstate *estate,
rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
/*
- * Check that there is already a tuple in the record. We
- * need that because records don't have any predefined
- * field structure.
+ * Check that there is already a tuple in the record. We need
+ * that because records don't have any predefined field
+ * structure.
*/
if (!HeapTupleIsValid(rec->tup))
ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("record \"%s\" is not assigned yet",
- rec->refname),
- errdetail("The tuple structure of a not-yet-assigned record is indeterminate.")));
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("record \"%s\" is not assigned yet",
+ rec->refname),
+ errdetail("The tuple structure of a not-yet-assigned record is indeterminate.")));
/*
* Get the number of the records field to change and the
@@ -3164,9 +3159,9 @@ exec_assign_value(PLpgSQL_execstate *estate,
natts = rec->tupdesc->natts;
/*
- * Set up values/datums arrays for heap_formtuple. For
- * all the attributes except the one we want to replace,
- * use the value that's in the old tuple.
+ * Set up values/datums arrays for heap_formtuple. For all
+ * the attributes except the one we want to replace, use the
+ * value that's in the old tuple.
*/
values = palloc(sizeof(Datum) * natts);
nulls = palloc(natts);
@@ -3184,8 +3179,8 @@ exec_assign_value(PLpgSQL_execstate *estate,
}
/*
- * Now insert the new value, being careful to cast it to
- * the right type.
+ * Now insert the new value, being careful to cast it to the
+ * right type.
*/
atttype = SPI_gettypeid(rec->tupdesc, fno + 1);
atttypmod = rec->tupdesc->attrs[fno]->atttypmod;
@@ -3201,8 +3196,8 @@ exec_assign_value(PLpgSQL_execstate *estate,
nulls[fno] = ' ';
/*
- * Avoid leaking the result of exec_simple_cast_value, if
- * it performed a conversion to a pass-by-ref type.
+ * Avoid leaking the result of exec_simple_cast_value, if it
+ * performed a conversion to a pass-by-ref type.
*/
if (!attisnull && values[fno] != value && !get_typbyval(atttype))
mustfree = DatumGetPointer(values[fno]);
@@ -3251,12 +3246,12 @@ exec_assign_value(PLpgSQL_execstate *estate,
/*
* Target is an element of an array
*
- * To handle constructs like x[1][2] := something, we have to
- * be prepared to deal with a chain of arrayelem datums.
- * Chase back to find the base array datum, and save the
- * subscript expressions as we go. (We are scanning right
- * to left here, but want to evaluate the subscripts
- * left-to-right to minimize surprises.)
+ * To handle constructs like x[1][2] := something, we have to be
+ * prepared to deal with a chain of arrayelem datums. Chase
+ * back to find the base array datum, and save the subscript
+ * expressions as we go. (We are scanning right to left here,
+ * but want to evaluate the subscripts left-to-right to
+ * minimize surprises.)
*/
nsubscripts = 0;
do
@@ -3274,13 +3269,13 @@ exec_assign_value(PLpgSQL_execstate *estate,
/* Fetch current value of array datum */
exec_eval_datum(estate, target, InvalidOid,
- &arraytypeid, &oldarraydatum, &oldarrayisnull);
+ &arraytypeid, &oldarraydatum, &oldarrayisnull);
arrayelemtypeid = get_element_type(arraytypeid);
if (!OidIsValid(arrayelemtypeid))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("subscripted object is not an array")));
+ errmsg("subscripted object is not an array")));
get_typlenbyvalalign(arrayelemtypeid,
&elemtyplen,
@@ -3289,8 +3284,7 @@ exec_assign_value(PLpgSQL_execstate *estate,
arraytyplen = get_typlen(arraytypeid);
/*
- * Evaluate the subscripts, switch into left-to-right
- * order
+ * Evaluate the subscripts, switch into left-to-right order
*/
havenullsubscript = false;
for (i = 0; i < nsubscripts; i++)
@@ -3313,12 +3307,12 @@ exec_assign_value(PLpgSQL_execstate *estate,
return;
/*
- * If the original array is null, cons up an empty array
- * so that the assignment can proceed; we'll end with a
+ * If the original array is null, cons up an empty array so
+ * that the assignment can proceed; we'll end with a
* one-element array containing just the assigned-to
- * subscript. This only works for varlena arrays, though;
- * for fixed-length array types we skip the assignment.
- * Again, this corresponds to the current behavior of
+ * subscript. This only works for varlena arrays, though; for
+ * fixed-length array types we skip the assignment. Again,
+ * this corresponds to the current behavior of
* ExecEvalArrayRef().
*/
if (oldarrayisnull)
@@ -3363,8 +3357,8 @@ exec_assign_value(PLpgSQL_execstate *estate,
arraytypeid, isNull);
/*
- * Avoid leaking the result of exec_simple_cast_value, if
- * it performed a conversion to a pass-by-ref type.
+ * Avoid leaking the result of exec_simple_cast_value, if it
+ * performed a conversion to a pass-by-ref type.
*/
if (!*isNull && coerced_value != value && !elemtypbyval)
pfree(DatumGetPointer(coerced_value));
@@ -3391,13 +3385,13 @@ exec_assign_value(PLpgSQL_execstate *estate,
* At present this doesn't handle PLpgSQL_expr or PLpgSQL_arrayelem datums.
*
* NOTE: caller must not modify the returned value, since it points right
- * at the stored value in the case of pass-by-reference datatypes. In some
+ * at the stored value in the case of pass-by-reference datatypes. In some
* cases we have to palloc a return value, and in such cases we put it into
* the estate's short-term memory context.
*/
static void
-exec_eval_datum(PLpgSQL_execstate *estate,
- PLpgSQL_datum *datum,
+exec_eval_datum(PLpgSQL_execstate * estate,
+ PLpgSQL_datum * datum,
Oid expectedtypeid,
Oid *typeid,
Datum *value,
@@ -3454,19 +3448,18 @@ exec_eval_datum(PLpgSQL_execstate *estate,
if (!HeapTupleIsValid(rec->tup))
ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("record \"%s\" is not assigned yet",
- rec->refname),
- errdetail("The tuple structure of a not-yet-assigned record is indeterminate.")));
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("record \"%s\" is not assigned yet",
+ rec->refname),
+ errdetail("The tuple structure of a not-yet-assigned record is indeterminate.")));
Assert(rec->tupdesc != NULL);
/* Make sure we have a valid type/typmod setting */
BlessTupleDesc(rec->tupdesc);
/*
- * In a trigger, the NEW and OLD parameters are likely to
- * be on-disk tuples that don't have the desired Datum
- * fields. Copy the tuple body and insert the right
- * values.
+ * In a trigger, the NEW and OLD parameters are likely to be
+ * on-disk tuples that don't have the desired Datum fields.
+ * Copy the tuple body and insert the right values.
*/
oldcontext = MemoryContextSwitchTo(estate->eval_econtext->ecxt_per_tuple_memory);
heap_copytuple_with_tuple(rec->tup, &worktup);
@@ -3494,10 +3487,10 @@ exec_eval_datum(PLpgSQL_execstate *estate,
rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
if (!HeapTupleIsValid(rec->tup))
ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("record \"%s\" is not assigned yet",
- rec->refname),
- errdetail("The tuple structure of a not-yet-assigned record is indeterminate.")));
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("record \"%s\" is not assigned yet",
+ rec->refname),
+ errdetail("The tuple structure of a not-yet-assigned record is indeterminate.")));
fno = SPI_fnumber(rec->tupdesc, recfield->fieldname);
if (fno == SPI_ERROR_NOATTRIBUTE)
ereport(ERROR,
@@ -3555,8 +3548,8 @@ exec_eval_datum(PLpgSQL_execstate *estate,
* ----------
*/
static int
-exec_eval_integer(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr,
+exec_eval_integer(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr,
bool *isNull)
{
Datum exprdatum;
@@ -3577,8 +3570,8 @@ exec_eval_integer(PLpgSQL_execstate *estate,
* ----------
*/
static bool
-exec_eval_boolean(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr,
+exec_eval_boolean(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr,
bool *isNull)
{
Datum exprdatum;
@@ -3599,8 +3592,8 @@ exec_eval_boolean(PLpgSQL_execstate *estate,
* ----------
*/
static Datum
-exec_eval_expr(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr,
+exec_eval_expr(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr,
bool *isNull,
Oid *rettype)
{
@@ -3623,7 +3616,7 @@ exec_eval_expr(PLpgSQL_execstate *estate,
if (rc != SPI_OK_SELECT)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("query \"%s\" did not return data", expr->query)));
+ errmsg("query \"%s\" did not return data", expr->query)));
/*
* If there are no rows selected, the result is NULL.
@@ -3662,8 +3655,8 @@ exec_eval_expr(PLpgSQL_execstate *estate,
* ----------
*/
static int
-exec_run_select(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr, long maxtuples, Portal *portalP)
+exec_run_select(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr, long maxtuples, Portal *portalP)
{
int i;
Datum *values;
@@ -3744,8 +3737,8 @@ exec_run_select(PLpgSQL_execstate *estate,
* ----------
*/
static Datum
-exec_eval_simple_expr(PLpgSQL_execstate *estate,
- PLpgSQL_expr *expr,
+exec_eval_simple_expr(PLpgSQL_execstate * estate,
+ PLpgSQL_expr * expr,
bool *isNull,
Oid *rettype)
{
@@ -3761,8 +3754,8 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate,
*rettype = expr->expr_simple_type;
/*
- * Prepare the expression for execution, if it's not been done already
- * in the current transaction.
+ * Prepare the expression for execution, if it's not been done already in
+ * the current transaction.
*/
if (expr->expr_simple_state == NULL)
{
@@ -3776,14 +3769,14 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate,
/*
* Param list can live in econtext's temporary memory context.
*
- * XXX think about avoiding repeated palloc's for param lists? Beware
- * however that this routine is re-entrant: exec_eval_datum() can call
- * it back for subscript evaluation, and so there can be a need to
- * have more than one active param list.
+ * XXX think about avoiding repeated palloc's for param lists? Beware however
+ * that this routine is re-entrant: exec_eval_datum() can call it back for
+ * subscript evaluation, and so there can be a need to have more than one
+ * active param list.
*/
paramLI = (ParamListInfo)
MemoryContextAlloc(econtext->ecxt_per_tuple_memory,
- (expr->nparams + 1) * sizeof(ParamListInfoData));
+ (expr->nparams + 1) * sizeof(ParamListInfoData));
/*
* Put the parameter values into the parameter list entries.
@@ -3806,10 +3799,10 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate,
econtext->ecxt_param_list_info = paramLI;
/*
- * We have to do some of the things SPI_execute_plan would do,
- * in particular advance the snapshot if we are in a non-read-only
- * function. Without this, stable functions within the expression
- * would fail to see updates made so far by our own function.
+ * We have to do some of the things SPI_execute_plan would do, in
+ * particular advance the snapshot if we are in a non-read-only function.
+ * Without this, stable functions within the expression would fail to see
+ * updates made so far by our own function.
*/
SPI_push();
saveActiveSnapshot = ActiveSnapshot;
@@ -3857,9 +3850,9 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate,
* ----------
*/
static void
-exec_move_row(PLpgSQL_execstate *estate,
- PLpgSQL_rec *rec,
- PLpgSQL_row *row,
+exec_move_row(PLpgSQL_execstate * estate,
+ PLpgSQL_rec * rec,
+ PLpgSQL_row * row,
HeapTuple tup, TupleDesc tupdesc)
{
/*
@@ -3923,16 +3916,16 @@ exec_move_row(PLpgSQL_execstate *estate,
* Row is a bit more complicated in that we assign the individual
* attributes of the tuple to the variables the row points to.
*
- * NOTE: this code used to demand row->nfields == tup->t_data->t_natts,
- * but that's wrong. The tuple might have more fields than we
- * expected if it's from an inheritance-child table of the current
- * table, or it might have fewer if the table has had columns added by
- * ALTER TABLE. Ignore extra columns and assume NULL for missing
- * columns, the same as heap_getattr would do. We also have to skip
- * over dropped columns in either the source or destination.
+ * NOTE: this code used to demand row->nfields == tup->t_data->t_natts, but
+ * that's wrong. The tuple might have more fields than we expected if
+ * it's from an inheritance-child table of the current table, or it might
+ * have fewer if the table has had columns added by ALTER TABLE. Ignore
+ * extra columns and assume NULL for missing columns, the same as
+ * heap_getattr would do. We also have to skip over dropped columns in
+ * either the source or destination.
*
- * If we have no tuple data at all, we'll assign NULL to all columns of
- * the row variable.
+ * If we have no tuple data at all, we'll assign NULL to all columns of the
+ * row variable.
*/
if (row != NULL)
{
@@ -3991,8 +3984,8 @@ exec_move_row(PLpgSQL_execstate *estate,
* ----------
*/
static HeapTuple
-make_tuple_from_row(PLpgSQL_execstate *estate,
- PLpgSQL_row *row,
+make_tuple_from_row(PLpgSQL_execstate * estate,
+ PLpgSQL_row * row,
TupleDesc tupdesc)
{
int natts = tupdesc->natts;
@@ -4066,8 +4059,8 @@ exec_cast_value(Datum value, Oid valtype,
if (!isnull)
{
/*
- * If the type of the queries return value isn't that of the
- * variable, convert it.
+ * If the type of the queries return value isn't that of the variable,
+ * convert it.
*/
if (valtype != reqtype || reqtypmod != -1)
{
@@ -4358,7 +4351,7 @@ exec_simple_check_node(Node *node)
* ----------
*/
static void
-exec_simple_check_plan(PLpgSQL_expr *expr)
+exec_simple_check_plan(PLpgSQL_expr * expr)
{
_SPI_plan *spi_plan = (_SPI_plan *) expr->plan;
Plan *plan;
@@ -4367,8 +4360,8 @@ exec_simple_check_plan(PLpgSQL_expr *expr)
expr->expr_simple_expr = NULL;
/*
- * 1. We can only evaluate queries that resulted in one single
- * execution plan
+ * 1. We can only evaluate queries that resulted in one single execution
+ * plan
*/
if (list_length(spi_plan->ptlist) != 1)
return;
@@ -4445,7 +4438,7 @@ compatible_tupdesc(TupleDesc td1, TupleDesc td2)
* ----------
*/
static void
-exec_set_found(PLpgSQL_execstate *estate, bool state)
+exec_set_found(PLpgSQL_execstate * estate, bool state)
{
PLpgSQL_var *var;
@@ -4481,10 +4474,10 @@ plpgsql_xact_cb(XactEvent event, void *arg)
active_simple_exprs = NULL;
/*
- * If we are doing a clean transaction shutdown, free the
- * EState (so that any remaining resources will be released
- * correctly). In an abort, we expect the regular abort
- * recovery procedures to release everything of interest.
+ * If we are doing a clean transaction shutdown, free the EState (so that
+ * any remaining resources will be released correctly). In an abort, we
+ * expect the regular abort recovery procedures to release everything of
+ * interest.
*/
if (event == XACT_EVENT_COMMIT && simple_eval_estate)
FreeExecutorState(simple_eval_estate);
@@ -4492,7 +4485,7 @@ plpgsql_xact_cb(XactEvent event, void *arg)
}
static void
-free_var(PLpgSQL_var *var)
+free_var(PLpgSQL_var * var)
{
if (var->freeval)
{
diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c
index 03280c94b12..dd12a061f34 100644
--- a/src/pl/plpgsql/src/pl_funcs.c
+++ b/src/pl/plpgsql/src/pl_funcs.c
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.45 2005/06/22 01:35:02 neilc Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.46 2005/10/15 02:49:50 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -56,7 +56,7 @@ static bool ns_localmode = false;
* ----------
*/
void
-plpgsql_dstring_init(PLpgSQL_dstring *ds)
+plpgsql_dstring_init(PLpgSQL_dstring * ds)
{
ds->value = palloc(ds->alloc = 512);
ds->used = 1;
@@ -69,13 +69,13 @@ plpgsql_dstring_init(PLpgSQL_dstring *ds)
* ----------
*/
void
-plpgsql_dstring_free(PLpgSQL_dstring *ds)
+plpgsql_dstring_free(PLpgSQL_dstring * ds)
{
pfree(ds->value);
}
static void
-plpgsql_dstring_expand(PLpgSQL_dstring *ds, int needed)
+plpgsql_dstring_expand(PLpgSQL_dstring * ds, int needed)
{
/* Don't allow truncating the string */
Assert(needed > ds->alloc);
@@ -94,7 +94,7 @@ plpgsql_dstring_expand(PLpgSQL_dstring *ds, int needed)
* ----------
*/
void
-plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str)
+plpgsql_dstring_append(PLpgSQL_dstring * ds, const char *str)
{
int len = strlen(str);
int needed = ds->used + len;
@@ -113,7 +113,7 @@ plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str)
* ----------
*/
void
-plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c)
+plpgsql_dstring_append_char(PLpgSQL_dstring * ds, char c)
{
if (ds->used == ds->alloc)
plpgsql_dstring_expand(ds, ds->used + 1);
@@ -129,7 +129,7 @@ plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c)
* ----------
*/
char *
-plpgsql_dstring_get(PLpgSQL_dstring *ds)
+plpgsql_dstring_get(PLpgSQL_dstring * ds)
{
return ds->value;
}
@@ -229,7 +229,7 @@ plpgsql_ns_additem(int itemtype, int itemno, const char *name)
{
ns->items_alloc *= 2;
ns->items = repalloc(ns->items,
- sizeof(PLpgSQL_nsitem *) * ns->items_alloc);
+ sizeof(PLpgSQL_nsitem *) * ns->items_alloc);
}
}
@@ -310,8 +310,8 @@ plpgsql_ns_rename(char *oldname, char *newname)
int i;
/*
- * Lookup name in the namestack; do the lookup in the current
- * namespace only.
+ * Lookup name in the namestack; do the lookup in the current namespace
+ * only.
*/
for (ns = ns_current; ns != NULL; ns = ns->upper)
{
@@ -416,8 +416,8 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("qualified identifier cannot be used here: %s",
- sstart)));
+ errmsg("qualified identifier cannot be used here: %s",
+ sstart)));
/* If not done, skip whitespace, dot, whitespace */
if (*s)
@@ -443,7 +443,7 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
* Statement type as a string, for use in error messages etc.
*/
const char *
-plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
+plpgsql_stmt_typename(PLpgSQL_stmt * stmt)
{
switch (stmt->cmd_type)
{
@@ -499,28 +499,28 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
static int dump_indent;
static void dump_ind();
-static void dump_stmt(PLpgSQL_stmt *stmt);
-static void dump_block(PLpgSQL_stmt_block *block);
-static void dump_assign(PLpgSQL_stmt_assign *stmt);
-static void dump_if(PLpgSQL_stmt_if *stmt);
-static void dump_loop(PLpgSQL_stmt_loop *stmt);
-static void dump_while(PLpgSQL_stmt_while *stmt);
-static void dump_fori(PLpgSQL_stmt_fori *stmt);
-static void dump_fors(PLpgSQL_stmt_fors *stmt);
-static void dump_select(PLpgSQL_stmt_select *stmt);
-static void dump_exit(PLpgSQL_stmt_exit *stmt);
-static void dump_return(PLpgSQL_stmt_return *stmt);
-static void dump_return_next(PLpgSQL_stmt_return_next *stmt);
-static void dump_raise(PLpgSQL_stmt_raise *stmt);
-static void dump_execsql(PLpgSQL_stmt_execsql *stmt);
-static void dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt);
-static void dump_dynfors(PLpgSQL_stmt_dynfors *stmt);
-static void dump_getdiag(PLpgSQL_stmt_getdiag *stmt);
-static void dump_open(PLpgSQL_stmt_open *stmt);
-static void dump_fetch(PLpgSQL_stmt_fetch *stmt);
-static void dump_close(PLpgSQL_stmt_close *stmt);
-static void dump_perform(PLpgSQL_stmt_perform *stmt);
-static void dump_expr(PLpgSQL_expr *expr);
+static void dump_stmt(PLpgSQL_stmt * stmt);
+static void dump_block(PLpgSQL_stmt_block * block);
+static void dump_assign(PLpgSQL_stmt_assign * stmt);
+static void dump_if(PLpgSQL_stmt_if * stmt);
+static void dump_loop(PLpgSQL_stmt_loop * stmt);
+static void dump_while(PLpgSQL_stmt_while * stmt);
+static void dump_fori(PLpgSQL_stmt_fori * stmt);
+static void dump_fors(PLpgSQL_stmt_fors * stmt);
+static void dump_select(PLpgSQL_stmt_select * stmt);
+static void dump_exit(PLpgSQL_stmt_exit * stmt);
+static void dump_return(PLpgSQL_stmt_return * stmt);
+static void dump_return_next(PLpgSQL_stmt_return_next * stmt);
+static void dump_raise(PLpgSQL_stmt_raise * stmt);
+static void dump_execsql(PLpgSQL_stmt_execsql * stmt);
+static void dump_dynexecute(PLpgSQL_stmt_dynexecute * stmt);
+static void dump_dynfors(PLpgSQL_stmt_dynfors * stmt);
+static void dump_getdiag(PLpgSQL_stmt_getdiag * stmt);
+static void dump_open(PLpgSQL_stmt_open * stmt);
+static void dump_fetch(PLpgSQL_stmt_fetch * stmt);
+static void dump_close(PLpgSQL_stmt_close * stmt);
+static void dump_perform(PLpgSQL_stmt_perform * stmt);
+static void dump_expr(PLpgSQL_expr * expr);
static void
@@ -533,7 +533,7 @@ dump_ind(void)
}
static void
-dump_stmt(PLpgSQL_stmt *stmt)
+dump_stmt(PLpgSQL_stmt * stmt)
{
printf("%3d:", stmt->lineno);
switch (stmt->cmd_type)
@@ -607,16 +607,16 @@ dump_stmt(PLpgSQL_stmt *stmt)
static void
dump_stmts(List *stmts)
{
- ListCell *s;
+ ListCell *s;
dump_indent += 2;
- foreach (s, stmts)
+ foreach(s, stmts)
dump_stmt((PLpgSQL_stmt *) lfirst(s));
dump_indent -= 2;
}
static void
-dump_block(PLpgSQL_stmt_block *block)
+dump_block(PLpgSQL_stmt_block * block)
{
char *name;
@@ -632,9 +632,9 @@ dump_block(PLpgSQL_stmt_block *block)
if (block->exceptions)
{
- ListCell *e;
+ ListCell *e;
- foreach (e, block->exceptions->exc_list)
+ foreach(e, block->exceptions->exc_list)
{
PLpgSQL_exception *exc = (PLpgSQL_exception *) lfirst(e);
PLpgSQL_condition *cond;
@@ -657,7 +657,7 @@ dump_block(PLpgSQL_stmt_block *block)
}
static void
-dump_assign(PLpgSQL_stmt_assign *stmt)
+dump_assign(PLpgSQL_stmt_assign * stmt)
{
dump_ind();
printf("ASSIGN var %d := ", stmt->varno);
@@ -666,7 +666,7 @@ dump_assign(PLpgSQL_stmt_assign *stmt)
}
static void
-dump_if(PLpgSQL_stmt_if *stmt)
+dump_if(PLpgSQL_stmt_if * stmt)
{
dump_ind();
printf("IF ");
@@ -687,7 +687,7 @@ dump_if(PLpgSQL_stmt_if *stmt)
}
static void
-dump_loop(PLpgSQL_stmt_loop *stmt)
+dump_loop(PLpgSQL_stmt_loop * stmt)
{
dump_ind();
printf("LOOP\n");
@@ -699,7 +699,7 @@ dump_loop(PLpgSQL_stmt_loop *stmt)
}
static void
-dump_while(PLpgSQL_stmt_while *stmt)
+dump_while(PLpgSQL_stmt_while * stmt)
{
dump_ind();
printf("WHILE ");
@@ -713,7 +713,7 @@ dump_while(PLpgSQL_stmt_while *stmt)
}
static void
-dump_fori(PLpgSQL_stmt_fori *stmt)
+dump_fori(PLpgSQL_stmt_fori * stmt)
{
dump_ind();
printf("FORI %s %s\n", stmt->var->refname, (stmt->reverse) ? "REVERSE" : "NORMAL");
@@ -736,7 +736,7 @@ dump_fori(PLpgSQL_stmt_fori *stmt)
}
static void
-dump_fors(PLpgSQL_stmt_fors *stmt)
+dump_fors(PLpgSQL_stmt_fors * stmt)
{
dump_ind();
printf("FORS %s ", (stmt->rec != NULL) ? stmt->rec->refname : stmt->row->refname);
@@ -750,7 +750,7 @@ dump_fors(PLpgSQL_stmt_fors *stmt)
}
static void
-dump_select(PLpgSQL_stmt_select *stmt)
+dump_select(PLpgSQL_stmt_select * stmt)
{
dump_ind();
printf("SELECT ");
@@ -773,7 +773,7 @@ dump_select(PLpgSQL_stmt_select *stmt)
}
static void
-dump_open(PLpgSQL_stmt_open *stmt)
+dump_open(PLpgSQL_stmt_open * stmt)
{
dump_ind();
printf("OPEN curvar=%d\n", stmt->curvar);
@@ -805,7 +805,7 @@ dump_open(PLpgSQL_stmt_open *stmt)
}
static void
-dump_fetch(PLpgSQL_stmt_fetch *stmt)
+dump_fetch(PLpgSQL_stmt_fetch * stmt)
{
dump_ind();
printf("FETCH curvar=%d\n", stmt->curvar);
@@ -826,14 +826,14 @@ dump_fetch(PLpgSQL_stmt_fetch *stmt)
}
static void
-dump_close(PLpgSQL_stmt_close *stmt)
+dump_close(PLpgSQL_stmt_close * stmt)
{
dump_ind();
printf("CLOSE curvar=%d\n", stmt->curvar);
}
static void
-dump_perform(PLpgSQL_stmt_perform *stmt)
+dump_perform(PLpgSQL_stmt_perform * stmt)
{
dump_ind();
printf("PERFORM expr = ");
@@ -842,7 +842,7 @@ dump_perform(PLpgSQL_stmt_perform *stmt)
}
static void
-dump_exit(PLpgSQL_stmt_exit *stmt)
+dump_exit(PLpgSQL_stmt_exit * stmt)
{
dump_ind();
printf("%s label='%s'",
@@ -856,7 +856,7 @@ dump_exit(PLpgSQL_stmt_exit *stmt)
}
static void
-dump_return(PLpgSQL_stmt_return *stmt)
+dump_return(PLpgSQL_stmt_return * stmt)
{
dump_ind();
printf("RETURN ");
@@ -870,7 +870,7 @@ dump_return(PLpgSQL_stmt_return *stmt)
}
static void
-dump_return_next(PLpgSQL_stmt_return_next *stmt)
+dump_return_next(PLpgSQL_stmt_return_next * stmt)
{
dump_ind();
printf("RETURN NEXT ");
@@ -884,15 +884,15 @@ dump_return_next(PLpgSQL_stmt_return_next *stmt)
}
static void
-dump_raise(PLpgSQL_stmt_raise *stmt)
+dump_raise(PLpgSQL_stmt_raise * stmt)
{
- ListCell *lc;
- int i = 0;
+ ListCell *lc;
+ int i = 0;
dump_ind();
printf("RAISE '%s'\n", stmt->message);
dump_indent += 2;
- foreach (lc, stmt->params)
+ foreach(lc, stmt->params)
{
dump_ind();
printf(" parameter %d: ", i++);
@@ -903,7 +903,7 @@ dump_raise(PLpgSQL_stmt_raise *stmt)
}
static void
-dump_execsql(PLpgSQL_stmt_execsql *stmt)
+dump_execsql(PLpgSQL_stmt_execsql * stmt)
{
dump_ind();
printf("EXECSQL ");
@@ -912,7 +912,7 @@ dump_execsql(PLpgSQL_stmt_execsql *stmt)
}
static void
-dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
+dump_dynexecute(PLpgSQL_stmt_dynexecute * stmt)
{
dump_ind();
printf("EXECUTE ");
@@ -934,7 +934,7 @@ dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
}
static void
-dump_dynfors(PLpgSQL_stmt_dynfors *stmt)
+dump_dynfors(PLpgSQL_stmt_dynfors * stmt)
{
dump_ind();
printf("FORS %s EXECUTE ", (stmt->rec != NULL) ? stmt->rec->refname : stmt->row->refname);
@@ -948,13 +948,13 @@ dump_dynfors(PLpgSQL_stmt_dynfors *stmt)
}
static void
-dump_getdiag(PLpgSQL_stmt_getdiag *stmt)
+dump_getdiag(PLpgSQL_stmt_getdiag * stmt)
{
- ListCell *lc;
+ ListCell *lc;
dump_ind();
printf("GET DIAGNOSTICS ");
- foreach (lc, stmt->diag_items)
+ foreach(lc, stmt->diag_items)
{
PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc);
@@ -982,7 +982,7 @@ dump_getdiag(PLpgSQL_stmt_getdiag *stmt)
}
static void
-dump_expr(PLpgSQL_expr *expr)
+dump_expr(PLpgSQL_expr * expr)
{
int i;
@@ -1002,7 +1002,7 @@ dump_expr(PLpgSQL_expr *expr)
}
void
-plpgsql_dumptree(PLpgSQL_function *func)
+plpgsql_dumptree(PLpgSQL_function * func)
{
int i;
PLpgSQL_datum *d;
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index c20efe77391..69d128e8698 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.25 2005/03/29 00:17:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.26 2005/10/15 02:49:50 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -47,7 +47,7 @@
extern DLLIMPORT bool check_function_bodies;
-static bool plpgsql_firstcall = true;
+static bool plpgsql_firstcall = true;
static void plpgsql_init_all(void);
@@ -118,7 +118,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
*/
if (CALLED_AS_TRIGGER(fcinfo))
retval = PointerGetDatum(plpgsql_exec_trigger(func,
- (TriggerData *) fcinfo->context));
+ (TriggerData *) fcinfo->context));
else
retval = plpgsql_exec_function(func, fcinfo);
@@ -198,7 +198,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpgsql functions cannot take type %s",
- format_type_be(proc->proargtypes.values[i]))));
+ format_type_be(proc->proargtypes.values[i]))));
}
}
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index 3615b3bf066..38b1aa1329b 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.64 2005/06/22 01:35:02 neilc Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.65 2005/10/15 02:49:50 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -150,7 +150,7 @@ typedef struct
int alloc;
int used; /* Including NUL terminator */
char *value;
-} PLpgSQL_dstring;
+} PLpgSQL_dstring;
typedef struct
@@ -164,7 +164,7 @@ typedef struct
Oid typioparam;
FmgrInfo typinput; /* lookup info for typinput function */
int32 atttypmod; /* typmod (taken from someplace else) */
-} PLpgSQL_type;
+} PLpgSQL_type;
/*
@@ -176,7 +176,7 @@ typedef struct
{ /* Generic datum array item */
int dtype;
int dno;
-} PLpgSQL_datum;
+} PLpgSQL_datum;
/*
* The variants PLpgSQL_var, PLpgSQL_row, and PLpgSQL_rec share these
@@ -188,7 +188,7 @@ typedef struct
int dno;
char *refname;
int lineno;
-} PLpgSQL_variable;
+} PLpgSQL_variable;
typedef struct PLpgSQL_expr
{ /* SQL Query to plan and execute */
@@ -206,7 +206,7 @@ typedef struct PLpgSQL_expr
/* params to pass to expr */
int nparams;
int params[1]; /* VARIABLE SIZE ARRAY ... must be last */
-} PLpgSQL_expr;
+} PLpgSQL_expr;
typedef struct
@@ -226,7 +226,7 @@ typedef struct
Datum value;
bool isnull;
bool freeval;
-} PLpgSQL_var;
+} PLpgSQL_var;
typedef struct
@@ -248,7 +248,7 @@ typedef struct
int nfields;
char **fieldnames;
int *varnos;
-} PLpgSQL_row;
+} PLpgSQL_row;
typedef struct
@@ -262,7 +262,7 @@ typedef struct
TupleDesc tupdesc;
bool freetup;
bool freetupdesc;
-} PLpgSQL_rec;
+} PLpgSQL_rec;
typedef struct
@@ -271,7 +271,7 @@ typedef struct
int rfno;
char *fieldname;
int recparentno; /* dno of parent record */
-} PLpgSQL_recfield;
+} PLpgSQL_recfield;
typedef struct
@@ -280,7 +280,7 @@ typedef struct
int dno;
PLpgSQL_expr *subscript;
int arrayparentno; /* dno of parent array variable */
-} PLpgSQL_arrayelem;
+} PLpgSQL_arrayelem;
typedef struct
@@ -288,7 +288,7 @@ typedef struct
int dtype;
int dno;
PLpgSQL_expr *argnum;
-} PLpgSQL_trigarg;
+} PLpgSQL_trigarg;
typedef struct
@@ -296,7 +296,7 @@ typedef struct
int itemtype;
int itemno;
char name[1];
-} PLpgSQL_nsitem;
+} PLpgSQL_nsitem;
/* XXX: consider adapting this to use List */
@@ -306,14 +306,14 @@ typedef struct PLpgSQL_ns
int items_used;
PLpgSQL_nsitem **items;
struct PLpgSQL_ns *upper;
-} PLpgSQL_ns;
+} PLpgSQL_ns;
typedef struct
{ /* Generic execution node */
int cmd_type;
int lineno;
-} PLpgSQL_stmt;
+} PLpgSQL_stmt;
typedef struct PLpgSQL_condition
@@ -321,21 +321,21 @@ typedef struct PLpgSQL_condition
int sqlerrstate; /* SQLSTATE code */
char *condname; /* condition name (for debugging) */
struct PLpgSQL_condition *next;
-} PLpgSQL_condition;
+} PLpgSQL_condition;
typedef struct
{
int sqlstate_varno;
int sqlerrm_varno;
List *exc_list; /* List of WHEN clauses */
-} PLpgSQL_exception_block;
+} PLpgSQL_exception_block;
typedef struct
{ /* One EXCEPTION ... WHEN clause */
int lineno;
PLpgSQL_condition *conditions;
List *action; /* List of statements */
-} PLpgSQL_exception;
+} PLpgSQL_exception;
typedef struct
@@ -347,7 +347,7 @@ typedef struct
int n_initvars;
int *initvarnos;
PLpgSQL_exception_block *exceptions;
-} PLpgSQL_stmt_block;
+} PLpgSQL_stmt_block;
typedef struct
@@ -356,27 +356,27 @@ typedef struct
int lineno;
int varno;
PLpgSQL_expr *expr;
-} PLpgSQL_stmt_assign;
+} PLpgSQL_stmt_assign;
typedef struct
{ /* PERFORM statement */
int cmd_type;
int lineno;
PLpgSQL_expr *expr;
-} PLpgSQL_stmt_perform;
+} PLpgSQL_stmt_perform;
typedef struct
{ /* Get Diagnostics item */
int kind; /* id for diagnostic value desired */
int target; /* where to assign it */
-} PLpgSQL_diag_item;
+} PLpgSQL_diag_item;
typedef struct
{ /* Get Diagnostics statement */
int cmd_type;
int lineno;
List *diag_items; /* List of PLpgSQL_diag_item */
-} PLpgSQL_stmt_getdiag;
+} PLpgSQL_stmt_getdiag;
typedef struct
@@ -386,7 +386,7 @@ typedef struct
PLpgSQL_expr *cond;
List *true_body; /* List of statements */
List *false_body; /* List of statements */
-} PLpgSQL_stmt_if;
+} PLpgSQL_stmt_if;
typedef struct
@@ -395,7 +395,7 @@ typedef struct
int lineno;
char *label;
List *body; /* List of statements */
-} PLpgSQL_stmt_loop;
+} PLpgSQL_stmt_loop;
typedef struct
@@ -405,7 +405,7 @@ typedef struct
char *label;
PLpgSQL_expr *cond;
List *body; /* List of statements */
-} PLpgSQL_stmt_while;
+} PLpgSQL_stmt_while;
typedef struct
@@ -418,7 +418,7 @@ typedef struct
PLpgSQL_expr *upper;
int reverse;
List *body; /* List of statements */
-} PLpgSQL_stmt_fori;
+} PLpgSQL_stmt_fori;
typedef struct
@@ -430,7 +430,7 @@ typedef struct
PLpgSQL_row *row;
PLpgSQL_expr *query;
List *body; /* List of statements */
-} PLpgSQL_stmt_fors;
+} PLpgSQL_stmt_fors;
typedef struct
@@ -442,7 +442,7 @@ typedef struct
PLpgSQL_row *row;
PLpgSQL_expr *query;
List *body; /* List of statements */
-} PLpgSQL_stmt_dynfors;
+} PLpgSQL_stmt_dynfors;
typedef struct
@@ -452,7 +452,7 @@ typedef struct
PLpgSQL_rec *rec;
PLpgSQL_row *row;
PLpgSQL_expr *query;
-} PLpgSQL_stmt_select;
+} PLpgSQL_stmt_select;
typedef struct
@@ -464,7 +464,7 @@ typedef struct
PLpgSQL_expr *argquery;
PLpgSQL_expr *query;
PLpgSQL_expr *dynquery;
-} PLpgSQL_stmt_open;
+} PLpgSQL_stmt_open;
typedef struct
@@ -474,7 +474,7 @@ typedef struct
PLpgSQL_rec *rec;
PLpgSQL_row *row;
int curvar;
-} PLpgSQL_stmt_fetch;
+} PLpgSQL_stmt_fetch;
typedef struct
@@ -482,7 +482,7 @@ typedef struct
int cmd_type;
int lineno;
int curvar;
-} PLpgSQL_stmt_close;
+} PLpgSQL_stmt_close;
typedef struct
@@ -492,7 +492,7 @@ typedef struct
bool is_exit; /* Is this an exit or a continue? */
char *label;
PLpgSQL_expr *cond;
-} PLpgSQL_stmt_exit;
+} PLpgSQL_stmt_exit;
typedef struct
@@ -501,7 +501,7 @@ typedef struct
int lineno;
PLpgSQL_expr *expr;
int retvarno;
-} PLpgSQL_stmt_return;
+} PLpgSQL_stmt_return;
typedef struct
{ /* RETURN NEXT statement */
@@ -509,7 +509,7 @@ typedef struct
int lineno;
PLpgSQL_expr *expr;
int retvarno;
-} PLpgSQL_stmt_return_next;
+} PLpgSQL_stmt_return_next;
typedef struct
{ /* RAISE statement */
@@ -518,7 +518,7 @@ typedef struct
int elog_level;
char *message;
List *params; /* list of expressions */
-} PLpgSQL_stmt_raise;
+} PLpgSQL_stmt_raise;
typedef struct
@@ -526,17 +526,17 @@ typedef struct
int cmd_type;
int lineno;
PLpgSQL_expr *sqlstmt;
-} PLpgSQL_stmt_execsql;
+} PLpgSQL_stmt_execsql;
typedef struct
{ /* Dynamic SQL string to execute */
int cmd_type;
int lineno;
- PLpgSQL_rec *rec; /* INTO record or row variable */
+ PLpgSQL_rec *rec; /* INTO record or row variable */
PLpgSQL_row *row;
PLpgSQL_expr *query;
-} PLpgSQL_stmt_dynexecute;
+} PLpgSQL_stmt_dynexecute;
typedef struct PLpgSQL_func_hashkey
@@ -544,20 +544,19 @@ typedef struct PLpgSQL_func_hashkey
Oid funcOid;
/*
- * For a trigger function, the OID of the relation triggered on is
- * part of the hashkey --- we want to compile the trigger separately
- * for each relation it is used with, in case the rowtype is
- * different. Zero if not called as a trigger.
+ * For a trigger function, the OID of the relation triggered on is part of
+ * the hashkey --- we want to compile the trigger separately for each
+ * relation it is used with, in case the rowtype is different. Zero if
+ * not called as a trigger.
*/
Oid trigrelOid;
/*
- * We include actual argument types in the hash key to support
- * polymorphic PLpgSQL functions. Be careful that extra positions are
- * zeroed!
+ * We include actual argument types in the hash key to support polymorphic
+ * PLpgSQL functions. Be careful that extra positions are zeroed!
*/
Oid argtypes[FUNC_MAX_ARGS];
-} PLpgSQL_func_hashkey;
+} PLpgSQL_func_hashkey;
typedef struct PLpgSQL_function
@@ -596,7 +595,7 @@ typedef struct PLpgSQL_function
int ndatums;
PLpgSQL_datum **datums;
PLpgSQL_stmt_block *action;
-} PLpgSQL_function;
+} PLpgSQL_function;
typedef struct
@@ -612,8 +611,8 @@ typedef struct
bool readonly_func;
TupleDesc rettupdesc;
- char *exitlabel; /* the "target" label of the current
- * EXIT or CONTINUE stmt, if any */
+ char *exitlabel; /* the "target" label of the current EXIT or
+ * CONTINUE stmt, if any */
Tuplestorestate *tuple_store; /* SRFs accumulate results here */
MemoryContext tuple_store_cxt;
@@ -636,15 +635,15 @@ typedef struct
PLpgSQL_function *err_func; /* current func */
PLpgSQL_stmt *err_stmt; /* current stmt */
const char *err_text; /* additional state info */
-} PLpgSQL_execstate;
+} PLpgSQL_execstate;
/**********************************************************************
* Global variable declarations
**********************************************************************/
-extern bool plpgsql_DumpExecTree;
-extern bool plpgsql_SpaceScanned;
+extern bool plpgsql_DumpExecTree;
+extern bool plpgsql_SpaceScanned;
extern int plpgsql_nDatums;
extern PLpgSQL_datum **plpgsql_Datums;
@@ -657,7 +656,7 @@ extern char *plpgsql_base_yytext;
#define plpgsql_yytext plpgsql_base_yytext
extern PLpgSQL_function *plpgsql_curr_compile;
-extern bool plpgsql_check_syntax;
+extern bool plpgsql_check_syntax;
extern MemoryContext compile_tmp_cxt;
/**********************************************************************
@@ -681,10 +680,10 @@ extern int plpgsql_parse_dblwordrowtype(char *word);
extern PLpgSQL_type *plpgsql_parse_datatype(const char *string);
extern PLpgSQL_type *plpgsql_build_datatype(Oid typeOid, int32 typmod);
extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno,
- PLpgSQL_type *dtype,
+ PLpgSQL_type * dtype,
bool add2namespace);
extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname);
-extern void plpgsql_adddatum(PLpgSQL_datum *new);
+extern void plpgsql_adddatum(PLpgSQL_datum * new);
extern int plpgsql_add_initdatums(int **varnos);
extern void plpgsql_HashTableInit(void);
extern void plpgsql_compile_error_callback(void *arg);
@@ -701,9 +700,9 @@ extern Datum plpgsql_validator(PG_FUNCTION_ARGS);
* Functions in pl_exec.c
* ----------
*/
-extern Datum plpgsql_exec_function(PLpgSQL_function *func,
+extern Datum plpgsql_exec_function(PLpgSQL_function * func,
FunctionCallInfo fcinfo);
-extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func,
+extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function * func,
TriggerData *trigdata);
extern void plpgsql_xact_cb(XactEvent event, void *arg);
@@ -711,11 +710,11 @@ extern void plpgsql_xact_cb(XactEvent event, void *arg);
* Functions for the dynamic string handling in pl_funcs.c
* ----------
*/
-extern void plpgsql_dstring_init(PLpgSQL_dstring *ds);
-extern void plpgsql_dstring_free(PLpgSQL_dstring *ds);
-extern void plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str);
-extern void plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c);
-extern char *plpgsql_dstring_get(PLpgSQL_dstring *ds);
+extern void plpgsql_dstring_init(PLpgSQL_dstring * ds);
+extern void plpgsql_dstring_free(PLpgSQL_dstring * ds);
+extern void plpgsql_dstring_append(PLpgSQL_dstring * ds, const char *str);
+extern void plpgsql_dstring_append_char(PLpgSQL_dstring * ds, char c);
+extern char *plpgsql_dstring_get(PLpgSQL_dstring * ds);
/* ----------
* Functions for the namestack handling in pl_funcs.c
@@ -734,8 +733,8 @@ extern void plpgsql_ns_rename(char *oldname, char *newname);
* ----------
*/
extern void plpgsql_convert_ident(const char *s, char **output, int numidents);
-extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt);
-extern void plpgsql_dumptree(PLpgSQL_function *func);
+extern const char *plpgsql_stmt_typename(PLpgSQL_stmt * stmt);
+extern void plpgsql_dumptree(PLpgSQL_function * func);
/* ----------
* Externs in gram.y and scan.l
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index b1d47c77820..eff1d695cd0 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.65 2005/07/10 04:56:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.66 2005/10/15 02:49:50 momjian Exp $
*
*********************************************************************
*/
@@ -118,8 +118,8 @@ typedef struct PLyTypeInfo
int is_rowtype;
/*
- * is_rowtype can be: -1 not known yet (initial state) 0 scalar
- * datatype 1 rowtype 2 rowtype, but I/O functions not set up yet
+ * is_rowtype can be: -1 not known yet (initial state) 0 scalar datatype
+ * 1 rowtype 2 rowtype, but I/O functions not set up yet
*/
} PLyTypeInfo;
@@ -133,8 +133,8 @@ typedef struct PLyProcedure
TransactionId fn_xmin;
CommandId fn_cmin;
bool fn_readonly;
- PLyTypeInfo result; /* also used to store info for trigger
- * tuple type */
+ PLyTypeInfo result; /* also used to store info for trigger tuple
+ * type */
PLyTypeInfo args[FUNC_MAX_ARGS];
int nargs;
PyObject *code; /* compiled procedure code */
@@ -340,7 +340,7 @@ plpython_call_handler(PG_FUNCTION_ARGS)
HeapTuple trv;
proc = PLy_procedure_get(fcinfo,
- RelationGetRelid(tdata->tg_relation));
+ RelationGetRelid(tdata->tg_relation));
PLy_curr_procedure = proc;
trv = PLy_trigger_handler(fcinfo, proc);
retval = PointerGetDatum(trv);
@@ -430,8 +430,8 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
{
/*
* hmmm, perhaps they only read the pltcl page, not a
- * surprising thing since i've written no documentation,
- * so accept a belated OK
+ * surprising thing since i've written no documentation, so
+ * accept a belated OK
*/
elog(ERROR, "expected return to be \"SKIP\" or \"MODIFY\"");
}
@@ -523,8 +523,8 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
modvalues[i] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc,
CStringGetDatum(src),
- ObjectIdGetDatum(proc->result.out.r.atts[atti].typioparam),
- Int32GetDatum(tupdesc->attrs[atti]->atttypmod));
+ ObjectIdGetDatum(proc->result.out.r.atts[atti].typioparam),
+ Int32GetDatum(tupdesc->attrs[atti]->atttypmod));
modnulls[i] = ' ';
Py_DECREF(plstr);
@@ -600,7 +600,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
Py_DECREF(pltname);
stroid = DatumGetCString(DirectFunctionCall1(oidout,
- ObjectIdGetDatum(tdata->tg_relation->rd_id)));
+ ObjectIdGetDatum(tdata->tg_relation->rd_id)));
pltrelid = PyString_FromString(stroid);
PyDict_SetItemString(pltdata, "relid", pltrelid);
Py_DECREF(pltrelid);
@@ -756,10 +756,10 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
Assert(!PLy_error_in_progress);
/*
- * Disconnect from SPI manager and then create the return values
- * datum (if the input function does a palloc for it this must not
- * be allocated in the SPI memory context because SPI_finish would
- * free it).
+ * Disconnect from SPI manager and then create the return values datum
+ * (if the input function does a palloc for it this must not be
+ * allocated in the SPI memory context because SPI_finish would free
+ * it).
*/
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed");
@@ -781,7 +781,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
plrv_sc = PyString_AsString(plrv_so);
rv = FunctionCall3(&proc->result.out.d.typfunc,
PointerGetDatum(plrv_sc),
- ObjectIdGetDatum(proc->result.out.d.typioparam),
+ ObjectIdGetDatum(proc->result.out.d.typioparam),
Int32GetDatum(-1));
}
@@ -813,8 +813,8 @@ PLy_procedure_call(PLyProcedure * proc, char *kargs, PyObject * vargs)
proc->globals, proc->globals);
/*
- * If there was an error in a PG callback, propagate that no matter
- * what Python claims about its success.
+ * If there was an error in a PG callback, propagate that no matter what
+ * Python claims about its success.
*/
if (PLy_error_in_progress)
{
@@ -885,7 +885,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
dt = FunctionCall3(&(proc->args[i].in.d.typfunc),
fcinfo->arg[i],
- ObjectIdGetDatum(proc->args[i].in.d.typioparam),
+ ObjectIdGetDatum(proc->args[i].in.d.typioparam),
Int32GetDatum(-1));
ct = DatumGetCString(dt);
arg = (proc->args[i].in.d.func) (ct);
@@ -1025,8 +1025,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
PG_TRY();
{
/*
- * get information required for output conversion of the return
- * value, but only if this isn't a trigger.
+ * get information required for output conversion of the return value,
+ * but only if this isn't a trigger.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
{
@@ -1034,7 +1034,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
Form_pg_type rvTypeStruct;
rvTypeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->prorettype),
+ ObjectIdGetDatum(procStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(rvTypeTup))
elog(ERROR, "cache lookup failed for type %u",
@@ -1051,14 +1051,14 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("plpython functions cannot return type %s",
- format_type_be(procStruct->prorettype))));
+ errmsg("plpython functions cannot return type %s",
+ format_type_be(procStruct->prorettype))));
}
if (rvTypeStruct->typtype == 'c')
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("plpython functions cannot return tuples yet")));
+ errmsg("plpython functions cannot return tuples yet")));
else
PLy_output_datum_func(&proc->result, rvTypeTup);
@@ -1077,8 +1077,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
}
/*
- * now get information required for input conversion of the
- * procedures arguments.
+ * now get information required for input conversion of the procedures
+ * arguments.
*/
proc->nargs = fcinfo->nargs;
for (i = 0; i < fcinfo->nargs; i++)
@@ -1087,7 +1087,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
Form_pg_type argTypeStruct;
argTypeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->proargtypes.values[i]),
+ ObjectIdGetDatum(procStruct->proargtypes.values[i]),
0, 0, 0);
if (!HeapTupleIsValid(argTypeTup))
elog(ERROR, "cache lookup failed for type %u",
@@ -1099,15 +1099,14 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpython functions cannot take type %s",
- format_type_be(procStruct->proargtypes.values[i]))));
+ format_type_be(procStruct->proargtypes.values[i]))));
if (argTypeStruct->typtype != 'c')
PLy_input_datum_func(&(proc->args[i]),
procStruct->proargtypes.values[i],
argTypeTup);
else
- proc->args[i].is_rowtype = 2; /* still need to set I/O
- * funcs */
+ proc->args[i].is_rowtype = 2; /* still need to set I/O funcs */
ReleaseSysCache(argTypeTup);
}
@@ -1152,8 +1151,8 @@ PLy_procedure_compile(PLyProcedure * proc, const char *src)
proc->globals = PyDict_Copy(PLy_interp_globals);
/*
- * SD is private preserved data between calls GD is global data shared
- * by all functions
+ * SD is private preserved data between calls GD is global data shared by
+ * all functions
*/
proc->statics = PyDict_New();
PyDict_SetItemString(proc->globals, "SD", proc->statics);
@@ -1279,7 +1278,7 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
continue;
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(desc->attrs[i]->atttypid),
+ ObjectIdGetDatum(desc->attrs[i]->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u",
@@ -1313,7 +1312,7 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
continue;
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(desc->attrs[i]->atttypid),
+ ObjectIdGetDatum(desc->attrs[i]->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u",
@@ -1492,8 +1491,8 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
{
vdat = FunctionCall3(&info->in.r.atts[i].typfunc,
vattr,
- ObjectIdGetDatum(info->in.r.atts[i].typioparam),
- Int32GetDatum(desc->attrs[i]->atttypmod));
+ ObjectIdGetDatum(info->in.r.atts[i].typioparam),
+ Int32GetDatum(desc->attrs[i]->atttypmod));
vsrc = DatumGetCString(vdat);
/*
@@ -1864,7 +1863,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
if ((list) && (!PySequence_Check(list)))
{
PyErr_SetString(PLy_exc_spi_error,
- "Second argument in plpy.prepare() must be a sequence");
+ "Second argument in plpy.prepare() must be a sequence");
return NULL;
}
@@ -1889,8 +1888,8 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
/*
* the other loop might throw an exception, if PLyTypeInfo
- * member isn't properly initialized the Py_DECREF(plan)
- * will go boom
+ * member isn't properly initialized the Py_DECREF(plan) will
+ * go boom
*/
for (i = 0; i < nargs; i++)
{
@@ -1910,8 +1909,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
sptr = PyString_AsString(optr);
/*
- * XXX should extend this to allow qualified type
- * names
+ * XXX should extend this to allow qualified type names
*/
typeTup = typenameType(makeTypeName(sptr));
Py_DECREF(optr);
@@ -2023,6 +2021,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
char *sv;
PyObject *so = PyObject_Str(list);
+
if (!so)
PLy_elog(ERROR, "function \"%s\" could not execute plan",
PLy_procedure_name(PLy_curr_procedure));
@@ -2061,7 +2060,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
plan->values[i] =
FunctionCall3(&(plan->args[i].out.d.typfunc),
CStringGetDatum(sv),
- ObjectIdGetDatum(plan->args[i].out.d.typioparam),
+ ObjectIdGetDatum(plan->args[i].out.d.typioparam),
Int32GetDatum(-1));
Py_DECREF(so);
@@ -2210,7 +2209,7 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status)
for (i = 0; i < rows; i++)
{
PyObject *row = PLyDict_FromTuple(&args, tuptable->vals[i],
- tuptable->tupdesc);
+ tuptable->tupdesc);
PyList_SetItem(result->rows, i, row);
}
@@ -2226,7 +2225,7 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status)
FlushErrorState();
if (!PyErr_Occurred())
PyErr_SetString(PLy_exc_error,
- "Unknown error in PLy_spi_execute_fetch_result");
+ "Unknown error in PLy_spi_execute_fetch_result");
Py_DECREF(result);
PLy_typeinfo_dealloc(&args);
return NULL;
@@ -2428,8 +2427,7 @@ PLy_output(volatile int level, PyObject * self, PyObject * args)
Py_XDECREF(so);
/*
- * return a legal object so the interpreter will continue on its merry
- * way
+ * return a legal object so the interpreter will continue on its merry way
*/
Py_INCREF(Py_None);
return Py_None;
@@ -2541,10 +2539,10 @@ PLy_traceback(int *xlevel)
vstr = "Unknown";
/*
- * I'm not sure what to do if eob is NULL here -- we can't call
- * PLy_elog because that function calls us, so we could end up
- * with infinite recursion. I'm not even sure if eob could be
- * NULL here -- would an Assert() be more appropriate?
+ * I'm not sure what to do if eob is NULL here -- we can't call PLy_elog
+ * because that function calls us, so we could end up with infinite
+ * recursion. I'm not even sure if eob could be NULL here -- would an
+ * Assert() be more appropriate?
*/
estr = eob ? PyString_AsString(eob) : "Unknown Exception";
xstr = PLy_printf("%s: %s", estr, vstr);
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 98cc0cf8329..fe4e9f030ec 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.97 2005/05/06 17:24:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.98 2005/10/15 02:49:50 momjian Exp $
*
**********************************************************************/
@@ -88,14 +88,12 @@ utf_e2u(unsigned char *src)
pfree(_pltcl_utf_dst); } while (0)
#define UTF_U2E(x) (_pltcl_utf_dst=utf_u2e(_pltcl_utf_src=(x)))
#define UTF_E2U(x) (_pltcl_utf_dst=utf_e2u(_pltcl_utf_src=(x)))
-
#else /* !PLTCL_UTF */
#define UTF_BEGIN
#define UTF_END
#define UTF_U2E(x) (x)
#define UTF_E2U(x) (x)
-
#endif /* PLTCL_UTF */
@@ -114,7 +112,7 @@ typedef struct pltcl_proc_desc
int nargs;
FmgrInfo arg_out_func[FUNC_MAX_ARGS];
bool arg_is_rowtype[FUNC_MAX_ARGS];
-} pltcl_proc_desc;
+} pltcl_proc_desc;
/**********************************************************************
@@ -128,7 +126,7 @@ typedef struct pltcl_query_desc
Oid *argtypes;
FmgrInfo *arginfuncs;
Oid *argtypioparams;
-} pltcl_query_desc;
+} pltcl_query_desc;
/**********************************************************************
@@ -151,9 +149,9 @@ static pltcl_proc_desc *pltcl_current_prodesc = NULL;
* Forward declarations
**********************************************************************/
static void pltcl_init_all(void);
-static void pltcl_init_interp(Tcl_Interp *interp);
+static void pltcl_init_interp(Tcl_Interp * interp);
-static void pltcl_init_load_unknown(Tcl_Interp *interp);
+static void pltcl_init_load_unknown(Tcl_Interp * interp);
Datum pltcl_call_handler(PG_FUNCTION_ARGS);
Datum pltclu_call_handler(PG_FUNCTION_ARGS);
@@ -165,34 +163,34 @@ static HeapTuple pltcl_trigger_handler(PG_FUNCTION_ARGS);
static pltcl_proc_desc *compile_pltcl_function(Oid fn_oid, Oid tgreloid);
-static int pltcl_elog(ClientData cdata, Tcl_Interp *interp,
+static int pltcl_elog(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[]);
-static int pltcl_quote(ClientData cdata, Tcl_Interp *interp,
+static int pltcl_quote(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[]);
-static int pltcl_argisnull(ClientData cdata, Tcl_Interp *interp,
+static int pltcl_argisnull(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[]);
-static int pltcl_returnnull(ClientData cdata, Tcl_Interp *interp,
+static int pltcl_returnnull(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[]);
-static int pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp,
- int argc, CONST84 char *argv[]);
-static int pltcl_process_SPI_result(Tcl_Interp *interp,
- CONST84 char *arrayname,
- CONST84 char *loop_body,
- int spi_rc,
- SPITupleTable *tuptable,
- int ntuples);
-static int pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
+static int pltcl_SPI_execute(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[]);
-static int pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
- int argc, CONST84 char *argv[]);
-static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
+static int pltcl_process_SPI_result(Tcl_Interp * interp,
+ CONST84 char *arrayname,
+ CONST84 char *loop_body,
+ int spi_rc,
+ SPITupleTable *tuptable,
+ int ntuples);
+static int pltcl_SPI_prepare(ClientData cdata, Tcl_Interp * interp,
+ int argc, CONST84 char *argv[]);
+static int pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp * interp,
+ int argc, CONST84 char *argv[]);
+static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[]);
-static void pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
+static void pltcl_set_tuple_values(Tcl_Interp * interp, CONST84 char *arrayname,
int tupno, HeapTuple tuple, TupleDesc tupdesc);
static void pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
- Tcl_DString *retval);
+ Tcl_DString * retval);
/*
@@ -298,7 +296,7 @@ pltcl_init_all(void)
* pltcl_init_interp() - initialize a Tcl interpreter
**********************************************************************/
static void
-pltcl_init_interp(Tcl_Interp *interp)
+pltcl_init_interp(Tcl_Interp * interp)
{
/************************************************************
* Install the commands for SPI support in the interpreter
@@ -328,7 +326,7 @@ pltcl_init_interp(Tcl_Interp *interp)
* table pltcl_modules (if it exists)
**********************************************************************/
static void
-pltcl_init_load_unknown(Tcl_Interp *interp)
+pltcl_init_load_unknown(Tcl_Interp * interp)
{
int spi_rc;
int tcl_rc;
@@ -429,8 +427,8 @@ pltcl_call_handler(PG_FUNCTION_ARGS)
PG_TRY();
{
/*
- * Determine if called as function or trigger and
- * call appropriate subhandler
+ * Determine if called as function or trigger and call appropriate
+ * subhandler
*/
if (CALLED_AS_TRIGGER(fcinfo))
{
@@ -615,7 +613,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
UTF_BEGIN;
retval = FunctionCall3(&prodesc->result_in_func,
PointerGetDatum(UTF_U2E(interp->result)),
- ObjectIdGetDatum(prodesc->result_typioparam),
+ ObjectIdGetDatum(prodesc->result_typioparam),
Int32GetDatum(-1));
UTF_END;
}
@@ -653,7 +651,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
/* Find or compile the function */
prodesc = compile_pltcl_function(fcinfo->flinfo->fn_oid,
- RelationGetRelid(trigdata->tg_relation));
+ RelationGetRelid(trigdata->tg_relation));
pltcl_current_prodesc = prodesc;
@@ -681,7 +679,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);
@@ -693,7 +691,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
Tcl_DStringAppendElement(&tcl_trigtup, "");
else
Tcl_DStringAppendElement(&tcl_trigtup,
- NameStr(tupdesc->attrs[i]->attname));
+ NameStr(tupdesc->attrs[i]->attname));
}
Tcl_DStringAppendElement(&tcl_cmd, Tcl_DStringValue(&tcl_trigtup));
Tcl_DStringFree(&tcl_trigtup);
@@ -717,8 +715,8 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
tupdesc, &tcl_trigtup);
/*
- * Now the command part of the event for TG_op and data for
- * NEW and OLD
+ * Now the command part of the event for TG_op and data for NEW
+ * and OLD
*/
if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event))
{
@@ -887,7 +885,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
* for the input function
************************************************************/
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid),
+ ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u",
@@ -906,7 +904,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
FunctionCall3(&finfo,
CStringGetDatum(UTF_U2E(ret_value)),
ObjectIdGetDatum(typioparam),
- Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod));
+ Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod));
UTF_END;
}
@@ -988,7 +986,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
prodesc = (pltcl_proc_desc *) Tcl_GetHashValue(hashent);
uptodate = (prodesc->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) &&
- prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data));
+ prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data));
if (!uptodate)
{
@@ -1065,7 +1063,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
if (!is_trigger)
{
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->prorettype),
+ ObjectIdGetDatum(procStruct->prorettype),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
@@ -1095,8 +1093,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("pltcl functions cannot return type %s",
- format_type_be(procStruct->prorettype))));
+ errmsg("pltcl functions cannot return type %s",
+ format_type_be(procStruct->prorettype))));
}
}
@@ -1106,7 +1104,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("pltcl functions cannot return tuples yet")));
+ errmsg("pltcl functions cannot return tuples yet")));
}
perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
@@ -1126,7 +1124,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
for (i = 0; i < prodesc->nargs; i++)
{
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(procStruct->proargtypes.values[i]),
+ ObjectIdGetDatum(procStruct->proargtypes.values[i]),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
{
@@ -1145,7 +1143,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("pltcl functions cannot take type %s",
- format_type_be(procStruct->proargtypes.values[i]))));
+ format_type_be(procStruct->proargtypes.values[i]))));
}
if (typeStruct->typtype == 'c')
@@ -1272,7 +1270,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
* pltcl_elog() - elog() support for PLTcl
**********************************************************************/
static int
-pltcl_elog(ClientData cdata, Tcl_Interp *interp,
+pltcl_elog(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[])
{
volatile int level;
@@ -1344,7 +1342,7 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
* be used in SPI_execute query strings
**********************************************************************/
static int
-pltcl_quote(ClientData cdata, Tcl_Interp *interp,
+pltcl_quote(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[])
{
char *tmp;
@@ -1397,7 +1395,7 @@ pltcl_quote(ClientData cdata, Tcl_Interp *interp,
* pltcl_argisnull() - determine if a specific argument is NULL
**********************************************************************/
static int
-pltcl_argisnull(ClientData cdata, Tcl_Interp *interp,
+pltcl_argisnull(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[])
{
int argno;
@@ -1454,7 +1452,7 @@ pltcl_argisnull(ClientData cdata, Tcl_Interp *interp,
* pltcl_returnnull() - Cause a NULL return from a function
**********************************************************************/
static int
-pltcl_returnnull(ClientData cdata, Tcl_Interp *interp,
+pltcl_returnnull(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[])
{
FunctionCallInfo fcinfo = pltcl_current_fcinfo;
@@ -1530,14 +1528,14 @@ pltcl_subtrans_commit(MemoryContext oldcontext, ResourceOwner oldowner)
CurrentResourceOwner = oldowner;
/*
- * AtEOSubXact_SPI() should not have popped any SPI context,
- * but just in case it did, make sure we remain connected.
+ * AtEOSubXact_SPI() should not have popped any SPI context, but just in
+ * case it did, make sure we remain connected.
*/
SPI_restore_connection();
}
static void
-pltcl_subtrans_abort(Tcl_Interp *interp,
+pltcl_subtrans_abort(Tcl_Interp * interp,
MemoryContext oldcontext, ResourceOwner oldowner)
{
ErrorData *edata;
@@ -1553,9 +1551,9 @@ pltcl_subtrans_abort(Tcl_Interp *interp,
CurrentResourceOwner = oldowner;
/*
- * If AtEOSubXact_SPI() popped any SPI context of the subxact,
- * it will have left us in a disconnected state. We need this
- * hack to return to connected state.
+ * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will
+ * have left us in a disconnected state. We need this hack to return to
+ * connected state.
*/
SPI_restore_connection();
@@ -1570,7 +1568,7 @@ pltcl_subtrans_abort(Tcl_Interp *interp,
* for the Tcl interpreter
**********************************************************************/
static int
-pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp,
+pltcl_SPI_execute(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[])
{
int my_rc;
@@ -1673,7 +1671,7 @@ pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp,
* Shared code between pltcl_SPI_execute and pltcl_SPI_execute_plan
*/
static int
-pltcl_process_SPI_result(Tcl_Interp *interp,
+pltcl_process_SPI_result(Tcl_Interp * interp,
CONST84 char *arrayname,
CONST84 char *loop_body,
int spi_rc,
@@ -1702,6 +1700,7 @@ pltcl_process_SPI_result(Tcl_Interp *interp,
break;
case SPI_OK_SELECT:
+
/*
* Process the tuples we got
*/
@@ -1711,8 +1710,8 @@ pltcl_process_SPI_result(Tcl_Interp *interp,
if (loop_body == NULL)
{
/*
- * If there is no loop body given, just set the variables
- * from the first tuple (if any)
+ * If there is no loop body given, just set the variables from
+ * the first tuple (if any)
*/
if (ntuples > 0)
pltcl_set_tuple_values(interp, arrayname, 0,
@@ -1721,8 +1720,8 @@ pltcl_process_SPI_result(Tcl_Interp *interp,
else
{
/*
- * There is a loop body - process all tuples and evaluate
- * the body on each
+ * There is a loop body - process all tuples and evaluate the
+ * body on each
*/
for (i = 0; i < ntuples; i++)
{
@@ -1776,7 +1775,7 @@ pltcl_process_SPI_result(Tcl_Interp *interp,
* and not save the plan currently.
**********************************************************************/
static int
-pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
+pltcl_SPI_prepare(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[])
{
int nargs;
@@ -1921,7 +1920,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
* pltcl_SPI_execute_plan() - Execute a prepared plan
**********************************************************************/
static int
-pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
+pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[])
{
int my_rc;
@@ -2017,7 +2016,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
if (strlen(nulls) != qdesc->nargs)
{
Tcl_SetResult(interp,
- "length of nulls string doesn't match # of arguments",
+ "length of nulls string doesn't match # of arguments",
TCL_VOLATILE);
return TCL_ERROR;
}
@@ -2047,7 +2046,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
if (callnargs != qdesc->nargs)
{
Tcl_SetResult(interp,
- "argument list length doesn't match # of arguments for query",
+ "argument list length doesn't match # of arguments for query",
TCL_VOLATILE);
ckfree((char *) callargs);
return TCL_ERROR;
@@ -2141,7 +2140,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
* be used after insert queries
**********************************************************************/
static int
-pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
+pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp * interp,
int argc, CONST84 char *argv[])
{
char buf[64];
@@ -2157,7 +2156,7 @@ pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
* of a given tuple
**********************************************************************/
static void
-pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
+pltcl_set_tuple_values(Tcl_Interp * interp, CONST84 char *arrayname,
int tupno, HeapTuple tuple, TupleDesc tupdesc)
{
int i;
@@ -2212,7 +2211,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
* for the output function
************************************************************/
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
+ ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u",
@@ -2250,7 +2249,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
**********************************************************************/
static void
pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
- Tcl_DString *retval)
+ Tcl_DString * retval)
{
int i;
char *outputstr;
@@ -2282,7 +2281,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
* for the output function
************************************************************/
typeTup = SearchSysCache(TYPEOID,
- ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
+ ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u",