diff options
403 files changed, 6779 insertions, 6523 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c index 61406db6342..ffc1a4a1063 100644 --- a/contrib/auto_explain/auto_explain.c +++ b/contrib/auto_explain/auto_explain.c @@ -6,7 +6,7 @@ * Copyright (c) 2008-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.13 2010/02/16 22:19:59 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.14 2010/02/26 02:00:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,11 +27,11 @@ static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT; static bool auto_explain_log_nested_statements = false; static const struct config_enum_entry format_options[] = { - {"text", EXPLAIN_FORMAT_TEXT, false}, - {"xml", EXPLAIN_FORMAT_XML, false}, - {"json", EXPLAIN_FORMAT_JSON, false}, - {"yaml", EXPLAIN_FORMAT_YAML, false}, - {NULL, 0, false} + {"text", EXPLAIN_FORMAT_TEXT, false}, + {"xml", EXPLAIN_FORMAT_XML, false}, + {"json", EXPLAIN_FORMAT_JSON, false}, + {"yaml", EXPLAIN_FORMAT_YAML, false}, + {NULL, 0, false} }; /* Current nesting depth of ExecutorRun calls */ @@ -231,7 +231,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc) msec = queryDesc->totaltime->total * 1000.0; if (msec >= auto_explain_log_min_duration) { - ExplainState es; + ExplainState es; ExplainInitState(&es); es.analyze = (queryDesc->instrument_options && auto_explain_log_analyze); @@ -257,7 +257,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc) ereport(LOG, (errmsg("duration: %.3f ms plan:\n%s", msec, es.str->data), - errhidestmt(true))); + errhidestmt(true))); pfree(es.str->data); } diff --git a/contrib/btree_gist/btree_cash.c b/contrib/btree_gist/btree_cash.c index 852ba3718bc..a1efde61468 100644 --- a/contrib/btree_gist/btree_cash.c +++ b/contrib/btree_gist/btree_cash.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_cash.c,v 1.10 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_cash.c,v 1.11 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -57,8 +57,8 @@ gbt_cashlt(const void *a, const void *b) static int gbt_cashkey_cmp(const void *a, const void *b) { - cashKEY *ia = (cashKEY*)(((Nsrt *) a)->t); - cashKEY *ib = (cashKEY*)(((Nsrt *) b)->t); + cashKEY *ia = (cashKEY *) (((Nsrt *) a)->t); + cashKEY *ib = (cashKEY *) (((Nsrt *) b)->t); if (ia->lower == ib->lower) { diff --git a/contrib/btree_gist/btree_date.c b/contrib/btree_gist/btree_date.c index b6e4e0b292a..d8dce91535d 100644 --- a/contrib/btree_gist/btree_date.c +++ b/contrib/btree_gist/btree_date.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_date.c,v 1.8 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_date.c,v 1.9 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -73,9 +73,9 @@ gbt_datelt(const void *a, const void *b) static int gbt_datekey_cmp(const void *a, const void *b) { - dateKEY *ia = (dateKEY*)(((Nsrt *) a)->t); - dateKEY *ib = (dateKEY*)(((Nsrt *) b)->t); - int res; + dateKEY *ia = (dateKEY *) (((Nsrt *) a)->t); + dateKEY *ib = (dateKEY *) (((Nsrt *) b)->t); + int res; res = DatumGetInt32(DirectFunctionCall2(date_cmp, DateADTGetDatum(ia->lower), DateADTGetDatum(ib->lower))); if (res == 0) diff --git a/contrib/btree_gist/btree_float4.c b/contrib/btree_gist/btree_float4.c index 3246f7f43bd..7ece9ea220d 100644 --- a/contrib/btree_gist/btree_float4.c +++ b/contrib/btree_gist/btree_float4.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_float4.c,v 1.9 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_float4.c,v 1.10 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -56,8 +56,8 @@ gbt_float4lt(const void *a, const void *b) static int gbt_float4key_cmp(const void *a, const void *b) { - float4KEY *ia = (float4KEY*)(((Nsrt *) a)->t); - float4KEY *ib = (float4KEY*)(((Nsrt *) b)->t); + float4KEY *ia = (float4KEY *) (((Nsrt *) a)->t); + float4KEY *ib = (float4KEY *) (((Nsrt *) b)->t); if (ia->lower == ib->lower) { diff --git a/contrib/btree_gist/btree_float8.c b/contrib/btree_gist/btree_float8.c index 6964d201917..ab4912883db 100644 --- a/contrib/btree_gist/btree_float8.c +++ b/contrib/btree_gist/btree_float8.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_float8.c,v 1.9 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_float8.c,v 1.10 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -57,8 +57,8 @@ gbt_float8lt(const void *a, const void *b) static int gbt_float8key_cmp(const void *a, const void *b) { - float8KEY *ia = (float8KEY*)(((Nsrt *) a)->t); - float8KEY *ib = (float8KEY*)(((Nsrt *) b)->t); + float8KEY *ia = (float8KEY *) (((Nsrt *) a)->t); + float8KEY *ib = (float8KEY *) (((Nsrt *) b)->t); if (ia->lower == ib->lower) { diff --git a/contrib/btree_gist/btree_inet.c b/contrib/btree_gist/btree_inet.c index a77864abeb5..a8d18c578ba 100644 --- a/contrib/btree_gist/btree_inet.c +++ b/contrib/btree_gist/btree_inet.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_inet.c,v 1.11 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_inet.c,v 1.12 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -60,8 +60,8 @@ gbt_inetlt(const void *a, const void *b) static int gbt_inetkey_cmp(const void *a, const void *b) { - inetKEY *ia = (inetKEY*)(((Nsrt *) a)->t); - inetKEY *ib = (inetKEY*)(((Nsrt *) b)->t); + inetKEY *ia = (inetKEY *) (((Nsrt *) a)->t); + inetKEY *ib = (inetKEY *) (((Nsrt *) b)->t); if (ia->lower == ib->lower) { diff --git a/contrib/btree_gist/btree_int2.c b/contrib/btree_gist/btree_int2.c index 2aeb94b169d..2be4c40aa8d 100644 --- a/contrib/btree_gist/btree_int2.c +++ b/contrib/btree_gist/btree_int2.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_int2.c,v 1.9 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_int2.c,v 1.10 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -56,8 +56,8 @@ gbt_int2lt(const void *a, const void *b) static int gbt_int2key_cmp(const void *a, const void *b) { - int16KEY *ia = (int16KEY*)(((Nsrt *) a)->t); - int16KEY *ib = (int16KEY*)(((Nsrt *) b)->t); + int16KEY *ia = (int16KEY *) (((Nsrt *) a)->t); + int16KEY *ib = (int16KEY *) (((Nsrt *) b)->t); if (ia->lower == ib->lower) { diff --git a/contrib/btree_gist/btree_int4.c b/contrib/btree_gist/btree_int4.c index 12a2c476a4d..aa0d4ac33fb 100644 --- a/contrib/btree_gist/btree_int4.c +++ b/contrib/btree_gist/btree_int4.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_int4.c,v 1.9 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_int4.c,v 1.10 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -57,8 +57,8 @@ gbt_int4lt(const void *a, const void *b) static int gbt_int4key_cmp(const void *a, const void *b) { - int32KEY *ia = (int32KEY*)(((Nsrt *) a)->t); - int32KEY *ib = (int32KEY*)(((Nsrt *) b)->t); + int32KEY *ia = (int32KEY *) (((Nsrt *) a)->t); + int32KEY *ib = (int32KEY *) (((Nsrt *) b)->t); if (ia->lower == ib->lower) { diff --git a/contrib/btree_gist/btree_int8.c b/contrib/btree_gist/btree_int8.c index 10b119a004d..4cf36a07faa 100644 --- a/contrib/btree_gist/btree_int8.c +++ b/contrib/btree_gist/btree_int8.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_int8.c,v 1.9 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_int8.c,v 1.10 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -57,8 +57,8 @@ gbt_int8lt(const void *a, const void *b) static int gbt_int8key_cmp(const void *a, const void *b) { - int64KEY *ia = (int64KEY*)(((Nsrt *) a)->t); - int64KEY *ib = (int64KEY*)(((Nsrt *) b)->t); + int64KEY *ia = (int64KEY *) (((Nsrt *) a)->t); + int64KEY *ib = (int64KEY *) (((Nsrt *) b)->t); if (ia->lower == ib->lower) { diff --git a/contrib/btree_gist/btree_interval.c b/contrib/btree_gist/btree_interval.c index 277835074b6..32b9ddbad74 100644 --- a/contrib/btree_gist/btree_interval.c +++ b/contrib/btree_gist/btree_interval.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_interval.c,v 1.13 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_interval.c,v 1.14 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -65,9 +65,9 @@ gbt_intvlt(const void *a, const void *b) static int gbt_intvkey_cmp(const void *a, const void *b) { - intvKEY *ia = (intvKEY*)(((Nsrt *) a)->t); - intvKEY *ib = (intvKEY*)(((Nsrt *) b)->t); - int res; + intvKEY *ia = (intvKEY *) (((Nsrt *) a)->t); + intvKEY *ib = (intvKEY *) (((Nsrt *) b)->t); + int res; res = DatumGetInt32(DirectFunctionCall2(interval_cmp, IntervalPGetDatum(&ia->lower), IntervalPGetDatum(&ib->lower))); if (res == 0) diff --git a/contrib/btree_gist/btree_macaddr.c b/contrib/btree_gist/btree_macaddr.c index 2683e1454cf..60092b4e9e2 100644 --- a/contrib/btree_gist/btree_macaddr.c +++ b/contrib/btree_gist/btree_macaddr.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_macaddr.c,v 1.9 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_macaddr.c,v 1.10 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -63,9 +63,9 @@ gbt_macadlt(const void *a, const void *b) static int gbt_macadkey_cmp(const void *a, const void *b) { - macKEY *ia = (macKEY*)(((Nsrt *) a)->t); - macKEY *ib = (macKEY*)(((Nsrt *) b)->t); - int res; + macKEY *ia = (macKEY *) (((Nsrt *) a)->t); + macKEY *ib = (macKEY *) (((Nsrt *) b)->t); + int res; res = DatumGetInt32(DirectFunctionCall2(macaddr_cmp, MacaddrPGetDatum(&ia->lower), MacaddrPGetDatum(&ib->lower))); if (res == 0) diff --git a/contrib/btree_gist/btree_oid.c b/contrib/btree_gist/btree_oid.c index 11327c29be4..96e4be54d4b 100644 --- a/contrib/btree_gist/btree_oid.c +++ b/contrib/btree_gist/btree_oid.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_oid.c,v 1.9 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_oid.c,v 1.10 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -57,8 +57,8 @@ gbt_oidlt(const void *a, const void *b) static int gbt_oidkey_cmp(const void *a, const void *b) { - oidKEY *ia = (oidKEY*)(((Nsrt *) a)->t); - oidKEY *ib = (oidKEY*)(((Nsrt *) b)->t); + oidKEY *ia = (oidKEY *) (((Nsrt *) a)->t); + oidKEY *ib = (oidKEY *) (((Nsrt *) b)->t); if (ia->lower == ib->lower) { diff --git a/contrib/btree_gist/btree_time.c b/contrib/btree_gist/btree_time.c index 25c756588be..8566a8efb70 100644 --- a/contrib/btree_gist/btree_time.c +++ b/contrib/btree_gist/btree_time.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_time.c,v 1.17 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_time.c,v 1.18 2010/02/26 02:00:31 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -101,9 +101,9 @@ gbt_timelt(const void *a, const void *b) static int gbt_timekey_cmp(const void *a, const void *b) { - timeKEY *ia = (timeKEY*)(((Nsrt *) a)->t); - timeKEY *ib = (timeKEY*)(((Nsrt *) b)->t); - int res; + timeKEY *ia = (timeKEY *) (((Nsrt *) a)->t); + timeKEY *ib = (timeKEY *) (((Nsrt *) b)->t); + int res; res = DatumGetInt32(DirectFunctionCall2(time_cmp, TimeADTGetDatumFast(ia->lower), TimeADTGetDatumFast(ib->lower))); if (res == 0) diff --git a/contrib/btree_gist/btree_ts.c b/contrib/btree_gist/btree_ts.c index 9b5dfba8cc8..543f2129b0b 100644 --- a/contrib/btree_gist/btree_ts.c +++ b/contrib/btree_gist/btree_ts.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_ts.c,v 1.18 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_ts.c,v 1.19 2010/02/26 02:00:32 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -99,9 +99,9 @@ gbt_tslt(const void *a, const void *b) static int gbt_tskey_cmp(const void *a, const void *b) { - tsKEY *ia = (tsKEY*)(((Nsrt *) a)->t); - tsKEY *ib = (tsKEY*)(((Nsrt *) b)->t); - int res; + tsKEY *ia = (tsKEY *) (((Nsrt *) a)->t); + tsKEY *ib = (tsKEY *) (((Nsrt *) b)->t); + int res; res = DatumGetInt32(DirectFunctionCall2(timestamp_cmp, TimestampGetDatumFast(ia->lower), TimestampGetDatumFast(ib->lower))); if (res == 0) diff --git a/contrib/btree_gist/btree_utils_var.c b/contrib/btree_gist/btree_utils_var.c index f5f490bf4e9..916706d8a47 100644 --- a/contrib/btree_gist/btree_utils_var.c +++ b/contrib/btree_gist/btree_utils_var.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_var.c,v 1.22 2009/12/02 13:13:24 teodor Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_var.c,v 1.23 2010/02/26 02:00:32 momjian Exp $ */ #include "btree_gist.h" @@ -444,7 +444,7 @@ gbt_vsrt_cmp(const void *a, const void *b, void *arg) GBT_VARKEY_R ar = gbt_var_key_readable(((const Vsrt *) a)->t); GBT_VARKEY_R br = gbt_var_key_readable(((const Vsrt *) b)->t); const gbtree_vinfo *tinfo = (const gbtree_vinfo *) arg; - int res; + int res; res = (*tinfo->f_cmp) (ar.lower, br.lower); if (res == 0) diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index f9dfba8da6b..abe64f3daec 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -8,7 +8,7 @@ * Darko Prenosil <Darko.Prenosil@finteh.hr> * Shridhar Daithankar <shridhar_daithankar@persistent.co.in> * - * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.90 2010/02/24 05:20:49 itagaki Exp $ + * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.91 2010/02/26 02:00:32 momjian Exp $ * Copyright (c) 2001-2010, PostgreSQL Global Development Group * ALL RIGHTS RESERVED; * @@ -101,7 +101,7 @@ static void dblink_security_check(PGconn *conn, remoteConn *rconn); static void dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_msg, bool fail); static char *get_connect_string(const char *servername); static char *escape_param_str(const char *from); -static int get_nondropped_natts(Oid relid); +static int get_nondropped_natts(Oid relid); /* Global */ static remoteConn *pconn = NULL; @@ -506,15 +506,15 @@ PG_FUNCTION_INFO_V1(dblink_fetch); Datum dblink_fetch(PG_FUNCTION_ARGS) { - ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; - PGresult *res = NULL; - char *conname = NULL; - remoteConn *rconn = NULL; - PGconn *conn = NULL; - StringInfoData buf; - char *curname = NULL; - int howmany = 0; - bool fail = true; /* default to backward compatible */ + ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; + PGresult *res = NULL; + char *conname = NULL; + remoteConn *rconn = NULL; + PGconn *conn = NULL; + StringInfoData buf; + char *curname = NULL; + int howmany = 0; + bool fail = true; /* default to backward compatible */ DBLINK_INIT; @@ -572,8 +572,8 @@ dblink_fetch(PG_FUNCTION_ARGS) /* * Try to execute the query. Note that since libpq uses malloc, the - * PGresult will be long-lived even though we are still in a - * short-lived memory context. + * PGresult will be long-lived even though we are still in a short-lived + * memory context. */ res = PQexec(conn, buf.data); if (!res || @@ -645,16 +645,16 @@ dblink_get_result(PG_FUNCTION_ARGS) static Datum dblink_record_internal(FunctionCallInfo fcinfo, bool is_async) { - ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; - char *msg; - PGresult *res = NULL; - PGconn *conn = NULL; - char *connstr = NULL; - char *sql = NULL; - char *conname = NULL; - remoteConn *rconn = NULL; - bool fail = true; /* default to backward compatible */ - bool freeconn = false; + ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; + char *msg; + PGresult *res = NULL; + PGconn *conn = NULL; + char *connstr = NULL; + char *sql = NULL; + char *conname = NULL; + remoteConn *rconn = NULL; + bool fail = true; /* default to backward compatible */ + bool freeconn = false; /* check to see if caller supports us returning a tuplestore */ if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo)) @@ -764,7 +764,7 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async) static void materializeResult(FunctionCallInfo fcinfo, PGresult *res) { - ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; + ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; Assert(rsinfo->returnMode == SFRM_Materialize); @@ -780,8 +780,8 @@ materializeResult(FunctionCallInfo fcinfo, PGresult *res) is_sql_cmd = true; /* - * need a tuple descriptor representing one TEXT column to - * return the command status string as our result tuple + * need a tuple descriptor representing one TEXT column to return + * the command status string as our result tuple */ tupdesc = CreateTemplateTupleDesc(1, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status", @@ -831,16 +831,16 @@ materializeResult(FunctionCallInfo fcinfo, PGresult *res) if (ntuples > 0) { - AttInMetadata *attinmeta; - Tuplestorestate *tupstore; - MemoryContext oldcontext; - int row; - char **values; + AttInMetadata *attinmeta; + Tuplestorestate *tupstore; + MemoryContext oldcontext; + int row; + char **values; attinmeta = TupleDescGetAttInMetadata(tupdesc); oldcontext = MemoryContextSwitchTo( - rsinfo->econtext->ecxt_per_query_memory); + rsinfo->econtext->ecxt_per_query_memory); tupstore = tuplestore_begin_heap(true, false, work_mem); rsinfo->setResult = tupstore; rsinfo->setDesc = tupdesc; @@ -1281,13 +1281,13 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS) "attributes too large"))); /* - * ensure we don't ask for more pk attributes than we have - * non-dropped columns + * ensure we don't ask for more pk attributes than we have non-dropped + * columns */ nondropped_natts = get_nondropped_natts(relid); if (pknumatts > nondropped_natts) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("number of primary key fields exceeds number of specified relation attributes"))); + errmsg("number of primary key fields exceeds number of specified relation attributes"))); /* * Source array is made up of key values that will be used to locate the @@ -1388,13 +1388,13 @@ dblink_build_sql_delete(PG_FUNCTION_ARGS) "attributes too large"))); /* - * ensure we don't ask for more pk attributes than we have - * non-dropped columns + * ensure we don't ask for more pk attributes than we have non-dropped + * columns */ nondropped_natts = get_nondropped_natts(relid); if (pknumatts > nondropped_natts) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("number of primary key fields exceeds number of specified relation attributes"))); + errmsg("number of primary key fields exceeds number of specified relation attributes"))); /* * Target array is made up of key values that will be used to build the @@ -1487,13 +1487,13 @@ dblink_build_sql_update(PG_FUNCTION_ARGS) "attributes too large"))); /* - * ensure we don't ask for more pk attributes than we have - * non-dropped columns + * ensure we don't ask for more pk attributes than we have non-dropped + * columns */ nondropped_natts = get_nondropped_natts(relid); if (pknumatts > nondropped_natts) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("number of primary key fields exceeds number of specified relation attributes"))); + errmsg("number of primary key fields exceeds number of specified relation attributes"))); /* * Source array is made up of key values that will be used to locate the @@ -1551,7 +1551,7 @@ dblink_current_query(PG_FUNCTION_ARGS) } /* - * Retrieve async notifications for a connection. + * Retrieve async notifications for a connection. * * Returns an setof record of notifications, or an empty set if none recieved. * Can optionally take a named connection as parameter, but uses the unnamed connection per default. @@ -1563,14 +1563,14 @@ PG_FUNCTION_INFO_V1(dblink_get_notify); Datum dblink_get_notify(PG_FUNCTION_ARGS) { - PGconn *conn = NULL; - remoteConn *rconn = NULL; - PGnotify *notify; - ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; - TupleDesc tupdesc; - Tuplestorestate *tupstore; - MemoryContext per_query_ctx; - MemoryContext oldcontext; + PGconn *conn = NULL; + remoteConn *rconn = NULL; + PGnotify *notify; + ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; + TupleDesc tupdesc; + Tuplestorestate *tupstore; + MemoryContext per_query_ctx; + MemoryContext oldcontext; DBLINK_INIT; if (PG_NARGS() == 1) @@ -2484,4 +2484,3 @@ get_nondropped_natts(Oid relid) relation_close(rel, AccessShareLock); return nondropped_natts; } - diff --git a/contrib/dict_xsyn/dict_xsyn.c b/contrib/dict_xsyn/dict_xsyn.c index 8c972484efe..dc16d9583e2 100644 --- a/contrib/dict_xsyn/dict_xsyn.c +++ b/contrib/dict_xsyn/dict_xsyn.c @@ -6,7 +6,7 @@ * Copyright (c) 2007-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/dict_xsyn/dict_xsyn.c,v 1.8 2010/01/02 16:57:32 momjian Exp $ + * $PostgreSQL: pgsql/contrib/dict_xsyn/dict_xsyn.c,v 1.9 2010/02/26 02:00:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -147,7 +147,7 @@ dxsyn_init(PG_FUNCTION_ARGS) List *dictoptions = (List *) PG_GETARG_POINTER(0); DictSyn *d; ListCell *l; - char *filename = NULL; + char *filename = NULL; d = (DictSyn *) palloc0(sizeof(DictSyn)); d->len = 0; diff --git a/contrib/hstore/hstore.h b/contrib/hstore/hstore.h index 495ac1afc9b..796dce575e5 100644 --- a/contrib/hstore/hstore.h +++ b/contrib/hstore/hstore.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/hstore.h,v 1.9 2009/09/30 19:50:22 tgl Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore.h,v 1.10 2010/02/26 02:00:32 momjian Exp $ */ #ifndef __HSTORE_H__ #define __HSTORE_H__ @@ -12,7 +12,7 @@ * HEntry: there is one of these for each key _and_ value in an hstore * * the position offset points to the _end_ so that we can get the length - * by subtraction from the previous entry. the ISFIRST flag lets us tell + * by subtraction from the previous entry. the ISFIRST flag lets us tell * whether there is a previous entry. */ typedef struct @@ -51,7 +51,7 @@ typedef struct /* * it's not possible to get more than 2^28 items into an hstore, * so we reserve the top few bits of the size field. See hstore_compat.c - * for one reason why. Some bits are left for future use here. + * for one reason why. Some bits are left for future use here. */ #define HS_FLAG_NEWVERSION 0x80000000 @@ -88,7 +88,7 @@ typedef struct * evaluation here. */ #define HS_COPYITEM(dent_,dbuf_,dptr_,sptr_,klen_,vlen_,vnull_) \ - do { \ + do { \ memcpy((dptr_), (sptr_), (klen_)+(vlen_)); \ (dptr_) += (klen_)+(vlen_); \ (dent_)++->entry = ((dptr_) - (dbuf_) - (vlen_)) & HENTRY_POSMASK; \ @@ -119,7 +119,7 @@ typedef struct /* finalize a newly-constructed hstore */ #define HS_FINALIZE(hsp_,count_,buf_,ptr_) \ do { \ - int buflen = (ptr_) - (buf_); \ + int buflen = (ptr_) - (buf_); \ if ((count_)) \ ARRPTR(hsp_)[0].entry |= HENTRY_ISFIRST; \ if ((count_) != HS_COUNT((hsp_))) \ @@ -133,7 +133,7 @@ typedef struct /* ensure the varlena size of an existing hstore is correct */ #define HS_FIXSIZE(hsp_,count_) \ do { \ - int bl = (count_) ? HSE_ENDPOS(ARRPTR(hsp_)[2*(count_)-1]) : 0; \ + int bl = (count_) ? HSE_ENDPOS(ARRPTR(hsp_)[2*(count_)-1]) : 0; \ SET_VARSIZE((hsp_), CALCDATASIZE((count_),bl)); \ } while (0) @@ -172,7 +172,7 @@ extern Pairs *hstoreArrayToPairs(ArrayType *a, int *npairs); #define HStoreExistsStrategyNumber 9 #define HStoreExistsAnyStrategyNumber 10 #define HStoreExistsAllStrategyNumber 11 -#define HStoreOldContainsStrategyNumber 13 /* backwards compatibility */ +#define HStoreOldContainsStrategyNumber 13 /* backwards compatibility */ /* * defining HSTORE_POLLUTE_NAMESPACE=0 will prevent use of old function names; diff --git a/contrib/hstore/hstore_compat.c b/contrib/hstore/hstore_compat.c index e2c2b55c100..033d945f9ca 100644 --- a/contrib/hstore/hstore_compat.c +++ b/contrib/hstore/hstore_compat.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/hstore_compat.c,v 1.1 2009/09/30 19:50:22 tgl Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore_compat.c,v 1.2 2010/02/26 02:00:32 momjian Exp $ * * Notes on old/new hstore format disambiguation. * @@ -106,24 +106,24 @@ typedef struct pos:31; } HOldEntry; -static int hstoreValidNewFormat(HStore *hs); -static int hstoreValidOldFormat(HStore *hs); +static int hstoreValidNewFormat(HStore *hs); +static int hstoreValidOldFormat(HStore *hs); /* * Validity test for a new-format hstore. - * 0 = not valid - * 1 = valid but with "slop" in the length - * 2 = exactly valid + * 0 = not valid + * 1 = valid but with "slop" in the length + * 2 = exactly valid */ static int hstoreValidNewFormat(HStore *hs) { - int count = HS_COUNT(hs); - HEntry *entries = ARRPTR(hs); - int buflen = (count) ? HSE_ENDPOS(entries[2*(count)-1]) : 0; - int vsize = CALCDATASIZE(count,buflen); - int i; + int count = HS_COUNT(hs); + HEntry *entries = ARRPTR(hs); + int buflen = (count) ? HSE_ENDPOS(entries[2 * (count) - 1]) : 0; + int vsize = CALCDATASIZE(count, buflen); + int i; if (hs->size_ & HS_FLAG_NEWVERSION) return 2; @@ -139,10 +139,10 @@ hstoreValidNewFormat(HStore *hs) /* entry position must be nondecreasing */ - for (i = 1; i < 2*count; ++i) + for (i = 1; i < 2 * count; ++i) { if (HSE_ISFIRST(entries[i]) - || (HSE_ENDPOS(entries[i]) < HSE_ENDPOS(entries[i-1]))) + || (HSE_ENDPOS(entries[i]) < HSE_ENDPOS(entries[i - 1]))) return 0; } @@ -150,9 +150,9 @@ hstoreValidNewFormat(HStore *hs) for (i = 1; i < count; ++i) { - if (HS_KEYLEN(entries,i) < HS_KEYLEN(entries,i-1)) + if (HS_KEYLEN(entries, i) < HS_KEYLEN(entries, i - 1)) return 0; - if (HSE_ISNULL(entries[2*i])) + if (HSE_ISNULL(entries[2 * i])) return 0; } @@ -164,18 +164,18 @@ hstoreValidNewFormat(HStore *hs) /* * Validity test for an old-format hstore. - * 0 = not valid - * 1 = valid but with "slop" in the length - * 2 = exactly valid + * 0 = not valid + * 1 = valid but with "slop" in the length + * 2 = exactly valid */ static int hstoreValidOldFormat(HStore *hs) { - int count = hs->size_; - HOldEntry *entries = (HOldEntry *) ARRPTR(hs); - int vsize; - int lastpos = 0; - int i; + int count = hs->size_; + HOldEntry *entries = (HOldEntry *) ARRPTR(hs); + int vsize; + int lastpos = 0; + int i; if (hs->size_ & HS_FLAG_NEWVERSION) return 0; @@ -188,7 +188,7 @@ hstoreValidOldFormat(HStore *hs) if (count > 0xFFFFFFF) return 0; - if (CALCDATASIZE(count,0) > VARSIZE(hs)) + if (CALCDATASIZE(count, 0) > VARSIZE(hs)) return 0; if (entries[0].pos != 0) @@ -198,14 +198,14 @@ hstoreValidOldFormat(HStore *hs) for (i = 1; i < count; ++i) { - if (entries[i].keylen < entries[i-1].keylen) + if (entries[i].keylen < entries[i - 1].keylen) return 0; } /* - * entry position must be strictly increasing, except for the - * first entry (which can be ""=>"" and thus zero-length); and - * all entries must be properly contiguous + * entry position must be strictly increasing, except for the first entry + * (which can be ""=>"" and thus zero-length); and all entries must be + * properly contiguous */ for (i = 0; i < count; ++i) @@ -216,7 +216,7 @@ hstoreValidOldFormat(HStore *hs) + ((entries[i].valisnull) ? 0 : entries[i].vallen)); } - vsize = CALCDATASIZE(count,lastpos); + vsize = CALCDATASIZE(count, lastpos); if (vsize > VARSIZE(hs)) return 0; @@ -255,108 +255,100 @@ hstoreUpgrade(Datum orig) if (valid_new) { /* - * force the "new version" flag and the correct varlena - * length, but only if we have a writable copy already - * (which we almost always will, since short new-format - * values won't come through here) + * force the "new version" flag and the correct varlena length, + * but only if we have a writable copy already (which we almost + * always will, since short new-format values won't come through + * here) */ if (writable) { - HS_SETCOUNT(hs,HS_COUNT(hs)); - HS_FIXSIZE(hs,HS_COUNT(hs)); + HS_SETCOUNT(hs, HS_COUNT(hs)); + HS_FIXSIZE(hs, HS_COUNT(hs)); } return hs; } else { - elog(ERROR,"invalid hstore value found"); + elog(ERROR, "invalid hstore value found"); } } /* - * this is the tricky edge case. It is only possible in some - * quite extreme cases (the hstore must have had a lot - * of wasted padding space at the end). - * But the only way a "new" hstore value could get here is if - * we're upgrading in place from a pre-release version of - * hstore-new (NOT contrib/hstore), so we work off the following - * assumptions: - * 1. If you're moving from old contrib/hstore to hstore-new, - * you're required to fix up any potential conflicts first, - * e.g. by running ALTER TABLE ... USING col::text::hstore; - * on all hstore columns before upgrading. - * 2. If you're moving from old contrib/hstore to new - * contrib/hstore, then "new" values are impossible here - * 3. If you're moving from pre-release hstore-new to hstore-new, - * then "old" values are impossible here - * 4. If you're moving from pre-release hstore-new to new - * contrib/hstore, you're not doing so as an in-place upgrade, - * so there is no issue - * So the upshot of all this is that we can treat all the edge - * cases as "new" if we're being built as hstore-new, and "old" - * if we're being built as contrib/hstore. + * this is the tricky edge case. It is only possible in some quite extreme + * cases (the hstore must have had a lot of wasted padding space at the + * end). But the only way a "new" hstore value could get here is if we're + * upgrading in place from a pre-release version of hstore-new (NOT + * contrib/hstore), so we work off the following assumptions: 1. If you're + * moving from old contrib/hstore to hstore-new, you're required to fix up + * any potential conflicts first, e.g. by running ALTER TABLE ... USING + * col::text::hstore; on all hstore columns before upgrading. 2. If you're + * moving from old contrib/hstore to new contrib/hstore, then "new" values + * are impossible here 3. If you're moving from pre-release hstore-new to + * hstore-new, then "old" values are impossible here 4. If you're moving + * from pre-release hstore-new to new contrib/hstore, you're not doing so + * as an in-place upgrade, so there is no issue So the upshot of all this + * is that we can treat all the edge cases as "new" if we're being built + * as hstore-new, and "old" if we're being built as contrib/hstore. * - * XXX the WARNING can probably be downgraded to DEBUG1 once this - * has been beta-tested. But for now, it would be very useful to - * know if anyone can actually reach this case in a non-contrived - * setting. + * XXX the WARNING can probably be downgraded to DEBUG1 once this has been + * beta-tested. But for now, it would be very useful to know if anyone can + * actually reach this case in a non-contrived setting. */ if (valid_new) { #if HSTORE_IS_HSTORE_NEW - elog(WARNING,"ambiguous hstore value resolved as hstore-new"); + elog(WARNING, "ambiguous hstore value resolved as hstore-new"); /* - * force the "new version" flag and the correct varlena - * length, but only if we have a writable copy already - * (which we almost always will, since short new-format - * values won't come through here) + * force the "new version" flag and the correct varlena length, but + * only if we have a writable copy already (which we almost always + * will, since short new-format values won't come through here) */ if (writable) { - HS_SETCOUNT(hs,HS_COUNT(hs)); - HS_FIXSIZE(hs,HS_COUNT(hs)); + HS_SETCOUNT(hs, HS_COUNT(hs)); + HS_FIXSIZE(hs, HS_COUNT(hs)); } return hs; #else - elog(WARNING,"ambiguous hstore value resolved as hstore-old"); + elog(WARNING, "ambiguous hstore value resolved as hstore-old"); #endif } /* - * must have an old-style value. Overwrite it in place as a new-style - * one, making sure we have a writable copy first. + * must have an old-style value. Overwrite it in place as a new-style one, + * making sure we have a writable copy first. */ if (!writable) hs = (HStore *) PG_DETOAST_DATUM_COPY(orig); { - int count = hs->size_; - HEntry *new_entries = ARRPTR(hs); - HOldEntry *old_entries = (HOldEntry *) ARRPTR(hs); - int i; - + int count = hs->size_; + HEntry *new_entries = ARRPTR(hs); + HOldEntry *old_entries = (HOldEntry *) ARRPTR(hs); + int i; + for (i = 0; i < count; ++i) { - uint32 pos = old_entries[i].pos; - uint32 keylen = old_entries[i].keylen; - uint32 vallen = old_entries[i].vallen; - bool isnull = old_entries[i].valisnull; + uint32 pos = old_entries[i].pos; + uint32 keylen = old_entries[i].keylen; + uint32 vallen = old_entries[i].vallen; + bool isnull = old_entries[i].valisnull; if (isnull) vallen = 0; - new_entries[2*i].entry = (pos + keylen) & HENTRY_POSMASK; - new_entries[2*i+1].entry = (((pos + keylen + vallen) & HENTRY_POSMASK) - | ((isnull) ? HENTRY_ISNULL : 0)); + new_entries[2 * i].entry = (pos + keylen) & HENTRY_POSMASK; + new_entries[2 * i + 1].entry = (((pos + keylen + vallen) & HENTRY_POSMASK) + | ((isnull) ? HENTRY_ISNULL : 0)); } if (count) new_entries[0].entry |= HENTRY_ISFIRST; - HS_SETCOUNT(hs,count); - HS_FIXSIZE(hs,count); + HS_SETCOUNT(hs, count); + HS_FIXSIZE(hs, count); } return hs; @@ -368,9 +360,9 @@ Datum hstore_version_diag(PG_FUNCTION_ARGS); Datum hstore_version_diag(PG_FUNCTION_ARGS) { - HStore *hs = (HStore *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); - int valid_new = hstoreValidNewFormat(hs); - int valid_old = hstoreValidOldFormat(hs); + HStore *hs = (HStore *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); + int valid_new = hstoreValidNewFormat(hs); + int valid_old = hstoreValidOldFormat(hs); - PG_RETURN_INT32(valid_old*10 + valid_new); + PG_RETURN_INT32(valid_old * 10 + valid_new); } diff --git a/contrib/hstore/hstore_gin.c b/contrib/hstore/hstore_gin.c index 3bd9d718bb3..f5056f53ec6 100644 --- a/contrib/hstore/hstore_gin.c +++ b/contrib/hstore/hstore_gin.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/hstore_gin.c,v 1.7 2009/09/30 19:50:22 tgl Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore_gin.c,v 1.8 2010/02/26 02:00:32 momjian Exp $ */ #include "postgres.h" @@ -36,10 +36,10 @@ gin_extract_hstore(PG_FUNCTION_ARGS) HStore *hs = PG_GETARG_HS(0); int32 *nentries = (int32 *) PG_GETARG_POINTER(1); Datum *entries = NULL; - HEntry *hsent = ARRPTR(hs); - char *ptr = STRPTR(hs); - int count = HS_COUNT(hs); - int i; + HEntry *hsent = ARRPTR(hs); + char *ptr = STRPTR(hs); + int count = HS_COUNT(hs); + int i; *nentries = 2 * count; if (count) @@ -49,21 +49,21 @@ gin_extract_hstore(PG_FUNCTION_ARGS) { text *item; - item = makeitem(HS_KEY(hsent,ptr,i), HS_KEYLEN(hsent,i)); + item = makeitem(HS_KEY(hsent, ptr, i), HS_KEYLEN(hsent, i)); *VARDATA(item) = KEYFLAG; - entries[2*i] = PointerGetDatum(item); + entries[2 * i] = PointerGetDatum(item); - if (HS_VALISNULL(hsent,i)) + if (HS_VALISNULL(hsent, i)) { item = makeitem(NULL, 0); *VARDATA(item) = NULLFLAG; } else { - item = makeitem(HS_VAL(hsent,ptr,i), HS_VALLEN(hsent,i)); + item = makeitem(HS_VAL(hsent, ptr, i), HS_VALLEN(hsent, i)); *VARDATA(item) = VALFLAG; } - entries[2*i+1] = PointerGetDatum(item); + entries[2 * i + 1] = PointerGetDatum(item); } PG_RETURN_POINTER(entries); @@ -103,14 +103,15 @@ gin_extract_hstore_query(PG_FUNCTION_ARGS) else if (strategy == HStoreExistsAnyStrategyNumber || strategy == HStoreExistsAllStrategyNumber) { - ArrayType *query = PG_GETARG_ARRAYTYPE_P(0); - Datum *key_datums; - bool *key_nulls; - int key_count; - int i,j; + ArrayType *query = PG_GETARG_ARRAYTYPE_P(0); + Datum *key_datums; + bool *key_nulls; + int key_count; + int i, + j; int32 *nentries = (int32 *) PG_GETARG_POINTER(1); Datum *entries = NULL; - text *item; + text *item; deconstruct_array(query, TEXTOID, -1, false, 'i', @@ -145,8 +146,10 @@ gin_consistent_hstore(PG_FUNCTION_ARGS) { bool *check = (bool *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); + /* HStore *query = PG_GETARG_HS(2); */ int32 nkeys = PG_GETARG_INT32(3); + /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ bool *recheck = (bool *) PG_GETARG_POINTER(5); bool res = true; @@ -178,7 +181,7 @@ gin_consistent_hstore(PG_FUNCTION_ARGS) } else if (strategy == HStoreExistsAllStrategyNumber) { - int i; + int i; for (i = 0; res && i < nkeys; ++i) if (!check[i]) diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c index b036fa932f2..db58fb62ddf 100644 --- a/contrib/hstore/hstore_gist.c +++ b/contrib/hstore/hstore_gist.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/hstore_gist.c,v 1.11 2009/09/30 19:50:22 tgl Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore_gist.c,v 1.12 2010/02/26 02:00:32 momjian Exp $ */ #include "postgres.h" @@ -118,20 +118,20 @@ ghstore_compress(PG_FUNCTION_ARGS) HStore *val = DatumGetHStoreP(entry->key); HEntry *hsent = ARRPTR(val); char *ptr = STRPTR(val); - int count = HS_COUNT(val); - int i; + int count = HS_COUNT(val); + int i; SET_VARSIZE(res, CALCGTSIZE(0)); for (i = 0; i < count; ++i) { - int h; + int h; - h = crc32_sz((char *) HS_KEY(hsent,ptr,i), HS_KEYLEN(hsent,i)); + h = crc32_sz((char *) HS_KEY(hsent, ptr, i), HS_KEYLEN(hsent, i)); HASH(GETSIGN(res), h); - if (!HS_VALISNULL(hsent,i)) + if (!HS_VALISNULL(hsent, i)) { - h = crc32_sz((char *) HS_VAL(hsent,ptr,i), HS_VALLEN(hsent,i)); + h = crc32_sz((char *) HS_VAL(hsent, ptr, i), HS_VALLEN(hsent, i)); HASH(GETSIGN(res), h); } } @@ -511,6 +511,7 @@ ghstore_consistent(PG_FUNCTION_ARGS) { GISTTYPE *entry = (GISTTYPE *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool res = true; @@ -530,18 +531,18 @@ ghstore_consistent(PG_FUNCTION_ARGS) HStore *query = PG_GETARG_HS(1); HEntry *qe = ARRPTR(query); char *qv = STRPTR(query); - int count = HS_COUNT(query); - int i; + int count = HS_COUNT(query); + int i; for (i = 0; res && i < count; ++i) { - int crc = crc32_sz((char *) HS_KEY(qe,qv,i), HS_KEYLEN(qe,i)); + int crc = crc32_sz((char *) HS_KEY(qe, qv, i), HS_KEYLEN(qe, i)); if (GETBIT(sign, HASHVAL(crc))) { - if (!HS_VALISNULL(qe,i)) + if (!HS_VALISNULL(qe, i)) { - crc = crc32_sz((char *) HS_VAL(qe,qv,i), HS_VALLEN(qe,i)); + crc = crc32_sz((char *) HS_VAL(qe, qv, i), HS_VALLEN(qe, i)); if (!GETBIT(sign, HASHVAL(crc))) res = false; } @@ -559,11 +560,11 @@ ghstore_consistent(PG_FUNCTION_ARGS) } else if (strategy == HStoreExistsAllStrategyNumber) { - ArrayType *query = PG_GETARG_ARRAYTYPE_P(1); - Datum *key_datums; - bool *key_nulls; - int key_count; - int i; + ArrayType *query = PG_GETARG_ARRAYTYPE_P(1); + Datum *key_datums; + bool *key_nulls; + int key_count; + int i; deconstruct_array(query, TEXTOID, -1, false, 'i', @@ -571,7 +572,8 @@ ghstore_consistent(PG_FUNCTION_ARGS) for (i = 0; res && i < key_count; ++i) { - int crc; + int crc; + if (key_nulls[i]) continue; crc = crc32_sz(VARDATA(key_datums[i]), VARSIZE(key_datums[i]) - VARHDRSZ); @@ -581,11 +583,11 @@ ghstore_consistent(PG_FUNCTION_ARGS) } else if (strategy == HStoreExistsAnyStrategyNumber) { - ArrayType *query = PG_GETARG_ARRAYTYPE_P(1); - Datum *key_datums; - bool *key_nulls; - int key_count; - int i; + ArrayType *query = PG_GETARG_ARRAYTYPE_P(1); + Datum *key_datums; + bool *key_nulls; + int key_count; + int i; deconstruct_array(query, TEXTOID, -1, false, 'i', @@ -595,7 +597,8 @@ ghstore_consistent(PG_FUNCTION_ARGS) for (i = 0; !res && i < key_count; ++i) { - int crc; + int crc; + if (key_nulls[i]) continue; crc = crc32_sz(VARDATA(key_datums[i]), VARSIZE(key_datums[i]) - VARHDRSZ); diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c index a79cddef0af..fa6da693e94 100644 --- a/contrib/hstore/hstore_io.c +++ b/contrib/hstore/hstore_io.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/hstore_io.c,v 1.12 2009/09/30 19:50:22 tgl Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore_io.c,v 1.13 2010/02/26 02:00:32 momjian Exp $ */ #include "postgres.h" @@ -18,7 +18,7 @@ PG_MODULE_MAGIC; /* old names for C functions */ -HSTORE_POLLUTE(hstore_from_text,tconvert); +HSTORE_POLLUTE(hstore_from_text, tconvert); typedef struct @@ -370,12 +370,12 @@ hstoreCheckValLen(size_t len) HStore * hstorePairs(Pairs *pairs, int4 pcount, int4 buflen) { - HStore *out; + HStore *out; HEntry *entry; char *ptr; char *buf; - int4 len; - int4 i; + int4 len; + int4 i; len = CALCDATASIZE(pcount, buflen); out = palloc(len); @@ -389,9 +389,9 @@ hstorePairs(Pairs *pairs, int4 pcount, int4 buflen) buf = ptr = STRPTR(out); for (i = 0; i < pcount; i++) - HS_ADDITEM(entry,buf,ptr,pairs[i]); + HS_ADDITEM(entry, buf, ptr, pairs[i]); - HS_FINALIZE(out,pcount,buf,ptr); + HS_FINALIZE(out, pcount, buf, ptr); return out; } @@ -426,9 +426,9 @@ hstore_recv(PG_FUNCTION_ARGS) int4 buflen; HStore *out; Pairs *pairs; - int4 i; - int4 pcount; - StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + int4 i; + int4 pcount; + StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); pcount = pq_getmsgint(buf, 4); @@ -442,8 +442,8 @@ hstore_recv(PG_FUNCTION_ARGS) for (i = 0; i < pcount; ++i) { - int rawlen = pq_getmsgint(buf, 4); - int len; + int rawlen = pq_getmsgint(buf, 4); + int len; if (rawlen < 0) ereport(ERROR, @@ -482,9 +482,9 @@ Datum hstore_from_text(PG_FUNCTION_ARGS); Datum hstore_from_text(PG_FUNCTION_ARGS) { - text *key; - text *val = NULL; - Pairs p; + text *key; + text *val = NULL; + Pairs p; HStore *out; if (PG_ARGISNULL(0)) @@ -524,13 +524,13 @@ hstore_from_arrays(PG_FUNCTION_ARGS) Pairs *pairs; Datum *key_datums; bool *key_nulls; - int key_count; + int key_count; Datum *value_datums; bool *value_nulls; - int value_count; + int value_count; ArrayType *key_array; ArrayType *value_array; - int i; + int i; if (PG_ARGISNULL(0)) PG_RETURN_NULL(); @@ -540,8 +540,8 @@ hstore_from_arrays(PG_FUNCTION_ARGS) Assert(ARR_ELEMTYPE(key_array) == TEXTOID); /* - * must check >1 rather than != 1 because empty arrays have - * 0 dimensions, not 1 + * must check >1 rather than != 1 because empty arrays have 0 dimensions, + * not 1 */ if (ARR_NDIM(key_array) > 1) @@ -631,15 +631,15 @@ Datum hstore_from_array(PG_FUNCTION_ARGS) { ArrayType *in_array = PG_GETARG_ARRAYTYPE_P(0); - int ndims = ARR_NDIM(in_array); - int count; + int ndims = ARR_NDIM(in_array); + int count; int4 buflen; HStore *out; Pairs *pairs; Datum *in_datums; bool *in_nulls; - int in_count; - int i; + int in_count; + int i; Assert(ARR_ELEMTYPE(in_array) == TEXTOID); @@ -667,7 +667,7 @@ hstore_from_array(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), errmsg("wrong number of array subscripts"))); - } + } deconstruct_array(in_array, TEXTOID, -1, false, 'i', @@ -679,26 +679,26 @@ hstore_from_array(PG_FUNCTION_ARGS) for (i = 0; i < count; ++i) { - if (in_nulls[i*2]) + if (in_nulls[i * 2]) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), errmsg("null value not allowed for hstore key"))); - if (in_nulls[i*2+1]) + if (in_nulls[i * 2 + 1]) { - pairs[i].key = VARDATA_ANY(in_datums[i*2]); + pairs[i].key = VARDATA_ANY(in_datums[i * 2]); pairs[i].val = NULL; - pairs[i].keylen = hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(in_datums[i*2])); + pairs[i].keylen = hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(in_datums[i * 2])); pairs[i].vallen = 4; pairs[i].isnull = true; pairs[i].needfree = false; } else { - pairs[i].key = VARDATA_ANY(in_datums[i*2]); - pairs[i].val = VARDATA_ANY(in_datums[i*2+1]); - pairs[i].keylen = hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(in_datums[i*2])); - pairs[i].vallen = hstoreCheckValLen(VARSIZE_ANY_EXHDR(in_datums[i*2+1])); + pairs[i].key = VARDATA_ANY(in_datums[i * 2]); + pairs[i].val = VARDATA_ANY(in_datums[i * 2 + 1]); + pairs[i].keylen = hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(in_datums[i * 2])); + pairs[i].vallen = hstoreCheckValLen(VARSIZE_ANY_EXHDR(in_datums[i * 2 + 1])); pairs[i].isnull = false; pairs[i].needfree = false; } @@ -740,25 +740,26 @@ hstore_from_record(PG_FUNCTION_ARGS) HeapTupleHeader rec; int4 buflen; HStore *out; - Pairs *pairs; + Pairs *pairs; Oid tupType; int32 tupTypmod; TupleDesc tupdesc; HeapTupleData tuple; RecordIOData *my_extra; int ncolumns; - int i,j; + int i, + j; Datum *values; bool *nulls; if (PG_ARGISNULL(0)) { - Oid argtype = get_fn_expr_argtype(fcinfo->flinfo,0); + Oid argtype = get_fn_expr_argtype(fcinfo->flinfo, 0); /* - * have no tuple to look at, so the only source of type info - * is the argtype. The lookup_rowtype_tupdesc call below will - * error out if we don't have a known composite type oid here. + * have no tuple to look at, so the only source of type info is the + * argtype. The lookup_rowtype_tupdesc call below will error out if we + * don't have a known composite type oid here. */ tupType = argtype; tupTypmod = -1; @@ -855,7 +856,7 @@ hstore_from_record(PG_FUNCTION_ARGS) */ if (column_info->column_type != column_type) { - bool typIsVarlena; + bool typIsVarlena; getTypeOutputInfo(column_type, &column_info->typiofunc, @@ -889,18 +890,18 @@ Datum hstore_populate_record(PG_FUNCTION_ARGS); Datum hstore_populate_record(PG_FUNCTION_ARGS) { - Oid argtype = get_fn_expr_argtype(fcinfo->flinfo,0); - HStore *hs; - HEntry *entries; - char *ptr; + Oid argtype = get_fn_expr_argtype(fcinfo->flinfo, 0); + HStore *hs; + HEntry *entries; + char *ptr; HeapTupleHeader rec; Oid tupType; int32 tupTypmod; TupleDesc tupdesc; HeapTupleData tuple; - HeapTuple rettuple; + HeapTuple rettuple; RecordIOData *my_extra; - int ncolumns; + int ncolumns; int i; Datum *values; bool *nulls; @@ -918,9 +919,9 @@ hstore_populate_record(PG_FUNCTION_ARGS) rec = NULL; /* - * have no tuple to look at, so the only source of type info - * is the argtype. The lookup_rowtype_tupdesc call below will - * error out if we don't have a known composite type oid here. + * have no tuple to look at, so the only source of type info is the + * argtype. The lookup_rowtype_tupdesc call below will error out if we + * don't have a known composite type oid here. */ tupType = argtype; tupTypmod = -1; @@ -942,9 +943,9 @@ hstore_populate_record(PG_FUNCTION_ARGS) ptr = STRPTR(hs); /* - * if the input hstore is empty, we can only skip the rest if - * we were passed in a non-null record, since otherwise there - * may be issues with domain nulls. + * if the input hstore is empty, we can only skip the rest if we were + * passed in a non-null record, since otherwise there may be issues with + * domain nulls. */ if (HS_COUNT(hs) == 0 && rec) @@ -1012,8 +1013,8 @@ hstore_populate_record(PG_FUNCTION_ARGS) ColumnIOData *column_info = &my_extra->columns[i]; Oid column_type = tupdesc->attrs[i]->atttypid; char *value; - int idx; - int vallen; + int idx; + int vallen; /* Ignore dropped columns in datatype */ if (tupdesc->attrs[i]->attisdropped) @@ -1025,14 +1026,14 @@ hstore_populate_record(PG_FUNCTION_ARGS) idx = hstoreFindKey(hs, 0, NameStr(tupdesc->attrs[i]->attname), strlen(NameStr(tupdesc->attrs[i]->attname))); + /* - * we can't just skip here if the key wasn't found since we - * might have a domain to deal with. If we were passed in a - * non-null record datum, we assume that the existing values - * are valid (if they're not, then it's not our fault), but if - * we were passed in a null, then every field which we don't - * populate needs to be run through the input function just in - * case it's a domain type. + * we can't just skip here if the key wasn't found since we might have + * a domain to deal with. If we were passed in a non-null record + * datum, we assume that the existing values are valid (if they're + * not, then it's not our fault), but if we were passed in a null, + * then every field which we don't populate needs to be run through + * the input function just in case it's a domain type. */ if (idx < 0 && rec) continue; @@ -1050,11 +1051,11 @@ hstore_populate_record(PG_FUNCTION_ARGS) column_info->column_type = column_type; } - if (idx < 0 || HS_VALISNULL(entries,idx)) + if (idx < 0 || HS_VALISNULL(entries, idx)) { /* - * need InputFunctionCall to happen even for nulls, so - * that domain checks are done + * need InputFunctionCall to happen even for nulls, so that domain + * checks are done */ values[i] = InputFunctionCall(&column_info->proc, NULL, column_info->typioparam, @@ -1063,9 +1064,9 @@ hstore_populate_record(PG_FUNCTION_ARGS) } else { - vallen = HS_VALLEN(entries,idx); + vallen = HS_VALLEN(entries, idx); value = palloc(1 + vallen); - memcpy(value, HS_VAL(entries,ptr,idx), vallen); + memcpy(value, HS_VAL(entries, ptr, idx), vallen); value[vallen] = 0; values[i] = InputFunctionCall(&column_info->proc, value, @@ -1105,7 +1106,7 @@ hstore_out(PG_FUNCTION_ARGS) HStore *in = PG_GETARG_HS(0); int buflen, i; - int count = HS_COUNT(in); + int count = HS_COUNT(in); char *out, *ptr; char *base = STRPTR(in); @@ -1121,21 +1122,21 @@ hstore_out(PG_FUNCTION_ARGS) buflen = 0; /* - * this loop overestimates due to pessimistic assumptions about - * escaping, so very large hstore values can't be output. this - * could be fixed, but many other data types probably have the - * same issue. This replaced code that used the original varlena - * size for calculations, which was wrong in some subtle ways. + * this loop overestimates due to pessimistic assumptions about escaping, + * so very large hstore values can't be output. this could be fixed, but + * many other data types probably have the same issue. This replaced code + * that used the original varlena size for calculations, which was wrong + * in some subtle ways. */ for (i = 0; i < count; i++) { /* include "" and => and comma-space */ - buflen += 6 + 2 * HS_KEYLEN(entries,i); + buflen += 6 + 2 * HS_KEYLEN(entries, i); /* include "" only if nonnull */ - buflen += 2 + (HS_VALISNULL(entries,i) + buflen += 2 + (HS_VALISNULL(entries, i) ? 2 - : 2 * HS_VALLEN(entries,i)); + : 2 * HS_VALLEN(entries, i)); } out = ptr = palloc(buflen); @@ -1143,11 +1144,11 @@ hstore_out(PG_FUNCTION_ARGS) for (i = 0; i < count; i++) { *ptr++ = '"'; - ptr = cpw(ptr, HS_KEY(entries,base,i), HS_KEYLEN(entries,i)); + ptr = cpw(ptr, HS_KEY(entries, base, i), HS_KEYLEN(entries, i)); *ptr++ = '"'; *ptr++ = '='; *ptr++ = '>'; - if (HS_VALISNULL(entries,i)) + if (HS_VALISNULL(entries, i)) { *ptr++ = 'N'; *ptr++ = 'U'; @@ -1157,7 +1158,7 @@ hstore_out(PG_FUNCTION_ARGS) else { *ptr++ = '"'; - ptr = cpw(ptr, HS_VAL(entries,base,i), HS_VALLEN(entries,i)); + ptr = cpw(ptr, HS_VAL(entries, base, i), HS_VALLEN(entries, i)); *ptr++ = '"'; } @@ -1179,8 +1180,8 @@ Datum hstore_send(PG_FUNCTION_ARGS) { HStore *in = PG_GETARG_HS(0); - int i; - int count = HS_COUNT(in); + int i; + int count = HS_COUNT(in); char *base = STRPTR(in); HEntry *entries = ARRPTR(in); StringInfoData buf; @@ -1191,18 +1192,20 @@ hstore_send(PG_FUNCTION_ARGS) for (i = 0; i < count; i++) { - int32 keylen = HS_KEYLEN(entries,i); + int32 keylen = HS_KEYLEN(entries, i); + pq_sendint(&buf, keylen, 4); - pq_sendtext(&buf, HS_KEY(entries,base,i), keylen); - if (HS_VALISNULL(entries,i)) + pq_sendtext(&buf, HS_KEY(entries, base, i), keylen); + if (HS_VALISNULL(entries, i)) { pq_sendint(&buf, -1, 4); } else { - int32 vallen = HS_VALLEN(entries,i); + int32 vallen = HS_VALLEN(entries, i); + pq_sendint(&buf, vallen, 4); - pq_sendtext(&buf, HS_VAL(entries,base,i), vallen); + pq_sendtext(&buf, HS_VAL(entries, base, i), vallen); } } diff --git a/contrib/hstore/hstore_op.c b/contrib/hstore/hstore_op.c index cc1a162dacb..ebee60a1dbe 100644 --- a/contrib/hstore/hstore_op.c +++ b/contrib/hstore/hstore_op.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/hstore_op.c,v 1.15 2009/09/30 21:26:17 tgl Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore_op.c,v 1.16 2010/02/26 02:00:32 momjian Exp $ */ #include "postgres.h" @@ -13,18 +13,18 @@ #include "hstore.h" /* old names for C functions */ -HSTORE_POLLUTE(hstore_fetchval,fetchval); -HSTORE_POLLUTE(hstore_exists,exists); -HSTORE_POLLUTE(hstore_defined,defined); -HSTORE_POLLUTE(hstore_delete,delete); -HSTORE_POLLUTE(hstore_concat,hs_concat); -HSTORE_POLLUTE(hstore_contains,hs_contains); -HSTORE_POLLUTE(hstore_contained,hs_contained); -HSTORE_POLLUTE(hstore_akeys,akeys); -HSTORE_POLLUTE(hstore_avals,avals); -HSTORE_POLLUTE(hstore_skeys,skeys); -HSTORE_POLLUTE(hstore_svals,svals); -HSTORE_POLLUTE(hstore_each,each); +HSTORE_POLLUTE(hstore_fetchval, fetchval); +HSTORE_POLLUTE(hstore_exists, exists); +HSTORE_POLLUTE(hstore_defined, defined); +HSTORE_POLLUTE(hstore_delete, delete); +HSTORE_POLLUTE(hstore_concat, hs_concat); +HSTORE_POLLUTE(hstore_contains, hs_contains); +HSTORE_POLLUTE(hstore_contained, hs_contained); +HSTORE_POLLUTE(hstore_akeys, akeys); +HSTORE_POLLUTE(hstore_avals, avals); +HSTORE_POLLUTE(hstore_skeys, skeys); +HSTORE_POLLUTE(hstore_svals, svals); +HSTORE_POLLUTE(hstore_each, each); /* @@ -34,24 +34,24 @@ HSTORE_POLLUTE(hstore_each,each); * one-off or unordered searches. */ int -hstoreFindKey(HStore * hs, int *lowbound, char *key, int keylen) +hstoreFindKey(HStore *hs, int *lowbound, char *key, int keylen) { HEntry *entries = ARRPTR(hs); - int stopLow = lowbound ? *lowbound : 0; - int stopHigh = HS_COUNT(hs); - int stopMiddle; + int stopLow = lowbound ? *lowbound : 0; + int stopHigh = HS_COUNT(hs); + int stopMiddle; char *base = STRPTR(hs); while (stopLow < stopHigh) { - int difference; + int difference; stopMiddle = stopLow + (stopHigh - stopLow) / 2; - if (HS_KEYLEN(entries,stopMiddle) == keylen) - difference = strncmp(HS_KEY(entries,base,stopMiddle), key, keylen); + if (HS_KEYLEN(entries, stopMiddle) == keylen) + difference = strncmp(HS_KEY(entries, base, stopMiddle), key, keylen); else - difference = (HS_KEYLEN(entries,stopMiddle) > keylen) ? 1 : -1; + difference = (HS_KEYLEN(entries, stopMiddle) > keylen) ? 1 : -1; if (difference == 0) { @@ -73,12 +73,13 @@ hstoreFindKey(HStore * hs, int *lowbound, char *key, int keylen) Pairs * hstoreArrayToPairs(ArrayType *a, int *npairs) { - Datum *key_datums; - bool *key_nulls; - int key_count; - Pairs *key_pairs; - int bufsiz; - int i,j; + Datum *key_datums; + bool *key_nulls; + int key_count; + Pairs *key_pairs; + int bufsiz; + int i, + j; deconstruct_array(a, TEXTOID, -1, false, 'i', @@ -121,14 +122,14 @@ hstore_fetchval(PG_FUNCTION_ARGS) text *key = PG_GETARG_TEXT_PP(1); HEntry *entries = ARRPTR(hs); text *out; - int idx = hstoreFindKey(hs, NULL, + int idx = hstoreFindKey(hs, NULL, VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key)); - if (idx < 0 || HS_VALISNULL(entries,idx)) + if (idx < 0 || HS_VALISNULL(entries, idx)) PG_RETURN_NULL(); - out = cstring_to_text_with_len(HS_VAL(entries,STRPTR(hs),idx), - HS_VALLEN(entries,idx)); + out = cstring_to_text_with_len(HS_VAL(entries, STRPTR(hs), idx), + HS_VALLEN(entries, idx)); PG_RETURN_TEXT_P(out); } @@ -141,7 +142,7 @@ hstore_exists(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); text *key = PG_GETARG_TEXT_PP(1); - int idx = hstoreFindKey(hs, NULL, + int idx = hstoreFindKey(hs, NULL, VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key)); PG_RETURN_BOOL(idx >= 0); @@ -155,23 +156,23 @@ hstore_exists_any(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1); - int nkeys; - Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys); - int i; - int lowbound = 0; - bool res = false; + int nkeys; + Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys); + int i; + int lowbound = 0; + bool res = false; /* - * we exploit the fact that the pairs list is already sorted into - * strictly increasing order to narrow the hstoreFindKey search; - * each search can start one entry past the previous "found" - * entry, or at the lower bound of the last search. + * we exploit the fact that the pairs list is already sorted into strictly + * increasing order to narrow the hstoreFindKey search; each search can + * start one entry past the previous "found" entry, or at the lower bound + * of the last search. */ for (i = 0; !res && i < nkeys; ++i) { - int idx = hstoreFindKey(hs, &lowbound, - key_pairs[i].key, key_pairs[i].keylen); + int idx = hstoreFindKey(hs, &lowbound, + key_pairs[i].key, key_pairs[i].keylen); if (idx >= 0) res = true; @@ -188,23 +189,23 @@ hstore_exists_all(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1); - int nkeys; - Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys); - int i; - int lowbound = 0; - bool res = nkeys ? true : false; + int nkeys; + Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys); + int i; + int lowbound = 0; + bool res = nkeys ? true : false; /* - * we exploit the fact that the pairs list is already sorted into - * strictly increasing order to narrow the hstoreFindKey search; - * each search can start one entry past the previous "found" - * entry, or at the lower bound of the last search. + * we exploit the fact that the pairs list is already sorted into strictly + * increasing order to narrow the hstoreFindKey search; each search can + * start one entry past the previous "found" entry, or at the lower bound + * of the last search. */ for (i = 0; res && i < nkeys; ++i) { - int idx = hstoreFindKey(hs, &lowbound, - key_pairs[i].key, key_pairs[i].keylen); + int idx = hstoreFindKey(hs, &lowbound, + key_pairs[i].key, key_pairs[i].keylen); if (idx < 0) res = false; @@ -222,9 +223,9 @@ hstore_defined(PG_FUNCTION_ARGS) HStore *hs = PG_GETARG_HS(0); text *key = PG_GETARG_TEXT_PP(1); HEntry *entries = ARRPTR(hs); - int idx = hstoreFindKey(hs, NULL, + int idx = hstoreFindKey(hs, NULL, VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key)); - bool res = (idx >= 0 && !HS_VALISNULL(entries,idx)); + bool res = (idx >= 0 && !HS_VALISNULL(entries, idx)); PG_RETURN_BOOL(res); } @@ -237,20 +238,20 @@ hstore_delete(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); text *key = PG_GETARG_TEXT_PP(1); - char *keyptr = VARDATA_ANY(key); - int keylen = VARSIZE_ANY_EXHDR(key); + char *keyptr = VARDATA_ANY(key); + int keylen = VARSIZE_ANY_EXHDR(key); HStore *out = palloc(VARSIZE(hs)); char *bufs, - *bufd, + *bufd, *ptrd; HEntry *es, *ed; - int i; - int count = HS_COUNT(hs); - int outcount = 0; + int i; + int count = HS_COUNT(hs); + int outcount = 0; SET_VARSIZE(out, VARSIZE(hs)); - HS_SETCOUNT(out, count); /* temporary! */ + HS_SETCOUNT(out, count); /* temporary! */ bufs = STRPTR(hs); es = ARRPTR(hs); @@ -259,18 +260,19 @@ hstore_delete(PG_FUNCTION_ARGS) for (i = 0; i < count; ++i) { - int len = HS_KEYLEN(es,i); - char *ptrs = HS_KEY(es,bufs,i); + int len = HS_KEYLEN(es, i); + char *ptrs = HS_KEY(es, bufs, i); if (!(len == keylen && strncmp(ptrs, keyptr, keylen) == 0)) { - int vallen = HS_VALLEN(es,i); - HS_COPYITEM(ed, bufd, ptrd, ptrs, len, vallen, HS_VALISNULL(es,i)); + int vallen = HS_VALLEN(es, i); + + HS_COPYITEM(ed, bufd, ptrd, ptrs, len, vallen, HS_VALISNULL(es, i)); ++outcount; } } - HS_FINALIZE(out,outcount,bufd,ptrd); + HS_FINALIZE(out, outcount, bufd, ptrd); PG_RETURN_POINTER(out); } @@ -283,20 +285,21 @@ hstore_delete_array(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); HStore *out = palloc(VARSIZE(hs)); - int hs_count = HS_COUNT(hs); + int hs_count = HS_COUNT(hs); char *ps, - *bufd, + *bufd, *pd; HEntry *es, *ed; - int i,j; - int outcount = 0; + int i, + j; + int outcount = 0; ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1); - int nkeys; - Pairs *key_pairs = hstoreArrayToPairs(key_array, &nkeys); + int nkeys; + Pairs *key_pairs = hstoreArrayToPairs(key_array, &nkeys); SET_VARSIZE(out, VARSIZE(hs)); - HS_SETCOUNT(out, hs_count); /* temporary! */ + HS_SETCOUNT(out, hs_count); /* temporary! */ ps = STRPTR(hs); es = ARRPTR(hs); @@ -313,22 +316,22 @@ hstore_delete_array(PG_FUNCTION_ARGS) } /* - * this is in effect a merge between hs and key_pairs, both of - * which are already sorted by (keylen,key); we take keys from - * hs only + * this is in effect a merge between hs and key_pairs, both of which are + * already sorted by (keylen,key); we take keys from hs only */ - for (i = j = 0; i < hs_count; ) + for (i = j = 0; i < hs_count;) { - int difference; - + int difference; + if (j >= nkeys) difference = -1; else { - int skeylen = HS_KEYLEN(es,i); + int skeylen = HS_KEYLEN(es, i); + if (skeylen == key_pairs[j].keylen) - difference = strncmp(HS_KEY(es,ps,i), + difference = strncmp(HS_KEY(es, ps, i), key_pairs[j].key, key_pairs[j].keylen); else @@ -342,14 +345,14 @@ hstore_delete_array(PG_FUNCTION_ARGS) else { HS_COPYITEM(ed, bufd, pd, - HS_KEY(es,ps,i), HS_KEYLEN(es,i), - HS_VALLEN(es,i), HS_VALISNULL(es,i)); + HS_KEY(es, ps, i), HS_KEYLEN(es, i), + HS_VALLEN(es, i), HS_VALISNULL(es, i)); ++outcount; ++i; } } - HS_FINALIZE(out,outcount,bufd,pd); + HS_FINALIZE(out, outcount, bufd, pd); PG_RETURN_POINTER(out); } @@ -363,20 +366,21 @@ hstore_delete_hstore(PG_FUNCTION_ARGS) HStore *hs = PG_GETARG_HS(0); HStore *hs2 = PG_GETARG_HS(1); HStore *out = palloc(VARSIZE(hs)); - int hs_count = HS_COUNT(hs); - int hs2_count = HS_COUNT(hs2); + int hs_count = HS_COUNT(hs); + int hs2_count = HS_COUNT(hs2); char *ps, - *ps2, - *bufd, + *ps2, + *bufd, *pd; HEntry *es, - *es2, + *es2, *ed; - int i,j; - int outcount = 0; + int i, + j; + int outcount = 0; SET_VARSIZE(out, VARSIZE(hs)); - HS_SETCOUNT(out, hs_count); /* temporary! */ + HS_SETCOUNT(out, hs_count); /* temporary! */ ps = STRPTR(hs); es = ARRPTR(hs); @@ -395,25 +399,25 @@ hstore_delete_hstore(PG_FUNCTION_ARGS) } /* - * this is in effect a merge between hs and hs2, both of - * which are already sorted by (keylen,key); we take keys from - * hs only; for equal keys, we take the value from hs unless the - * values are equal + * this is in effect a merge between hs and hs2, both of which are already + * sorted by (keylen,key); we take keys from hs only; for equal keys, we + * take the value from hs unless the values are equal */ - for (i = j = 0; i < hs_count; ) + for (i = j = 0; i < hs_count;) { - int difference; - + int difference; + if (j >= hs2_count) difference = -1; else { - int skeylen = HS_KEYLEN(es,i); - int s2keylen = HS_KEYLEN(es2,j); + int skeylen = HS_KEYLEN(es, i); + int s2keylen = HS_KEYLEN(es2, j); + if (skeylen == s2keylen) - difference = strncmp(HS_KEY(es,ps,i), - HS_KEY(es2,ps2,j), + difference = strncmp(HS_KEY(es, ps, i), + HS_KEY(es2, ps2, j), skeylen); else difference = (skeylen > s2keylen) ? 1 : -1; @@ -423,15 +427,16 @@ hstore_delete_hstore(PG_FUNCTION_ARGS) ++j; else if (difference == 0) { - int svallen = HS_VALLEN(es,i); - int snullval = HS_VALISNULL(es,i); - if (snullval != HS_VALISNULL(es2,j) + int svallen = HS_VALLEN(es, i); + int snullval = HS_VALISNULL(es, i); + + if (snullval != HS_VALISNULL(es2, j) || (!snullval - && (svallen != HS_VALLEN(es2,j) - || strncmp(HS_VAL(es,ps,i), HS_VAL(es2,ps2,j), svallen) != 0))) + && (svallen != HS_VALLEN(es2, j) + || strncmp(HS_VAL(es, ps, i), HS_VAL(es2, ps2, j), svallen) != 0))) { HS_COPYITEM(ed, bufd, pd, - HS_KEY(es,ps,i), HS_KEYLEN(es,i), + HS_KEY(es, ps, i), HS_KEYLEN(es, i), svallen, snullval); ++outcount; } @@ -440,14 +445,14 @@ hstore_delete_hstore(PG_FUNCTION_ARGS) else { HS_COPYITEM(ed, bufd, pd, - HS_KEY(es,ps,i), HS_KEYLEN(es,i), - HS_VALLEN(es,i), HS_VALISNULL(es,i)); + HS_KEY(es, ps, i), HS_KEYLEN(es, i), + HS_VALLEN(es, i), HS_VALISNULL(es, i)); ++outcount; ++i; } } - HS_FINALIZE(out,outcount,bufd,pd); + HS_FINALIZE(out, outcount, bufd, pd); PG_RETURN_POINTER(out); } @@ -463,16 +468,16 @@ hstore_concat(PG_FUNCTION_ARGS) HStore *out = palloc(VARSIZE(s1) + VARSIZE(s2)); char *ps1, *ps2, - *bufd, + *bufd, *pd; HEntry *es1, *es2, *ed; - int s1idx; - int s2idx; - int s1count = HS_COUNT(s1); - int s2count = HS_COUNT(s2); - int outcount = 0; + int s1idx; + int s2idx; + int s1count = HS_COUNT(s1); + int s2count = HS_COUNT(s2); + int outcount = 0; SET_VARSIZE(out, VARSIZE(s1) + VARSIZE(s2) - HSHRDSIZE); HS_SETCOUNT(out, s1count + s2count); @@ -503,25 +508,26 @@ hstore_concat(PG_FUNCTION_ARGS) ed = ARRPTR(out); /* - * this is in effect a merge between s1 and s2, both of which - * are already sorted by (keylen,key); we take s2 for equal keys + * this is in effect a merge between s1 and s2, both of which are already + * sorted by (keylen,key); we take s2 for equal keys */ for (s1idx = s2idx = 0; s1idx < s1count || s2idx < s2count; ++outcount) { - int difference; - + int difference; + if (s1idx >= s1count) difference = 1; else if (s2idx >= s2count) difference = -1; else { - int s1keylen = HS_KEYLEN(es1,s1idx); - int s2keylen = HS_KEYLEN(es2,s2idx); + int s1keylen = HS_KEYLEN(es1, s1idx); + int s2keylen = HS_KEYLEN(es2, s2idx); + if (s1keylen == s2keylen) - difference = strncmp(HS_KEY(es1,ps1,s1idx), - HS_KEY(es2,ps2,s2idx), + difference = strncmp(HS_KEY(es1, ps1, s1idx), + HS_KEY(es2, ps2, s2idx), s1keylen); else difference = (s1keylen > s2keylen) ? 1 : -1; @@ -530,8 +536,8 @@ hstore_concat(PG_FUNCTION_ARGS) if (difference >= 0) { HS_COPYITEM(ed, bufd, pd, - HS_KEY(es2,ps2,s2idx), HS_KEYLEN(es2,s2idx), - HS_VALLEN(es2,s2idx), HS_VALISNULL(es2,s2idx)); + HS_KEY(es2, ps2, s2idx), HS_KEYLEN(es2, s2idx), + HS_VALLEN(es2, s2idx), HS_VALISNULL(es2, s2idx)); ++s2idx; if (difference == 0) ++s1idx; @@ -539,13 +545,13 @@ hstore_concat(PG_FUNCTION_ARGS) else { HS_COPYITEM(ed, bufd, pd, - HS_KEY(es1,ps1,s1idx), HS_KEYLEN(es1,s1idx), - HS_VALLEN(es1,s1idx), HS_VALISNULL(es1,s1idx)); + HS_KEY(es1, ps1, s1idx), HS_KEYLEN(es1, s1idx), + HS_VALLEN(es1, s1idx), HS_VALISNULL(es1, s1idx)); ++s1idx; } } - HS_FINALIZE(out,outcount,bufd,pd); + HS_FINALIZE(out, outcount, bufd, pd); PG_RETURN_POINTER(out); } @@ -558,15 +564,15 @@ hstore_slice_to_array(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); HEntry *entries = ARRPTR(hs); - char *ptr = STRPTR(hs); + char *ptr = STRPTR(hs); ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1); ArrayType *aout; - Datum *key_datums; - bool *key_nulls; - Datum *out_datums; - bool *out_nulls; - int key_count; - int i; + Datum *key_datums; + bool *key_nulls; + Datum *out_datums; + bool *out_nulls; + int key_count; + int i; deconstruct_array(key_array, TEXTOID, -1, false, 'i', @@ -583,15 +589,15 @@ hstore_slice_to_array(PG_FUNCTION_ARGS) for (i = 0; i < key_count; ++i) { - text *key = (text*) DatumGetPointer(key_datums[i]); - int idx; + text *key = (text *) DatumGetPointer(key_datums[i]); + int idx; if (key_nulls[i]) idx = -1; else idx = hstoreFindKey(hs, NULL, VARDATA(key), VARSIZE(key) - VARHDRSZ); - if (idx < 0 || HS_VALISNULL(entries,idx)) + if (idx < 0 || HS_VALISNULL(entries, idx)) { out_nulls[i] = true; out_datums[i] = (Datum) 0; @@ -599,8 +605,8 @@ hstore_slice_to_array(PG_FUNCTION_ARGS) else { out_datums[i] = PointerGetDatum( - cstring_to_text_with_len(HS_VAL(entries,ptr,idx), - HS_VALLEN(entries,idx))); + cstring_to_text_with_len(HS_VAL(entries, ptr, idx), + HS_VALLEN(entries, idx))); out_nulls[i] = false; } } @@ -609,7 +615,7 @@ hstore_slice_to_array(PG_FUNCTION_ARGS) ARR_NDIM(key_array), ARR_DIMS(key_array), ARR_LBOUND(key_array), - TEXTOID, -1, false, 'i'); + TEXTOID, -1, false, 'i'); PG_RETURN_POINTER(aout); } @@ -622,16 +628,16 @@ hstore_slice_to_hstore(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); HEntry *entries = ARRPTR(hs); - char *ptr = STRPTR(hs); + char *ptr = STRPTR(hs); ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1); - HStore *out; - int nkeys; - Pairs *key_pairs = hstoreArrayToPairs(key_array, &nkeys); - Pairs *out_pairs; - int bufsiz; - int lastidx = 0; - int i; - int out_count = 0; + HStore *out; + int nkeys; + Pairs *key_pairs = hstoreArrayToPairs(key_array, &nkeys); + Pairs *out_pairs; + int bufsiz; + int lastidx = 0; + int i; + int out_count = 0; if (nkeys == 0) { @@ -643,32 +649,32 @@ hstore_slice_to_hstore(PG_FUNCTION_ARGS) bufsiz = 0; /* - * we exploit the fact that the pairs list is already sorted into - * strictly increasing order to narrow the hstoreFindKey search; - * each search can start one entry past the previous "found" - * entry, or at the lower bound of the last search. + * we exploit the fact that the pairs list is already sorted into strictly + * increasing order to narrow the hstoreFindKey search; each search can + * start one entry past the previous "found" entry, or at the lower bound + * of the last search. */ for (i = 0; i < nkeys; ++i) { - int idx = hstoreFindKey(hs, &lastidx, - key_pairs[i].key, key_pairs[i].keylen); + int idx = hstoreFindKey(hs, &lastidx, + key_pairs[i].key, key_pairs[i].keylen); if (idx >= 0) { out_pairs[out_count].key = key_pairs[i].key; bufsiz += (out_pairs[out_count].keylen = key_pairs[i].keylen); - out_pairs[out_count].val = HS_VAL(entries,ptr,idx); - bufsiz += (out_pairs[out_count].vallen = HS_VALLEN(entries,idx)); - out_pairs[out_count].isnull = HS_VALISNULL(entries,idx); + out_pairs[out_count].val = HS_VAL(entries, ptr, idx); + bufsiz += (out_pairs[out_count].vallen = HS_VALLEN(entries, idx)); + out_pairs[out_count].isnull = HS_VALISNULL(entries, idx); out_pairs[out_count].needfree = false; ++out_count; } } /* - * we don't use uniquePairs here because we know that the - * pairs list is already sorted and uniq'ed. + * we don't use uniquePairs here because we know that the pairs list is + * already sorted and uniq'ed. */ out = hstorePairs(out_pairs, out_count, bufsiz); @@ -687,8 +693,8 @@ hstore_akeys(PG_FUNCTION_ARGS) ArrayType *a; HEntry *entries = ARRPTR(hs); char *base = STRPTR(hs); - int count = HS_COUNT(hs); - int i; + int count = HS_COUNT(hs); + int i; if (count == 0) { @@ -700,13 +706,14 @@ hstore_akeys(PG_FUNCTION_ARGS) for (i = 0; i < count; ++i) { - text *item = cstring_to_text_with_len(HS_KEY(entries,base,i), - HS_KEYLEN(entries,i)); + text *item = cstring_to_text_with_len(HS_KEY(entries, base, i), + HS_KEYLEN(entries, i)); + d[i] = PointerGetDatum(item); } a = construct_array(d, count, - TEXTOID, -1, false, 'i'); + TEXTOID, -1, false, 'i'); PG_RETURN_POINTER(a); } @@ -719,13 +726,13 @@ hstore_avals(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); Datum *d; - bool *nulls; + bool *nulls; ArrayType *a; HEntry *entries = ARRPTR(hs); char *base = STRPTR(hs); - int count = HS_COUNT(hs); - int lb = 1; - int i; + int count = HS_COUNT(hs); + int lb = 1; + int i; if (count == 0) { @@ -738,22 +745,23 @@ hstore_avals(PG_FUNCTION_ARGS) for (i = 0; i < count; ++i) { - if (HS_VALISNULL(entries,i)) + if (HS_VALISNULL(entries, i)) { d[i] = (Datum) 0; nulls[i] = true; } else { - text *item = cstring_to_text_with_len(HS_VAL(entries,base,i), - HS_VALLEN(entries,i)); + text *item = cstring_to_text_with_len(HS_VAL(entries, base, i), + HS_VALLEN(entries, i)); + d[i] = PointerGetDatum(item); nulls[i] = false; } } a = construct_md_array(d, nulls, 1, &count, &lb, - TEXTOID, -1, false, 'i'); + TEXTOID, -1, false, 'i'); PG_RETURN_POINTER(a); } @@ -764,12 +772,12 @@ hstore_to_array_internal(HStore *hs, int ndims) { HEntry *entries = ARRPTR(hs); char *base = STRPTR(hs); - int count = HS_COUNT(hs); - int out_size[2] = { 0, 2 }; - int lb[2] = { 1, 1 }; + int count = HS_COUNT(hs); + int out_size[2] = {0, 2}; + int lb[2] = {1, 1}; Datum *out_datums; bool *out_nulls; - int i; + int i; Assert(ndims < 3); @@ -782,22 +790,24 @@ hstore_to_array_internal(HStore *hs, int ndims) for (i = 0; i < count; ++i) { - text *key = cstring_to_text_with_len(HS_KEY(entries,base,i), - HS_KEYLEN(entries,i)); - out_datums[i*2] = PointerGetDatum(key); - out_nulls[i*2] = false; + text *key = cstring_to_text_with_len(HS_KEY(entries, base, i), + HS_KEYLEN(entries, i)); + + out_datums[i * 2] = PointerGetDatum(key); + out_nulls[i * 2] = false; - if (HS_VALISNULL(entries,i)) + if (HS_VALISNULL(entries, i)) { - out_datums[i*2+1] = (Datum) 0; - out_nulls[i*2+1] = true; + out_datums[i * 2 + 1] = (Datum) 0; + out_nulls[i * 2 + 1] = true; } else { - text *item = cstring_to_text_with_len(HS_VAL(entries,base,i), - HS_VALLEN(entries,i)); - out_datums[i*2+1] = PointerGetDatum(item); - out_nulls[i*2+1] = false; + text *item = cstring_to_text_with_len(HS_VAL(entries, base, i), + HS_VALLEN(entries, i)); + + out_datums[i * 2 + 1] = PointerGetDatum(item); + out_nulls[i * 2 + 1] = false; } } @@ -811,7 +821,7 @@ Datum hstore_to_array(PG_FUNCTION_ARGS); Datum hstore_to_array(PG_FUNCTION_ARGS) { - HStore *hs = PG_GETARG_HS(0); + HStore *hs = PG_GETARG_HS(0); ArrayType *out = hstore_to_array_internal(hs, 1); PG_RETURN_POINTER(out); @@ -822,7 +832,7 @@ Datum hstore_to_matrix(PG_FUNCTION_ARGS); Datum hstore_to_matrix(PG_FUNCTION_ARGS) { - HStore *hs = PG_GETARG_HS(0); + HStore *hs = PG_GETARG_HS(0); ArrayType *out = hstore_to_array_internal(hs, 2); PG_RETURN_POINTER(out); @@ -838,11 +848,11 @@ hstore_to_matrix(PG_FUNCTION_ARGS) */ static void -setup_firstcall(FuncCallContext *funcctx, HStore * hs, +setup_firstcall(FuncCallContext *funcctx, HStore *hs, FunctionCallInfoData *fcinfo) { MemoryContext oldcontext; - HStore *st; + HStore *st; oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -858,7 +868,7 @@ setup_firstcall(FuncCallContext *funcctx, HStore * hs, /* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) elog(ERROR, "return type must be a row type"); - + funcctx->tuple_desc = BlessTupleDesc(tupdesc); } @@ -872,8 +882,8 @@ Datum hstore_skeys(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; - HStore *hs; - int i; + HStore *hs; + int i; if (SRF_IS_FIRSTCALL()) { @@ -888,11 +898,11 @@ hstore_skeys(PG_FUNCTION_ARGS) if (i < HS_COUNT(hs)) { - HEntry *entries = ARRPTR(hs); + HEntry *entries = ARRPTR(hs); text *item; - item = cstring_to_text_with_len(HS_KEY(entries,STRPTR(hs),i), - HS_KEYLEN(entries,i)); + item = cstring_to_text_with_len(HS_KEY(entries, STRPTR(hs), i), + HS_KEYLEN(entries, i)); SRF_RETURN_NEXT(funcctx, PointerGetDatum(item)); } @@ -907,8 +917,8 @@ Datum hstore_svals(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; - HStore *hs; - int i; + HStore *hs; + int i; if (SRF_IS_FIRSTCALL()) { @@ -923,9 +933,9 @@ hstore_svals(PG_FUNCTION_ARGS) if (i < HS_COUNT(hs)) { - HEntry *entries = ARRPTR(hs); + HEntry *entries = ARRPTR(hs); - if (HS_VALISNULL(entries,i)) + if (HS_VALISNULL(entries, i)) { ReturnSetInfo *rsi; @@ -939,8 +949,8 @@ hstore_svals(PG_FUNCTION_ARGS) { text *item; - item = cstring_to_text_with_len(HS_VAL(entries,STRPTR(hs),i), - HS_VALLEN(entries,i)); + item = cstring_to_text_with_len(HS_VAL(entries, STRPTR(hs), i), + HS_VALLEN(entries, i)); SRF_RETURN_NEXT(funcctx, PointerGetDatum(item)); } @@ -962,31 +972,31 @@ hstore_contains(PG_FUNCTION_ARGS) char *tstr = STRPTR(tmpl); HEntry *ve = ARRPTR(val); char *vstr = STRPTR(val); - int tcount = HS_COUNT(tmpl); - int lastidx = 0; - int i; + int tcount = HS_COUNT(tmpl); + int lastidx = 0; + int i; /* - * we exploit the fact that keys in "tmpl" are in strictly - * increasing order to narrow the hstoreFindKey search; each search - * can start one entry past the previous "found" entry, or at the - * lower bound of the search + * we exploit the fact that keys in "tmpl" are in strictly increasing + * order to narrow the hstoreFindKey search; each search can start one + * entry past the previous "found" entry, or at the lower bound of the + * search */ for (i = 0; res && i < tcount; ++i) { - int idx = hstoreFindKey(val, &lastidx, - HS_KEY(te,tstr,i), HS_KEYLEN(te,i)); + int idx = hstoreFindKey(val, &lastidx, + HS_KEY(te, tstr, i), HS_KEYLEN(te, i)); if (idx >= 0) { - bool nullval = HS_VALISNULL(te,i); - int vallen = HS_VALLEN(te,i); + bool nullval = HS_VALISNULL(te, i); + int vallen = HS_VALLEN(te, i); - if (nullval != HS_VALISNULL(ve,idx) + if (nullval != HS_VALISNULL(ve, idx) || (!nullval - && (vallen != HS_VALLEN(ve,idx) - || strncmp(HS_VAL(te,tstr,i), HS_VAL(ve,vstr,idx), vallen)))) + && (vallen != HS_VALLEN(ve, idx) + || strncmp(HS_VAL(te, tstr, i), HS_VAL(ve, vstr, idx), vallen)))) res = false; } else @@ -1015,8 +1025,8 @@ Datum hstore_each(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; - HStore *hs; - int i; + HStore *hs; + int i; if (SRF_IS_FIRSTCALL()) { @@ -1032,26 +1042,26 @@ hstore_each(PG_FUNCTION_ARGS) if (i < HS_COUNT(hs)) { HEntry *entries = ARRPTR(hs); - char *ptr = STRPTR(hs); + char *ptr = STRPTR(hs); Datum res, dvalues[2]; bool nulls[2] = {false, false}; text *item; HeapTuple tuple; - item = cstring_to_text_with_len(HS_KEY(entries,ptr,i), - HS_KEYLEN(entries,i)); + item = cstring_to_text_with_len(HS_KEY(entries, ptr, i), + HS_KEYLEN(entries, i)); dvalues[0] = PointerGetDatum(item); - if (HS_VALISNULL(entries,i)) + if (HS_VALISNULL(entries, i)) { dvalues[1] = (Datum) 0; nulls[1] = true; } else { - item = cstring_to_text_with_len(HS_VAL(entries,ptr,i), - HS_VALLEN(entries,i)); + item = cstring_to_text_with_len(HS_VAL(entries, ptr, i), + HS_VALLEN(entries, i)); dvalues[1] = PointerGetDatum(item); } @@ -1078,15 +1088,15 @@ hstore_cmp(PG_FUNCTION_ARGS) { HStore *hs1 = PG_GETARG_HS(0); HStore *hs2 = PG_GETARG_HS(1); - int hcount1 = HS_COUNT(hs1); - int hcount2 = HS_COUNT(hs2); - int res = 0; + int hcount1 = HS_COUNT(hs1); + int hcount2 = HS_COUNT(hs2); + int res = 0; if (hcount1 == 0 || hcount2 == 0) { /* - * if either operand is empty, and the other is nonempty, the - * nonempty one is larger. If both are empty they are equal. + * if either operand is empty, and the other is nonempty, the nonempty + * one is larger. If both are empty they are equal. */ if (hcount1 > 0) res = 1; @@ -1096,14 +1106,14 @@ hstore_cmp(PG_FUNCTION_ARGS) else { /* here we know both operands are nonempty */ - char *str1 = STRPTR(hs1); - char *str2 = STRPTR(hs2); - HEntry *ent1 = ARRPTR(hs1); - HEntry *ent2 = ARRPTR(hs2); - size_t len1 = HSE_ENDPOS(ent1[2*hcount1 - 1]); - size_t len2 = HSE_ENDPOS(ent2[2*hcount2 - 1]); + char *str1 = STRPTR(hs1); + char *str2 = STRPTR(hs2); + HEntry *ent1 = ARRPTR(hs1); + HEntry *ent2 = ARRPTR(hs2); + size_t len1 = HSE_ENDPOS(ent1[2 * hcount1 - 1]); + size_t len2 = HSE_ENDPOS(ent2[2 * hcount2 - 1]); - res = memcmp(str1, str2, Min(len1,len2)); + res = memcmp(str1, str2, Min(len1, len2)); if (res == 0) { @@ -1117,8 +1127,8 @@ hstore_cmp(PG_FUNCTION_ARGS) res = -1; else { - int count = hcount1 * 2; - int i; + int count = hcount1 * 2; + int i; for (i = 0; i < count; ++i) if (HSE_ENDPOS(ent1[i]) != HSE_ENDPOS(ent2[i]) || @@ -1144,11 +1154,11 @@ hstore_cmp(PG_FUNCTION_ARGS) } /* - * this is a btree support function; this is one of the few - * places where memory needs to be explicitly freed. + * this is a btree support function; this is one of the few places where + * memory needs to be explicitly freed. */ - PG_FREE_IF_COPY(hs1,0); - PG_FREE_IF_COPY(hs2,1); + PG_FREE_IF_COPY(hs1, 0); + PG_FREE_IF_COPY(hs2, 1); PG_RETURN_INT32(res); } @@ -1158,9 +1168,10 @@ Datum hstore_eq(PG_FUNCTION_ARGS); Datum hstore_eq(PG_FUNCTION_ARGS) { - int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, - PG_GETARG_DATUM(0), - PG_GETARG_DATUM(1))); + int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, + PG_GETARG_DATUM(0), + PG_GETARG_DATUM(1))); + PG_RETURN_BOOL(res == 0); } @@ -1169,9 +1180,10 @@ Datum hstore_ne(PG_FUNCTION_ARGS); Datum hstore_ne(PG_FUNCTION_ARGS) { - int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, - PG_GETARG_DATUM(0), - PG_GETARG_DATUM(1))); + int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, + PG_GETARG_DATUM(0), + PG_GETARG_DATUM(1))); + PG_RETURN_BOOL(res != 0); } @@ -1180,9 +1192,10 @@ Datum hstore_gt(PG_FUNCTION_ARGS); Datum hstore_gt(PG_FUNCTION_ARGS) { - int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, - PG_GETARG_DATUM(0), - PG_GETARG_DATUM(1))); + int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, + PG_GETARG_DATUM(0), + PG_GETARG_DATUM(1))); + PG_RETURN_BOOL(res > 0); } @@ -1191,9 +1204,10 @@ Datum hstore_ge(PG_FUNCTION_ARGS); Datum hstore_ge(PG_FUNCTION_ARGS) { - int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, - PG_GETARG_DATUM(0), - PG_GETARG_DATUM(1))); + int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, + PG_GETARG_DATUM(0), + PG_GETARG_DATUM(1))); + PG_RETURN_BOOL(res >= 0); } @@ -1202,9 +1216,10 @@ Datum hstore_lt(PG_FUNCTION_ARGS); Datum hstore_lt(PG_FUNCTION_ARGS) { - int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, - PG_GETARG_DATUM(0), - PG_GETARG_DATUM(1))); + int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, + PG_GETARG_DATUM(0), + PG_GETARG_DATUM(1))); + PG_RETURN_BOOL(res < 0); } @@ -1213,9 +1228,10 @@ Datum hstore_le(PG_FUNCTION_ARGS); Datum hstore_le(PG_FUNCTION_ARGS) { - int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, - PG_GETARG_DATUM(0), - PG_GETARG_DATUM(1))); + int res = DatumGetInt32(DirectFunctionCall2(hstore_cmp, + PG_GETARG_DATUM(0), + PG_GETARG_DATUM(1))); + PG_RETURN_BOOL(res <= 0); } @@ -1226,21 +1242,20 @@ Datum hstore_hash(PG_FUNCTION_ARGS) { HStore *hs = PG_GETARG_HS(0); - Datum hval = hash_any((unsigned char *)VARDATA(hs), + Datum hval = hash_any((unsigned char *) VARDATA(hs), VARSIZE(hs) - VARHDRSZ); /* - * this is the only place in the code that cares whether the - * overall varlena size exactly matches the true data size; - * this assertion should be maintained by all the other code, - * but we make it explicit here. + * this is the only place in the code that cares whether the overall + * varlena size exactly matches the true data size; this assertion should + * be maintained by all the other code, but we make it explicit here. */ Assert(VARSIZE(hs) == (HS_COUNT(hs) != 0 ? CALCDATASIZE(HS_COUNT(hs), - HSE_ENDPOS(ARRPTR(hs)[2*HS_COUNT(hs) - 1])) : + HSE_ENDPOS(ARRPTR(hs)[2 * HS_COUNT(hs) - 1])) : HSHRDSIZE)); - PG_FREE_IF_COPY(hs,0); + PG_FREE_IF_COPY(hs, 0); PG_RETURN_DATUM(hval); } diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c index 11cd53a3907..dac760b1114 100644 --- a/contrib/isn/isn.c +++ b/contrib/isn/isn.c @@ -3,11 +3,11 @@ * isn.c * PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC) * - * Author: German Mendez Bravo (Kronuz) + * Author: German Mendez Bravo (Kronuz) * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.13 2010/02/05 04:34:51 momjian Exp $ + * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.14 2010/02/26 02:00:32 momjian Exp $ * *------------------------------------------------------------------------- */ diff --git a/contrib/isn/isn.h b/contrib/isn/isn.h index 628fdab91b9..fdc72d9b539 100644 --- a/contrib/isn/isn.h +++ b/contrib/isn/isn.h @@ -3,11 +3,11 @@ * isn.h * PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC) * - * Author: German Mendez Bravo (Kronuz) + * Author: German Mendez Bravo (Kronuz) * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/isn/isn.h,v 1.9 2010/02/05 04:34:51 momjian Exp $ + * $PostgreSQL: pgsql/contrib/isn/isn.h,v 1.10 2010/02/26 02:00:32 momjian Exp $ * *------------------------------------------------------------------------- */ diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c index 52d6fafeaf4..ff824278aac 100644 --- a/contrib/oid2name/oid2name.c +++ b/contrib/oid2name/oid2name.c @@ -5,7 +5,7 @@ * Originally by * B. Palmer, bpalmer@crimelabs.net 1-17-2001 * - * $PostgreSQL: pgsql/contrib/oid2name/oid2name.c,v 1.37 2010/02/07 20:48:08 tgl Exp $ + * $PostgreSQL: pgsql/contrib/oid2name/oid2name.c,v 1.38 2010/02/26 02:00:32 momjian Exp $ */ #include "postgres_fe.h" @@ -440,7 +440,7 @@ sql_exec_dumpalldbs(PGconn *conn, struct options * opts) /* get the oid and database name from the system pg_database table */ snprintf(todo, sizeof(todo), "SELECT d.oid AS \"Oid\", datname AS \"Database Name\", " - "spcname AS \"Tablespace\" FROM pg_catalog.pg_database d JOIN pg_catalog.pg_tablespace t ON " + "spcname AS \"Tablespace\" FROM pg_catalog.pg_database d JOIN pg_catalog.pg_tablespace t ON " "(dattablespace = t.oid) ORDER BY 2"); sql_exec(conn, todo, opts->quiet); @@ -456,10 +456,10 @@ sql_exec_dumpalltables(PGconn *conn, struct options * opts) char *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" "; snprintf(todo, sizeof(todo), - "SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s " + "SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s " "FROM pg_class c " " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace " - " LEFT JOIN pg_catalog.pg_database d ON d.datname = pg_catalog.current_database()," + " LEFT JOIN pg_catalog.pg_database d ON d.datname = pg_catalog.current_database()," " pg_catalog.pg_tablespace t " "WHERE relkind IN ('r'%s%s) AND " " %s" @@ -527,7 +527,7 @@ sql_exec_searchtables(PGconn *conn, struct options * opts) /* now build the query */ todo = (char *) myalloc(650 + strlen(qualifiers)); snprintf(todo, 650 + strlen(qualifiers), - "SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s\n" + "SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s\n" "FROM pg_catalog.pg_class c \n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \n" " LEFT JOIN pg_catalog.pg_database d ON d.datname = pg_catalog.current_database(),\n" diff --git a/contrib/passwordcheck/passwordcheck.c b/contrib/passwordcheck/passwordcheck.c index b18b161227c..adf417769e7 100644 --- a/contrib/passwordcheck/passwordcheck.c +++ b/contrib/passwordcheck/passwordcheck.c @@ -8,7 +8,7 @@ * Author: Laurenz Albe <laurenz.albe@wien.gv.at> * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/passwordcheck/passwordcheck.c,v 1.2 2010/01/02 16:57:32 momjian Exp $ + * $PostgreSQL: pgsql/contrib/passwordcheck/passwordcheck.c,v 1.3 2010/02/26 02:00:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,12 +66,12 @@ check_password(const char *username, switch (password_type) { case PASSWORD_TYPE_MD5: + /* - * Unfortunately we cannot perform exhaustive checks on - * encrypted passwords - we are restricted to guessing. - * (Alternatively, we could insist on the password being - * presented non-encrypted, but that has its own security - * disadvantages.) + * Unfortunately we cannot perform exhaustive checks on encrypted + * passwords - we are restricted to guessing. (Alternatively, we + * could insist on the password being presented non-encrypted, but + * that has its own security disadvantages.) * * We only check for username = password. */ @@ -84,6 +84,7 @@ check_password(const char *username, break; case PASSWORD_TYPE_PLAINTEXT: + /* * For unencrypted passwords we can perform better checks */ @@ -106,8 +107,8 @@ check_password(const char *username, for (i = 0; i < pwdlen; i++) { /* - * isalpha() does not work for multibyte encodings - * but let's consider non-ASCII characters non-letters + * isalpha() does not work for multibyte encodings but let's + * consider non-ASCII characters non-letters */ if (isalpha((unsigned char) password[i])) pwd_has_letter = true; @@ -117,7 +118,7 @@ check_password(const char *username, if (!pwd_has_letter || !pwd_has_nonletter) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("password must contain both letters and nonletters"))); + errmsg("password must contain both letters and nonletters"))); #ifdef USE_CRACKLIB /* call cracklib to check password */ diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c index 7df15a978ac..d1a0d60a2c2 100644 --- a/contrib/pg_standby/pg_standby.c +++ b/contrib/pg_standby/pg_standby.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pg_standby/pg_standby.c,v 1.27 2009/11/04 12:51:30 heikki Exp $ + * $PostgreSQL: pgsql/contrib/pg_standby/pg_standby.c,v 1.28 2010/02/26 02:00:32 momjian Exp $ * * * pg_standby.c @@ -576,6 +576,7 @@ main(int argc, char **argv) } #ifndef WIN32 + /* * You can send SIGUSR1 to trigger failover. * @@ -614,9 +615,10 @@ main(int argc, char **argv) } break; case 'l': /* Use link */ + /* - * Link feature disabled, possibly permanently. Linking - * causes a problem after recovery ends that is not currently + * Link feature disabled, possibly permanently. Linking causes + * a problem after recovery ends that is not currently * resolved by PostgreSQL. 25 Jun 2009 */ #ifdef NOT_USED diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index 11dfb6280ad..8fa249e9b8b 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -14,7 +14,7 @@ * Copyright (c) 2008-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/pg_stat_statements/pg_stat_statements.c,v 1.12 2010/01/08 00:38:19 itagaki Exp $ + * $PostgreSQL: pgsql/contrib/pg_stat_statements/pg_stat_statements.c,v 1.13 2010/02/26 02:00:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,18 +76,18 @@ typedef struct pgssHashKey */ typedef struct Counters { - int64 calls; /* # of times executed */ - double total_time; /* total execution time in seconds */ - int64 rows; /* total # of retrieved or affected rows */ + int64 calls; /* # of times executed */ + double total_time; /* total execution time in seconds */ + int64 rows; /* total # of retrieved or affected rows */ int64 shared_blks_hit; /* # of shared buffer hits */ - int64 shared_blks_read; /* # of shared disk blocks read */ - int64 shared_blks_written;/* # of shared disk blocks written */ - int64 local_blks_hit; /* # of local buffer hits */ + int64 shared_blks_read; /* # of shared disk blocks read */ + int64 shared_blks_written; /* # of shared disk blocks written */ + int64 local_blks_hit; /* # of local buffer hits */ int64 local_blks_read; /* # of local disk blocks read */ - int64 local_blks_written; /* # of local disk blocks written */ - int64 temp_blks_read; /* # of temp blocks read */ - int64 temp_blks_written; /* # of temp blocks written */ - double usage; /* usage factor */ + int64 local_blks_written; /* # of local disk blocks written */ + int64 temp_blks_read; /* # of temp blocks read */ + int64 temp_blks_written; /* # of temp blocks written */ + double usage; /* usage factor */ } Counters; /* @@ -148,7 +148,7 @@ static const struct config_enum_entry track_options[] = static int pgss_max; /* max # statements to track */ static int pgss_track; /* tracking level */ -static bool pgss_track_utility; /* whether to track utility commands */ +static bool pgss_track_utility; /* whether to track utility commands */ static bool pgss_save; /* whether to save stats across shutdown */ @@ -175,12 +175,12 @@ static void pgss_ExecutorRun(QueryDesc *queryDesc, long count); static void pgss_ExecutorEnd(QueryDesc *queryDesc); static void pgss_ProcessUtility(Node *parsetree, - const char *queryString, ParamListInfo params, bool isTopLevel, - DestReceiver *dest, char *completionTag); + const char *queryString, ParamListInfo params, bool isTopLevel, + DestReceiver *dest, char *completionTag); static uint32 pgss_hash_fn(const void *key, Size keysize); static int pgss_match_fn(const void *key1, const void *key2, Size keysize); static void pgss_store(const char *query, double total_time, uint64 rows, - const BufferUsage *bufusage); + const BufferUsage *bufusage); static Size pgss_memsize(void); static pgssEntry *entry_alloc(pgssHashKey *key); static void entry_dealloc(void); @@ -231,7 +231,7 @@ _PG_init(void) NULL); DefineCustomBoolVariable("pg_stat_statements.track_utility", - "Selects whether utility commands are tracked by pg_stat_statements.", + "Selects whether utility commands are tracked by pg_stat_statements.", NULL, &pgss_track_utility, true, @@ -356,8 +356,8 @@ pgss_shmem_startup(void) on_shmem_exit(pgss_shmem_shutdown, (Datum) 0); /* - * Attempt to load old statistics from the dump file, if this is the - * first time through and we weren't told not to. + * Attempt to load old statistics from the dump file, if this is the first + * time through and we weren't told not to. */ if (found || !pgss_save) return; @@ -592,7 +592,7 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString, instr_time start; instr_time duration; uint64 rows = 0; - BufferUsage bufusage; + BufferUsage bufusage; bufusage = pgBufferUsage; INSTR_TIME_SET_CURRENT(start); diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index b38086490a4..b290b7477b1 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -4,7 +4,7 @@ * A simple benchmark program for PostgreSQL * Originally written by Tatsuo Ishii and enhanced by many contributors. * - * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.96 2010/01/06 01:30:03 itagaki Exp $ + * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.97 2010/02/26 02:00:32 momjian Exp $ * Copyright (c) 2000-2010, PostgreSQL Global Development Group * ALL RIGHTS RESERVED; * @@ -28,7 +28,7 @@ */ #ifdef WIN32 -#define FD_SETSIZE 1024 /* set before winsock2.h is included */ +#define FD_SETSIZE 1024 /* set before winsock2.h is included */ #endif /* ! WIN32 */ #include "postgres_fe.h" @@ -66,16 +66,14 @@ #ifdef WIN32 /* Use native win32 threads on Windows */ -typedef struct win32_pthread *pthread_t; -typedef int pthread_attr_t; - -static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void * (*start_routine)(void *), void *arg); -static int pthread_join(pthread_t th, void **thread_return); +typedef struct win32_pthread *pthread_t; +typedef int pthread_attr_t; +static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); +static int pthread_join(pthread_t th, void **thread_return); #elif defined(ENABLE_THREAD_SAFETY) /* Use platform-dependent pthread capability */ #include <pthread.h> - #else /* Use emulation with fork. Rename pthread identifiers to avoid conflicts */ @@ -86,12 +84,11 @@ static int pthread_join(pthread_t th, void **thread_return); #define pthread_create pg_pthread_create #define pthread_join pg_pthread_join -typedef struct fork_pthread *pthread_t; -typedef int pthread_attr_t; - -static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void * (*start_routine)(void *), void *arg); -static int pthread_join(pthread_t th, void **thread_return); +typedef struct fork_pthread *pthread_t; +typedef int pthread_attr_t; +static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); +static int pthread_join(pthread_t th, void **thread_return); #endif extern char *optarg; @@ -129,7 +126,8 @@ int fillfactor = 100; * end of configurable parameters *********************************************************************/ -#define nbranches 1 /* Makes little sense to change this. Change -s instead */ +#define nbranches 1 /* Makes little sense to change this. Change + * -s instead */ #define ntellers 10 #define naccounts 100000 @@ -156,7 +154,7 @@ typedef struct } Variable; #define MAX_FILES 128 /* max number of SQL script files allowed */ -#define SHELL_COMMAND_SIZE 256 /* maximum size allowed for shell command */ +#define SHELL_COMMAND_SIZE 256 /* maximum size allowed for shell command */ /* * structures used in custom query mode @@ -185,18 +183,18 @@ typedef struct */ typedef struct { - pthread_t thread; /* thread handle */ - CState *state; /* array of CState */ - int nstate; /* length of state[] */ - instr_time start_time; /* thread start time */ + pthread_t thread; /* thread handle */ + CState *state; /* array of CState */ + int nstate; /* length of state[] */ + instr_time start_time; /* thread start time */ } TState; #define INVALID_THREAD ((pthread_t) 0) typedef struct { - instr_time conn_time; - int xacts; + instr_time conn_time; + int xacts; } TResult; /* @@ -224,9 +222,9 @@ typedef struct char *argv[MAX_ARGS]; /* command list */ } Command; -static Command **sql_files[MAX_FILES]; /* SQL script files */ -static int num_files; /* number of script files */ -static int debug = 0; /* debug flag */ +static Command **sql_files[MAX_FILES]; /* SQL script files */ +static int num_files; /* number of script files */ +static int debug = 0; /* debug flag */ /* default scenario */ static char *tpc_b = { @@ -271,7 +269,7 @@ static char *select_only = { /* Function prototypes */ static void setalarm(int seconds); -static void* threadRun(void *arg); +static void *threadRun(void *arg); static void usage(const char *progname) @@ -432,7 +430,7 @@ getVariable(CState *st, char *name) static bool isLegalVariableName(const char *name) { - int i; + int i; for (i = 0; name[i] != '\0'; i++) { @@ -624,29 +622,28 @@ getQueryParams(CState *st, const Command *command, const char **params) static bool runShellCommand(CState *st, char *variable, char **argv, int argc) { - char command[SHELL_COMMAND_SIZE]; - int i, - len = 0; - FILE *fp; - char res[64]; - char *endptr; - int retval; + char command[SHELL_COMMAND_SIZE]; + int i, + len = 0; + FILE *fp; + char res[64]; + char *endptr; + int retval; /* * Join arguments with whilespace separaters. Arguments starting with - * exactly one colon are treated as variables: - * name - append a string "name" - * :var - append a variable named 'var'. - * ::name - append a string ":name" + * exactly one colon are treated as variables: name - append a string + * "name" :var - append a variable named 'var'. ::name - append a string + * ":name" */ for (i = 0; i < argc; i++) { - char *arg; - int arglen; + char *arg; + int arglen; if (argv[i][0] != ':') { - arg = argv[i]; /* a string literal */ + arg = argv[i]; /* a string literal */ } else if (argv[i][1] == ':') { @@ -732,14 +729,14 @@ preparedStatementName(char *buffer, int file, int state) static bool clientDone(CState *st, bool ok) { - (void) ok; /* unused */ + (void) ok; /* unused */ if (st->con != NULL) { PQfinish(st->con); st->con = NULL; } - return false; /* always false */ + return false; /* always false */ } /* return false iff client should be disconnected */ @@ -811,10 +808,10 @@ top: { case PGRES_COMMAND_OK: case PGRES_TUPLES_OK: - break; /* OK */ + break; /* OK */ default: fprintf(stderr, "Client %d aborted in state %d: %s", - st->id, st->state, PQerrorMessage(st->con)); + st->id, st->state, PQerrorMessage(st->con)); PQclear(res); return clientDone(st, false); } @@ -847,7 +844,8 @@ top: if (st->con == NULL) { - instr_time start, end; + instr_time start, + end; INSTR_TIME_SET_CURRENT(start); if ((st->con = doConnect()) == NULL) @@ -1091,7 +1089,7 @@ top: { char *var; int usec; - instr_time now; + instr_time now; if (*argv[1] == ':') { @@ -1124,9 +1122,9 @@ top: } else if (pg_strcasecmp(argv[0], "setshell") == 0) { - bool ret = runShellCommand(st, argv[1], argv + 2, argc - 2); + bool ret = runShellCommand(st, argv[1], argv + 2, argc - 2); - if (timer_exceeded) /* timeout */ + if (timer_exceeded) /* timeout */ return clientDone(st, true); else if (!ret) /* on error */ { @@ -1138,9 +1136,9 @@ top: } else if (pg_strcasecmp(argv[0], "shell") == 0) { - bool ret = runShellCommand(st, NULL, argv + 1, argc - 1); + bool ret = runShellCommand(st, NULL, argv + 1, argc - 1); - if (timer_exceeded) /* timeout */ + if (timer_exceeded) /* timeout */ return clientDone(st, true); else if (!ret) /* on error */ { @@ -1442,7 +1440,7 @@ process_commands(char *buf) */ if (my_commands->argv[1][0] != ':') { - char *c = my_commands->argv[1]; + char *c = my_commands->argv[1]; while (isdigit((unsigned char) *c)) c++; @@ -1667,7 +1665,7 @@ printResults(int ttype, int normal_xacts, int nclients, int nthreads, time_include = INSTR_TIME_GET_DOUBLE(total_time); tps_include = normal_xacts / time_include; tps_exclude = normal_xacts / (time_include - - (INSTR_TIME_GET_DOUBLE(conn_total_time) / nthreads)); + (INSTR_TIME_GET_DOUBLE(conn_total_time) / nthreads)); if (ttype == 0) s = "TPC-B (sort of)"; @@ -1704,8 +1702,8 @@ int main(int argc, char **argv) { int c; - int nclients = 1; /* default number of simulated clients */ - int nthreads = 1; /* default number of threads */ + int nclients = 1; /* default number of simulated clients */ + int nthreads = 1; /* default number of threads */ int is_init_mode = 0; /* initialize mode? */ int is_no_vacuum = 0; /* no vacuum at all before testing? */ int do_vacuum_accounts = 0; /* do vacuum accounts before testing? */ @@ -1826,7 +1824,7 @@ main(int argc, char **argv) } #endif /* HAVE_GETRLIMIT */ break; - case 'j': /* jobs */ + case 'j': /* jobs */ nthreads = atoi(optarg); if (nthreads <= 0) { @@ -2120,7 +2118,8 @@ main(int argc, char **argv) /* the first thread (i = 0) is executed by main thread */ if (i > 0) { - int err = pthread_create(&threads[i].thread, NULL, threadRun, &threads[i]); + int err = pthread_create(&threads[i].thread, NULL, threadRun, &threads[i]); + if (err != 0 || threads[i].thread == INVALID_THREAD) { fprintf(stderr, "cannot create thread: %s\n", strerror(err)); @@ -2138,7 +2137,7 @@ main(int argc, char **argv) INSTR_TIME_SET_ZERO(conn_total_time); for (i = 0; i < nthreads; i++) { - void *ret = NULL; + void *ret = NULL; if (threads[i].thread == INVALID_THREAD) ret = threadRun(&threads[i]); @@ -2147,7 +2146,8 @@ main(int argc, char **argv) if (ret != NULL) { - TResult *r = (TResult *) ret; + TResult *r = (TResult *) ret; + total_xacts += r->xacts; INSTR_TIME_ADD(conn_total_time, r->conn_time); free(ret); @@ -2170,10 +2170,11 @@ threadRun(void *arg) { TState *thread = (TState *) arg; CState *state = thread->state; - TResult *result; - instr_time start, end; + TResult *result; + instr_time start, + end; int nstate = thread->nstate; - int remains = nstate; /* number of remaining clients */ + int remains = nstate; /* number of remaining clients */ int i; result = malloc(sizeof(TResult)); @@ -2202,7 +2203,7 @@ threadRun(void *arg) st->use_file = getrand(0, num_files - 1); if (!doCustom(st, &result->conn_time)) - remains--; /* I've aborted */ + remains--; /* I've aborted */ if (st->ecnt > prev_ecnt && commands[st->state]->type == META_COMMAND) { @@ -2215,10 +2216,10 @@ threadRun(void *arg) while (remains > 0) { - fd_set input_mask; - int maxsock; /* max socket number to be waited */ - int64 now_usec = 0; - int64 min_usec; + fd_set input_mask; + int maxsock; /* max socket number to be waited */ + int64 now_usec = 0; + int64 min_usec; FD_ZERO(&input_mask); @@ -2237,6 +2238,7 @@ threadRun(void *arg) if (min_usec == INT64_MAX) { instr_time now; + INSTR_TIME_SET_CURRENT(now); now_usec = INSTR_TIME_GET_MICROSEC(now); } @@ -2262,18 +2264,20 @@ threadRun(void *arg) goto done; } - FD_SET(sock, &input_mask); + FD_SET (sock, &input_mask); + if (maxsock < sock) maxsock = sock; } if (min_usec > 0 && maxsock != -1) { - int nsocks; /* return from select(2) */ + int nsocks; /* return from select(2) */ if (min_usec != INT64_MAX) { - struct timeval timeout; + struct timeval timeout; + timeout.tv_sec = min_usec / 1000000; timeout.tv_usec = min_usec % 1000000; nsocks = select(maxsock + 1, &input_mask, NULL, NULL, &timeout); @@ -2298,10 +2302,10 @@ threadRun(void *arg) int prev_ecnt = st->ecnt; if (st->con && (FD_ISSET(PQsocket(st->con), &input_mask) - || commands[st->state]->type == META_COMMAND)) + || commands[st->state]->type == META_COMMAND)) { if (!doCustom(st, &result->conn_time)) - remains--; /* I've aborted */ + remains--; /* I've aborted */ } if (st->ecnt > prev_ecnt && commands[st->state]->type == META_COMMAND) @@ -2353,30 +2357,30 @@ setalarm(int seconds) typedef struct fork_pthread { - pid_t pid; - int pipes[2]; -} fork_pthread; + pid_t pid; + int pipes[2]; +} fork_pthread; static int pthread_create(pthread_t *thread, pthread_attr_t *attr, - void * (*start_routine)(void *), + void *(*start_routine) (void *), void *arg) { - fork_pthread *th; - void *ret; - instr_time start_time; + fork_pthread *th; + void *ret; + instr_time start_time; th = (fork_pthread *) malloc(sizeof(fork_pthread)); pipe(th->pipes); th->pid = fork(); - if (th->pid == -1) /* error */ + if (th->pid == -1) /* error */ { free(th); return errno; } - if (th->pid != 0) /* in parent process */ + if (th->pid != 0) /* in parent process */ { close(th->pipes[1]); *thread = th; @@ -2391,11 +2395,11 @@ pthread_create(pthread_t *thread, setalarm(duration); /* - * Set a different random seed in each child process. Otherwise they - * all inherit the parent's state and generate the same "random" - * sequence. (In the threaded case, the different threads will obtain - * subsets of the output of a single random() sequence, which should be - * okay for our purposes.) + * Set a different random seed in each child process. Otherwise they all + * inherit the parent's state and generate the same "random" sequence. + * (In the threaded case, the different threads will obtain subsets of the + * output of a single random() sequence, which should be okay for our + * purposes.) */ INSTR_TIME_SET_CURRENT(start_time); srandom(((unsigned int) INSTR_TIME_GET_MICROSEC(start_time)) + @@ -2411,7 +2415,7 @@ pthread_create(pthread_t *thread, static int pthread_join(pthread_t th, void **thread_return) { - int status; + int status; while (waitpid(th->pid, &status, 0) != th->pid) { @@ -2434,9 +2438,7 @@ pthread_join(pthread_t th, void **thread_return) free(th); return 0; } - #endif - #else /* WIN32 */ static VOID CALLBACK @@ -2468,7 +2470,7 @@ setalarm(int seconds) typedef struct win32_pthread { HANDLE handle; - void *(*routine)(void *); + void *(*routine) (void *); void *arg; void *result; } win32_pthread; @@ -2486,11 +2488,11 @@ win32_pthread_run(void *arg) static int pthread_create(pthread_t *thread, pthread_attr_t *attr, - void * (*start_routine)(void *), + void *(*start_routine) (void *), void *arg) { - int save_errno; - win32_pthread *th; + int save_errno; + win32_pthread *th; th = (win32_pthread *) malloc(sizeof(win32_pthread)); th->routine = start_routine; diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c index 99a2ed50dc2..8e012ac1725 100644 --- a/contrib/unaccent/unaccent.c +++ b/contrib/unaccent/unaccent.c @@ -1,12 +1,12 @@ /*------------------------------------------------------------------------- * * unaccent.c - * Text search unaccent dictionary + * Text search unaccent dictionary * * Copyright (c) 2009-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/unaccent/unaccent.c,v 1.4 2010/01/02 16:57:33 momjian Exp $ + * $PostgreSQL: pgsql/contrib/unaccent/unaccent.c,v 1.5 2010/02/26 02:00:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,26 +25,27 @@ PG_MODULE_MAGIC; /* - * Unaccent dictionary uses uncompressed suffix tree to find a - * character to replace. Each node of tree is an array of + * Unaccent dictionary uses uncompressed suffix tree to find a + * character to replace. Each node of tree is an array of * SuffixChar struct with length = 256 (n-th element of array * corresponds to byte) */ -typedef struct SuffixChar { - struct SuffixChar *nextChar; - char *replaceTo; - int replacelen; +typedef struct SuffixChar +{ + struct SuffixChar *nextChar; + char *replaceTo; + int replacelen; } SuffixChar; /* * placeChar - put str into tree's structure, byte by byte. */ -static SuffixChar* +static SuffixChar * placeChar(SuffixChar *node, unsigned char *str, int lenstr, char *replaceTo, int replacelen) { - SuffixChar *curnode; + SuffixChar *curnode; - if ( !node ) + if (!node) { node = palloc(sizeof(SuffixChar) * 256); memset(node, 0, sizeof(SuffixChar) * 256); @@ -52,20 +53,20 @@ placeChar(SuffixChar *node, unsigned char *str, int lenstr, char *replaceTo, int curnode = node + *str; - if ( lenstr == 1 ) + if (lenstr == 1) { - if ( curnode->replaceTo ) + if (curnode->replaceTo) elog(WARNING, "duplicate TO argument, use first one"); else { curnode->replacelen = replacelen; - curnode->replaceTo = palloc( replacelen ); + curnode->replaceTo = palloc(replacelen); memcpy(curnode->replaceTo, replaceTo, replacelen); } } else { - curnode->nextChar = placeChar( curnode->nextChar, str+1, lenstr-1, replaceTo, replacelen); + curnode->nextChar = placeChar(curnode->nextChar, str + 1, lenstr - 1, replaceTo, replacelen); } return node; @@ -75,13 +76,13 @@ placeChar(SuffixChar *node, unsigned char *str, int lenstr, char *replaceTo, int * initSuffixTree - create suffix tree from file. Function converts * UTF8-encoded file into current encoding. */ -static SuffixChar* -initSuffixTree(char *filename) +static SuffixChar * +initSuffixTree(char *filename) { - SuffixChar * volatile rootSuffixTree = NULL; + SuffixChar *volatile rootSuffixTree = NULL; MemoryContext ccxt = CurrentMemoryContext; - tsearch_readline_state trst; - volatile bool skip; + tsearch_readline_state trst; + volatile bool skip; filename = get_tsearch_config_filename(filename, "rules"); if (!tsearch_readline_begin(&trst, filename)) @@ -90,34 +91,34 @@ initSuffixTree(char *filename) errmsg("could not open unaccent file \"%s\": %m", filename))); - do + do { - char src[4096]; - char trg[4096]; - int srclen; - int trglen; - char *line = NULL; + char src[4096]; + char trg[4096]; + int srclen; + int trglen; + char *line = NULL; skip = true; PG_TRY(); { /* - * pg_do_encoding_conversion() (called by tsearch_readline()) - * will emit exception if it finds untranslatable characters in current locale. - * We just skip such characters. + * pg_do_encoding_conversion() (called by tsearch_readline()) will + * emit exception if it finds untranslatable characters in current + * locale. We just skip such characters. */ while ((line = tsearch_readline(&trst)) != NULL) { - if ( sscanf(line, "%s\t%s\n", src, trg)!=2 ) + if (sscanf(line, "%s\t%s\n", src, trg) != 2) continue; srclen = strlen(src); trglen = strlen(trg); - rootSuffixTree = placeChar(rootSuffixTree, - (unsigned char*)src, srclen, - trg, trglen); + rootSuffixTree = placeChar(rootSuffixTree, + (unsigned char *) src, srclen, + trg, trglen); skip = false; pfree(line); } @@ -141,7 +142,7 @@ initSuffixTree(char *filename) } PG_END_TRY(); } - while(skip); + while (skip); tsearch_readline_end(&trst); @@ -151,13 +152,13 @@ initSuffixTree(char *filename) /* * findReplaceTo - find multibyte character in tree */ -static SuffixChar * -findReplaceTo( SuffixChar *node, unsigned char *src, int srclen ) +static SuffixChar * +findReplaceTo(SuffixChar *node, unsigned char *src, int srclen) { - while( node ) + while (node) { node = node + *src; - if ( srclen == 1 ) + if (srclen == 1) return node; src++; @@ -169,13 +170,13 @@ findReplaceTo( SuffixChar *node, unsigned char *src, int srclen ) } PG_FUNCTION_INFO_V1(unaccent_init); -Datum unaccent_init(PG_FUNCTION_ARGS); +Datum unaccent_init(PG_FUNCTION_ARGS); Datum unaccent_init(PG_FUNCTION_ARGS) { - List *dictoptions = (List *) PG_GETARG_POINTER(0); + List *dictoptions = (List *) PG_GETARG_POINTER(0); SuffixChar *rootSuffixTree = NULL; - bool fileloaded = false; + bool fileloaded = false; ListCell *l; foreach(l, dictoptions) @@ -188,8 +189,8 @@ unaccent_init(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("multiple Rules parameters"))); - rootSuffixTree = initSuffixTree(defGetString(defel)); - fileloaded = true; + rootSuffixTree = initSuffixTree(defGetString(defel)); + fileloaded = true; } else { @@ -211,51 +212,52 @@ unaccent_init(PG_FUNCTION_ARGS) } PG_FUNCTION_INFO_V1(unaccent_lexize); -Datum unaccent_lexize(PG_FUNCTION_ARGS); +Datum unaccent_lexize(PG_FUNCTION_ARGS); Datum unaccent_lexize(PG_FUNCTION_ARGS) { - SuffixChar *rootSuffixTree = (SuffixChar*)PG_GETARG_POINTER(0); - char *srcchar = (char *) PG_GETARG_POINTER(1); + SuffixChar *rootSuffixTree = (SuffixChar *) PG_GETARG_POINTER(0); + char *srcchar = (char *) PG_GETARG_POINTER(1); int32 len = PG_GETARG_INT32(2); - char *srcstart, *trgchar = NULL; + char *srcstart, + *trgchar = NULL; int charlen; TSLexeme *res = NULL; SuffixChar *node; srcstart = srcchar; - while( srcchar - srcstart < len ) + while (srcchar - srcstart < len) { charlen = pg_mblen(srcchar); - node = findReplaceTo( rootSuffixTree, (unsigned char *) srcchar, charlen ); - if ( node && node->replaceTo ) + node = findReplaceTo(rootSuffixTree, (unsigned char *) srcchar, charlen); + if (node && node->replaceTo) { - if ( !res ) + if (!res) { /* allocate res only it it's needed */ res = palloc0(sizeof(TSLexeme) * 2); - res->lexeme = trgchar = palloc( len * pg_database_encoding_max_length() + 1 /* \0 */ ); + res->lexeme = trgchar = palloc(len * pg_database_encoding_max_length() + 1 /* \0 */ ); res->flags = TSL_FILTER; - if ( srcchar != srcstart ) + if (srcchar != srcstart) { memcpy(trgchar, srcstart, srcchar - srcstart); trgchar += (srcchar - srcstart); } } - memcpy( trgchar, node->replaceTo, node->replacelen ); - trgchar += node->replacelen; + memcpy(trgchar, node->replaceTo, node->replacelen); + trgchar += node->replacelen; } - else if ( res ) + else if (res) { - memcpy( trgchar, srcchar, charlen ); + memcpy(trgchar, srcchar, charlen); trgchar += charlen; } srcchar += charlen; } - if ( res ) + if (res) *trgchar = '\0'; PG_RETURN_POINTER(res); @@ -265,15 +267,15 @@ unaccent_lexize(PG_FUNCTION_ARGS) * Function-like wrapper for dictionary */ PG_FUNCTION_INFO_V1(unaccent_dict); -Datum unaccent_dict(PG_FUNCTION_ARGS); +Datum unaccent_dict(PG_FUNCTION_ARGS); Datum unaccent_dict(PG_FUNCTION_ARGS) { - text *str; - int strArg; - Oid dictOid; - TSDictionaryCacheEntry *dict; - TSLexeme *res; + text *str; + int strArg; + Oid dictOid; + TSDictionaryCacheEntry *dict; + TSLexeme *res; if (PG_NARGS() == 1) { @@ -290,25 +292,25 @@ unaccent_dict(PG_FUNCTION_ARGS) dict = lookup_ts_dictionary_cache(dictOid); res = (TSLexeme *) DatumGetPointer(FunctionCall4(&(dict->lexize), - PointerGetDatum(dict->dictData), - PointerGetDatum(VARDATA(str)), - Int32GetDatum(VARSIZE(str) - VARHDRSZ), + PointerGetDatum(dict->dictData), + PointerGetDatum(VARDATA(str)), + Int32GetDatum(VARSIZE(str) - VARHDRSZ), PointerGetDatum(NULL))); PG_FREE_IF_COPY(str, strArg); - if ( res == NULL ) + if (res == NULL) { PG_RETURN_TEXT_P(PG_GETARG_TEXT_P_COPY(strArg)); } - else if ( res->lexeme == NULL ) + else if (res->lexeme == NULL) { pfree(res); PG_RETURN_TEXT_P(PG_GETARG_TEXT_P_COPY(strArg)); } else { - text *txt = cstring_to_text(res->lexeme); + text *txt = cstring_to_text(res->lexeme); pfree(res->lexeme); pfree(res); diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 65328a9f288..052982145d9 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.32 2010/01/22 16:40:18 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.33 2010/02/26 02:00:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1210,7 +1210,7 @@ bytea * attribute_reloptions(Datum reloptions, bool validate) { relopt_value *options; - AttributeOpts *aopts; + AttributeOpts *aopts; int numoptions; static const relopt_parse_elt tab[] = { {"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)}, @@ -1241,7 +1241,7 @@ bytea * tablespace_reloptions(Datum reloptions, bool validate) { relopt_value *options; - TableSpaceOpts *tsopts; + TableSpaceOpts *tsopts; int numoptions; static const relopt_parse_elt tab[] = { {"random_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, random_page_cost)}, diff --git a/src/backend/access/common/tupconvert.c b/src/backend/access/common/tupconvert.c index 3d7de339dd2..fec3b3ef583 100644 --- a/src/backend/access/common/tupconvert.c +++ b/src/backend/access/common/tupconvert.c @@ -5,7 +5,7 @@ * * These functions provide conversion between rowtypes that are logically * equivalent but might have columns in a different order or different sets - * of dropped columns. There is some overlap of functionality with the + * of dropped columns. There is some overlap of functionality with the * executor's "junkfilter" routines, but these functions work on bare * HeapTuples rather than TupleTableSlots. * @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/tupconvert.c,v 1.3 2010/01/02 16:57:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/tupconvert.c,v 1.4 2010/02/26 02:00:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,7 +88,7 @@ convert_tuples_by_position(TupleDesc indesc, int32 atttypmod; if (att->attisdropped) - continue; /* attrMap[i] is already 0 */ + continue; /* attrMap[i] is already 0 */ noutcols++; atttypid = att->atttypid; atttypmod = att->atttypmod; @@ -137,22 +137,22 @@ convert_tuples_by_position(TupleDesc indesc, nincols, noutcols))); /* - * Check to see if the map is one-to-one and the tuple types are the - * same. (We check the latter because if they're not, we want to do - * conversion to inject the right OID into the tuple datum.) + * Check to see if the map is one-to-one and the tuple types are the same. + * (We check the latter because if they're not, we want to do conversion + * to inject the right OID into the tuple datum.) */ if (indesc->natts == outdesc->natts && indesc->tdtypeid == outdesc->tdtypeid) { for (i = 0; i < n; i++) { - if (attrMap[i] == (i+1)) + if (attrMap[i] == (i + 1)) continue; /* - * If it's a dropped column and the corresponding input - * column is also dropped, we needn't convert. However, - * attlen and attalign must agree. + * If it's a dropped column and the corresponding input column is + * also dropped, we needn't convert. However, attlen and attalign + * must agree. */ if (attrMap[i] == 0 && indesc->attrs[i]->attisdropped && @@ -182,10 +182,10 @@ convert_tuples_by_position(TupleDesc indesc, /* preallocate workspace for Datum arrays */ map->outvalues = (Datum *) palloc(n * sizeof(Datum)); map->outisnull = (bool *) palloc(n * sizeof(bool)); - n = indesc->natts + 1; /* +1 for NULL */ + n = indesc->natts + 1; /* +1 for NULL */ map->invalues = (Datum *) palloc(n * sizeof(Datum)); map->inisnull = (bool *) palloc(n * sizeof(bool)); - map->invalues[0] = (Datum) 0; /* set up the NULL entry */ + map->invalues[0] = (Datum) 0; /* set up the NULL entry */ map->inisnull[0] = true; return map; @@ -193,7 +193,7 @@ convert_tuples_by_position(TupleDesc indesc, /* * Set up for tuple conversion, matching input and output columns by name. - * (Dropped columns are ignored in both input and output.) This is intended + * (Dropped columns are ignored in both input and output.) This is intended * for use when the rowtypes are related by inheritance, so we expect an exact * match of both type and typmod. The error messages will be a bit unhelpful * unless both rowtypes are named composite types. @@ -221,7 +221,7 @@ convert_tuples_by_name(TupleDesc indesc, int j; if (att->attisdropped) - continue; /* attrMap[i] is already 0 */ + continue; /* attrMap[i] is already 0 */ attname = NameStr(att->attname); atttypid = att->atttypid; atttypmod = att->atttypmod; @@ -256,9 +256,9 @@ convert_tuples_by_name(TupleDesc indesc, } /* - * Check to see if the map is one-to-one and the tuple types are the - * same. (We check the latter because if they're not, we want to do - * conversion to inject the right OID into the tuple datum.) + * Check to see if the map is one-to-one and the tuple types are the same. + * (We check the latter because if they're not, we want to do conversion + * to inject the right OID into the tuple datum.) */ if (indesc->natts == outdesc->natts && indesc->tdtypeid == outdesc->tdtypeid) @@ -266,13 +266,13 @@ convert_tuples_by_name(TupleDesc indesc, same = true; for (i = 0; i < n; i++) { - if (attrMap[i] == (i+1)) + if (attrMap[i] == (i + 1)) continue; /* - * If it's a dropped column and the corresponding input - * column is also dropped, we needn't convert. However, - * attlen and attalign must agree. + * If it's a dropped column and the corresponding input column is + * also dropped, we needn't convert. However, attlen and attalign + * must agree. */ if (attrMap[i] == 0 && indesc->attrs[i]->attisdropped && @@ -302,10 +302,10 @@ convert_tuples_by_name(TupleDesc indesc, /* preallocate workspace for Datum arrays */ map->outvalues = (Datum *) palloc(n * sizeof(Datum)); map->outisnull = (bool *) palloc(n * sizeof(bool)); - n = indesc->natts + 1; /* +1 for NULL */ + n = indesc->natts + 1; /* +1 for NULL */ map->invalues = (Datum *) palloc(n * sizeof(Datum)); map->inisnull = (bool *) palloc(n * sizeof(bool)); - map->invalues[0] = (Datum) 0; /* set up the NULL entry */ + map->invalues[0] = (Datum) 0; /* set up the NULL entry */ map->inisnull[0] = true; return map; diff --git a/src/backend/access/gin/ginbulk.c b/src/backend/access/gin/ginbulk.c index accd6640375..bb726e69f4c 100644 --- a/src/backend/access/gin/ginbulk.c +++ b/src/backend/access/gin/ginbulk.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginbulk.c,v 1.18 2010/02/11 14:29:50 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginbulk.c,v 1.19 2010/02/26 02:00:33 momjian Exp $ *------------------------------------------------------------------------- */ @@ -22,20 +22,20 @@ #define DEF_NENTRY 2048 #define DEF_NPTR 4 -static void* +static void * ginAppendData(void *old, void *new, void *arg) { - EntryAccumulator *eo = (EntryAccumulator*)old, - *en = (EntryAccumulator*)new; + EntryAccumulator *eo = (EntryAccumulator *) old, + *en = (EntryAccumulator *) new; - BuildAccumulator *accum = (BuildAccumulator*)arg; + BuildAccumulator *accum = (BuildAccumulator *) arg; if (eo->number >= eo->length) { accum->allocatedMemory -= GetMemoryChunkSpace(eo->list); eo->length *= 2; eo->list = (ItemPointerData *) repalloc(eo->list, - sizeof(ItemPointerData) * eo->length); + sizeof(ItemPointerData) * eo->length); accum->allocatedMemory += GetMemoryChunkSpace(eo->list); } @@ -60,9 +60,9 @@ ginAppendData(void *old, void *new, void *arg) static int cmpEntryAccumulator(const void *a, const void *b, void *arg) { - EntryAccumulator *ea = (EntryAccumulator*)a; - EntryAccumulator *eb = (EntryAccumulator*)b; - BuildAccumulator *accum = (BuildAccumulator*)arg; + EntryAccumulator *ea = (EntryAccumulator *) a; + EntryAccumulator *eb = (EntryAccumulator *) b; + BuildAccumulator *accum = (BuildAccumulator *) arg; return compareAttEntries(accum->ginstate, ea->attnum, ea->value, eb->attnum, eb->value); @@ -104,13 +104,13 @@ getDatumCopy(BuildAccumulator *accum, OffsetNumber attnum, Datum value) static void ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, Datum entry) { - EntryAccumulator *key, - *ea; + EntryAccumulator *key, + *ea; - /* - * Allocate memory by rather big chunk to decrease overhead, we don't - * keep pointer to previously allocated chunks because they will free - * by MemoryContextReset() call. + /* + * Allocate memory by rather big chunk to decrease overhead, we don't keep + * pointer to previously allocated chunks because they will free by + * MemoryContextReset() call. */ if (accum->entryallocator == NULL || accum->length >= DEF_NENTRY) { @@ -125,7 +125,7 @@ ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum key->attnum = attnum; key->value = entry; - /* To prevent multiple palloc/pfree cycles, we reuse array */ + /* To prevent multiple palloc/pfree cycles, we reuse array */ if (accum->tmpList == NULL) accum->tmpList = (ItemPointerData *) palloc(sizeof(ItemPointerData) * DEF_NPTR); @@ -149,8 +149,8 @@ ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum else { /* - * The key has been appended, so "free" allocated - * key by decrementing chunk's counter. + * The key has been appended, so "free" allocated key by decrementing + * chunk's counter. */ accum->length--; } @@ -162,7 +162,7 @@ ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum * Since the entries are being inserted into a balanced binary tree, you * might think that the order of insertion wouldn't be critical, but it turns * out that inserting the entries in sorted order results in a lot of - * rebalancing operations and is slow. To prevent this, we attempt to insert + * rebalancing operations and is slow. To prevent this, we attempt to insert * the nodes in an order that will produce a nearly-balanced tree if the input * is in fact sorted. * @@ -172,11 +172,11 @@ ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum * tree; then, we insert the middles of each half of out virtual array, then * middles of quarters, etc. */ - void +void ginInsertRecordBA(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, Datum *entries, int32 nentry) { - uint32 step = nentry; + uint32 step = nentry; if (nentry <= 0) return; @@ -186,21 +186,22 @@ ginInsertRecordBA(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber att /* * step will contain largest power of 2 and <= nentry */ - step |= (step >> 1); - step |= (step >> 2); - step |= (step >> 4); - step |= (step >> 8); + step |= (step >> 1); + step |= (step >> 2); + step |= (step >> 4); + step |= (step >> 8); step |= (step >> 16); step >>= 1; - step ++; + step++; - while(step > 0) { - int i; + while (step > 0) + { + int i; - for (i = step - 1; i < nentry && i >= 0; i += step << 1 /* *2 */) + for (i = step - 1; i < nentry && i >= 0; i += step << 1 /* *2 */ ) ginInsertEntry(accum, heapptr, attnum, entries[i]); - step >>= 1; /* /2 */ + step >>= 1; /* /2 */ } } diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c index 8913b437cf6..6d307c8d59a 100644 --- a/src/backend/access/gin/ginentrypage.c +++ b/src/backend/access/gin/ginentrypage.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.23 2010/01/02 16:57:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.24 2010/02/26 02:00:33 momjian Exp $ *------------------------------------------------------------------------- */ @@ -104,7 +104,7 @@ GinFormTuple(Relation index, GinState *ginstate, * Gin tuple without any ItemPointers should be large enough to keep * one ItemPointer, to prevent inconsistency between * ginHeapTupleFastCollect and ginEntryInsert called by - * ginHeapTupleInsert. ginHeapTupleFastCollect forms tuple without + * ginHeapTupleInsert. ginHeapTupleFastCollect forms tuple without * extra pointer to heap, but ginEntryInsert (called for pending list * cleanup during vacuum) will form the same tuple with one * ItemPointer. diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c index 967c02b7983..705d167963b 100644 --- a/src/backend/access/gin/ginget.c +++ b/src/backend/access/gin/ginget.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.29 2010/01/02 16:57:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.30 2010/02/26 02:00:33 momjian Exp $ *------------------------------------------------------------------------- */ @@ -25,11 +25,11 @@ typedef struct pendingPosition { - Buffer pendingBuffer; - OffsetNumber firstOffset; - OffsetNumber lastOffset; - ItemPointerData item; - bool *hasMatchKey; + Buffer pendingBuffer; + OffsetNumber firstOffset; + OffsetNumber lastOffset; + ItemPointerData item; + bool *hasMatchKey; } pendingPosition; @@ -877,7 +877,7 @@ matchPartialInPendingList(GinState *ginstate, Page page, static bool hasAllMatchingKeys(GinScanOpaque so, pendingPosition *pos) { - int i; + int i; for (i = 0; i < so->nkeys; i++) if (pos->hasMatchKey[i] == false) @@ -912,7 +912,7 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos) memset(key->entryRes, FALSE, key->nentries); } - memset(pos->hasMatchKey, FALSE, so->nkeys); + memset(pos->hasMatchKey, FALSE, so->nkeys); for (;;) { diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index 5cf969a1fdf..216910307a8 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.84 2010/01/02 16:57:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.85 2010/02/26 02:00:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -414,7 +414,8 @@ gistindex_keytest(IndexTuple tuple, /* * On non-leaf page we can't conclude that child hasn't NULL * values because of assumption in GiST: union (VAL, NULL) is VAL. - * But if on non-leaf page key IS NULL, then all children are NULL. + * But if on non-leaf page key IS NULL, then all children are + * NULL. */ if (key->sk_flags & SK_SEARCHNULL) { diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c index 18ee0259a59..cb34b26113e 100644 --- a/src/backend/access/gist/gistproc.c +++ b/src/backend/access/gist/gistproc.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.20 2010/01/14 16:31:09 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.21 2010/02/26 02:00:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -889,8 +889,8 @@ gist_point_compress(PG_FUNCTION_ARGS) if (entry->leafkey) /* Point, actually */ { - BOX *box = palloc(sizeof(BOX)); - Point *point = DatumGetPointP(entry->key); + BOX *box = palloc(sizeof(BOX)); + Point *point = DatumGetPointP(entry->key); GISTENTRY *retval = palloc(sizeof(GISTENTRY)); box->high = box->low = *point; @@ -906,9 +906,9 @@ gist_point_compress(PG_FUNCTION_ARGS) static bool gist_point_consistent_internal(StrategyNumber strategy, - bool isLeaf, BOX *key, Point *query) + bool isLeaf, BOX *key, Point *query) { - bool result = false; + bool result = false; switch (strategy) { @@ -953,10 +953,10 @@ Datum gist_point_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); bool result; bool *recheck = (bool *) PG_GETARG_POINTER(4); - StrategyNumber strategyGroup = strategy / GeoStrategyNumberOffset; + StrategyNumber strategyGroup = strategy / GeoStrategyNumberOffset; switch (strategyGroup) { @@ -969,22 +969,22 @@ gist_point_consistent(PG_FUNCTION_ARGS) break; case BoxStrategyNumberGroup: result = DatumGetBool(DirectFunctionCall5( - gist_box_consistent, - PointerGetDatum(entry), - PG_GETARG_DATUM(1), - Int16GetDatum(RTOverlapStrategyNumber), - 0, PointerGetDatum(recheck))); + gist_box_consistent, + PointerGetDatum(entry), + PG_GETARG_DATUM(1), + Int16GetDatum(RTOverlapStrategyNumber), + 0, PointerGetDatum(recheck))); break; case PolygonStrategyNumberGroup: { POLYGON *query = PG_GETARG_POLYGON_P(1); result = DatumGetBool(DirectFunctionCall5( - gist_poly_consistent, - PointerGetDatum(entry), - PolygonPGetDatum(query), - Int16GetDatum(RTOverlapStrategyNumber), - 0, PointerGetDatum(recheck))); + gist_poly_consistent, + PointerGetDatum(entry), + PolygonPGetDatum(query), + Int16GetDatum(RTOverlapStrategyNumber), + 0, PointerGetDatum(recheck))); if (GIST_LEAF(entry) && result) { @@ -992,13 +992,13 @@ gist_point_consistent(PG_FUNCTION_ARGS) * We are on leaf page and quick check shows overlapping * of polygon's bounding box and point */ - BOX *box = DatumGetBoxP(entry->key); + BOX *box = DatumGetBoxP(entry->key); Assert(box->high.x == box->low.x - && box->high.y == box->low.y); + && box->high.y == box->low.y); result = DatumGetBool(DirectFunctionCall2( - poly_contain_pt, - PolygonPGetDatum(query), + poly_contain_pt, + PolygonPGetDatum(query), PointPGetDatum(&box->high))); *recheck = false; } @@ -1006,14 +1006,14 @@ gist_point_consistent(PG_FUNCTION_ARGS) break; case CircleStrategyNumberGroup: { - CIRCLE *query = PG_GETARG_CIRCLE_P(1); + CIRCLE *query = PG_GETARG_CIRCLE_P(1); result = DatumGetBool(DirectFunctionCall5( - gist_circle_consistent, - PointerGetDatum(entry), - CirclePGetDatum(query), - Int16GetDatum(RTOverlapStrategyNumber), - 0, PointerGetDatum(recheck))); + gist_circle_consistent, + PointerGetDatum(entry), + CirclePGetDatum(query), + Int16GetDatum(RTOverlapStrategyNumber), + 0, PointerGetDatum(recheck))); if (GIST_LEAF(entry) && result) { @@ -1021,20 +1021,20 @@ gist_point_consistent(PG_FUNCTION_ARGS) * We are on leaf page and quick check shows overlapping * of polygon's bounding box and point */ - BOX *box = DatumGetBoxP(entry->key); + BOX *box = DatumGetBoxP(entry->key); Assert(box->high.x == box->low.x - && box->high.y == box->low.y); + && box->high.y == box->low.y); result = DatumGetBool(DirectFunctionCall2( - circle_contain_pt, - CirclePGetDatum(query), + circle_contain_pt, + CirclePGetDatum(query), PointPGetDatum(&box->high))); *recheck = false; } } break; default: - result = false; /* silence compiler warning */ + result = false; /* silence compiler warning */ elog(ERROR, "unknown strategy number: %d", strategy); } diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index 1abdc3e168f..a53d8cd0873 100644 --- a/src/backend/access/gist/gistscan.c +++ b/src/backend/access/gist/gistscan.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.78 2010/01/02 16:57:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.79 2010/02/26 02:00:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,8 +92,8 @@ gistrescan(PG_FUNCTION_ARGS) * field. * * Next, if any of keys is a NULL and that key is not marked with - * SK_SEARCHNULL/SK_SEARCHNOTNULL then nothing can be found (ie, - * we assume all indexable operators are strict). + * SK_SEARCHNULL/SK_SEARCHNOTNULL then nothing can be found (ie, we + * assume all indexable operators are strict). */ for (i = 0; i < scan->numberOfKeys; i++) { diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index cd01b06437f..6474f45940e 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.116 2010/01/02 16:57:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.117 2010/02/26 02:00:33 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -233,7 +233,7 @@ hashgettuple(PG_FUNCTION_ARGS) /* * An insertion into the current index page could have happened while * we didn't have read lock on it. Re-find our position by looking - * for the TID we previously returned. (Because we hold share lock on + * for the TID we previously returned. (Because we hold share lock on * the bucket, no deletions or splits could have occurred; therefore * we can expect that the TID still exists in the current index page, * at an offset >= where we were.) diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c index 804f3ee934a..3ca8d733ad6 100644 --- a/src/backend/access/hash/hashovfl.c +++ b/src/backend/access/hash/hashovfl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.68 2010/01/02 16:57:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.69 2010/02/26 02:00:33 momjian Exp $ * * NOTES * Overflow pages look like ordinary relation pages. @@ -717,8 +717,8 @@ _hash_squeezebucket(Relation rel, /* * If we reach here, there are no live tuples on the "read" page --- - * it was empty when we got to it, or we moved them all. So we - * can just free the page without bothering with deleting tuples + * it was empty when we got to it, or we moved them all. So we can + * just free the page without bothering with deleting tuples * individually. Then advance to the previous "read" page. * * Tricky point here: if our read and write pages are adjacent in the diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 3f1d3cda3f3..77b072c8801 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.82 2010/01/02 16:57:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.83 2010/02/26 02:00:33 momjian Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -799,8 +799,8 @@ _hash_splitbucket(Relation rel, /* * Partition the tuples in the old bucket between the old bucket and the * new bucket, advancing along the old bucket's overflow bucket chain and - * adding overflow pages to the new bucket as needed. Outer loop - * iterates once per page in old bucket. + * adding overflow pages to the new bucket as needed. Outer loop iterates + * once per page in old bucket. */ for (;;) { diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 4dfb85ac56b..1f26faa2ee0 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.287 2010/02/14 18:42:12 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.288 2010/02/26 02:00:33 momjian Exp $ * * * INTERFACE ROUTINES @@ -79,8 +79,8 @@ static HeapScanDesc heap_beginscan_internal(Relation relation, bool allow_strat, bool allow_sync, bool is_bitmapscan); static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf, - ItemPointerData from, Buffer newbuf, HeapTuple newtup, - bool all_visible_cleared, bool new_all_visible_cleared); + ItemPointerData from, Buffer newbuf, HeapTuple newtup, + bool all_visible_cleared, bool new_all_visible_cleared); static bool HeapSatisfiesHOTUpdate(Relation relation, Bitmapset *hot_attrs, HeapTuple oldtup, HeapTuple newtup); @@ -248,8 +248,8 @@ heapgetpage(HeapScanDesc scan, BlockNumber page) /* * If the all-visible flag indicates that all tuples on the page are - * visible to everyone, we can skip the per-tuple visibility tests. - * But not in hot standby mode. A tuple that's already visible to all + * visible to everyone, we can skip the per-tuple visibility tests. But + * not in hot standby mode. A tuple that's already visible to all * transactions in the master might still be invisible to a read-only * transaction in the standby. */ @@ -3667,8 +3667,8 @@ recheck_xmax: * someone setting xmax. Hence recheck after changing lock, same as for * xmax itself. * - * Old-style VACUUM FULL is gone, but we have to keep this code as long - * as we support having MOVED_OFF/MOVED_IN tuples in the database. + * Old-style VACUUM FULL is gone, but we have to keep this code as long as + * we support having MOVED_OFF/MOVED_IN tuples in the database. */ recheck_xvac: if (tuple->t_infomask & HEAP_MOVED) @@ -4099,9 +4099,9 @@ heap_xlog_cleanup_info(XLogRecPtr lsn, XLogRecord *record) ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, xlrec->node); /* - * Actual operation is a no-op. Record type exists to provide a means - * for conflict processing to occur before we begin index vacuum actions. - * see vacuumlazy.c and also comments in btvacuumpage() + * Actual operation is a no-op. Record type exists to provide a means for + * conflict processing to occur before we begin index vacuum actions. see + * vacuumlazy.c and also comments in btvacuumpage() */ } @@ -4769,8 +4769,8 @@ heap_redo(XLogRecPtr lsn, XLogRecord *record) uint8 info = record->xl_info & ~XLR_INFO_MASK; /* - * These operations don't overwrite MVCC data so no conflict - * processing is required. The ones in heap2 rmgr do. + * These operations don't overwrite MVCC data so no conflict processing is + * required. The ones in heap2 rmgr do. */ RestoreBkpBlocks(lsn, record, false); @@ -4809,8 +4809,8 @@ heap2_redo(XLogRecPtr lsn, XLogRecord *record) uint8 info = record->xl_info & ~XLR_INFO_MASK; /* - * Note that RestoreBkpBlocks() is called after conflict processing - * within each record type handling function. + * Note that RestoreBkpBlocks() is called after conflict processing within + * each record type handling function. */ switch (info & XLOG_HEAP_OPMASK) diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 9d6a737277b..89607f57be3 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.21 2010/02/08 04:33:53 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.22 2010/02/26 02:00:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,8 +29,9 @@ typedef struct { TransactionId new_prune_xid; /* new prune hint value for page */ - TransactionId latestRemovedXid; /* latest xid to be removed by this prune */ - int nredirected; /* numbers of entries in arrays below */ + TransactionId latestRemovedXid; /* latest xid to be removed by this + * prune */ + int nredirected; /* numbers of entries in arrays below */ int ndead; int nunused; /* arrays that accumulate indexes of items to be changed */ @@ -85,8 +86,8 @@ heap_page_prune_opt(Relation relation, Buffer buffer, TransactionId OldestXmin) /* * We can't write WAL in recovery mode, so there's no point trying to - * clean the page. The master will likely issue a cleaning WAL record - * soon anyway, so this is no particular loss. + * clean the page. The master will likely issue a cleaning WAL record soon + * anyway, so this is no particular loss. */ if (RecoveryInProgress()) return; @@ -164,8 +165,8 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, * * First, initialize the new pd_prune_xid value to zero (indicating no * prunable tuples). If we find any tuples which may soon become - * prunable, we will save the lowest relevant XID in new_prune_xid. - * Also initialize the rest of our working state. + * prunable, we will save the lowest relevant XID in new_prune_xid. Also + * initialize the rest of our working state. */ prstate.new_prune_xid = InvalidTransactionId; prstate.latestRemovedXid = InvalidTransactionId; @@ -370,7 +371,7 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum, { heap_prune_record_unused(prstate, rootoffnum); HeapTupleHeaderAdvanceLatestRemovedXid(htup, - &prstate->latestRemovedXid); + &prstate->latestRemovedXid); ndeleted++; } @@ -499,7 +500,7 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum, { latestdead = offnum; HeapTupleHeaderAdvanceLatestRemovedXid(htup, - &prstate->latestRemovedXid); + &prstate->latestRemovedXid); } else if (!recent_dead) break; diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index 65522f46c14..5c60c1f130d 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -96,7 +96,7 @@ * Portions Copyright (c) 1994-5, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.20 2010/02/03 10:01:29 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.21 2010/02/26 02:00:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -281,7 +281,8 @@ end_heap_rewrite(RewriteState state) /* Write an XLOG UNLOGGED record if WAL-logging was skipped */ if (!state->rs_use_wal && !state->rs_new_rel->rd_istemp) { - char reason[NAMEDATALEN + 30]; + char reason[NAMEDATALEN + 30]; + snprintf(reason, sizeof(reason), "heap rewrite on \"%s\"", RelationGetRelationName(state->rs_new_rel)); XLogReportUnloggedStatement(reason); diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c index dd6218cbfe2..7518db16c81 100644 --- a/src/backend/access/heap/tuptoaster.c +++ b/src/backend/access/heap/tuptoaster.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.97 2010/02/04 00:09:13 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.98 2010/02/26 02:00:33 momjian Exp $ * * * INTERFACE ROUTINES @@ -796,9 +796,9 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup, } /* - * Finally we store attributes of type 'm' externally. At this point - * we increase the target tuple size, so that 'm' attributes aren't - * stored externally unless really necessary. + * Finally we store attributes of type 'm' externally. At this point we + * increase the target tuple size, so that 'm' attributes aren't stored + * externally unless really necessary. */ maxDataLen = TOAST_TUPLE_TARGET_MAIN - hoff; @@ -1190,8 +1190,8 @@ toast_save_datum(Relation rel, Datum value, int options) * * Normally this is the actual OID of the target toast table, but during * table-rewriting operations such as CLUSTER, we have to insert the OID - * of the table's real permanent toast table instead. rd_toastoid is - * set if we have to substitute such an OID. + * of the table's real permanent toast table instead. rd_toastoid is set + * if we have to substitute such an OID. */ if (OidIsValid(rel->rd_toastoid)) toast_pointer.va_toastrelid = rel->rd_toastoid; diff --git a/src/backend/access/heap/visibilitymap.c b/src/backend/access/heap/visibilitymap.c index dbfb3df2d0d..1ae92e6fe82 100644 --- a/src/backend/access/heap/visibilitymap.c +++ b/src/backend/access/heap/visibilitymap.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/visibilitymap.c,v 1.8 2010/02/09 21:43:29 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/visibilitymap.c,v 1.9 2010/02/26 02:00:33 momjian Exp $ * * INTERFACE ROUTINES * visibilitymap_clear - clear a bit in the visibility map @@ -19,7 +19,7 @@ * NOTES * * The visibility map is a bitmap with one bit per heap page. A set bit means - * that all tuples on the page are known visible to all transactions, and + * that all tuples on the page are known visible to all transactions, and * therefore the page doesn't need to be vacuumed. The map is conservative in * the sense that we make sure that whenever a bit is set, we know the * condition is true, but if a bit is not set, it might or might not be true. @@ -377,11 +377,10 @@ visibilitymap_truncate(Relation rel, BlockNumber nheapblocks) rel->rd_istemp); /* - * We might as well update the local smgr_vm_nblocks setting. - * smgrtruncate sent an smgr cache inval message, which will cause - * other backends to invalidate their copy of smgr_vm_nblocks, and - * this one too at the next command boundary. But this ensures it - * isn't outright wrong until then. + * We might as well update the local smgr_vm_nblocks setting. smgrtruncate + * sent an smgr cache inval message, which will cause other backends to + * invalidate their copy of smgr_vm_nblocks, and this one too at the next + * command boundary. But this ensures it isn't outright wrong until then. */ if (rel->rd_smgr) rel->rd_smgr->smgr_vm_nblocks = newnblocks; @@ -411,7 +410,7 @@ vm_readbuf(Relation rel, BlockNumber blkno, bool extend) { if (smgrexists(rel->rd_smgr, VISIBILITYMAP_FORKNUM)) rel->rd_smgr->smgr_vm_nblocks = smgrnblocks(rel->rd_smgr, - VISIBILITYMAP_FORKNUM); + VISIBILITYMAP_FORKNUM); else rel->rd_smgr->smgr_vm_nblocks = 0; } @@ -466,8 +465,8 @@ vm_extend(Relation rel, BlockNumber vm_nblocks) RelationOpenSmgr(rel); /* - * Create the file first if it doesn't exist. If smgr_vm_nblocks - * is positive then it must exist, no need for an smgrexists call. + * Create the file first if it doesn't exist. If smgr_vm_nblocks is + * positive then it must exist, no need for an smgrexists call. */ if ((rel->rd_smgr->smgr_vm_nblocks == 0 || rel->rd_smgr->smgr_vm_nblocks == InvalidBlockNumber) && diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index bd280360879..d95fd90a424 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.80 2010/02/07 20:48:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.81 2010/02/26 02:00:33 momjian Exp $ * * NOTES * many of the old access method routines have been turned into @@ -94,13 +94,13 @@ RelationGetIndexScan(Relation indexRelation, /* * During recovery we ignore killed tuples and don't bother to kill them - * either. We do this because the xmin on the primary node could easily - * be later than the xmin on the standby node, so that what the primary + * either. We do this because the xmin on the primary node could easily be + * later than the xmin on the standby node, so that what the primary * thinks is killed is supposed to be visible on standby. So for correct * MVCC for queries during recovery we must ignore these hints and check - * all tuples. Do *not* set ignore_killed_tuples to true when running - * in a transaction that was started during recovery. - * xactStartedInRecovery should not be altered by index AMs. + * all tuples. Do *not* set ignore_killed_tuples to true when running in a + * transaction that was started during recovery. xactStartedInRecovery + * should not be altered by index AMs. */ scan->kill_prior_tuple = false; scan->xactStartedInRecovery = TransactionStartedDuringRecovery(); @@ -170,24 +170,24 @@ BuildIndexValueDescription(Relation indexRelation, for (i = 0; i < natts; i++) { - char *val; + char *val; if (isnull[i]) val = "null"; else { - Oid foutoid; - bool typisvarlena; + Oid foutoid; + bool typisvarlena; /* - * The provided data is not necessarily of the type stored in - * the index; rather it is of the index opclass's input type. - * So look at rd_opcintype not the index tupdesc. + * The provided data is not necessarily of the type stored in the + * index; rather it is of the index opclass's input type. So look + * at rd_opcintype not the index tupdesc. * * Note: this is a bit shaky for opclasses that have pseudotype - * input types such as ANYARRAY or RECORD. Currently, the - * typoutput functions associated with the pseudotypes will - * work okay, but we might have to try harder in future. + * input types such as ANYARRAY or RECORD. Currently, the + * typoutput functions associated with the pseudotypes will work + * okay, but we might have to try harder in future. */ getTypeOutputInfo(indexRelation->rd_opcintype[i], &foutoid, &typisvarlena); diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index f5a36971575..3e7331ae7b8 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.117 2010/01/02 16:57:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.118 2010/02/26 02:00:34 momjian Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relation OID @@ -455,9 +455,9 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) /* * If we scanned a whole HOT chain and found only dead tuples, - * tell index AM to kill its entry for that TID. We do not do - * this when in recovery because it may violate MVCC to do so. - * see comments in RelationGetIndexScan(). + * tell index AM to kill its entry for that TID. We do not do this + * when in recovery because it may violate MVCC to do so. see + * comments in RelationGetIndexScan(). */ if (!scan->xactStartedInRecovery) scan->kill_prior_tuple = scan->xs_hot_dead; diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 86c8698f696..de9bd95f88f 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.176 2010/01/02 16:57:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.177 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,7 +88,7 @@ static void _bt_vacuum_one_page(Relation rel, Buffer buffer); * and btinsert. By here, itup is filled in, including the TID. * * If checkUnique is UNIQUE_CHECK_NO or UNIQUE_CHECK_PARTIAL, this - * will allow duplicates. Otherwise (UNIQUE_CHECK_YES or + * will allow duplicates. Otherwise (UNIQUE_CHECK_YES or * UNIQUE_CHECK_EXISTING) it will throw error for a duplicate. * For UNIQUE_CHECK_EXISTING we merely run the duplicate check, and * don't actually insert. @@ -149,9 +149,9 @@ top: * If we must wait for another xact, we release the lock while waiting, * and then must start over completely. * - * For a partial uniqueness check, we don't wait for the other xact. - * Just let the tuple in and return false for possibly non-unique, - * or true for definitely unique. + * For a partial uniqueness check, we don't wait for the other xact. Just + * let the tuple in and return false for possibly non-unique, or true for + * definitely unique. */ if (checkUnique != UNIQUE_CHECK_NO) { @@ -281,7 +281,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, /* * If we are doing a recheck, we expect to find the tuple we - * are rechecking. It's not a duplicate, but we have to keep + * are rechecking. It's not a duplicate, but we have to keep * scanning. */ if (checkUnique == UNIQUE_CHECK_EXISTING && @@ -302,10 +302,10 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, /* * It is a duplicate. If we are only doing a partial - * check, then don't bother checking if the tuple is - * being updated in another transaction. Just return - * the fact that it is a potential conflict and leave - * the full check till later. + * check, then don't bother checking if the tuple is being + * updated in another transaction. Just return the fact + * that it is a potential conflict and leave the full + * check till later. */ if (checkUnique == UNIQUE_CHECK_PARTIAL) { @@ -362,20 +362,20 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, } /* - * This is a definite conflict. Break the tuple down - * into datums and report the error. But first, make - * sure we release the buffer locks we're holding --- + * This is a definite conflict. Break the tuple down into + * datums and report the error. But first, make sure we + * release the buffer locks we're holding --- * BuildIndexValueDescription could make catalog accesses, - * which in the worst case might touch this same index - * and cause deadlocks. + * which in the worst case might touch this same index and + * cause deadlocks. */ if (nbuf != InvalidBuffer) _bt_relbuf(rel, nbuf); _bt_relbuf(rel, buf); { - Datum values[INDEX_MAX_KEYS]; - bool isnull[INDEX_MAX_KEYS]; + Datum values[INDEX_MAX_KEYS]; + bool isnull[INDEX_MAX_KEYS]; index_deform_tuple(itup, RelationGetDescr(rel), values, isnull); @@ -385,7 +385,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, RelationGetRelationName(rel)), errdetail("Key %s already exists.", BuildIndexValueDescription(rel, - values, isnull)))); + values, isnull)))); } } else if (all_dead) @@ -438,16 +438,16 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, } /* - * If we are doing a recheck then we should have found the tuple we - * are checking. Otherwise there's something very wrong --- probably, - * the index is on a non-immutable expression. + * If we are doing a recheck then we should have found the tuple we are + * checking. Otherwise there's something very wrong --- probably, the + * index is on a non-immutable expression. */ if (checkUnique == UNIQUE_CHECK_EXISTING && !found) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to re-find tuple within index \"%s\"", RelationGetRelationName(rel)), - errhint("This may be because of a non-immutable index expression."))); + errhint("This may be because of a non-immutable index expression."))); if (nbuf != InvalidBuffer) _bt_relbuf(rel, nbuf); @@ -518,10 +518,10 @@ _bt_findinsertloc(Relation rel, if (itemsz > BTMaxItemSize(page)) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("index row size %lu exceeds maximum %lu for index \"%s\"", - (unsigned long) itemsz, - (unsigned long) BTMaxItemSize(page), - RelationGetRelationName(rel)), + errmsg("index row size %lu exceeds maximum %lu for index \"%s\"", + (unsigned long) itemsz, + (unsigned long) BTMaxItemSize(page), + RelationGetRelationName(rel)), errhint("Values larger than 1/3 of a buffer page cannot be indexed.\n" "Consider a function index of an MD5 hash of the value, " "or use full text indexing."))); diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 5df975e4ec5..c0502e55833 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.119 2010/02/13 00:59:58 sriggs Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.120 2010/02/26 02:00:34 momjian Exp $ * * NOTES * Postgres btree pages look like ordinary relation pages. The opaque @@ -459,8 +459,8 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, TransactionId latestRemovedX START_CRIT_SECTION(); /* - * We don't do MarkBufferDirty here because we're about initialise - * the page, and nobody else can see it yet. + * We don't do MarkBufferDirty here because we're about initialise the + * page, and nobody else can see it yet. */ /* XLOG stuff */ @@ -480,8 +480,8 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, TransactionId latestRemovedX recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_REUSE_PAGE, rdata); /* - * We don't do PageSetLSN or PageSetTLI here because - * we're about initialise the page, so no need. + * We don't do PageSetLSN or PageSetTLI here because we're about + * initialise the page, so no need. */ } @@ -552,11 +552,11 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access) { page = BufferGetPage(buf); if (_bt_page_recyclable(page)) - { + { /* - * If we are generating WAL for Hot Standby then create - * a WAL record that will allow us to conflict with - * queries running on standby. + * If we are generating WAL for Hot Standby then create a + * WAL record that will allow us to conflict with queries + * running on standby. */ if (XLogStandbyInfoActive()) { @@ -762,6 +762,7 @@ _bt_delitems(Relation rel, Buffer buf, if (isVacuum) { xl_btree_vacuum xlrec_vacuum; + xlrec_vacuum.node = rel->rd_node; xlrec_vacuum.block = BufferGetBlockNumber(buf); @@ -772,6 +773,7 @@ _bt_delitems(Relation rel, Buffer buf, else { xl_btree_delete xlrec_delete; + xlrec_delete.node = rel->rd_node; xlrec_delete.block = BufferGetBlockNumber(buf); diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index b0acaf257f2..01899cfc166 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.175 2010/02/08 04:33:53 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.176 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,8 +57,8 @@ typedef struct IndexBulkDeleteCallback callback; void *callback_state; BTCycleId cycleid; - BlockNumber lastBlockVacuumed; /* last blkno reached by Vacuum scan */ - BlockNumber lastUsedPage; /* blkno of last non-recyclable page */ + BlockNumber lastBlockVacuumed; /* last blkno reached by Vacuum scan */ + BlockNumber lastUsedPage; /* blkno of last non-recyclable page */ BlockNumber totFreePages; /* true total # of free pages */ MemoryContext pagedelcontext; } BTVacState; @@ -630,7 +630,7 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, vstate.callback = callback; vstate.callback_state = callback_state; vstate.cycleid = cycleid; - vstate.lastBlockVacuumed = BTREE_METAPAGE; /* Initialise at first block */ + vstate.lastBlockVacuumed = BTREE_METAPAGE; /* Initialise at first block */ vstate.lastUsedPage = BTREE_METAPAGE; vstate.totFreePages = 0; @@ -702,8 +702,8 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, /* * We can't use _bt_getbuf() here because it always applies * _bt_checkpage(), which will barf on an all-zero page. We want to - * recycle all-zero pages, not fail. Also, we want to use a nondefault - * buffer access strategy. + * recycle all-zero pages, not fail. Also, we want to use a + * nondefault buffer access strategy. */ buf = ReadBufferExtended(rel, MAIN_FORKNUM, num_pages - 1, RBM_NORMAL, info->strategy); @@ -856,23 +856,25 @@ restart: htup = &(itup->t_tid); /* - * During Hot Standby we currently assume that XLOG_BTREE_VACUUM - * records do not produce conflicts. That is only true as long - * as the callback function depends only upon whether the index - * tuple refers to heap tuples removed in the initial heap scan. - * When vacuum starts it derives a value of OldestXmin. Backends - * taking later snapshots could have a RecentGlobalXmin with a - * later xid than the vacuum's OldestXmin, so it is possible that - * row versions deleted after OldestXmin could be marked as killed - * by other backends. The callback function *could* look at the - * index tuple state in isolation and decide to delete the index - * tuple, though currently it does not. If it ever did, we would - * need to reconsider whether XLOG_BTREE_VACUUM records should - * cause conflicts. If they did cause conflicts they would be - * fairly harsh conflicts, since we haven't yet worked out a way - * to pass a useful value for latestRemovedXid on the - * XLOG_BTREE_VACUUM records. This applies to *any* type of index - * that marks index tuples as killed. + * During Hot Standby we currently assume that + * XLOG_BTREE_VACUUM records do not produce conflicts. That is + * only true as long as the callback function depends only + * upon whether the index tuple refers to heap tuples removed + * in the initial heap scan. When vacuum starts it derives a + * value of OldestXmin. Backends taking later snapshots could + * have a RecentGlobalXmin with a later xid than the vacuum's + * OldestXmin, so it is possible that row versions deleted + * after OldestXmin could be marked as killed by other + * backends. The callback function *could* look at the index + * tuple state in isolation and decide to delete the index + * tuple, though currently it does not. If it ever did, we + * would need to reconsider whether XLOG_BTREE_VACUUM records + * should cause conflicts. If they did cause conflicts they + * would be fairly harsh conflicts, since we haven't yet + * worked out a way to pass a useful value for + * latestRemovedXid on the XLOG_BTREE_VACUUM records. This + * applies to *any* type of index that marks index tuples as + * killed. */ if (callback(htup, callback_state)) deletable[ndeletable++] = offnum; @@ -885,13 +887,13 @@ restart: */ if (ndeletable > 0) { - BlockNumber lastBlockVacuumed = BufferGetBlockNumber(buf); + BlockNumber lastBlockVacuumed = BufferGetBlockNumber(buf); _bt_delitems(rel, buf, deletable, ndeletable, true, vstate->lastBlockVacuumed); /* - * Keep track of the block number of the lastBlockVacuumed, so - * we can scan those blocks as well during WAL replay. This then + * Keep track of the block number of the lastBlockVacuumed, so we + * can scan those blocks as well during WAL replay. This then * provides concurrency protection and allows btrees to be used * while in recovery. */ diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 772215c1810..84540b73530 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -59,7 +59,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.123 2010/01/20 19:43:40 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.124 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -216,12 +216,13 @@ _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2) wstate.btws_use_wal = XLogIsNeeded() && !wstate.index->rd_istemp; /* - * Write an XLOG UNLOGGED record if WAL-logging was skipped because - * WAL archiving is not enabled. + * Write an XLOG UNLOGGED record if WAL-logging was skipped because WAL + * archiving is not enabled. */ if (!wstate.btws_use_wal && !wstate.index->rd_istemp) { - char reason[NAMEDATALEN + 20]; + char reason[NAMEDATALEN + 20]; + snprintf(reason, sizeof(reason), "b-tree build on \"%s\"", RelationGetRelationName(wstate.index)); XLogReportUnloggedStatement(reason); @@ -492,10 +493,10 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, IndexTuple itup) if (itupsz > BTMaxItemSize(npage)) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("index row size %lu exceeds maximum %lu for index \"%s\"", - (unsigned long) itupsz, - (unsigned long) BTMaxItemSize(npage), - RelationGetRelationName(wstate->index)), + errmsg("index row size %lu exceeds maximum %lu for index \"%s\"", + (unsigned long) itupsz, + (unsigned long) BTMaxItemSize(npage), + RelationGetRelationName(wstate->index)), errhint("Values larger than 1/3 of a buffer page cannot be indexed.\n" "Consider a function index of an MD5 hash of the value, " "or use full text indexing."))); diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index a7a3d7a12d6..6b399d34a66 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.97 2010/01/03 05:39:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.98 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -515,7 +515,7 @@ _bt_compare_scankey_args(IndexScanDesc scan, ScanKey op, StrategyNumber strat; /* - * First, deal with cases where one or both args are NULL. This should + * First, deal with cases where one or both args are NULL. This should * only happen when the scankeys represent IS NULL/NOT NULL conditions. */ if ((leftarg->sk_flags | rightarg->sk_flags) & SK_ISNULL) @@ -566,7 +566,7 @@ _bt_compare_scankey_args(IndexScanDesc scan, ScanKey op, break; default: elog(ERROR, "unrecognized StrategyNumber: %d", (int) strat); - *result = false; /* keep compiler quiet */ + *result = false; /* keep compiler quiet */ break; } return true; @@ -612,8 +612,8 @@ _bt_compare_scankey_args(IndexScanDesc scan, ScanKey op, * indexscan initiated by syscache lookup will use cross-data-type * operators.) * - * If the sk_strategy was flipped by _bt_fix_scankey_strategy, we - * have to un-flip it to get the correct opfamily member. + * If the sk_strategy was flipped by _bt_fix_scankey_strategy, we have to + * un-flip it to get the correct opfamily member. */ strat = op->sk_strategy; if (op->sk_flags & SK_BT_DESC) @@ -653,7 +653,7 @@ _bt_compare_scankey_args(IndexScanDesc scan, ScanKey op, * * Lastly, for ordinary scankeys (not IS NULL/NOT NULL), we check for a * NULL comparison value. Since all btree operators are assumed strict, - * a NULL means that the qual cannot be satisfied. We return TRUE if the + * a NULL means that the qual cannot be satisfied. We return TRUE if the * comparison value isn't NULL, or FALSE if the scan should be abandoned. * * This function is applied to the *input* scankey structure; therefore @@ -682,7 +682,7 @@ _bt_fix_scankey_strategy(ScanKey skey, int16 *indoption) * --- we can treat IS NULL as an equality operator for purposes of search * strategy. * - * Likewise, "x IS NOT NULL" is supported. We treat that as either "less + * Likewise, "x IS NOT NULL" is supported. We treat that as either "less * than NULL" in a NULLS LAST index, or "greater than NULL" in a NULLS * FIRST index. */ @@ -910,13 +910,13 @@ _bt_checkkeys(IndexScanDesc scan, if (key->sk_flags & SK_SEARCHNULL) { if (isNull) - continue; /* tuple satisfies this qual */ + continue; /* tuple satisfies this qual */ } else { Assert(key->sk_flags & SK_SEARCHNOTNULL); if (!isNull) - continue; /* tuple satisfies this qual */ + continue; /* tuple satisfies this qual */ } /* diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c index f5320fb1039..07416d599b5 100644 --- a/src/backend/access/nbtree/nbtxlog.c +++ b/src/backend/access/nbtree/nbtxlog.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.61 2010/02/13 00:59:58 sriggs Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.62 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -473,10 +473,10 @@ btree_xlog_vacuum(XLogRecPtr lsn, XLogRecord *record) xlrec = (xl_btree_vacuum *) XLogRecGetData(record); /* - * If queries might be active then we need to ensure every block is unpinned - * between the lastBlockVacuumed and the current block, if there are any. - * This ensures that every block in the index is touched during VACUUM as - * required to ensure scans work correctly. + * If queries might be active then we need to ensure every block is + * unpinned between the lastBlockVacuumed and the current block, if there + * are any. This ensures that every block in the index is touched during + * VACUUM as required to ensure scans work correctly. */ if (standbyState == STANDBY_SNAPSHOT_READY && (xlrec->lastBlockVacuumed + 1) != xlrec->block) @@ -486,10 +486,10 @@ btree_xlog_vacuum(XLogRecPtr lsn, XLogRecord *record) for (; blkno < xlrec->block; blkno++) { /* - * XXX we don't actually need to read the block, we - * just need to confirm it is unpinned. If we had a special call - * into the buffer manager we could optimise this so that - * if the block is not in shared_buffers we confirm it as unpinned. + * XXX we don't actually need to read the block, we just need to + * confirm it is unpinned. If we had a special call into the + * buffer manager we could optimise this so that if the block is + * not in shared_buffers we confirm it as unpinned. * * Another simple optimization would be to check if there's any * backends running; if not, we could just skip this. @@ -505,9 +505,9 @@ btree_xlog_vacuum(XLogRecPtr lsn, XLogRecord *record) /* * If the block was restored from a full page image, nothing more to do. - * The RestoreBkpBlocks() call already pinned and took cleanup lock on - * it. XXX: Perhaps we should call RestoreBkpBlocks() *after* the loop - * above, to make the disk access more sequential. + * The RestoreBkpBlocks() call already pinned and took cleanup lock on it. + * XXX: Perhaps we should call RestoreBkpBlocks() *after* the loop above, + * to make the disk access more sequential. */ if (record->xl_info & XLR_BKP_BLOCK_1) return; @@ -567,8 +567,8 @@ btree_xlog_delete(XLogRecPtr lsn, XLogRecord *record) xlrec = (xl_btree_delete *) XLogRecGetData(record); /* - * We don't need to take a cleanup lock to apply these changes. - * See nbtree/README for details. + * We don't need to take a cleanup lock to apply these changes. See + * nbtree/README for details. */ buffer = XLogReadBuffer(xlrec->node, xlrec->block, false); if (!BufferIsValid(buffer)) @@ -819,13 +819,15 @@ btree_redo(XLogRecPtr lsn, XLogRecord *record) switch (info) { case XLOG_BTREE_DELETE: + /* - * Btree delete records can conflict with standby queries. You might - * think that vacuum records would conflict as well, but we've handled - * that already. XLOG_HEAP2_CLEANUP_INFO records provide the highest xid - * cleaned by the vacuum of the heap and so we can resolve any conflicts - * just once when that arrives. After that any we know that no conflicts - * exist from individual btree vacuum records on that index. + * Btree delete records can conflict with standby queries. You + * might think that vacuum records would conflict as well, but + * we've handled that already. XLOG_HEAP2_CLEANUP_INFO records + * provide the highest xid cleaned by the vacuum of the heap + * and so we can resolve any conflicts just once when that + * arrives. After that any we know that no conflicts exist + * from individual btree vacuum records on that index. */ { xl_btree_delete *xlrec = (xl_btree_delete *) XLogRecGetData(record); @@ -842,9 +844,11 @@ btree_redo(XLogRecPtr lsn, XLogRecord *record) break; case XLOG_BTREE_REUSE_PAGE: + /* - * Btree reuse page records exist to provide a conflict point when we - * reuse pages in the index via the FSM. That's all it does though. + * Btree reuse page records exist to provide a conflict point + * when we reuse pages in the index via the FSM. That's all it + * does though. */ { xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) XLogRecGetData(record); @@ -859,8 +863,8 @@ btree_redo(XLogRecPtr lsn, XLogRecord *record) } /* - * Vacuum needs to pin and take cleanup lock on every leaf page, - * a regular exclusive lock is enough for all other purposes. + * Vacuum needs to pin and take cleanup lock on every leaf page, a regular + * exclusive lock is enough for all other purposes. */ RestoreBkpBlocks(lsn, record, (info == XLOG_BTREE_VACUUM)); diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 92e1aeb3fd2..3f3bdc03353 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -42,7 +42,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.34 2010/01/02 16:57:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.35 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1298,11 +1298,11 @@ PostPrepare_MultiXact(TransactionId xid) myOldestMember = OldestMemberMXactId[MyBackendId]; if (MultiXactIdIsValid(myOldestMember)) { - BackendId dummyBackendId = TwoPhaseGetDummyBackendId(xid); + BackendId dummyBackendId = TwoPhaseGetDummyBackendId(xid); /* - * Even though storing MultiXactId is atomic, acquire lock to make sure - * others see both changes, not just the reset of the slot of the + * Even though storing MultiXactId is atomic, acquire lock to make + * sure others see both changes, not just the reset of the slot of the * current backend. Using a volatile pointer might suffice, but this * isn't a hot spot. */ @@ -1316,8 +1316,8 @@ PostPrepare_MultiXact(TransactionId xid) /* * We don't need to transfer OldestVisibleMXactId value, because the - * transaction is not going to be looking at any more multixacts once - * it's prepared. + * transaction is not going to be looking at any more multixacts once it's + * prepared. * * We assume that storing a MultiXactId is atomic and so we need not take * MultiXactGenLock to do this. @@ -1340,14 +1340,14 @@ multixact_twophase_recover(TransactionId xid, uint16 info, void *recdata, uint32 len) { BackendId dummyBackendId = TwoPhaseGetDummyBackendId(xid); - MultiXactId oldestMember; + MultiXactId oldestMember; /* - * Get the oldest member XID from the state file record, and set it in - * the OldestMemberMXactId slot reserved for this prepared transaction. + * Get the oldest member XID from the state file record, and set it in the + * OldestMemberMXactId slot reserved for this prepared transaction. */ Assert(len == sizeof(MultiXactId)); - oldestMember = *((MultiXactId *)recdata); + oldestMember = *((MultiXactId *) recdata); OldestMemberMXactId[dummyBackendId] = oldestMember; } @@ -1373,7 +1373,7 @@ multixact_twophase_postcommit(TransactionId xid, uint16 info, */ void multixact_twophase_postabort(TransactionId xid, uint16 info, - void *recdata, uint32 len) + void *recdata, uint32 len) { multixact_twophase_postcommit(xid, info, recdata, len); } @@ -2031,9 +2031,10 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record) max_xid = xids[i]; } - /* We don't expect anyone else to modify nextXid, hence startup process - * doesn't need to hold a lock while checking this. We still acquire - * the lock to modify it, though. + /* + * We don't expect anyone else to modify nextXid, hence startup + * process doesn't need to hold a lock while checking this. We still + * acquire the lock to modify it, though. */ if (TransactionIdFollowsOrEquals(max_xid, ShmemVariableCache->nextXid)) diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c index eac83a7b538..4ccb0c239b0 100644 --- a/src/backend/access/transam/subtrans.c +++ b/src/backend/access/transam/subtrans.c @@ -22,7 +22,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.26 2010/01/02 16:57:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.27 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,7 +89,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent, bool overwriteOK) /* Current state should be 0 */ Assert(*ptr == InvalidTransactionId || - (*ptr == parent && overwriteOK)); + (*ptr == parent && overwriteOK)); *ptr = parent; diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index ee9da91f68a..b1bf2c4f260 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.58 2010/01/02 16:57:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.59 2010/02/26 02:00:34 momjian Exp $ * * NOTES * Each global transaction is associated with a global transaction @@ -110,7 +110,7 @@ int max_prepared_xacts = 0; typedef struct GlobalTransactionData { PGPROC proc; /* dummy proc */ - BackendId dummyBackendId; /* similar to backend id for backends */ + BackendId dummyBackendId; /* similar to backend id for backends */ TimestampTz prepared_at; /* time of preparation */ XLogRecPtr prepare_lsn; /* XLOG offset of prepare record */ Oid owner; /* ID of user that executed the xact */ @@ -209,14 +209,14 @@ TwoPhaseShmemInit(void) /* * Assign a unique ID for each dummy proc, so that the range of * dummy backend IDs immediately follows the range of normal - * backend IDs. We don't dare to assign a real backend ID to - * dummy procs, because prepared transactions don't take part in - * cache invalidation like a real backend ID would imply, but - * having a unique ID for them is nevertheless handy. This - * arrangement allows you to allocate an array of size - * (MaxBackends + max_prepared_xacts + 1), and have a slot for - * every backend and prepared transaction. Currently multixact.c - * uses that technique. + * backend IDs. We don't dare to assign a real backend ID to dummy + * procs, because prepared transactions don't take part in cache + * invalidation like a real backend ID would imply, but having a + * unique ID for them is nevertheless handy. This arrangement + * allows you to allocate an array of size (MaxBackends + + * max_prepared_xacts + 1), and have a slot for every backend and + * prepared transaction. Currently multixact.c uses that + * technique. */ gxacts[i].dummyBackendId = MaxBackends + 1 + i; } @@ -677,7 +677,7 @@ pg_prepared_xact(PG_FUNCTION_ARGS) BackendId TwoPhaseGetDummyBackendId(TransactionId xid) { - PGPROC *proc = TwoPhaseGetDummyProc(xid); + PGPROC *proc = TwoPhaseGetDummyProc(xid); return ((GlobalTransaction) proc)->dummyBackendId; } @@ -874,8 +874,8 @@ StartPrepare(GlobalTransaction gxact) save_state_data(&hdr, sizeof(TwoPhaseFileHeader)); /* - * Add the additional info about subxacts, deletable files and - * cache invalidation messages. + * Add the additional info about subxacts, deletable files and cache + * invalidation messages. */ if (hdr.nsubxacts > 0) { @@ -1331,8 +1331,8 @@ FinishPreparedTransaction(const char *gid, bool isCommit) /* * Handle cache invalidation messages. * - * Relcache init file invalidation requires processing both - * before and after we send the SI messages. See AtEOXact_Inval() + * Relcache init file invalidation requires processing both before and + * after we send the SI messages. See AtEOXact_Inval() */ if (hdr->initfileinval) RelationCacheInitFileInvalidate(true); @@ -1786,8 +1786,8 @@ RecoverPreparedTransactions(void) bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage)); /* - * It's possible that SubTransSetParent has been set before, if the - * prepared transaction generated xid assignment records. Test + * It's possible that SubTransSetParent has been set before, if + * the prepared transaction generated xid assignment records. Test * here must match one used in AssignTransactionId(). */ if (InHotStandby && hdr->nsubxacts >= PGPROC_MAX_CACHED_SUBXIDS) diff --git a/src/backend/access/transam/twophase_rmgr.c b/src/backend/access/transam/twophase_rmgr.c index 86a1d12f93d..d8f7fb6a035 100644 --- a/src/backend/access/transam/twophase_rmgr.c +++ b/src/backend/access/transam/twophase_rmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.13 2010/02/16 22:34:43 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.14 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,8 +32,8 @@ const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] = { NULL, /* END ID */ lock_twophase_postcommit, /* Lock */ - pgstat_twophase_postcommit, /* pgstat */ - multixact_twophase_postcommit /* MultiXact */ + pgstat_twophase_postcommit, /* pgstat */ + multixact_twophase_postcommit /* MultiXact */ }; const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] = @@ -41,7 +41,7 @@ const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] = NULL, /* END ID */ lock_twophase_postabort, /* Lock */ pgstat_twophase_postabort, /* pgstat */ - multixact_twophase_postabort /* MultiXact */ + multixact_twophase_postabort /* MultiXact */ }; const TwoPhaseCallback twophase_standby_recover_callbacks[TWOPHASE_RM_MAX_ID + 1] = diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 60b5d3bd514..4f3c0ae4524 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -6,7 +6,7 @@ * Copyright (c) 2000-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.90 2010/02/20 21:24:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.91 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ VariableCache ShmemVariableCache = NULL; * * Note: when this is called, we are actually already inside a valid * transaction, since XIDs are now not allocated until the transaction - * does something. So it is safe to do a database lookup if we want to + * does something. So it is safe to do a database lookup if we want to * issue a warning about XID wrap. */ TransactionId @@ -83,13 +83,13 @@ GetNewTransactionId(bool isSubXact) * For safety's sake, we release XidGenLock while sending signals, * warnings, etc. This is not so much because we care about * preserving concurrency in this situation, as to avoid any - * possibility of deadlock while doing get_database_name(). - * First, copy all the shared values we'll need in this path. + * possibility of deadlock while doing get_database_name(). First, + * copy all the shared values we'll need in this path. */ TransactionId xidWarnLimit = ShmemVariableCache->xidWarnLimit; TransactionId xidStopLimit = ShmemVariableCache->xidStopLimit; TransactionId xidWrapLimit = ShmemVariableCache->xidWrapLimit; - Oid oldest_datoid = ShmemVariableCache->oldestXidDB; + Oid oldest_datoid = ShmemVariableCache->oldestXidDB; LWLockRelease(XidGenLock); @@ -104,7 +104,7 @@ GetNewTransactionId(bool isSubXact) if (IsUnderPostmaster && TransactionIdFollowsOrEquals(xid, xidStopLimit)) { - char *oldest_datname = get_database_name(oldest_datoid); + char *oldest_datname = get_database_name(oldest_datoid); /* complain even if that DB has disappeared */ if (oldest_datname) @@ -124,7 +124,7 @@ GetNewTransactionId(bool isSubXact) } else if (TransactionIdFollowsOrEquals(xid, xidWarnLimit)) { - char *oldest_datname = get_database_name(oldest_datoid); + char *oldest_datname = get_database_name(oldest_datoid); /* complain even if that DB has disappeared */ if (oldest_datname) @@ -329,8 +329,8 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid) /* Log the info */ ereport(DEBUG1, - (errmsg("transaction ID wrap limit is %u, limited by database with OID %u", - xidWrapLimit, oldest_datoid))); + (errmsg("transaction ID wrap limit is %u, limited by database with OID %u", + xidWrapLimit, oldest_datoid))); /* * If past the autovacuum force point, immediately signal an autovac @@ -346,7 +346,7 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid) /* Give an immediate warning if past the wrap warn point */ if (TransactionIdFollowsOrEquals(curXid, xidWarnLimit) && !InRecovery) { - char *oldest_datname = get_database_name(oldest_datoid); + char *oldest_datname = get_database_name(oldest_datoid); /* * Note: it's possible that get_database_name fails and returns NULL, @@ -355,11 +355,11 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid) */ if (oldest_datname) ereport(WARNING, - (errmsg("database \"%s\" must be vacuumed within %u transactions", - oldest_datname, - xidWrapLimit - curXid), - errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n" - "You might also need to commit or roll back old prepared transactions."))); + (errmsg("database \"%s\" must be vacuumed within %u transactions", + oldest_datname, + xidWrapLimit - curXid), + errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n" + "You might also need to commit or roll back old prepared transactions."))); else ereport(WARNING, (errmsg("database with OID %u must be vacuumed within %u transactions", @@ -377,7 +377,7 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid) * We primarily check whether oldestXidDB is valid. The cases we have in * mind are that that database was dropped, or the field was reset to zero * by pg_resetxlog. In either case we should force recalculation of the - * wrap limit. Also do it if oldestXid is old enough to be forcing + * wrap limit. Also do it if oldestXid is old enough to be forcing * autovacuums or other actions; this ensures we update our state as soon * as possible once extra overhead is being incurred. */ diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 044afd582dd..43966d5ab6f 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.288 2010/02/20 21:24:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.289 2010/02/26 02:00:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -139,9 +139,9 @@ typedef struct TransactionStateData int nChildXids; /* # of subcommitted child XIDs */ int maxChildXids; /* allocated size of childXids[] */ Oid prevUser; /* previous CurrentUserId setting */ - int prevSecContext; /* previous SecurityRestrictionContext */ + int prevSecContext; /* previous SecurityRestrictionContext */ bool prevXactReadOnly; /* entry-time xact r/o state */ - bool startedInRecovery; /* did we start in recovery? */ + bool startedInRecovery; /* did we start in recovery? */ struct TransactionStateData *parent; /* back link to parent */ } TransactionStateData; @@ -178,7 +178,7 @@ static TransactionStateData TopTransactionStateData = { * unreportedXids holds XIDs of all subtransactions that have not yet been * reported in a XLOG_XACT_ASSIGNMENT record. */ -static int nUnreportedXids; +static int nUnreportedXids; static TransactionId unreportedXids[PGPROC_MAX_CACHED_SUBXIDS]; static TransactionState CurrentTransactionState = &TopTransactionStateData; @@ -452,25 +452,28 @@ AssignTransactionId(TransactionState s) * include the top-level xid and all the subxids that have not yet been * reported using XLOG_XACT_ASSIGNMENT records. * - * This is required to limit the amount of shared memory required in a - * hot standby server to keep track of in-progress XIDs. See notes for + * This is required to limit the amount of shared memory required in a hot + * standby server to keep track of in-progress XIDs. See notes for * RecordKnownAssignedTransactionIds(). * - * We don't keep track of the immediate parent of each subxid, - * only the top-level transaction that each subxact belongs to. This - * is correct in recovery only because aborted subtransactions are - * separately WAL logged. + * We don't keep track of the immediate parent of each subxid, only the + * top-level transaction that each subxact belongs to. This is correct in + * recovery only because aborted subtransactions are separately WAL + * logged. */ if (isSubXact && XLogStandbyInfoActive()) { unreportedXids[nUnreportedXids] = s->transactionId; nUnreportedXids++; - /* ensure this test matches similar one in RecoverPreparedTransactions() */ + /* + * ensure this test matches similar one in + * RecoverPreparedTransactions() + */ if (nUnreportedXids >= PGPROC_MAX_CACHED_SUBXIDS) { XLogRecData rdata[2]; - xl_xact_assignment xlrec; + xl_xact_assignment xlrec; /* * xtop is always set by now because we recurse up transaction @@ -899,6 +902,7 @@ RecordTransactionCommit(void) nchildren = xactGetCommittedChildren(&children); nmsgs = xactGetCommittedInvalidationMessages(&invalMessages, &RelcacheInitFileInval); + /* * If we haven't been assigned an XID yet, we neither can, nor do we want * to write a COMMIT record. @@ -1098,10 +1102,9 @@ static void AtCCI_LocalCache(void) { /* - * Make any pending relation map changes visible. We must do this - * before processing local sinval messages, so that the map changes - * will get reflected into the relcache when relcache invals are - * processed. + * Make any pending relation map changes visible. We must do this before + * processing local sinval messages, so that the map changes will get + * reflected into the relcache when relcache invals are processed. */ AtCCI_RelationMap(); @@ -1227,9 +1230,9 @@ AtSubCommit_childXids(void) * * Note: We rely on the fact that the XID of a child always follows that * of its parent. By copying the XID of this subtransaction before the - * XIDs of its children, we ensure that the array stays ordered. - * Likewise, all XIDs already in the array belong to subtransactions - * started and subcommitted before us, so their XIDs must precede ours. + * XIDs of its children, we ensure that the array stays ordered. Likewise, + * all XIDs already in the array belong to subtransactions started and + * subcommitted before us, so their XIDs must precede ours. */ s->parent->childXids[s->parent->nChildXids] = s->transactionId; @@ -1457,10 +1460,10 @@ AtSubAbort_childXids(void) s->maxChildXids = 0; /* - * We could prune the unreportedXids array here. But we don't bother. - * That would potentially reduce number of XLOG_XACT_ASSIGNMENT records - * but it would likely introduce more CPU time into the more common - * paths, so we choose not to do that. + * We could prune the unreportedXids array here. But we don't bother. That + * would potentially reduce number of XLOG_XACT_ASSIGNMENT records but it + * would likely introduce more CPU time into the more common paths, so we + * choose not to do that. */ } @@ -2162,7 +2165,7 @@ AbortTransaction(void) /* * do abort processing */ - AfterTriggerEndXact(false); /* 'false' means it's abort */ + AfterTriggerEndXact(false); /* 'false' means it's abort */ AtAbort_Portals(); AtEOXact_LargeObject(false); AtAbort_Notify(); @@ -4362,9 +4365,9 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn) /* * Make sure nextXid is beyond any XID mentioned in the record. * - * We don't expect anyone else to modify nextXid, hence we - * don't need to hold a lock while checking this. We still acquire - * the lock to modify it, though. + * We don't expect anyone else to modify nextXid, hence we don't need to + * hold a lock while checking this. We still acquire the lock to modify + * it, though. */ if (TransactionIdFollowsOrEquals(max_xid, ShmemVariableCache->nextXid)) @@ -4400,8 +4403,8 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn) * protocol during recovery to provide information on database * consistency for when users try to set hint bits. It is important * that we do not set hint bits until the minRecoveryPoint is past - * this commit record. This ensures that if we crash we don't see - * hint bits set on changes made by transactions that haven't yet + * this commit record. This ensures that if we crash we don't see hint + * bits set on changes made by transactions that haven't yet * recovered. It's unlikely but it's good to be safe. */ TransactionIdAsyncCommitTree(xid, xlrec->nsubxacts, sub_xids, lsn); @@ -4413,17 +4416,17 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn) /* * Send any cache invalidations attached to the commit. We must - * maintain the same order of invalidation then release locks - * as occurs in . + * maintain the same order of invalidation then release locks as + * occurs in . */ ProcessCommittedInvalidationMessages(inval_msgs, xlrec->nmsgs, - XactCompletionRelcacheInitFileInval(xlrec), - xlrec->dbId, xlrec->tsId); + XactCompletionRelcacheInitFileInval(xlrec), + xlrec->dbId, xlrec->tsId); /* - * Release locks, if any. We do this for both two phase and normal - * one phase transactions. In effect we are ignoring the prepare - * phase and just going straight to lock release. + * Release locks, if any. We do this for both two phase and normal one + * phase transactions. In effect we are ignoring the prepare phase and + * just going straight to lock release. */ StandbyReleaseLockTree(xid, xlrec->nsubxacts, sub_xids); } @@ -4446,15 +4449,16 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn) } /* - * We issue an XLogFlush() for the same reason we emit ForceSyncCommit() in - * normal operation. For example, in DROP DATABASE, we delete all the files - * belonging to the database, and then commit the transaction. If we crash - * after all the files have been deleted but before the commit, you have an - * entry in pg_database without any files. To minimize the window for that, - * we use ForceSyncCommit() to rush the commit record to disk as quick as - * possible. We have the same window during recovery, and forcing an - * XLogFlush() (which updates minRecoveryPoint during recovery) helps - * to reduce that problem window, for any user that requested ForceSyncCommit(). + * We issue an XLogFlush() for the same reason we emit ForceSyncCommit() + * in normal operation. For example, in DROP DATABASE, we delete all the + * files belonging to the database, and then commit the transaction. If we + * crash after all the files have been deleted but before the commit, you + * have an entry in pg_database without any files. To minimize the window + * for that, we use ForceSyncCommit() to rush the commit record to disk as + * quick as possible. We have the same window during recovery, and forcing + * an XLogFlush() (which updates minRecoveryPoint during recovery) helps + * to reduce that problem window, for any user that requested + * ForceSyncCommit(). */ if (XactCompletionForceSyncCommit(xlrec)) XLogFlush(lsn); @@ -4480,9 +4484,11 @@ xact_redo_abort(xl_xact_abort *xlrec, TransactionId xid) max_xid = TransactionIdLatest(xid, xlrec->nsubxacts, sub_xids); /* Make sure nextXid is beyond any XID mentioned in the record */ - /* We don't expect anyone else to modify nextXid, hence we - * don't need to hold a lock while checking this. We still acquire - * the lock to modify it, though. + + /* + * We don't expect anyone else to modify nextXid, hence we don't need to + * hold a lock while checking this. We still acquire the lock to modify + * it, though. */ if (TransactionIdFollowsOrEquals(max_xid, ShmemVariableCache->nextXid)) @@ -4496,12 +4502,13 @@ xact_redo_abort(xl_xact_abort *xlrec, TransactionId xid) if (InHotStandby) { /* - * If a transaction completion record arrives that has as-yet unobserved - * subtransactions then this will not have been fully handled by the call - * to RecordKnownAssignedTransactionIds() in the main recovery loop in - * xlog.c. So we need to do bookkeeping again to cover that case. This is - * confusing and it is easy to think this call is irrelevant, which has - * happened three times in development already. Leave it in. + * If a transaction completion record arrives that has as-yet + * unobserved subtransactions then this will not have been fully + * handled by the call to RecordKnownAssignedTransactionIds() in the + * main recovery loop in xlog.c. So we need to do bookkeeping again to + * cover that case. This is confusing and it is easy to think this + * call is irrelevant, which has happened three times in development + * already. Leave it in. */ RecordKnownAssignedTransactionIds(max_xid); } @@ -4631,8 +4638,8 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec) msgs = (SharedInvalidationMessage *) &xacts[xlrec->nsubxacts]; if (XactCompletionRelcacheInitFileInval(xlrec)) - appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u", - xlrec->dbId, xlrec->tsId); + appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u", + xlrec->dbId, xlrec->tsId); appendStringInfo(buf, "; inval msgs:"); for (i = 0; i < xlrec->nmsgs; i++) @@ -4738,8 +4745,8 @@ xact_desc(StringInfo buf, uint8 xl_info, char *rec) /* * Note that we ignore the WAL record's xid, since we're more - * interested in the top-level xid that issued the record - * and which xids are being reported here. + * interested in the top-level xid that issued the record and which + * xids are being reported here. */ appendStringInfo(buf, "xid assignment xtop %u: ", xlrec->xtop); xact_desc_assignment(buf, xlrec); diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 40916571ac0..d753a31cb35 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.378 2010/02/25 02:17:50 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.379 2010/02/26 02:00:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,7 +70,7 @@ int XLOGbuffers = 8; int XLogArchiveTimeout = 0; bool XLogArchiveMode = false; char *XLogArchiveCommand = NULL; -bool XLogRequestRecoveryConnections = true; +bool XLogRequestRecoveryConnections = true; int MaxStandbyDelay = 30; bool fullPageWrites = true; bool log_checkpoints = false; @@ -140,9 +140,9 @@ TimeLineID ThisTimeLineID = 0; bool InRecovery = false; /* Are we in Hot Standby mode? Only valid in startup process, see xlog.h */ -HotStandbyState standbyState = STANDBY_DISABLED; +HotStandbyState standbyState = STANDBY_DISABLED; -static XLogRecPtr LastRec; +static XLogRecPtr LastRec; /* * Local copy of SharedRecoveryInProgress variable. True actually means "not @@ -156,7 +156,7 @@ static bool LocalRecoveryInProgress = true; * 0: unconditionally not allowed to insert XLOG * -1: must check RecoveryInProgress(); disallow until it is false * Most processes start with -1 and transition to 1 after seeing that recovery - * is not in progress. But we can also force the value for special cases. + * is not in progress. But we can also force the value for special cases. * The coding in XLogInsertAllowed() depends on the first two of these states * being numerically the same as bool true and false. */ @@ -181,7 +181,7 @@ static TimestampTz recoveryLastXTime = 0; /* options taken from recovery.conf for XLOG streaming */ static bool StandbyMode = false; static char *PrimaryConnInfo = NULL; -char *TriggerFile = NULL; +char *TriggerFile = NULL; /* if recoveryStopsHere returns true, it saves actual stop xid/time here */ static TransactionId recoveryStopXid; @@ -389,7 +389,7 @@ typedef struct XLogCtlData /* end+1 of the last record replayed (or being replayed) */ XLogRecPtr replayEndRecPtr; /* timestamp of last record replayed (or being replayed) */ - TimestampTz recoveryLastXTime; + TimestampTz recoveryLastXTime; /* end+1 of the last record replayed */ XLogRecPtr recoveryLastRecPtr; @@ -456,6 +456,7 @@ static uint32 readId = 0; static uint32 readSeg = 0; static uint32 readOff = 0; static uint32 readLen = 0; + /* Is the currently open segment being streamed from primary? */ static bool readStreamed = false; @@ -510,9 +511,9 @@ static void XLogWrite(XLogwrtRqst WriteRqst, bool flexible, bool xlog_switch); static bool InstallXLogFileSegment(uint32 *log, uint32 *seg, char *tmppath, bool find_free, int *max_advance, bool use_lock); -static int XLogFileRead(uint32 log, uint32 seg, int emode, TimeLineID tli, +static int XLogFileRead(uint32 log, uint32 seg, int emode, TimeLineID tli, bool fromArchive, bool notexistOk); -static int XLogFileReadAnyTLI(uint32 log, uint32 seg, int emode, +static int XLogFileReadAnyTLI(uint32 log, uint32 seg, int emode, bool fromArchive); static bool XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt, bool randAccess); @@ -1867,10 +1868,10 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force) * to not need a valid 'lsn' value. * * Another important reason for doing it this way is that the passed - * 'lsn' value could be bogus, i.e., past the end of available WAL, - * if the caller got it from a corrupted heap page. Accepting such - * a value as the min recovery point would prevent us from coming up - * at all. Instead, we just log a warning and continue with recovery. + * 'lsn' value could be bogus, i.e., past the end of available WAL, if + * the caller got it from a corrupted heap page. Accepting such a + * value as the min recovery point would prevent us from coming up at + * all. Instead, we just log a warning and continue with recovery. * (See also the comments about corrupt LSNs in XLogFlush.) */ SpinLockAcquire(&xlogctl->info_lck); @@ -1879,7 +1880,7 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force) if (!force && XLByteLT(newMinRecoveryPoint, lsn)) elog(WARNING, - "xlog min recovery request %X/%X is past current point %X/%X", + "xlog min recovery request %X/%X is past current point %X/%X", lsn.xlogid, lsn.xrecoff, newMinRecoveryPoint.xlogid, newMinRecoveryPoint.xrecoff); @@ -1912,10 +1913,10 @@ XLogFlush(XLogRecPtr record) /* * During REDO, we are reading not writing WAL. Therefore, instead of - * trying to flush the WAL, we should update minRecoveryPoint instead. - * We test XLogInsertAllowed(), not InRecovery, because we need the - * bgwriter to act this way too, and because when the bgwriter tries - * to write the end-of-recovery checkpoint, it should indeed flush. + * trying to flush the WAL, we should update minRecoveryPoint instead. We + * test XLogInsertAllowed(), not InRecovery, because we need the bgwriter + * to act this way too, and because when the bgwriter tries to write the + * end-of-recovery checkpoint, it should indeed flush. */ if (!XLogInsertAllowed()) { @@ -2007,16 +2008,16 @@ XLogFlush(XLogRecPtr record) * the whole system due to corruption on one data page. In particular, if * the bad page is encountered again during recovery then we would be * unable to restart the database at all! (This scenario actually - * happened in the field several times with 7.1 releases.) As of 8.4, - * bad LSNs encountered during recovery are UpdateMinRecoveryPoint's - * problem; the only time we can reach here during recovery is while - * flushing the end-of-recovery checkpoint record, and we don't expect - * that to have a bad LSN. + * happened in the field several times with 7.1 releases.) As of 8.4, bad + * LSNs encountered during recovery are UpdateMinRecoveryPoint's problem; + * the only time we can reach here during recovery is while flushing the + * end-of-recovery checkpoint record, and we don't expect that to have a + * bad LSN. * - * Note that for calls from xact.c, the ERROR will - * be promoted to PANIC since xact.c calls this routine inside a critical - * section. However, calls from bufmgr.c are not within critical sections - * and so we will not force a restart for a bad LSN on a data page. + * Note that for calls from xact.c, the ERROR will be promoted to PANIC + * since xact.c calls this routine inside a critical section. However, + * calls from bufmgr.c are not within critical sections and so we will not + * force a restart for a bad LSN on a data page. */ if (XLByteLT(LogwrtResult.Flush, record)) elog(ERROR, @@ -2136,9 +2137,10 @@ XLogNeedsFlush(XLogRecPtr record) LWLockRelease(ControlFileLock); /* - * An invalid minRecoveryPoint means that we need to recover all the WAL, - * i.e., we're doing crash recovery. We never modify the control file's - * value in that case, so we can short-circuit future checks here too. + * An invalid minRecoveryPoint means that we need to recover all the + * WAL, i.e., we're doing crash recovery. We never modify the control + * file's value in that case, so we can short-circuit future checks + * here too. */ if (minRecoveryPoint.xlogid == 0 && minRecoveryPoint.xrecoff == 0) updateMinRecoveryPoint = false; @@ -2572,46 +2574,46 @@ XLogFileRead(uint32 log, uint32 seg, int emode, TimeLineID tli, char path[MAXPGPATH]; int fd; - XLogFileName(xlogfname, tli, log, seg); + XLogFileName(xlogfname, tli, log, seg); - if (fromArchive) - { - /* Report recovery progress in PS display */ - snprintf(activitymsg, sizeof(activitymsg), "waiting for %s", - xlogfname); - set_ps_display(activitymsg, false); - - restoredFromArchive = RestoreArchivedFile(path, xlogfname, - "RECOVERYXLOG", - XLogSegSize); - if (!restoredFromArchive) - return -1; - } - else - { - XLogFilePath(path, tli, log, seg); - restoredFromArchive = false; - } + if (fromArchive) + { + /* Report recovery progress in PS display */ + snprintf(activitymsg, sizeof(activitymsg), "waiting for %s", + xlogfname); + set_ps_display(activitymsg, false); - fd = BasicOpenFile(path, O_RDONLY | PG_BINARY, 0); - if (fd >= 0) - { - /* Success! */ - curFileTLI = tli; + restoredFromArchive = RestoreArchivedFile(path, xlogfname, + "RECOVERYXLOG", + XLogSegSize); + if (!restoredFromArchive) + return -1; + } + else + { + XLogFilePath(path, tli, log, seg); + restoredFromArchive = false; + } - /* Report recovery progress in PS display */ - snprintf(activitymsg, sizeof(activitymsg), "recovering %s", - xlogfname); - set_ps_display(activitymsg, false); + fd = BasicOpenFile(path, O_RDONLY | PG_BINARY, 0); + if (fd >= 0) + { + /* Success! */ + curFileTLI = tli; - return fd; - } - if (errno != ENOENT || !notfoundOk) /* unexpected failure? */ - ereport(PANIC, - (errcode_for_file_access(), - errmsg("could not open file \"%s\" (log file %u, segment %u): %m", - path, log, seg))); - return -1; + /* Report recovery progress in PS display */ + snprintf(activitymsg, sizeof(activitymsg), "recovering %s", + xlogfname); + set_ps_display(activitymsg, false); + + return fd; + } + if (errno != ENOENT || !notfoundOk) /* unexpected failure? */ + ereport(PANIC, + (errcode_for_file_access(), + errmsg("could not open file \"%s\" (log file %u, segment %u): %m", + path, log, seg))); + return -1; } /* @@ -2653,8 +2655,8 @@ XLogFileReadAnyTLI(uint32 log, uint32 seg, int emode, bool fromArchive) * If not in StandbyMode, fall back to searching pg_xlog. In * StandbyMode we're streaming segments from the primary to pg_xlog, * and we mustn't confuse the (possibly partial) segments in pg_xlog - * with complete segments ready to be applied. We rather wait for - * the records to arrive through streaming. + * with complete segments ready to be applied. We rather wait for the + * records to arrive through streaming. */ if (!StandbyMode && fromArchive) { @@ -2685,8 +2687,8 @@ XLogFileClose(void) /* * WAL segment files will not be re-read in normal operation, so we advise * the OS to release any cached pages. But do not do so if WAL archiving - * or streaming is active, because archiver and walsender process could use - * the cache to read the WAL segment. + * or streaming is active, because archiver and walsender process could + * use the cache to read the WAL segment. */ #if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED) if (!XLogIsNeeded()) @@ -2893,7 +2895,7 @@ RestoreArchivedFile(char *path, const char *xlogfname, { if (expectedSize > 0 && stat_buf.st_size != expectedSize) { - int elevel; + int elevel; /* * If we find a partial file in standby mode, we assume it's @@ -2901,11 +2903,11 @@ RestoreArchivedFile(char *path, const char *xlogfname, * trying. * * Otherwise treat a wrong-sized file as FATAL to ensure the - * DBA would notice it, but is that too strong? We could try + * DBA would notice it, but is that too strong? We could try * to plow ahead with a local copy of the file ... but the * problem is that there probably isn't one, and we'd - * incorrectly conclude we've reached the end of WAL and - * we're done recovering ... + * incorrectly conclude we've reached the end of WAL and we're + * done recovering ... */ if (StandbyMode && stat_buf.st_size < expectedSize) elevel = DEBUG1; @@ -2975,6 +2977,7 @@ RestoreArchivedFile(char *path, const char *xlogfname, xlogfname, rc))); not_available: + /* * if an archived file is not available, there might still be a version of * this file in XLOGDIR, so return that as the filename to open. @@ -3141,6 +3144,7 @@ RemoveOldXlogFiles(uint32 log, uint32 seg, XLogRecPtr endptr) struct dirent *xlde; char lastoff[MAXFNAMELEN]; char path[MAXPGPATH]; + #ifdef WIN32 char newpath[MAXPGPATH]; #endif @@ -3218,21 +3222,22 @@ RemoveOldXlogFiles(uint32 log, uint32 seg, XLogRecPtr endptr) else { /* No need for any more future segments... */ - int rc; + int rc; ereport(DEBUG2, (errmsg("removing transaction log file \"%s\"", xlde->d_name))); #ifdef WIN32 + /* * On Windows, if another process (e.g another backend) * holds the file open in FILE_SHARE_DELETE mode, unlink * will succeed, but the file will still show up in - * directory listing until the last handle is closed. - * To avoid confusing the lingering deleted file for a - * live WAL file that needs to be archived, rename it - * before deleting it. + * directory listing until the last handle is closed. To + * avoid confusing the lingering deleted file for a live + * WAL file that needs to be archived, rename it before + * deleting it. * * If another process holds the file open without * FILE_SHARE_DELETE flag, rename will fail. We'll try @@ -3553,8 +3558,8 @@ ReadRecord(XLogRecPtr *RecPtr, int emode_arg, bool fetching_ckpt) RecPtr = &tmpRecPtr; /* - * Align recptr to next page if no more records can fit on the - * current page. + * Align recptr to next page if no more records can fit on the current + * page. */ if (XLOG_BLCKSZ - (RecPtr->xrecoff % XLOG_BLCKSZ) < SizeOfXLogRecord) { @@ -5093,8 +5098,8 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg) UpdateMinRecoveryPoint(InvalidXLogRecPtr, true); /* - * If the ending log segment is still open, close it (to avoid - * problems on Windows with trying to rename or delete an open file). + * If the ending log segment is still open, close it (to avoid problems on + * Windows with trying to rename or delete an open file). */ if (readFile >= 0) { @@ -5376,17 +5381,17 @@ CheckRequiredParameterValues(CheckPoint checkPoint) { /* We ignore autovacuum_max_workers when we make this test. */ RecoveryRequiresIntParameter("max_connections", - MaxConnections, checkPoint.MaxConnections); + MaxConnections, checkPoint.MaxConnections); RecoveryRequiresIntParameter("max_prepared_xacts", - max_prepared_xacts, checkPoint.max_prepared_xacts); + max_prepared_xacts, checkPoint.max_prepared_xacts); RecoveryRequiresIntParameter("max_locks_per_xact", - max_locks_per_xact, checkPoint.max_locks_per_xact); + max_locks_per_xact, checkPoint.max_locks_per_xact); if (!checkPoint.XLogStandbyInfoMode) ereport(ERROR, - (errmsg("recovery connections cannot start because the recovery_connections " - "parameter is disabled on the WAL source server"))); + (errmsg("recovery connections cannot start because the recovery_connections " + "parameter is disabled on the WAL source server"))); } /* @@ -5464,12 +5469,12 @@ StartupXLOG(void) ValidateXLOGDirectoryStructure(); /* - * Clear out any old relcache cache files. This is *necessary* if we - * do any WAL replay, since that would probably result in the cache files - * being out of sync with database reality. In theory we could leave - * them in place if the database had been cleanly shut down, but it - * seems safest to just remove them always and let them be rebuilt - * during the first backend startup. + * Clear out any old relcache cache files. This is *necessary* if we do + * any WAL replay, since that would probably result in the cache files + * being out of sync with database reality. In theory we could leave them + * in place if the database had been cleanly shut down, but it seems + * safest to just remove them always and let them be rebuilt during the + * first backend startup. */ RelationCacheInitFileRemove(); @@ -5648,8 +5653,8 @@ StartupXLOG(void) { if (recoveryTargetExact) ereport(LOG, - (errmsg("starting point-in-time recovery to XID %u", - recoveryTargetXid))); + (errmsg("starting point-in-time recovery to XID %u", + recoveryTargetXid))); else ereport(LOG, (errmsg("starting point-in-time recovery to %s", @@ -5676,6 +5681,7 @@ StartupXLOG(void) if (XLByteLT(ControlFile->minRecoveryPoint, checkPoint.redo)) ControlFile->minRecoveryPoint = checkPoint.redo; } + /* * set backupStartupPoint if we're starting archive recovery from a * base backup @@ -5714,14 +5720,14 @@ StartupXLOG(void) /* * Initialize recovery connections, if enabled. We won't let backends - * in yet, not until we've reached the min recovery point specified - * in control file and we've established a recovery snapshot from a + * in yet, not until we've reached the min recovery point specified in + * control file and we've established a recovery snapshot from a * running-xacts WAL record. */ if (InArchiveRecovery && XLogRequestRecoveryConnections) { TransactionId *xids; - int nxids; + int nxids; CheckRequiredParameterValues(checkPoint); @@ -5814,7 +5820,7 @@ StartupXLOG(void) { #ifdef WAL_DEBUG if (XLOG_DEBUG || - (rmid == RM_XACT_ID && trace_recovery_messages <= DEBUG2) || + (rmid == RM_XACT_ID && trace_recovery_messages <= DEBUG2) || (rmid != RM_XACT_ID && trace_recovery_messages <= DEBUG3)) { StringInfoData buf; @@ -5845,14 +5851,14 @@ StartupXLOG(void) { reachedMinRecoveryPoint = true; ereport(LOG, - (errmsg("consistent recovery state reached at %X/%X", - EndRecPtr.xlogid, EndRecPtr.xrecoff))); + (errmsg("consistent recovery state reached at %X/%X", + EndRecPtr.xlogid, EndRecPtr.xrecoff))); } /* * Have we got a valid starting snapshot that will allow - * queries to be run? If so, we can tell postmaster that - * the database is consistent now, enabling connections. + * queries to be run? If so, we can tell postmaster that the + * database is consistent now, enabling connections. */ if (standbyState == STANDBY_SNAPSHOT_READY && !backendsAllowed && @@ -5950,9 +5956,8 @@ StartupXLOG(void) /* * We are now done reading the xlog from stream. Turn off streaming - * recovery to force fetching the files (which would be required - * at end of recovery, e.g., timeline history file) from archive or - * pg_xlog. + * recovery to force fetching the files (which would be required at end of + * recovery, e.g., timeline history file) from archive or pg_xlog. */ StandbyMode = false; @@ -6155,8 +6160,8 @@ StartupXLOG(void) TransactionIdRetreat(ShmemVariableCache->latestCompletedXid); /* - * Start up the commit log and related stuff, too. In hot standby mode - * we did this already before WAL replay. + * Start up the commit log and related stuff, too. In hot standby mode we + * did this already before WAL replay. */ if (standbyState == STANDBY_DISABLED) { @@ -6194,7 +6199,7 @@ StartupXLOG(void) } /* - * All done. Allow backends to write WAL. (Although the bool flag is + * All done. Allow backends to write WAL. (Although the bool flag is * probably atomic in itself, we use the info_lck here to ensure that * there are no race conditions concerning visibility of other recent * updates to shared memory.) @@ -6222,9 +6227,9 @@ bool RecoveryInProgress(void) { /* - * We check shared state each time only until we leave recovery mode. - * We can't re-enter recovery, so there's no need to keep checking after - * the shared variable has once been seen false. + * We check shared state each time only until we leave recovery mode. We + * can't re-enter recovery, so there's no need to keep checking after the + * shared variable has once been seen false. */ if (!LocalRecoveryInProgress) return false; @@ -6241,7 +6246,7 @@ RecoveryInProgress(void) /* * Initialize TimeLineID and RedoRecPtr when we discover that recovery * is finished. InitPostgres() relies upon this behaviour to ensure - * that InitXLOGAccess() is called at backend startup. (If you change + * that InitXLOGAccess() is called at backend startup. (If you change * this, see also LocalSetXLogInsertAllowed.) */ if (!LocalRecoveryInProgress) @@ -6262,9 +6267,9 @@ bool XLogInsertAllowed(void) { /* - * If value is "unconditionally true" or "unconditionally false", - * just return it. This provides the normal fast path once recovery - * is known done. + * If value is "unconditionally true" or "unconditionally false", just + * return it. This provides the normal fast path once recovery is known + * done. */ if (LocalXLogInsertAllowed >= 0) return (bool) LocalXLogInsertAllowed; @@ -6276,8 +6281,8 @@ XLogInsertAllowed(void) return false; /* - * On exit from recovery, reset to "unconditionally true", since there - * is no need to keep checking. + * On exit from recovery, reset to "unconditionally true", since there is + * no need to keep checking. */ LocalXLogInsertAllowed = 1; return true; @@ -6938,9 +6943,9 @@ CreateCheckPoint(int flags) CheckPointGuts(checkPoint.redo, flags); /* - * Take a snapshot of running transactions and write this to WAL. - * This allows us to reconstruct the state of running transactions - * during archive recovery, if required. Skip, if this info disabled. + * Take a snapshot of running transactions and write this to WAL. This + * allows us to reconstruct the state of running transactions during + * archive recovery, if required. Skip, if this info disabled. * * If we are shutting down, or Startup process is completing crash * recovery we don't need to write running xact data. @@ -6948,7 +6953,7 @@ CreateCheckPoint(int flags) * Update checkPoint.nextXid since we have a later value */ if (!shutdown && XLogStandbyInfoActive()) - LogStandbySnapshot(&checkPoint.oldestActiveXid, &checkPoint.nextXid); + LogStandbySnapshot(&checkPoint.oldestActiveXid, &checkPoint.nextXid); else checkPoint.oldestActiveXid = InvalidTransactionId; @@ -6970,18 +6975,18 @@ CreateCheckPoint(int flags) XLogFlush(recptr); /* - * We mustn't write any new WAL after a shutdown checkpoint, or it will - * be overwritten at next startup. No-one should even try, this just - * allows sanity-checking. In the case of an end-of-recovery checkpoint, - * we want to just temporarily disable writing until the system has exited + * We mustn't write any new WAL after a shutdown checkpoint, or it will be + * overwritten at next startup. No-one should even try, this just allows + * sanity-checking. In the case of an end-of-recovery checkpoint, we want + * to just temporarily disable writing until the system has exited * recovery. */ if (shutdown) { if (flags & CHECKPOINT_END_OF_RECOVERY) - LocalXLogInsertAllowed = -1; /* return to "check" state */ + LocalXLogInsertAllowed = -1; /* return to "check" state */ else - LocalXLogInsertAllowed = 0; /* never again write WAL */ + LocalXLogInsertAllowed = 0; /* never again write WAL */ } /* @@ -7036,18 +7041,17 @@ CreateCheckPoint(int flags) smgrpostckpt(); /* - * If there's connected standby servers doing XLOG streaming, don't - * delete XLOG files that have not been streamed to all of them yet. - * This does nothing to prevent them from being deleted when the - * standby is disconnected (e.g because of network problems), but at - * least it avoids an open replication connection from failing because - * of that. + * If there's connected standby servers doing XLOG streaming, don't delete + * XLOG files that have not been streamed to all of them yet. This does + * nothing to prevent them from being deleted when the standby is + * disconnected (e.g because of network problems), but at least it avoids + * an open replication connection from failing because of that. */ if ((_logId || _logSeg) && MaxWalSenders > 0) { - XLogRecPtr oldest; - uint32 log; - uint32 seg; + XLogRecPtr oldest; + uint32 log; + uint32 seg; oldest = GetOldestWALSendPointer(); if (oldest.xlogid != 0 || oldest.xrecoff != 0) @@ -7055,15 +7059,15 @@ CreateCheckPoint(int flags) XLByteToSeg(oldest, log, seg); if (log < _logId || (log == _logId && seg < _logSeg)) { - _logId = log; - _logSeg = seg; + _logId = log; + _logSeg = seg; } } } /* - * Delete old log files (those no longer needed even for - * previous checkpoint or the standbys in XLOG streaming). + * Delete old log files (those no longer needed even for previous + * checkpoint or the standbys in XLOG streaming). */ if (_logId || _logSeg) { @@ -7262,8 +7266,8 @@ CreateRestartPoint(int flags) /* * Update pg_control, using current time. Check that it still shows * IN_ARCHIVE_RECOVERY state and an older checkpoint, else do nothing; - * this is a quick hack to make sure nothing really bad happens if - * somehow we get here after the end-of-recovery checkpoint. + * this is a quick hack to make sure nothing really bad happens if somehow + * we get here after the end-of-recovery checkpoint. */ LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); if (ControlFile->state == DB_IN_ARCHIVE_RECOVERY && @@ -7312,9 +7316,9 @@ CreateRestartPoint(int flags) LogCheckpointEnd(true); ereport((log_checkpoints ? LOG : DEBUG2), - (errmsg("recovery restart point at %X/%X with latest known log time %s", - lastCheckPoint.redo.xlogid, lastCheckPoint.redo.xrecoff, - timestamptz_to_str(GetLatestXLogTime())))); + (errmsg("recovery restart point at %X/%X with latest known log time %s", + lastCheckPoint.redo.xlogid, lastCheckPoint.redo.xrecoff, + timestamptz_to_str(GetLatestXLogTime())))); LWLockRelease(CheckpointLock); return true; @@ -7522,6 +7526,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record) else if (info == XLOG_BACKUP_END) { XLogRecPtr startpoint; + memcpy(&startpoint, XLogRecGetData(record), sizeof(startpoint)); if (XLByteEQ(ControlFile->backupStartPoint, startpoint)) @@ -7550,12 +7555,12 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record) if (InArchiveRecovery) { /* - * Note: We don't print the reason string from the record, - * because that gets added as a line using xlog_desc() + * Note: We don't print the reason string from the record, because + * that gets added as a line using xlog_desc() */ ereport(WARNING, - (errmsg("unlogged operation performed, data may be missing"), - errhint("This can happen if you temporarily disable archive_mode without taking a new base backup."))); + (errmsg("unlogged operation performed, data may be missing"), + errhint("This can happen if you temporarily disable archive_mode without taking a new base backup."))); } } } @@ -7601,7 +7606,7 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec) } else if (info == XLOG_BACKUP_END) { - XLogRecPtr startpoint; + XLogRecPtr startpoint; memcpy(&startpoint, rec, sizeof(XLogRecPtr)); appendStringInfo(buf, "backup end: %X/%X", @@ -7609,7 +7614,7 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec) } else if (info == XLOG_UNLOGGED) { - char *reason = rec; + char *reason = rec; appendStringInfo(buf, "unlogged operation: %s", reason); } @@ -7649,7 +7654,7 @@ xlog_outrec(StringInfo buf, XLogRecord *record) static int get_sync_bit(int method) { - int o_direct_flag = 0; + int o_direct_flag = 0; /* If fsync is disabled, never open in sync mode */ if (!enableFsync) @@ -7658,11 +7663,11 @@ get_sync_bit(int method) /* * Optimize writes by bypassing kernel cache with O_DIRECT when using * O_SYNC, O_DSYNC or O_FSYNC. But only if archiving and streaming are - * disabled, otherwise the archive command or walsender process will - * read the WAL soon after writing it, which is guaranteed to cause a - * physical read if we bypassed the kernel cache. We also skip the - * posix_fadvise(POSIX_FADV_DONTNEED) call in XLogFileClose() for the - * same reason. + * disabled, otherwise the archive command or walsender process will read + * the WAL soon after writing it, which is guaranteed to cause a physical + * read if we bypassed the kernel cache. We also skip the + * posix_fadvise(POSIX_FADV_DONTNEED) call in XLogFileClose() for the same + * reason. * * Never use O_DIRECT in walreceiver process for similar reasons; the WAL * written by walreceiver is normally read by the startup process soon @@ -7985,7 +7990,7 @@ pg_stop_backup(PG_FUNCTION_ARGS) { XLogRecPtr startpoint; XLogRecPtr stoppoint; - XLogRecData rdata; + XLogRecData rdata; pg_time_t stamp_time; char strfbuf[128]; char histfilepath[MAXPGPATH]; @@ -8132,8 +8137,8 @@ pg_stop_backup(PG_FUNCTION_ARGS) * * We wait forever, since archive_command is supposed to work and we * assume the admin wanted his backup to work completely. If you don't - * wish to wait, you can set statement_timeout. Also, some notices - * are issued to clue in anyone who might be doing this interactively. + * wish to wait, you can set statement_timeout. Also, some notices are + * issued to clue in anyone who might be doing this interactively. */ XLByteToPrevSeg(stoppoint, _logId, _logSeg); XLogFileName(lastxlogfilename, ThisTimeLineID, _logId, _logSeg); @@ -8161,9 +8166,9 @@ pg_stop_backup(PG_FUNCTION_ARGS) ereport(WARNING, (errmsg("pg_stop_backup still waiting for all required WAL segments to be archived (%d seconds elapsed)", waits), - errhint("Check that your archive_command is executing properly. " - "pg_stop_backup can be cancelled safely, " - "but the database backup will not be usable without all the WAL segments."))); + errhint("Check that your archive_command is executing properly. " + "pg_stop_backup can be cancelled safely, " + "but the database backup will not be usable without all the WAL segments."))); } } @@ -8621,6 +8626,7 @@ HandleStartupProcInterrupts(void) got_SIGHUP = false; ProcessConfigFile(PGC_SIGHUP); } + /* * Check if we were requested to exit without finishing recovery. */ @@ -8653,10 +8659,11 @@ StartupProcessMain(void) */ pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */ pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */ - pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */ - pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */ + pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */ + pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */ if (XLogRequestRecoveryConnections) - pqsignal(SIGALRM, handle_standby_sig_alarm); /* ignored unless InHotStandby */ + pqsignal(SIGALRM, handle_standby_sig_alarm); /* ignored unless + * InHotStandby */ else pqsignal(SIGALRM, SIG_IGN); pqsignal(SIGPIPE, SIG_IGN); @@ -8731,20 +8738,20 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt, { if (StandbyMode) { - bool last_restore_failed = false; + bool last_restore_failed = false; /* * In standby mode, wait for the requested record to become - * available, either via restore_command succeeding to restore - * the segment, or via walreceiver having streamed the record. + * available, either via restore_command succeeding to restore the + * segment, or via walreceiver having streamed the record. */ for (;;) { if (WalRcvInProgress()) { /* - * While walreceiver is active, wait for new WAL to - * arrive from primary. + * While walreceiver is active, wait for new WAL to arrive + * from primary. */ receivedUpto = GetWalRcvWriteRecPtr(); if (XLByteLT(*RecPtr, receivedUpto)) @@ -8798,10 +8805,10 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt, /* * If we succeeded restoring some segments from archive - * since the last connection attempt (or we haven't - * tried streaming yet, retry immediately. But if we - * haven't, assume the problem is persistent, so be - * less aggressive. + * since the last connection attempt (or we haven't tried + * streaming yet, retry immediately. But if we haven't, + * assume the problem is persistent, so be less + * aggressive. */ if (last_restore_failed) { @@ -8813,7 +8820,7 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt, */ if (CheckForStandbyTrigger()) goto next_record_is_invalid; - pg_usleep(5000000L); /* 5 seconds */ + pg_usleep(5000000L); /* 5 seconds */ } last_restore_failed = true; @@ -8832,8 +8839,8 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt, } /* - * This possibly-long loop needs to handle interrupts of startup - * process. + * This possibly-long loop needs to handle interrupts of + * startup process. */ HandleStartupProcInterrupts(); } @@ -8857,16 +8864,16 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt, } /* - * At this point, we have the right segment open and we know the - * requested record is in it. + * At this point, we have the right segment open and we know the requested + * record is in it. */ Assert(readFile != -1); /* - * If the current segment is being streamed from master, calculate - * how much of the current page we have received already. We know the - * requested record has been received, but this is for the benefit - * of future calls, to allow quick exit at the top of this function. + * If the current segment is being streamed from master, calculate how + * much of the current page we have received already. We know the + * requested record has been received, but this is for the benefit of + * future calls, to allow quick exit at the top of this function. */ if (readStreamed) { @@ -8909,16 +8916,16 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt, { ereport(emode, (errcode_for_file_access(), - errmsg("could not seek in log file %u, segment %u to offset %u: %m", - readId, readSeg, readOff))); + errmsg("could not seek in log file %u, segment %u to offset %u: %m", + readId, readSeg, readOff))); goto next_record_is_invalid; } if (read(readFile, readBuf, XLOG_BLCKSZ) != XLOG_BLCKSZ) { ereport(emode, (errcode_for_file_access(), - errmsg("could not read from log file %u, segment %u, offset %u: %m", - readId, readSeg, readOff))); + errmsg("could not read from log file %u, segment %u, offset %u: %m", + readId, readSeg, readOff))); goto next_record_is_invalid; } if (!ValidXLOGHeader((XLogPageHeader) readBuf, emode)) diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index d2b7c1e5854..a9c5d1fd53b 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.259 2010/02/07 20:48:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.260 2010/02/26 02:00:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -370,7 +370,7 @@ AuxiliaryProcessMain(int argc, char *argv[]) #endif /* - * Assign the ProcSignalSlot for an auxiliary process. Since it + * Assign the ProcSignalSlot for an auxiliary process. Since it * doesn't have a BackendId, the slot is statically allocated based on * the auxiliary process type (auxType). Backends use slots indexed * in the range from 1 to MaxBackends (inclusive), so we use @@ -493,8 +493,8 @@ BootstrapModeMain(void) boot_yyparse(); /* - * We should now know about all mapped relations, so it's okay to - * write out the initial relation mapping files. + * We should now know about all mapped relations, so it's okay to write + * out the initial relation mapping files. */ RelationMapFinishBootstrap(); diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 1576191737a..0488f765965 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.162 2010/02/14 18:42:12 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.163 2010/02/26 02:00:35 momjian Exp $ * * NOTES * See acl.h. @@ -85,8 +85,8 @@ typedef struct */ typedef struct { - Oid roleid; /* owning role */ - Oid nspid; /* namespace, or InvalidOid if none */ + Oid roleid; /* owning role */ + Oid nspid; /* namespace, or InvalidOid if none */ /* remaining fields are same as in InternalGrant: */ bool is_grant; GrantObjectType objtype; @@ -353,7 +353,7 @@ ExecuteGrantStmt(GrantStmt *stmt) case ACL_TARGET_ALL_IN_SCHEMA: istmt.objects = objectsInSchemaToOids(stmt->objtype, stmt->objects); break; - /* ACL_TARGET_DEFAULTS should not be seen here */ + /* ACL_TARGET_DEFAULTS should not be seen here */ default: elog(ERROR, "unrecognized GrantStmt.targtype: %d", (int) stmt->targtype); @@ -611,7 +611,7 @@ objectNamesToOids(GrantObjectType objtype, List *objnames) case ACL_OBJECT_LARGEOBJECT: foreach(cell, objnames) { - Oid lobjOid = intVal(lfirst(cell)); + Oid lobjOid = intVal(lfirst(cell)); if (!LargeObjectExists(lobjOid)) ereport(ERROR, @@ -880,8 +880,8 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt) } /* - * Convert action->privileges, a list of privilege strings, - * into an AclMode bitmask. + * Convert action->privileges, a list of privilege strings, into an + * AclMode bitmask. */ switch (action->objtype) { @@ -928,7 +928,7 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt) if (privnode->cols) ereport(ERROR, (errcode(ERRCODE_INVALID_GRANT_OPERATION), - errmsg("default privileges cannot be set for columns"))); + errmsg("default privileges cannot be set for columns"))); if (privnode->priv_name == NULL) /* parser mistake? */ elog(ERROR, "AccessPriv node must specify privilege"); @@ -962,10 +962,10 @@ ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt) iacls.roleid = get_roleid_checked(rolename); /* - * We insist that calling user be a member of each target role. - * If he has that, he could become that role anyway via SET ROLE, - * so FOR ROLE is just a syntactic convenience and doesn't give - * any special privileges. + * We insist that calling user be a member of each target role. If + * he has that, he could become that role anyway via SET ROLE, so + * FOR ROLE is just a syntactic convenience and doesn't give any + * special privileges. */ check_is_member_of_role(GetUserId(), iacls.roleid); @@ -1050,8 +1050,8 @@ SetDefaultACL(InternalDefaultACL *iacls) rel = heap_open(DefaultAclRelationId, RowExclusiveLock); /* - * Convert ACL object type to pg_default_acl object type - * and handle all_privs option + * Convert ACL object type to pg_default_acl object type and handle + * all_privs option */ switch (iacls->objtype) { @@ -1084,7 +1084,7 @@ SetDefaultACL(InternalDefaultACL *iacls) tuple = SearchSysCache3(DEFACLROLENSPOBJ, ObjectIdGetDatum(iacls->roleid), ObjectIdGetDatum(iacls->nspid), - CharGetDatum(objtype)); + CharGetDatum(objtype)); if (HeapTupleIsValid(tuple)) { @@ -1110,9 +1110,9 @@ SetDefaultACL(InternalDefaultACL *iacls) { /* * If we are creating a global entry, start with the hard-wired - * defaults and modify as per command. Otherwise, start with an empty - * ACL and modify that. This is needed because global entries - * replace the hard-wired defaults, while others do not. + * defaults and modify as per command. Otherwise, start with an empty + * ACL and modify that. This is needed because global entries replace + * the hard-wired defaults, while others do not. */ if (!OidIsValid(iacls->nspid)) old_acl = acldefault(iacls->objtype, iacls->roleid); @@ -1128,8 +1128,8 @@ SetDefaultACL(InternalDefaultACL *iacls) noldmembers = aclmembers(old_acl, &oldmembers); /* - * Generate new ACL. Grantor of rights is always the same as the - * target role. + * Generate new ACL. Grantor of rights is always the same as the target + * role. */ new_acl = merge_acl_with_grant(old_acl, iacls->is_grant, @@ -1180,7 +1180,7 @@ SetDefaultACL(InternalDefaultACL *iacls) if (OidIsValid(iacls->nspid)) { ObjectAddress myself, - referenced; + referenced; myself.classId = DefaultAclRelationId; myself.objectId = HeapTupleGetOid(newtuple); @@ -2046,7 +2046,7 @@ ExecGrant_Fdw(InternalGrant *istmt) Oid *newmembers; tuple = SearchSysCache1(FOREIGNDATAWRAPPEROID, - ObjectIdGetDatum(fdwid)); + ObjectIdGetDatum(fdwid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwid); @@ -2499,7 +2499,7 @@ ExecGrant_Largeobject(InternalGrant *istmt) foreach(cell, istmt->objects) { Oid loid = lfirst_oid(cell); - Form_pg_largeobject_metadata form_lo_meta; + Form_pg_largeobject_metadata form_lo_meta; char loname[NAMEDATALEN]; Datum aclDatum; bool isNull; @@ -2517,8 +2517,8 @@ ExecGrant_Largeobject(InternalGrant *istmt) int nnewmembers; Oid *oldmembers; Oid *newmembers; - ScanKeyData entry[1]; - SysScanDesc scan; + ScanKeyData entry[1]; + SysScanDesc scan; HeapTuple tuple; /* There's no syscache for pg_largeobject_metadata */ @@ -3494,8 +3494,8 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid, { AclMode result; Relation pg_lo_meta; - ScanKeyData entry[1]; - SysScanDesc scan; + ScanKeyData entry[1]; + SysScanDesc scan; HeapTuple tuple; Datum aclDatum; bool isNull; @@ -3669,8 +3669,8 @@ pg_tablespace_aclmask(Oid spc_oid, Oid roleid, ownerId = ((Form_pg_tablespace) GETSTRUCT(tuple))->spcowner; aclDatum = SysCacheGetAttr(TABLESPACEOID, tuple, - Anum_pg_tablespace_spcacl, - &isNull); + Anum_pg_tablespace_spcacl, + &isNull); if (isNull) { @@ -4190,8 +4190,8 @@ bool pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid) { Relation pg_lo_meta; - ScanKeyData entry[1]; - SysScanDesc scan; + ScanKeyData entry[1]; + SysScanDesc scan; HeapTuple tuple; Oid ownerId; @@ -4484,8 +4484,8 @@ get_default_acl_internal(Oid roleId, Oid nsp_oid, char objtype) if (HeapTupleIsValid(tuple)) { - Datum aclDatum; - bool isNull; + Datum aclDatum; + bool isNull; aclDatum = SysCacheGetAttr(DEFACLROLENSPOBJ, tuple, Anum_pg_default_acl_defaclacl, diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index 943cc4920ec..a7eb09d8613 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.88 2010/02/07 20:48:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.89 2010/02/26 02:00:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -163,7 +163,7 @@ GetDatabasePath(Oid dbNode, Oid spcNode) { /* All other tablespaces are accessed via symlinks */ pathlen = 9 + 1 + OIDCHARS + 1 + strlen(TABLESPACE_VERSION_DIRECTORY) + - 1 + OIDCHARS + 1; + 1 + OIDCHARS + 1; path = (char *) palloc(pathlen); snprintf(path, pathlen, "pg_tblspc/%u/%s/%u", spcNode, TABLESPACE_VERSION_DIRECTORY, dbNode); diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index e4fa47d27f9..491c402a03b 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.95 2010/02/14 18:42:12 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.96 2010/02/26 02:00:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -148,7 +148,7 @@ static const Oid object_classes[MAX_OCLASS] = { AuthIdRelationId, /* OCLASS_ROLE */ DatabaseRelationId, /* OCLASS_DATABASE */ TableSpaceRelationId, /* OCLASS_TBLSPACE */ - ForeignDataWrapperRelationId, /* OCLASS_FDW */ + ForeignDataWrapperRelationId, /* OCLASS_FDW */ ForeignServerRelationId, /* OCLASS_FOREIGN_SERVER */ UserMappingRelationId, /* OCLASS_USER_MAPPING */ DefaultAclRelationId /* OCLASS_DEFACL */ @@ -1129,8 +1129,8 @@ doDeletion(const ObjectAddress *object) break; /* - * OCLASS_ROLE, OCLASS_DATABASE, OCLASS_TBLSPACE intentionally - * not handled here + * OCLASS_ROLE, OCLASS_DATABASE, OCLASS_TBLSPACE intentionally not + * handled here */ case OCLASS_FDW: @@ -2637,31 +2637,31 @@ getObjectDescription(const ObjectAddress *object) case DEFACLOBJ_RELATION: appendStringInfo(&buffer, _("default privileges on new relations belonging to role %s"), - GetUserNameFromId(defacl->defaclrole)); + GetUserNameFromId(defacl->defaclrole)); break; case DEFACLOBJ_SEQUENCE: appendStringInfo(&buffer, _("default privileges on new sequences belonging to role %s"), - GetUserNameFromId(defacl->defaclrole)); + GetUserNameFromId(defacl->defaclrole)); break; case DEFACLOBJ_FUNCTION: appendStringInfo(&buffer, _("default privileges on new functions belonging to role %s"), - GetUserNameFromId(defacl->defaclrole)); + GetUserNameFromId(defacl->defaclrole)); break; default: /* shouldn't get here */ appendStringInfo(&buffer, - _("default privileges belonging to role %s"), - GetUserNameFromId(defacl->defaclrole)); + _("default privileges belonging to role %s"), + GetUserNameFromId(defacl->defaclrole)); break; } if (OidIsValid(defacl->defaclnamespace)) { appendStringInfo(&buffer, - _(" in schema %s"), - get_namespace_name(defacl->defaclnamespace)); + _(" in schema %s"), + get_namespace_name(defacl->defaclnamespace)); } systable_endscan(rcscan); diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index b4d448da3e4..39aec680c08 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.371 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.372 2010/02/26 02:00:36 momjian Exp $ * * * INTERFACE ROUTINES @@ -71,8 +71,8 @@ /* Kluge for upgrade-in-place support */ -Oid binary_upgrade_next_heap_relfilenode = InvalidOid; -Oid binary_upgrade_next_toast_relfilenode = InvalidOid; +Oid binary_upgrade_next_heap_relfilenode = InvalidOid; +Oid binary_upgrade_next_toast_relfilenode = InvalidOid; static void AddNewRelationTuple(Relation pg_class_desc, Relation new_rel_desc, @@ -455,9 +455,9 @@ CheckAttributeType(const char *attname, Oid atttypid, { /* * Refuse any attempt to create a pseudo-type column, except for a - * special hack for pg_statistic: allow ANYARRAY when modifying - * system catalogs (this allows creating pg_statistic and cloning it - * during VACUUM FULL) + * special hack for pg_statistic: allow ANYARRAY when modifying system + * catalogs (this allows creating pg_statistic and cloning it during + * VACUUM FULL) */ if (atttypid != ANYARRAYOID || !allow_system_table_mods) ereport(ERROR, @@ -657,7 +657,7 @@ AddNewAttributeTuples(Oid new_rel_oid, * Tuple data is taken from new_rel_desc->rd_rel, except for the * variable-width fields which are not present in a cached reldesc. * relacl and reloptions are passed in Datum form (to avoid having - * to reference the data types in heap.h). Pass (Datum) 0 to set them + * to reference the data types in heap.h). Pass (Datum) 0 to set them * to NULL. * -------------------------------- */ @@ -825,7 +825,7 @@ AddNewRelationType(const char *typeName, Oid new_array_type) { return - TypeCreate(new_row_type, /* optional predetermined OID */ + TypeCreate(new_row_type, /* optional predetermined OID */ typeName, /* type name */ typeNamespace, /* type namespace */ new_rel_oid, /* relation oid */ @@ -1032,9 +1032,9 @@ heap_create_with_catalog(const char *relname, /* * Since defining a relation also defines a complex type, we add a new - * system type corresponding to the new relation. The OID of the type - * can be preselected by the caller, but if reltypeid is InvalidOid, - * we'll generate a new OID for it. + * system type corresponding to the new relation. The OID of the type can + * be preselected by the caller, but if reltypeid is InvalidOid, we'll + * generate a new OID for it. * * NOTE: we could get a unique-index failure here, in case someone else is * creating the same type name in parallel but hadn't committed yet when @@ -1116,14 +1116,14 @@ heap_create_with_catalog(const char *relname, /* * Make a dependency link to force the relation to be deleted if its - * namespace is. Also make a dependency link to its owner, as well - * as dependencies for any roles mentioned in the default ACL. + * namespace is. Also make a dependency link to its owner, as well as + * dependencies for any roles mentioned in the default ACL. * * For composite types, these dependencies are tracked for the pg_type * entry, so we needn't record them here. Likewise, TOAST tables don't * need a namespace dependency (they live in a pinned namespace) nor an - * owner dependency (they depend indirectly through the parent table), - * nor should they have any ACL entries. + * owner dependency (they depend indirectly through the parent table), nor + * should they have any ACL entries. * * Also, skip this in bootstrap mode, since we don't make dependencies * while bootstrapping. @@ -1774,7 +1774,7 @@ StoreRelCheck(Relation rel, char *ccname, Node *expr, ' ', ' ', ' ', - NULL, /* not an exclusion constraint */ + NULL, /* not an exclusion constraint */ expr, /* Tree form of check constraint */ ccbin, /* Binary form of check constraint */ ccsrc, /* Source form of check constraint */ diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index e90b92dcf6e..dea6889075f 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.336 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.337 2010/02/26 02:00:36 momjian Exp $ * * * INTERFACE ROUTINES @@ -70,7 +70,7 @@ /* Kluge for upgrade-in-place support */ -Oid binary_upgrade_next_index_relfilenode = InvalidOid; +Oid binary_upgrade_next_index_relfilenode = InvalidOid; /* state info for validate_index bulkdelete callback */ typedef struct @@ -272,7 +272,7 @@ ConstructTupleDescriptor(Relation heapRelation, /* * Set the attribute name as specified by caller. */ - if (colnames_item == NULL) /* shouldn't happen */ + if (colnames_item == NULL) /* shouldn't happen */ elog(ERROR, "too few entries in colnames list"); namestrcpy(&to->attname, (const char *) lfirst(colnames_item)); colnames_item = lnext(colnames_item); @@ -561,8 +561,8 @@ index_create(Oid heapRelationId, /* * The index will be in the same namespace as its parent table, and is - * shared across databases if and only if the parent is. Likewise, - * it will use the relfilenode map if and only if the parent does. + * shared across databases if and only if the parent is. Likewise, it + * will use the relfilenode map if and only if the parent does. */ namespaceId = RelationGetNamespace(heapRelation); shared_relation = heapRelation->rd_rel->relisshared; @@ -592,8 +592,8 @@ index_create(Oid heapRelationId, errmsg("concurrent index creation on system catalog tables is not supported"))); /* - * This case is currently not supported, but there's no way to ask for - * it in the grammar anyway, so it can't happen. + * This case is currently not supported, but there's no way to ask for it + * in the grammar anyway, so it can't happen. */ if (concurrent && is_exclusion) ereport(ERROR, @@ -775,7 +775,7 @@ index_create(Oid heapRelationId, indexInfo->ii_KeyAttrNumbers, indexInfo->ii_NumIndexAttrs, InvalidOid, /* no domain */ - indexRelationId, /* index OID */ + indexRelationId, /* index OID */ InvalidOid, /* no foreign key */ NULL, NULL, @@ -810,7 +810,7 @@ index_create(Oid heapRelationId, CreateTrigStmt *trigger; heapRel = makeRangeVar(get_namespace_name(namespaceId), - pstrdup(RelationGetRelationName(heapRelation)), + pstrdup(RelationGetRelationName(heapRelation)), -1); trigger = makeNode(CreateTrigStmt); @@ -1436,8 +1436,8 @@ index_build(Relation heapRelation, Assert(PointerIsValid(stats)); /* - * If it's for an exclusion constraint, make a second pass over the - * heap to verify that the constraint is satisfied. + * If it's for an exclusion constraint, make a second pass over the heap + * to verify that the constraint is satisfied. */ if (indexInfo->ii_ExclusionOps != NULL) IndexCheckExclusion(heapRelation, indexRelation, indexInfo); @@ -1710,7 +1710,7 @@ IndexBuildHeapScan(Relation heapRelation, /* * Since caller should hold ShareLock or better, normally * the only way to see this is if it was inserted earlier - * in our own transaction. However, it can happen in + * in our own transaction. However, it can happen in * system catalogs, since we tend to release write lock * before commit there. Give a warning if neither case * applies. @@ -1761,9 +1761,9 @@ IndexBuildHeapScan(Relation heapRelation, /* * If we are performing uniqueness checks, assuming - * the tuple is dead could lead to missing a uniqueness - * violation. In that case we wait for the deleting - * transaction to finish and check again. + * the tuple is dead could lead to missing a + * uniqueness violation. In that case we wait for the + * deleting transaction to finish and check again. */ if (checking_uniqueness) { @@ -2472,9 +2472,9 @@ reindex_index(Oid indexId, bool skip_constraint_checks) /* * If the index is marked invalid or not ready (ie, it's from a failed - * CREATE INDEX CONCURRENTLY), and we didn't skip a uniqueness check, - * we can now mark it valid. This allows REINDEX to be used to clean up - * in such cases. + * CREATE INDEX CONCURRENTLY), and we didn't skip a uniqueness check, we + * can now mark it valid. This allows REINDEX to be used to clean up in + * such cases. * * We can also reset indcheckxmin, because we have now done a * non-concurrent index build, *except* in the case where index_build @@ -2568,7 +2568,7 @@ reindex_relation(Oid relid, bool toast_too, bool heap_rebuilt) * It is okay to not insert entries into the indexes we have not processed * yet because all of this is transaction-safe. If we fail partway * through, the updated rows are dead and it doesn't matter whether they - * have index entries. Also, a new pg_class index will be created with a + * have index entries. Also, a new pg_class index will be created with a * correct entry for its own pg_class row because we do * RelationSetNewRelfilenode() before we do index_build(). * diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index ac68b963931..e2e19985506 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.124 2010/02/20 21:24:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.125 2010/02/26 02:00:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -190,7 +190,7 @@ static void RemoveTempRelations(Oid tempNamespaceId); static void RemoveTempRelationsCallback(int code, Datum arg); static void NamespaceCallback(Datum arg, int cacheid, ItemPointer tuplePtr); static bool MatchNamedCall(HeapTuple proctup, int nargs, List *argnames, - int **argnumbers); + int **argnumbers); /* These don't really need to appear in any header file */ Datum pg_table_is_visible(PG_FUNCTION_ARGS); @@ -333,7 +333,7 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation) } /* use exact schema given */ namespaceId = GetSysCacheOid1(NAMESPACENAME, - CStringGetDatum(newRelation->schemaname)); + CStringGetDatum(newRelation->schemaname)); if (!OidIsValid(namespaceId)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_SCHEMA), @@ -689,10 +689,9 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames, /* * Call uses named or mixed notation * - * Named or mixed notation can match a variadic function only - * if expand_variadic is off; otherwise there is no way to match - * the presumed-nameless parameters expanded from the variadic - * array. + * Named or mixed notation can match a variadic function only if + * expand_variadic is off; otherwise there is no way to match the + * presumed-nameless parameters expanded from the variadic array. */ if (OidIsValid(procform->provariadic) && expand_variadic) continue; @@ -702,7 +701,7 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames, /* * Check argument count. */ - Assert(nargs >= 0); /* -1 not supported with argnames */ + Assert(nargs >= 0); /* -1 not supported with argnames */ if (pronargs > nargs && expand_defaults) { @@ -732,7 +731,7 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames, * Call uses positional notation * * Check if function is variadic, and get variadic element type if - * so. If expand_variadic is false, we should just ignore + * so. If expand_variadic is false, we should just ignore * variadic-ness. */ if (pronargs <= nargs && expand_variadic) @@ -1020,9 +1019,9 @@ MatchNamedCall(HeapTuple proctup, int nargs, List *argnames, /* now examine the named args */ foreach(lc, argnames) { - char *argname = (char *) lfirst(lc); - bool found; - int i; + char *argname = (char *) lfirst(lc); + bool found; + int i; pp = 0; found = false; @@ -1058,7 +1057,7 @@ MatchNamedCall(HeapTuple proctup, int nargs, List *argnames, /* Check for default arguments */ if (nargs < pronargs) { - int first_arg_with_default = pronargs - procform->pronargdefaults; + int first_arg_with_default = pronargs - procform->pronargdefaults; for (pp = numposargs; pp < pronargs; pp++) { @@ -3021,10 +3020,10 @@ InitTempTableNamespace(void) * Do not allow a Hot Standby slave session to make temp tables. Aside * from problems with modifying the system catalogs, there is a naming * conflict: pg_temp_N belongs to the session with BackendId N on the - * master, not to a slave session with the same BackendId. We should - * not be able to get here anyway due to XactReadOnly checks, but let's - * just make real sure. Note that this also backstops various operations - * that allow XactReadOnly transactions to modify temp tables; they'd need + * master, not to a slave session with the same BackendId. We should not + * be able to get here anyway due to XactReadOnly checks, but let's just + * make real sure. Note that this also backstops various operations that + * allow XactReadOnly transactions to modify temp tables; they'd need * RecoveryInProgress checks if not for this. */ if (RecoveryInProgress()) diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index ddb16a27459..9672ecf0aa1 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.105 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.106 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -360,8 +360,8 @@ lookup_agg_function(List *fnName, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("function %s requires run-time type coercion", - func_signature_string(fnName, nargs, - NIL, true_oid_array)))); + func_signature_string(fnName, nargs, + NIL, true_oid_array)))); } /* Check aggregate creator has permission to call the function */ diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c index 6d453538b32..84dab8eb218 100644 --- a/src/backend/catalog/pg_constraint.c +++ b/src/backend/catalog/pg_constraint.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.52 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.53 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -298,9 +298,9 @@ CreateConstraintEntry(const char *constraintName, { /* * Register normal dependency on the unique index that supports a - * foreign-key constraint. (Note: for indexes associated with - * unique or primary-key constraints, the dependency runs the other - * way, and is not made here.) + * foreign-key constraint. (Note: for indexes associated with unique + * or primary-key constraints, the dependency runs the other way, and + * is not made here.) */ ObjectAddress relobject; @@ -342,11 +342,11 @@ CreateConstraintEntry(const char *constraintName, } /* - * We don't bother to register dependencies on the exclusion operators - * of an exclusion constraint. We assume they are members of the opclass - * supporting the index, so there's an indirect dependency via that. - * (This would be pretty dicey for cross-type operators, but exclusion - * operators can never be cross-type.) + * We don't bother to register dependencies on the exclusion operators of + * an exclusion constraint. We assume they are members of the opclass + * supporting the index, so there's an indirect dependency via that. (This + * would be pretty dicey for cross-type operators, but exclusion operators + * can never be cross-type.) */ if (conExpr != NULL) @@ -764,8 +764,8 @@ GetConstraintByName(Oid relid, const char *conname) if (OidIsValid(conOid)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("table \"%s\" has multiple constraints named \"%s\"", - get_rel_name(relid), conname))); + errmsg("table \"%s\" has multiple constraints named \"%s\"", + get_rel_name(relid), conname))); conOid = HeapTupleGetOid(tuple); } } diff --git a/src/backend/catalog/pg_db_role_setting.c b/src/backend/catalog/pg_db_role_setting.c index 3063186e612..6687cbf2132 100644 --- a/src/backend/catalog/pg_db_role_setting.c +++ b/src/backend/catalog/pg_db_role_setting.c @@ -1,12 +1,12 @@ /* * pg_db_role_setting.c * Routines to support manipulation of the pg_db_role_setting relation - * + * * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_db_role_setting.c,v 1.2 2010/01/02 16:57:36 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_db_role_setting.c,v 1.3 2010/02/26 02:00:37 momjian Exp $ */ #include "postgres.h" @@ -51,11 +51,11 @@ AlterSetting(Oid databaseid, Oid roleid, VariableSetStmt *setstmt) * * - in RESET ALL, simply delete the pg_db_role_setting tuple (if any) * - * - in other commands, if there's a tuple in pg_db_role_setting, update it; - * if it ends up empty, delete it + * - in other commands, if there's a tuple in pg_db_role_setting, update + * it; if it ends up empty, delete it * * - otherwise, insert a new pg_db_role_setting tuple, but only if the - * command is not RESET + * command is not RESET */ if (setstmt->kind == VAR_RESET_ALL) { @@ -111,7 +111,7 @@ AlterSetting(Oid databaseid, Oid roleid, VariableSetStmt *setstmt) ArrayType *a; memset(nulls, false, sizeof(nulls)); - + a = GUCArrayAdd(NULL, setstmt->name, valuestr); values[Anum_pg_db_role_setting_setdatabase - 1] = @@ -134,17 +134,17 @@ AlterSetting(Oid databaseid, Oid roleid, VariableSetStmt *setstmt) /* * Drop some settings from the catalog. These can be for a particular - * database, or for a particular role. (It is of course possible to do both + * database, or for a particular role. (It is of course possible to do both * too, but it doesn't make sense for current uses.) */ void DropSetting(Oid databaseid, Oid roleid) { - Relation relsetting; - HeapScanDesc scan; - ScanKeyData keys[2]; - HeapTuple tup; - int numkeys = 0; + Relation relsetting; + HeapScanDesc scan; + ScanKeyData keys[2]; + HeapTuple tup; + int numkeys = 0; relsetting = heap_open(DbRoleSettingRelationId, RowExclusiveLock); @@ -190,9 +190,9 @@ DropSetting(Oid databaseid, Oid roleid) void ApplySetting(Oid databaseid, Oid roleid, Relation relsetting, GucSource source) { - SysScanDesc scan; - ScanKeyData keys[2]; - HeapTuple tup; + SysScanDesc scan; + ScanKeyData keys[2]; + HeapTuple tup; ScanKeyInit(&keys[0], Anum_pg_db_role_setting_setdatabase, @@ -209,8 +209,8 @@ ApplySetting(Oid databaseid, Oid roleid, Relation relsetting, GucSource source) SnapshotNow, 2, keys); while (HeapTupleIsValid(tup = systable_getnext(scan))) { - bool isnull; - Datum datum; + bool isnull; + Datum datum; datum = heap_getattr(tup, Anum_pg_db_role_setting_setconfig, RelationGetDescr(relsetting), &isnull); diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c index 446b865cf89..dba215f6122 100644 --- a/src/backend/catalog/pg_enum.c +++ b/src/backend/catalog/pg_enum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_enum.c,v 1.13 2010/01/02 16:57:36 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_enum.c,v 1.14 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,32 +59,32 @@ EnumValuesCreate(Oid enumTypeOid, List *vals, tupDesc = pg_enum->rd_att; /* - * Allocate oids + * Allocate oids */ oids = (Oid *) palloc(num_elems * sizeof(Oid)); if (OidIsValid(binary_upgrade_next_pg_enum_oid)) { - if (num_elems != 1) - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("EnumValuesCreate() can only set a single OID"))); - oids[0] = binary_upgrade_next_pg_enum_oid; - binary_upgrade_next_pg_enum_oid = InvalidOid; - } + if (num_elems != 1) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("EnumValuesCreate() can only set a single OID"))); + oids[0] = binary_upgrade_next_pg_enum_oid; + binary_upgrade_next_pg_enum_oid = InvalidOid; + } else { /* - * While this method does not absolutely guarantee that we generate - * no duplicate oids (since we haven't entered each oid into the - * table before allocating the next), trouble could only occur if - * the oid counter wraps all the way around before we finish. Which - * seems unlikely. + * While this method does not absolutely guarantee that we generate no + * duplicate oids (since we haven't entered each oid into the table + * before allocating the next), trouble could only occur if the oid + * counter wraps all the way around before we finish. Which seems + * unlikely. */ for (elemno = 0; elemno < num_elems; elemno++) { /* - * The pg_enum.oid is stored in user tables. This oid must be - * preserved by binary upgrades. + * The pg_enum.oid is stored in user tables. This oid must be + * preserved by binary upgrades. */ oids[elemno] = GetNewOid(pg_enum); } diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c index 14bef8bf3ba..d852e3554be 100644 --- a/src/backend/catalog/pg_inherits.c +++ b/src/backend/catalog/pg_inherits.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_inherits.c,v 1.7 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_inherits.c,v 1.8 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -158,7 +158,8 @@ find_inheritance_children(Oid parentrelId, LOCKMODE lockmode) List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents) { - List *rels_list, *rel_numparents; + List *rels_list, + *rel_numparents; ListCell *l; /* @@ -189,8 +190,8 @@ find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents) */ foreach(lc, currentchildren) { - Oid child_oid = lfirst_oid(lc); - bool found = false; + Oid child_oid = lfirst_oid(lc); + bool found = false; ListCell *lo; ListCell *li; diff --git a/src/backend/catalog/pg_largeobject.c b/src/backend/catalog/pg_largeobject.c index 500a6c9bae6..0be0be93cd2 100644 --- a/src/backend/catalog/pg_largeobject.c +++ b/src/backend/catalog/pg_largeobject.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_largeobject.c,v 1.38 2010/02/17 04:19:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_largeobject.c,v 1.39 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,7 +79,7 @@ LargeObjectCreate(Oid loid) } /* - * Drop a large object having the given LO identifier. Both the data pages + * Drop a large object having the given LO identifier. Both the data pages * and metadata must be dropped. */ void @@ -103,7 +103,7 @@ LargeObjectDrop(Oid loid) ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, - ObjectIdGetDatum(loid)); + ObjectIdGetDatum(loid)); scan = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, @@ -150,10 +150,10 @@ LargeObjectDrop(Oid loid) void LargeObjectAlterOwner(Oid loid, Oid newOwnerId) { - Form_pg_largeobject_metadata form_lo_meta; + Form_pg_largeobject_metadata form_lo_meta; Relation pg_lo_meta; - ScanKeyData skey[1]; - SysScanDesc scan; + ScanKeyData skey[1]; + SysScanDesc scan; HeapTuple oldtup; HeapTuple newtup; @@ -189,9 +189,8 @@ LargeObjectAlterOwner(Oid loid, Oid newOwnerId) if (!superuser()) { /* - * lo_compat_privileges is not checked here, because ALTER - * LARGE OBJECT ... OWNER did not exist at all prior to - * PostgreSQL 9.0. + * lo_compat_privileges is not checked here, because ALTER LARGE + * OBJECT ... OWNER did not exist at all prior to PostgreSQL 9.0. * * We must be the owner of the existing object. */ @@ -213,8 +212,8 @@ LargeObjectAlterOwner(Oid loid, Oid newOwnerId) replaces[Anum_pg_largeobject_metadata_lomowner - 1] = true; /* - * Determine the modified ACL for the new owner. - * This is only necessary when the ACL is non-null. + * Determine the modified ACL for the new owner. This is only + * necessary when the ACL is non-null. */ aclDatum = heap_getattr(oldtup, Anum_pg_largeobject_metadata_lomacl, @@ -261,8 +260,8 @@ bool LargeObjectExists(Oid loid) { Relation pg_lo_meta; - ScanKeyData skey[1]; - SysScanDesc sd; + ScanKeyData skey[1]; + SysScanDesc sd; HeapTuple tuple; bool retval = false; diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index fc87a80c4d1..2b216098939 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.171 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.172 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -396,8 +396,8 @@ ProcedureCreate(const char *procedureName, /* * If there were any named input parameters, check to make sure the - * names have not been changed, as this could break existing calls. - * We allow adding names to formerly unnamed parameters, though. + * names have not been changed, as this could break existing calls. We + * allow adding names to formerly unnamed parameters, though. */ proargnames = SysCacheGetAttr(PROCNAMEARGSNSP, oldtup, Anum_pg_proc_proargnames, @@ -431,11 +431,11 @@ ProcedureCreate(const char *procedureName, strcmp(old_arg_names[j], new_arg_names[j]) != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("cannot change name of input parameter \"%s\"", - old_arg_names[j]), + errmsg("cannot change name of input parameter \"%s\"", + old_arg_names[j]), errhint("Use DROP FUNCTION first."))); } - } + } /* * If there are existing defaults, check compatibility: redefinition @@ -845,7 +845,7 @@ sql_function_parse_error_callback(void *arg) /* * Adjust a syntax error occurring inside the function body of a CREATE - * FUNCTION or DO command. This can be used by any function validator or + * FUNCTION or DO command. This can be used by any function validator or * anonymous-block handler, not only for SQL-language functions. * It is assumed that the syntax error position is initially relative to the * function body string (as passed in). If possible, we adjust the position diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index 999776402da..df65e1086ee 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.39 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.40 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1015,7 +1015,7 @@ shdepLockAndCheckObject(Oid classId, Oid objectId) pfree(database); break; } - + default: elog(ERROR, "unrecognized shared classId: %u", classId); @@ -1351,9 +1351,10 @@ shdepReassignOwned(List *roleids, Oid newrole) break; case DefaultAclRelationId: + /* - * Ignore default ACLs; they should be handled by - * DROP OWNED, not REASSIGN OWNED. + * Ignore default ACLs; they should be handled by DROP + * OWNED, not REASSIGN OWNED. */ break; diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index e8ff841a725..d4fdea91aa0 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.132 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.133 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ #include "utils/rel.h" #include "utils/syscache.h" -Oid binary_upgrade_next_pg_type_oid = InvalidOid; +Oid binary_upgrade_next_pg_type_oid = InvalidOid; /* ---------------------------------------------------------------- * TypeShellMake @@ -424,7 +424,7 @@ TypeCreate(Oid newTypeOid, binary_upgrade_next_pg_type_oid = InvalidOid; } /* else allow system to assign oid */ - + typeObjectId = simple_heap_insert(pg_type_desc, tup); } diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c index 363d21ac613..86e7daa1a03 100644 --- a/src/backend/catalog/toasting.c +++ b/src/backend/catalog/toasting.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.31 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.32 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,9 +32,9 @@ #include "utils/syscache.h" /* Kluges for upgrade-in-place support */ -extern Oid binary_upgrade_next_toast_relfilenode; +extern Oid binary_upgrade_next_toast_relfilenode; -Oid binary_upgrade_next_pg_type_toast_oid = InvalidOid; +Oid binary_upgrade_next_pg_type_toast_oid = InvalidOid; static bool create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptions); diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 233ac1bc3d2..26a28d55a76 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.34 2010/02/01 19:28:56 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.35 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -126,7 +126,7 @@ ExecRenameStmt(RenameStmt *stmt) stmt->subname, /* old att name */ stmt->newname, /* new att name */ interpretInhOption(stmt->relation->inhOpt), /* recursive? */ - 0); /* expected inhcount */ + 0); /* expected inhcount */ break; case OBJECT_TRIGGER: renametrig(relid, diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 32fb44051c6..22734b76195 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.151 2010/02/14 18:42:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.152 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -99,11 +99,11 @@ static double random_fract(void); static double init_selection_state(int n); static double get_next_S(double t, int n, double *stateptr); static int compare_rows(const void *a, const void *b); -static int acquire_inherited_sample_rows(Relation onerel, +static int acquire_inherited_sample_rows(Relation onerel, HeapTuple *rows, int targrows, double *totalrows, double *totaldeadrows); static void update_attstats(Oid relid, bool inh, - int natts, VacAttrStats **vacattrstats); + int natts, VacAttrStats **vacattrstats); static Datum std_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull); static Datum ind_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull); @@ -289,8 +289,8 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, RelationGetRelationName(onerel)))); /* - * Set up a working context so that we can easily free whatever junk - * gets created. + * Set up a working context so that we can easily free whatever junk gets + * created. */ anl_context = AllocSetContextCreate(CurrentMemoryContext, "Analyze", @@ -364,8 +364,8 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, * Open all indexes of the relation, and see if there are any analyzable * columns in the indexes. We do not analyze index columns if there was * an explicit column list in the ANALYZE command, however. If we are - * doing a recursive scan, we don't want to touch the parent's indexes - * at all. + * doing a recursive scan, we don't want to touch the parent's indexes at + * all. */ if (!inh) vac_open_indexes(onerel, AccessShareLock, &nindexes, &Irel); @@ -495,7 +495,7 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, { VacAttrStats *stats = vacattrstats[i]; AttributeOpts *aopt = - get_attribute_options(onerel->rd_id, stats->attr->attnum); + get_attribute_options(onerel->rd_id, stats->attr->attnum); stats->rows = rows; stats->tupDesc = onerel->rd_att; @@ -510,8 +510,9 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, */ if (aopt != NULL) { - float8 n_distinct = - inh ? aopt->n_distinct_inherited : aopt->n_distinct; + float8 n_distinct = + inh ? aopt->n_distinct_inherited : aopt->n_distinct; + if (n_distinct != 0.0) stats->stadistinct = n_distinct; } @@ -546,8 +547,8 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, } /* - * Update pages/tuples stats in pg_class, but not if we're inside a - * VACUUM that got a more precise number. + * Update pages/tuples stats in pg_class, but not if we're inside a VACUUM + * that got a more precise number. */ if (update_reltuples) vac_update_relstats(onerel, @@ -574,10 +575,9 @@ do_analyze_rel(Relation onerel, VacuumStmt *vacstmt, } /* - * Report ANALYZE to the stats collector, too; likewise, tell it to - * adopt these numbers only if we're not inside a VACUUM that got a - * better number. However, a call with inh = true shouldn't reset - * the stats. + * Report ANALYZE to the stats collector, too; likewise, tell it to adopt + * these numbers only if we're not inside a VACUUM that got a better + * number. However, a call with inh = true shouldn't reset the stats. */ if (!inh) pgstat_report_analyze(onerel, update_reltuples, @@ -762,8 +762,8 @@ compute_index_stats(Relation onerel, double totalrows, { VacAttrStats *stats = thisdata->vacattrstats[i]; AttributeOpts *aopt = - get_attribute_options(stats->attr->attrelid, - stats->attr->attnum); + get_attribute_options(stats->attr->attrelid, + stats->attr->attnum); stats->exprvals = exprvals + i; stats->exprnulls = exprnulls + i; @@ -1436,10 +1436,10 @@ acquire_inherited_sample_rows(Relation onerel, HeapTuple *rows, int targrows, } /* - * Now sample rows from each relation, proportionally to its fraction - * of the total block count. (This might be less than desirable if the - * child rels have radically different free-space percentages, but it's - * not clear that it's worth working harder.) + * Now sample rows from each relation, proportionally to its fraction of + * the total block count. (This might be less than desirable if the child + * rels have radically different free-space percentages, but it's not + * clear that it's worth working harder.) */ numrows = 0; *totalrows = 0; @@ -1451,7 +1451,7 @@ acquire_inherited_sample_rows(Relation onerel, HeapTuple *rows, int targrows, if (childblocks > 0) { - int childtargrows; + int childtargrows; childtargrows = (int) rint(targrows * childblocks / totalblocks); /* Make sure we don't overrun due to roundoff error */ @@ -1478,10 +1478,10 @@ acquire_inherited_sample_rows(Relation onerel, HeapTuple *rows, int targrows, map = convert_tuples_by_name(RelationGetDescr(childrel), RelationGetDescr(onerel), - gettext_noop("could not convert row type")); + gettext_noop("could not convert row type")); if (map != NULL) { - int j; + int j; for (j = 0; j < childrows; j++) { diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index c7b60de32a9..11c84e7f3c8 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.154 2010/02/20 21:24:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.155 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -149,7 +149,7 @@ * * This struct declaration has the maximal length, but in a real queue entry * the data area is only big enough for the actual channel and payload strings - * (each null-terminated). AsyncQueueEntryEmptySize is the minimum possible + * (each null-terminated). AsyncQueueEntryEmptySize is the minimum possible * entry size, if both channel and payload strings are empty (but note it * doesn't include alignment padding). * @@ -158,11 +158,11 @@ */ typedef struct AsyncQueueEntry { - int length; /* total allocated length of entry */ - Oid dboid; /* sender's database OID */ - TransactionId xid; /* sender's XID */ - int32 srcPid; /* sender's PID */ - char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH]; + int length; /* total allocated length of entry */ + Oid dboid; /* sender's database OID */ + TransactionId xid; /* sender's XID */ + int32 srcPid; /* sender's PID */ + char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH]; } AsyncQueueEntry; /* Currently, no field of AsyncQueueEntry requires more than int alignment */ @@ -175,8 +175,8 @@ typedef struct AsyncQueueEntry */ typedef struct QueuePosition { - int page; /* SLRU page number */ - int offset; /* byte offset within page */ + int page; /* SLRU page number */ + int offset; /* byte offset within page */ } QueuePosition; #define QUEUE_POS_PAGE(x) ((x).page) @@ -202,11 +202,11 @@ typedef struct QueuePosition */ typedef struct QueueBackendStatus { - int32 pid; /* either a PID or InvalidPid */ - QueuePosition pos; /* backend has read queue up to here */ + int32 pid; /* either a PID or InvalidPid */ + QueuePosition pos; /* backend has read queue up to here */ } QueueBackendStatus; -#define InvalidPid (-1) +#define InvalidPid (-1) /* * Shared memory state for LISTEN/NOTIFY (excluding its SLRU stuff) @@ -230,15 +230,15 @@ typedef struct QueueBackendStatus */ typedef struct AsyncQueueControl { - QueuePosition head; /* head points to the next free location */ - QueuePosition tail; /* the global tail is equivalent to the - tail of the "slowest" backend */ - TimestampTz lastQueueFillWarn; /* time of last queue-full msg */ - QueueBackendStatus backend[1]; /* actually of length MaxBackends+1 */ + QueuePosition head; /* head points to the next free location */ + QueuePosition tail; /* the global tail is equivalent to the tail + * of the "slowest" backend */ + TimestampTz lastQueueFillWarn; /* time of last queue-full msg */ + QueueBackendStatus backend[1]; /* actually of length MaxBackends+1 */ /* DO NOT ADD FURTHER STRUCT MEMBERS HERE */ } AsyncQueueControl; -static AsyncQueueControl *asyncQueueControl; +static AsyncQueueControl *asyncQueueControl; #define QUEUE_HEAD (asyncQueueControl->head) #define QUEUE_TAIL (asyncQueueControl->tail) @@ -248,11 +248,11 @@ static AsyncQueueControl *asyncQueueControl; /* * The SLRU buffer area through which we access the notification queue */ -static SlruCtlData AsyncCtlData; +static SlruCtlData AsyncCtlData; #define AsyncCtl (&AsyncCtlData) #define QUEUE_PAGESIZE BLCKSZ -#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */ +#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */ /* * slru.c currently assumes that all filenames are four characters of hex @@ -265,7 +265,7 @@ static SlruCtlData AsyncCtlData; * * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2 * pages, because more than that would confuse slru.c into thinking there - * was a wraparound condition. With the default BLCKSZ this means there + * was a wraparound condition. With the default BLCKSZ this means there * can be up to 8GB of queued-and-not-read data. * * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of @@ -309,7 +309,7 @@ static List *upperPendingActions = NIL; /* list of upper-xact lists */ /* * State for outbound notifies consists of a list of all channels+payloads - * NOTIFYed in the current transaction. We do not actually perform a NOTIFY + * NOTIFYed in the current transaction. We do not actually perform a NOTIFY * until and unless the transaction commits. pendingNotifies is NIL if no * NOTIFYs have been done in the current transaction. * @@ -325,11 +325,11 @@ static List *upperPendingActions = NIL; /* list of upper-xact lists */ */ typedef struct Notification { - char *channel; /* channel name */ - char *payload; /* payload string (can be empty) */ + char *channel; /* channel name */ + char *payload; /* payload string (can be empty) */ } Notification; -static List *pendingNotifies = NIL; /* list of Notifications */ +static List *pendingNotifies = NIL; /* list of Notifications */ static List *upperPendingNotifies = NIL; /* list of upper-xact lists */ @@ -348,8 +348,10 @@ static volatile sig_atomic_t notifyInterruptOccurred = 0; /* True if we've registered an on_shmem_exit cleanup */ static bool unlistenExitRegistered = false; + /* has this backend sent notifications in the current transaction? */ static bool backendHasSentNotifications = false; + /* has this backend executed its first LISTEN in the current transaction? */ static bool backendHasExecutedInitialListen = false; @@ -380,8 +382,8 @@ static bool asyncQueueProcessPageEntries(QueuePosition *current, static void asyncQueueAdvanceTail(void); static void ProcessIncomingNotify(void); static void NotifyMyFrontEnd(const char *channel, - const char *payload, - int32 srcPid); + const char *payload, + int32 srcPid); static bool AsyncExistsPendingNotify(const char *channel, const char *payload); static void ClearPendingActionsAndNotifies(void); @@ -408,17 +410,17 @@ asyncQueuePagePrecedesLogically(int p, int q) int diff; /* - * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should - * be in the range 0..QUEUE_MAX_PAGE. + * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be + * in the range 0..QUEUE_MAX_PAGE. */ Assert(p >= 0 && p <= QUEUE_MAX_PAGE); Assert(q >= 0 && q <= QUEUE_MAX_PAGE); diff = p - q; - if (diff >= ((QUEUE_MAX_PAGE+1)/2)) - diff -= QUEUE_MAX_PAGE+1; - else if (diff < -((QUEUE_MAX_PAGE+1)/2)) - diff += QUEUE_MAX_PAGE+1; + if (diff >= ((QUEUE_MAX_PAGE + 1) / 2)) + diff -= QUEUE_MAX_PAGE + 1; + else if (diff < -((QUEUE_MAX_PAGE + 1) / 2)) + diff += QUEUE_MAX_PAGE + 1; return diff < 0; } @@ -428,7 +430,7 @@ asyncQueuePagePrecedesLogically(int p, int q) Size AsyncShmemSize(void) { - Size size; + Size size; /* This had better match AsyncShmemInit */ size = mul_size(MaxBackends, sizeof(QueueBackendStatus)); @@ -445,9 +447,9 @@ AsyncShmemSize(void) void AsyncShmemInit(void) { - bool found; - int slotno; - Size size; + bool found; + int slotno; + Size size; /* * Create or attach to the AsyncQueueControl structure. @@ -468,7 +470,7 @@ AsyncShmemInit(void) if (!found) { /* First time through, so initialize it */ - int i; + int i; SET_QUEUE_POS(QUEUE_HEAD, 0, 0); SET_QUEUE_POS(QUEUE_TAIL, 0, 0); @@ -598,8 +600,8 @@ Async_Notify(const char *channel, const char *payload) n->payload = ""; /* - * We want to preserve the order so we need to append every - * notification. See comments at AsyncExistsPendingNotify(). + * We want to preserve the order so we need to append every notification. + * See comments at AsyncExistsPendingNotify(). */ pendingNotifies = lappend(pendingNotifies, n); @@ -698,13 +700,13 @@ Async_UnlistenAll(void) Datum pg_listening_channels(PG_FUNCTION_ARGS) { - FuncCallContext *funcctx; - ListCell **lcp; + FuncCallContext *funcctx; + ListCell **lcp; /* stuff done only on the first call of the function */ if (SRF_IS_FIRSTCALL()) { - MemoryContext oldcontext; + MemoryContext oldcontext; /* create a function context for cross-call persistence */ funcctx = SRF_FIRSTCALL_INIT(); @@ -726,7 +728,7 @@ pg_listening_channels(PG_FUNCTION_ARGS) while (*lcp != NULL) { - char *channel = (char *) lfirst(*lcp); + char *channel = (char *) lfirst(*lcp); *lcp = lnext(*lcp); SRF_RETURN_NEXT(funcctx, CStringGetTextDatum(channel)); @@ -818,9 +820,9 @@ PreCommit_Notify(void) /* * Make sure that we have an XID assigned to the current transaction. - * GetCurrentTransactionId is cheap if we already have an XID, but - * not so cheap if we don't, and we'd prefer not to do that work - * while holding AsyncQueueLock. + * GetCurrentTransactionId is cheap if we already have an XID, but not + * so cheap if we don't, and we'd prefer not to do that work while + * holding AsyncQueueLock. */ (void) GetCurrentTransactionId(); @@ -850,7 +852,7 @@ PreCommit_Notify(void) while (nextNotify != NULL) { /* - * Add the pending notifications to the queue. We acquire and + * Add the pending notifications to the queue. We acquire and * release AsyncQueueLock once per page, which might be overkill * but it does allow readers to get in while we're doing this. * @@ -866,7 +868,7 @@ PreCommit_Notify(void) if (asyncQueueIsFull()) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("too many notifications in the NOTIFY queue"))); + errmsg("too many notifications in the NOTIFY queue"))); nextNotify = asyncQueueAddEntries(nextNotify); LWLockRelease(AsyncQueueLock); } @@ -915,8 +917,8 @@ AtCommit_Notify(void) } /* - * If we did an initial LISTEN, listenChannels now has the entry, so - * we no longer need or want the flag to be set. + * If we did an initial LISTEN, listenChannels now has the entry, so we no + * longer need or want the flag to be set. */ backendHasExecutedInitialListen = false; @@ -943,15 +945,15 @@ Exec_ListenPreCommit(void) elog(DEBUG1, "Exec_ListenPreCommit(%d)", MyProcPid); /* - * We need this variable to detect an aborted initial LISTEN. - * In that case we would set up our pointer but not listen on any channel. - * This flag gets cleared in AtCommit_Notify or AtAbort_Notify(). + * We need this variable to detect an aborted initial LISTEN. In that case + * we would set up our pointer but not listen on any channel. This flag + * gets cleared in AtCommit_Notify or AtAbort_Notify(). */ backendHasExecutedInitialListen = true; /* - * Before registering, make sure we will unlisten before dying. - * (Note: this action does not get undone if we abort later.) + * Before registering, make sure we will unlisten before dying. (Note: + * this action does not get undone if we abort later.) */ if (!unlistenExitRegistered) { @@ -977,8 +979,8 @@ Exec_ListenPreCommit(void) * already-committed notifications. Still, we could get notifications that * have already committed before we started to LISTEN. * - * Note that we are not yet listening on anything, so we won't deliver - * any notification to the frontend. + * Note that we are not yet listening on anything, so we won't deliver any + * notification to the frontend. * * This will also advance the global tail pointer if possible. */ @@ -1020,8 +1022,8 @@ Exec_ListenCommit(const char *channel) static void Exec_UnlistenCommit(const char *channel) { - ListCell *q; - ListCell *prev; + ListCell *q; + ListCell *prev; if (Trace_notify) elog(DEBUG1, "Exec_UnlistenCommit(%s,%d)", channel, MyProcPid); @@ -1029,7 +1031,7 @@ Exec_UnlistenCommit(const char *channel) prev = NULL; foreach(q, listenChannels) { - char *lchan = (char *) lfirst(q); + char *lchan = (char *) lfirst(q); if (strcmp(lchan, channel) == 0) { @@ -1078,12 +1080,12 @@ Exec_UnlistenAllCommit(void) * The reason that this is not done in AtCommit_Notify is that there is * a nonzero chance of errors here (for example, encoding conversion errors * while trying to format messages to our frontend). An error during - * AtCommit_Notify would be a PANIC condition. The timing is also arranged + * AtCommit_Notify would be a PANIC condition. The timing is also arranged * to ensure that a transaction's self-notifies are delivered to the frontend * before it gets the terminating ReadyForQuery message. * * Note that we send signals and process the queue even if the transaction - * eventually aborted. This is because we need to clean out whatever got + * eventually aborted. This is because we need to clean out whatever got * added to the queue. * * NOTE: we are outside of any transaction here. @@ -1098,9 +1100,9 @@ ProcessCompletedNotifies(void) return; /* - * We reset the flag immediately; otherwise, if any sort of error - * occurs below, we'd be locked up in an infinite loop, because - * control will come right back here after error cleanup. + * We reset the flag immediately; otherwise, if any sort of error occurs + * below, we'd be locked up in an infinite loop, because control will come + * right back here after error cleanup. */ backendHasSentNotifications = false; @@ -1108,8 +1110,8 @@ ProcessCompletedNotifies(void) elog(DEBUG1, "ProcessCompletedNotifies"); /* - * We must run asyncQueueReadAllNotifications inside a transaction, - * else bad things happen if it gets an error. + * We must run asyncQueueReadAllNotifications inside a transaction, else + * bad things happen if it gets an error. */ StartTransactionCommand(); @@ -1125,11 +1127,11 @@ ProcessCompletedNotifies(void) { /* * If we found no other listening backends, and we aren't listening - * ourselves, then we must execute asyncQueueAdvanceTail to flush - * the queue, because ain't nobody else gonna do it. This prevents - * queue overflow when we're sending useless notifies to nobody. - * (A new listener could have joined since we looked, but if so this - * is harmless.) + * ourselves, then we must execute asyncQueueAdvanceTail to flush the + * queue, because ain't nobody else gonna do it. This prevents queue + * overflow when we're sending useless notifies to nobody. (A new + * listener could have joined since we looked, but if so this is + * harmless.) */ asyncQueueAdvanceTail(); } @@ -1164,14 +1166,14 @@ IsListeningOn(const char *channel) /* * Remove our entry from the listeners array when we are no longer listening - * on any channel. NB: must not fail if we're already not listening. + * on any channel. NB: must not fail if we're already not listening. */ static void asyncQueueUnregister(void) { - bool advanceTail; + bool advanceTail; - Assert(listenChannels == NIL); /* else caller error */ + Assert(listenChannels == NIL); /* else caller error */ LWLockAcquire(AsyncQueueLock, LW_SHARED); /* check if entry is valid and oldest ... */ @@ -1200,7 +1202,7 @@ asyncQueueIsFull(void) /* * The queue is full if creating a new head page would create a page that * logically precedes the current global tail pointer, ie, the head - * pointer would wrap around compared to the tail. We cannot create such + * pointer would wrap around compared to the tail. We cannot create such * a head page for fear of confusing slru.c. For safety we round the tail * pointer back to a segment boundary (compare the truncation logic in * asyncQueueAdvanceTail). @@ -1219,15 +1221,15 @@ asyncQueueIsFull(void) /* * Advance the QueuePosition to the next entry, assuming that the current - * entry is of length entryLength. If we jump to a new page the function + * entry is of length entryLength. If we jump to a new page the function * returns true, else false. */ static bool asyncQueueAdvance(QueuePosition *position, int entryLength) { - int pageno = QUEUE_POS_PAGE(*position); - int offset = QUEUE_POS_OFFSET(*position); - bool pageJump = false; + int pageno = QUEUE_POS_PAGE(*position); + int offset = QUEUE_POS_OFFSET(*position); + bool pageJump = false; /* * Move to the next writing position: First jump over what we have just @@ -1245,7 +1247,7 @@ asyncQueueAdvance(QueuePosition *position, int entryLength) { pageno++; if (pageno > QUEUE_MAX_PAGE) - pageno = 0; /* wrap around */ + pageno = 0; /* wrap around */ offset = 0; pageJump = true; } @@ -1260,9 +1262,9 @@ asyncQueueAdvance(QueuePosition *position, int entryLength) static void asyncQueueNotificationToEntry(Notification *n, AsyncQueueEntry *qe) { - size_t channellen = strlen(n->channel); - size_t payloadlen = strlen(n->payload); - int entryLength; + size_t channellen = strlen(n->channel); + size_t payloadlen = strlen(n->payload); + int entryLength; Assert(channellen < NAMEDATALEN); Assert(payloadlen < NOTIFY_PAYLOAD_MAX_LENGTH); @@ -1288,7 +1290,7 @@ asyncQueueNotificationToEntry(Notification *n, AsyncQueueEntry *qe) * the last byte which simplifies reading the page later. * * We are passed the list cell containing the next notification to write - * and return the first still-unwritten cell back. Eventually we will return + * and return the first still-unwritten cell back. Eventually we will return * NULL indicating all is done. * * We are holding AsyncQueueLock already from the caller and grab AsyncCtlLock @@ -1297,10 +1299,10 @@ asyncQueueNotificationToEntry(Notification *n, AsyncQueueEntry *qe) static ListCell * asyncQueueAddEntries(ListCell *nextNotify) { - AsyncQueueEntry qe; - int pageno; - int offset; - int slotno; + AsyncQueueEntry qe; + int pageno; + int offset; + int slotno; /* We hold both AsyncQueueLock and AsyncCtlLock during this operation */ LWLockAcquire(AsyncCtlLock, LW_EXCLUSIVE); @@ -1313,7 +1315,7 @@ asyncQueueAddEntries(ListCell *nextNotify) while (nextNotify != NULL) { - Notification *n = (Notification *) lfirst(nextNotify); + Notification *n = (Notification *) lfirst(nextNotify); /* Construct a valid queue entry in local variable qe */ asyncQueueNotificationToEntry(n, &qe); @@ -1335,8 +1337,8 @@ asyncQueueAddEntries(ListCell *nextNotify) */ qe.length = QUEUE_PAGESIZE - offset; qe.dboid = InvalidOid; - qe.data[0] = '\0'; /* empty channel */ - qe.data[1] = '\0'; /* empty payload */ + qe.data[0] = '\0'; /* empty channel */ + qe.data[1] = '\0'; /* empty payload */ } /* Now copy qe into the shared buffer page */ @@ -1348,12 +1350,12 @@ asyncQueueAddEntries(ListCell *nextNotify) if (asyncQueueAdvance(&(QUEUE_HEAD), qe.length)) { /* - * Page is full, so we're done here, but first fill the next - * page with zeroes. The reason to do this is to ensure that - * slru.c's idea of the head page is always the same as ours, - * which avoids boundary problems in SimpleLruTruncate. The - * test in asyncQueueIsFull() ensured that there is room to - * create this page without overrunning the queue. + * Page is full, so we're done here, but first fill the next page + * with zeroes. The reason to do this is to ensure that slru.c's + * idea of the head page is always the same as ours, which avoids + * boundary problems in SimpleLruTruncate. The test in + * asyncQueueIsFull() ensured that there is room to create this + * page without overrunning the queue. */ slotno = SimpleLruZeroPage(AsyncCtl, QUEUE_POS_PAGE(QUEUE_HEAD)); /* And exit the loop */ @@ -1377,24 +1379,24 @@ asyncQueueAddEntries(ListCell *nextNotify) static void asyncQueueFillWarning(void) { - int headPage = QUEUE_POS_PAGE(QUEUE_HEAD); - int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL); - int occupied; - double fillDegree; - TimestampTz t; + int headPage = QUEUE_POS_PAGE(QUEUE_HEAD); + int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL); + int occupied; + double fillDegree; + TimestampTz t; occupied = headPage - tailPage; if (occupied == 0) return; /* fast exit for common case */ - + if (occupied < 0) { /* head has wrapped around, tail not yet */ - occupied += QUEUE_MAX_PAGE+1; + occupied += QUEUE_MAX_PAGE + 1; } - fillDegree = (double) occupied / (double) ((QUEUE_MAX_PAGE+1)/2); + fillDegree = (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2); if (fillDegree < 0.5) return; @@ -1404,9 +1406,9 @@ asyncQueueFillWarning(void) if (TimestampDifferenceExceeds(asyncQueueControl->lastQueueFillWarn, t, QUEUE_FULL_WARN_INTERVAL)) { - QueuePosition min = QUEUE_HEAD; - int32 minPid = InvalidPid; - int i; + QueuePosition min = QUEUE_HEAD; + int32 minPid = InvalidPid; + int i; for (i = 1; i <= MaxBackends; i++) { @@ -1455,13 +1457,13 @@ SignalBackends(void) int32 pid; /* - * Identify all backends that are listening and not already up-to-date. - * We don't want to send signals while holding the AsyncQueueLock, so - * we just build a list of target PIDs. + * Identify all backends that are listening and not already up-to-date. We + * don't want to send signals while holding the AsyncQueueLock, so we just + * build a list of target PIDs. * - * XXX in principle these pallocs could fail, which would be bad. - * Maybe preallocate the arrays? But in practice this is only run - * in trivial transactions, so there should surely be space available. + * XXX in principle these pallocs could fail, which would be bad. Maybe + * preallocate the arrays? But in practice this is only run in trivial + * transactions, so there should surely be space available. */ pids = (int32 *) palloc(MaxBackends * sizeof(int32)); ids = (BackendId *) palloc(MaxBackends * sizeof(BackendId)); @@ -1493,8 +1495,8 @@ SignalBackends(void) /* * Note: assuming things aren't broken, a signal failure here could * only occur if the target backend exited since we released - * AsyncQueueLock; which is unlikely but certainly possible. - * So we just log a low-level debug message if it happens. + * AsyncQueueLock; which is unlikely but certainly possible. So we + * just log a low-level debug message if it happens. */ if (SendProcSignal(pid, PROCSIG_NOTIFY_INTERRUPT, ids[i]) < 0) elog(DEBUG3, "could not signal backend with PID %d: %m", pid); @@ -1521,8 +1523,8 @@ AtAbort_Notify(void) { /* * If we LISTEN but then roll back the transaction we have set our pointer - * but have not made any entry in listenChannels. In that case, remove - * our pointer again. + * but have not made any entry in listenChannels. In that case, remove our + * pointer again. */ if (backendHasExecutedInitialListen) { @@ -1778,7 +1780,7 @@ EnableNotifyInterrupt(void) * is disabled until the next EnableNotifyInterrupt call. * * The PROCSIG_CATCHUP_INTERRUPT signal handler also needs to call this, - * so as to prevent conflicts if one signal interrupts the other. So we + * so as to prevent conflicts if one signal interrupts the other. So we * must return the previous state of the flag. */ bool @@ -1799,15 +1801,17 @@ DisableNotifyInterrupt(void) static void asyncQueueReadAllNotifications(void) { - QueuePosition pos; - QueuePosition oldpos; - QueuePosition head; + QueuePosition pos; + QueuePosition oldpos; + QueuePosition head; bool advanceTail; + /* page_buffer must be adequately aligned, so use a union */ - union { + union + { char buf[QUEUE_PAGESIZE]; AsyncQueueEntry align; - } page_buffer; + } page_buffer; /* Fetch current state */ LWLockAcquire(AsyncQueueLock, LW_SHARED); @@ -1829,16 +1833,16 @@ asyncQueueReadAllNotifications(void) * Especially we do not take into account different commit times. * Consider the following example: * - * Backend 1: Backend 2: + * Backend 1: Backend 2: * * transaction starts * NOTIFY foo; * commit starts - * transaction starts - * LISTEN foo; - * commit starts + * transaction starts + * LISTEN foo; + * commit starts * commit to clog - * commit to clog + * commit to clog * * It could happen that backend 2 sees the notification from backend 1 in * the queue. Even though the notifying transaction committed before @@ -1861,7 +1865,7 @@ asyncQueueReadAllNotifications(void) { bool reachedStop; - do + do { int curpage = QUEUE_POS_PAGE(pos); int curoffset = QUEUE_POS_OFFSET(pos); @@ -1871,7 +1875,7 @@ asyncQueueReadAllNotifications(void) /* * We copy the data from SLRU into a local buffer, so as to avoid * holding the AsyncCtlLock while we are examining the entries and - * possibly transmitting them to our frontend. Copy only the part + * possibly transmitting them to our frontend. Copy only the part * of the page we will actually inspect. */ slotno = SimpleLruReadPage_ReadOnly(AsyncCtl, curpage, @@ -1881,7 +1885,7 @@ asyncQueueReadAllNotifications(void) /* we only want to read as far as head */ copysize = QUEUE_POS_OFFSET(head) - curoffset; if (copysize < 0) - copysize = 0; /* just for safety */ + copysize = 0; /* just for safety */ } else { @@ -1899,9 +1903,9 @@ asyncQueueReadAllNotifications(void) * uncommitted message. * * Our stop position is what we found to be the head's position - * when we entered this function. It might have changed - * already. But if it has, we will receive (or have already - * received and queued) another signal and come here again. + * when we entered this function. It might have changed already. + * But if it has, we will receive (or have already received and + * queued) another signal and come here again. * * We are not holding AsyncQueueLock here! The queue can only * extend beyond the head pointer (see above) and we leave our @@ -1945,7 +1949,7 @@ asyncQueueReadAllNotifications(void) * and deliver relevant ones to my frontend. * * The current page must have been fetched into page_buffer from shared - * memory. (We could access the page right in shared memory, but that + * memory. (We could access the page right in shared memory, but that * would imply holding the AsyncCtlLock throughout this routine.) * * We stop if we reach the "stop" position, or reach a notification from an @@ -1963,11 +1967,11 @@ asyncQueueProcessPageEntries(QueuePosition *current, { bool reachedStop = false; bool reachedEndOfPage; - AsyncQueueEntry *qe; + AsyncQueueEntry *qe; do { - QueuePosition thisentry = *current; + QueuePosition thisentry = *current; if (QUEUE_POS_EQUAL(thisentry, stop)) break; @@ -1975,9 +1979,9 @@ asyncQueueProcessPageEntries(QueuePosition *current, qe = (AsyncQueueEntry *) (page_buffer + QUEUE_POS_OFFSET(thisentry)); /* - * Advance *current over this message, possibly to the next page. - * As noted in the comments for asyncQueueReadAllNotifications, we - * must do this before possibly failing while processing the message. + * Advance *current over this message, possibly to the next page. As + * noted in the comments for asyncQueueReadAllNotifications, we must + * do this before possibly failing while processing the message. */ reachedEndOfPage = asyncQueueAdvance(current, qe->length); @@ -1987,12 +1991,12 @@ asyncQueueProcessPageEntries(QueuePosition *current, if (TransactionIdDidCommit(qe->xid)) { /* qe->data is the null-terminated channel name */ - char *channel = qe->data; + char *channel = qe->data; if (IsListeningOn(channel)) { /* payload follows channel name */ - char *payload = qe->data + strlen(channel) + 1; + char *payload = qe->data + strlen(channel) + 1; NotifyMyFrontEnd(channel, payload, qe->srcPid); } @@ -2008,12 +2012,12 @@ asyncQueueProcessPageEntries(QueuePosition *current, { /* * The transaction has neither committed nor aborted so far, - * so we can't process its message yet. Break out of the loop, - * but first back up *current so we will reprocess the message - * next time. (Note: it is unlikely but not impossible for - * TransactionIdDidCommit to fail, so we can't really avoid - * this advance-then-back-up behavior when dealing with an - * uncommitted message.) + * so we can't process its message yet. Break out of the + * loop, but first back up *current so we will reprocess the + * message next time. (Note: it is unlikely but not + * impossible for TransactionIdDidCommit to fail, so we can't + * really avoid this advance-then-back-up behavior when + * dealing with an uncommitted message.) */ *current = thisentry; reachedStop = true; @@ -2037,11 +2041,11 @@ asyncQueueProcessPageEntries(QueuePosition *current, static void asyncQueueAdvanceTail(void) { - QueuePosition min; - int i; - int oldtailpage; - int newtailpage; - int boundary; + QueuePosition min; + int i; + int oldtailpage; + int newtailpage; + int boundary; LWLockAcquire(AsyncQueueLock, LW_EXCLUSIVE); min = QUEUE_HEAD; @@ -2058,16 +2062,16 @@ asyncQueueAdvanceTail(void) * We can truncate something if the global tail advanced across an SLRU * segment boundary. * - * XXX it might be better to truncate only once every several segments, - * to reduce the number of directory scans. + * XXX it might be better to truncate only once every several segments, to + * reduce the number of directory scans. */ newtailpage = QUEUE_POS_PAGE(min); boundary = newtailpage - (newtailpage % SLRU_PAGES_PER_SEGMENT); if (asyncQueuePagePrecedesLogically(oldtailpage, boundary)) { /* - * SimpleLruTruncate() will ask for AsyncCtlLock but will also - * release the lock again. + * SimpleLruTruncate() will ask for AsyncCtlLock but will also release + * the lock again. */ SimpleLruTruncate(AsyncCtl, newtailpage); } @@ -2104,8 +2108,8 @@ ProcessIncomingNotify(void) notifyInterruptOccurred = 0; /* - * We must run asyncQueueReadAllNotifications inside a transaction, - * else bad things happen if it gets an error. + * We must run asyncQueueReadAllNotifications inside a transaction, else + * bad things happen if it gets an error. */ StartTransactionCommand(); diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index eed4d51edcc..78df9a8da85 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -1,7 +1,7 @@ /*------------------------------------------------------------------------- * * cluster.c - * CLUSTER a table on an index. This is now also used for VACUUM FULL. + * CLUSTER a table on an index. This is now also used for VACUUM FULL. * * There is hardly anything left of Paul Brown's original implementation... * @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.201 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.202 2010/02/26 02:00:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ typedef struct static void rebuild_relation(Relation OldHeap, Oid indexOid, - int freeze_min_age, int freeze_table_age); + int freeze_min_age, int freeze_table_age); static void copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, int freeze_min_age, int freeze_table_age, bool *pSwapToastByContent, TransactionId *pFreezeXid); @@ -252,7 +252,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel) * them incrementally while we load the table. * * If indexOid is InvalidOid, the table will be rewritten in physical order - * instead of index order. This is the new implementation of VACUUM FULL, + * instead of index order. This is the new implementation of VACUUM FULL, * and error messages should refer to the operation as VACUUM not CLUSTER. */ void @@ -301,8 +301,8 @@ cluster_rel(Oid tableOid, Oid indexOid, bool recheck, bool verbose, * check in the "recheck" case is appropriate (which currently means * somebody is executing a database-wide CLUSTER), because there is * another check in cluster() which will stop any attempt to cluster - * remote temp tables by name. There is another check in - * cluster_rel which is redundant, but we leave it for extra safety. + * remote temp tables by name. There is another check in cluster_rel + * which is redundant, but we leave it for extra safety. */ if (RELATION_IS_OTHER_TEMP(OldHeap)) { @@ -325,7 +325,7 @@ cluster_rel(Oid tableOid, Oid indexOid, bool recheck, bool verbose, * Check that the index is still the one with indisclustered set. */ tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid)); - if (!HeapTupleIsValid(tuple)) /* probably can't happen */ + if (!HeapTupleIsValid(tuple)) /* probably can't happen */ { relation_close(OldHeap, AccessExclusiveLock); return; @@ -353,19 +353,19 @@ cluster_rel(Oid tableOid, Oid indexOid, bool recheck, bool verbose, errmsg("cannot cluster a shared catalog"))); /* - * Don't process temp tables of other backends ... their local - * buffer manager is not going to cope. + * Don't process temp tables of other backends ... their local buffer + * manager is not going to cope. */ if (RELATION_IS_OTHER_TEMP(OldHeap)) { if (OidIsValid(indexOid)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot cluster temporary tables of other sessions"))); + errmsg("cannot cluster temporary tables of other sessions"))); else ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot vacuum temporary tables of other sessions"))); + errmsg("cannot vacuum temporary tables of other sessions"))); } /* @@ -664,8 +664,8 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace) * the old, or we will have problems with the TEMP status of temp tables. * * Note: the new heap is not a shared relation, even if we are rebuilding - * a shared rel. However, we do make the new heap mapped if the source - * is mapped. This simplifies swap_relation_files, and is absolutely + * a shared rel. However, we do make the new heap mapped if the source is + * mapped. This simplifies swap_relation_files, and is absolutely * necessary for rebuilding pg_class, for reasons explained there. */ snprintf(NewHeapName, sizeof(NewHeapName), "pg_temp_%u", OIDOldHeap); @@ -701,9 +701,9 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace) * If necessary, create a TOAST table for the new relation. * * If the relation doesn't have a TOAST table already, we can't need one - * for the new relation. The other way around is possible though: if - * some wide columns have been dropped, AlterTableCreateToastTable - * can decide that no TOAST table is needed for the new table. + * for the new relation. The other way around is possible though: if some + * wide columns have been dropped, AlterTableCreateToastTable can decide + * that no TOAST table is needed for the new table. * * Note that AlterTableCreateToastTable ends with CommandCounterIncrement, * so that the TOAST table will be visible for insertion. @@ -782,18 +782,18 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, isnull = (bool *) palloc(natts * sizeof(bool)); /* - * We need to log the copied data in WAL iff WAL archiving/streaming - * is enabled AND it's not a temp rel. + * We need to log the copied data in WAL iff WAL archiving/streaming is + * enabled AND it's not a temp rel. */ use_wal = XLogIsNeeded() && !NewHeap->rd_istemp; /* - * Write an XLOG UNLOGGED record if WAL-logging was skipped because - * WAL archiving is not enabled. + * Write an XLOG UNLOGGED record if WAL-logging was skipped because WAL + * archiving is not enabled. */ if (!use_wal && !NewHeap->rd_istemp) { - char reason[NAMEDATALEN + 32]; + char reason[NAMEDATALEN + 32]; if (OldIndex != NULL) snprintf(reason, sizeof(reason), "CLUSTER on \"%s\"", @@ -810,7 +810,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, /* * If both tables have TOAST tables, perform toast swap by content. It is * possible that the old table has a toast table but the new one doesn't, - * if toastable columns have been dropped. In that case we have to do + * if toastable columns have been dropped. In that case we have to do * swap by links. This is okay because swap by content is only essential * for system catalogs, and we don't support schema changes for them. */ @@ -824,7 +824,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, * data will eventually be found. Set this up by setting rd_toastoid. * Note that we must hold NewHeap open until we are done writing data, * since the relcache will not guarantee to remember this setting once - * the relation is closed. Also, this technique depends on the fact + * the relation is closed. Also, this technique depends on the fact * that no one will try to read from the NewHeap until after we've * finished writing it and swapping the rels --- otherwise they could * follow the toast pointers to the wrong place. @@ -860,8 +860,8 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, rwstate = begin_heap_rewrite(NewHeap, OldestXmin, FreezeXid, use_wal); /* - * Scan through the OldHeap, either in OldIndex order or sequentially, - * and copy each tuple into the NewHeap. To ensure we see recently-dead + * Scan through the OldHeap, either in OldIndex order or sequentially, and + * copy each tuple into the NewHeap. To ensure we see recently-dead * tuples that still need to be copied, we scan with SnapshotAny and use * HeapTupleSatisfiesVacuum for the visibility test. */ @@ -924,12 +924,12 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, case HEAPTUPLE_INSERT_IN_PROGRESS: /* - * Since we hold exclusive lock on the relation, normally - * the only way to see this is if it was inserted earlier - * in our own transaction. However, it can happen in system + * Since we hold exclusive lock on the relation, normally the + * only way to see this is if it was inserted earlier in our + * own transaction. However, it can happen in system * catalogs, since we tend to release write lock before commit - * there. Give a warning if neither case applies; but in - * any case we had better copy it. + * there. Give a warning if neither case applies; but in any + * case we had better copy it. */ if (!is_system_catalog && !TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple->t_data))) @@ -1139,7 +1139,7 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, NameStr(relform2->relname), r2); /* - * Send replacement mappings to relmapper. Note these won't actually + * Send replacement mappings to relmapper. Note these won't actually * take effect until CommandCounterIncrement. */ RelationMapUpdateMap(r1, relfilenode2, relform1->relisshared, false); @@ -1151,10 +1151,10 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, /* * In the case of a shared catalog, these next few steps will only affect - * our own database's pg_class row; but that's okay, because they are - * all noncritical updates. That's also an important fact for the case - * of a mapped catalog, because it's possible that we'll commit the map - * change and then fail to commit the pg_class update. + * our own database's pg_class row; but that's okay, because they are all + * noncritical updates. That's also an important fact for the case of a + * mapped catalog, because it's possible that we'll commit the map change + * and then fail to commit the pg_class update. */ /* set rel1's frozen Xid */ @@ -1181,10 +1181,10 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, /* * Update the tuples in pg_class --- unless the target relation of the * swap is pg_class itself. In that case, there is zero point in making - * changes because we'd be updating the old data that we're about to - * throw away. Because the real work being done here for a mapped relation - * is just to change the relation map settings, it's all right to not - * update the pg_class rows in this case. + * changes because we'd be updating the old data that we're about to throw + * away. Because the real work being done here for a mapped relation is + * just to change the relation map settings, it's all right to not update + * the pg_class rows in this case. */ if (!target_is_pg_class) { @@ -1248,8 +1248,8 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, /* * We disallow this case for system catalogs, to avoid the * possibility that the catalog we're rebuilding is one of the - * ones the dependency changes would change. It's too late - * to be making any data changes to the target catalog. + * ones the dependency changes would change. It's too late to be + * making any data changes to the target catalog. */ if (IsSystemClass(relform1)) elog(ERROR, "cannot swap toast files by links for system catalogs"); @@ -1302,12 +1302,12 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, */ if (swap_toast_by_content && relform1->reltoastidxid && relform2->reltoastidxid) - swap_relation_files(relform1->reltoastidxid, - relform2->reltoastidxid, - target_is_pg_class, - swap_toast_by_content, - InvalidTransactionId, - mapped_tables); + swap_relation_files(relform1->reltoastidxid, + relform2->reltoastidxid, + target_is_pg_class, + swap_toast_by_content, + InvalidTransactionId, + mapped_tables); /* Clean up. */ heap_freetuple(reltup1); @@ -1327,7 +1327,7 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, * non-transient relation.) * * Caution: the placement of this step interacts with the decision to - * handle toast rels by recursion. When we are trying to rebuild pg_class + * handle toast rels by recursion. When we are trying to rebuild pg_class * itself, the smgr close on pg_class must happen after all accesses in * this function. */ @@ -1369,12 +1369,12 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, /* * Rebuild each index on the relation (but not the toast table, which is - * all-new at this point). It is important to do this before the DROP + * all-new at this point). It is important to do this before the DROP * step because if we are processing a system catalog that will be used - * during DROP, we want to have its indexes available. There is no + * during DROP, we want to have its indexes available. There is no * advantage to the other order anyway because this is all transactional, - * so no chance to reclaim disk space before commit. We do not need - * a final CommandCounterIncrement() because reindex_relation does it. + * so no chance to reclaim disk space before commit. We do not need a + * final CommandCounterIncrement() because reindex_relation does it. */ reindex_relation(OIDOldHeap, false, true); @@ -1393,9 +1393,9 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, /* * Now we must remove any relation mapping entries that we set up for the - * transient table, as well as its toast table and toast index if any. - * If we fail to do this before commit, the relmapper will complain about - * new permanent map entries being added post-bootstrap. + * transient table, as well as its toast table and toast index if any. If + * we fail to do this before commit, the relmapper will complain about new + * permanent map entries being added post-bootstrap. */ for (i = 0; OidIsValid(mapped_tables[i]); i++) RelationMapRemoveMapping(mapped_tables[i]); diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index 6577af4969b..2cf8aff6aec 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -7,7 +7,7 @@ * Copyright (c) 1996-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.113 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.114 2010/02/26 02:00:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -498,11 +498,11 @@ GetComment(Oid oid, Oid classoid, int32 subid) sd = systable_beginscan(description, DescriptionObjIndexId, true, SnapshotNow, 3, skey); - comment = NULL; + comment = NULL; while ((tuple = systable_getnext(sd)) != NULL) { - Datum value; - bool isnull; + Datum value; + bool isnull; /* Found the tuple, get description field */ value = heap_getattr(tuple, Anum_pg_description_description, tupdesc, &isnull); @@ -631,9 +631,8 @@ CommentAttribute(List *qualname, char *comment) * Allow comments only on columns of tables, views, and composite types * (which are the only relkinds for which pg_dump will dump per-column * comments). In particular we wish to disallow comments on index - * columns, because the naming of an index's columns may change across - * PG versions, so dumping per-column comments could create reload - * failures. + * columns, because the naming of an index's columns may change across PG + * versions, so dumping per-column comments could create reload failures. */ if (relation->rd_rel->relkind != RELKIND_RELATION && relation->rd_rel->relkind != RELKIND_VIEW && @@ -903,7 +902,7 @@ CommentRule(List *qualname, char *comment) /* Find the rule's pg_rewrite tuple, get its OID */ tuple = SearchSysCache2(RULERELNAME, - ObjectIdGetDatum(reloid), + ObjectIdGetDatum(reloid), PointerGetDatum(rulename)); if (!HeapTupleIsValid(tuple)) ereport(ERROR, @@ -1358,7 +1357,7 @@ CommentOpFamily(List *qualname, List *arguments, char *comment) namespaceId = LookupExplicitNamespace(schemaname); tuple = SearchSysCache3(OPFAMILYAMNAMENSP, ObjectIdGetDatum(amID), - PointerGetDatum(opfname), + PointerGetDatum(opfname), ObjectIdGetDatum(namespaceId)); } else @@ -1448,9 +1447,8 @@ CommentLargeObject(List *qualname, char *comment) /* * Call CreateComments() to create/drop the comments * - * See the comment in the inv_create() which describes - * the reason why LargeObjectRelationId is used instead - * of LargeObjectMetadataRelationId. + * See the comment in the inv_create() which describes the reason why + * LargeObjectRelationId is used instead of LargeObjectMetadataRelationId. */ CreateComments(loid, LargeObjectRelationId, 0, comment); } diff --git a/src/backend/commands/constraint.c b/src/backend/commands/constraint.c index 389a7df482b..5f18cf7f2a8 100644 --- a/src/backend/commands/constraint.c +++ b/src/backend/commands/constraint.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/constraint.c,v 1.3 2010/01/02 16:57:37 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/constraint.c,v 1.4 2010/02/26 02:00:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,9 +49,9 @@ unique_key_recheck(PG_FUNCTION_ARGS) bool isnull[INDEX_MAX_KEYS]; /* - * Make sure this is being called as an AFTER ROW trigger. Note: - * translatable error strings are shared with ri_triggers.c, so - * resist the temptation to fold the function name into them. + * Make sure this is being called as an AFTER ROW trigger. Note: + * translatable error strings are shared with ri_triggers.c, so resist the + * temptation to fold the function name into them. */ if (!CALLED_AS_TRIGGER(fcinfo)) ereport(ERROR, @@ -86,7 +86,7 @@ unique_key_recheck(PG_FUNCTION_ARGS) * If the new_row is now dead (ie, inserted and then deleted within our * transaction), we can skip the check. However, we have to be careful, * because this trigger gets queued only in response to index insertions; - * which means it does not get queued for HOT updates. The row we are + * which means it does not get queued for HOT updates. The row we are * called for might now be dead, but have a live HOT child, in which case * we still need to make the check. Therefore we have to use * heap_hot_search, not just HeapTupleSatisfiesVisibility as is done in @@ -109,9 +109,9 @@ unique_key_recheck(PG_FUNCTION_ARGS) } /* - * Open the index, acquiring a RowExclusiveLock, just as if we were - * going to update it. (This protects against possible changes of the - * index schema, not against concurrent updates.) + * Open the index, acquiring a RowExclusiveLock, just as if we were going + * to update it. (This protects against possible changes of the index + * schema, not against concurrent updates.) */ indexRel = index_open(trigdata->tg_trigger->tgconstrindid, RowExclusiveLock); @@ -125,9 +125,9 @@ unique_key_recheck(PG_FUNCTION_ARGS) ExecStoreTuple(new_row, slot, InvalidBuffer, false); /* - * Typically the index won't have expressions, but if it does we need - * an EState to evaluate them. We need it for exclusion constraints - * too, even if they are just on simple columns. + * Typically the index won't have expressions, but if it does we need an + * EState to evaluate them. We need it for exclusion constraints too, + * even if they are just on simple columns. */ if (indexInfo->ii_Expressions != NIL || indexInfo->ii_ExclusionOps != NULL) @@ -140,13 +140,13 @@ unique_key_recheck(PG_FUNCTION_ARGS) estate = NULL; /* - * Form the index values and isnull flags for the index entry that - * we need to check. + * Form the index values and isnull flags for the index entry that we need + * to check. * - * Note: if the index uses functions that are not as immutable as they - * are supposed to be, this could produce an index tuple different from - * the original. The index AM can catch such errors by verifying that - * it finds a matching index entry with the tuple's TID. For exclusion + * Note: if the index uses functions that are not as immutable as they are + * supposed to be, this could produce an index tuple different from the + * original. The index AM can catch such errors by verifying that it + * finds a matching index entry with the tuple's TID. For exclusion * constraints we check this in check_exclusion_constraint(). */ FormIndexDatum(indexInfo, slot, estate, values, isnull); @@ -166,8 +166,8 @@ unique_key_recheck(PG_FUNCTION_ARGS) else { /* - * For exclusion constraints we just do the normal check, but now - * it's okay to throw error. + * For exclusion constraints we just do the normal check, but now it's + * okay to throw error. */ check_exclusion_constraint(trigdata->tg_relation, indexRel, indexInfo, &(new_row->t_self), values, isnull, @@ -175,8 +175,8 @@ unique_key_recheck(PG_FUNCTION_ARGS) } /* - * If that worked, then this index entry is unique or non-excluded, - * and we are done. + * If that worked, then this index entry is unique or non-excluded, and we + * are done. */ if (estate != NULL) FreeExecutorState(estate); diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index fbcc4afb968..9031cd1fa51 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.325 2010/02/20 21:24:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.326 2010/02/26 02:00:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -743,7 +743,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString) if (strcmp(defel->defname, "format") == 0) { - char *fmt = defGetString(defel); + char *fmt = defGetString(defel); if (format_specified) ereport(ERROR, @@ -751,7 +751,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString) errmsg("conflicting or redundant options"))); format_specified = true; if (strcmp(fmt, "text") == 0) - /* default format */ ; + /* default format */ ; else if (strcmp(fmt, "csv") == 0) cstate->csv_mode = true; else if (strcmp(fmt, "binary") == 0) @@ -821,9 +821,9 @@ DoCopy(const CopyStmt *stmt, const char *queryString) force_quote = (List *) defel->arg; else ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("argument to option \"%s\" must be a list of column names", - defel->defname))); + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("argument to option \"%s\" must be a list of column names", + defel->defname))); } else if (strcmp(defel->defname, "force_not_null") == 0) { @@ -835,9 +835,9 @@ DoCopy(const CopyStmt *stmt, const char *queryString) force_notnull = (List *) defel->arg; else ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("argument to option \"%s\" must be a list of column names", - defel->defname))); + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("argument to option \"%s\" must be a list of column names", + defel->defname))); } else ereport(ERROR, @@ -1113,7 +1113,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString) cstate->force_quote_flags = (bool *) palloc0(num_phys_attrs * sizeof(bool)); if (force_quote_all) { - int i; + int i; for (i = 0; i < num_phys_attrs; i++) cstate->force_quote_flags[i] = true; @@ -2150,7 +2150,7 @@ CopyFrom(CopyState cstate) if (!skip_tuple) { - List *recheckIndexes = NIL; + List *recheckIndexes = NIL; /* Place tuple in tuple slot */ ExecStoreTuple(tuple, slot, InvalidBuffer, false); @@ -2224,7 +2224,8 @@ CopyFrom(CopyState cstate) */ if (hi_options & HEAP_INSERT_SKIP_WAL) { - char reason[NAMEDATALEN + 30]; + char reason[NAMEDATALEN + 30]; + snprintf(reason, sizeof(reason), "COPY FROM on \"%s\"", RelationGetRelationName(cstate->rel)); XLogReportUnloggedStatement(reason); diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 9c6f1b6936a..4b7131b7097 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.234 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.235 2010/02/26 02:00:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -338,11 +338,11 @@ createdb(const CreatedbStmt *stmt) * fails when presented with data in an encoding it's not expecting. We * allow mismatch in four cases: * - * 1. locale encoding = SQL_ASCII, which means that the locale is - * C/POSIX which works with any encoding. + * 1. locale encoding = SQL_ASCII, which means that the locale is C/POSIX + * which works with any encoding. * - * 2. locale encoding = -1, which means that we couldn't determine - * the locale's encoding and have to trust the user to get it right. + * 2. locale encoding = -1, which means that we couldn't determine the + * locale's encoding and have to trust the user to get it right. * * 3. selected encoding is UTF8 and platform is win32. This is because * UTF8 is a pseudo codepage that is supported in all locales since it's @@ -551,7 +551,7 @@ createdb(const CreatedbStmt *stmt) /* * We deliberately set datacl to default (NULL), rather than copying it - * from the template database. Copying it would be a bad idea when the + * from the template database. Copying it would be a bad idea when the * owner is not the same as the template's owner. */ new_record_nulls[Anum_pg_database_datacl - 1] = true; @@ -871,9 +871,9 @@ dropdb(const char *dbname, bool missing_ok) heap_close(pgdbrel, NoLock); /* - * Force synchronous commit, thus minimizing the window between removal - * of the database files and commital of the transaction. If we crash - * before committing, we'll have a DB that's gone on disk but still there + * Force synchronous commit, thus minimizing the window between removal of + * the database files and commital of the transaction. If we crash before + * committing, we'll have a DB that's gone on disk but still there * according to pg_database, which is not good. */ ForceSyncCommit(); @@ -1402,13 +1402,13 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel) void AlterDatabaseSet(AlterDatabaseSetStmt *stmt) { - Oid datid = get_database_oid(stmt->dbname); + Oid datid = get_database_oid(stmt->dbname); if (!OidIsValid(datid)) - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_DATABASE), - errmsg("database \"%s\" does not exist", stmt->dbname))); - + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_DATABASE), + errmsg("database \"%s\" does not exist", stmt->dbname))); + /* * Obtain a lock on the database and make sure it didn't go away in the * meantime. @@ -1416,11 +1416,11 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt) shdepLockAndCheckObject(DatabaseRelationId, datid); if (!pg_database_ownercheck(datid, GetUserId())) - aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE, - stmt->dbname); + aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE, + stmt->dbname); AlterSetting(datid, InvalidOid, stmt->setstmt); - + UnlockSharedObject(DatabaseRelationId, datid, 0, AccessShareLock); } @@ -1936,9 +1936,10 @@ dbase_redo(XLogRecPtr lsn, XLogRecord *record) if (InHotStandby) { /* - * Lock database while we resolve conflicts to ensure that InitPostgres() - * cannot fully re-execute concurrently. This avoids backends re-connecting - * automatically to same database, which can happen in some cases. + * Lock database while we resolve conflicts to ensure that + * InitPostgres() cannot fully re-execute concurrently. This + * avoids backends re-connecting automatically to same database, + * which can happen in some cases. */ LockSharedObjectForSession(DatabaseRelationId, xlrec->db_id, 0, AccessExclusiveLock); ResolveRecoveryConflictWithDatabase(xlrec->db_id); @@ -1962,10 +1963,11 @@ dbase_redo(XLogRecPtr lsn, XLogRecord *record) if (InHotStandby) { /* - * Release locks prior to commit. XXX There is a race condition here that may allow - * backends to reconnect, but the window for this is small because the gap between - * here and commit is mostly fairly small and it is unlikely that people will be - * dropping databases that we are trying to connect to anyway. + * Release locks prior to commit. XXX There is a race condition + * here that may allow backends to reconnect, but the window for + * this is small because the gap between here and commit is mostly + * fairly small and it is unlikely that people will be dropping + * databases that we are trying to connect to anyway. */ UnlockSharedObjectForSession(DatabaseRelationId, xlrec->db_id, 0, AccessExclusiveLock); } diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c index a3d45872b43..cf029cd539a 100644 --- a/src/backend/commands/define.c +++ b/src/backend/commands/define.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.107 2010/01/02 16:57:37 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.108 2010/02/26 02:00:38 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -156,8 +156,8 @@ defGetBoolean(DefElem *def) char *sval = defGetString(def); /* - * The set of strings accepted here should match up with - * the grammar's opt_boolean production. + * The set of strings accepted here should match up with the + * grammar's opt_boolean production. */ if (pg_strcasecmp(sval, "true") == 0) return true; diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 9100c404ad7..2409a01e2dd 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994-5, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.203 2010/02/16 22:19:59 adunstan Exp $ + * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.204 2010/02/26 02:00:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,9 +55,9 @@ static void report_triggers(ResultRelInfo *rInfo, bool show_relname, ExplainState *es); static double elapsed_time(instr_time *starttime); static void ExplainNode(Plan *plan, PlanState *planstate, - Plan *outer_plan, - const char *relationship, const char *plan_name, - ExplainState *es); + Plan *outer_plan, + const char *relationship, const char *plan_name, + ExplainState *es); static void show_plan_tlist(Plan *plan, ExplainState *es); static void show_qual(List *qual, const char *qlabel, Plan *plan, Plan *outer_plan, bool useprefix, ExplainState *es); @@ -74,25 +74,26 @@ static void ExplainScanTarget(Scan *plan, ExplainState *es); static void ExplainMemberNodes(List *plans, PlanState **planstate, Plan *outer_plan, ExplainState *es); static void ExplainSubPlans(List *plans, const char *relationship, - ExplainState *es); + ExplainState *es); static void ExplainPropertyList(const char *qlabel, List *data, - ExplainState *es); + ExplainState *es); static void ExplainProperty(const char *qlabel, const char *value, - bool numeric, ExplainState *es); -#define ExplainPropertyText(qlabel, value, es) \ + bool numeric, ExplainState *es); + +#define ExplainPropertyText(qlabel, value, es) \ ExplainProperty(qlabel, value, false, es) static void ExplainPropertyInteger(const char *qlabel, int value, - ExplainState *es); + ExplainState *es); static void ExplainPropertyLong(const char *qlabel, long value, - ExplainState *es); + ExplainState *es); static void ExplainPropertyFloat(const char *qlabel, double value, int ndigits, - ExplainState *es); + ExplainState *es); static void ExplainOpenGroup(const char *objtype, const char *labelname, bool labeled, ExplainState *es); static void ExplainCloseGroup(const char *objtype, const char *labelname, - bool labeled, ExplainState *es); + bool labeled, ExplainState *es); static void ExplainDummyGroup(const char *objtype, const char *labelname, - ExplainState *es); + ExplainState *es); static void ExplainXMLTag(const char *tagname, int flags, ExplainState *es); static void ExplainJSONLineEnding(ExplainState *es); static void ExplainYAMLLineStarting(ExplainState *es); @@ -120,7 +121,7 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString, /* Parse options list. */ foreach(lc, stmt->options) { - DefElem *opt = (DefElem *) lfirst(lc); + DefElem *opt = (DefElem *) lfirst(lc); if (strcmp(opt->defname, "analyze") == 0) es.analyze = defGetBoolean(opt); @@ -132,7 +133,7 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString, es.buffers = defGetBoolean(opt); else if (strcmp(opt->defname, "format") == 0) { - char *p = defGetString(opt); + char *p = defGetString(opt); if (strcmp(p, "text") == 0) es.format = EXPLAIN_FORMAT_TEXT; @@ -144,9 +145,9 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString, es.format = EXPLAIN_FORMAT_YAML; else ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("unrecognized value for EXPLAIN option \"%s\": \"%s\"", - opt->defname, p))); + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("unrecognized value for EXPLAIN option \"%s\": \"%s\"", + opt->defname, p))); } else ereport(ERROR, @@ -157,14 +158,14 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString, if (es.buffers && !es.analyze) ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("EXPLAIN option BUFFERS requires ANALYZE"))); + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("EXPLAIN option BUFFERS requires ANALYZE"))); /* * Parse analysis was done already, but we still have to run the rule - * rewriter. We do not do AcquireRewriteLocks: we assume the query - * either came straight from the parser, or suitable locks were - * acquired by plancache.c. + * rewriter. We do not do AcquireRewriteLocks: we assume the query either + * came straight from the parser, or suitable locks were acquired by + * plancache.c. * * Because the rewriter and planner tend to scribble on the input, we make * a preliminary copy of the source querytree. This prevents problems in @@ -244,11 +245,11 @@ ExplainResultDesc(ExplainStmt *stmt) /* Check for XML format option */ foreach(lc, stmt->options) { - DefElem *opt = (DefElem *) lfirst(lc); + DefElem *opt = (DefElem *) lfirst(lc); if (strcmp(opt->defname, "format") == 0) { - char *p = defGetString(opt); + char *p = defGetString(opt); xml = (strcmp(p, "xml") == 0); /* don't "break", as ExplainQuery will use the last value */ @@ -322,7 +323,7 @@ ExplainOneUtility(Node *utilityStmt, ExplainState *es, { if (es->format == EXPLAIN_FORMAT_TEXT) appendStringInfoString(es->str, - "Utility statements have no plan structure\n"); + "Utility statements have no plan structure\n"); else ExplainDummyGroup("Utility Statement", NULL, es); } @@ -472,7 +473,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, ExplainState *es, * convert a QueryDesc's plan tree to text and append it to es->str * * The caller should have set up the options fields of *es, as well as - * initializing the output buffer es->str. Other fields in *es are + * initializing the output buffer es->str. Other fields in *es are * initialized here. * * NB: will not work on utility statements @@ -489,10 +490,10 @@ ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc) /* * ExplainQueryText - - * add a "Query Text" node that contains the actual text of the query - * + * add a "Query Text" node that contains the actual text of the query + * * The caller should have set up the options fields of *es, as well as - * initializing the output buffer es->str. + * initializing the output buffer es->str. * */ void @@ -538,8 +539,8 @@ report_triggers(ResultRelInfo *rInfo, bool show_relname, ExplainState *es) /* * In text format, we avoid printing both the trigger name and the - * constraint name unless VERBOSE is specified. In non-text - * formats we just print everything. + * constraint name unless VERBOSE is specified. In non-text formats + * we just print everything. */ if (es->format == EXPLAIN_FORMAT_TEXT) { @@ -657,11 +658,11 @@ ExplainNode(Plan *plan, PlanState *planstate, pname = sname = "Nested Loop"; break; case T_MergeJoin: - pname = "Merge"; /* "Join" gets added by jointype switch */ + pname = "Merge"; /* "Join" gets added by jointype switch */ sname = "Merge Join"; break; case T_HashJoin: - pname = "Hash"; /* "Join" gets added by jointype switch */ + pname = "Hash"; /* "Join" gets added by jointype switch */ sname = "Hash Join"; break; case T_SeqScan: @@ -801,9 +802,9 @@ ExplainNode(Plan *plan, PlanState *planstate, { case T_IndexScan: { - IndexScan *indexscan = (IndexScan *) plan; + IndexScan *indexscan = (IndexScan *) plan; const char *indexname = - explain_get_index_name(indexscan->indexid); + explain_get_index_name(indexscan->indexid); if (es->format == EXPLAIN_FORMAT_TEXT) { @@ -849,7 +850,7 @@ ExplainNode(Plan *plan, PlanState *planstate, { BitmapIndexScan *bitmapindexscan = (BitmapIndexScan *) plan; const char *indexname = - explain_get_index_name(bitmapindexscan->indexid); + explain_get_index_name(bitmapindexscan->indexid); if (es->format == EXPLAIN_FORMAT_TEXT) appendStringInfo(es->str, " on %s", indexname); @@ -1084,14 +1085,14 @@ ExplainNode(Plan *plan, PlanState *planstate, if (es->format == EXPLAIN_FORMAT_TEXT) { - bool has_shared = (usage->shared_blks_hit > 0 || - usage->shared_blks_read > 0 || - usage->shared_blks_written); - bool has_local = (usage->local_blks_hit > 0 || - usage->local_blks_read > 0 || - usage->local_blks_written); - bool has_temp = (usage->temp_blks_read > 0 || - usage->temp_blks_written); + bool has_shared = (usage->shared_blks_hit > 0 || + usage->shared_blks_read > 0 || + usage->shared_blks_written); + bool has_local = (usage->local_blks_hit > 0 || + usage->local_blks_read > 0 || + usage->local_blks_written); + bool has_temp = (usage->temp_blks_read > 0 || + usage->temp_blks_written); /* Show only positive counter values. */ if (has_shared || has_local || has_temp) @@ -1104,13 +1105,13 @@ ExplainNode(Plan *plan, PlanState *planstate, appendStringInfoString(es->str, " shared"); if (usage->shared_blks_hit > 0) appendStringInfo(es->str, " hit=%ld", - usage->shared_blks_hit); + usage->shared_blks_hit); if (usage->shared_blks_read > 0) appendStringInfo(es->str, " read=%ld", - usage->shared_blks_read); + usage->shared_blks_read); if (usage->shared_blks_written > 0) appendStringInfo(es->str, " written=%ld", - usage->shared_blks_written); + usage->shared_blks_written); if (has_local || has_temp) appendStringInfoChar(es->str, ','); } @@ -1119,13 +1120,13 @@ ExplainNode(Plan *plan, PlanState *planstate, appendStringInfoString(es->str, " local"); if (usage->local_blks_hit > 0) appendStringInfo(es->str, " hit=%ld", - usage->local_blks_hit); + usage->local_blks_hit); if (usage->local_blks_read > 0) appendStringInfo(es->str, " read=%ld", - usage->local_blks_read); + usage->local_blks_read); if (usage->local_blks_written > 0) appendStringInfo(es->str, " written=%ld", - usage->local_blks_written); + usage->local_blks_written); if (has_temp) appendStringInfoChar(es->str, ','); } @@ -1134,10 +1135,10 @@ ExplainNode(Plan *plan, PlanState *planstate, appendStringInfoString(es->str, " temp"); if (usage->temp_blks_read > 0) appendStringInfo(es->str, " read=%ld", - usage->temp_blks_read); + usage->temp_blks_read); if (usage->temp_blks_written > 0) appendStringInfo(es->str, " written=%ld", - usage->temp_blks_written); + usage->temp_blks_written); } appendStringInfoChar(es->str, '\n'); } @@ -1283,7 +1284,7 @@ show_plan_tlist(Plan *plan, ExplainState *es) TargetEntry *tle = (TargetEntry *) lfirst(lc); result = lappend(result, - deparse_expression((Node *) tle->expr, context, + deparse_expression((Node *) tle->expr, context, useprefix, false)); } @@ -1403,7 +1404,7 @@ show_sort_info(SortState *sortstate, ExplainState *es) if (es->analyze && sortstate->sort_Done && sortstate->tuplesortstate != NULL) { - Tuplesortstate *state = (Tuplesortstate *) sortstate->tuplesortstate; + Tuplesortstate *state = (Tuplesortstate *) sortstate->tuplesortstate; const char *sortMethod; const char *spaceType; long spaceUsed; @@ -1438,7 +1439,8 @@ show_hash_info(HashState *hashstate, ExplainState *es) if (hashtable) { - long spacePeakKb = (hashtable->spacePeak + 1023) / 1024; + long spacePeakKb = (hashtable->spacePeak + 1023) / 1024; + if (es->format != EXPLAIN_FORMAT_TEXT) { ExplainPropertyLong("Hash Buckets", hashtable->nbuckets, es); @@ -1451,7 +1453,7 @@ show_hash_info(HashState *hashstate, ExplainState *es) { appendStringInfoSpaces(es->str, es->indent * 2); appendStringInfo(es->str, - "Buckets: %d Batches: %d (originally %d) Memory Usage: %ldkB\n", + "Buckets: %d Batches: %d (originally %d) Memory Usage: %ldkB\n", hashtable->nbuckets, hashtable->nbatch, hashtable->nbatch_original, spacePeakKb); } @@ -1459,7 +1461,7 @@ show_hash_info(HashState *hashstate, ExplainState *es) { appendStringInfoSpaces(es->str, es->indent * 2); appendStringInfo(es->str, - "Buckets: %d Batches: %d Memory Usage: %ldkB\n", + "Buckets: %d Batches: %d Memory Usage: %ldkB\n", hashtable->nbuckets, hashtable->nbatch, spacePeakKb); } @@ -1600,7 +1602,7 @@ ExplainScanTarget(Scan *plan, ExplainState *es) */ static void ExplainMemberNodes(List *plans, PlanState **planstate, Plan *outer_plan, - ExplainState *es) + ExplainState *es) { ListCell *lst; int j = 0; @@ -1667,7 +1669,7 @@ ExplainPropertyList(const char *qlabel, List *data, ExplainState *es) ExplainXMLTag(qlabel, X_OPENING, es); foreach(lc, data) { - char *str; + char *str; appendStringInfoSpaces(es->str, es->indent * 2 + 2); appendStringInfoString(es->str, "<Item>"); @@ -1731,7 +1733,7 @@ ExplainProperty(const char *qlabel, const char *value, bool numeric, case EXPLAIN_FORMAT_XML: { - char *str; + char *str; appendStringInfoSpaces(es->str, es->indent * 2); ExplainXMLTag(qlabel, X_OPENING | X_NOWHITESPACE, es); @@ -1768,7 +1770,7 @@ ExplainProperty(const char *qlabel, const char *value, bool numeric, static void ExplainPropertyInteger(const char *qlabel, int value, ExplainState *es) { - char buf[32]; + char buf[32]; snprintf(buf, sizeof(buf), "%d", value); ExplainProperty(qlabel, buf, true, es); @@ -1780,7 +1782,7 @@ ExplainPropertyInteger(const char *qlabel, int value, ExplainState *es) static void ExplainPropertyLong(const char *qlabel, long value, ExplainState *es) { - char buf[32]; + char buf[32]; snprintf(buf, sizeof(buf), "%ld", value); ExplainProperty(qlabel, buf, true, es); @@ -1794,7 +1796,7 @@ static void ExplainPropertyFloat(const char *qlabel, double value, int ndigits, ExplainState *es) { - char buf[256]; + char buf[256]; snprintf(buf, sizeof(buf), "%.*f", ndigits, value); ExplainProperty(qlabel, buf, true, es); @@ -1837,8 +1839,8 @@ ExplainOpenGroup(const char *objtype, const char *labelname, /* * In JSON format, the grouping_stack is an integer list. 0 means * we've emitted nothing at this grouping level, 1 means we've - * emitted something (and so the next item needs a comma). - * See ExplainJSONLineEnding(). + * emitted something (and so the next item needs a comma). See + * ExplainJSONLineEnding(). */ es->grouping_stack = lcons_int(0, es->grouping_stack); es->indent++; @@ -1966,7 +1968,7 @@ ExplainBeginOutput(ExplainState *es) case EXPLAIN_FORMAT_XML: appendStringInfoString(es->str, - "<explain xmlns=\"http://www.postgresql.org/2009/explain\">\n"); + "<explain xmlns=\"http://www.postgresql.org/2009/explain\">\n"); es->indent++; break; @@ -2065,7 +2067,7 @@ ExplainXMLTag(const char *tagname, int flags, ExplainState *es) /* * Emit a JSON line ending. * - * JSON requires a comma after each property but the last. To facilitate this, + * JSON requires a comma after each property but the last. To facilitate this, * in JSON format, the text emitted for each property begins just prior to the * preceding line-break (and comma, if applicable). */ @@ -2086,7 +2088,7 @@ ExplainJSONLineEnding(ExplainState *es) * YAML lines are ordinarily indented by two spaces per indentation level. * The text emitted for each property begins just prior to the preceding * line-break, except for the first property in an unlabelled group, for which - * it begins immediately after the "- " that introduces the group. The first + * it begins immediately after the "- " that introduces the group. The first * property of the group appears on the same line as the opening "- ". */ static void diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 3de1a9b0caa..26a3a52efc3 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.117 2010/02/17 04:19:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.118 2010/02/26 02:00:39 momjian Exp $ * * DESCRIPTION * These routines take the parse tree and pick out the @@ -314,8 +314,8 @@ examine_parameter_list(List *parameters, Oid languageOid, strcmp(prevfp->name, fp->name) == 0) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("parameter name \"%s\" used more than once", - fp->name))); + errmsg("parameter name \"%s\" used more than once", + fp->name))); } paramNames[i] = CStringGetTextDatum(fp->name); @@ -2019,8 +2019,8 @@ ExecuteDoStmt(DoStmt *stmt) if (!OidIsValid(laninline)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("language \"%s\" does not support inline code execution", - NameStr(languageStruct->lanname)))); + errmsg("language \"%s\" does not support inline code execution", + NameStr(languageStruct->lanname)))); ReleaseSysCache(languageTuple); diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index dee14d57f65..380eca12877 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.193 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.194 2010/02/26 02:00:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -310,8 +310,8 @@ DefineIndex(RangeVar *heapRelation, if (exclusionOpNames != NIL && !OidIsValid(accessMethodForm->amgettuple)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("access method \"%s\" does not support exclusion constraints", - accessMethodName))); + errmsg("access method \"%s\" does not support exclusion constraints", + accessMethodName))); amcanorder = accessMethodForm->amcanorder; amoptions = accessMethodForm->amoptions; @@ -460,7 +460,7 @@ DefineIndex(RangeVar *heapRelation, else { elog(ERROR, "unknown constraint type"); - constraint_type = NULL; /* keep compiler quiet */ + constraint_type = NULL; /* keep compiler quiet */ } ereport(NOTICE, @@ -476,8 +476,8 @@ DefineIndex(RangeVar *heapRelation, heap_close(rel, NoLock); /* - * Make the catalog entries for the index, including constraints. - * Then, if not skip_build || concurrent, actually build the index. + * Make the catalog entries for the index, including constraints. Then, if + * not skip_build || concurrent, actually build the index. */ indexRelationId = index_create(relationId, indexRelationName, indexRelationId, @@ -494,10 +494,10 @@ DefineIndex(RangeVar *heapRelation, /* * For a concurrent build, it's important to make the catalog entries - * visible to other transactions before we start to build the index. - * That will prevent them from making incompatible HOT updates. The new - * index will be marked not indisready and not indisvalid, so that no one - * else tries to either insert into it or use it for queries. + * visible to other transactions before we start to build the index. That + * will prevent them from making incompatible HOT updates. The new index + * will be marked not indisready and not indisvalid, so that no one else + * tries to either insert into it or use it for queries. * * We must commit our current transaction so that the index becomes * visible; then start another. Note that all the data structures we just @@ -835,7 +835,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo, /* Allocate space for exclusion operator info, if needed */ if (exclusionOpNames) { - int ncols = list_length(attList); + int ncols = list_length(attList); Assert(list_length(exclusionOpNames) == ncols); indexInfo->ii_ExclusionOps = (Oid *) palloc(sizeof(Oid) * ncols); @@ -941,10 +941,10 @@ ComputeIndexAttrs(IndexInfo *indexInfo, */ if (nextExclOp) { - List *opname = (List *) lfirst(nextExclOp); - Oid opid; - Oid opfamily; - int strat; + List *opname = (List *) lfirst(nextExclOp); + Oid opid; + Oid opfamily; + int strat; /* * Find the operator --- it must accept the column datatype @@ -971,7 +971,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo, strat = get_op_opfamily_strategy(opid, opfamily); if (strat == 0) { - HeapTuple opftuple; + HeapTuple opftuple; Form_pg_opfamily opfform; /* @@ -1433,7 +1433,7 @@ ChooseIndexNameAddition(List *colnames) const char *name = (const char *) lfirst(lc); if (buflen > 0) - buf[buflen++] = '_'; /* insert _ between names */ + buf[buflen++] = '_'; /* insert _ between names */ /* * At this point we have buflen <= NAMEDATALEN. name should be less @@ -1449,7 +1449,7 @@ ChooseIndexNameAddition(List *colnames) /* * Select the actual names to be used for the columns of an index, given the - * list of IndexElems for the columns. This is mostly about ensuring the + * list of IndexElems for the columns. This is mostly about ensuring the * names are unique so we don't get a conflicting-attribute-names error. * * Returns a List of plain strings (char *, not String nodes). @@ -1470,11 +1470,11 @@ ChooseIndexColumnNames(List *indexElems) /* Get the preliminary name from the IndexElem */ if (ielem->indexcolname) - origname = ielem->indexcolname; /* caller-specified name */ + origname = ielem->indexcolname; /* caller-specified name */ else if (ielem->name) - origname = ielem->name; /* simple column reference */ + origname = ielem->name; /* simple column reference */ else - origname = "expr"; /* default name for expression */ + origname = "expr"; /* default name for expression */ /* If it conflicts with any previous column, tweak it */ curname = origname; diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c index 31096e0beb6..34d657c0312 100644 --- a/src/backend/commands/lockcmds.c +++ b/src/backend/commands/lockcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.28 2010/02/20 21:24:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.29 2010/02/26 02:00:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,11 +48,10 @@ LockTableCommand(LockStmt *lockstmt) reloid = RangeVarGetRelid(relation, false); /* - * During recovery we only accept these variations: - * LOCK TABLE foo IN ACCESS SHARE MODE - * LOCK TABLE foo IN ROW SHARE MODE - * LOCK TABLE foo IN ROW EXCLUSIVE MODE - * This test must match the restrictions defined in LockAcquire() + * During recovery we only accept these variations: LOCK TABLE foo IN + * ACCESS SHARE MODE LOCK TABLE foo IN ROW SHARE MODE LOCK TABLE foo + * IN ROW EXCLUSIVE MODE This test must match the restrictions defined + * in LockAcquire() */ if (lockstmt->mode > RowExclusiveLock) PreventCommandDuringRecovery("LOCK TABLE"); diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 34f33670c3e..8292ae1f777 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.90 2010/02/23 22:51:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.91 2010/02/26 02:00:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -149,8 +149,8 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) } /* - * Likewise for the anonymous block handler, if required; - * but we don't care about its return type. + * Likewise for the anonymous block handler, if required; but we don't + * care about its return type. */ if (pltemplate->tmplinline) { @@ -161,17 +161,17 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) { inlineOid = ProcedureCreate(pltemplate->tmplinline, PG_CATALOG_NAMESPACE, - false, /* replace */ - false, /* returnsSet */ + false, /* replace */ + false, /* returnsSet */ VOIDOID, ClanguageId, F_FMGR_C_VALIDATOR, pltemplate->tmplinline, pltemplate->tmpllibrary, - false, /* isAgg */ - false, /* isWindowFunc */ - false, /* security_definer */ - true, /* isStrict */ + false, /* isAgg */ + false, /* isWindowFunc */ + false, /* security_definer */ + true, /* isStrict */ PROVOLATILE_VOLATILE, buildoidvector(funcargtypes, 1), PointerGetDatum(NULL), @@ -209,7 +209,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) false, /* isAgg */ false, /* isWindowFunc */ false, /* security_definer */ - true, /* isStrict */ + true, /* isStrict */ PROVOLATILE_VOLATILE, buildoidvector(funcargtypes, 1), PointerGetDatum(NULL), diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index 13574938138..b30fdce73d0 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.56 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.57 2010/02/26 02:00:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,7 +92,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString) */ if (saved_uid != owner_uid) SetUserIdAndSecContext(owner_uid, - save_sec_context | SECURITY_LOCAL_USERID_CHANGE); + save_sec_context | SECURITY_LOCAL_USERID_CHANGE); /* Create the schema's namespace */ namespaceId = NamespaceCreate(schemaName, owner_uid); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 228304562da..c2360e2d84e 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.326 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.327 2010/02/26 02:00:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -304,9 +304,9 @@ static void ATAddCheckConstraint(List **wqueue, static void ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, Constraint *fkconstraint); static void ATExecDropConstraint(Relation rel, const char *constrName, - DropBehavior behavior, - bool recurse, bool recursing, - bool missing_ok); + DropBehavior behavior, + bool recurse, bool recursing, + bool missing_ok); static void ATPrepAlterColumnType(List **wqueue, AlteredTableInfo *tab, Relation rel, bool recurse, bool recursing, @@ -974,12 +974,11 @@ ExecuteTruncate(TruncateStmt *stmt) Relation rel = (Relation) lfirst(cell); /* - * Normally, we need a transaction-safe truncation here. However, - * if the table was either created in the current (sub)transaction - * or has a new relfilenode in the current (sub)transaction, then - * we can just truncate it in-place, because a rollback would - * cause the whole table or the current physical file to be - * thrown away anyway. + * Normally, we need a transaction-safe truncation here. However, if + * the table was either created in the current (sub)transaction or has + * a new relfilenode in the current (sub)transaction, then we can just + * truncate it in-place, because a rollback would cause the whole + * table or the current physical file to be thrown away anyway. */ if (rel->rd_createSubid == mySubid || rel->rd_newRelfilenodeSubid == mySubid) @@ -1112,7 +1111,7 @@ truncate_check_rel(Relation rel) /* * storage_name - * returns the name corresponding to a typstorage/attstorage enum value + * returns the name corresponding to a typstorage/attstorage enum value */ static const char * storage_name(char c) @@ -1201,7 +1200,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, int parentsWithOids = 0; bool have_bogus_defaults = false; int child_attno; - static Node bogus_marker = { 0 }; /* marks conflicting defaults */ + static Node bogus_marker = {0}; /* marks conflicting defaults */ /* * Check for and reject tables with too many columns. We perform this @@ -1234,10 +1233,11 @@ MergeAttributes(List *schema, List *supers, bool istemp, ListCell *prev = entry; if (coldef->typeName == NULL) + /* - * Typed table column option that does not belong to a - * column from the type. This works because the columns - * from the type come first in the list. + * Typed table column option that does not belong to a column from + * the type. This works because the columns from the type come + * first in the list. */ ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), @@ -1247,14 +1247,16 @@ MergeAttributes(List *schema, List *supers, bool istemp, while (rest != NULL) { ColumnDef *restdef = lfirst(rest); - ListCell *next = lnext(rest); /* need to save it in case we delete it */ + ListCell *next = lnext(rest); /* need to save it in case we + * delete it */ if (strcmp(coldef->colname, restdef->colname) == 0) { if (coldef->is_from_type) { - /* merge the column options into the column from - * the type */ + /* + * merge the column options into the column from the type + */ coldef->is_not_null = restdef->is_not_null; coldef->raw_default = restdef->raw_default; coldef->cooked_default = restdef->cooked_default; @@ -1391,11 +1393,11 @@ MergeAttributes(List *schema, List *supers, bool istemp, else if (def->storage != attribute->attstorage) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("inherited column \"%s\" has a storage parameter conflict", - attributeName), - errdetail("%s versus %s", - storage_name(def->storage), - storage_name(attribute->attstorage)))); + errmsg("inherited column \"%s\" has a storage parameter conflict", + attributeName), + errdetail("%s versus %s", + storage_name(def->storage), + storage_name(attribute->attstorage)))); def->inhcount++; /* Merge of NOT NULL constraints = OR 'em together */ @@ -1563,11 +1565,11 @@ MergeAttributes(List *schema, List *supers, bool istemp, else if (newdef->storage != 0 && def->storage != newdef->storage) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("column \"%s\" has a storage parameter conflict", - attributeName), - errdetail("%s versus %s", - storage_name(def->storage), - storage_name(newdef->storage)))); + errmsg("column \"%s\" has a storage parameter conflict", + attributeName), + errdetail("%s versus %s", + storage_name(def->storage), + storage_name(newdef->storage)))); /* Mark the column as locally defined */ def->is_local = true; @@ -1978,8 +1980,10 @@ renameatt(Oid myrelid, */ if (recurse) { - List *child_oids, *child_numparents; - ListCell *lo, *li; + List *child_oids, + *child_numparents; + ListCell *lo, + *li; /* * we need the number of parents for each child so that the recursive @@ -2039,13 +2043,13 @@ renameatt(Oid myrelid, oldattname))); /* - * if the attribute is inherited, forbid the renaming. if this is a + * if the attribute is inherited, forbid the renaming. if this is a * top-level call to renameatt(), then expected_parents will be 0, so the * effect of this code will be to prohibit the renaming if the attribute * is inherited at all. if this is a recursive call to renameatt(), * expected_parents will be the number of parents the current relation has - * within the inheritance hierarchy being processed, so we'll prohibit - * the renaming only if there are additional parents from elsewhere. + * within the inheritance hierarchy being processed, so we'll prohibit the + * renaming only if there are additional parents from elsewhere. */ if (attform->attinhcount > expected_parents) ereport(ERROR, @@ -2861,9 +2865,9 @@ ATRewriteTables(List **wqueue) OldHeap = heap_open(tab->relid, NoLock); /* - * We don't support rewriting of system catalogs; there are - * too many corner cases and too little benefit. In particular - * this is certainly not going to work for mapped catalogs. + * We don't support rewriting of system catalogs; there are too + * many corner cases and too little benefit. In particular this + * is certainly not going to work for mapped catalogs. */ if (IsSystemRelation(OldHeap)) ereport(ERROR, @@ -3007,11 +3011,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) newrel = NULL; /* - * Prepare a BulkInsertState and options for heap_insert. Because - * we're building a new heap, we can skip WAL-logging and fsync it - * to disk at the end instead (unless WAL-logging is required for - * archiving or streaming replication). The FSM is empty too, - * so don't bother using it. + * Prepare a BulkInsertState and options for heap_insert. Because we're + * building a new heap, we can skip WAL-logging and fsync it to disk at + * the end instead (unless WAL-logging is required for archiving or + * streaming replication). The FSM is empty too, so don't bother using it. */ if (newrel) { @@ -3255,7 +3258,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) /* If we skipped writing WAL, then we need to sync the heap. */ if (hi_options & HEAP_INSERT_SKIP_WAL) { - char reason[NAMEDATALEN + 30]; + char reason[NAMEDATALEN + 30]; + snprintf(reason, sizeof(reason), "table rewrite on \"%s\"", RelationGetRelationName(newrel)); XLogReportUnloggedStatement(reason); @@ -4205,7 +4209,7 @@ ATExecSetOptions(Relation rel, const char *colName, Node *options, /* Generate new proposed attoptions (text array) */ Assert(IsA(options, List)); datum = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions, - &isnull); + &isnull); newOptions = transformRelOptions(isnull ? (Datum) 0 : datum, (List *) options, NULL, NULL, false, isReset); @@ -4338,8 +4342,10 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName, * get the number of the attribute */ tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName); - if (!HeapTupleIsValid(tuple)){ - if (!missing_ok){ + if (!HeapTupleIsValid(tuple)) + { + if (!missing_ok) + { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", @@ -4574,9 +4580,10 @@ ATExecAddConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, break; case CONSTR_FOREIGN: + /* - * Note that we currently never recurse for FK constraints, so - * the "recurse" flag is silently ignored. + * Note that we currently never recurse for FK constraints, so the + * "recurse" flag is silently ignored. * * Assign or validate constraint name */ @@ -4595,7 +4602,7 @@ ATExecAddConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel, else newConstraint->conname = ChooseConstraintName(RelationGetRelationName(rel), - strVal(linitial(newConstraint->fk_attrs)), + strVal(linitial(newConstraint->fk_attrs)), "fkey", RelationGetNamespace(rel), NIL); @@ -5093,9 +5100,9 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, if (indexStruct->indisprimary) { /* - * Refuse to use a deferrable primary key. This is per SQL spec, - * and there would be a lot of interesting semantic problems if - * we tried to allow it. + * Refuse to use a deferrable primary key. This is per SQL spec, + * and there would be a lot of interesting semantic problems if we + * tried to allow it. */ if (!indexStruct->indimmediate) ereport(ERROR, @@ -5243,15 +5250,15 @@ transformFkeyCheckAttrs(Relation pkrel, } /* - * Refuse to use a deferrable unique/primary key. This is per - * SQL spec, and there would be a lot of interesting semantic - * problems if we tried to allow it. + * Refuse to use a deferrable unique/primary key. This is per SQL + * spec, and there would be a lot of interesting semantic problems + * if we tried to allow it. */ if (found && !indexStruct->indimmediate) { /* - * Remember that we found an otherwise matching index, so - * that we can generate a more appropriate error message. + * Remember that we found an otherwise matching index, so that + * we can generate a more appropriate error message. */ found_deferrable = true; found = false; @@ -5623,12 +5630,14 @@ ATExecDropConstraint(Relation rel, const char *constrName, systable_endscan(scan); - if (!found){ - if (!missing_ok){ + if (!found) + { + if (!missing_ok) + { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("constraint \"%s\" of relation \"%s\" does not exist", - constrName, RelationGetRelationName(rel)))); + errmsg("constraint \"%s\" of relation \"%s\" does not exist", + constrName, RelationGetRelationName(rel)))); } else { @@ -5639,6 +5648,7 @@ ATExecDropConstraint(Relation rel, const char *constrName, return; } } + /* * Propagate to children as appropriate. Unlike most other ALTER * routines, we have to do this one level of recursion at a time; we can't @@ -6997,12 +7007,13 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace) heap_close(pg_class, RowExclusiveLock); /* - * Write an XLOG UNLOGGED record if WAL-logging was skipped because - * WAL archiving is not enabled. + * Write an XLOG UNLOGGED record if WAL-logging was skipped because WAL + * archiving is not enabled. */ if (!XLogIsNeeded() && !rel->rd_istemp) { - char reason[NAMEDATALEN + 40]; + char reason[NAMEDATALEN + 40]; + snprintf(reason, sizeof(reason), "ALTER TABLE SET TABLESPACE on \"%s\"", RelationGetRelationName(rel)); @@ -7039,8 +7050,8 @@ copy_relation_data(SMgrRelation src, SMgrRelation dst, * enabled AND it's not a temp rel. * * Note: If you change the conditions here, update the conditions in - * ATExecSetTableSpace() for when an XLOG UNLOGGED record is written - * to match. + * ATExecSetTableSpace() for when an XLOG UNLOGGED record is written to + * match. */ use_wal = XLogIsNeeded() && !istemp; diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index 32c06127912..5dcb3a60ab9 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -40,7 +40,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.73 2010/02/17 04:19:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.74 2010/02/26 02:00:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -85,7 +85,7 @@ char *temp_tablespaces = NULL; static void create_tablespace_directories(const char *location, - const Oid tablespaceoid); + const Oid tablespaceoid); static bool destroy_tablespace_directories(Oid tablespaceoid, bool redo); @@ -159,8 +159,8 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo) /* * Parent directories are missing during WAL replay, so - * continue by creating simple parent directories - * rather than a symlink. + * continue by creating simple parent directories rather + * than a symlink. */ /* create two parents up if not exist */ @@ -272,7 +272,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) /* * Check that location isn't too long. Remember that we're going to append - * 'PG_XXX/<dboid>/<relid>.<nnn>'. FYI, we never actually reference the + * 'PG_XXX/<dboid>/<relid>.<nnn>'. FYI, we never actually reference the * whole path, but mkdir() uses the first two parts. */ if (strlen(location) + 1 + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + @@ -535,13 +535,13 @@ DropTableSpace(DropTableSpaceStmt *stmt) static void create_tablespace_directories(const char *location, const Oid tablespaceoid) { - char *linkloc = palloc(OIDCHARS + OIDCHARS + 1); - char *location_with_version_dir = palloc(strlen(location) + 1 + - strlen(TABLESPACE_VERSION_DIRECTORY) + 1); + char *linkloc = palloc(OIDCHARS + OIDCHARS + 1); + char *location_with_version_dir = palloc(strlen(location) + 1 + + strlen(TABLESPACE_VERSION_DIRECTORY) + 1); sprintf(linkloc, "pg_tblspc/%u", tablespaceoid); sprintf(location_with_version_dir, "%s/%s", location, - TABLESPACE_VERSION_DIRECTORY); + TABLESPACE_VERSION_DIRECTORY); /* * Attempt to coerce target directory to safe permissions. If this fails, @@ -556,14 +556,14 @@ create_tablespace_directories(const char *location, const Oid tablespaceoid) location))); else ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not set permissions on directory \"%s\": %m", - location))); + (errcode_for_file_access(), + errmsg("could not set permissions on directory \"%s\": %m", + location))); } /* - * The creation of the version directory prevents more than one - * tablespace in a single location. + * The creation of the version directory prevents more than one tablespace + * in a single location. */ if (mkdir(location_with_version_dir, S_IRWXU) < 0) { @@ -575,8 +575,8 @@ create_tablespace_directories(const char *location, const Oid tablespaceoid) else ereport(ERROR, (errcode_for_file_access(), - errmsg("could not create directory \"%s\": %m", - location_with_version_dir))); + errmsg("could not create directory \"%s\": %m", + location_with_version_dir))); } /* @@ -613,9 +613,9 @@ destroy_tablespace_directories(Oid tablespaceoid, bool redo) struct stat st; linkloc_with_version_dir = palloc(9 + 1 + OIDCHARS + 1 + - strlen(TABLESPACE_VERSION_DIRECTORY)); + strlen(TABLESPACE_VERSION_DIRECTORY)); sprintf(linkloc_with_version_dir, "pg_tblspc/%u/%s", tablespaceoid, - TABLESPACE_VERSION_DIRECTORY); + TABLESPACE_VERSION_DIRECTORY); /* * Check if the tablespace still contains any files. We try to rmdir each @@ -690,12 +690,12 @@ destroy_tablespace_directories(Oid tablespaceoid, bool redo) (errcode_for_file_access(), errmsg("could not remove directory \"%s\": %m", linkloc_with_version_dir))); - + /* - * Try to remove the symlink. We must however deal with the - * possibility that it's a directory instead of a symlink --- this could - * happen during WAL replay (see TablespaceCreateDbspace), and it is also - * the case on Windows where junction points lstat() as directories. + * Try to remove the symlink. We must however deal with the possibility + * that it's a directory instead of a symlink --- this could happen during + * WAL replay (see TablespaceCreateDbspace), and it is also the case on + * Windows where junction points lstat() as directories. */ linkloc = pstrdup(linkloc_with_version_dir); get_parent_directory(linkloc); @@ -948,7 +948,7 @@ AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("tablespace \"%s\" does not exist", - stmt->tablespacename))); + stmt->tablespacename))); /* Must be owner of the existing object */ if (!pg_tablespace_ownercheck(HeapTupleGetOid(tup), GetUserId())) @@ -1366,30 +1366,30 @@ tblspc_redo(XLogRecPtr lsn, XLogRecord *record) xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) XLogRecGetData(record); /* - * If we issued a WAL record for a drop tablespace it is - * because there were no files in it at all. That means that - * no permanent objects can exist in it at this point. + * If we issued a WAL record for a drop tablespace it is because there + * were no files in it at all. That means that no permanent objects + * can exist in it at this point. * - * It is possible for standby users to be using this tablespace - * as a location for their temporary files, so if we fail to - * remove all files then do conflict processing and try again, - * if currently enabled. + * It is possible for standby users to be using this tablespace as a + * location for their temporary files, so if we fail to remove all + * files then do conflict processing and try again, if currently + * enabled. */ if (!destroy_tablespace_directories(xlrec->ts_id, true)) { ResolveRecoveryConflictWithTablespace(xlrec->ts_id); /* - * If we did recovery processing then hopefully the - * backends who wrote temp files should have cleaned up and - * exited by now. So lets recheck before we throw an error. - * If !process_conflicts then this will just fail again. + * If we did recovery processing then hopefully the backends who + * wrote temp files should have cleaned up and exited by now. So + * lets recheck before we throw an error. If !process_conflicts + * then this will just fail again. */ if (!destroy_tablespace_directories(xlrec->ts_id, true)) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("tablespace %u is not empty", - xlrec->ts_id))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("tablespace %u is not empty", + xlrec->ts_id))); } } else diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 49c913c00bb..aef7838eb6e 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.261 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.262 2010/02/26 02:00:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -117,7 +117,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, { int16 tgtype; int ncolumns; - int2 *columns; + int2 *columns; int2vector *tgattr; Node *whenClause; List *whenRtable; @@ -196,10 +196,10 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, */ if (stmt->whenClause) { - ParseState *pstate; + ParseState *pstate; RangeTblEntry *rte; - List *varList; - ListCell *lc; + List *varList; + ListCell *lc; /* Set up a pstate to parse with */ pstate = make_parsestate(NULL); @@ -230,7 +230,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, if (pstate->p_hasSubLinks) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use subquery in trigger WHEN condition"))); + errmsg("cannot use subquery in trigger WHEN condition"))); if (pstate->p_hasAggs) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), @@ -238,7 +238,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, if (pstate->p_hasWindowFuncs) ereport(ERROR, (errcode(ERRCODE_WINDOWING_ERROR), - errmsg("cannot use window function in trigger WHEN condition"))); + errmsg("cannot use window function in trigger WHEN condition"))); /* * Check for disallowed references to OLD/NEW. @@ -364,11 +364,11 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, stmt->deferrable, stmt->initdeferred, RelationGetRelid(rel), - NULL, /* no conkey */ + NULL, /* no conkey */ 0, - InvalidOid, /* no domain */ - InvalidOid, /* no index */ - InvalidOid, /* no foreign key */ + InvalidOid, /* no domain */ + InvalidOid, /* no index */ + InvalidOid, /* no foreign key */ NULL, NULL, NULL, @@ -382,7 +382,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, NULL, NULL, true, /* islocal */ - 0); /* inhcount */ + 0); /* inhcount */ } /* @@ -394,9 +394,9 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, trigoid = GetNewOid(tgrel); /* - * If trigger is internally generated, modify the provided trigger name - * to ensure uniqueness by appending the trigger OID. (Callers will - * usually supply a simple constant trigger name in these cases.) + * If trigger is internally generated, modify the provided trigger name to + * ensure uniqueness by appending the trigger OID. (Callers will usually + * supply a simple constant trigger name in these cases.) */ if (isInternal) { @@ -413,8 +413,8 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, /* * Scan pg_trigger for existing triggers on relation. We do this only to * give a nice error message if there's already a trigger of the same - * name. (The unique index on tgrelid/tgname would complain anyway.) - * We can skip this for internally generated triggers, since the name + * name. (The unique index on tgrelid/tgname would complain anyway.) We + * can skip this for internally generated triggers, since the name * modification above should be sufficient. * * NOTE that this is cool only because we have AccessExclusiveLock on the @@ -435,8 +435,8 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, if (namestrcmp(&(pg_trigger->tgname), trigname) == 0) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("trigger \"%s\" for relation \"%s\" already exists", - trigname, stmt->relation->relname))); + errmsg("trigger \"%s\" for relation \"%s\" already exists", + trigname, stmt->relation->relname))); } systable_endscan(tgscan); } @@ -515,17 +515,17 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, columns = (int2 *) palloc(ncolumns * sizeof(int2)); foreach(cell, stmt->columns) { - char *name = strVal(lfirst(cell)); - int2 attnum; - int j; + char *name = strVal(lfirst(cell)); + int2 attnum; + int j; - /* Lookup column name. System columns are not allowed */ + /* Lookup column name. System columns are not allowed */ attnum = attnameAttNum(rel, name, false); if (attnum == InvalidAttrNumber) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" of relation \"%s\" does not exist", - name, RelationGetRelationName(rel)))); + errmsg("column \"%s\" of relation \"%s\" does not exist", + name, RelationGetRelationName(rel)))); /* Check for duplicates */ for (j = i - 1; j >= 0; j--) @@ -624,7 +624,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, else { /* - * User CREATE TRIGGER, so place dependencies. We make trigger be + * User CREATE TRIGGER, so place dependencies. We make trigger be * auto-dropped if its relation is dropped or if the FK relation is * dropped. (Auto drop is compatible with our pre-7.3 behavior.) */ @@ -641,6 +641,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, } /* Not possible to have an index dependency in this case */ Assert(!OidIsValid(indexOid)); + /* * If it's a user-specified constraint trigger, make the constraint * internally dependent on the trigger instead of vice versa. @@ -657,7 +658,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, /* If column-specific trigger, add normal dependencies on columns */ if (columns != NULL) { - int i; + int i; referenced.classId = RelationRelationId; referenced.objectId = RelationGetRelid(rel); @@ -669,8 +670,8 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, } /* - * If it has a WHEN clause, add dependencies on objects mentioned in - * the expression (eg, functions, as well as any columns used). + * If it has a WHEN clause, add dependencies on objects mentioned in the + * expression (eg, functions, as well as any columns used). */ if (whenClause != NULL) recordDependencyOnExpr(&myself, whenClause, whenRtable, @@ -1714,9 +1715,9 @@ equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2) * comparison; so we just compare corresponding slots of the two sets. * * Note: comparing the stringToNode forms of the WHEN clauses means that - * parse column locations will affect the result. This is okay as long - * as this function is only used for detecting exact equality, as for - * example in checking for staleness of a cache entry. + * parse column locations will affect the result. This is okay as long as + * this function is only used for detecting exact equality, as for example + * in checking for staleness of a cache entry. */ if (trigdesc1 != NULL) { @@ -1763,11 +1764,11 @@ equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2) if (strcmp(trig1->tgargs[j], trig2->tgargs[j]) != 0) return false; if (trig1->tgqual == NULL && trig2->tgqual == NULL) - /* ok */ ; + /* ok */ ; else if (trig1->tgqual == NULL || trig2->tgqual == NULL) return false; else if (strcmp(trig1->tgqual, trig2->tgqual) != 0) - return false; + return false; } } else if (trigdesc2 != NULL) @@ -2114,7 +2115,7 @@ ExecBSUpdateTriggers(EState *estate, ResultRelInfo *relinfo) int *tgindx; int i; TriggerData LocTriggerData; - Bitmapset *modifiedCols; + Bitmapset *modifiedCols; trigdesc = relinfo->ri_TrigDesc; @@ -2185,7 +2186,7 @@ ExecBRUpdateTriggers(EState *estate, EPQState *epqstate, HeapTuple intuple = newtuple; TupleTableSlot *newSlot; int i; - Bitmapset *modifiedCols; + Bitmapset *modifiedCols; trigtuple = GetTupleForTrigger(estate, epqstate, relinfo, tupleid, &newSlot); @@ -2381,9 +2382,9 @@ ltrmark:; /* * EvalPlanQual already locked the tuple, but we - * re-call heap_lock_tuple anyway as an easy way - * of re-fetching the correct tuple. Speed is - * hardly a criterion in this path anyhow. + * re-call heap_lock_tuple anyway as an easy way of + * re-fetching the correct tuple. Speed is hardly a + * criterion in this path anyhow. */ goto ltrmark; } @@ -2485,8 +2486,8 @@ TriggerEnabled(EState *estate, ResultRelInfo *relinfo, Assert(estate != NULL); /* - * trigger is an element of relinfo->ri_TrigDesc->triggers[]; - * find the matching element of relinfo->ri_TrigWhenExprs[] + * trigger is an element of relinfo->ri_TrigDesc->triggers[]; find the + * matching element of relinfo->ri_TrigWhenExprs[] */ i = trigger - relinfo->ri_TrigDesc->triggers; predicate = &relinfo->ri_TrigWhenExprs[i]; @@ -2498,7 +2499,7 @@ TriggerEnabled(EState *estate, ResultRelInfo *relinfo, */ if (*predicate == NIL) { - Node *tgqual; + Node *tgqual; oldContext = MemoryContextSwitchTo(estate->es_query_cxt); tgqual = stringToNode(trigger->tgqual); @@ -3895,9 +3896,9 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) * Handle SET CONSTRAINTS constraint-name [, ...] * * First, identify all the named constraints and make a list of their - * OIDs. Since, unlike the SQL spec, we allow multiple constraints - * of the same name within a schema, the specifications are not - * necessarily unique. Our strategy is to target all matching + * OIDs. Since, unlike the SQL spec, we allow multiple constraints of + * the same name within a schema, the specifications are not + * necessarily unique. Our strategy is to target all matching * constraints within the first search-path schema that has any * matches, but disregard matches in schemas beyond the first match. * (This is a bit odd but it's the historical behavior.) @@ -4025,9 +4026,9 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup); /* - * Silently skip triggers that are marked as non-deferrable - * in pg_trigger. This is not an error condition, since - * a deferrable RI constraint may have some non-deferrable + * Silently skip triggers that are marked as non-deferrable in + * pg_trigger. This is not an error condition, since a + * deferrable RI constraint may have some non-deferrable * actions. */ if (pg_trigger->tgdeferrable) @@ -4198,7 +4199,7 @@ AfterTriggerPendingOnRel(Oid relid) * be fired for an event. * * NOTE: this is called whenever there are any triggers associated with - * the event (even if they are disabled). This function decides which + * the event (even if they are disabled). This function decides which * triggers actually need to be queued. * ---------- */ @@ -4217,9 +4218,9 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo, int *tgindx; /* - * Check state. We use normal tests not Asserts because it is possible - * to reach here in the wrong state given misconfigured RI triggers, - * in particular deferring a cascade action trigger. + * Check state. We use normal tests not Asserts because it is possible to + * reach here in the wrong state given misconfigured RI triggers, in + * particular deferring a cascade action trigger. */ if (afterTriggers == NULL) elog(ERROR, "AfterTriggerSaveEvent() called outside of transaction"); @@ -4363,9 +4364,9 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo, } /* - * If the trigger is a deferred unique constraint check trigger, - * only queue it if the unique constraint was potentially violated, - * which we know from index insertion time. + * If the trigger is a deferred unique constraint check trigger, only + * queue it if the unique constraint was potentially violated, which + * we know from index insertion time. */ if (trigger->tgfoid == F_UNIQUE_KEY_RECHECK) { diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index 86d631a0ad7..8a85e79ea65 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.147 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.148 2010/02/26 02:00:40 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -74,7 +74,7 @@ typedef struct /* atts[] is of allocated length RelationGetNumberOfAttributes(rel) */ } RelToCheck; -Oid binary_upgrade_next_pg_type_array_oid = InvalidOid; +Oid binary_upgrade_next_pg_type_array_oid = InvalidOid; static Oid findTypeInputFunction(List *procname, Oid typeOid); static Oid findTypeOutputFunction(List *procname, Oid typeOid); @@ -527,12 +527,12 @@ DefineType(List *names, List *parameters) * now have TypeCreate do all the real work. */ typoid = - /* - * The pg_type.oid is stored in user tables as array elements - * (base types) in ArrayType and in composite types in - * DatumTupleFields. This oid must be preserved by binary - * upgrades. - */ + + /* + * The pg_type.oid is stored in user tables as array elements (base types) + * in ArrayType and in composite types in DatumTupleFields. This oid must + * be preserved by binary upgrades. + */ TypeCreate(InvalidOid, /* no predetermined type OID */ typeName, /* type name */ typeNamespace, /* namespace */ @@ -986,7 +986,7 @@ DefineDomain(CreateDomainStmt *stmt) case CONSTR_EXCLUSION: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("exclusion constraints not possible for domains"))); + errmsg("exclusion constraints not possible for domains"))); break; case CONSTR_FOREIGN: @@ -1466,7 +1466,7 @@ findTypeAnalyzeFunction(List *procname, Oid typeOid) Oid AssignTypeArrayOid(void) { - Oid type_array_oid; + Oid type_array_oid; /* Pre-assign the type's array OID for use in pg_type.typarray */ if (OidIsValid(binary_upgrade_next_pg_type_array_oid)) @@ -1525,10 +1525,10 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist) createStmt->tablespacename = NULL; /* - * Check for collision with an existing type name. If there is one - * and it's an autogenerated array, we can rename it out of the - * way. This check is here mainly to get a better error message - * about a "type" instead of below about a "relation". + * Check for collision with an existing type name. If there is one and + * it's an autogenerated array, we can rename it out of the way. This + * check is here mainly to get a better error message about a "type" + * instead of below about a "relation". */ typeNamespace = RangeVarGetCreationNamespace(createStmt->relation); old_type_oid = @@ -1911,7 +1911,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint) case CONSTR_EXCLUSION: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("exclusion constraints not possible for domains"))); + errmsg("exclusion constraints not possible for domains"))); break; case CONSTR_FOREIGN: @@ -2343,7 +2343,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, ' ', ' ', ' ', - NULL, /* not an exclusion constraint */ + NULL, /* not an exclusion constraint */ expr, /* Tree form of check constraint */ ccbin, /* Binary form of check constraint */ ccsrc, /* Source form of check constraint */ diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 36711565548..cdf7dc5ef1f 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.192 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.193 2010/02/26 02:00:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -321,7 +321,7 @@ CreateRole(CreateRoleStmt *stmt) if (check_password_hook && password) (*check_password_hook) (stmt->role, password, - isMD5(password) ? PASSWORD_TYPE_MD5 : PASSWORD_TYPE_PLAINTEXT, + isMD5(password) ? PASSWORD_TYPE_MD5 : PASSWORD_TYPE_PLAINTEXT, validUntil_datum, validUntil_null); @@ -630,7 +630,7 @@ AlterRole(AlterRoleStmt *stmt) if (check_password_hook && password) (*check_password_hook) (stmt->role, password, - isMD5(password) ? PASSWORD_TYPE_MD5 : PASSWORD_TYPE_PLAINTEXT, + isMD5(password) ? PASSWORD_TYPE_MD5 : PASSWORD_TYPE_PLAINTEXT, validUntil_datum, validUntil_null); diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 5c1c48570e2..e77430e6e4e 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.409 2010/02/15 16:10:34 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.410 2010/02/26 02:00:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,7 +109,7 @@ vacuum(VacuumStmt *vacstmt, Oid relid, bool do_toast, /* * We cannot run VACUUM inside a user transaction block; if we were inside * a transaction, then our commit- and start-transaction-command calls - * would not have the intended effect! There are numerous other subtle + * would not have the intended effect! There are numerous other subtle * dependencies on this, too. * * ANALYZE (without VACUUM) can run either way. @@ -664,9 +664,9 @@ vac_update_datfrozenxid(void) heap_close(relation, RowExclusiveLock); /* - * If we were able to advance datfrozenxid, see if we can truncate pg_clog. - * Also do it if the shared XID-wrap-limit info is stale, since this - * action will update that too. + * If we were able to advance datfrozenxid, see if we can truncate + * pg_clog. Also do it if the shared XID-wrap-limit info is stale, since + * this action will update that too. */ if (dirty || ForceTransactionIdLimitUpdate()) vac_truncate_clog(newFrozenXid); @@ -944,8 +944,8 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, bool do_toast, bool for_wraparound, /* * Switch to the table owner's userid, so that any index functions are run * as that user. Also lock down security-restricted operations and - * arrange to make GUC variable changes local to this command. - * (This is unnecessary, but harmless, for lazy VACUUM.) + * arrange to make GUC variable changes local to this command. (This is + * unnecessary, but harmless, for lazy VACUUM.) */ GetUserIdAndSecContext(&save_userid, &save_sec_context); SetUserIdAndSecContext(onerel->rd_rel->relowner, diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 247cc72dd1f..1cf1ae3e593 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -29,7 +29,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.131 2010/02/09 21:43:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.132 2010/02/26 02:00:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -268,8 +268,8 @@ static void vacuum_log_cleanup_info(Relation rel, LVRelStats *vacrelstats) { /* - * No need to log changes for temp tables, they do not contain - * data visible on the standby server. + * No need to log changes for temp tables, they do not contain data + * visible on the standby server. */ if (rel->rd_istemp || !XLogIsNeeded()) return; @@ -629,7 +629,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, { lazy_record_dead_tuple(vacrelstats, &(tuple.t_self)); HeapTupleHeaderAdvanceLatestRemovedXid(tuple.t_data, - &vacrelstats->latestRemovedXid); + &vacrelstats->latestRemovedXid); tups_vacuumed += 1; } else @@ -1039,7 +1039,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) RelationTruncate(onerel, new_rel_pages); /* - * We can release the exclusive lock as soon as we have truncated. Other + * We can release the exclusive lock as soon as we have truncated. Other * backends can't safely access the relation until they have processed the * smgr invalidation that smgrtruncate sent out ... but that should happen * as part of standard invalidation processing once they acquire lock on diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 20d59f9a8c9..151299555cf 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -26,7 +26,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.347 2010/02/20 21:24:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.348 2010/02/26 02:00:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,7 +76,7 @@ static void ExecCheckRTPerms(List *rangeTable); static void ExecCheckRTEPerms(RangeTblEntry *rte); static void ExecCheckXactReadOnly(PlannedStmt *plannedstmt); static void EvalPlanQualStart(EPQState *epqstate, EState *parentestate, - Plan *planTree); + Plan *planTree); static void OpenIntoRel(QueryDesc *queryDesc); static void CloseIntoRel(QueryDesc *queryDesc); static void intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo); @@ -582,8 +582,8 @@ ExecCheckXactReadOnly(PlannedStmt *plannedstmt) /* * CREATE TABLE AS or SELECT INTO? * - * XXX should we allow this if the destination is temp? Considering - * that it would still require catalog changes, probably not. + * XXX should we allow this if the destination is temp? Considering that + * it would still require catalog changes, probably not. */ if (plannedstmt->intoClause != NULL) PreventCommandIfReadOnly(CreateCommandTag((Node *) plannedstmt)); @@ -641,8 +641,8 @@ InitPlan(QueryDesc *queryDesc, int eflags) /* * initialize result relation stuff, and open/lock the result rels. * - * We must do this before initializing the plan tree, else we might - * try to do a lock upgrade if a result rel is also a source rel. + * We must do this before initializing the plan tree, else we might try to + * do a lock upgrade if a result rel is also a source rel. */ if (plannedstmt->resultRelations) { @@ -686,8 +686,8 @@ InitPlan(QueryDesc *queryDesc, int eflags) /* * Similarly, we have to lock relations selected FOR UPDATE/FOR SHARE - * before we initialize the plan tree, else we'd be risking lock - * upgrades. While we are at it, build the ExecRowMark list. + * before we initialize the plan tree, else we'd be risking lock upgrades. + * While we are at it, build the ExecRowMark list. */ estate->es_rowMarks = NIL; foreach(l, plannedstmt->rowMarks) @@ -804,8 +804,8 @@ InitPlan(QueryDesc *queryDesc, int eflags) tupType = ExecGetResultType(planstate); /* - * Initialize the junk filter if needed. SELECT queries need a - * filter if there are any junk attrs in the top-level tlist. + * Initialize the junk filter if needed. SELECT queries need a filter if + * there are any junk attrs in the top-level tlist. */ if (operation == CMD_SELECT) { @@ -1101,9 +1101,9 @@ ExecEndPlan(PlanState *planstate, EState *estate) /* * destroy the executor's tuple table. Actually we only care about - * releasing buffer pins and tupdesc refcounts; there's no need to - * pfree the TupleTableSlots, since the containing memory context - * is about to go away anyway. + * releasing buffer pins and tupdesc refcounts; there's no need to pfree + * the TupleTableSlots, since the containing memory context is about to go + * away anyway. */ ExecResetTupleTable(estate->es_tupleTable, false); @@ -1208,8 +1208,8 @@ ExecutePlan(EState *estate, slot = ExecFilterJunk(estate->es_junkFilter, slot); /* - * If we are supposed to send the tuple somewhere, do so. - * (In practice, this is probably always the case at this point.) + * If we are supposed to send the tuple somewhere, do so. (In + * practice, this is probably always the case at this point.) */ if (sendTuples) (*dest->receiveSlot) (slot, dest); @@ -1390,8 +1390,8 @@ EvalPlanQual(EState *estate, EPQState *epqstate, EvalPlanQualBegin(epqstate, estate); /* - * Free old test tuple, if any, and store new tuple where relation's - * scan node will see it + * Free old test tuple, if any, and store new tuple where relation's scan + * node will see it */ EvalPlanQualSetTuple(epqstate, rti, copyTuple); @@ -1406,19 +1406,19 @@ EvalPlanQual(EState *estate, EPQState *epqstate, slot = EvalPlanQualNext(epqstate); /* - * If we got a tuple, force the slot to materialize the tuple so that - * it is not dependent on any local state in the EPQ query (in particular, + * If we got a tuple, force the slot to materialize the tuple so that it + * is not dependent on any local state in the EPQ query (in particular, * it's highly likely that the slot contains references to any pass-by-ref - * datums that may be present in copyTuple). As with the next step, - * this is to guard against early re-use of the EPQ query. + * datums that may be present in copyTuple). As with the next step, this + * is to guard against early re-use of the EPQ query. */ if (!TupIsNull(slot)) (void) ExecMaterializeSlot(slot); /* - * Clear out the test tuple. This is needed in case the EPQ query - * is re-used to test a tuple for a different relation. (Not clear - * that can really happen, but let's be safe.) + * Clear out the test tuple. This is needed in case the EPQ query is + * re-used to test a tuple for a different relation. (Not clear that can + * really happen, but let's be safe.) */ EvalPlanQualSetTuple(epqstate, rti, NULL); @@ -1680,8 +1680,8 @@ EvalPlanQualSetTuple(EPQState *epqstate, Index rti, HeapTuple tuple) Assert(rti > 0); /* - * free old test tuple, if any, and store new tuple where relation's - * scan node will see it + * free old test tuple, if any, and store new tuple where relation's scan + * node will see it */ if (estate->es_epqTuple[rti - 1] != NULL) heap_freetuple(estate->es_epqTuple[rti - 1]); @@ -1704,7 +1704,7 @@ EvalPlanQualGetTuple(EPQState *epqstate, Index rti) /* * Fetch the current row values for any non-locked relations that need - * to be scanned by an EvalPlanQual operation. origslot must have been set + * to be scanned by an EvalPlanQual operation. origslot must have been set * to contain the current result row (top-level row) that we need to recheck. */ void @@ -1841,7 +1841,7 @@ EvalPlanQualBegin(EPQState *epqstate, EState *parentestate) /* Recopy current values of parent parameters */ if (parentestate->es_plannedstmt->nParamExec > 0) { - int i = parentestate->es_plannedstmt->nParamExec; + int i = parentestate->es_plannedstmt->nParamExec; while (--i >= 0) { @@ -1913,7 +1913,7 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree) estate->es_param_list_info = parentestate->es_param_list_info; if (parentestate->es_plannedstmt->nParamExec > 0) { - int i = parentestate->es_plannedstmt->nParamExec; + int i = parentestate->es_plannedstmt->nParamExec; estate->es_param_exec_vals = (ParamExecData *) palloc0(i * sizeof(ParamExecData)); @@ -1929,7 +1929,7 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree) /* * Each EState must have its own es_epqScanDone state, but if we have - * nested EPQ checks they should share es_epqTuple arrays. This allows + * nested EPQ checks they should share es_epqTuple arrays. This allows * sub-rechecks to inherit the values being examined by an outer recheck. */ estate->es_epqScanDone = (bool *) palloc0(rtsize * sizeof(bool)); @@ -1954,10 +1954,10 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree) /* * Initialize private state information for each SubPlan. We must do this * before running ExecInitNode on the main query tree, since - * ExecInitSubPlan expects to be able to find these entries. - * Some of the SubPlans might not be used in the part of the plan tree - * we intend to run, but since it's not easy to tell which, we just - * initialize them all. + * ExecInitSubPlan expects to be able to find these entries. Some of the + * SubPlans might not be used in the part of the plan tree we intend to + * run, but since it's not easy to tell which, we just initialize them + * all. */ Assert(estate->es_subplanstates == NIL); foreach(l, parentestate->es_plannedstmt->subplans) @@ -1972,9 +1972,9 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree) } /* - * Initialize the private state information for all the nodes in the - * part of the plan tree we need to run. This opens files, allocates - * storage and leaves us ready to start processing tuples. + * Initialize the private state information for all the nodes in the part + * of the plan tree we need to run. This opens files, allocates storage + * and leaves us ready to start processing tuples. */ epqstate->planstate = ExecInitNode(planTree, estate, 0); @@ -2078,8 +2078,8 @@ OpenIntoRel(QueryDesc *queryDesc) Assert(into); /* - * XXX This code needs to be kept in sync with DefineRelation(). - * Maybe we should try to use that function instead. + * XXX This code needs to be kept in sync with DefineRelation(). Maybe we + * should try to use that function instead. */ /* @@ -2242,7 +2242,8 @@ CloseIntoRel(QueryDesc *queryDesc) /* If we skipped using WAL, must heap_sync before commit */ if (myState->hi_options & HEAP_INSERT_SKIP_WAL) { - char reason[NAMEDATALEN + 30]; + char reason[NAMEDATALEN + 30]; + snprintf(reason, sizeof(reason), "SELECT INTO on \"%s\"", RelationGetRelationName(myState->rel)); XLogReportUnloggedStatement(reason); diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 92be3a0a559..e381e112821 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.262 2010/02/18 18:41:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.263 2010/02/26 02:00:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -357,7 +357,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate, * We might have a nested-assignment situation, in which the * refassgnexpr is itself a FieldStore or ArrayRef that needs to * obtain and modify the previous value of the array element or slice - * being replaced. If so, we have to extract that value from the + * being replaced. If so, we have to extract that value from the * array and pass it down via the econtext's caseValue. It's safe to * reuse the CASE mechanism because there cannot be a CASE between * here and where the value would be needed, and an array assignment @@ -386,7 +386,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate, astate->refelemlength, astate->refelembyval, astate->refelemalign, - &econtext->caseValue_isNull); + &econtext->caseValue_isNull); } else { @@ -673,7 +673,7 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext, * We really only care about number of attributes and data type. * Also, we can ignore type mismatch on columns that are dropped * in the destination type, so long as (1) the physical storage - * matches or (2) the actual column value is NULL. Case (1) is + * matches or (2) the actual column value is NULL. Case (1) is * helpful in some cases involving out-of-date cached plans, while * case (2) is expected behavior in situations such as an INSERT * into a table with dropped columns (the planner typically @@ -682,8 +682,8 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext, * holds, we have to use ExecEvalWholeRowSlow to check (2) for * each row. Also, we have to allow the case that the slot has * more columns than the Var's type, because we might be looking - * at the output of a subplan that includes resjunk columns. - * (XXX it would be nice to verify that the extra columns are all + * at the output of a subplan that includes resjunk columns. (XXX + * it would be nice to verify that the extra columns are all * marked resjunk, but we haven't got access to the subplan * targetlist here...) Resjunk columns should always be at the end * of a targetlist, so it's sufficient to ignore them here; but we @@ -702,7 +702,7 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext, slot_tupdesc->natts, var_tupdesc->natts))); else if (var_tupdesc->natts < slot_tupdesc->natts) - needslow = true; /* need to trim trailing atts */ + needslow = true; /* need to trim trailing atts */ for (i = 0; i < var_tupdesc->natts; i++) { @@ -722,7 +722,7 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext, if (vattr->attlen != sattr->attlen || vattr->attalign != sattr->attalign) - needslow = true; /* need runtime check for null */ + needslow = true; /* need runtime check for null */ } ReleaseTupleDesc(var_tupdesc); @@ -907,7 +907,7 @@ ExecEvalWholeRowSlow(ExprState *exprstate, ExprContext *econtext, if (!vattr->attisdropped) continue; /* already checked non-dropped cols */ - if (heap_attisnull(tuple, i+1)) + if (heap_attisnull(tuple, i + 1)) continue; /* null is always okay */ if (vattr->attlen != sattr->attlen || vattr->attalign != sattr->attalign) @@ -2722,7 +2722,7 @@ ExecEvalConvertRowtype(ConvertRowtypeExprState *cstate, /* prepare map from old to new attribute numbers */ cstate->map = convert_tuples_by_name(cstate->indesc, cstate->outdesc, - gettext_noop("could not convert row type")); + gettext_noop("could not convert row type")); cstate->initialized = true; MemoryContextSwitchTo(old_cxt); @@ -3870,11 +3870,11 @@ ExecEvalFieldSelect(FieldSelectState *fstate, &fstate->argdesc, econtext); /* - * Find field's attr record. Note we don't support system columns here: - * a datum tuple doesn't have valid values for most of the interesting + * Find field's attr record. Note we don't support system columns here: a + * datum tuple doesn't have valid values for most of the interesting * system columns anyway. */ - if (fieldnum <= 0) /* should never happen */ + if (fieldnum <= 0) /* should never happen */ elog(ERROR, "unsupported reference to system column %d in FieldSelect", fieldnum); if (fieldnum > tupDesc->natts) /* should never happen */ diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index bda81cc12d1..fa5ff2d0e05 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.48 2010/01/02 16:57:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.49 2010/02/26 02:00:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ static bool tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, Tuple * ExecScanFetch -- fetch next potential tuple * * This routine is concerned with substituting a test tuple if we are - * inside an EvalPlanQual recheck. If we aren't, just execute + * inside an EvalPlanQual recheck. If we aren't, just execute * the access method's next-tuple routine. */ static inline TupleTableSlot * @@ -152,7 +152,7 @@ ExecScan(ScanState *node, ResetExprContext(econtext); /* - * get a tuple from the access method. Loop until we obtain a tuple that + * get a tuple from the access method. Loop until we obtain a tuple that * passes the qualification. */ for (;;) diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index a13cf5d1980..e2ee706c6da 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -4,7 +4,7 @@ * Routines dealing with TupleTableSlots. These are used for resource * management associated with tuples (eg, releasing buffer pins for * tuples in disk buffers, or freeing the memory occupied by transient - * tuples). Slots also provide access abstraction that lets us implement + * tuples). Slots also provide access abstraction that lets us implement * "virtual" tuples to reduce data-copying overhead. * * Routines dealing with the type information for tuples. Currently, @@ -17,7 +17,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.111 2010/01/02 16:57:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.112 2010/02/26 02:00:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1178,7 +1178,7 @@ void do_text_output_multiline(TupOutputState *tstate, char *text) { Datum values[1]; - bool isnull[1] = { false }; + bool isnull[1] = {false}; while (*text) { @@ -1189,6 +1189,7 @@ do_text_output_multiline(TupOutputState *tstate, char *text) if (eol) { len = eol - text; + eol++; } else diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 151e50b63f9..de78719c4c5 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.170 2010/02/08 04:33:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.171 2010/02/26 02:00:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -342,7 +342,7 @@ CreateStandaloneExprContext(void) * any previously computed pass-by-reference expression result will go away! * * If isCommit is false, we are being called in error cleanup, and should - * not call callbacks but only release memory. (It might be better to call + * not call callbacks but only release memory. (It might be better to call * the callbacks and pass the isCommit flag to them, but that would require * more invasive code changes than currently seems justified.) * @@ -1078,9 +1078,9 @@ ExecInsertIndexTuples(TupleTableSlot *slot, checkUnique = UNIQUE_CHECK_PARTIAL; satisfiesConstraint = - index_insert(indexRelation, /* index relation */ - values, /* array of index Datums */ - isnull, /* null flags */ + index_insert(indexRelation, /* index relation */ + values, /* array of index Datums */ + isnull, /* null flags */ tupleid, /* tid of heap tuple */ heapRelation, /* heap relation */ checkUnique); /* type of uniqueness check to do */ @@ -1088,7 +1088,7 @@ ExecInsertIndexTuples(TupleTableSlot *slot, /* * If the index has an associated exclusion constraint, check that. * This is simpler than the process for uniqueness checks since we - * always insert first and then check. If the constraint is deferred, + * always insert first and then check. If the constraint is deferred, * we check now anyway, but don't throw error on violation; instead * we'll queue a recheck event. * @@ -1098,7 +1098,7 @@ ExecInsertIndexTuples(TupleTableSlot *slot, */ if (indexInfo->ii_ExclusionOps != NULL) { - bool errorOK = !indexRelation->rd_index->indimmediate; + bool errorOK = !indexRelation->rd_index->indimmediate; satisfiesConstraint = check_exclusion_constraint(heapRelation, @@ -1152,23 +1152,23 @@ check_exclusion_constraint(Relation heap, Relation index, IndexInfo *indexInfo, ItemPointer tupleid, Datum *values, bool *isnull, EState *estate, bool newIndex, bool errorOK) { - Oid *constr_procs = indexInfo->ii_ExclusionProcs; - uint16 *constr_strats = indexInfo->ii_ExclusionStrats; - int index_natts = index->rd_index->indnatts; - IndexScanDesc index_scan; - HeapTuple tup; - ScanKeyData scankeys[INDEX_MAX_KEYS]; - SnapshotData DirtySnapshot; - int i; - bool conflict; - bool found_self; - ExprContext *econtext; + Oid *constr_procs = indexInfo->ii_ExclusionProcs; + uint16 *constr_strats = indexInfo->ii_ExclusionStrats; + int index_natts = index->rd_index->indnatts; + IndexScanDesc index_scan; + HeapTuple tup; + ScanKeyData scankeys[INDEX_MAX_KEYS]; + SnapshotData DirtySnapshot; + int i; + bool conflict; + bool found_self; + ExprContext *econtext; TupleTableSlot *existing_slot; TupleTableSlot *save_scantuple; /* - * If any of the input values are NULL, the constraint check is assumed - * to pass (i.e., we assume the operators are strict). + * If any of the input values are NULL, the constraint check is assumed to + * pass (i.e., we assume the operators are strict). */ for (i = 0; i < index_natts; i++) { @@ -1177,8 +1177,8 @@ check_exclusion_constraint(Relation heap, Relation index, IndexInfo *indexInfo, } /* - * Search the tuples that are in the index for any violations, - * including tuples that aren't visible yet. + * Search the tuples that are in the index for any violations, including + * tuples that aren't visible yet. */ InitDirtySnapshot(DirtySnapshot); @@ -1205,8 +1205,8 @@ check_exclusion_constraint(Relation heap, Relation index, IndexInfo *indexInfo, econtext->ecxt_scantuple = existing_slot; /* - * May have to restart scan from this point if a potential - * conflict is found. + * May have to restart scan from this point if a potential conflict is + * found. */ retry: conflict = false; @@ -1217,11 +1217,11 @@ retry: while ((tup = index_getnext(index_scan, ForwardScanDirection)) != NULL) { - TransactionId xwait; + TransactionId xwait; Datum existing_values[INDEX_MAX_KEYS]; bool existing_isnull[INDEX_MAX_KEYS]; - char *error_new; - char *error_existing; + char *error_new; + char *error_existing; /* * Ignore the entry for the tuple we're trying to check. @@ -1239,7 +1239,7 @@ retry: * Extract the index column values and isnull flags from the existing * tuple. */ - ExecStoreTuple(tup, existing_slot, InvalidBuffer, false); + ExecStoreTuple(tup, existing_slot, InvalidBuffer, false); FormIndexDatum(indexInfo, existing_slot, estate, existing_values, existing_isnull); @@ -1251,12 +1251,13 @@ retry: existing_values, existing_isnull, values)) - continue; /* tuple doesn't actually match, so no conflict */ + continue; /* tuple doesn't actually match, so no + * conflict */ } /* - * At this point we have either a conflict or a potential conflict. - * If we're not supposed to raise error, just return the fact of the + * At this point we have either a conflict or a potential conflict. If + * we're not supposed to raise error, just return the fact of the * potential conflict without waiting to see if it's real. */ if (errorOK) @@ -1267,7 +1268,7 @@ retry: /* * If an in-progress transaction is affecting the visibility of this - * tuple, we need to wait for it to complete and then recheck. For + * tuple, we need to wait for it to complete and then recheck. For * simplicity we do rechecking by just restarting the whole scan --- * this case probably doesn't happen often enough to be worth trying * harder, and anyway we don't want to hold any index internal locks @@ -1308,15 +1309,15 @@ retry: index_endscan(index_scan); /* - * We should have found our tuple in the index, unless we exited the - * loop early because of conflict. Complain if not. + * We should have found our tuple in the index, unless we exited the loop + * early because of conflict. Complain if not. */ if (!found_self && !conflict) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("failed to re-find tuple within index \"%s\"", RelationGetRelationName(index)), - errhint("This may be because of a non-immutable index expression."))); + errhint("This may be because of a non-immutable index expression."))); econtext->ecxt_scantuple = save_scantuple; @@ -1327,7 +1328,7 @@ retry: /* * Check existing tuple's index values to see if it really matches the - * exclusion condition against the new_values. Returns true if conflict. + * exclusion condition against the new_values. Returns true if conflict. */ static bool index_recheck_constraint(Relation index, Oid *constr_procs, diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 88b47316e24..d2bd23da750 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.141 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.142 2010/02/26 02:00:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -636,8 +636,8 @@ fmgr_sql(PG_FUNCTION_ARGS) /* * For simplicity, we require callers to support both set eval modes. * There are cases where we must use one or must use the other, and - * it's not really worthwhile to postpone the check till we know. - * But note we do not require caller to provide an expectedDesc. + * it's not really worthwhile to postpone the check till we know. But + * note we do not require caller to provide an expectedDesc. */ if (!rsi || !IsA(rsi, ReturnSetInfo) || (rsi->allowedModes & SFRM_ValuePerCall) == 0 || @@ -1042,7 +1042,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, AssertArg(!IsPolymorphicType(rettype)); if (modifyTargetList) - *modifyTargetList = false; /* initialize for no change */ + *modifyTargetList = false; /* initialize for no change */ if (junkFilter) *junkFilter = NULL; /* initialize in case of VOID result */ @@ -1219,7 +1219,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, /* * Verify that the targetlist matches the return tuple type. We scan * the non-deleted attributes to ensure that they match the datatypes - * of the non-resjunk columns. For deleted attributes, insert NULL + * of the non-resjunk columns. For deleted attributes, insert NULL * result columns if the caller asked for that. */ tupnatts = tupdesc->natts; @@ -1254,7 +1254,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, attr = tupdesc->attrs[colindex - 1]; if (attr->attisdropped && modifyTargetList) { - Expr *null_expr; + Expr *null_expr; /* The type of the null we insert isn't important */ null_expr = (Expr *) makeConst(INT4OID, @@ -1311,17 +1311,17 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("return type mismatch in function declared to return %s", format_type_be(rettype)), - errdetail("Final statement returns too few columns."))); + errdetail("Final statement returns too few columns."))); if (modifyTargetList) { - Expr *null_expr; + Expr *null_expr; /* The type of the null we insert isn't important */ null_expr = (Expr *) makeConst(INT4OID, -1, sizeof(int32), (Datum) 0, - true, /* isnull */ + true, /* isnull */ true /* byval */ ); newtlist = lappend(newtlist, makeTargetEntry(null_expr, diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c index 9b46215cd3f..55aace9a826 100644 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@ -7,7 +7,7 @@ * Copyright (c) 2001-2010, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.24 2010/01/02 16:57:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.25 2010/02/26 02:00:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,10 +17,10 @@ #include "executor/instrument.h" -BufferUsage pgBufferUsage; +BufferUsage pgBufferUsage; static void BufferUsageAccumDiff(BufferUsage *dst, - const BufferUsage *add, const BufferUsage *sub); + const BufferUsage *add, const BufferUsage *sub); /* Allocate new instrumentation structure(s) */ Instrumentation * @@ -34,7 +34,7 @@ InstrAlloc(int n, int instrument_options) instr = palloc0(n * sizeof(Instrumentation)); if (instrument_options & INSTRUMENT_BUFFERS) { - int i; + int i; for (i = 0; i < n; i++) instr[i].needs_bufusage = true; @@ -80,7 +80,7 @@ InstrStopNode(Instrumentation *instr, double nTuples) /* Adds delta of buffer usage to node's count. */ if (instr->needs_bufusage) BufferUsageAccumDiff(&instr->bufusage, - &pgBufferUsage, &instr->bufusage_start); + &pgBufferUsage, &instr->bufusage_start); /* Is this the first tuple of this cycle? */ if (!instr->running) diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 14a0a091b0f..74fc87a66a5 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -55,7 +55,7 @@ * it is completely forbidden for functions to modify pass-by-ref inputs, * but in the aggregate case we know the left input is either the initial * transition value or a previous function result, and in either case its - * value need not be preserved. See int8inc() for an example. Notice that + * value need not be preserved. See int8inc() for an example. Notice that * advance_transition_function() is coded to avoid a data copy step when * the previous transition value pointer is returned. Also, some * transition functions want to store working state in addition to the @@ -71,7 +71,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.174 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.175 2010/02/26 02:00:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,12 +135,12 @@ typedef struct AggStatePerAggData /* number of sorting columns to consider in DISTINCT comparisons */ /* (this is either zero or the same as numSortCols) */ - int numDistinctCols; + int numDistinctCols; /* deconstructed sorting information (arrays of length numSortCols) */ AttrNumber *sortColIdx; - Oid *sortOperators; - bool *sortNullsFirst; + Oid *sortOperators; + bool *sortNullsFirst; /* * fmgr lookup data for input columns' equality operators --- only @@ -170,12 +170,12 @@ typedef struct AggStatePerAggData transtypeByVal; /* - * Stuff for evaluation of inputs. We used to just use ExecEvalExpr, but + * Stuff for evaluation of inputs. We used to just use ExecEvalExpr, but * with the addition of ORDER BY we now need at least a slot for passing * data to the sort object, which requires a tupledesc, so we might as * well go whole hog and use ExecProject too. */ - TupleDesc evaldesc; /* descriptor of input tuples */ + TupleDesc evaldesc; /* descriptor of input tuples */ ProjectionInfo *evalproj; /* projection machinery */ /* @@ -190,7 +190,7 @@ typedef struct AggStatePerAggData * input tuple group and updated for each input tuple. * * For a simple (non DISTINCT/ORDER BY) aggregate, we just feed the input - * values straight to the transition function. If it's DISTINCT or + * values straight to the transition function. If it's DISTINCT or * requires ORDER BY, we pass the input values into a Tuplesort object; * then at completion of the input tuple group, we scan the sorted values, * eliminate duplicates if needed, and run the transition function on the @@ -257,11 +257,11 @@ static void advance_transition_function(AggState *aggstate, FunctionCallInfoData *fcinfo); static void advance_aggregates(AggState *aggstate, AggStatePerGroup pergroup); static void process_ordered_aggregate_single(AggState *aggstate, - AggStatePerAgg peraggstate, - AggStatePerGroup pergroupstate); + AggStatePerAgg peraggstate, + AggStatePerGroup pergroupstate); static void process_ordered_aggregate_multi(AggState *aggstate, - AggStatePerAgg peraggstate, - AggStatePerGroup pergroupstate); + AggStatePerAgg peraggstate, + AggStatePerGroup pergroupstate); static void finalize_aggregate(AggState *aggstate, AggStatePerAgg peraggstate, AggStatePerGroup pergroupstate, @@ -307,8 +307,8 @@ initialize_aggregates(AggState *aggstate, tuplesort_end(peraggstate->sortstate); /* - * We use a plain Datum sorter when there's a single input - * column; otherwise sort the full tuple. (See comments for + * We use a plain Datum sorter when there's a single input column; + * otherwise sort the full tuple. (See comments for * process_ordered_aggregate_single.) */ peraggstate->sortstate = @@ -488,11 +488,11 @@ advance_aggregates(AggState *aggstate, AggStatePerGroup pergroup) Assert(slot->tts_nvalid == peraggstate->numInputs); /* - * If the transfn is strict, we want to check for nullity - * before storing the row in the sorter, to save space if - * there are a lot of nulls. Note that we must only check - * numArguments columns, not numInputs, since nullity in - * columns used only for sorting is not relevant here. + * If the transfn is strict, we want to check for nullity before + * storing the row in the sorter, to save space if there are a lot + * of nulls. Note that we must only check numArguments columns, + * not numInputs, since nullity in columns used only for sorting + * is not relevant here. */ if (peraggstate->transfn.fn_strict) { @@ -537,7 +537,7 @@ advance_aggregates(AggState *aggstate, AggStatePerGroup pergroup) /* * Run the transition function for a DISTINCT or ORDER BY aggregate * with only one input. This is called after we have completed - * entering all the input values into the sort object. We complete the + * entering all the input values into the sort object. We complete the * sort, read out the values in sorted order, and run the transition * function on each value (applying DISTINCT if appropriate). * @@ -559,11 +559,11 @@ process_ordered_aggregate_single(AggState *aggstate, AggStatePerGroup pergroupstate) { Datum oldVal = (Datum) 0; - bool oldIsNull = true; + bool oldIsNull = true; bool haveOldVal = false; MemoryContext workcontext = aggstate->tmpcontext->ecxt_per_tuple_memory; MemoryContext oldContext; - bool isDistinct = (peraggstate->numDistinctCols > 0); + bool isDistinct = (peraggstate->numDistinctCols > 0); Datum *newVal; bool *isNull; FunctionCallInfoData fcinfo; @@ -632,7 +632,7 @@ process_ordered_aggregate_single(AggState *aggstate, /* * Run the transition function for a DISTINCT or ORDER BY aggregate * with more than one input. This is called after we have completed - * entering all the input values into the sort object. We complete the + * entering all the input values into the sort object. We complete the * sort, read out the values in sorted order, and run the transition * function on each value (applying DISTINCT if appropriate). * @@ -647,10 +647,10 @@ process_ordered_aggregate_multi(AggState *aggstate, FunctionCallInfoData fcinfo; TupleTableSlot *slot1 = peraggstate->evalslot; TupleTableSlot *slot2 = peraggstate->uniqslot; - int numArguments = peraggstate->numArguments; - int numDistinctCols = peraggstate->numDistinctCols; - bool haveOldValue = false; - int i; + int numArguments = peraggstate->numArguments; + int numDistinctCols = peraggstate->numDistinctCols; + bool haveOldValue = false; + int i; tuplesort_performsort(peraggstate->sortstate); @@ -983,9 +983,9 @@ ExecAgg(AggState *node) } /* - * Exit if nothing left to do. (We must do the ps_TupFromTlist check - * first, because in some cases agg_done gets set before we emit the - * final aggregate tuple, and we have to finish running SRFs for it.) + * Exit if nothing left to do. (We must do the ps_TupFromTlist check + * first, because in some cases agg_done gets set before we emit the final + * aggregate tuple, and we have to finish running SRFs for it.) */ if (node->agg_done) return NULL; @@ -1066,9 +1066,9 @@ agg_retrieve_direct(AggState *aggstate) /* * Clear the per-output-tuple context for each group, as well as - * aggcontext (which contains any pass-by-ref transvalues of the - * old group). We also clear any child contexts of the aggcontext; - * some aggregate functions store working state in such contexts. + * aggcontext (which contains any pass-by-ref transvalues of the old + * group). We also clear any child contexts of the aggcontext; some + * aggregate functions store working state in such contexts. */ ResetExprContext(econtext); @@ -1402,8 +1402,8 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) * structures and transition values. NOTE: the details of what is stored * in aggcontext and what is stored in the regular per-query memory * context are driven by a simple decision: we want to reset the - * aggcontext at group boundaries (if not hashing) and in ExecReScanAgg - * to recover no-longer-wanted space. + * aggcontext at group boundaries (if not hashing) and in ExecReScanAgg to + * recover no-longer-wanted space. */ aggstate->aggcontext = AllocSetContextCreate(CurrentMemoryContext, @@ -1539,7 +1539,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) int numInputs; int numSortCols; int numDistinctCols; - List *sortlist; + List *sortlist; HeapTuple aggTuple; Form_pg_aggregate aggform; Oid aggtranstype; @@ -1735,9 +1735,9 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) NULL); /* - * If we're doing either DISTINCT or ORDER BY, then we have a list - * of SortGroupClause nodes; fish out the data in them and - * stick them into arrays. + * If we're doing either DISTINCT or ORDER BY, then we have a list of + * SortGroupClause nodes; fish out the data in them and stick them + * into arrays. * * Note that by construction, if there is a DISTINCT clause then the * ORDER BY clause is a prefix of it (see transformDistinctClause). @@ -1976,8 +1976,8 @@ ExecReScanAgg(AggState *node, ExprContext *exprCtxt) * * The transition and/or final functions of an aggregate may want to verify * that they are being called as aggregates, rather than as plain SQL - * functions. They should use this function to do so. The return value - * is nonzero if being called as an aggregate, or zero if not. (Specific + * functions. They should use this function to do so. The return value + * is nonzero if being called as an aggregate, or zero if not. (Specific * nonzero values are AGG_CONTEXT_AGGREGATE or AGG_CONTEXT_WINDOW, but more * values could conceivably appear in future.) * diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 6a41a290126..be45d732e09 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.128 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.129 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -458,7 +458,7 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew, /* * Set nbuckets to achieve an average bucket load of NTUP_PER_BUCKET when * memory is filled. Set nbatch to the smallest power of 2 that appears - * sufficient. The Min() steps limit the results so that the pointer + * sufficient. The Min() steps limit the results so that the pointer * arrays we'll try to allocate do not exceed work_mem. */ max_pointers = (work_mem * 1024L) / sizeof(void *); diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index b60160c0402..0994dbf84ef 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.138 2010/01/02 16:57:42 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.139 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -240,9 +240,9 @@ ExecIndexEvalRuntimeKeys(ExprContext *econtext, * necessary. * * It's also entirely possible that the result of the eval is a - * toasted value. In this case we should forcibly detoast it, - * to avoid repeat detoastings each time the value is examined - * by an index support function. + * toasted value. In this case we should forcibly detoast it, to + * avoid repeat detoastings each time the value is examined by an + * index support function. */ scanvalue = ExecEvalExpr(key_expr, econtext, diff --git a/src/backend/executor/nodeLockRows.c b/src/backend/executor/nodeLockRows.c index b3c61d43e19..0eafa0afa2c 100644 --- a/src/backend/executor/nodeLockRows.c +++ b/src/backend/executor/nodeLockRows.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeLockRows.c,v 1.3 2010/01/02 16:57:42 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeLockRows.c,v 1.4 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -154,8 +154,8 @@ lnext: tuple.t_self = copyTuple->t_self; /* - * Need to run a recheck subquery. Initialize EPQ state - * if we didn't do so already. + * Need to run a recheck subquery. Initialize EPQ state if we + * didn't do so already. */ if (!epq_started) { @@ -185,9 +185,9 @@ lnext: { /* * First, fetch a copy of any rows that were successfully locked - * without any update having occurred. (We do this in a separate - * pass so as to avoid overhead in the common case where there are - * no concurrent updates.) + * without any update having occurred. (We do this in a separate pass + * so as to avoid overhead in the common case where there are no + * concurrent updates.) */ foreach(lc, node->lr_rowMarks) { @@ -209,12 +209,14 @@ lnext: heap_copytuple(&tuple)); ReleaseBuffer(buffer); } + /* - * Now fetch any non-locked source rows --- the EPQ logic knows - * how to do that. + * Now fetch any non-locked source rows --- the EPQ logic knows how to + * do that. */ EvalPlanQualSetSlot(&node->lr_epqstate, slot); EvalPlanQualFetchRowMarks(&node->lr_epqstate); + /* * And finally we can re-evaluate the tuple. */ @@ -272,15 +274,15 @@ ExecInitLockRows(LockRows *node, EState *estate, int eflags) outerPlanState(lrstate) = ExecInitNode(outerPlan, estate, eflags); /* - * LockRows nodes do no projections, so initialize projection info for this - * node appropriately + * LockRows nodes do no projections, so initialize projection info for + * this node appropriately */ ExecAssignResultTypeFromTL(&lrstate->ps); lrstate->ps.ps_ProjInfo = NULL; /* - * Locate the ExecRowMark(s) that this node is responsible for. - * (InitPlan should already have built the global list of ExecRowMarks.) + * Locate the ExecRowMark(s) that this node is responsible for. (InitPlan + * should already have built the global list of ExecRowMarks.) */ lrstate->lr_rowMarks = NIL; foreach(lc, node->rowMarks) @@ -307,10 +309,10 @@ ExecInitLockRows(LockRows *node, EState *estate, int eflags) rc->rti); /* - * Only locking rowmarks go into our own list. Non-locking marks - * are passed off to the EvalPlanQual machinery. This is because - * we don't want to bother fetching non-locked rows unless we - * actually have to do an EPQ recheck. + * Only locking rowmarks go into our own list. Non-locking marks are + * passed off to the EvalPlanQual machinery. This is because we don't + * want to bother fetching non-locked rows unless we actually have to + * do an EPQ recheck. */ if (RowMarkRequiresRowShareLock(erm->markType)) lrstate->lr_rowMarks = lappend(lrstate->lr_rowMarks, erm); diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 0c611015134..8404c4d4646 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.100 2010/01/05 23:25:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.101 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -507,7 +507,7 @@ check_constant_qual(List *qual, bool *is_const_false) foreach(lc, qual) { - Const *con = (Const *) lfirst(lc); + Const *con = (Const *) lfirst(lc); if (!con || !IsA(con, Const)) return false; diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index eca1d6de3f4..adfe97cefde 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -8,12 +8,12 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeModifyTable.c,v 1.6 2010/02/08 04:33:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeModifyTable.c,v 1.7 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ /* INTERFACE ROUTINES - * ExecInitModifyTable - initialize the ModifyTable node + * ExecInitModifyTable - initialize the ModifyTable node * ExecModifyTable - retrieve the next tuple from the node * ExecEndModifyTable - shut down the ModifyTable node * ExecReScanModifyTable - rescan the ModifyTable node @@ -30,7 +30,7 @@ * * If the query specifies RETURNING, then the ModifyTable returns a * RETURNING tuple after completing each row insert, update, or delete. - * It must be called again to continue the operation. Without RETURNING, + * It must be called again to continue the operation. Without RETURNING, * we just loop within the node until all the work is done, then * return NULL. This avoids useless call/return overhead. */ @@ -215,7 +215,7 @@ ExecInsert(TupleTableSlot *slot, * slot should not try to clear it. */ TupleTableSlot *newslot = estate->es_trig_tuple_slot; - TupleDesc tupdesc = RelationGetDescr(resultRelationDesc); + TupleDesc tupdesc = RelationGetDescr(resultRelationDesc); if (newslot->tts_tupleDescriptor != tupdesc) ExecSetSlotDescriptor(newslot, tupdesc); @@ -470,7 +470,7 @@ ExecUpdate(ItemPointer tupleid, * slot should not try to clear it. */ TupleTableSlot *newslot = estate->es_trig_tuple_slot; - TupleDesc tupdesc = RelationGetDescr(resultRelationDesc); + TupleDesc tupdesc = RelationGetDescr(resultRelationDesc); if (newslot->tts_tupleDescriptor != tupdesc) ExecSetSlotDescriptor(newslot, tupdesc); @@ -646,9 +646,9 @@ fireASTriggers(ModifyTableState *node) TupleTableSlot * ExecModifyTable(ModifyTableState *node) { - EState *estate = node->ps.state; - CmdType operation = node->operation; - PlanState *subplanstate; + EState *estate = node->ps.state; + CmdType operation = node->operation; + PlanState *subplanstate; JunkFilter *junkfilter; TupleTableSlot *slot; TupleTableSlot *planSlot; @@ -666,8 +666,8 @@ ExecModifyTable(ModifyTableState *node) /* * es_result_relation_info must point to the currently active result - * relation. (Note we assume that ModifyTable nodes can't be nested.) - * We want it to be NULL whenever we're not within ModifyTable, though. + * relation. (Note we assume that ModifyTable nodes can't be nested.) We + * want it to be NULL whenever we're not within ModifyTable, though. */ estate->es_result_relation_info = estate->es_result_relations + node->mt_whichplan; @@ -791,8 +791,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK))); /* - * This should NOT get called during EvalPlanQual; we should have passed - * a subplan tree to EvalPlanQual, instead. Use a runtime test not just + * This should NOT get called during EvalPlanQual; we should have passed a + * subplan tree to EvalPlanQual, instead. Use a runtime test not just * Assert because this condition is easy to miss in testing ... */ if (estate->es_epqTuple != NULL) @@ -846,8 +846,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) ExprContext *econtext; /* - * Initialize result tuple slot and assign its rowtype using the - * first RETURNING list. We assume the rest will look the same. + * Initialize result tuple slot and assign its rowtype using the first + * RETURNING list. We assume the rest will look the same. */ tupDesc = ExecTypeFromTL((List *) linitial(node->returningLists), false); @@ -881,8 +881,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) else { /* - * We still must construct a dummy result tuple type, because - * InitPlan expects one (maybe should change that?). + * We still must construct a dummy result tuple type, because InitPlan + * expects one (maybe should change that?). */ tupDesc = ExecTypeFromTL(NIL, false); ExecInitResultTupleSlot(estate, &mtstate->ps); @@ -892,10 +892,10 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) } /* - * If we have any secondary relations in an UPDATE or DELETE, they need - * to be treated like non-locked relations in SELECT FOR UPDATE, ie, - * the EvalPlanQual mechanism needs to be told about them. Locate - * the relevant ExecRowMarks. + * If we have any secondary relations in an UPDATE or DELETE, they need to + * be treated like non-locked relations in SELECT FOR UPDATE, ie, the + * EvalPlanQual mechanism needs to be told about them. Locate the + * relevant ExecRowMarks. */ foreach(l, node->rowMarks) { @@ -925,12 +925,12 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) /* * Initialize the junk filter(s) if needed. INSERT queries need a filter - * if there are any junk attrs in the tlist. UPDATE and DELETE - * always need a filter, since there's always a junk 'ctid' attribute - * present --- no need to look first. + * if there are any junk attrs in the tlist. UPDATE and DELETE always + * need a filter, since there's always a junk 'ctid' attribute present --- + * no need to look first. * * If there are multiple result relations, each one needs its own junk - * filter. Note multiple rels are only possible for UPDATE/DELETE, so we + * filter. Note multiple rels are only possible for UPDATE/DELETE, so we * can't be fooled by some needing a filter and some not. * * This section of code is also a convenient place to verify that the @@ -999,9 +999,9 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) } /* - * Set up a tuple table slot for use for trigger output tuples. - * In a plan containing multiple ModifyTable nodes, all can share - * one such slot, so we keep it in the estate. + * Set up a tuple table slot for use for trigger output tuples. In a plan + * containing multiple ModifyTable nodes, all can share one such slot, so + * we keep it in the estate. */ if (estate->es_trig_tuple_slot == NULL) estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate); @@ -1020,7 +1020,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) void ExecEndModifyTable(ModifyTableState *node) { - int i; + int i; /* * Free the exprcontext @@ -1040,7 +1040,7 @@ ExecEndModifyTable(ModifyTableState *node) /* * shut down subplans */ - for (i=0; i<node->mt_nplans; i++) + for (i = 0; i < node->mt_nplans; i++) ExecEndNode(node->mt_plans[i]); } @@ -1048,8 +1048,8 @@ void ExecReScanModifyTable(ModifyTableState *node, ExprContext *exprCtxt) { /* - * Currently, we don't need to support rescan on ModifyTable nodes. - * The semantics of that would be a bit debatable anyway. + * Currently, we don't need to support rescan on ModifyTable nodes. The + * semantics of that would be a bit debatable anyway. */ elog(ERROR, "ExecReScanModifyTable is not implemented"); } diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c index d4a5f677fec..75623be3715 100644 --- a/src/backend/executor/nodeSeqscan.c +++ b/src/backend/executor/nodeSeqscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.69 2010/01/02 16:57:45 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.70 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,9 +92,8 @@ static bool SeqRecheck(SeqScanState *node, TupleTableSlot *slot) { /* - * Note that unlike IndexScan, SeqScan never use keys in - * heap_beginscan (and this is very bad) - so, here we do not check - * are keys ok or not. + * Note that unlike IndexScan, SeqScan never use keys in heap_beginscan + * (and this is very bad) - so, here we do not check are keys ok or not. */ return true; } diff --git a/src/backend/executor/nodeSubqueryscan.c b/src/backend/executor/nodeSubqueryscan.c index c8e2e083df2..dbd42d79720 100644 --- a/src/backend/executor/nodeSubqueryscan.c +++ b/src/backend/executor/nodeSubqueryscan.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.44 2010/01/02 16:57:45 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.45 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,9 +53,9 @@ SubqueryNext(SubqueryScanState *node) slot = ExecProcNode(node->subplan); /* - * We just return the subplan's result slot, rather than expending - * extra cycles for ExecCopySlot(). (Our own ScanTupleSlot is used - * only for EvalPlanQual rechecks.) + * We just return the subplan's result slot, rather than expending extra + * cycles for ExecCopySlot(). (Our own ScanTupleSlot is used only for + * EvalPlanQual rechecks.) */ return slot; } diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c index 2668d83b03e..4d76981b02a 100644 --- a/src/backend/executor/nodeWindowAgg.c +++ b/src/backend/executor/nodeWindowAgg.c @@ -27,7 +27,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeWindowAgg.c,v 1.11 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeWindowAgg.c,v 1.12 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -416,8 +416,8 @@ eval_windowaggregates(WindowAggState *winstate) * need the current aggregate value. This is considerably more efficient * than the naive approach of re-running the entire aggregate calculation * for each current row. It does assume that the final function doesn't - * damage the running transition value, but we have the same assumption - * in nodeAgg.c too (when it rescans an existing hash table). + * damage the running transition value, but we have the same assumption in + * nodeAgg.c too (when it rescans an existing hash table). * * For other frame start rules, we discard the aggregate state and re-run * the aggregates whenever the frame head row moves. We can still @@ -434,11 +434,11 @@ eval_windowaggregates(WindowAggState *winstate) * accumulated into the aggregate transition values. Whenever we start a * new peer group, we accumulate forward to the end of the peer group. * - * TODO: Rerunning aggregates from the frame start can be pretty slow. - * For some aggregates like SUM and COUNT we could avoid that by - * implementing a "negative transition function" that would be called for - * each row as it exits the frame. We'd have to think about avoiding - * recalculation of volatile arguments of aggregate functions, too. + * TODO: Rerunning aggregates from the frame start can be pretty slow. For + * some aggregates like SUM and COUNT we could avoid that by implementing + * a "negative transition function" that would be called for each row as + * it exits the frame. We'd have to think about avoiding recalculation of + * volatile arguments of aggregate functions, too. */ /* @@ -447,8 +447,8 @@ eval_windowaggregates(WindowAggState *winstate) update_frameheadpos(agg_winobj, winstate->temp_slot_1); /* - * Initialize aggregates on first call for partition, or if the frame - * head position moved since last time. + * Initialize aggregates on first call for partition, or if the frame head + * position moved since last time. */ if (winstate->currentpos == 0 || winstate->frameheadpos != winstate->aggregatedbase) @@ -468,8 +468,8 @@ eval_windowaggregates(WindowAggState *winstate) } /* - * If we created a mark pointer for aggregates, keep it pushed up - * to frame head, so that tuplestore can discard unnecessary rows. + * If we created a mark pointer for aggregates, keep it pushed up to + * frame head, so that tuplestore can discard unnecessary rows. */ if (agg_winobj->markptr >= 0) WinSetMarkPosition(agg_winobj, winstate->frameheadpos); @@ -485,9 +485,9 @@ eval_windowaggregates(WindowAggState *winstate) /* * In UNBOUNDED_FOLLOWING mode, we don't have to recalculate aggregates * except when the frame head moves. In END_CURRENT_ROW mode, we only - * have to recalculate when the frame head moves or currentpos has advanced - * past the place we'd aggregated up to. Check for these cases and if - * so, reuse the saved result values. + * have to recalculate when the frame head moves or currentpos has + * advanced past the place we'd aggregated up to. Check for these cases + * and if so, reuse the saved result values. */ if ((winstate->frameOptions & (FRAMEOPTION_END_UNBOUNDED_FOLLOWING | FRAMEOPTION_END_CURRENT_ROW)) && @@ -508,7 +508,7 @@ eval_windowaggregates(WindowAggState *winstate) * Advance until we reach a row not in frame (or end of partition). * * Note the loop invariant: agg_row_slot is either empty or holds the row - * at position aggregatedupto. We advance aggregatedupto after processing + * at position aggregatedupto. We advance aggregatedupto after processing * a row. */ for (;;) @@ -896,7 +896,7 @@ row_is_in_frame(WindowAggState *winstate, int64 pos, TupleTableSlot *slot) { if (frameOptions & FRAMEOPTION_ROWS) { - int64 offset = DatumGetInt64(winstate->startOffsetValue); + int64 offset = DatumGetInt64(winstate->startOffsetValue); /* rows before current row + offset are out of frame */ if (frameOptions & FRAMEOPTION_START_VALUE_PRECEDING) @@ -937,7 +937,7 @@ row_is_in_frame(WindowAggState *winstate, int64 pos, TupleTableSlot *slot) { if (frameOptions & FRAMEOPTION_ROWS) { - int64 offset = DatumGetInt64(winstate->endOffsetValue); + int64 offset = DatumGetInt64(winstate->endOffsetValue); /* rows after current row + offset are out of frame */ if (frameOptions & FRAMEOPTION_END_VALUE_PRECEDING) @@ -965,7 +965,7 @@ row_is_in_frame(WindowAggState *winstate, int64 pos, TupleTableSlot *slot) * * Uses the winobj's read pointer for any required fetches; hence, if the * frame mode is one that requires row comparisons, the winobj's mark must - * not be past the currently known frame head. Also uses the specified slot + * not be past the currently known frame head. Also uses the specified slot * for any required fetches. */ static void @@ -1007,9 +1007,9 @@ update_frameheadpos(WindowObject winobj, TupleTableSlot *slot) /* * In RANGE START_CURRENT mode, frame head is the first row that * is a peer of current row. We search backwards from current, - * which could be a bit inefficient if peer sets are large. - * Might be better to have a separate read pointer that moves - * forward tracking the frame head. + * which could be a bit inefficient if peer sets are large. Might + * be better to have a separate read pointer that moves forward + * tracking the frame head. */ fhprev = winstate->currentpos - 1; for (;;) @@ -1018,9 +1018,9 @@ update_frameheadpos(WindowObject winobj, TupleTableSlot *slot) if (fhprev < winstate->frameheadpos) break; if (!window_gettupleslot(winobj, fhprev, slot)) - break; /* start of partition */ + break; /* start of partition */ if (!are_peers(winstate, slot, winstate->ss.ss_ScanTupleSlot)) - break; /* not peer of current row */ + break; /* not peer of current row */ fhprev--; } winstate->frameheadpos = fhprev + 1; @@ -1034,7 +1034,7 @@ update_frameheadpos(WindowObject winobj, TupleTableSlot *slot) if (frameOptions & FRAMEOPTION_ROWS) { /* In ROWS mode, bound is physically n before/after current */ - int64 offset = DatumGetInt64(winstate->startOffsetValue); + int64 offset = DatumGetInt64(winstate->startOffsetValue); if (frameOptions & FRAMEOPTION_START_VALUE_PRECEDING) offset = -offset; @@ -1070,7 +1070,7 @@ update_frameheadpos(WindowObject winobj, TupleTableSlot *slot) * * Uses the winobj's read pointer for any required fetches; hence, if the * frame mode is one that requires row comparisons, the winobj's mark must - * not be past the currently known frame tail. Also uses the specified slot + * not be past the currently known frame tail. Also uses the specified slot * for any required fetches. */ static void @@ -1122,9 +1122,9 @@ update_frametailpos(WindowObject winobj, TupleTableSlot *slot) for (;;) { if (!window_gettupleslot(winobj, ftnext, slot)) - break; /* end of partition */ + break; /* end of partition */ if (!are_peers(winstate, slot, winstate->ss.ss_ScanTupleSlot)) - break; /* not peer of current row */ + break; /* not peer of current row */ ftnext++; } winstate->frametailpos = ftnext - 1; @@ -1138,7 +1138,7 @@ update_frametailpos(WindowObject winobj, TupleTableSlot *slot) if (frameOptions & FRAMEOPTION_ROWS) { /* In ROWS mode, bound is physically n before/after current */ - int64 offset = DatumGetInt64(winstate->endOffsetValue); + int64 offset = DatumGetInt64(winstate->endOffsetValue); if (frameOptions & FRAMEOPTION_END_VALUE_PRECEDING) offset = -offset; @@ -1213,12 +1213,12 @@ ExecWindowAgg(WindowAggState *winstate) */ if (winstate->all_first) { - int frameOptions = winstate->frameOptions; - ExprContext *econtext = winstate->ss.ps.ps_ExprContext; - Datum value; - bool isnull; - int16 len; - bool byval; + int frameOptions = winstate->frameOptions; + ExprContext *econtext = winstate->ss.ps.ps_ExprContext; + Datum value; + bool isnull; + int16 len; + bool byval; if (frameOptions & FRAMEOPTION_START_VALUE) { @@ -1238,12 +1238,12 @@ ExecWindowAgg(WindowAggState *winstate) if (frameOptions & FRAMEOPTION_ROWS) { /* value is known to be int8 */ - int64 offset = DatumGetInt64(value); + int64 offset = DatumGetInt64(value); if (offset < 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("frame starting offset must not be negative"))); + errmsg("frame starting offset must not be negative"))); } } if (frameOptions & FRAMEOPTION_END_VALUE) @@ -1264,12 +1264,12 @@ ExecWindowAgg(WindowAggState *winstate) if (frameOptions & FRAMEOPTION_ROWS) { /* value is known to be int8 */ - int64 offset = DatumGetInt64(value); + int64 offset = DatumGetInt64(value); if (offset < 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("frame ending offset must not be negative"))); + errmsg("frame ending offset must not be negative"))); } } winstate->all_first = false; @@ -2146,8 +2146,8 @@ WinGetFuncArgInPartition(WindowObject winobj, int argno, *isout = false; if (set_mark) { - int frameOptions = winstate->frameOptions; - int64 mark_pos = abs_pos; + int frameOptions = winstate->frameOptions; + int64 mark_pos = abs_pos; /* * In RANGE mode with a moving frame head, we must not let the @@ -2155,10 +2155,10 @@ WinGetFuncArgInPartition(WindowObject winobj, int argno, * fetchable during future update_frameheadpos calls. * * XXX it is very ugly to pollute window functions' marks with - * this consideration; it could for instance mask a logic bug - * that lets a window function fetch rows before what it had - * claimed was its mark. Perhaps use a separate mark for - * frame head probes? + * this consideration; it could for instance mask a logic bug that + * lets a window function fetch rows before what it had claimed + * was its mark. Perhaps use a separate mark for frame head + * probes? */ if ((frameOptions & FRAMEOPTION_RANGE) && !(frameOptions & FRAMEOPTION_START_UNBOUNDED_PRECEDING)) @@ -2245,8 +2245,8 @@ WinGetFuncArgInFrame(WindowObject winobj, int argno, *isout = false; if (set_mark) { - int frameOptions = winstate->frameOptions; - int64 mark_pos = abs_pos; + int frameOptions = winstate->frameOptions; + int64 mark_pos = abs_pos; /* * In RANGE mode with a moving frame head, we must not let the @@ -2254,10 +2254,10 @@ WinGetFuncArgInFrame(WindowObject winobj, int argno, * fetchable during future update_frameheadpos calls. * * XXX it is very ugly to pollute window functions' marks with - * this consideration; it could for instance mask a logic bug - * that lets a window function fetch rows before what it had - * claimed was its mark. Perhaps use a separate mark for - * frame head probes? + * this consideration; it could for instance mask a logic bug that + * lets a window function fetch rows before what it had claimed + * was its mark. Perhaps use a separate mark for frame head + * probes? */ if ((frameOptions & FRAMEOPTION_RANGE) && !(frameOptions & FRAMEOPTION_START_UNBOUNDED_PRECEDING)) diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index a78474f037b..1ffb1b2fee7 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.214 2010/02/14 18:42:14 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.215 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1268,10 +1268,9 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan, } /* - * If the plan has parameters, copy them into the portal. Note that - * this must be done after revalidating the plan, because in dynamic - * parameter cases the set of parameters could have changed during - * re-parsing. + * If the plan has parameters, copy them into the portal. Note that this + * must be done after revalidating the plan, because in dynamic parameter + * cases the set of parameters could have changed during re-parsing. */ if (paramLI) { diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 01b6851e358..70b0f665665 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.194 2010/02/02 19:09:36 mha Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.195 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -313,9 +313,9 @@ ClientAuthentication(Port *port) errhint("See server log for details."))); /* - * Enable immediate response to SIGTERM/SIGINT/timeout interrupts. - * (We don't want this during hba_getauthmethod() because it might - * have to do database access, eg for role membership checks.) + * Enable immediate response to SIGTERM/SIGINT/timeout interrupts. (We + * don't want this during hba_getauthmethod() because it might have to do + * database access, eg for role membership checks.) */ ImmediateInterruptOK = true; /* And don't forget to detect one that already arrived */ @@ -1960,7 +1960,7 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg, if (strlen(passwd) == 0) { ereport(LOG, - (errmsg("empty password returned by client"))); + (errmsg("empty password returned by client"))); goto fail; } } @@ -2243,20 +2243,21 @@ CheckLDAPAuth(Port *port) if (port->hba->ldapbasedn) { /* - * First perform an LDAP search to find the DN for the user we are trying to log - * in as. + * First perform an LDAP search to find the DN for the user we are + * trying to log in as. */ - char *filter; - LDAPMessage *search_message; - LDAPMessage *entry; - char *attributes[2]; - char *dn; - char *c; + char *filter; + LDAPMessage *search_message; + LDAPMessage *entry; + char *attributes[2]; + char *dn; + char *c; /* - * Disallow any characters that we would otherwise need to escape, since they - * aren't really reasonable in a username anyway. Allowing them would make it - * possible to inject any kind of custom filters in the LDAP filter. + * Disallow any characters that we would otherwise need to escape, + * since they aren't really reasonable in a username anyway. Allowing + * them would make it possible to inject any kind of custom filters in + * the LDAP filter. */ for (c = port->user_name; *c; c++) { @@ -2273,17 +2274,17 @@ CheckLDAPAuth(Port *port) } /* - * Bind with a pre-defined username/password (if available) for searching. If - * none is specified, this turns into an anonymous bind. + * Bind with a pre-defined username/password (if available) for + * searching. If none is specified, this turns into an anonymous bind. */ r = ldap_simple_bind_s(ldap, - port->hba->ldapbinddn ? port->hba->ldapbinddn : "", - port->hba->ldapbindpasswd ? port->hba->ldapbindpasswd : ""); + port->hba->ldapbinddn ? port->hba->ldapbinddn : "", + port->hba->ldapbindpasswd ? port->hba->ldapbindpasswd : ""); if (r != LDAP_SUCCESS) { ereport(LOG, (errmsg("could not perform initial LDAP bind for ldapbinddn \"%s\" on server \"%s\": error code %d", - port->hba->ldapbinddn, port->hba->ldapserver, r))); + port->hba->ldapbinddn, port->hba->ldapserver, r))); return STATUS_ERROR; } @@ -2291,10 +2292,10 @@ CheckLDAPAuth(Port *port) attributes[0] = port->hba->ldapsearchattribute ? port->hba->ldapsearchattribute : "uid"; attributes[1] = NULL; - filter = palloc(strlen(attributes[0])+strlen(port->user_name)+4); + filter = palloc(strlen(attributes[0]) + strlen(port->user_name) + 4); sprintf(filter, "(%s=%s)", - attributes[0], - port->user_name); + attributes[0], + port->user_name); r = ldap_search_s(ldap, port->hba->ldapbasedn, @@ -2323,7 +2324,7 @@ CheckLDAPAuth(Port *port) ereport(LOG, (errmsg("LDAP search failed for filter \"%s\" on server \"%s\": user is not unique (%ld matches)", filter, port->hba->ldapserver, - (long) ldap_count_entries(ldap, search_message)))); + (long) ldap_count_entries(ldap, search_message)))); pfree(filter); ldap_msgfree(search_message); @@ -2334,11 +2335,12 @@ CheckLDAPAuth(Port *port) dn = ldap_get_dn(ldap, entry); if (dn == NULL) { - int error; - (void)ldap_get_option(ldap, LDAP_OPT_ERROR_NUMBER, &error); + int error; + + (void) ldap_get_option(ldap, LDAP_OPT_ERROR_NUMBER, &error); ereport(LOG, (errmsg("could not get dn for the first entry matching \"%s\" on server \"%s\": %s", - filter, port->hba->ldapserver, ldap_err2string(error)))); + filter, port->hba->ldapserver, ldap_err2string(error)))); pfree(filter); ldap_msgfree(search_message); return STATUS_ERROR; @@ -2353,18 +2355,19 @@ CheckLDAPAuth(Port *port) r = ldap_unbind_s(ldap); if (r != LDAP_SUCCESS) { - int error; - (void)ldap_get_option(ldap, LDAP_OPT_ERROR_NUMBER, &error); + int error; + + (void) ldap_get_option(ldap, LDAP_OPT_ERROR_NUMBER, &error); ereport(LOG, (errmsg("could not unbind after searching for user \"%s\" on server \"%s\": %s", - fulluser, port->hba->ldapserver, ldap_err2string(error)))); + fulluser, port->hba->ldapserver, ldap_err2string(error)))); pfree(fulluser); return STATUS_ERROR; } /* - * Need to re-initialize the LDAP connection, so that we can bind - * to it with a different username. + * Need to re-initialize the LDAP connection, so that we can bind to + * it with a different username. */ if (InitializeLDAPConnection(port, &ldap) == STATUS_ERROR) { @@ -2378,13 +2381,13 @@ CheckLDAPAuth(Port *port) { fulluser = palloc((port->hba->ldapprefix ? strlen(port->hba->ldapprefix) : 0) + strlen(port->user_name) + - (port->hba->ldapsuffix ? strlen(port->hba->ldapsuffix) : 0) + + (port->hba->ldapsuffix ? strlen(port->hba->ldapsuffix) : 0) + 1); sprintf(fulluser, "%s%s%s", - port->hba->ldapprefix ? port->hba->ldapprefix : "", - port->user_name, - port->hba->ldapsuffix ? port->hba->ldapsuffix : ""); + port->hba->ldapprefix ? port->hba->ldapprefix : "", + port->user_name, + port->hba->ldapsuffix ? port->hba->ldapsuffix : ""); } r = ldap_simple_bind_s(ldap, fulluser, passwd); @@ -2429,7 +2432,6 @@ CheckCertAuth(Port *port) /* Just pass the certificate CN to the usermap check */ return check_usermap(port->hba->usermap, port->user_name, port->peer_cn, false); } - #endif @@ -2448,17 +2450,17 @@ CheckCertAuth(Port *port) typedef struct { - uint8 attribute; - uint8 length; - uint8 data[1]; + uint8 attribute; + uint8 length; + uint8 data[1]; } radius_attribute; typedef struct { - uint8 code; - uint8 id; - uint16 length; - uint8 vector[RADIUS_VECTOR_LENGTH]; + uint8 code; + uint8 id; + uint16 length; + uint8 vector[RADIUS_VECTOR_LENGTH]; } radius_packet; /* RADIUS packet types */ @@ -2484,14 +2486,15 @@ typedef struct static void radius_add_attribute(radius_packet *packet, uint8 type, const unsigned char *data, int len) { - radius_attribute *attr; + radius_attribute *attr; if (packet->length + len > RADIUS_BUFFER_SIZE) { /* - * With remotely realistic data, this can never happen. But catch it just to make - * sure we don't overrun a buffer. We'll just skip adding the broken attribute, - * which will in the end cause authentication to fail. + * With remotely realistic data, this can never happen. But catch it + * just to make sure we don't overrun a buffer. We'll just skip adding + * the broken attribute, which will in the end cause authentication to + * fail. */ elog(WARNING, "Adding attribute code %i with length %i to radius packet would create oversize packet, ignoring", @@ -2500,9 +2503,9 @@ radius_add_attribute(radius_packet *packet, uint8 type, const unsigned char *dat } - attr = (radius_attribute *) ((unsigned char *)packet + packet->length); + attr = (radius_attribute *) ((unsigned char *) packet + packet->length); attr->attribute = type; - attr->length = len + 2; /* total size includes type and length */ + attr->length = len + 2; /* total size includes type and length */ memcpy(attr->data, data, len); packet->length += attr->length; } @@ -2510,31 +2513,33 @@ radius_add_attribute(radius_packet *packet, uint8 type, const unsigned char *dat static int CheckRADIUSAuth(Port *port) { - char *passwd; - char *identifier = "postgresql"; - char radius_buffer[RADIUS_BUFFER_SIZE]; - char receive_buffer[RADIUS_BUFFER_SIZE]; - radius_packet *packet = (radius_packet *)radius_buffer; - radius_packet *receivepacket = (radius_packet *)receive_buffer; - int32 service = htonl(RADIUS_AUTHENTICATE_ONLY); - uint8 *cryptvector; - uint8 encryptedpassword[RADIUS_VECTOR_LENGTH]; - int packetlength; - pgsocket sock; + char *passwd; + char *identifier = "postgresql"; + char radius_buffer[RADIUS_BUFFER_SIZE]; + char receive_buffer[RADIUS_BUFFER_SIZE]; + radius_packet *packet = (radius_packet *) radius_buffer; + radius_packet *receivepacket = (radius_packet *) receive_buffer; + int32 service = htonl(RADIUS_AUTHENTICATE_ONLY); + uint8 *cryptvector; + uint8 encryptedpassword[RADIUS_VECTOR_LENGTH]; + int packetlength; + pgsocket sock; + #ifdef HAVE_IPV6 struct sockaddr_in6 localaddr; struct sockaddr_in6 remoteaddr; #else - struct sockaddr_in localaddr; - struct sockaddr_in remoteaddr; + struct sockaddr_in localaddr; + struct sockaddr_in remoteaddr; #endif - struct addrinfo hint; - struct addrinfo *serveraddrs; - char portstr[128]; - ACCEPT_TYPE_ARG3 addrsize; - fd_set fdset; - struct timeval timeout; - int i,r; + struct addrinfo hint; + struct addrinfo *serveraddrs; + char portstr[128]; + ACCEPT_TYPE_ARG3 addrsize; + fd_set fdset; + struct timeval timeout; + int i, + r; /* Make sure struct alignment is correct */ Assert(offsetof(radius_packet, vector) == 4); @@ -2619,8 +2624,8 @@ CheckRADIUSAuth(Port *port) radius_add_attribute(packet, RADIUS_NAS_IDENTIFIER, (unsigned char *) identifier, strlen(identifier)); /* - * RADIUS password attributes are calculated as: - * e[0] = p[0] XOR MD5(secret + vector) + * RADIUS password attributes are calculated as: e[0] = p[0] XOR + * MD5(secret + vector) */ cryptvector = palloc(RADIUS_VECTOR_LENGTH + strlen(port->hba->radiussecret)); memcpy(cryptvector, port->hba->radiussecret, strlen(port->hba->radiussecret)); @@ -2668,7 +2673,7 @@ CheckRADIUSAuth(Port *port) localaddr.sin_addr.s_addr = INADDR_ANY; addrsize = sizeof(struct sockaddr_in); #endif - if (bind(sock, (struct sockaddr *) &localaddr, addrsize)) + if (bind(sock, (struct sockaddr *) & localaddr, addrsize)) { ereport(LOG, (errmsg("could not bind local RADIUS socket: %m"))); @@ -2694,7 +2699,8 @@ CheckRADIUSAuth(Port *port) timeout.tv_sec = RADIUS_TIMEOUT; timeout.tv_usec = 0; FD_ZERO(&fdset); - FD_SET(sock, &fdset); + FD_SET (sock, &fdset); + while (true) { r = select(sock + 1, &fdset, NULL, NULL, &timeout); @@ -2724,7 +2730,7 @@ CheckRADIUSAuth(Port *port) /* Read the response packet */ addrsize = sizeof(remoteaddr); packetlength = recvfrom(sock, receive_buffer, RADIUS_BUFFER_SIZE, 0, - (struct sockaddr *) &remoteaddr, &addrsize); + (struct sockaddr *) & remoteaddr, &addrsize); if (packetlength < 0) { ereport(LOG, @@ -2763,8 +2769,8 @@ CheckRADIUSAuth(Port *port) if (packetlength != ntohs(receivepacket->length)) { ereport(LOG, - (errmsg("RADIUS response has corrupt length: %i (actual length %i)", - ntohs(receivepacket->length), packetlength))); + (errmsg("RADIUS response has corrupt length: %i (actual length %i)", + ntohs(receivepacket->length), packetlength))); return STATUS_ERROR; } @@ -2783,23 +2789,26 @@ CheckRADIUSAuth(Port *port) cryptvector = palloc(packetlength + strlen(port->hba->radiussecret)); memcpy(cryptvector, receivepacket, 4); /* code+id+length */ - memcpy(cryptvector+4, packet->vector, RADIUS_VECTOR_LENGTH); /* request authenticator, from original packet */ - if (packetlength > RADIUS_HEADER_LENGTH) /* there may be no attributes at all */ - memcpy(cryptvector+RADIUS_HEADER_LENGTH, receive_buffer + RADIUS_HEADER_LENGTH, packetlength-RADIUS_HEADER_LENGTH); - memcpy(cryptvector+packetlength, port->hba->radiussecret, strlen(port->hba->radiussecret)); + memcpy(cryptvector + 4, packet->vector, RADIUS_VECTOR_LENGTH); /* request + * authenticator, from + * original packet */ + if (packetlength > RADIUS_HEADER_LENGTH) /* there may be no attributes + * at all */ + memcpy(cryptvector + RADIUS_HEADER_LENGTH, receive_buffer + RADIUS_HEADER_LENGTH, packetlength - RADIUS_HEADER_LENGTH); + memcpy(cryptvector + packetlength, port->hba->radiussecret, strlen(port->hba->radiussecret)); if (!pg_md5_binary(cryptvector, packetlength + strlen(port->hba->radiussecret), encryptedpassword)) { ereport(LOG, - (errmsg("could not perform md5 encryption of received packet"))); + (errmsg("could not perform md5 encryption of received packet"))); pfree(cryptvector); return STATUS_ERROR; } pfree(cryptvector); - if (memcmp(receivepacket->vector, encryptedpassword, RADIUS_VECTOR_LENGTH) != 0) + if (memcmp(receivepacket->vector, encryptedpassword, RADIUS_VECTOR_LENGTH) != 0) { ereport(LOG, (errmsg("RADIUS response has incorrect MD5 signature"))); diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c index 2a317a6a9a4..464183da783 100644 --- a/src/backend/libpq/be-fsstubs.c +++ b/src/backend/libpq/be-fsstubs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.93 2010/01/02 16:57:45 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.94 2010/02/26 02:00:42 momjian Exp $ * * NOTES * This should be moved to a more appropriate place. It is here @@ -55,7 +55,7 @@ /* * compatibility flag for permission checks */ -bool lo_compat_privileges; +bool lo_compat_privileges; /*#define FSDB 1*/ #define BUFSIZE 8192 @@ -167,7 +167,7 @@ lo_read(int fd, char *buf, int len) pg_largeobject_aclcheck_snapshot(cookies[fd]->id, GetUserId(), ACL_SELECT, - cookies[fd]->snapshot) != ACLCHECK_OK) + cookies[fd]->snapshot) != ACLCHECK_OK) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied for large object %u", @@ -199,9 +199,9 @@ lo_write(int fd, const char *buf, int len) pg_largeobject_aclcheck_snapshot(cookies[fd]->id, GetUserId(), ACL_UPDATE, - cookies[fd]->snapshot) != ACLCHECK_OK) + cookies[fd]->snapshot) != ACLCHECK_OK) ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied for large object %u", cookies[fd]->id))); @@ -522,7 +522,7 @@ lo_truncate(PG_FUNCTION_ARGS) pg_largeobject_aclcheck_snapshot(cookies[fd]->id, GetUserId(), ACL_UPDATE, - cookies[fd]->snapshot) != ACLCHECK_OK) + cookies[fd]->snapshot) != ACLCHECK_OK) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied for large object %u", diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index 6dac77bff78..19047bd148a 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.98 2010/02/25 13:26:15 mha Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.99 2010/02/26 02:00:42 momjian Exp $ * * Since the server static private key ($DataDir/server.key) * will normally be stored unencrypted so that the database @@ -98,7 +98,7 @@ static const char *SSLerrmessage(void); * (total in both directions) before we require renegotiation. * Set to 0 to disable renegotiation completely. */ -int ssl_renegotiation_limit; +int ssl_renegotiation_limit; #ifdef USE_SSL static SSL_CTX *SSL_context = NULL; @@ -973,8 +973,8 @@ aloop: else { /* - * Reject embedded NULLs in certificate common name to prevent attacks like - * CVE-2009-4034. + * Reject embedded NULLs in certificate common name to prevent + * attacks like CVE-2009-4034. */ if (r != strlen(port->peer_cn)) { diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 56a20a67491..c956bf10a41 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.80 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.81 2010/02/26 02:00:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,8 +41,8 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass) bool isnull; /* - * Disable immediate interrupts while doing database access. (Note - * we don't bother to turn this back on if we hit one of the failure + * Disable immediate interrupts while doing database access. (Note we + * don't bother to turn this back on if we hit one of the failure * conditions, since we can expect we'll just exit right away anyway.) */ ImmediateInterruptOK = false; @@ -50,14 +50,14 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass) /* Get role info from pg_authid */ roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(role)); if (!HeapTupleIsValid(roleTup)) - return STATUS_ERROR; /* no such user */ + return STATUS_ERROR; /* no such user */ datum = SysCacheGetAttr(AUTHNAME, roleTup, Anum_pg_authid_rolpassword, &isnull); if (isnull) { ReleaseSysCache(roleTup); - return STATUS_ERROR; /* user has no password */ + return STATUS_ERROR; /* user has no password */ } shadow_pass = TextDatumGetCString(datum); @@ -69,7 +69,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass) ReleaseSysCache(roleTup); if (*shadow_pass == '\0') - return STATUS_ERROR; /* empty password */ + return STATUS_ERROR; /* empty password */ /* Re-enable immediate response to SIGTERM/SIGINT/timeout interrupts */ ImmediateInterruptOK = true; diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 94cff7cfd57..ae075ed939c 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.197 2010/02/02 19:09:37 mha Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.198 2010/02/26 02:00:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,8 +56,8 @@ static List *parsed_hba_lines = NIL; /* * These variables hold the pre-parsed contents of the ident usermap - * configuration file. ident_lines is a list of sublists, one sublist for - * each (non-empty, non-comment) line of the file. The sublist items are + * configuration file. ident_lines is a list of sublists, one sublist for + * each (non-empty, non-comment) line of the file. The sublist items are * palloc'd strings, one string per token on the line. Note there will always * be at least one token, since blank lines are not entered in the data * structure. ident_line_nums is an integer list containing the actual line @@ -529,14 +529,14 @@ check_db(const char *dbname, const char *role, Oid roleid, char *param_str) * Check to see if a connecting IP matches the given address and netmask. */ static bool -check_ip(SockAddr *raddr, struct sockaddr *addr, struct sockaddr *mask) +check_ip(SockAddr *raddr, struct sockaddr * addr, struct sockaddr * mask) { if (raddr->addr.ss_family == addr->sa_family) { /* Same address family */ if (!pg_range_sockaddr(&raddr->addr, - (struct sockaddr_storage*)addr, - (struct sockaddr_storage*)mask)) + (struct sockaddr_storage *) addr, + (struct sockaddr_storage *) mask)) return false; } #ifdef HAVE_IPV6 @@ -545,8 +545,8 @@ check_ip(SockAddr *raddr, struct sockaddr *addr, struct sockaddr *mask) { /* * If we're connected on IPv6 but the file specifies an IPv4 address - * to match against, promote the latter to an IPv6 address - * before trying to match the client's address. + * to match against, promote the latter to an IPv6 address before + * trying to match the client's address. */ struct sockaddr_storage addrcopy, maskcopy; @@ -573,7 +573,7 @@ check_ip(SockAddr *raddr, struct sockaddr *addr, struct sockaddr *mask) * pg_foreach_ifaddr callback: does client addr match this machine interface? */ static void -check_network_callback(struct sockaddr *addr, struct sockaddr *netmask, +check_network_callback(struct sockaddr * addr, struct sockaddr * netmask, void *cb_data) { check_network_data *cn = (check_network_data *) cb_data; @@ -587,7 +587,7 @@ check_network_callback(struct sockaddr *addr, struct sockaddr *netmask, { /* Make an all-ones netmask of appropriate length for family */ pg_sockaddr_cidr_mask(&mask, NULL, addr->sa_family); - cn->result = check_ip(cn->raddr, addr, (struct sockaddr*) &mask); + cn->result = check_ip(cn->raddr, addr, (struct sockaddr *) & mask); } else { @@ -825,13 +825,13 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) if (pg_sockaddr_cidr_mask(&parsedline->mask, cidr_slash + 1, parsedline->addr.ss_family) < 0) { - *cidr_slash = '/'; /* restore token for message */ + *cidr_slash = '/'; /* restore token for message */ ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), errmsg("invalid CIDR mask in address \"%s\"", token), - errcontext("line %d of configuration file \"%s\"", - line_num, HbaFileName))); + errcontext("line %d of configuration file \"%s\"", + line_num, HbaFileName))); pfree(token); return false; } @@ -846,9 +846,9 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) { ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("end-of-line before netmask specification"), - errcontext("line %d of configuration file \"%s\"", - line_num, HbaFileName))); + errmsg("end-of-line before netmask specification"), + errcontext("line %d of configuration file \"%s\"", + line_num, HbaFileName))); return false; } token = lfirst(line_item); @@ -860,8 +860,8 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) (errcode(ERRCODE_CONFIG_FILE_ERROR), errmsg("invalid IP mask \"%s\": %s", token, gai_strerror(ret)), - errcontext("line %d of configuration file \"%s\"", - line_num, HbaFileName))); + errcontext("line %d of configuration file \"%s\"", + line_num, HbaFileName))); if (gai_result) pg_freeaddrinfo_all(hints.ai_family, gai_result); return false; @@ -952,7 +952,7 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) #else unsupauth = "cert"; #endif - else if (strcmp(token, "radius")== 0) + else if (strcmp(token, "radius") == 0) parsedline->auth_method = uaRADIUS; else { @@ -1234,8 +1234,8 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) /* * LDAP can operate in two modes: either with a direct bind, using - * ldapprefix and ldapsuffix, or using a search+bind, - * using ldapbasedn, ldapbinddn, ldapbindpasswd and ldapsearchattribute. + * ldapprefix and ldapsuffix, or using a search+bind, using + * ldapbasedn, ldapbinddn, ldapbindpasswd and ldapsearchattribute. * Disallow mixing these parameters. */ if (parsedline->ldapprefix || parsedline->ldapsuffix) @@ -1336,8 +1336,8 @@ check_hba(hbaPort *port) { case ipCmpMask: if (!check_ip(&port->raddr, - (struct sockaddr *) &hba->addr, - (struct sockaddr *) &hba->mask)) + (struct sockaddr *) & hba->addr, + (struct sockaddr *) & hba->mask)) continue; break; case ipCmpSameHost: diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c index 778b9f9ea4a..7c17210cbe6 100644 --- a/src/backend/libpq/ip.c +++ b/src/backend/libpq/ip.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.50 2010/01/10 14:16:07 mha Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.51 2010/02/26 02:00:43 momjian Exp $ * * This file and the IPV6 implementation were initially provided by * Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design @@ -482,7 +482,6 @@ pg_promote_v4_to_v6_mask(struct sockaddr_storage * addr) memcpy(addr, &addr6, sizeof(addr6)); } - #endif /* HAVE_IPV6 */ @@ -492,7 +491,7 @@ pg_promote_v4_to_v6_mask(struct sockaddr_storage * addr) */ static void run_ifaddr_callback(PgIfAddrCallback callback, void *cb_data, - struct sockaddr *addr, struct sockaddr *mask) + struct sockaddr * addr, struct sockaddr * mask) { struct sockaddr_storage fullmask; @@ -508,13 +507,13 @@ run_ifaddr_callback(PgIfAddrCallback callback, void *cb_data, } else if (mask->sa_family == AF_INET) { - if (((struct sockaddr_in*)mask)->sin_addr.s_addr == INADDR_ANY) + if (((struct sockaddr_in *) mask)->sin_addr.s_addr == INADDR_ANY) mask = NULL; } #ifdef HAVE_IPV6 else if (mask->sa_family == AF_INET6) { - if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6*)mask)->sin6_addr)) + if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *) mask)->sin6_addr)) mask = NULL; } #endif @@ -524,7 +523,7 @@ run_ifaddr_callback(PgIfAddrCallback callback, void *cb_data, if (!mask) { pg_sockaddr_cidr_mask(&fullmask, NULL, addr->sa_family); - mask = (struct sockaddr*) &fullmask; + mask = (struct sockaddr *) & fullmask; } (*callback) (addr, mask, cb_data); @@ -544,11 +543,13 @@ run_ifaddr_callback(PgIfAddrCallback callback, void *cb_data, int pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) { - INTERFACE_INFO *ptr, *ii = NULL; - unsigned long length, i; + INTERFACE_INFO *ptr, + *ii = NULL; + unsigned long length, + i; unsigned long n_ii = 0; - SOCKET sock; - int error; + SOCKET sock; + int error; sock = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0); if (sock == SOCKET_ERROR) @@ -557,7 +558,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) while (n_ii < 1024) { n_ii += 64; - ptr = realloc(ii, sizeof (INTERFACE_INFO) * n_ii); + ptr = realloc(ii, sizeof(INTERFACE_INFO) * n_ii); if (!ptr) { free(ii); @@ -568,8 +569,8 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) ii = ptr; if (WSAIoctl(sock, SIO_GET_INTERFACE_LIST, 0, 0, - ii, n_ii * sizeof (INTERFACE_INFO), - &length, 0, 0) == SOCKET_ERROR) + ii, n_ii * sizeof(INTERFACE_INFO), + &length, 0, 0) == SOCKET_ERROR) { error = WSAGetLastError(); if (error == WSAEFAULT || error == WSAENOBUFS) @@ -584,15 +585,14 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) for (i = 0; i < length / sizeof(INTERFACE_INFO); ++i) run_ifaddr_callback(callback, cb_data, - (struct sockaddr*)&ii[i].iiAddress, - (struct sockaddr*)&ii[i].iiNetmask); + (struct sockaddr *) & ii[i].iiAddress, + (struct sockaddr *) & ii[i].iiNetmask); closesocket(sock); free(ii); return 0; } - -#elif HAVE_GETIFADDRS /* && !WIN32 */ +#elif HAVE_GETIFADDRS /* && !WIN32 */ #ifdef HAVE_IFADDRS_H #include <ifaddrs.h> @@ -608,20 +608,20 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) int pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) { - struct ifaddrs *ifa, *l; + struct ifaddrs *ifa, + *l; if (getifaddrs(&ifa) < 0) return -1; for (l = ifa; l; l = l->ifa_next) run_ifaddr_callback(callback, cb_data, - l->ifa_addr, l->ifa_netmask); + l->ifa_addr, l->ifa_netmask); freeifaddrs(ifa); return 0; } - -#else /* !HAVE_GETIFADDRS && !WIN32 */ +#else /* !HAVE_GETIFADDRS && !WIN32 */ #ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> @@ -652,15 +652,21 @@ int pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) { struct lifconf lifc; - struct lifreq *lifr, lmask; - struct sockaddr *addr, *mask; - char *ptr, *buffer = NULL; - size_t n_buffer = 1024; - pgsocket sock, fd; + struct lifreq *lifr, + lmask; + struct sockaddr *addr, + *mask; + char *ptr, + *buffer = NULL; + size_t n_buffer = 1024; + pgsocket sock, + fd; + #ifdef HAVE_IPV6 - pgsocket sock6; + pgsocket sock6; #endif - int i, total; + int i, + total; sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) @@ -678,7 +684,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) return -1; } - memset(&lifc, 0, sizeof (lifc)); + memset(&lifc, 0, sizeof(lifc)); lifc.lifc_family = AF_UNSPEC; lifc.lifc_buf = buffer = ptr; lifc.lifc_len = n_buffer; @@ -693,9 +699,9 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) } /* - * Some Unixes try to return as much data as possible, - * with no indication of whether enough space allocated. - * Don't believe we have it all unless there's lots of slop. + * Some Unixes try to return as much data as possible, with no + * indication of whether enough space allocated. Don't believe we have + * it all unless there's lots of slop. */ if (lifc.lifc_len < n_buffer - 1024) break; @@ -716,7 +722,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) lifr = lifc.lifc_req; for (i = 0; i < total; ++i) { - addr = (struct sockaddr*)&lifr[i].lifr_addr; + addr = (struct sockaddr *) & lifr[i].lifr_addr; memcpy(&lmask, &lifr[i], sizeof(struct lifreq)); #ifdef HAVE_IPV6 fd = (addr->sa_family == AF_INET6) ? sock6 : sock; @@ -726,7 +732,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) if (ioctl(fd, SIOCGLIFNETMASK, &lmask) < 0) mask = NULL; else - mask = (struct sockaddr*)&lmask.lifr_addr; + mask = (struct sockaddr *) & lmask.lifr_addr; run_ifaddr_callback(callback, cb_data, addr, mask); } @@ -737,7 +743,6 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) #endif return 0; } - #elif defined(SIOCGIFCONF) /* @@ -754,17 +759,16 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) /* Calculate based on sockaddr.sa_len */ #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN #define _SIZEOF_ADDR_IFREQ(ifr) \ - ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ - (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ - (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) + ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ + (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ + (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) /* Padded ifreq structure, simple */ #else #define _SIZEOF_ADDR_IFREQ(ifr) \ sizeof (struct ifreq) #endif - -#endif /* !_SIZEOF_ADDR_IFREQ */ +#endif /* !_SIZEOF_ADDR_IFREQ */ /* * Enumerate the system's network interface addresses and call the callback @@ -776,10 +780,14 @@ int pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) { struct ifconf ifc; - struct ifreq *ifr, *end, addr, mask; - char *ptr, *buffer = NULL; - size_t n_buffer = 1024; - int sock; + struct ifreq *ifr, + *end, + addr, + mask; + char *ptr, + *buffer = NULL; + size_t n_buffer = 1024; + int sock; sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) @@ -797,7 +805,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) return -1; } - memset(&ifc, 0, sizeof (ifc)); + memset(&ifc, 0, sizeof(ifc)); ifc.ifc_buf = buffer = ptr; ifc.ifc_len = n_buffer; @@ -811,32 +819,31 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) } /* - * Some Unixes try to return as much data as possible, - * with no indication of whether enough space allocated. - * Don't believe we have it all unless there's lots of slop. + * Some Unixes try to return as much data as possible, with no + * indication of whether enough space allocated. Don't believe we have + * it all unless there's lots of slop. */ if (ifc.ifc_len < n_buffer - 1024) break; } - end = (struct ifreq*)(buffer + ifc.ifc_len); + end = (struct ifreq *) (buffer + ifc.ifc_len); for (ifr = ifc.ifc_req; ifr < end;) { memcpy(&addr, ifr, sizeof(addr)); memcpy(&mask, ifr, sizeof(mask)); if (ioctl(sock, SIOCGIFADDR, &addr, sizeof(addr)) == 0 && - ioctl(sock, SIOCGIFNETMASK, &mask, sizeof(mask)) == 0) + ioctl(sock, SIOCGIFNETMASK, &mask, sizeof(mask)) == 0) run_ifaddr_callback(callback, cb_data, - &addr.ifr_addr, &mask.ifr_addr); - ifr = (struct ifreq*)((char*)ifr + _SIZEOF_ADDR_IFREQ(*ifr)); + &addr.ifr_addr, &mask.ifr_addr); + ifr = (struct ifreq *) ((char *) ifr + _SIZEOF_ADDR_IFREQ(*ifr)); } free(buffer); close(sock); return 0; } - -#else /* !defined(SIOCGIFCONF) */ +#else /* !defined(SIOCGIFCONF) */ /* * Enumerate the system's network interface addresses and call the callback @@ -850,6 +857,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) { struct sockaddr_in addr; struct sockaddr_storage mask; + #ifdef HAVE_IPV6 struct sockaddr_in6 addr6; #endif @@ -861,8 +869,8 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) memset(&mask, 0, sizeof(mask)); pg_sockaddr_cidr_mask(&mask, "8", AF_INET); run_ifaddr_callback(callback, cb_data, - (struct sockaddr*)&addr, - (struct sockaddr*)&mask); + (struct sockaddr *) & addr, + (struct sockaddr *) & mask); #ifdef HAVE_IPV6 /* addr ::1/128 */ @@ -872,13 +880,12 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) memset(&mask, 0, sizeof(mask)); pg_sockaddr_cidr_mask(&mask, "128", AF_INET6); run_ifaddr_callback(callback, cb_data, - (struct sockaddr*)&addr6, - (struct sockaddr*)&mask); + (struct sockaddr *) & addr6, + (struct sockaddr *) & mask); #endif return 0; } +#endif /* !defined(SIOCGIFCONF) */ -#endif /* !defined(SIOCGIFCONF) */ - -#endif /* !HAVE_GETIFADDRS */ +#endif /* !HAVE_GETIFADDRS */ diff --git a/src/backend/libpq/md5.c b/src/backend/libpq/md5.c index e875f51ed72..ff4f9eaebf1 100644 --- a/src/backend/libpq/md5.c +++ b/src/backend/libpq/md5.c @@ -14,7 +14,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.39 2010/01/27 12:11:59 mha Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.40 2010/02/26 02:00:43 momjian Exp $ */ /* This is intended to be used in both frontend and backend, so use c.h */ @@ -298,7 +298,8 @@ pg_md5_hash(const void *buff, size_t len, char *hexsum) return true; } -bool pg_md5_binary(const void *buff, size_t len, void *outbuf) +bool +pg_md5_binary(const void *buff, size_t len, void *outbuf) { if (!calculateDigestFromBuffer((uint8 *) buff, len, outbuf)) return false; @@ -320,6 +321,7 @@ pg_md5_encrypt(const char *passwd, const char *salt, size_t salt_len, char *buf) { size_t passwd_len = strlen(passwd); + /* +1 here is just to avoid risk of unportable malloc(0) */ char *crypt_buf = malloc(passwd_len + salt_len + 1); bool ret; diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index 98b27f1f71a..5826aacaf77 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -30,7 +30,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.204 2010/02/18 11:13:45 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.205 2010/02/26 02:00:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ * pq_peekbyte - peek at next byte from connection * pq_putbytes - send bytes to connection (not flushed until pq_flush) * pq_flush - flush pending output - * pq_getbyte_if_available - get a byte if available without blocking + * pq_getbyte_if_available - get a byte if available without blocking * * message-level I/O (and old-style-COPY-OUT cruft): * pq_putmessage - send a normal message (suppressed in COPY OUT mode) @@ -200,7 +200,8 @@ pq_close(int code, Datum arg) * transport layer reports connection closure, and you can be sure the * backend has exited. * - * We do set sock to PGINVALID_SOCKET to prevent any further I/O, though. + * We do set sock to PGINVALID_SOCKET to prevent any further I/O, + * though. */ MyProcPort->sock = PGINVALID_SOCKET; } @@ -818,7 +819,7 @@ pq_peekbyte(void) /* -------------------------------- - * pq_getbyte_if_available - get a single byte from connection, + * pq_getbyte_if_available - get a single byte from connection, * if available * * The received byte is stored in *c. Returns 1 if a byte was read, @@ -828,7 +829,7 @@ pq_peekbyte(void) int pq_getbyte_if_available(unsigned char *c) { - int r; + int r; if (PqRecvPointer < PqRecvLength) { @@ -851,18 +852,19 @@ pq_getbyte_if_available(unsigned char *c) if (r < 0) { /* - * Ok if no data available without blocking or interrupted - * (though EINTR really shouldn't happen with a non-blocking - * socket). Report other errors. + * Ok if no data available without blocking or interrupted (though + * EINTR really shouldn't happen with a non-blocking socket). + * Report other errors. */ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) r = 0; else { /* - * Careful: an ereport() that tries to write to the client would - * cause recursion to here, leading to stack overflow and core - * dump! This message must go *only* to the postmaster log. + * Careful: an ereport() that tries to write to the client + * would cause recursion to here, leading to stack overflow + * and core dump! This message must go *only* to the + * postmaster log. */ ereport(COMMERROR, (errcode_for_socket_access(), diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 22d24ef21a5..829dc7ba8d2 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.463 2010/02/23 22:51:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.464 2010/02/26 02:00:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -160,7 +160,7 @@ _copyResult(Result *from) static ModifyTable * _copyModifyTable(ModifyTable *from) { - ModifyTable *newnode = makeNode(ModifyTable); + ModifyTable *newnode = makeNode(ModifyTable); /* * copy node superclass fields @@ -806,7 +806,7 @@ _copySetOp(SetOp *from) static LockRows * _copyLockRows(LockRows *from) { - LockRows *newnode = makeNode(LockRows); + LockRows *newnode = makeNode(LockRows); /* * copy node superclass fields diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 9a05bcc1c0f..e97a3ea9daa 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -22,7 +22,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.384 2010/02/23 22:51:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.385 2010/02/26 02:00:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1572,7 +1572,7 @@ _equalDropTableSpaceStmt(DropTableSpaceStmt *a, DropTableSpaceStmt *b) static bool _equalAlterTableSpaceOptionsStmt(AlterTableSpaceOptionsStmt *a, - AlterTableSpaceOptionsStmt *b) + AlterTableSpaceOptionsStmt *b) { COMPARE_STRING_FIELD(tablespacename); COMPARE_NODE_FIELD(options); diff --git a/src/backend/nodes/params.c b/src/backend/nodes/params.c index ef17a9bb321..a4deebf896b 100644 --- a/src/backend/nodes/params.c +++ b/src/backend/nodes/params.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/params.c,v 1.14 2010/01/15 22:36:31 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/params.c,v 1.15 2010/02/26 02:00:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ * * Note: the intent of this function is to make a static, self-contained * set of parameter values. If dynamic parameter hooks are present, we - * intentionally do not copy them into the result. Rather, we forcibly + * intentionally do not copy them into the result. Rather, we forcibly * instantiate all available parameter values and copy the datum values. */ ParamListInfo @@ -61,7 +61,7 @@ copyParamList(ParamListInfo from) /* give hook a chance in case parameter is dynamic */ if (!OidIsValid(oprm->ptype) && from->paramFetch != NULL) - (*from->paramFetch) (from, i+1); + (*from->paramFetch) (from, i + 1); /* flat-copy the parameter info */ *nprm = *oprm; diff --git a/src/backend/optimizer/geqo/geqo_eval.c b/src/backend/optimizer/geqo/geqo_eval.c index f614e056319..353ed1aa1ac 100644 --- a/src/backend/optimizer/geqo/geqo_eval.c +++ b/src/backend/optimizer/geqo/geqo_eval.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.92 2010/01/02 16:57:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.93 2010/02/26 02:00:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ typedef struct } Clump; static List *merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump, - bool force); + bool force); static bool desirable_join(PlannerInfo *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel); @@ -156,14 +156,14 @@ gimme_tree(PlannerInfo *root, Gene *tour, int num_gene) /* * Sometimes, a relation can't yet be joined to others due to heuristics * or actual semantic restrictions. We maintain a list of "clumps" of - * successfully joined relations, with larger clumps at the front. - * Each new relation from the tour is added to the first clump it can - * be joined to; if there is none then it becomes a new clump of its own. - * When we enlarge an existing clump we check to see if it can now be - * merged with any other clumps. After the tour is all scanned, we - * forget about the heuristics and try to forcibly join any remaining - * clumps. Some forced joins might still fail due to semantics, but - * we should always be able to find some join order that works. + * successfully joined relations, with larger clumps at the front. Each + * new relation from the tour is added to the first clump it can be joined + * to; if there is none then it becomes a new clump of its own. When we + * enlarge an existing clump we check to see if it can now be merged with + * any other clumps. After the tour is all scanned, we forget about the + * heuristics and try to forcibly join any remaining clumps. Some forced + * joins might still fail due to semantics, but we should always be able + * to find some join order that works. */ clumps = NIL; @@ -214,7 +214,7 @@ gimme_tree(PlannerInfo *root, Gene *tour, int num_gene) * Merge a "clump" into the list of existing clumps for gimme_tree. * * We try to merge the clump into some existing clump, and repeat if - * successful. When no more merging is possible, insert the clump + * successful. When no more merging is possible, insert the clump * into the list, preserving the list ordering rule (namely, that * clumps of larger size appear earlier). * @@ -265,7 +265,7 @@ merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump, bool force) /* * Recursively try to merge the enlarged old_clump with - * others. When no further merge is possible, we'll reinsert + * others. When no further merge is possible, we'll reinsert * it into the list. */ return merge_clump(root, clumps, old_clump, force); @@ -276,7 +276,7 @@ merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump, bool force) /* * No merging is possible, so add new_clump as an independent clump, in - * proper order according to size. We can be fast for the common case + * proper order according to size. We can be fast for the common case * where it has size 1 --- it should always go at the end. */ if (clumps == NIL || new_clump->size == 1) diff --git a/src/backend/optimizer/geqo/geqo_random.c b/src/backend/optimizer/geqo/geqo_random.c index 15446541ee7..9ff5b40ecd2 100644 --- a/src/backend/optimizer/geqo/geqo_random.c +++ b/src/backend/optimizer/geqo/geqo_random.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_random.c,v 1.2 2010/01/02 16:57:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_random.c,v 1.3 2010/02/26 02:00:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,8 +22,8 @@ geqo_set_seed(PlannerInfo *root, double seed) GeqoPrivateData *private = (GeqoPrivateData *) root->join_search_private; /* - * XXX. This seeding algorithm could certainly be improved - but - * it is not critical to do so. + * XXX. This seeding algorithm could certainly be improved - but it is not + * critical to do so. */ memset(private->random_state, 0, sizeof(private->random_state)); memcpy(private->random_state, diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 8437a8a638d..52f26d255d9 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.192 2010/01/02 16:57:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.193 2010/02/26 02:00:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -347,11 +347,11 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, * can disregard this child. * * As of 8.4, the child rel's targetlist might contain non-Var - * expressions, which means that substitution into the quals - * could produce opportunities for const-simplification, and perhaps - * even pseudoconstant quals. To deal with this, we strip the - * RestrictInfo nodes, do the substitution, do const-simplification, - * and then reconstitute the RestrictInfo layer. + * expressions, which means that substitution into the quals could + * produce opportunities for const-simplification, and perhaps even + * pseudoconstant quals. To deal with this, we strip the RestrictInfo + * nodes, do the substitution, do const-simplification, and then + * reconstitute the RestrictInfo layer. */ childquals = get_all_actual_clauses(rel->baserestrictinfo); childquals = (List *) adjust_appendrel_attrs((Node *) childquals, diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 98d60c5ce06..355db7f6844 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -59,7 +59,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.215 2010/02/19 21:49:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.216 2010/02/26 02:00:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -635,11 +635,11 @@ cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel, pages_fetched = ceil(pages_fetched); /* - * For small numbers of pages we should charge spc_random_page_cost apiece, - * while if nearly all the table's pages are being read, it's more - * appropriate to charge spc_seq_page_cost apiece. The effect is nonlinear, - * too. For lack of a better idea, interpolate like this to determine the - * cost per page. + * For small numbers of pages we should charge spc_random_page_cost + * apiece, while if nearly all the table's pages are being read, it's more + * appropriate to charge spc_seq_page_cost apiece. The effect is + * nonlinear, too. For lack of a better idea, interpolate like this to + * determine the cost per page. */ if (pages_fetched >= 2.0) cost_per_page = spc_random_page_cost - @@ -936,13 +936,13 @@ cost_functionscan(Path *path, PlannerInfo *root, RelOptInfo *baserel) * * Currently, nodeFunctionscan.c always executes the function to * completion before returning any rows, and caches the results in a - * tuplestore. So the function eval cost is all startup cost, and - * per-row costs are minimal. + * tuplestore. So the function eval cost is all startup cost, and per-row + * costs are minimal. * * XXX in principle we ought to charge tuplestore spill costs if the * number of rows is large. However, given how phony our rowcount - * estimates for functions tend to be, there's not a lot of point - * in that refinement right now. + * estimates for functions tend to be, there's not a lot of point in that + * refinement right now. */ cost_qual_eval_node(&exprcost, rte->funcexpr, root); @@ -1230,7 +1230,7 @@ cost_material(Path *path, * if it is exactly the same then there will be a cost tie between * nestloop with A outer, materialized B inner and nestloop with B outer, * materialized A inner. The extra cost ensures we'll prefer - * materializing the smaller rel.) Note that this is normally a good deal + * materializing the smaller rel.) Note that this is normally a good deal * less than cpu_tuple_cost; which is OK because a Material plan node * doesn't do qual-checking or projection, so it's got less overhead than * most plan nodes. @@ -1526,9 +1526,10 @@ cost_nestloop(NestPath *path, PlannerInfo *root, SpecialJoinInfo *sjinfo) { run_cost += (outer_path_rows - outer_matched_rows) * inner_rescan_run_cost / inner_path_rows; + /* - * We won't be evaluating any quals at all for these rows, - * so don't add them to ntuples. + * We won't be evaluating any quals at all for these rows, so + * don't add them to ntuples. */ } else @@ -1568,10 +1569,10 @@ cost_nestloop(NestPath *path, PlannerInfo *root, SpecialJoinInfo *sjinfo) * Unlike other costsize functions, this routine makes one actual decision: * whether we should materialize the inner path. We do that either because * the inner path can't support mark/restore, or because it's cheaper to - * use an interposed Material node to handle mark/restore. When the decision + * use an interposed Material node to handle mark/restore. When the decision * is cost-based it would be logically cleaner to build and cost two separate * paths with and without that flag set; but that would require repeating most - * of the calculations here, which are not all that cheap. Since the choice + * of the calculations here, which are not all that cheap. Since the choice * will not affect output pathkeys or startup cost, only total cost, there is * no possibility of wanting to keep both paths. So it seems best to make * the decision here and record it in the path's materialize_inner field. @@ -1826,14 +1827,15 @@ cost_mergejoin(MergePath *path, PlannerInfo *root, SpecialJoinInfo *sjinfo) /* * Decide whether we want to materialize the inner input to shield it from - * mark/restore and performing re-fetches. Our cost model for regular + * mark/restore and performing re-fetches. Our cost model for regular * re-fetches is that a re-fetch costs the same as an original fetch, * which is probably an overestimate; but on the other hand we ignore the * bookkeeping costs of mark/restore. Not clear if it's worth developing - * a more refined model. So we just need to inflate the inner run cost - * by rescanratio. + * a more refined model. So we just need to inflate the inner run cost by + * rescanratio. */ bare_inner_cost = inner_run_cost * rescanratio; + /* * When we interpose a Material node the re-fetch cost is assumed to be * just cpu_operator_cost per tuple, independently of the underlying @@ -1842,7 +1844,7 @@ cost_mergejoin(MergePath *path, PlannerInfo *root, SpecialJoinInfo *sjinfo) * never spill to disk, since it only has to remember tuples back to the * last mark. (If there are a huge number of duplicates, our other cost * factors will make the path so expensive that it probably won't get - * chosen anyway.) So we don't use cost_rescan here. + * chosen anyway.) So we don't use cost_rescan here. * * Note: keep this estimate in sync with create_mergejoin_plan's labeling * of the generated Material node. @@ -1853,6 +1855,7 @@ cost_mergejoin(MergePath *path, PlannerInfo *root, SpecialJoinInfo *sjinfo) /* Prefer materializing if it looks cheaper */ if (mat_inner_cost < bare_inner_cost) path->materialize_inner = true; + /* * Even if materializing doesn't look cheaper, we *must* do it if the * inner path is to be used directly (without sorting) and it doesn't @@ -1868,6 +1871,7 @@ cost_mergejoin(MergePath *path, PlannerInfo *root, SpecialJoinInfo *sjinfo) else if (innersortkeys == NIL && !ExecSupportsMarkRestore(inner_path->pathtype)) path->materialize_inner = true; + /* * Also, force materializing if the inner path is to be sorted and the * sort is expected to spill to disk. This is because the final merge @@ -2323,10 +2327,10 @@ cost_subplan(PlannerInfo *root, SubPlan *subplan, Plan *plan) /* * cost_rescan * Given a finished Path, estimate the costs of rescanning it after - * having done so the first time. For some Path types a rescan is + * having done so the first time. For some Path types a rescan is * cheaper than an original scan (if no parameters change), and this * function embodies knowledge about that. The default is to return - * the same costs stored in the Path. (Note that the cost estimates + * the same costs stored in the Path. (Note that the cost estimates * actually stored in Paths are always for first scans.) * * This function is not currently intended to model effects such as rescans @@ -2336,23 +2340,25 @@ cost_subplan(PlannerInfo *root, SubPlan *subplan, Plan *plan) */ static void cost_rescan(PlannerInfo *root, Path *path, - Cost *rescan_startup_cost, /* output parameters */ + Cost *rescan_startup_cost, /* output parameters */ Cost *rescan_total_cost) { switch (path->pathtype) { case T_FunctionScan: + /* - * Currently, nodeFunctionscan.c always executes the function - * to completion before returning any rows, and caches the - * results in a tuplestore. So the function eval cost is - * all startup cost and isn't paid over again on rescans. - * However, all run costs will be paid over again. + * Currently, nodeFunctionscan.c always executes the function to + * completion before returning any rows, and caches the results in + * a tuplestore. So the function eval cost is all startup cost + * and isn't paid over again on rescans. However, all run costs + * will be paid over again. */ *rescan_startup_cost = 0; *rescan_total_cost = path->total_cost - path->startup_cost; break; case T_HashJoin: + /* * Assume that all of the startup cost represents hash table * building, which we won't have to do over. @@ -2365,14 +2371,14 @@ cost_rescan(PlannerInfo *root, Path *path, { /* * These plan types materialize their final result in a - * tuplestore or tuplesort object. So the rescan cost is only + * tuplestore or tuplesort object. So the rescan cost is only * cpu_tuple_cost per tuple, unless the result is large enough * to spill to disk. */ - Cost run_cost = cpu_tuple_cost * path->parent->rows; - double nbytes = relation_byte_size(path->parent->rows, - path->parent->width); - long work_mem_bytes = work_mem * 1024L; + Cost run_cost = cpu_tuple_cost * path->parent->rows; + double nbytes = relation_byte_size(path->parent->rows, + path->parent->width); + long work_mem_bytes = work_mem * 1024L; if (nbytes > work_mem_bytes) { @@ -2389,17 +2395,17 @@ cost_rescan(PlannerInfo *root, Path *path, case T_Sort: { /* - * These plan types not only materialize their results, but - * do not implement qual filtering or projection. So they - * are even cheaper to rescan than the ones above. We charge - * only cpu_operator_cost per tuple. (Note: keep that in - * sync with the run_cost charge in cost_sort, and also see - * comments in cost_material before you change it.) + * These plan types not only materialize their results, but do + * not implement qual filtering or projection. So they are + * even cheaper to rescan than the ones above. We charge only + * cpu_operator_cost per tuple. (Note: keep that in sync with + * the run_cost charge in cost_sort, and also see comments in + * cost_material before you change it.) */ - Cost run_cost = cpu_operator_cost * path->parent->rows; - double nbytes = relation_byte_size(path->parent->rows, - path->parent->width); - long work_mem_bytes = work_mem * 1024L; + Cost run_cost = cpu_operator_cost * path->parent->rows; + double nbytes = relation_byte_size(path->parent->rows, + path->parent->width); + long work_mem_bytes = work_mem * 1024L; if (nbytes > work_mem_bytes) { @@ -3212,8 +3218,8 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel) { /* * We could be looking at an expression pulled up from a subquery, - * or a ROW() representing a whole-row child Var, etc. Do what - * we can using the expression type information. + * or a ROW() representing a whole-row child Var, etc. Do what we + * can using the expression type information. */ int32 item_width; diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c index a2b6319d5e7..75219d0f334 100644 --- a/src/backend/optimizer/path/equivclass.c +++ b/src/backend/optimizer/path/equivclass.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/equivclass.c,v 1.22 2010/01/02 16:57:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/equivclass.c,v 1.23 2010/02/26 02:00:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,14 +115,13 @@ process_equivalence(PlannerInfo *root, RestrictInfo *restrictinfo, item2_relids = restrictinfo->right_relids; /* - * Reject clauses of the form X=X. These are not as redundant as they + * Reject clauses of the form X=X. These are not as redundant as they * might seem at first glance: assuming the operator is strict, this is - * really an expensive way to write X IS NOT NULL. So we must not risk - * just losing the clause, which would be possible if there is already - * a single-element EquivalenceClass containing X. The case is not - * common enough to be worth contorting the EC machinery for, so just - * reject the clause and let it be processed as a normal restriction - * clause. + * really an expensive way to write X IS NOT NULL. So we must not risk + * just losing the clause, which would be possible if there is already a + * single-element EquivalenceClass containing X. The case is not common + * enough to be worth contorting the EC machinery for, so just reject the + * clause and let it be processed as a normal restriction clause. */ if (equal(item1, item2)) return false; /* X=X is not a useful equivalence */ @@ -367,7 +366,7 @@ add_eq_member(EquivalenceClass *ec, Expr *expr, Relids relids, * EquivalenceClass for it. * * sortref is the SortGroupRef of the originating SortGroupClause, if any, - * or zero if not. (It should never be zero if the expression is volatile!) + * or zero if not. (It should never be zero if the expression is volatile!) * * This can be used safely both before and after EquivalenceClass merging; * since it never causes merging it does not invalidate any existing ECs @@ -448,7 +447,7 @@ get_eclass_for_sort_expr(PlannerInfo *root, newec->ec_sortref = sortref; newec->ec_merged = NULL; - if (newec->ec_has_volatile && sortref == 0) /* should not happen */ + if (newec->ec_has_volatile && sortref == 0) /* should not happen */ elog(ERROR, "volatile EquivalenceClass has no sortref"); newem = add_eq_member(newec, expr, pull_varnos((Node *) expr), diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 3cf971c9c0f..2c97bea3fa3 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.245 2010/01/02 16:57:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.246 2010/02/26 02:00:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1944,8 +1944,8 @@ relation_has_unique_index_for(PlannerInfo *root, RelOptInfo *rel, /* Examine each index of the relation ... */ foreach(ic, rel->indexlist) { - IndexOptInfo *ind = (IndexOptInfo *) lfirst(ic); - int c; + IndexOptInfo *ind = (IndexOptInfo *) lfirst(ic); + int c; /* * If the index is not unique or if it's a partial index that doesn't @@ -1964,13 +1964,13 @@ relation_has_unique_index_for(PlannerInfo *root, RelOptInfo *rel, foreach(lc, restrictlist) { - RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc); - Node *rexpr; + RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc); + Node *rexpr; /* * The condition's equality operator must be a member of the - * index opfamily, else it is not asserting the right kind - * of equality behavior for this index. We check this first + * index opfamily, else it is not asserting the right kind of + * equality behavior for this index. We check this first * since it's probably cheaper than match_index_to_operand(). */ if (!list_member_oid(rinfo->mergeopfamilies, ind->opfamily[c])) diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 2e208cb6210..35c9353d2e2 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.129 2010/01/05 23:25:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.130 2010/02/26 02:00:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -161,7 +161,7 @@ add_paths_to_joinrel(PlannerInfo *root, * We already know that the clause is a binary opclause referencing only the * rels in the current join. The point here is to check whether it has the * form "outerrel_expr op innerrel_expr" or "innerrel_expr op outerrel_expr", - * rather than mixing outer and inner vars on either side. If it matches, + * rather than mixing outer and inner vars on either side. If it matches, * we set the transient flag outer_is_left to identify which side is which. */ static inline bool @@ -212,7 +212,7 @@ join_is_removable(PlannerInfo *root, /* * Currently, we only know how to remove left joins to a baserel with - * unique indexes. We can check most of these criteria pretty trivially + * unique indexes. We can check most of these criteria pretty trivially * to avoid doing useless extra work. But checking whether any of the * indexes are unique would require iterating over the indexlist, so for * now we just make sure there are indexes of some sort or other. If none @@ -225,13 +225,12 @@ join_is_removable(PlannerInfo *root, return false; /* - * We can't remove the join if any inner-rel attributes are used above - * the join. + * We can't remove the join if any inner-rel attributes are used above the + * join. * - * Note that this test only detects use of inner-rel attributes in - * higher join conditions and the target list. There might be such - * attributes in pushed-down conditions at this join, too. We check - * that case below. + * Note that this test only detects use of inner-rel attributes in higher + * join conditions and the target list. There might be such attributes in + * pushed-down conditions at this join, too. We check that case below. * * As a micro-optimization, it seems better to start with max_attr and * count down rather than starting with min_attr and counting up, on the @@ -249,9 +248,9 @@ join_is_removable(PlannerInfo *root, /* * Search for mergejoinable clauses that constrain the inner rel against * either the outer rel or a pseudoconstant. If an operator is - * mergejoinable then it behaves like equality for some btree opclass, - * so it's what we want. The mergejoinability test also eliminates - * clauses containing volatile functions, which we couldn't depend on. + * mergejoinable then it behaves like equality for some btree opclass, so + * it's what we want. The mergejoinability test also eliminates clauses + * containing volatile functions, which we couldn't depend on. */ foreach(l, restrictlist) { @@ -259,10 +258,10 @@ join_is_removable(PlannerInfo *root, /* * If we find a pushed-down clause, it must have come from above the - * outer join and it must contain references to the inner rel. (If - * it had only outer-rel variables, it'd have been pushed down into - * the outer rel.) Therefore, we can conclude that join removal - * is unsafe without any examination of the clause contents. + * outer join and it must contain references to the inner rel. (If it + * had only outer-rel variables, it'd have been pushed down into the + * outer rel.) Therefore, we can conclude that join removal is unsafe + * without any examination of the clause contents. */ if (restrictinfo->is_pushed_down) return false; @@ -289,15 +288,15 @@ join_is_removable(PlannerInfo *root, /* * Note: can_join won't be set for a restriction clause, but - * mergeopfamilies will be if it has a mergejoinable operator - * and doesn't contain volatile functions. + * mergeopfamilies will be if it has a mergejoinable operator and + * doesn't contain volatile functions. */ if (restrictinfo->mergeopfamilies == NIL) continue; /* not mergejoinable */ /* - * The clause certainly doesn't refer to anything but the given - * rel. If either side is pseudoconstant then we can use it. + * The clause certainly doesn't refer to anything but the given rel. + * If either side is pseudoconstant then we can use it. */ if (bms_is_empty(restrictinfo->left_relids)) { @@ -340,13 +339,13 @@ generate_outer_only(PlannerInfo *root, RelOptInfo *joinrel, /* * For the moment, replicate all of the outerrel's paths as join paths. * Some of them might not really be interesting above the join, if they - * have sort orderings that have no real use except to do a mergejoin - * for the join we've just found we don't need. But distinguishing that - * case probably isn't worth the extra code it would take. + * have sort orderings that have no real use except to do a mergejoin for + * the join we've just found we don't need. But distinguishing that case + * probably isn't worth the extra code it would take. */ foreach(lc, outerrel->pathlist) { - Path *outerpath = (Path *) lfirst(lc); + Path *outerpath = (Path *) lfirst(lc); add_path(joinrel, (Path *) create_noop_path(root, joinrel, outerpath)); @@ -1189,8 +1188,8 @@ select_mergejoin_clauses(PlannerInfo *root, restrictinfo->mergeopfamilies == NIL) { /* - * The executor can handle extra joinquals that are constants, - * but not anything else, when doing right/full merge join. (The + * The executor can handle extra joinquals that are constants, but + * not anything else, when doing right/full merge join. (The * reason to support constants is so we can do FULL JOIN ON * FALSE.) */ diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index 3a332473080..e781ad5c1a8 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.104 2010/01/02 16:57:47 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.105 2010/02/26 02:00:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -373,10 +373,10 @@ join_is_legal(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, continue; /* - * If it's a semijoin and we already joined the RHS to any other - * rels within either input, then we must have unique-ified the RHS - * at that point (see below). Therefore the semijoin is no longer - * relevant in this join path. + * If it's a semijoin and we already joined the RHS to any other rels + * within either input, then we must have unique-ified the RHS at that + * point (see below). Therefore the semijoin is no longer relevant in + * this join path. */ if (sjinfo->jointype == JOIN_SEMI) { @@ -495,9 +495,9 @@ join_is_legal(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, } /* - * Fail if violated some SJ's RHS and didn't match to another SJ. - * However, "matching" to a semijoin we are implementing by - * unique-ification doesn't count (think: it's really an inner join). + * Fail if violated some SJ's RHS and didn't match to another SJ. However, + * "matching" to a semijoin we are implementing by unique-ification + * doesn't count (think: it's really an inner join). */ if (!is_valid_inner && (match_sjinfo == NULL || unique_ified)) diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index 066cfbdb356..3f0c2fe9040 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.100 2010/01/02 16:57:47 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.101 2010/02/26 02:00:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -637,12 +637,12 @@ convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel, 0); /* - * Note: it might look funny to be setting sortref = 0 for - * a reference to a volatile sub_eclass. However, the - * expression is *not* volatile in the outer query: it's - * just a Var referencing whatever the subquery emitted. - * (IOW, the outer query isn't going to re-execute the - * volatile expression itself.) So this is okay. + * Note: it might look funny to be setting sortref = 0 for a + * reference to a volatile sub_eclass. However, the + * expression is *not* volatile in the outer query: it's just + * a Var referencing whatever the subquery emitted. (IOW, the + * outer query isn't going to re-execute the volatile + * expression itself.) So this is okay. */ outer_ec = get_eclass_for_sort_expr(root, @@ -1000,7 +1000,7 @@ find_mergeclauses_for_pathkeys(PlannerInfo *root, * It's possible that multiple matching clauses might have different * ECs on the other side, in which case the order we put them into our * result makes a difference in the pathkeys required for the other - * input path. However this routine hasn't got any info about which + * input path. However this routine hasn't got any info about which * order would be best, so we don't worry about that. * * It's also possible that the selected mergejoin clauses produce diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 5c35f77ec2d..db47054ecdc 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.272 2010/02/19 21:49:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.273 2010/02/26 02:00:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1694,8 +1694,8 @@ create_mergejoin_plan(PlannerInfo *root, innerpathkeys = best_path->jpath.innerjoinpath->pathkeys; /* - * If specified, add a materialize node to shield the inner plan from - * the need to handle mark/restore. + * If specified, add a materialize node to shield the inner plan from the + * need to handle mark/restore. */ if (best_path->materialize_inner) { @@ -1754,9 +1754,9 @@ create_mergejoin_plan(PlannerInfo *root, Assert(ieclass != NULL); /* - * For debugging purposes, we check that the eclasses match the - * paths' pathkeys. In typical cases the merge clauses are one-to-one - * with the pathkeys, but when dealing with partially redundant query + * For debugging purposes, we check that the eclasses match the paths' + * pathkeys. In typical cases the merge clauses are one-to-one with + * the pathkeys, but when dealing with partially redundant query * conditions, we might have clauses that re-reference earlier path * keys. The case that we need to reject is where a pathkey is * entirely skipped over. @@ -1861,9 +1861,9 @@ create_mergejoin_plan(PlannerInfo *root, } /* - * Note: it is not an error if we have additional pathkey elements - * (i.e., lop or lip isn't NULL here). The input paths might be - * better-sorted than we need for the current mergejoin. + * Note: it is not an error if we have additional pathkey elements (i.e., + * lop or lip isn't NULL here). The input paths might be better-sorted + * than we need for the current mergejoin. */ /* @@ -3751,7 +3751,7 @@ make_result(PlannerInfo *root, * Build a ModifyTable plan node * * Currently, we don't charge anything extra for the actual table modification - * work, nor for the RETURNING expressions if any. It would only be window + * work, nor for the RETURNING expressions if any. It would only be window * dressing, since these are always top-level nodes and there is no way for * the costs to change any higher-level planning choices. But we might want * to make it look better sometime. @@ -3781,7 +3781,7 @@ make_modifytable(CmdType operation, List *resultRelations, { Plan *subplan = (Plan *) lfirst(subnode); - if (subnode == list_head(subplans)) /* first node? */ + if (subnode == list_head(subplans)) /* first node? */ plan->startup_cost = subplan->startup_cost; plan->total_cost += subplan->total_cost; plan->plan_rows += subplan->plan_rows; @@ -3798,8 +3798,8 @@ make_modifytable(CmdType operation, List *resultRelations, /* * Set up the visible plan targetlist as being the same as the first - * RETURNING list. This is for the use of EXPLAIN; the executor won't - * pay any attention to the targetlist. + * RETURNING list. This is for the use of EXPLAIN; the executor won't pay + * any attention to the targetlist. */ if (returningLists) node->plan.targetlist = copyObject(linitial(returningLists)); diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index a3e70935703..f8e1d523bb2 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.157 2010/01/02 16:57:47 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.158 2010/02/26 02:00:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -560,8 +560,8 @@ make_outerjoininfo(PlannerInfo *root, * FOR UPDATE applied to a view. Only after rewriting and flattening do * we know whether the view contains an outer join. * - * We use the original RowMarkClause list here; the PlanRowMark list - * would list everything. + * We use the original RowMarkClause list here; the PlanRowMark list would + * list everything. */ foreach(l, root->parse->rowMarks) { diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 77e9d65ae7e..356fe17df4b 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.265 2010/02/12 17:33:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.266 2010/02/26 02:00:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -370,7 +370,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse, } /* - * Preprocess RowMark information. We need to do this after subquery + * Preprocess RowMark information. We need to do this after subquery * pullup (so that all non-inherited RTEs are present) and before * inheritance expansion (so that the info is available for * expand_inherited_tables to examine and modify). @@ -525,8 +525,8 @@ subquery_planner(PlannerGlobal *glob, Query *parse, /* If it's not SELECT, we need a ModifyTable node */ if (parse->commandType != CMD_SELECT) { - List *returningLists; - List *rowMarks; + List *returningLists; + List *rowMarks; /* * Deal with the RETURNING clause if any. It's convenient to pass @@ -542,7 +542,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse, rlist = set_returning_clause_references(root->glob, parse->returningList, plan, - parse->resultRelation); + parse->resultRelation); returningLists = list_make1(rlist); } else @@ -559,7 +559,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse, rowMarks = root->rowMarks; plan = (Plan *) make_modifytable(parse->commandType, - copyObject(root->resultRelations), + copyObject(root->resultRelations), list_make1(plan), returningLists, rowMarks, @@ -614,11 +614,11 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind) * Simplify constant expressions. * * Note: an essential effect of this is to convert named-argument function - * calls to positional notation and insert the current actual values - * of any default arguments for functions. To ensure that happens, we - * *must* process all expressions here. Previous PG versions sometimes - * skipped const-simplification if it didn't seem worth the trouble, but - * we can't do that anymore. + * calls to positional notation and insert the current actual values of + * any default arguments for functions. To ensure that happens, we *must* + * process all expressions here. Previous PG versions sometimes skipped + * const-simplification if it didn't seem worth the trouble, but we can't + * do that anymore. * * Note: this also flattens nested AND and OR expressions into N-argument * form. All processing of a qual expression after this point must be @@ -783,7 +783,7 @@ inheritance_planner(PlannerInfo *root) List *rlist; rlist = set_returning_clause_references(root->glob, - subroot.parse->returningList, + subroot.parse->returningList, subplan, appinfo->child_relid); returningLists = lappend(returningLists, rlist); @@ -796,8 +796,8 @@ inheritance_planner(PlannerInfo *root) root->query_pathkeys = NIL; /* - * If we managed to exclude every child rel, return a dummy plan; - * it doesn't even need a ModifyTable node. + * If we managed to exclude every child rel, return a dummy plan; it + * doesn't even need a ModifyTable node. */ if (subplans == NIL) { @@ -825,9 +825,9 @@ inheritance_planner(PlannerInfo *root) parse->rtable = rtable; /* - * If there was a FOR UPDATE/SHARE clause, the LockRows node will - * have dealt with fetching non-locked marked rows, else we need - * to have ModifyTable do that. + * If there was a FOR UPDATE/SHARE clause, the LockRows node will have + * dealt with fetching non-locked marked rows, else we need to have + * ModifyTable do that. */ if (parse->rowMarks) rowMarks = NIL; @@ -837,7 +837,7 @@ inheritance_planner(PlannerInfo *root) /* And last, tack on a ModifyTable node to do the UPDATE/DELETE work */ return (Plan *) make_modifytable(parse->commandType, copyObject(root->resultRelations), - subplans, + subplans, returningLists, rowMarks, SS_assign_special_param(root)); @@ -1121,8 +1121,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) } else { - path_rows = 1; /* assume non-set result */ - path_width = 100; /* arbitrary */ + path_rows = 1; /* assume non-set result */ + path_width = 100; /* arbitrary */ } if (parse->groupClause) @@ -1424,8 +1424,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) * WindowFuncs. It's probably not worth trying to optimize that * though.) We also need any volatile sort expressions, because * make_sort_from_pathkeys won't add those on its own, and anyway - * we want them evaluated only once at the bottom of the stack. - * As we climb up the stack, we add outputs for the WindowFuncs + * we want them evaluated only once at the bottom of the stack. As + * we climb up the stack, we add outputs for the WindowFuncs * computed at each level. Also, each input tlist has to present * all the columns needed to sort the data for the next WindowAgg * step. That's handled internally by make_sort_from_pathkeys, @@ -1659,16 +1659,17 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) } /* - * If there is a FOR UPDATE/SHARE clause, add the LockRows node. - * (Note: we intentionally test parse->rowMarks not root->rowMarks here. - * If there are only non-locking rowmarks, they should be handled by - * the ModifyTable node instead.) + * If there is a FOR UPDATE/SHARE clause, add the LockRows node. (Note: we + * intentionally test parse->rowMarks not root->rowMarks here. If there + * are only non-locking rowmarks, they should be handled by the + * ModifyTable node instead.) */ if (parse->rowMarks) { result_plan = (Plan *) make_lockrows(result_plan, root->rowMarks, SS_assign_special_param(root)); + /* * The result can no longer be assumed sorted, since locking might * cause the sort key columns to be replaced with new values. @@ -1811,9 +1812,9 @@ preprocess_rowmarks(PlannerInfo *root) } /* - * We need to have rowmarks for all base relations except the target. - * We make a bitmapset of all base rels and then remove the items we - * don't need or have FOR UPDATE/SHARE marks for. + * We need to have rowmarks for all base relations except the target. We + * make a bitmapset of all base rels and then remove the items we don't + * need or have FOR UPDATE/SHARE marks for. */ rels = get_base_rel_indexes((Node *) parse->jointree); if (parse->resultRelation) @@ -1831,16 +1832,16 @@ preprocess_rowmarks(PlannerInfo *root) /* * Currently, it is syntactically impossible to have FOR UPDATE - * applied to an update/delete target rel. If that ever becomes + * applied to an update/delete target rel. If that ever becomes * possible, we should drop the target from the PlanRowMark list. */ Assert(rc->rti != parse->resultRelation); /* - * Ignore RowMarkClauses for subqueries; they aren't real tables - * and can't support true locking. Subqueries that got flattened - * into the main query should be ignored completely. Any that didn't - * will get ROW_MARK_COPY items in the next loop. + * Ignore RowMarkClauses for subqueries; they aren't real tables and + * can't support true locking. Subqueries that got flattened into the + * main query should be ignored completely. Any that didn't will get + * ROW_MARK_COPY items in the next loop. */ if (rte->rtekind != RTE_RELATION) continue; @@ -1883,7 +1884,7 @@ preprocess_rowmarks(PlannerInfo *root) newrc->markType = ROW_MARK_REFERENCE; else newrc->markType = ROW_MARK_COPY; - newrc->noWait = false; /* doesn't matter */ + newrc->noWait = false; /* doesn't matter */ newrc->isParent = false; /* attnos will be assigned in preprocess_targetlist */ newrc->ctidAttNo = InvalidAttrNumber; @@ -2196,7 +2197,7 @@ choose_hashed_grouping(PlannerInfo *root, /* * Executor doesn't support hashed aggregation with DISTINCT or ORDER BY - * aggregates. (Doing so would imply storing *all* the input values in + * aggregates. (Doing so would imply storing *all* the input values in * the hash table, and/or running many sorts in parallel, either of which * seems like a certain loser.) */ @@ -2364,8 +2365,8 @@ choose_hashed_distinct(PlannerInfo *root, Path sorted_p; /* - * If we have a sortable DISTINCT ON clause, we always use sorting. - * This enforces the expected behavior of DISTINCT ON. + * If we have a sortable DISTINCT ON clause, we always use sorting. This + * enforces the expected behavior of DISTINCT ON. */ can_sort = grouping_is_sortable(parse->distinctClause); if (can_sort && parse->hasDistinctOn) diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index d1d875d3cf0..70be2e66f2d 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.159 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.160 2010/02/26 02:00:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -431,8 +431,8 @@ set_plan_refs(PlannerGlobal *glob, Plan *plan, int rtoffset) /* * Like the plan types above, LockRows doesn't evaluate its - * tlist or quals. But we have to fix up the RT indexes - * in its rowmarks. + * tlist or quals. But we have to fix up the RT indexes in + * its rowmarks. */ set_dummy_tlist_references(plan, rtoffset); Assert(splan->plan.qual == NIL); @@ -471,7 +471,7 @@ set_plan_refs(PlannerGlobal *glob, Plan *plan, int rtoffset) break; case T_WindowAgg: { - WindowAgg *wplan = (WindowAgg *) plan; + WindowAgg *wplan = (WindowAgg *) plan; set_upper_references(glob, plan, rtoffset); @@ -1514,7 +1514,7 @@ search_indexed_tlist_for_sortgroupref(Node *node, exprType((Node *) tle->expr), exprTypmod((Node *) tle->expr), 0); - newvar->varnoold = 0; /* wasn't ever a plain Var */ + newvar->varnoold = 0; /* wasn't ever a plain Var */ newvar->varoattno = 0; return newvar; } diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index 202243c35b9..16dbc3ad443 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.160 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.161 2010/02/26 02:00:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1766,8 +1766,8 @@ SS_finalize_plan(PlannerInfo *root, Plan *plan, bool attach_initplans) * output parameters of any initPlans. (We do not include output * parameters of regular subplans. Those should only appear within the * testexpr of SubPlan nodes, and are taken care of locally within - * finalize_primnode. Likewise, special parameters that are generated - * by nodes such as ModifyTable are handled within finalize_plan.) + * finalize_primnode. Likewise, special parameters that are generated by + * nodes such as ModifyTable are handled within finalize_plan.) * * Note: this is a bit overly generous since some parameters of upper * query levels might belong to query subtrees that don't include this @@ -1944,14 +1944,14 @@ finalize_plan(PlannerInfo *root, Plan *plan, Bitmapset *valid_params, * You might think we should add the node's cteParam to * paramids, but we shouldn't because that param is just a * linkage mechanism for multiple CteScan nodes for the same - * CTE; it is never used for changed-param signaling. What - * we have to do instead is to find the referenced CTE plan - * and incorporate its external paramids, so that the correct + * CTE; it is never used for changed-param signaling. What we + * have to do instead is to find the referenced CTE plan and + * incorporate its external paramids, so that the correct * things will happen if the CTE references outer-level * variables. See test cases for bug #4902. */ - int plan_id = ((CteScan *) plan)->ctePlanId; - Plan *cteplan; + int plan_id = ((CteScan *) plan)->ctePlanId; + Plan *cteplan; /* so, do this ... */ if (plan_id < 1 || plan_id > list_length(root->glob->subplans)) diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index 914703227f4..bcc1fe2be33 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.70 2010/01/02 16:57:47 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.71 2010/02/26 02:00:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,13 +39,13 @@ typedef struct pullup_replace_vars_context { PlannerInfo *root; - List *targetlist; /* tlist of subquery being pulled up */ - RangeTblEntry *target_rte; /* RTE of subquery */ - bool *outer_hasSubLinks; /* -> outer query's hasSubLinks */ - int varno; /* varno of subquery */ - bool need_phvs; /* do we need PlaceHolderVars? */ - bool wrap_non_vars; /* do we need 'em on *all* non-Vars? */ - Node **rv_cache; /* cache for results with PHVs */ + List *targetlist; /* tlist of subquery being pulled up */ + RangeTblEntry *target_rte; /* RTE of subquery */ + bool *outer_hasSubLinks; /* -> outer query's hasSubLinks */ + int varno; /* varno of subquery */ + bool need_phvs; /* do we need PlaceHolderVars? */ + bool wrap_non_vars; /* do we need 'em on *all* non-Vars? */ + Node **rv_cache; /* cache for results with PHVs */ } pullup_replace_vars_context; typedef struct reduce_outer_joins_state @@ -79,7 +79,7 @@ static void replace_vars_in_jointree(Node *jtnode, pullup_replace_vars_context *context, JoinExpr *lowest_outer_join); static Node *pullup_replace_vars(Node *expr, - pullup_replace_vars_context *context); + pullup_replace_vars_context *context); static Node *pullup_replace_vars_callback(Var *var, replace_rte_variables_context *context); static reduce_outer_joins_state *reduce_outer_joins_pass1(Node *jtnode); @@ -708,7 +708,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, * insert into the top query, but if we are under an outer join then * non-nullable items may have to be turned into PlaceHolderVars. If we * are dealing with an appendrel member then anything that's not a simple - * Var has to be turned into a PlaceHolderVar. Set up appropriate context + * Var has to be turned into a PlaceHolderVar. Set up appropriate context * data for pullup_replace_vars. */ rvcontext.root = root; @@ -729,7 +729,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, * replace any of the jointree structure. (This'd be a lot cleaner if we * could use query_tree_mutator.) We have to use PHVs in the targetList, * returningList, and havingQual, since those are certainly above any - * outer join. replace_vars_in_jointree tracks its location in the + * outer join. replace_vars_in_jointree tracks its location in the * jointree and uses PHVs or not appropriately. */ parse->targetList = (List *) @@ -751,7 +751,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, foreach(lc, root->append_rel_list) { AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(lc); - bool save_need_phvs = rvcontext.need_phvs; + bool save_need_phvs = rvcontext.need_phvs; if (appinfo == containing_appendrel) rvcontext.need_phvs = false; @@ -796,9 +796,8 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, * We also have to fix the relid sets of any PlaceHolderVar nodes in the * parent query. (This could perhaps be done by pullup_replace_vars(), * but it seems cleaner to use two passes.) Note in particular that any - * PlaceHolderVar nodes just created by pullup_replace_vars() - * will be adjusted, so having created them with the subquery's varno is - * correct. + * PlaceHolderVar nodes just created by pullup_replace_vars() will be + * adjusted, so having created them with the subquery's varno is correct. * * Likewise, relids appearing in AppendRelInfo nodes have to be fixed. We * already checked that this won't require introducing multiple subrelids @@ -1033,8 +1032,8 @@ is_simple_subquery(Query *subquery) * * We also don't pull up a subquery that has explicit FOR UPDATE/SHARE * clauses, because pullup would cause the locking to occur semantically - * higher than it should. Implicit FOR UPDATE/SHARE is okay because - * in that case the locking was originally declared in the upper query + * higher than it should. Implicit FOR UPDATE/SHARE is okay because in + * that case the locking was originally declared in the upper query * anyway. */ if (subquery->hasAggs || @@ -1227,7 +1226,7 @@ replace_vars_in_jointree(Node *jtnode, else if (IsA(jtnode, JoinExpr)) { JoinExpr *j = (JoinExpr *) jtnode; - bool save_need_phvs = context->need_phvs; + bool save_need_phvs = context->need_phvs; if (j == lowest_outer_join) { @@ -1310,7 +1309,7 @@ pullup_replace_vars_callback(Var *var, * expansion with varlevelsup = 0, and then adjust if needed. */ expandRTE(rcon->target_rte, - var->varno, 0 /* not varlevelsup */, var->location, + var->varno, 0 /* not varlevelsup */ , var->location, (var->vartype != RECORDOID), &colnames, &fields); /* Adjust the generated per-field Vars, but don't insert PHVs */ @@ -1327,11 +1326,11 @@ pullup_replace_vars_callback(Var *var, newnode = (Node *) rowexpr; /* - * Insert PlaceHolderVar if needed. Notice that we are wrapping - * one PlaceHolderVar around the whole RowExpr, rather than putting - * one around each element of the row. This is because we need - * the expression to yield NULL, not ROW(NULL,NULL,...) when it - * is forced to null by an outer join. + * Insert PlaceHolderVar if needed. Notice that we are wrapping one + * PlaceHolderVar around the whole RowExpr, rather than putting one + * around each element of the row. This is because we need the + * expression to yield NULL, not ROW(NULL,NULL,...) when it is forced + * to null by an outer join. */ if (rcon->need_phvs) { @@ -1359,7 +1358,7 @@ pullup_replace_vars_callback(Var *var, /* Insert PlaceHolderVar if needed */ if (rcon->need_phvs) { - bool wrap; + bool wrap; if (newnode && IsA(newnode, Var) && ((Var *) newnode)->varlevelsup == 0) @@ -1402,8 +1401,8 @@ pullup_replace_vars_callback(Var *var, /* * Cache it if possible (ie, if the attno is in range, which it - * probably always should be). We can cache the value even if - * we decided we didn't need a PHV, since this result will be + * probably always should be). We can cache the value even if we + * decided we didn't need a PHV, since this result will be * suitable for any request that has need_phvs. */ if (varattno > InvalidAttrNumber && @@ -1837,7 +1836,7 @@ reduce_outer_joins_pass2(Node *jtnode, * top query could (yet) contain such a reference. * * NOTE: although this has the form of a walker, we cheat and modify the - * nodes in-place. This should be OK since the tree was copied by + * nodes in-place. This should be OK since the tree was copied by * pullup_replace_vars earlier. Avoid scribbling on the original values of * the bitmapsets, though, because expression_tree_mutator doesn't copy those. */ diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index cf51fce481e..abbf42cb625 100644 --- a/src/backend/optimizer/prep/preptlist.c +++ b/src/backend/optimizer/prep/preptlist.c @@ -17,7 +17,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.99 2010/01/02 16:57:47 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.100 2010/02/26 02:00:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,11 +109,10 @@ preprocess_targetlist(PlannerInfo *root, List *tlist) } /* - * Add necessary junk columns for rowmarked rels. These values are - * needed for locking of rels selected FOR UPDATE/SHARE, and to do - * EvalPlanQual rechecking. While we are at it, store these junk attnos - * in the PlanRowMark list so that we don't have to redetermine them - * at runtime. + * Add necessary junk columns for rowmarked rels. These values are needed + * for locking of rels selected FOR UPDATE/SHARE, and to do EvalPlanQual + * rechecking. While we are at it, store these junk attnos in the + * PlanRowMark list so that we don't have to redetermine them at runtime. */ foreach(lc, root->rowMarks) { diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 560afaaa240..562006e13bb 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -22,7 +22,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.180 2010/02/01 19:28:56 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.181 2010/02/26 02:00:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1196,8 +1196,8 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti) /* * If parent relation is selected FOR UPDATE/SHARE, we need to mark its - * PlanRowMark as isParent = true, and generate a new PlanRowMark for - * each child. + * PlanRowMark as isParent = true, and generate a new PlanRowMark for each + * child. */ if (oldrc) oldrc->isParent = true; @@ -1244,7 +1244,8 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti) childrte = copyObject(rte); childrte->relid = childOID; childrte->inh = false; - childrte->requiredPerms = 0; /* do not require permissions on child tables */ + childrte->requiredPerms = 0; /* do not require permissions on child + * tables */ parse->rtable = lappend(parse->rtable, childrte); childRTindex = list_length(parse->rtable); diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 91bdb3537e7..cb1735725a7 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.285 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.286 2010/02/26 02:00:46 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -106,7 +106,7 @@ static List *add_function_defaults(List *args, Oid result_type, eval_const_expressions_context *context); static List *fetch_function_defaults(HeapTuple func_tuple); static void recheck_cast_function_args(List *args, Oid result_type, - HeapTuple func_tuple); + HeapTuple func_tuple); static Expr *evaluate_function(Oid funcid, Oid result_type, int32 result_typmod, List *args, HeapTuple func_tuple, @@ -2127,14 +2127,14 @@ eval_const_expressions_mutator(Node *node, ListCell *lc; /* - * Reduce constants in the FuncExpr's arguments, and check to see - * if there are any named args. + * Reduce constants in the FuncExpr's arguments, and check to see if + * there are any named args. */ args = NIL; has_named_args = false; foreach(lc, expr->args) { - Node *arg = (Node *) lfirst(lc); + Node *arg = (Node *) lfirst(lc); arg = eval_const_expressions_mutator(arg, context); if (IsA(arg, NamedArgExpr)) @@ -2158,8 +2158,8 @@ eval_const_expressions_mutator(Node *node, /* * The expression cannot be simplified any further, so build and * return a replacement FuncExpr node using the possibly-simplified - * arguments. Note that we have also converted the argument list - * to positional notation. + * arguments. Note that we have also converted the argument list to + * positional notation. */ newexpr = makeNode(FuncExpr); newexpr->funcid = expr->funcid; @@ -3219,16 +3219,16 @@ simplify_boolean_equality(Oid opno, List *args) if (opno == BooleanEqualOperator) { if (DatumGetBool(((Const *) leftop)->constvalue)) - return rightop; /* true = foo */ + return rightop; /* true = foo */ else - return make_notclause(rightop); /* false = foo */ + return make_notclause(rightop); /* false = foo */ } else { if (DatumGetBool(((Const *) leftop)->constvalue)) - return make_notclause(rightop); /* true <> foo */ + return make_notclause(rightop); /* true <> foo */ else - return rightop; /* false <> foo */ + return rightop; /* false <> foo */ } } if (rightop && IsA(rightop, Const)) @@ -3237,16 +3237,16 @@ simplify_boolean_equality(Oid opno, List *args) if (opno == BooleanEqualOperator) { if (DatumGetBool(((Const *) rightop)->constvalue)) - return leftop; /* foo = true */ + return leftop; /* foo = true */ else - return make_notclause(leftop); /* foo = false */ + return make_notclause(leftop); /* foo = false */ } else { if (DatumGetBool(((Const *) rightop)->constvalue)) - return make_notclause(leftop); /* foo <> true */ + return make_notclause(leftop); /* foo <> true */ else - return leftop; /* foo <> false */ + return leftop; /* foo <> false */ } } return NULL; @@ -3340,7 +3340,7 @@ reorder_function_arguments(List *args, Oid result_type, HeapTuple func_tuple, i = 0; foreach(lc, args) { - Node *arg = (Node *) lfirst(lc); + Node *arg = (Node *) lfirst(lc); if (!IsA(arg, NamedArgExpr)) { @@ -3358,13 +3358,13 @@ reorder_function_arguments(List *args, Oid result_type, HeapTuple func_tuple, } /* - * Fetch default expressions, if needed, and insert into array at - * proper locations (they aren't necessarily consecutive or all used) + * Fetch default expressions, if needed, and insert into array at proper + * locations (they |