summaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
authorBruce Momjian2006-10-04 00:30:14 +0000
committerBruce Momjian2006-10-04 00:30:14 +0000
commitf99a569a2ee3763b4ae174e81250c95ca0fdcbb6 (patch)
tree76e6371fe8b347c73d7020c0bc54b9fba519dc10 /src/pl
parent451e419e9852cdf9d7e7cefc09d5355abb3405e9 (diff)
pgindent run for 8.2.
Diffstat (limited to 'src/pl')
-rw-r--r--src/pl/plperl/plperl.c334
-rw-r--r--src/pl/plperl/plperl.h20
-rw-r--r--src/pl/plpgsql/src/pl_comp.c6
-rw-r--r--src/pl/plpgsql/src/pl_exec.c99
-rw-r--r--src/pl/plpgsql/src/pl_handler.c4
-rw-r--r--src/pl/plpgsql/src/plpgsql.h41
-rw-r--r--src/pl/plpython/plpython.c200
-rw-r--r--src/pl/tcl/pltcl.c20
8 files changed, 370 insertions, 354 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 0906d3186ac..d683e42cf54 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1,7 +1,7 @@
/**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.118 2006/08/27 23:47:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.119 2006/10/04 00:30:13 momjian Exp $
*
**********************************************************************/
@@ -64,11 +64,11 @@ typedef struct plperl_proc_desc
typedef struct plperl_call_data
{
plperl_proc_desc *prodesc;
- FunctionCallInfo fcinfo;
- Tuplestorestate *tuple_store;
- TupleDesc ret_tdesc;
- AttInMetadata *attinmeta;
- MemoryContext tmp_cxt;
+ FunctionCallInfo fcinfo;
+ Tuplestorestate *tuple_store;
+ TupleDesc ret_tdesc;
+ AttInMetadata *attinmeta;
+ MemoryContext tmp_cxt;
} plperl_call_data;
/**********************************************************************
@@ -244,13 +244,13 @@ plperl_init_interp(void)
#ifdef WIN32
- /*
+ /*
* The perl library on startup does horrible things like call
- * setlocale(LC_ALL,""). We have protected against that on most
- * platforms by setting the environment appropriately. However, on
- * Windows, setlocale() does not consult the environment, so we need
- * to save the existing locale settings before perl has a chance to
- * mangle them and restore them after its dirty deeds are done.
+ * setlocale(LC_ALL,""). We have protected against that on most platforms
+ * by setting the environment appropriately. However, on Windows,
+ * setlocale() does not consult the environment, so we need to save the
+ * existing locale settings before perl has a chance to mangle them and
+ * restore them after its dirty deeds are done.
*
* MSDN ref:
* http://msdn.microsoft.com/library/en-us/vclib/html/_crt_locale.asp
@@ -259,26 +259,29 @@ plperl_init_interp(void)
* subsequent calls to the interpreter don't mess with the locale
* settings.
*
- * We restore them using Perl's POSIX::setlocale() function so that
- * Perl doesn't have a different idea of the locale from Postgres.
+ * We restore them using Perl's POSIX::setlocale() function so that Perl
+ * doesn't have a different idea of the locale from Postgres.
*
*/
- char *loc;
- char *save_collate, *save_ctype, *save_monetary, *save_numeric, *save_time;
- char buf[1024];
+ char *loc;
+ char *save_collate,
+ *save_ctype,
+ *save_monetary,
+ *save_numeric,
+ *save_time;
+ char buf[1024];
- loc = setlocale(LC_COLLATE,NULL);
+ loc = setlocale(LC_COLLATE, NULL);
save_collate = loc ? pstrdup(loc) : NULL;
- loc = setlocale(LC_CTYPE,NULL);
+ loc = setlocale(LC_CTYPE, NULL);
save_ctype = loc ? pstrdup(loc) : NULL;
- loc = setlocale(LC_MONETARY,NULL);
+ loc = setlocale(LC_MONETARY, NULL);
save_monetary = loc ? pstrdup(loc) : NULL;
- loc = setlocale(LC_NUMERIC,NULL);
+ loc = setlocale(LC_NUMERIC, NULL);
save_numeric = loc ? pstrdup(loc) : NULL;
- loc = setlocale(LC_TIME,NULL);
+ loc = setlocale(LC_TIME, NULL);
save_time = loc ? pstrdup(loc) : NULL;
-
#endif
plperl_interp = perl_alloc();
@@ -294,44 +297,43 @@ plperl_init_interp(void)
#ifdef WIN32
- eval_pv("use POSIX qw(locale_h);", TRUE); /* croak on failure */
+ eval_pv("use POSIX qw(locale_h);", TRUE); /* croak on failure */
if (save_collate != NULL)
{
- snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
- "LC_COLLATE",save_collate);
- eval_pv(buf,TRUE);
+ snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+ "LC_COLLATE", save_collate);
+ eval_pv(buf, TRUE);
pfree(save_collate);
}
if (save_ctype != NULL)
{
- snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
- "LC_CTYPE",save_ctype);
- eval_pv(buf,TRUE);
+ snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+ "LC_CTYPE", save_ctype);
+ eval_pv(buf, TRUE);
pfree(save_ctype);
}
if (save_monetary != NULL)
{
- snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
- "LC_MONETARY",save_monetary);
- eval_pv(buf,TRUE);
+ snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+ "LC_MONETARY", save_monetary);
+ eval_pv(buf, TRUE);
pfree(save_monetary);
}
if (save_numeric != NULL)
{
- snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
- "LC_NUMERIC",save_numeric);
- eval_pv(buf,TRUE);
+ snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+ "LC_NUMERIC", save_numeric);
+ eval_pv(buf, TRUE);
pfree(save_numeric);
}
if (save_time != NULL)
{
- snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
- "LC_TIME",save_time);
- eval_pv(buf,TRUE);
+ snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+ "LC_TIME", save_time);
+ eval_pv(buf, TRUE);
pfree(save_time);
}
-
#endif
}
@@ -1011,8 +1013,8 @@ plperl_func_handler(PG_FUNCTION_ARGS)
SV *array_ret = NULL;
/*
- * Create the call_data beforing connecting to SPI, so that it is
- * not allocated in the SPI memory context
+ * Create the call_data beforing connecting to SPI, so that it is not
+ * allocated in the SPI memory context
*/
current_call_data = (plperl_call_data *) palloc0(sizeof(plperl_call_data));
current_call_data->fcinfo = fcinfo;
@@ -1160,8 +1162,8 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
HV *hvTD;
/*
- * Create the call_data beforing connecting to SPI, so that it is
- * not allocated in the SPI memory context
+ * Create the call_data beforing connecting to SPI, so that it is not
+ * allocated in the SPI memory context
*/
current_call_data = (plperl_call_data *) palloc0(sizeof(plperl_call_data));
current_call_data->fcinfo = fcinfo;
@@ -1285,7 +1287,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{
bool uptodate;
- prodesc = INT2PTR( plperl_proc_desc *, SvUV(*svp));
+ prodesc = INT2PTR(plperl_proc_desc *, SvUV(*svp));
/************************************************************
* If it's present, must check whether it's still up to date.
@@ -1483,7 +1485,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
}
hv_store(plperl_proc_hash, internal_proname, proname_len,
- newSVuv( PTR2UV( prodesc)), 0);
+ newSVuv(PTR2UV(prodesc)), 0);
}
ReleaseSysCache(procTup);
@@ -1690,14 +1692,14 @@ plperl_return_next(SV *sv)
if (!current_call_data->ret_tdesc)
{
- TupleDesc tupdesc;
+ TupleDesc tupdesc;
Assert(!current_call_data->tuple_store);
Assert(!current_call_data->attinmeta);
/*
- * This is the first call to return_next in the current
- * PL/Perl function call, so memoize some lookups
+ * This is the first call to return_next in the current PL/Perl
+ * function call, so memoize some lookups
*/
if (prodesc->fn_retistuple)
(void) get_call_result_type(fcinfo, NULL, &tupdesc);
@@ -1720,14 +1722,13 @@ plperl_return_next(SV *sv)
}
MemoryContextSwitchTo(old_cxt);
- }
+ }
/*
* Producing the tuple we want to return requires making plenty of
- * palloc() allocations that are not cleaned up. Since this
- * function can be called many times before the current memory
- * context is reset, we need to do those allocations in a
- * temporary context.
+ * palloc() allocations that are not cleaned up. Since this function can
+ * be called many times before the current memory context is reset, we
+ * need to do those allocations in a temporary context.
*/
if (!current_call_data->tmp_cxt)
{
@@ -1801,15 +1802,15 @@ plperl_spi_query(char *query)
/* Create a cursor for the query */
plan = SPI_prepare(query, 0, NULL);
- if ( plan == NULL)
+ if (plan == NULL)
elog(ERROR, "SPI_prepare() failed:%s",
- SPI_result_code_string(SPI_result));
+ SPI_result_code_string(SPI_result));
portal = SPI_cursor_open(NULL, plan, NULL, NULL, false);
- SPI_freeplan( plan);
- if ( portal == NULL)
+ SPI_freeplan(plan);
+ if (portal == NULL)
elog(ERROR, "SPI_cursor_open() failed:%s",
- SPI_result_code_string(SPI_result));
+ SPI_result_code_string(SPI_result));
cursor = newSVpv(portal->name, 0);
/* Commit the inner transaction, return to outer xact context */
@@ -1942,13 +1943,14 @@ plperl_spi_fetchrow(char *cursor)
void
plperl_spi_cursor_close(char *cursor)
{
- Portal p = SPI_cursor_find(cursor);
+ Portal p = SPI_cursor_find(cursor);
+
if (p)
SPI_cursor_close(p);
}
SV *
-plperl_spi_prepare(char* query, int argc, SV ** argv)
+plperl_spi_prepare(char *query, int argc, SV **argv)
{
plperl_query_desc *qdesc;
void *plan;
@@ -1965,11 +1967,11 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
************************************************************/
qdesc = (plperl_query_desc *) malloc(sizeof(plperl_query_desc));
MemSet(qdesc, 0, sizeof(plperl_query_desc));
- snprintf(qdesc-> qname, sizeof(qdesc-> qname), "%lx", (long) qdesc);
- qdesc-> nargs = argc;
- qdesc-> argtypes = (Oid *) malloc(argc * sizeof(Oid));
- qdesc-> arginfuncs = (FmgrInfo *) malloc(argc * sizeof(FmgrInfo));
- qdesc-> argtypioparams = (Oid *) malloc(argc * sizeof(Oid));
+ snprintf(qdesc->qname, sizeof(qdesc->qname), "%lx", (long) qdesc);
+ qdesc->nargs = argc;
+ qdesc->argtypes = (Oid *) malloc(argc * sizeof(Oid));
+ qdesc->arginfuncs = (FmgrInfo *) malloc(argc * sizeof(FmgrInfo));
+ qdesc->argtypioparams = (Oid *) malloc(argc * sizeof(Oid));
PG_TRY();
{
@@ -2000,7 +2002,7 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
if (plan == NULL)
elog(ERROR, "SPI_prepare() failed:%s",
- SPI_result_code_string(SPI_result));
+ SPI_result_code_string(SPI_result));
/************************************************************
* Save the plan into permanent memory (right now it's in the
@@ -2008,8 +2010,8 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
************************************************************/
qdesc->plan = SPI_saveplan(plan);
if (qdesc->plan == NULL)
- elog(ERROR, "SPI_saveplan() failed: %s",
- SPI_result_code_string(SPI_result));
+ elog(ERROR, "SPI_saveplan() failed: %s",
+ SPI_result_code_string(SPI_result));
/* Release the procCxt copy to avoid within-function memory leak */
SPI_freeplan(plan);
@@ -2018,19 +2020,20 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
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();
}
PG_CATCH();
{
ErrorData *edata;
-
- free(qdesc-> argtypes);
- free(qdesc-> arginfuncs);
- free(qdesc-> argtypioparams);
+
+ free(qdesc->argtypes);
+ free(qdesc->arginfuncs);
+ free(qdesc->argtypioparams);
free(qdesc);
/* Save error info */
@@ -2044,9 +2047,9 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
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();
@@ -2062,24 +2065,26 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
* Insert a hashtable entry for the plan and return
* the key to the caller.
************************************************************/
- hv_store( plperl_query_hash, qdesc->qname, strlen(qdesc->qname), newSVuv( PTR2UV( qdesc)), 0);
+ hv_store(plperl_query_hash, qdesc->qname, strlen(qdesc->qname), newSVuv(PTR2UV(qdesc)), 0);
- return newSVpv( qdesc->qname, strlen(qdesc->qname));
-}
+ return newSVpv(qdesc->qname, strlen(qdesc->qname));
+}
HV *
-plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
+plperl_spi_exec_prepared(char *query, HV *attr, int argc, SV **argv)
{
HV *ret_hv;
- SV **sv;
- int i, limit, spi_rv;
- char * nulls;
+ SV **sv;
+ int i,
+ limit,
+ spi_rv;
+ char *nulls;
Datum *argvalues;
plperl_query_desc *qdesc;
/*
- * 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;
@@ -2094,54 +2099,54 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
* Fetch the saved plan descriptor, see if it's o.k.
************************************************************/
sv = hv_fetch(plperl_query_hash, query, strlen(query), 0);
- if ( sv == NULL)
+ if (sv == NULL)
elog(ERROR, "spi_exec_prepared: Invalid prepared query passed");
- if ( *sv == NULL || !SvOK( *sv))
+ if (*sv == NULL || !SvOK(*sv))
elog(ERROR, "spi_exec_prepared: panic - plperl_query_hash value corrupted");
- qdesc = INT2PTR( plperl_query_desc *, SvUV(*sv));
- if ( qdesc == NULL)
+ qdesc = INT2PTR(plperl_query_desc *, SvUV(*sv));
+ if (qdesc == NULL)
elog(ERROR, "spi_exec_prepared: panic - plperl_query_hash value vanished");
- if ( qdesc-> nargs != argc)
- elog(ERROR, "spi_exec_prepared: expected %d argument(s), %d passed",
- qdesc-> nargs, argc);
-
+ if (qdesc->nargs != argc)
+ elog(ERROR, "spi_exec_prepared: expected %d argument(s), %d passed",
+ qdesc->nargs, argc);
+
/************************************************************
* Parse eventual attributes
************************************************************/
limit = 0;
- if ( attr != NULL)
+ if (attr != NULL)
{
- sv = hv_fetch( attr, "limit", 5, 0);
- if ( *sv && SvIOK( *sv))
- limit = SvIV( *sv);
+ sv = hv_fetch(attr, "limit", 5, 0);
+ if (*sv && SvIOK(*sv))
+ limit = SvIV(*sv);
}
/************************************************************
* Set up arguments
************************************************************/
- if (argc > 0)
+ if (argc > 0)
{
nulls = (char *) palloc(argc);
argvalues = (Datum *) palloc(argc * sizeof(Datum));
- }
- else
+ }
+ else
{
nulls = NULL;
argvalues = NULL;
}
- for (i = 0; i < argc; i++)
+ for (i = 0; i < argc; i++)
{
- if (SvTYPE(argv[i]) != SVt_NULL)
+ if (SvTYPE(argv[i]) != SVt_NULL)
{
argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
SvPV(argv[i], PL_na),
qdesc->argtypioparams[i],
-1);
nulls[i] = ' ';
- }
- else
+ }
+ else
{
argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
NULL,
@@ -2154,23 +2159,24 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
/************************************************************
* go
************************************************************/
- spi_rv = SPI_execute_plan(qdesc-> plan, argvalues, nulls,
+ spi_rv = SPI_execute_plan(qdesc->plan, argvalues, nulls,
current_call_data->prodesc->fn_readonly, limit);
ret_hv = plperl_spi_execute_fetch_result(SPI_tuptable, SPI_processed,
spi_rv);
- if ( argc > 0)
+ if (argc > 0)
{
- pfree( argvalues);
- pfree( nulls);
+ pfree(argvalues);
+ pfree(nulls);
}
/* Commit the inner transaction, return to outer xact context */
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();
}
@@ -2189,9 +2195,9 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
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();
@@ -2207,19 +2213,19 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
}
SV *
-plperl_spi_query_prepared(char* query, int argc, SV ** argv)
+plperl_spi_query_prepared(char *query, int argc, SV **argv)
{
- SV **sv;
- int i;
- char * nulls;
+ SV **sv;
+ int i;
+ char *nulls;
Datum *argvalues;
plperl_query_desc *qdesc;
- SV *cursor;
- Portal portal = NULL;
+ SV *cursor;
+ Portal portal = NULL;
/*
- * 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;
@@ -2234,44 +2240,44 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
* Fetch the saved plan descriptor, see if it's o.k.
************************************************************/
sv = hv_fetch(plperl_query_hash, query, strlen(query), 0);
- if ( sv == NULL)
+ if (sv == NULL)
elog(ERROR, "spi_query_prepared: Invalid prepared query passed");
- if ( *sv == NULL || !SvOK( *sv))
+ if (*sv == NULL || !SvOK(*sv))
elog(ERROR, "spi_query_prepared: panic - plperl_query_hash value corrupted");
- qdesc = INT2PTR( plperl_query_desc *, SvUV(*sv));
- if ( qdesc == NULL)
+ qdesc = INT2PTR(plperl_query_desc *, SvUV(*sv));
+ if (qdesc == NULL)
elog(ERROR, "spi_query_prepared: panic - plperl_query_hash value vanished");
- if ( qdesc-> nargs != argc)
- elog(ERROR, "spi_query_prepared: expected %d argument(s), %d passed",
- qdesc-> nargs, argc);
-
+ if (qdesc->nargs != argc)
+ elog(ERROR, "spi_query_prepared: expected %d argument(s), %d passed",
+ qdesc->nargs, argc);
+
/************************************************************
* Set up arguments
************************************************************/
- if (argc > 0)
+ if (argc > 0)
{
nulls = (char *) palloc(argc);
argvalues = (Datum *) palloc(argc * sizeof(Datum));
- }
- else
+ }
+ else
{
nulls = NULL;
argvalues = NULL;
}
- for (i = 0; i < argc; i++)
+ for (i = 0; i < argc; i++)
{
- if (SvTYPE(argv[i]) != SVt_NULL)
+ if (SvTYPE(argv[i]) != SVt_NULL)
{
argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
SvPV(argv[i], PL_na),
qdesc->argtypioparams[i],
-1);
nulls[i] = ' ';
- }
- else
+ }
+ else
{
argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
NULL,
@@ -2284,16 +2290,16 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
/************************************************************
* go
************************************************************/
- portal = SPI_cursor_open(NULL, qdesc-> plan, argvalues, nulls,
- current_call_data->prodesc->fn_readonly);
- if ( argc > 0)
+ portal = SPI_cursor_open(NULL, qdesc->plan, argvalues, nulls,
+ current_call_data->prodesc->fn_readonly);
+ if (argc > 0)
{
- pfree( argvalues);
- pfree( nulls);
+ pfree(argvalues);
+ pfree(nulls);
}
- if ( portal == NULL)
+ if (portal == NULL)
elog(ERROR, "SPI_cursor_open() failed:%s",
- SPI_result_code_string(SPI_result));
+ SPI_result_code_string(SPI_result));
cursor = newSVpv(portal->name, 0);
@@ -2301,9 +2307,10 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
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();
}
@@ -2322,9 +2329,9 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
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();
@@ -2342,29 +2349,30 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
void
plperl_spi_freeplan(char *query)
{
- SV ** sv;
- void * plan;
+ SV **sv;
+ void *plan;
plperl_query_desc *qdesc;
sv = hv_fetch(plperl_query_hash, query, strlen(query), 0);
- if ( sv == NULL)
+ if (sv == NULL)
elog(ERROR, "spi_exec_freeplan: Invalid prepared query passed");
- if ( *sv == NULL || !SvOK( *sv))
+ if (*sv == NULL || !SvOK(*sv))
elog(ERROR, "spi_exec_freeplan: panic - plperl_query_hash value corrupted");
- qdesc = INT2PTR( plperl_query_desc *, SvUV(*sv));
- if ( qdesc == NULL)
+ qdesc = INT2PTR(plperl_query_desc *, SvUV(*sv));
+ if (qdesc == NULL)
elog(ERROR, "spi_exec_freeplan: panic - plperl_query_hash value vanished");
/*
- * free all memory before SPI_freeplan, so if it dies, nothing will be left over
- */
+ * free all memory before SPI_freeplan, so if it dies, nothing will be
+ * left over
+ */
hv_delete(plperl_query_hash, query, strlen(query), G_DISCARD);
- plan = qdesc-> plan;
- free(qdesc-> argtypes);
- free(qdesc-> arginfuncs);
- free(qdesc-> argtypioparams);
+ plan = qdesc->plan;
+ free(qdesc->argtypes);
+ free(qdesc->arginfuncs);
+ free(qdesc->argtypioparams);
free(qdesc);
- SPI_freeplan( plan);
+ SPI_freeplan(plan);
}
diff --git a/src/pl/plperl/plperl.h b/src/pl/plperl/plperl.h
index 53c7b164faf..8feccb45cd3 100644
--- a/src/pl/plperl/plperl.h
+++ b/src/pl/plperl/plperl.h
@@ -1,14 +1,14 @@
/*-------------------------------------------------------------------------
*
* plperl.h
- * Common include file for PL/Perl files
+ * Common include file for PL/Perl files
*
* This should be included _AFTER_ postgres.h and system include files
*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.h,v 1.4 2006/03/05 16:40:51 adunstan Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.h,v 1.5 2006/10/04 00:30:13 momjian Exp $
*/
#ifndef PL_PERL_H
@@ -17,14 +17,14 @@
/* stop perl headers from hijacking stdio and other stuff on Windows */
#ifdef WIN32
#define WIN32IO_IS_STDIO
-/*
+/*
* isnan is defined in both the perl and mingw headers. We don't use it,
* so this just clears up the compile warning.
*/
#ifdef isnan
#undef isnan
#endif
-#endif
+#endif
/* required for perl API */
#include "EXTERN.h"
@@ -51,12 +51,12 @@ HV *plperl_spi_exec(char *, int);
void plperl_return_next(SV *);
SV *plperl_spi_query(char *);
SV *plperl_spi_fetchrow(char *);
-SV *plperl_spi_prepare(char *, int, SV **);
-HV *plperl_spi_exec_prepared(char *, HV *, int, SV **);
-SV *plperl_spi_query_prepared(char *, int, SV **);
-void plperl_spi_freeplan(char *);
-void plperl_spi_cursor_close(char *);
+SV *plperl_spi_prepare(char *, int, SV **);
+HV *plperl_spi_exec_prepared(char *, HV *, int, SV **);
+SV *plperl_spi_query_prepared(char *, int, SV **);
+void plperl_spi_freeplan(char *);
+void plperl_spi_cursor_close(char *);
-#endif /* PL_PERL_H */
+#endif /* PL_PERL_H */
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 6670ac65716..654e8ccf43f 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.107 2006/07/11 17:26:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.108 2006/10/04 00:30:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -587,14 +587,14 @@ do_compile(FunctionCallInfo fcinfo,
true);
function->tg_table_name_varno = var->dno;
-
+
/* add variable tg_table_schema */
var = plpgsql_build_variable("tg_table_schema", 0,
plpgsql_build_datatype(NAMEOID, -1),
true);
function->tg_table_schema_varno = var->dno;
-
+
/* Add the variable tg_nargs */
var = plpgsql_build_variable("tg_nargs", 0,
plpgsql_build_datatype(INT4OID, -1),
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index c5e036ccb77..c28c2c6c8f3 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.179 2006/09/22 21:39:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.180 2006/10/04 00:30:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -257,7 +257,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
* Let the instrumentation plugin peek at this function
*/
if (*plugin_ptr && (*plugin_ptr)->func_beg)
- ((*plugin_ptr)->func_beg)(&estate, func);
+ ((*plugin_ptr)->func_beg) (&estate, func);
/*
* Now call the toplevel block of statements
@@ -325,9 +325,9 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
if (estate.retistuple)
{
/*
- * We have to check that the returned tuple actually matches
- * the expected result type. XXX would be better to cache the
- * tupdesc instead of repeating get_call_result_type()
+ * We have to check that the returned tuple actually matches the
+ * expected result type. XXX would be better to cache the tupdesc
+ * instead of repeating get_call_result_type()
*/
TupleDesc tupdesc;
@@ -342,12 +342,13 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
errmsg("returned record type does not match expected record type")));
break;
case TYPEFUNC_RECORD:
+
/*
* Failed to determine actual type of RECORD. We could
- * raise an error here, but what this means in practice
- * is that the caller is expecting any old generic
- * rowtype, so we don't really need to be restrictive.
- * Pass back the generated result type, instead.
+ * raise an error here, but what this means in practice is
+ * that the caller is expecting any old generic rowtype,
+ * so we don't really need to be restrictive. Pass back
+ * the generated result type, instead.
*/
tupdesc = estate.rettupdesc;
if (tupdesc == NULL) /* shouldn't happen */
@@ -360,8 +361,8 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
}
/*
- * Copy tuple to upper executor memory, as a tuple Datum.
- * Make sure it is labeled with the caller-supplied tuple type.
+ * Copy tuple to upper executor memory, as a tuple Datum. Make
+ * sure it is labeled with the caller-supplied tuple type.
*/
estate.retval =
PointerGetDatum(SPI_returntuple((HeapTuple) (estate.retval),
@@ -398,7 +399,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
* Let the instrumentation plugin peek at this function
*/
if (*plugin_ptr && (*plugin_ptr)->func_end)
- ((*plugin_ptr)->func_end)(&estate, func);
+ ((*plugin_ptr)->func_end) (&estate, func);
/* Clean up any leftover temporary memory */
FreeExprContext(estate.eval_econtext);
@@ -561,9 +562,9 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
var = (PLpgSQL_var *) (estate.datums[func->tg_table_schema_varno]);
var->value = DirectFunctionCall1(namein,
CStringGetDatum(
- get_namespace_name(
- RelationGetNamespace(
- trigdata->tg_relation))));
+ get_namespace_name(
+ RelationGetNamespace(
+ trigdata->tg_relation))));
var->isnull = false;
var->freeval = true;
@@ -597,7 +598,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
* Let the instrumentation plugin peek at this function
*/
if (*plugin_ptr && (*plugin_ptr)->func_beg)
- ((*plugin_ptr)->func_beg)(&estate, func);
+ ((*plugin_ptr)->func_beg) (&estate, func);
/*
* Now call the toplevel block of statements
@@ -656,7 +657,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
* Let the instrumentation plugin peek at this function
*/
if (*plugin_ptr && (*plugin_ptr)->func_end)
- ((*plugin_ptr)->func_end)(&estate, func);
+ ((*plugin_ptr)->func_end) (&estate, func);
/* Clean up any leftover temporary memory */
FreeExprContext(estate.eval_econtext);
@@ -1064,7 +1065,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
/* Let the plugin know that we are about to execute this statement */
if (*plugin_ptr && (*plugin_ptr)->stmt_beg)
- ((*plugin_ptr)->stmt_beg)(estate, stmt);
+ ((*plugin_ptr)->stmt_beg) (estate, stmt);
CHECK_FOR_INTERRUPTS();
@@ -1153,7 +1154,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
/* Let the plugin know that we have finished executing this statement */
if (*plugin_ptr && (*plugin_ptr)->stmt_end)
- ((*plugin_ptr)->stmt_end)(estate, stmt);
+ ((*plugin_ptr)->stmt_end) (estate, stmt);
estate->err_stmt = save_estmt;
@@ -1439,7 +1440,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
exec_eval_cleanup(estate);
/*
- * Get the by value
+ * Get the by value
*/
by_value = exec_eval_expr(estate, stmt->by, &isnull, &valtype);
by_value = exec_cast_value(by_value, valtype, var->datatype->typoid,
@@ -2158,10 +2159,10 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
estate->eval_econtext = CreateExprContext(simple_eval_estate);
/*
- * Let the plugin see this function before we initialize any
- * local PL/pgSQL variables - note that we also give the plugin
- * a few function pointers so it can call back into PL/pgSQL
- * for doing things like variable assignments and stack traces
+ * Let the plugin see this function before we initialize any local
+ * PL/pgSQL variables - note that we also give the plugin a few function
+ * pointers so it can call back into PL/pgSQL for doing things like
+ * variable assignments and stack traces
*/
if (*plugin_ptr)
{
@@ -2169,7 +2170,7 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
(*plugin_ptr)->assign_expr = exec_assign_expr;
if ((*plugin_ptr)->func_setup)
- ((*plugin_ptr)->func_setup)(estate, func);
+ ((*plugin_ptr)->func_setup) (estate, func);
}
}
@@ -2278,8 +2279,8 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
PLpgSQL_expr *expr = stmt->sqlstmt;
/*
- * On the first call for this statement generate the plan, and
- * detect whether the statement is INSERT/UPDATE/DELETE
+ * On the first call for this statement generate the plan, and detect
+ * whether the statement is INSERT/UPDATE/DELETE
*/
if (expr->plan == NULL)
{
@@ -2295,7 +2296,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
foreach(l2, (List *) lfirst(l))
{
- Query *q = (Query *) lfirst(l2);
+ Query *q = (Query *) lfirst(l2);
Assert(IsA(q, Query));
if (q->canSetTag)
@@ -2330,15 +2331,15 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
}
/*
- * If we have INTO, then we only need one row back ... but if we have
- * INTO STRICT, ask for two rows, so that we can verify the statement
- * returns only one. INSERT/UPDATE/DELETE are always treated strictly.
- * Without INTO, just run the statement to completion (tcount = 0).
+ * If we have INTO, then we only need one row back ... but if we have INTO
+ * STRICT, ask for two rows, so that we can verify the statement returns
+ * only one. INSERT/UPDATE/DELETE are always treated strictly. Without
+ * INTO, just run the statement to completion (tcount = 0).
*
- * We could just ask for two rows always when using INTO, but there
- * are some cases where demanding the extra row costs significant time,
- * eg by forcing completion of a sequential scan. So don't do it unless
- * we need to enforce strictness.
+ * We could just ask for two rows always when using INTO, but there are
+ * some cases where demanding the extra row costs significant time, eg by
+ * forcing completion of a sequential scan. So don't do it unless we need
+ * to enforce strictness.
*/
if (stmt->into)
{
@@ -2358,7 +2359,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
/*
* Check for error, and set FOUND if appropriate (for historical reasons
- * we set FOUND only for certain query types). Also Assert that we
+ * we set FOUND only for certain query types). Also Assert that we
* identified the statement type the same as SPI did.
*/
switch (rc)
@@ -2404,7 +2405,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
if (tuptab == NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("INTO used with a command that cannot return data")));
+ errmsg("INTO used with a command that cannot return data")));
/* Determine if we assign to a record or a row */
if (stmt->rec != NULL)
@@ -2415,9 +2416,9 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
elog(ERROR, "unsupported target");
/*
- * If SELECT ... INTO specified STRICT, and the query didn't
- * find exactly one row, throw an error. If STRICT was not specified,
- * then allow the query to find any number of rows.
+ * If SELECT ... INTO specified STRICT, and the query didn't find
+ * exactly one row, throw an error. If STRICT was not specified, then
+ * allow the query to find any number of rows.
*/
if (n == 0)
{
@@ -2474,8 +2475,8 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
int exec_res;
/*
- * First we evaluate the string expression after the EXECUTE keyword.
- * Its result is the querystring we have to execute.
+ * First we evaluate the string expression after the EXECUTE keyword. Its
+ * result is the querystring we have to execute.
*/
query = exec_eval_expr(estate, stmt->query, &isnull, &restype);
if (isnull)
@@ -2575,7 +2576,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
if (tuptab == NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("INTO used with a command that cannot return data")));
+ errmsg("INTO used with a command that cannot return data")));
/* Determine if we assign to a record or a row */
if (stmt->rec != NULL)
@@ -2586,9 +2587,9 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
elog(ERROR, "unsupported target");
/*
- * If SELECT ... INTO specified STRICT, and the query didn't
- * find exactly one row, throw an error. If STRICT was not specified,
- * then allow the query to find any number of rows.
+ * If SELECT ... INTO specified STRICT, and the query didn't find
+ * exactly one row, throw an error. If STRICT was not specified, then
+ * allow the query to find any number of rows.
*/
if (n == 0)
{
@@ -3951,7 +3952,7 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate,
paramLI = (ParamListInfo)
MemoryContextAlloc(econtext->ecxt_per_tuple_memory,
sizeof(ParamListInfoData) +
- (expr->nparams - 1) * sizeof(ParamExternData));
+ (expr->nparams - 1) *sizeof(ParamExternData));
paramLI->numParams = expr->nparams;
for (i = 0; i < expr->nparams; i++)
@@ -4462,7 +4463,7 @@ exec_simple_check_node(Node *node)
case T_RowCompareExpr:
{
- RowCompareExpr *expr = (RowCompareExpr *) node;
+ RowCompareExpr *expr = (RowCompareExpr *) node;
if (!exec_simple_check_node((Node *) expr->largs))
return FALSE;
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index a0f2cb46550..5f08107f91a 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.31 2006/08/15 19:01:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.32 2006/10/04 00:30:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -162,7 +162,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpgsql functions cannot take type %s",
- format_type_be(argtypes[i]))));
+ format_type_be(argtypes[i]))));
}
}
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index 206f9b9875e..051dd9e3c48 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.80 2006/08/15 19:01:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.81 2006/10/04 00:30:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -178,6 +178,7 @@ typedef struct PLpgSQL_expr
/* fields for "simple expression" fast-path execution: */
Expr *expr_simple_expr; /* NULL means not a simple expr */
Oid expr_simple_type;
+
/*
* if expr is simple AND in use in current xact, expr_simple_state is
* valid. Test validity by seeing if expr_simple_xid matches current XID.
@@ -570,8 +571,8 @@ typedef struct PLpgSQL_function
int tg_op_varno;
int tg_relid_varno;
int tg_relname_varno;
- int tg_table_name_varno;
- int tg_table_schema_varno;
+ int tg_table_name_varno;
+ int tg_table_schema_varno;
int tg_nargs_varno;
int ndatums;
@@ -629,42 +630,42 @@ typedef struct
* We expect that a plugin would do this at library load time (_PG_init()).
* It must also be careful to set the rendezvous variable back to NULL
* if it is unloaded (_PG_fini()).
- *
+ *
* This structure is basically a collection of function pointers --- at
* various interesting points in pl_exec.c, we call these functions
* (if the pointers are non-NULL) to give the plugin a chance to watch
* what we are doing.
*
- * func_setup is called when we start a function, before we've initialized
- * the local variables defined by the function.
+ * func_setup is called when we start a function, before we've initialized
+ * the local variables defined by the function.
*
- * func_beg is called when we start a function, after we've initialized
- * the local variables.
+ * func_beg is called when we start a function, after we've initialized
+ * the local variables.
*
- * func_end is called at the end of a function.
+ * func_end is called at the end of a function.
*
- * stmt_beg and stmt_end are called before and after (respectively) each
- * statement.
+ * stmt_beg and stmt_end are called before and after (respectively) each
+ * statement.
*
* Also, immediately before any call to func_setup, PL/pgSQL fills in the
* error_callback and assign_expr fields with pointers to its own
- * plpgsql_exec_error_callback and exec_assign_expr functions. This is
+ * plpgsql_exec_error_callback and exec_assign_expr functions. This is
* a somewhat ad-hoc expedient to simplify life for debugger plugins.
*/
typedef struct
{
/* Function pointers set up by the plugin */
- void (*func_setup) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
- void (*func_beg) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
- void (*func_end) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
- void (*stmt_beg) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
- void (*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
+ void (*func_setup) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
+ void (*func_beg) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
+ void (*func_end) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
+ void (*stmt_beg) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
+ void (*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
/* Function pointers set by PL/pgSQL itself */
- void (*error_callback) (void *arg);
- void (*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
- PLpgSQL_expr *expr);
+ void (*error_callback) (void *arg);
+ void (*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
+ PLpgSQL_expr *expr);
} PLpgSQL_plugin;
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 1a80a74d829..6445837ac9c 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -1,7 +1,7 @@
/**********************************************************************
* plpython.c - python as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.88 2006/09/16 13:35:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.89 2006/10/04 00:30:14 momjian Exp $
*
*********************************************************************
*/
@@ -122,9 +122,9 @@ typedef struct PLyProcedure
bool fn_readonly;
PLyTypeInfo result; /* also used to store info for trigger tuple
* type */
- bool is_setof; /* true, if procedure returns result set */
- PyObject *setof; /* contents of result set. */
- char **argnames; /* Argument names */
+ bool is_setof; /* true, if procedure returns result set */
+ PyObject *setof; /* contents of result set. */
+ char **argnames; /* Argument names */
PLyTypeInfo args[FUNC_MAX_ARGS];
int nargs;
PyObject *code; /* compiled procedure code */
@@ -150,7 +150,7 @@ typedef struct PLyResultObject
{
PyObject_HEAD
/* HeapTuple *tuples; */
- PyObject *nrows; /* number of rows returned by query */
+ PyObject * nrows; /* number of rows returned by query */
PyObject *rows; /* data rows, or None if no data returned */
PyObject *status; /* query status, SPI_OK_*, or SPI_ERR_* */
} PLyResultObject;
@@ -391,7 +391,7 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
if (!PyString_Check(plrv))
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
- errmsg("unexpected return value from trigger procedure"),
+ errmsg("unexpected return value from trigger procedure"),
errdetail("Expected None or a String.")));
srv = PyString_AsString(plrv);
@@ -410,12 +410,12 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
else if (pg_strcasecmp(srv, "OK") != 0)
{
/*
- * accept "OK" as an alternative to None; otherwise,
- * raise an error
+ * accept "OK" as an alternative to None; otherwise, raise an
+ * error
*/
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
- errmsg("unexpected return value from trigger procedure"),
+ errmsg("unexpected return value from trigger procedure"),
errdetail("Expected None, \"OK\", \"SKIP\", or \"MODIFY\".")));
}
}
@@ -513,7 +513,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
modvalues[i] =
InputFunctionCall(&proc->result.out.r.atts[atti].typfunc,
src,
- proc->result.out.r.atts[atti].typioparam,
+ proc->result.out.r.atts[atti].typioparam,
tupdesc->attrs[atti]->atttypmod);
modnulls[i] = ' ';
@@ -525,7 +525,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
modvalues[i] =
InputFunctionCall(&proc->result.out.r.atts[atti].typfunc,
NULL,
- proc->result.out.r.atts[atti].typioparam,
+ proc->result.out.r.atts[atti].typioparam,
tupdesc->attrs[atti]->atttypmod);
modnulls[i] = 'n';
}
@@ -575,9 +575,9 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
*pltevent,
*pltwhen,
*pltlevel,
- *pltrelid,
- *plttablename,
- *plttableschema;
+ *pltrelid,
+ *plttablename,
+ *plttableschema;
PyObject *pltargs,
*pytnew,
*pytold;
@@ -606,13 +606,13 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
PyDict_SetItemString(pltdata, "table_name", plttablename);
Py_DECREF(plttablename);
pfree(stroid);
-
+
stroid = SPI_getnspname(tdata->tg_relation);
plttableschema = PyString_FromString(stroid);
PyDict_SetItemString(pltdata, "table_schema", plttableschema);
Py_DECREF(plttableschema);
pfree(stroid);
-
+
if (TRIGGER_FIRED_BEFORE(tdata->tg_event))
pltwhen = PyString_FromString("BEFORE");
@@ -762,7 +762,11 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
plargs = PLy_function_build_args(fcinfo, proc);
plrv = PLy_procedure_call(proc, "args", plargs);
if (!proc->is_setof)
- /* SETOF function parameters will be deleted when last row is returned */
+
+ /*
+ * SETOF function parameters will be deleted when last row is
+ * returned
+ */
PLy_function_delete_args(proc);
Assert(plrv != NULL);
Assert(!PLy_error_in_progress);
@@ -779,14 +783,14 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
if (proc->is_setof)
{
- bool has_error = false;
- ReturnSetInfo *rsi = (ReturnSetInfo *)fcinfo->resultinfo;
+ bool has_error = false;
+ ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo;
if (proc->setof == NULL)
{
/* first time -- do checks and setup */
if (!rsi || !IsA(rsi, ReturnSetInfo) ||
- (rsi->allowedModes & SFRM_ValuePerCall) == 0)
+ (rsi->allowedModes & SFRM_ValuePerCall) == 0)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -803,7 +807,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("returned object can not be iterated"),
- errdetail("SETOF must be returned as iterable object")));
+ errdetail("SETOF must be returned as iterable object")));
}
/* Fetch next from iterator */
@@ -831,26 +835,25 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
if (has_error)
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
- errmsg("error fetching next item from iterator")));
+ errmsg("error fetching next item from iterator")));
fcinfo->isnull = true;
- return (Datum)NULL;
+ return (Datum) NULL;
}
}
/*
- * If the function is declared to return void, the Python
- * return value must be None. For void-returning functions, we
- * also treat a None return value as a special "void datum"
- * rather than NULL (as is the case for non-void-returning
- * functions).
+ * If the function is declared to return void, the Python return value
+ * must be None. For void-returning functions, we also treat a None
+ * return value as a special "void datum" rather than NULL (as is the
+ * case for non-void-returning functions).
*/
if (proc->result.out.d.typoid == VOIDOID)
{
if (plrv != Py_None)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("invalid return value from plpython function"),
+ errmsg("invalid return value from plpython function"),
errdetail("Functions returning type \"void\" must return None.")));
fcinfo->isnull = false;
@@ -861,16 +864,16 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
fcinfo->isnull = true;
if (proc->result.is_rowtype < 1)
rv = InputFunctionCall(&proc->result.out.d.typfunc,
- NULL,
- proc->result.out.d.typioparam,
- -1);
+ NULL,
+ proc->result.out.d.typioparam,
+ -1);
else
/* Tuple as None */
rv = (Datum) NULL;
}
else if (proc->result.is_rowtype >= 1)
{
- HeapTuple tuple = NULL;
+ HeapTuple tuple = NULL;
if (PySequence_Check(plrv))
/* composite type as sequence (tuple, list etc) */
@@ -1017,8 +1020,8 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
}
if (PyList_SetItem(args, i, arg) == -1 ||
- (proc->argnames &&
- PyDict_SetItemString(proc->globals, proc->argnames[i], arg) == -1))
+ (proc->argnames &&
+ PyDict_SetItemString(proc->globals, proc->argnames[i], arg) == -1))
PLy_elog(ERROR, "problem setting up arguments for \"%s\"", proc->proname);
arg = NULL;
}
@@ -1037,14 +1040,14 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
static void
-PLy_function_delete_args(PLyProcedure *proc)
+PLy_function_delete_args(PLyProcedure * proc)
{
- int i;
+ int i;
if (!proc->argnames)
return;
- for (i = 0; i < proc->nargs; i++)
+ for (i = 0; i < proc->nargs; i++)
PyDict_DelItemString(proc->globals, proc->argnames[i]);
}
@@ -1120,8 +1123,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
int i,
rv;
Datum argnames;
- Datum *elems;
- int nelems;
+ Datum *elems;
+ int nelems;
procStruct = (Form_pg_proc) GETSTRUCT(procTup);
@@ -1193,7 +1196,10 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
if (rvTypeStruct->typtype == 'c')
{
- /* Tuple: set up later, during first call to PLy_function_handler */
+ /*
+ * Tuple: set up later, during first call to
+ * PLy_function_handler
+ */
proc->result.out.d.typoid = procStruct->prorettype;
proc->result.is_rowtype = 2;
}
@@ -1215,8 +1221,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
}
/*
- * now get information required for input conversion of the procedure's
- * arguments.
+ * now get information required for input conversion of the
+ * procedure's arguments.
*/
proc->nargs = fcinfo->nargs;
if (proc->nargs)
@@ -1225,12 +1231,12 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
if (!isnull)
{
deconstruct_array(DatumGetArrayTypeP(argnames), TEXTOID, -1, false, 'i',
- &elems, NULL, &nelems);
+ &elems, NULL, &nelems);
if (nelems != proc->nargs)
elog(ERROR,
- "proargnames must have the same number of elements "
- "as the function has arguments");
- proc->argnames = (char **) PLy_malloc(sizeof(char *)*proc->nargs);
+ "proargnames must have the same number of elements "
+ "as the function has arguments");
+ proc->argnames = (char **) PLy_malloc(sizeof(char *) * proc->nargs);
}
}
for (i = 0; i < fcinfo->nargs; i++)
@@ -1306,8 +1312,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);
@@ -1674,13 +1680,13 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
static HeapTuple
-PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
+PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
{
TupleDesc desc;
HeapTuple tuple;
- Datum *values;
- char *nulls;
- int i;
+ Datum *values;
+ char *nulls;
+ int i;
Assert(PyMapping_Check(mapping));
@@ -1690,13 +1696,13 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
Assert(info->is_rowtype == 1);
/* Build tuple */
- values = palloc(sizeof(Datum)*desc->natts);
- nulls = palloc(sizeof(char)*desc->natts);
- for (i = 0; i < desc->natts; ++i)
+ values = palloc(sizeof(Datum) * desc->natts);
+ nulls = palloc(sizeof(char) * desc->natts);
+ for (i = 0; i < desc->natts; ++i)
{
- char *key;
- PyObject *value,
- *so;
+ char *key;
+ PyObject *value,
+ *so;
key = NameStr(desc->attrs[i]->attname);
value = so = NULL;
@@ -1710,7 +1716,7 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
}
else if (value)
{
- char *valuestr;
+ char *valuestr;
so = PyObject_Str(value);
if (so == NULL)
@@ -1718,9 +1724,9 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
valuestr = PyString_AsString(so);
values[i] = InputFunctionCall(&info->out.r.atts[i].typfunc
- , valuestr
- , info->out.r.atts[i].typioparam
- , -1);
+ ,valuestr
+ ,info->out.r.atts[i].typioparam
+ ,-1);
Py_DECREF(so);
so = NULL;
nulls[i] = ' ';
@@ -1730,7 +1736,7 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("no mapping found with key \"%s\"", key),
errhint("to return null in specific column, "
- "add value None to map with key named after column")));
+ "add value None to map with key named after column")));
Py_XDECREF(value);
value = NULL;
@@ -1754,38 +1760,38 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
static HeapTuple
-PLySequence_ToTuple(PLyTypeInfo *info, PyObject *sequence)
+PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
{
TupleDesc desc;
HeapTuple tuple;
- Datum *values;
- char *nulls;
- int i;
+ Datum *values;
+ char *nulls;
+ int i;
Assert(PySequence_Check(sequence));
/*
* Check that sequence length is exactly same as PG tuple's. We actually
- * can ignore exceeding items or assume missing ones as null but to
- * avoid plpython developer's errors we are strict here
+ * can ignore exceeding items or assume missing ones as null but to avoid
+ * plpython developer's errors we are strict here
*/
desc = lookup_rowtype_tupdesc(info->out.d.typoid, -1);
if (PySequence_Length(sequence) != desc->natts)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("returned sequence's length must be same as tuple's length")));
+ errmsg("returned sequence's length must be same as tuple's length")));
if (info->is_rowtype == 2)
PLy_output_tuple_funcs(info, desc);
Assert(info->is_rowtype == 1);
/* Build tuple */
- values = palloc(sizeof(Datum)*desc->natts);
- nulls = palloc(sizeof(char)*desc->natts);
- for (i = 0; i < desc->natts; ++i)
+ values = palloc(sizeof(Datum) * desc->natts);
+ nulls = palloc(sizeof(char) * desc->natts);
+ for (i = 0; i < desc->natts; ++i)
{
- PyObject *value,
- *so;
+ PyObject *value,
+ *so;
value = so = NULL;
PG_TRY();
@@ -1799,16 +1805,16 @@ PLySequence_ToTuple(PLyTypeInfo *info, PyObject *sequence)
}
else if (value)
{
- char *valuestr;
+ char *valuestr;
so = PyObject_Str(value);
if (so == NULL)
PLy_elog(ERROR, "can't convert sequence type");
valuestr = PyString_AsString(so);
values[i] = InputFunctionCall(&info->out.r.atts[i].typfunc
- , valuestr
- , info->out.r.atts[i].typioparam
- , -1);
+ ,valuestr
+ ,info->out.r.atts[i].typioparam
+ ,-1);
Py_DECREF(so);
so = NULL;
nulls[i] = ' ';
@@ -1836,13 +1842,13 @@ PLySequence_ToTuple(PLyTypeInfo *info, PyObject *sequence)
static HeapTuple
-PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
+PLyObject_ToTuple(PLyTypeInfo * info, PyObject * object)
{
TupleDesc desc;
HeapTuple tuple;
- Datum *values;
- char *nulls;
- int i;
+ Datum *values;
+ char *nulls;
+ int i;
desc = lookup_rowtype_tupdesc(info->out.d.typoid, -1);
if (info->is_rowtype == 2)
@@ -1850,13 +1856,13 @@ PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
Assert(info->is_rowtype == 1);
/* Build tuple */
- values = palloc(sizeof(Datum)*desc->natts);
- nulls = palloc(sizeof(char)*desc->natts);
- for (i = 0; i < desc->natts; ++i)
+ values = palloc(sizeof(Datum) * desc->natts);
+ nulls = palloc(sizeof(char) * desc->natts);
+ for (i = 0; i < desc->natts; ++i)
{
- char *key;
- PyObject *value,
- *so;
+ char *key;
+ PyObject *value,
+ *so;
key = NameStr(desc->attrs[i]->attname);
value = so = NULL;
@@ -1870,16 +1876,16 @@ PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
}
else if (value)
{
- char *valuestr;
+ char *valuestr;
so = PyObject_Str(value);
if (so == NULL)
PLy_elog(ERROR, "can't convert object type");
valuestr = PyString_AsString(so);
values[i] = InputFunctionCall(&info->out.r.atts[i].typfunc
- , valuestr
- , info->out.r.atts[i].typioparam
- , -1);
+ ,valuestr
+ ,info->out.r.atts[i].typioparam
+ ,-1);
Py_DECREF(so);
so = NULL;
nulls[i] = ' ';
@@ -1889,8 +1895,8 @@ PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("no attribute named \"%s\"", key),
errhint("to return null in specific column, "
- "let returned object to have attribute named "
- "after column with value None")));
+ "let returned object to have attribute named "
+ "after column with value None")));
Py_XDECREF(value);
value = NULL;
@@ -2450,7 +2456,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
PG_TRY();
{
- char *sv = PyString_AsString(so);
+ char *sv = PyString_AsString(so);
plan->values[i] =
InputFunctionCall(&(plan->args[i].out.d.typfunc),
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 44b2e405f32..c6efa75331f 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -2,7 +2,7 @@
* pltcl.c - PostgreSQL support for Tcl as
* procedural language (PL)
*
- * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.107 2006/08/27 23:47:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.108 2006/10/04 00:30:14 momjian Exp $
*
**********************************************************************/
@@ -652,15 +652,15 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
pfree(stroid);
/* The name of the table the trigger is acting on: TG_table_name */
- stroid = SPI_getrelname(trigdata->tg_relation);
+ stroid = SPI_getrelname(trigdata->tg_relation);
Tcl_DStringAppendElement(&tcl_cmd, stroid);
- pfree(stroid);
-
+ pfree(stroid);
+
/* The schema of the table the trigger is acting on: TG_table_schema */
- stroid = SPI_getnspname(trigdata->tg_relation);
+ stroid = SPI_getnspname(trigdata->tg_relation);
Tcl_DStringAppendElement(&tcl_cmd, stroid);
- pfree(stroid);
-
+ pfree(stroid);
+
/* A list of attribute names for argument TG_relatts */
Tcl_DStringAppendElement(&tcl_trigtup, "");
for (i = 0; i < tupdesc->natts; i++)
@@ -878,9 +878,9 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
fmgr_info(typinput, &finfo);
UTF_BEGIN;
modvalues[attnum - 1] = InputFunctionCall(&finfo,
- (char *) UTF_U2E(ret_value),
+ (char *) UTF_U2E(ret_value),
typioparam,
- tupdesc->attrs[attnum - 1]->atttypmod);
+ tupdesc->attrs[attnum - 1]->atttypmod);
UTF_END;
}
@@ -2062,7 +2062,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
{
UTF_BEGIN;
argvalues[j] = InputFunctionCall(&qdesc->arginfuncs[j],
- (char *) UTF_U2E(callargs[j]),
+ (char *) UTF_U2E(callargs[j]),
qdesc->argtypioparams[j],
-1);
UTF_END;