diff options
author | Bruce Momjian | 2009-06-11 14:49:15 +0000 |
---|---|---|
committer | Bruce Momjian | 2009-06-11 14:49:15 +0000 |
commit | d7471402794266078953f1bd113dab4913d631a1 (patch) | |
tree | 618e392a84eaf837e00bf78f8694097b78fec227 | |
parent | 4e86efb4e51b66ef57b3fe6f28576de23a1bf1c6 (diff) |
8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
654 files changed, 11901 insertions, 11388 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c index 8e0f11038c..9108a77ba1 100644 --- a/contrib/auto_explain/auto_explain.c +++ b/contrib/auto_explain/auto_explain.c @@ -6,7 +6,7 @@ * Copyright (c) 2008-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.4 2009/01/05 13:35:38 tgl Exp $ + * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.5 2009/06/11 14:48:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,7 @@ PG_MODULE_MAGIC; /* GUC variables */ -static int auto_explain_log_min_duration = -1; /* msec or -1 */ +static int auto_explain_log_min_duration = -1; /* msec or -1 */ static bool auto_explain_log_analyze = false; static bool auto_explain_log_verbose = false; static bool auto_explain_log_nested_statements = false; @@ -28,21 +28,21 @@ static bool auto_explain_log_nested_statements = false; static int nesting_level = 0; /* Saved hook values in case of unload */ -static ExecutorStart_hook_type prev_ExecutorStart = NULL; -static ExecutorRun_hook_type prev_ExecutorRun = NULL; -static ExecutorEnd_hook_type prev_ExecutorEnd = NULL; +static ExecutorStart_hook_type prev_ExecutorStart = NULL; +static ExecutorRun_hook_type prev_ExecutorRun = NULL; +static ExecutorEnd_hook_type prev_ExecutorEnd = NULL; #define auto_explain_enabled() \ (auto_explain_log_min_duration >= 0 && \ (nesting_level == 0 || auto_explain_log_nested_statements)) -void _PG_init(void); -void _PG_fini(void); +void _PG_init(void); +void _PG_fini(void); static void explain_ExecutorStart(QueryDesc *queryDesc, int eflags); static void explain_ExecutorRun(QueryDesc *queryDesc, - ScanDirection direction, - long count); + ScanDirection direction, + long count); static void explain_ExecutorEnd(QueryDesc *queryDesc); @@ -54,8 +54,8 @@ _PG_init(void) { /* Define custom GUC variables. */ DefineCustomIntVariable("auto_explain.log_min_duration", - "Sets the minimum execution time above which plans will be logged.", - "Zero prints all plans. -1 turns this feature off.", + "Sets the minimum execution time above which plans will be logged.", + "Zero prints all plans. -1 turns this feature off.", &auto_explain_log_min_duration, -1, -1, INT_MAX / 1000, @@ -138,9 +138,9 @@ explain_ExecutorStart(QueryDesc *queryDesc, int eflags) if (auto_explain_enabled()) { /* - * Set up to track total elapsed time in ExecutorRun. Make sure - * the space is allocated in the per-query context so it will go - * away at ExecutorEnd. + * Set up to track total elapsed time in ExecutorRun. Make sure the + * space is allocated in the per-query context so it will go away at + * ExecutorEnd. */ if (queryDesc->totaltime == NULL) { @@ -184,11 +184,11 @@ explain_ExecutorEnd(QueryDesc *queryDesc) { if (queryDesc->totaltime && auto_explain_enabled()) { - double msec; + double msec; /* - * Make sure stats accumulation is done. (Note: it's okay if - * several levels of hook all do this.) + * Make sure stats accumulation is done. (Note: it's okay if several + * levels of hook all do this.) */ InstrEndLoop(queryDesc->totaltime); @@ -196,11 +196,11 @@ explain_ExecutorEnd(QueryDesc *queryDesc) msec = queryDesc->totaltime->total * 1000.0; if (msec >= auto_explain_log_min_duration) { - StringInfoData buf; + StringInfoData buf; initStringInfo(&buf); ExplainPrintPlan(&buf, queryDesc, - queryDesc->doInstrument && auto_explain_log_analyze, + queryDesc->doInstrument && auto_explain_log_analyze, auto_explain_log_verbose); /* Remove last line break */ diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c index 164eeb8d3b..6fae89cad5 100644 --- a/contrib/btree_gin/btree_gin.c +++ b/contrib/btree_gin/btree_gin.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gin/btree_gin.c,v 1.1 2009/03/25 23:20:01 tgl Exp $ + * $PostgreSQL: pgsql/contrib/btree_gin/btree_gin.c,v 1.2 2009/06/11 14:48:50 momjian Exp $ */ #include "postgres.h" @@ -19,20 +19,20 @@ PG_MODULE_MAGIC; typedef struct TypeInfo { - bool is_varlena; - Datum (*leftmostvalue)(void); - Datum (*typecmp)(FunctionCallInfo); + bool is_varlena; + Datum (*leftmostvalue) (void); + Datum (*typecmp) (FunctionCallInfo); } TypeInfo; typedef struct QueryInfo { - StrategyNumber strategy; - Datum datum; + StrategyNumber strategy; + Datum datum; } QueryInfo; #define GIN_EXTRACT_VALUE(type) \ PG_FUNCTION_INFO_V1(gin_extract_value_##type); \ -Datum gin_extract_value_##type(PG_FUNCTION_ARGS); \ +Datum gin_extract_value_##type(PG_FUNCTION_ARGS); \ Datum \ gin_extract_value_##type(PG_FUNCTION_ARGS) \ { \ @@ -59,7 +59,7 @@ gin_extract_value_##type(PG_FUNCTION_ARGS) \ #define GIN_EXTRACT_QUERY(type) \ PG_FUNCTION_INFO_V1(gin_extract_query_##type); \ -Datum gin_extract_query_##type(PG_FUNCTION_ARGS); \ +Datum gin_extract_query_##type(PG_FUNCTION_ARGS); \ Datum \ gin_extract_query_##type(PG_FUNCTION_ARGS) \ { \ @@ -67,7 +67,7 @@ gin_extract_query_##type(PG_FUNCTION_ARGS) \ int32 *nentries = (int32 *) PG_GETARG_POINTER(1); \ StrategyNumber strategy = PG_GETARG_UINT16(2); \ bool **partialmatch = (bool **) PG_GETARG_POINTER(3); \ - Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); \ + Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); \ Datum *entries = (Datum *) palloc(sizeof(Datum)); \ QueryInfo *data = (QueryInfo *) palloc(sizeof(QueryInfo)); \ bool *ptr_partialmatch; \ @@ -109,7 +109,7 @@ gin_extract_query_##type(PG_FUNCTION_ARGS) \ */ #define GIN_COMPARE_PREFIX(type) \ PG_FUNCTION_INFO_V1(gin_compare_prefix_##type); \ -Datum gin_compare_prefix_##type(PG_FUNCTION_ARGS); \ +Datum gin_compare_prefix_##type(PG_FUNCTION_ARGS); \ Datum \ gin_compare_prefix_##type(PG_FUNCTION_ARGS) \ { \ @@ -120,10 +120,10 @@ gin_compare_prefix_##type(PG_FUNCTION_ARGS) \ cmp; \ \ cmp = DatumGetInt32(DirectFunctionCall2( \ - TypeInfo_##type.typecmp, \ - (data->strategy == BTLessStrategyNumber || \ + TypeInfo_##type.typecmp, \ + (data->strategy == BTLessStrategyNumber || \ data->strategy == BTLessEqualStrategyNumber) \ - ? data->datum : a, \ + ? data->datum : a, \ b)); \ \ switch (data->strategy) \ @@ -166,7 +166,7 @@ gin_compare_prefix_##type(PG_FUNCTION_ARGS) \ res = 1; \ break; \ default: \ - elog(ERROR, "unrecognized strategy number: %d", \ + elog(ERROR, "unrecognized strategy number: %d", \ data->strategy); \ res = 0; \ } \ @@ -181,11 +181,11 @@ gin_compare_prefix_##type(PG_FUNCTION_ARGS) \ PG_FUNCTION_INFO_V1(gin_btree_consistent); -Datum gin_btree_consistent(PG_FUNCTION_ARGS); +Datum gin_btree_consistent(PG_FUNCTION_ARGS); Datum gin_btree_consistent(PG_FUNCTION_ARGS) { - bool *recheck = (bool *) PG_GETARG_POINTER(5); + bool *recheck = (bool *) PG_GETARG_POINTER(5); *recheck = false; PG_RETURN_BOOL(true); @@ -197,6 +197,7 @@ leftmostvalue_int2(void) return Int16GetDatum(SHRT_MIN); } static TypeInfo TypeInfo_int2 = {false, leftmostvalue_int2, btint2cmp}; + GIN_SUPPORT(int2) static Datum @@ -205,18 +206,20 @@ leftmostvalue_int4(void) return Int32GetDatum(INT_MIN); } static TypeInfo TypeInfo_int4 = {false, leftmostvalue_int4, btint4cmp}; + GIN_SUPPORT(int4) static Datum leftmostvalue_int8(void) { /* - * Use sequence's definition to keep compatibility. - * Another way may make a problem with INT64_IS_BUSTED + * Use sequence's definition to keep compatibility. Another way may make a + * problem with INT64_IS_BUSTED */ return Int64GetDatum(SEQ_MINVALUE); } static TypeInfo TypeInfo_int8 = {false, leftmostvalue_int8, btint8cmp}; + GIN_SUPPORT(int8) static Datum @@ -225,6 +228,7 @@ leftmostvalue_float4(void) return Float4GetDatum(-get_float4_infinity()); } static TypeInfo TypeInfo_float4 = {false, leftmostvalue_float4, btfloat4cmp}; + GIN_SUPPORT(float4) static Datum @@ -233,18 +237,20 @@ leftmostvalue_float8(void) return Float8GetDatum(-get_float8_infinity()); } static TypeInfo TypeInfo_float8 = {false, leftmostvalue_float8, btfloat8cmp}; + GIN_SUPPORT(float8) static Datum leftmostvalue_money(void) { /* - * Use sequence's definition to keep compatibility. - * Another way may make a problem with INT64_IS_BUSTED + * Use sequence's definition to keep compatibility. Another way may make a + * problem with INT64_IS_BUSTED */ return Int64GetDatum(SEQ_MINVALUE); } static TypeInfo TypeInfo_money = {false, leftmostvalue_money, cash_cmp}; + GIN_SUPPORT(money) static Datum @@ -253,6 +259,7 @@ leftmostvalue_oid(void) return ObjectIdGetDatum(0); } static TypeInfo TypeInfo_oid = {false, leftmostvalue_oid, btoidcmp}; + GIN_SUPPORT(oid) static Datum @@ -261,9 +268,11 @@ leftmostvalue_timestamp(void) return TimestampGetDatum(DT_NOBEGIN); } static TypeInfo TypeInfo_timestamp = {false, leftmostvalue_timestamp, timestamp_cmp}; + GIN_SUPPORT(timestamp) static TypeInfo TypeInfo_timestamptz = {false, leftmostvalue_timestamp, timestamp_cmp}; + GIN_SUPPORT(timestamptz) static Datum @@ -272,19 +281,21 @@ leftmostvalue_time(void) return TimeADTGetDatum(0); } static TypeInfo TypeInfo_time = {false, leftmostvalue_time, time_cmp}; + GIN_SUPPORT(time) static Datum leftmostvalue_timetz(void) { - TimeTzADT *v = palloc(sizeof(TimeTzADT)); + TimeTzADT *v = palloc(sizeof(TimeTzADT)); v->time = 0; - v->zone = -24*3600; /* XXX is that true? */ + v->zone = -24 * 3600; /* XXX is that true? */ return TimeTzADTPGetDatum(v); } static TypeInfo TypeInfo_timetz = {false, leftmostvalue_timetz, timetz_cmp}; + GIN_SUPPORT(timetz) static Datum @@ -293,12 +304,13 @@ leftmostvalue_date(void) return DateADTGetDatum(DATEVAL_NOBEGIN); } static TypeInfo TypeInfo_date = {false, leftmostvalue_date, date_cmp}; + GIN_SUPPORT(date) static Datum leftmostvalue_interval(void) { - Interval *v = palloc(sizeof(Interval)); + Interval *v = palloc(sizeof(Interval)); v->time = DT_NOBEGIN; v->day = 0; @@ -306,16 +318,18 @@ leftmostvalue_interval(void) return IntervalPGetDatum(v); } static TypeInfo TypeInfo_interval = {false, leftmostvalue_interval, interval_cmp}; + GIN_SUPPORT(interval) static Datum leftmostvalue_macaddr(void) { - macaddr *v = palloc0(sizeof(macaddr)); + macaddr *v = palloc0(sizeof(macaddr)); return MacaddrPGetDatum(v); } static TypeInfo TypeInfo_macaddr = {false, leftmostvalue_macaddr, macaddr_cmp}; + GIN_SUPPORT(macaddr) static Datum @@ -327,9 +341,11 @@ leftmostvalue_inet(void) Int32GetDatum(-1)); } static TypeInfo TypeInfo_inet = {true, leftmostvalue_inet, network_cmp}; + GIN_SUPPORT(inet) static TypeInfo TypeInfo_cidr = {true, leftmostvalue_inet, network_cmp}; + GIN_SUPPORT(cidr) static Datum @@ -338,6 +354,7 @@ leftmostvalue_text(void) return PointerGetDatum(cstring_to_text_with_len("", 0)); } static TypeInfo TypeInfo_text = {true, leftmostvalue_text, bttextcmp}; + GIN_SUPPORT(text) static Datum @@ -346,9 +363,11 @@ leftmostvalue_char(void) return CharGetDatum(SCHAR_MIN); } static TypeInfo TypeInfo_char = {false, leftmostvalue_char, btcharcmp}; + GIN_SUPPORT(char) static TypeInfo TypeInfo_bytea = {true, leftmostvalue_text, byteacmp}; + GIN_SUPPORT(bytea) static Datum @@ -360,6 +379,7 @@ leftmostvalue_bit(void) Int32GetDatum(-1)); } static TypeInfo TypeInfo_bit = {true, leftmostvalue_bit, bitcmp}; + GIN_SUPPORT(bit) static Datum @@ -371,6 +391,7 @@ leftmostvalue_varbit(void) Int32GetDatum(-1)); } static TypeInfo TypeInfo_varbit = {true, leftmostvalue_varbit, bitcmp}; + GIN_SUPPORT(varbit) /* @@ -383,20 +404,20 @@ GIN_SUPPORT(varbit) #define NUMERIC_IS_LEFTMOST(x) ((x) == NULL) PG_FUNCTION_INFO_V1(gin_numeric_cmp); -Datum gin_numeric_cmp(PG_FUNCTION_ARGS); +Datum gin_numeric_cmp(PG_FUNCTION_ARGS); Datum gin_numeric_cmp(PG_FUNCTION_ARGS) { - Numeric a = (Numeric)PG_GETARG_POINTER(0); - Numeric b = (Numeric)PG_GETARG_POINTER(1); - int res = 0; + Numeric a = (Numeric) PG_GETARG_POINTER(0); + Numeric b = (Numeric) PG_GETARG_POINTER(1); + int res = 0; - if ( NUMERIC_IS_LEFTMOST(a) ) + if (NUMERIC_IS_LEFTMOST(a)) { - res = ( NUMERIC_IS_LEFTMOST(b) ) ? 0 : -1; + res = (NUMERIC_IS_LEFTMOST(b)) ? 0 : -1; } - else if ( NUMERIC_IS_LEFTMOST(b) ) + else if (NUMERIC_IS_LEFTMOST(b)) { res = 1; } @@ -417,4 +438,5 @@ leftmostvalue_numeric(void) } static TypeInfo TypeInfo_numeric = {true, leftmostvalue_numeric, gin_numeric_cmp}; + GIN_SUPPORT(numeric) diff --git a/contrib/btree_gist/btree_bit.c b/contrib/btree_gist/btree_bit.c index feadf6be48..3c5a2e0ce5 100644 --- a/contrib/btree_gist/btree_bit.c +++ b/contrib/btree_gist/btree_bit.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_bit.c,v 1.9 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_bit.c,v 1.10 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_var.h" @@ -82,7 +82,7 @@ gbt_bit_xfrm(bytea *leaf) static GBT_VARKEY * -gbt_bit_l2n(GBT_VARKEY * leaf) +gbt_bit_l2n(GBT_VARKEY *leaf) { GBT_VARKEY *out = leaf; @@ -131,6 +131,7 @@ gbt_bit_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); void *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1)); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool retval = FALSE; diff --git a/contrib/btree_gist/btree_bytea.c b/contrib/btree_gist/btree_bytea.c index 9619a7a0af..9977b201c6 100644 --- a/contrib/btree_gist/btree_bytea.c +++ b/contrib/btree_gist/btree_bytea.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_bytea.c,v 1.8 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_bytea.c,v 1.9 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_var.h" @@ -101,6 +101,7 @@ gbt_bytea_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); void *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1)); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool retval; diff --git a/contrib/btree_gist/btree_cash.c b/contrib/btree_gist/btree_cash.c index 4543b082e9..fbc79c1330 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.8 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_cash.c,v 1.9 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -9,7 +9,7 @@ typedef struct { Cash lower; Cash upper; -} cashKEY; +} cashKEY; /* ** Cash ops @@ -101,6 +101,7 @@ gbt_cash_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); Cash query = PG_GETARG_CASH(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); cashKEY *kkk = (cashKEY *) DatumGetPointer(entry->key); @@ -109,8 +110,8 @@ gbt_cash_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_date.c b/contrib/btree_gist/btree_date.c index 5ee7273a0b..b9929922fe 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.6 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_date.c,v 1.7 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -9,7 +9,7 @@ typedef struct { DateADT lower; DateADT upper; -} dateKEY; +} dateKEY; /* ** date ops @@ -117,6 +117,7 @@ gbt_date_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); DateADT query = PG_GETARG_DATEADT(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); dateKEY *kkk = (dateKEY *) DatumGetPointer(entry->key); @@ -125,8 +126,8 @@ gbt_date_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_float4.c b/contrib/btree_gist/btree_float4.c index 1def7479e0..3a508ec0a6 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.7 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_float4.c,v 1.8 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -8,7 +8,7 @@ typedef struct float4key { float4 lower; float4 upper; -} float4KEY; +} float4KEY; /* ** float4 ops @@ -100,6 +100,7 @@ gbt_float4_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); float4 query = PG_GETARG_FLOAT4(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); float4KEY *kkk = (float4KEY *) DatumGetPointer(entry->key); @@ -108,8 +109,8 @@ gbt_float4_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_float8.c b/contrib/btree_gist/btree_float8.c index 6117adf19e..66e63f31f8 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.7 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_float8.c,v 1.8 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -8,7 +8,7 @@ typedef struct float8key { float8 lower; float8 upper; -} float8KEY; +} float8KEY; /* ** float8 ops @@ -101,6 +101,7 @@ gbt_float8_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); float8 query = PG_GETARG_FLOAT8(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); float8KEY *kkk = (float8KEY *) DatumGetPointer(entry->key); @@ -109,8 +110,8 @@ gbt_float8_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_gist.c b/contrib/btree_gist/btree_gist.c index d3befb04f7..f109de4a64 100644 --- a/contrib/btree_gist/btree_gist.c +++ b/contrib/btree_gist/btree_gist.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_gist.c,v 1.12 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_gist.c,v 1.13 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" diff --git a/contrib/btree_gist/btree_gist.h b/contrib/btree_gist/btree_gist.h index dd708fb889..425ce8cff4 100644 --- a/contrib/btree_gist/btree_gist.h +++ b/contrib/btree_gist/btree_gist.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_gist.h,v 1.8 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_gist.h,v 1.9 2009/06/11 14:48:50 momjian Exp $ */ #ifndef __BTREE_GIST_H__ #define __BTREE_GIST_H__ diff --git a/contrib/btree_gist/btree_inet.c b/contrib/btree_gist/btree_inet.c index d8c85d7433..32f9d11102 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.9 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_inet.c,v 1.10 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -11,7 +11,7 @@ typedef struct inetkey { double lower; double upper; -} inetKEY; +} inetKEY; /* ** inet ops @@ -118,6 +118,7 @@ gbt_inet_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); double query = convert_network_to_scalar(PG_GETARG_DATUM(1), INETOID); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); inetKEY *kkk = (inetKEY *) DatumGetPointer(entry->key); @@ -126,8 +127,8 @@ gbt_inet_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are inexact */ *recheck = true; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL(gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)); diff --git a/contrib/btree_gist/btree_int2.c b/contrib/btree_gist/btree_int2.c index fa03f364f8..4a1b1c4a39 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.7 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_int2.c,v 1.8 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -8,7 +8,7 @@ typedef struct int16key { int16 lower; int16 upper; -} int16KEY; +} int16KEY; /* ** int16 ops @@ -104,6 +104,7 @@ gbt_int2_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); int16 query = PG_GETARG_INT16(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); int16KEY *kkk = (int16KEY *) DatumGetPointer(entry->key); @@ -112,8 +113,8 @@ gbt_int2_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_int4.c b/contrib/btree_gist/btree_int4.c index 5d9b1a19f9..f3c29f6051 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.7 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_int4.c,v 1.8 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -8,7 +8,7 @@ typedef struct int32key { int32 lower; int32 upper; -} int32KEY; +} int32KEY; /* ** int32 ops @@ -101,6 +101,7 @@ gbt_int4_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); int32 query = PG_GETARG_INT32(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); int32KEY *kkk = (int32KEY *) DatumGetPointer(entry->key); @@ -109,8 +110,8 @@ gbt_int4_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_int8.c b/contrib/btree_gist/btree_int8.c index 59493081bd..c65e1d214d 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.7 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_int8.c,v 1.8 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -8,7 +8,7 @@ typedef struct int64key { int64 lower; int64 upper; -} int64KEY; +} int64KEY; /* ** int64 ops @@ -101,6 +101,7 @@ gbt_int8_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); int64 query = PG_GETARG_INT64(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); int64KEY *kkk = (int64KEY *) DatumGetPointer(entry->key); @@ -109,8 +110,8 @@ gbt_int8_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_interval.c b/contrib/btree_gist/btree_interval.c index e5c096cfda..b136847923 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.11 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_interval.c,v 1.12 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -9,7 +9,7 @@ typedef struct { Interval lower, upper; -} intvKEY; +} intvKEY; /* @@ -169,6 +169,7 @@ gbt_intv_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); Interval *query = PG_GETARG_INTERVAL_P(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); intvKEY *kkk = (intvKEY *) DatumGetPointer(entry->key); @@ -177,8 +178,8 @@ gbt_intv_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_macaddr.c b/contrib/btree_gist/btree_macaddr.c index da57e6d4e3..5c5030faec 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.7 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_macaddr.c,v 1.8 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -10,7 +10,7 @@ typedef struct { macaddr lower; macaddr upper; -} macKEY; +} macKEY; /* ** OID ops @@ -122,6 +122,7 @@ gbt_macad_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); macaddr *query = (macaddr *) PG_GETARG_POINTER(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); macKEY *kkk = (macKEY *) DatumGetPointer(entry->key); @@ -130,8 +131,8 @@ gbt_macad_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_numeric.c b/contrib/btree_gist/btree_numeric.c index 7b52d07353..810bb279da 100644 --- a/contrib/btree_gist/btree_numeric.c +++ b/contrib/btree_gist/btree_numeric.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_numeric.c,v 1.12 2008/06/19 00:46:02 alvherre Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_numeric.c,v 1.13 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" @@ -106,6 +106,7 @@ gbt_numeric_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); void *query = (void *) DatumGetNumeric(PG_GETARG_DATUM(1)); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool retval; diff --git a/contrib/btree_gist/btree_oid.c b/contrib/btree_gist/btree_oid.c index 3334275530..6a0805635d 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.7 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_oid.c,v 1.8 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -8,7 +8,7 @@ typedef struct { Oid lower; Oid upper; -} oidKEY; +} oidKEY; /* ** OID ops @@ -101,6 +101,7 @@ gbt_oid_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); Oid query = PG_GETARG_OID(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key); @@ -109,8 +110,8 @@ gbt_oid_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) diff --git a/contrib/btree_gist/btree_text.c b/contrib/btree_gist/btree_text.c index a0e817780e..8b01eb7aac 100644 --- a/contrib/btree_gist/btree_text.c +++ b/contrib/btree_gist/btree_text.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_text.c,v 1.11 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_text.c,v 1.12 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_var.h" @@ -135,6 +135,7 @@ gbt_text_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); void *query = (void *) DatumGetTextP(PG_GETARG_DATUM(1)); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool retval; @@ -161,6 +162,7 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); void *query = (void *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1))); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool retval; diff --git a/contrib/btree_gist/btree_time.c b/contrib/btree_gist/btree_time.c index fff5e3b446..7287755fc7 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.15 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_time.c,v 1.16 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -10,7 +10,7 @@ typedef struct { TimeADT lower; TimeADT upper; -} timeKEY; +} timeKEY; /* ** time ops @@ -175,6 +175,7 @@ gbt_time_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); TimeADT query = PG_GETARG_TIMEADT(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); timeKEY *kkk = (timeKEY *) DatumGetPointer(entry->key); @@ -183,8 +184,8 @@ gbt_time_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) @@ -197,6 +198,7 @@ gbt_timetz_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); TimeTzADT *query = PG_GETARG_TIMETZADT_P(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); timeKEY *kkk = (timeKEY *) DatumGetPointer(entry->key); @@ -212,8 +214,8 @@ gbt_timetz_consistent(PG_FUNCTION_ARGS) qqq = (query->time + query->zone); #endif - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &qqq, &strategy, GIST_LEAF(entry), &tinfo) @@ -244,15 +246,15 @@ gbt_time_penalty(PG_FUNCTION_ARGS) intr = DatumGetIntervalP(DirectFunctionCall2( time_mi_time, - TimeADTGetDatumFast(newentry->upper), - TimeADTGetDatumFast(origentry->upper))); + TimeADTGetDatumFast(newentry->upper), + TimeADTGetDatumFast(origentry->upper))); res = INTERVAL_TO_SEC(intr); res = Max(res, 0); intr = DatumGetIntervalP(DirectFunctionCall2( time_mi_time, - TimeADTGetDatumFast(origentry->lower), - TimeADTGetDatumFast(newentry->lower))); + TimeADTGetDatumFast(origentry->lower), + TimeADTGetDatumFast(newentry->lower))); res2 = INTERVAL_TO_SEC(intr); res2 = Max(res2, 0); @@ -264,8 +266,8 @@ gbt_time_penalty(PG_FUNCTION_ARGS) { intr = DatumGetIntervalP(DirectFunctionCall2( time_mi_time, - TimeADTGetDatumFast(origentry->upper), - TimeADTGetDatumFast(origentry->lower))); + TimeADTGetDatumFast(origentry->upper), + TimeADTGetDatumFast(origentry->lower))); *result += FLT_MIN; *result += (float) (res / (res + INTERVAL_TO_SEC(intr))); *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); diff --git a/contrib/btree_gist/btree_ts.c b/contrib/btree_gist/btree_ts.c index c20699fa91..e0780ef391 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.16 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_ts.c,v 1.17 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -9,7 +9,7 @@ typedef struct { Timestamp lower; Timestamp upper; -} tsKEY; +} tsKEY; /* ** timestamp ops @@ -192,6 +192,7 @@ gbt_ts_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); Timestamp query = PG_GETARG_TIMESTAMP(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); tsKEY *kkk = (tsKEY *) DatumGetPointer(entry->key); @@ -200,8 +201,8 @@ gbt_ts_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk->lower; - key.upper = (GBT_NUMKEY *) & kkk->upper; + key.lower = (GBT_NUMKEY *) &kkk->lower; + key.upper = (GBT_NUMKEY *) &kkk->upper; PG_RETURN_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) @@ -212,8 +213,9 @@ Datum gbt_tstz_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - TimestampTz query = PG_GETARG_TIMESTAMPTZ(1); + TimestampTz query = PG_GETARG_TIMESTAMPTZ(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); char *kkk = (char *) DatumGetPointer(entry->key); @@ -223,8 +225,8 @@ gbt_tstz_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are exact */ *recheck = false; - key.lower = (GBT_NUMKEY *) & kkk[0]; - key.upper = (GBT_NUMKEY *) & kkk[MAXALIGN(tinfo.size)]; + key.lower = (GBT_NUMKEY *) &kkk[0]; + key.upper = (GBT_NUMKEY *) &kkk[MAXALIGN(tinfo.size)]; qqq = tstz_to_ts_gmt(query); PG_RETURN_BOOL( diff --git a/contrib/btree_gist/btree_utils_num.c b/contrib/btree_gist/btree_utils_num.c index 357a8f165b..ff206dcda8 100644 --- a/contrib/btree_gist/btree_utils_num.c +++ b/contrib/btree_gist/btree_utils_num.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_num.c,v 1.11 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_num.c,v 1.12 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" #include "btree_utils_num.h" @@ -8,7 +8,7 @@ GISTENTRY * -gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo * tinfo) +gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo *tinfo) { if (entry->leafkey) { @@ -94,7 +94,7 @@ gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo * tinfo */ void * -gbt_num_union(GBT_NUMKEY * out, const GistEntryVector *entryvec, const gbtree_ninfo * tinfo) +gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo) { int i, numranges; @@ -132,7 +132,7 @@ gbt_num_union(GBT_NUMKEY * out, const GistEntryVector *entryvec, const gbtree_ni */ bool -gbt_num_same(const GBT_NUMKEY * a, const GBT_NUMKEY * b, const gbtree_ninfo * tinfo) +gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo) { GBT_NUMKEY_R b1, @@ -154,7 +154,7 @@ gbt_num_same(const GBT_NUMKEY * a, const GBT_NUMKEY * b, const gbtree_ninfo * ti void -gbt_num_bin_union(Datum *u, GBT_NUMKEY * e, const gbtree_ninfo * tinfo) +gbt_num_bin_union(Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo) { GBT_NUMKEY_R rd; @@ -189,11 +189,11 @@ gbt_num_bin_union(Datum *u, GBT_NUMKEY * e, const gbtree_ninfo * tinfo) bool gbt_num_consistent( - const GBT_NUMKEY_R * key, + const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, - const gbtree_ninfo * tinfo + const gbtree_ninfo *tinfo ) { @@ -235,7 +235,7 @@ gbt_num_consistent( GIST_SPLITVEC * gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, - const gbtree_ninfo * tinfo) + const gbtree_ninfo *tinfo) { OffsetNumber i, maxoff = entryvec->n - 1; diff --git a/contrib/btree_gist/btree_utils_num.h b/contrib/btree_gist/btree_utils_num.h index 42573aa8e8..dcd17bc430 100644 --- a/contrib/btree_gist/btree_utils_num.h +++ b/contrib/btree_gist/btree_utils_num.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_num.h,v 1.13 2008/06/19 00:46:02 alvherre Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_num.h,v 1.14 2009/06/11 14:48:50 momjian Exp $ */ #ifndef __BTREE_UTILS_NUM_H__ #define __BTREE_UTILS_NUM_H__ @@ -17,7 +17,7 @@ typedef struct { const GBT_NUMKEY *lower, *upper; -} GBT_NUMKEY_R; +} GBT_NUMKEY_R; /* for sorting */ @@ -25,7 +25,7 @@ typedef struct { int i; GBT_NUMKEY *t; -} Nsrt; +} Nsrt; /* type description */ @@ -46,7 +46,7 @@ typedef struct bool (*f_le) (const void *, const void *); /* less equal */ bool (*f_lt) (const void *, const void *); /* less then */ int (*f_cmp) (const void *, const void *); /* key compare function */ -} gbtree_ninfo; +} gbtree_ninfo; /* @@ -92,24 +92,24 @@ typedef struct #endif -extern bool gbt_num_consistent(const GBT_NUMKEY_R * key, const void *query, +extern bool gbt_num_consistent(const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, - const gbtree_ninfo * tinfo); + const gbtree_ninfo *tinfo); extern GIST_SPLITVEC *gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, - const gbtree_ninfo * tinfo); + const gbtree_ninfo *tinfo); extern GISTENTRY *gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, - const gbtree_ninfo * tinfo); + const gbtree_ninfo *tinfo); -extern void *gbt_num_union(GBT_NUMKEY * out, const GistEntryVector *entryvec, - const gbtree_ninfo * tinfo); +extern void *gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, + const gbtree_ninfo *tinfo); -extern bool gbt_num_same(const GBT_NUMKEY * a, const GBT_NUMKEY * b, - const gbtree_ninfo * tinfo); +extern bool gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, + const gbtree_ninfo *tinfo); -extern void gbt_num_bin_union(Datum *u, GBT_NUMKEY * e, - const gbtree_ninfo * tinfo); +extern void gbt_num_bin_union(Datum *u, GBT_NUMKEY *e, + const gbtree_ninfo *tinfo); #endif diff --git a/contrib/btree_gist/btree_utils_var.c b/contrib/btree_gist/btree_utils_var.c index 4f1b7e49a3..57d12e4cda 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.20 2008/06/19 00:46:02 alvherre Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_var.c,v 1.21 2009/06/11 14:48:50 momjian Exp $ */ #include "btree_gist.h" @@ -38,7 +38,7 @@ gbt_var_decompress(PG_FUNCTION_ARGS) /* Returns a better readable representaion of variable key ( sets pointer ) */ GBT_VARKEY_R -gbt_var_key_readable(const GBT_VARKEY * k) +gbt_var_key_readable(const GBT_VARKEY *k) { GBT_VARKEY_R r; @@ -53,7 +53,7 @@ gbt_var_key_readable(const GBT_VARKEY * k) GBT_VARKEY * -gbt_var_key_copy(const GBT_VARKEY_R * u, bool force_node) +gbt_var_key_copy(const GBT_VARKEY_R *u, bool force_node) { GBT_VARKEY *r = NULL; @@ -75,7 +75,7 @@ gbt_var_key_copy(const GBT_VARKEY_R * u, bool force_node) static GBT_VARKEY * -gbt_var_leaf2node(GBT_VARKEY * leaf, const gbtree_vinfo * tinfo) +gbt_var_leaf2node(GBT_VARKEY *leaf, const gbtree_vinfo *tinfo) { GBT_VARKEY *out = leaf; @@ -90,7 +90,7 @@ gbt_var_leaf2node(GBT_VARKEY * leaf, const gbtree_vinfo * tinfo) * returns the common prefix length of a node key */ static int32 -gbt_var_node_cp_len(const GBT_VARKEY * node, const gbtree_vinfo * tinfo) +gbt_var_node_cp_len(const GBT_VARKEY *node, const gbtree_vinfo *tinfo) { GBT_VARKEY_R r = gbt_var_key_readable(node); @@ -141,7 +141,7 @@ gbt_var_node_cp_len(const GBT_VARKEY * node, const gbtree_vinfo * tinfo) * returns true, if query matches prefix ( common prefix ) */ static bool -gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tinfo) +gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo *tinfo) { bool out = FALSE; @@ -186,7 +186,7 @@ gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tin */ static bool -gbt_var_node_pf_match(const GBT_VARKEY_R * node, const bytea *query, const gbtree_vinfo * tinfo) +gbt_var_node_pf_match(const GBT_VARKEY_R *node, const bytea *query, const gbtree_vinfo *tinfo) { return (tinfo->trnc && ( @@ -202,7 +202,7 @@ gbt_var_node_pf_match(const GBT_VARKEY_R * node, const bytea *query, const gbtre * cpf_length .. common prefix length */ static GBT_VARKEY * -gbt_var_node_truncate(const GBT_VARKEY * node, int32 cpf_length, const gbtree_vinfo * tinfo) +gbt_var_node_truncate(const GBT_VARKEY *node, int32 cpf_length, const gbtree_vinfo *tinfo) { GBT_VARKEY *out = NULL; GBT_VARKEY_R r = gbt_var_key_readable(node); @@ -231,7 +231,7 @@ gbt_var_node_truncate(const GBT_VARKEY * node, int32 cpf_length, const gbtree_vi void -gbt_var_bin_union(Datum *u, GBT_VARKEY * e, const gbtree_vinfo * tinfo) +gbt_var_bin_union(Datum *u, GBT_VARKEY *e, const gbtree_vinfo *tinfo) { GBT_VARKEY *nk = NULL; @@ -279,7 +279,7 @@ gbt_var_bin_union(Datum *u, GBT_VARKEY * e, const gbtree_vinfo * tinfo) GISTENTRY * -gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo * tinfo) +gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo) { GISTENTRY *retval; @@ -307,7 +307,7 @@ gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo * tinfo) GBT_VARKEY * -gbt_var_union(const GistEntryVector *entryvec, int32 *size, const gbtree_vinfo * tinfo) +gbt_var_union(const GistEntryVector *entryvec, int32 *size, const gbtree_vinfo *tinfo) { int i = 0, @@ -346,7 +346,7 @@ gbt_var_union(const GistEntryVector *entryvec, int32 *size, const gbtree_vinfo * bool -gbt_var_same(bool *result, const Datum d1, const Datum d2, const gbtree_vinfo * tinfo) +gbt_var_same(bool *result, const Datum d1, const Datum d2, const gbtree_vinfo *tinfo) { GBT_VARKEY *t1 = (GBT_VARKEY *) DatumGetPointer(d1); @@ -371,7 +371,7 @@ gbt_var_same(bool *result, const Datum d1, const Datum d2, const gbtree_vinfo * float * -gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree_vinfo * tinfo) +gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree_vinfo *tinfo) { GBT_VARKEY *orge = (GBT_VARKEY *) DatumGetPointer(o->key); @@ -449,7 +449,7 @@ gbt_vsrt_cmp(const void *a, const void *b, void *arg) } GIST_SPLITVEC * -gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_vinfo * tinfo) +gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_vinfo *tinfo) { OffsetNumber i, maxoff = entryvec->n - 1; @@ -541,11 +541,11 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtre */ bool gbt_var_consistent( - GBT_VARKEY_R * key, + GBT_VARKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, - const gbtree_vinfo * tinfo + const gbtree_vinfo *tinfo ) { bool retval = FALSE; diff --git a/contrib/btree_gist/btree_utils_var.h b/contrib/btree_gist/btree_utils_var.h index 53d720adc5..49f5d59ee2 100644 --- a/contrib/btree_gist/btree_utils_var.h +++ b/contrib/btree_gist/btree_utils_var.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_var.h,v 1.8 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/btree_gist/btree_utils_var.h,v 1.9 2009/06/11 14:48:50 momjian Exp $ */ #ifndef __BTREE_UTILS_VAR_H__ #define __BTREE_UTILS_VAR_H__ @@ -16,14 +16,14 @@ typedef struct { bytea *lower, *upper; -} GBT_VARKEY_R; +} GBT_VARKEY_R; /* used for key sorting */ typedef struct { int i; GBT_VARKEY *t; -} Vsrt; +} Vsrt; /* type description @@ -49,32 +49,32 @@ typedef struct bool (*f_lt) (const void *, const void *); /* less then */ int32 (*f_cmp) (const bytea *, const bytea *); /* node compare */ GBT_VARKEY *(*f_l2n) (GBT_VARKEY *); /* convert leaf to node */ -} gbtree_vinfo; +} gbtree_vinfo; -extern GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY * k); +extern GBT_VARKEY_R gbt_var_key_readable(const GBT_VARKEY *k); -extern GBT_VARKEY *gbt_var_key_copy(const GBT_VARKEY_R * u, bool force_node); +extern GBT_VARKEY *gbt_var_key_copy(const GBT_VARKEY_R *u, bool force_node); -extern GISTENTRY *gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo * tinfo); +extern GISTENTRY *gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo); extern GBT_VARKEY *gbt_var_union(const GistEntryVector *entryvec, int32 *size, - const gbtree_vinfo * tinfo); + const gbtree_vinfo *tinfo); extern bool gbt_var_same(bool *result, const Datum d1, const Datum d2, - const gbtree_vinfo * tinfo); + const gbtree_vinfo *tinfo); extern float *gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, - const gbtree_vinfo * tinfo); + const gbtree_vinfo *tinfo); -extern bool gbt_var_consistent(GBT_VARKEY_R * key, const void *query, +extern bool gbt_var_consistent(GBT_VARKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, - const gbtree_vinfo * tinfo); + const gbtree_vinfo *tinfo); extern GIST_SPLITVEC *gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, - const gbtree_vinfo * tinfo); -extern void gbt_var_bin_union(Datum *u, GBT_VARKEY * e, - const gbtree_vinfo * tinfo); + const gbtree_vinfo *tinfo); +extern void gbt_var_bin_union(Datum *u, GBT_VARKEY *e, + const gbtree_vinfo *tinfo); #endif diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c index ed6a7566b2..56a998ec83 100644 --- a/contrib/chkpass/chkpass.c +++ b/contrib/chkpass/chkpass.c @@ -4,7 +4,7 @@ * http://www.druid.net/darcy/ * - * $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.20 2008/03/25 22:42:41 tgl Exp $ + * $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.21 2009/06/11 14:48:50 momjian Exp $ * best viewed with tabs set to 4 */ @@ -37,7 +37,7 @@ PG_MODULE_MAGIC; typedef struct chkpass { char password[16]; -} chkpass; +} chkpass; /* * Various forward declarations: diff --git a/contrib/citext/citext.c b/contrib/citext/citext.c index eb885c0037..371e70f74d 100644 --- a/contrib/citext/citext.c +++ b/contrib/citext/citext.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/citext/citext.c,v 1.1 2008/07/29 18:31:20 tgl Exp $ + * $PostgreSQL: pgsql/contrib/citext/citext.c,v 1.2 2009/06/11 14:48:50 momjian Exp $ */ #include "postgres.h" @@ -13,27 +13,27 @@ PG_MODULE_MAGIC; #endif /* - * ==================== - * FORWARD DECLARATIONS - * ==================== + * ==================== + * FORWARD DECLARATIONS + * ==================== */ -static int32 citextcmp (text *left, text *right); -extern Datum citext_cmp (PG_FUNCTION_ARGS); -extern Datum citext_hash (PG_FUNCTION_ARGS); -extern Datum citext_eq (PG_FUNCTION_ARGS); -extern Datum citext_ne (PG_FUNCTION_ARGS); -extern Datum citext_gt (PG_FUNCTION_ARGS); -extern Datum citext_ge (PG_FUNCTION_ARGS); -extern Datum citext_lt (PG_FUNCTION_ARGS); -extern Datum citext_le (PG_FUNCTION_ARGS); -extern Datum citext_smaller (PG_FUNCTION_ARGS); -extern Datum citext_larger (PG_FUNCTION_ARGS); +static int32 citextcmp(text *left, text *right); +extern Datum citext_cmp(PG_FUNCTION_ARGS); +extern Datum citext_hash(PG_FUNCTION_ARGS); +extern Datum citext_eq(PG_FUNCTION_ARGS); +extern Datum citext_ne(PG_FUNCTION_ARGS); +extern Datum citext_gt(PG_FUNCTION_ARGS); +extern Datum citext_ge(PG_FUNCTION_ARGS); +extern Datum citext_lt(PG_FUNCTION_ARGS); +extern Datum citext_le(PG_FUNCTION_ARGS); +extern Datum citext_smaller(PG_FUNCTION_ARGS); +extern Datum citext_larger(PG_FUNCTION_ARGS); /* - * ================= - * UTILITY FUNCTIONS - * ================= + * ================= + * UTILITY FUNCTIONS + * ================= */ /* @@ -42,27 +42,28 @@ extern Datum citext_larger (PG_FUNCTION_ARGS); * Returns int32 negative, zero, or positive. */ static int32 -citextcmp (text *left, text *right) +citextcmp(text *left, text *right) { - char *lcstr, *rcstr; - int32 result; + char *lcstr, + *rcstr; + int32 result; - lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left)); - rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right)); + lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left)); + rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right)); - result = varstr_cmp(lcstr, strlen(lcstr), - rcstr, strlen(rcstr)); + result = varstr_cmp(lcstr, strlen(lcstr), + rcstr, strlen(rcstr)); - pfree(lcstr); - pfree(rcstr); + pfree(lcstr); + pfree(rcstr); - return result; + return result; } /* - * ================== - * INDEXING FUNCTIONS - * ================== + * ================== + * INDEXING FUNCTIONS + * ================== */ PG_FUNCTION_INFO_V1(citext_cmp); @@ -70,16 +71,16 @@ PG_FUNCTION_INFO_V1(citext_cmp); Datum citext_cmp(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - int32 result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + int32 result; - result = citextcmp(left, right); + result = citextcmp(left, right); - PG_FREE_IF_COPY(left, 0); - PG_FREE_IF_COPY(right, 1); + PG_FREE_IF_COPY(left, 0); + PG_FREE_IF_COPY(right, 1); - PG_RETURN_INT32(result); + PG_RETURN_INT32(result); } PG_FUNCTION_INFO_V1(citext_hash); @@ -87,24 +88,24 @@ PG_FUNCTION_INFO_V1(citext_hash); Datum citext_hash(PG_FUNCTION_ARGS) { - text *txt = PG_GETARG_TEXT_PP(0); - char *str; - Datum result; + text *txt = PG_GETARG_TEXT_PP(0); + char *str; + Datum result; - str = str_tolower(VARDATA_ANY(txt), VARSIZE_ANY_EXHDR(txt)); - result = hash_any((unsigned char *) str, strlen(str)); - pfree(str); + str = str_tolower(VARDATA_ANY(txt), VARSIZE_ANY_EXHDR(txt)); + result = hash_any((unsigned char *) str, strlen(str)); + pfree(str); - /* Avoid leaking memory for toasted inputs */ - PG_FREE_IF_COPY(txt, 0); + /* Avoid leaking memory for toasted inputs */ + PG_FREE_IF_COPY(txt, 0); - PG_RETURN_DATUM(result); + PG_RETURN_DATUM(result); } /* - * ================== - * OPERATOR FUNCTIONS - * ================== + * ================== + * OPERATOR FUNCTIONS + * ================== */ PG_FUNCTION_INFO_V1(citext_eq); @@ -112,29 +113,29 @@ PG_FUNCTION_INFO_V1(citext_eq); Datum citext_eq(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - char *lcstr, *rcstr; - bool result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + char *lcstr, + *rcstr; + bool result; - /* We can't compare lengths in advance of downcasing ... */ + /* We can't compare lengths in advance of downcasing ... */ - lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left)); - rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right)); + lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left)); + rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right)); - /* - * Since we only care about equality or not-equality, we can - * avoid all the expense of strcoll() here, and just do bitwise - * comparison. - */ - result = (strcmp(lcstr, rcstr) == 0); + /* + * Since we only care about equality or not-equality, we can avoid all the + * expense of strcoll() here, and just do bitwise comparison. + */ + result = (strcmp(lcstr, rcstr) == 0); - pfree(lcstr); - pfree(rcstr); - PG_FREE_IF_COPY(left, 0); - PG_FREE_IF_COPY(right, 1); + pfree(lcstr); + pfree(rcstr); + PG_FREE_IF_COPY(left, 0); + PG_FREE_IF_COPY(right, 1); - PG_RETURN_BOOL(result); + PG_RETURN_BOOL(result); } PG_FUNCTION_INFO_V1(citext_ne); @@ -142,29 +143,29 @@ PG_FUNCTION_INFO_V1(citext_ne); Datum citext_ne(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - char *lcstr, *rcstr; - bool result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + char *lcstr, + *rcstr; + bool result; - /* We can't compare lengths in advance of downcasing ... */ + /* We can't compare lengths in advance of downcasing ... */ - lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left)); - rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right)); + lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left)); + rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right)); - /* - * Since we only care about equality or not-equality, we can - * avoid all the expense of strcoll() here, and just do bitwise - * comparison. - */ - result = (strcmp(lcstr, rcstr) != 0); + /* + * Since we only care about equality or not-equality, we can avoid all the + * expense of strcoll() here, and just do bitwise comparison. + */ + result = (strcmp(lcstr, rcstr) != 0); - pfree(lcstr); - pfree(rcstr); - PG_FREE_IF_COPY(left, 0); - PG_FREE_IF_COPY(right, 1); + pfree(lcstr); + pfree(rcstr); + PG_FREE_IF_COPY(left, 0); + PG_FREE_IF_COPY(right, 1); - PG_RETURN_BOOL(result); + PG_RETURN_BOOL(result); } PG_FUNCTION_INFO_V1(citext_lt); @@ -172,16 +173,16 @@ PG_FUNCTION_INFO_V1(citext_lt); Datum citext_lt(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - bool result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + bool result; - result = citextcmp(left, right) < 0; + result = citextcmp(left, right) < 0; - PG_FREE_IF_COPY(left, 0); - PG_FREE_IF_COPY(right, 1); + PG_FREE_IF_COPY(left, 0); + PG_FREE_IF_COPY(right, 1); - PG_RETURN_BOOL(result); + PG_RETURN_BOOL(result); } PG_FUNCTION_INFO_V1(citext_le); @@ -189,16 +190,16 @@ PG_FUNCTION_INFO_V1(citext_le); Datum citext_le(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - bool result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + bool result; - result = citextcmp(left, right) <= 0; + result = citextcmp(left, right) <= 0; - PG_FREE_IF_COPY(left, 0); - PG_FREE_IF_COPY(right, 1); + PG_FREE_IF_COPY(left, 0); + PG_FREE_IF_COPY(right, 1); - PG_RETURN_BOOL(result); + PG_RETURN_BOOL(result); } PG_FUNCTION_INFO_V1(citext_gt); @@ -206,16 +207,16 @@ PG_FUNCTION_INFO_V1(citext_gt); Datum citext_gt(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - bool result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + bool result; - result = citextcmp(left, right) > 0; + result = citextcmp(left, right) > 0; - PG_FREE_IF_COPY(left, 0); - PG_FREE_IF_COPY(right, 1); + PG_FREE_IF_COPY(left, 0); + PG_FREE_IF_COPY(right, 1); - PG_RETURN_BOOL(result); + PG_RETURN_BOOL(result); } PG_FUNCTION_INFO_V1(citext_ge); @@ -223,22 +224,22 @@ PG_FUNCTION_INFO_V1(citext_ge); Datum citext_ge(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - bool result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + bool result; - result = citextcmp(left, right) >= 0; + result = citextcmp(left, right) >= 0; - PG_FREE_IF_COPY(left, 0); - PG_FREE_IF_COPY(right, 1); + PG_FREE_IF_COPY(left, 0); + PG_FREE_IF_COPY(right, 1); - PG_RETURN_BOOL(result); + PG_RETURN_BOOL(result); } /* - * =================== - * AGGREGATE FUNCTIONS - * =================== + * =================== + * AGGREGATE FUNCTIONS + * =================== */ PG_FUNCTION_INFO_V1(citext_smaller); @@ -246,12 +247,12 @@ PG_FUNCTION_INFO_V1(citext_smaller); Datum citext_smaller(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - text *result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + text *result; - result = citextcmp(left, right) < 0 ? left : right; - PG_RETURN_TEXT_P(result); + result = citextcmp(left, right) < 0 ? left : right; + PG_RETURN_TEXT_P(result); } PG_FUNCTION_INFO_V1(citext_larger); @@ -259,10 +260,10 @@ PG_FUNCTION_INFO_V1(citext_larger); Datum citext_larger(PG_FUNCTION_ARGS) { - text *left = PG_GETARG_TEXT_PP(0); - text *right = PG_GETARG_TEXT_PP(1); - text *result; + text *left = PG_GETARG_TEXT_PP(0); + text *right = PG_GETARG_TEXT_PP(1); + text *result; - result = citextcmp(left, right) > 0 ? left : right; - PG_RETURN_TEXT_P(result); + result = citextcmp(left, right) > 0 ? left : right; + PG_RETURN_TEXT_P(result); } diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index 72ec3ba2ad..62cd3a2d02 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -1,5 +1,5 @@ /****************************************************************************** - $PostgreSQL: pgsql/contrib/cube/cube.c,v 1.36 2008/05/29 18:46:40 tgl Exp $ + $PostgreSQL: pgsql/contrib/cube/cube.c,v 1.37 2009/06/11 14:48:50 momjian Exp $ This file contains routines that can be bound to a Postgres backend and called by the backend in the process of processing queries. The calling @@ -134,14 +134,14 @@ Datum cube_enlarge(PG_FUNCTION_ARGS); /* ** For internal use only */ -int32 cube_cmp_v0(NDBOX * a, NDBOX * b); -bool cube_contains_v0(NDBOX * a, NDBOX * b); -bool cube_overlap_v0(NDBOX * a, NDBOX * b); -NDBOX *cube_union_v0(NDBOX * a, NDBOX * b); -void rt_cube_size(NDBOX * a, double *sz); -NDBOX *g_cube_binary_union(NDBOX * r1, NDBOX * r2, int *sizep); -bool g_cube_leaf_consistent(NDBOX * key, NDBOX * query, StrategyNumber strategy); -bool g_cube_internal_consistent(NDBOX * key, NDBOX * query, StrategyNumber strategy); +int32 cube_cmp_v0(NDBOX *a, NDBOX *b); +bool cube_contains_v0(NDBOX *a, NDBOX *b); +bool cube_overlap_v0(NDBOX *a, NDBOX *b); +NDBOX *cube_union_v0(NDBOX *a, NDBOX *b); +void rt_cube_size(NDBOX *a, double *sz); +NDBOX *g_cube_binary_union(NDBOX *r1, NDBOX *r2, int *sizep); +bool g_cube_leaf_consistent(NDBOX *key, NDBOX *query, StrategyNumber strategy); +bool g_cube_internal_consistent(NDBOX *key, NDBOX *query, StrategyNumber strategy); /* ** Auxiliary funxtions @@ -201,7 +201,7 @@ cube_a_f8_f8(PG_FUNCTION_ARGS) dur = ARRPTR(ur); dll = ARRPTR(ll); - size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim; + size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim; result = (NDBOX *) palloc0(size); SET_VARSIZE(result, size); result->dim = dim; @@ -237,7 +237,7 @@ cube_a_f8(PG_FUNCTION_ARGS) dur = ARRPTR(ur); - size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim; + size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim; result = (NDBOX *) palloc0(size); SET_VARSIZE(result, size); result->dim = dim; @@ -270,7 +270,7 @@ cube_subset(PG_FUNCTION_ARGS) dx = (int4 *) ARR_DATA_PTR(idx); dim = ARRNELEMS(idx); - size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim; + size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim; result = (NDBOX *) palloc0(size); SET_VARSIZE(result, size); result->dim = dim; @@ -359,6 +359,7 @@ g_cube_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); NDBOX *query = PG_GETARG_NDBOX(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool res; @@ -652,8 +653,8 @@ g_cube_same(PG_FUNCTION_ARGS) ** SUPPORT ROUTINES */ bool -g_cube_leaf_consistent(NDBOX * key, - NDBOX * query, +g_cube_leaf_consistent(NDBOX *key, + NDBOX *query, StrategyNumber strategy) { bool retval; @@ -684,8 +685,8 @@ g_cube_leaf_consistent(NDBOX * key, } bool -g_cube_internal_consistent(NDBOX * key, - NDBOX * query, +g_cube_internal_consistent(NDBOX *key, + NDBOX *query, StrategyNumber strategy) { bool retval; @@ -714,7 +715,7 @@ g_cube_internal_consistent(NDBOX * key, } NDBOX * -g_cube_binary_union(NDBOX * r1, NDBOX * r2, int *sizep) +g_cube_binary_union(NDBOX *r1, NDBOX *r2, int *sizep) { NDBOX *retval; @@ -727,7 +728,7 @@ g_cube_binary_union(NDBOX * r1, NDBOX * r2, int *sizep) /* cube_union_v0 */ NDBOX * -cube_union_v0(NDBOX * a, NDBOX * b) +cube_union_v0(NDBOX *a, NDBOX *b) { int i; NDBOX *result; @@ -887,7 +888,7 @@ cube_size(PG_FUNCTION_ARGS) } void -rt_cube_size(NDBOX * a, double *size) +rt_cube_size(NDBOX *a, double *size) { int i, j; @@ -906,7 +907,7 @@ rt_cube_size(NDBOX * a, double *size) /* make up a metric in which one box will be 'lower' than the other -- this can be useful for sorting and to determine uniqueness */ int32 -cube_cmp_v0(NDBOX * a, NDBOX * b) +cube_cmp_v0(NDBOX *a, NDBOX *b) { int i; int dim; @@ -1093,7 +1094,7 @@ cube_ge(PG_FUNCTION_ARGS) /* Contains */ /* Box(A) CONTAINS Box(B) IFF pt(A) < pt(B) */ bool -cube_contains_v0(NDBOX * a, NDBOX * b) +cube_contains_v0(NDBOX *a, NDBOX *b) { int i; @@ -1163,7 +1164,7 @@ cube_contained(PG_FUNCTION_ARGS) /* Overlap */ /* Box(A) Overlap Box(B) IFF (pt(a)LL < pt(B)UR) && (pt(b)LL < pt(a)UR) */ bool -cube_overlap_v0(NDBOX * a, NDBOX * b) +cube_overlap_v0(NDBOX *a, NDBOX *b) { int i; @@ -1374,7 +1375,7 @@ cube_enlarge(PG_FUNCTION_ARGS) dim = n; if (a->dim > dim) dim = a->dim; - size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2; + size = offsetof(NDBOX, x[0]) +sizeof(double) * dim * 2; result = (NDBOX *) palloc0(size); SET_VARSIZE(result, size); result->dim = dim; @@ -1415,7 +1416,7 @@ cube_f8(PG_FUNCTION_ARGS) NDBOX *result; int size; - size = offsetof(NDBOX, x[0]) + sizeof(double) * 2; + size = offsetof(NDBOX, x[0]) +sizeof(double) * 2; result = (NDBOX *) palloc0(size); SET_VARSIZE(result, size); result->dim = 1; @@ -1433,7 +1434,7 @@ cube_f8_f8(PG_FUNCTION_ARGS) NDBOX *result; int size; - size = offsetof(NDBOX, x[0]) + sizeof(double) * 2; + size = offsetof(NDBOX, x[0]) +sizeof(double) * 2; result = (NDBOX *) palloc0(size); SET_VARSIZE(result, size); result->dim = 1; @@ -1454,7 +1455,7 @@ cube_c_f8(PG_FUNCTION_ARGS) int size; int i; - size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) *2; + size = offsetof(NDBOX, x[0]) +sizeof(double) * (c->dim + 1) *2; result = (NDBOX *) palloc0(size); SET_VARSIZE(result, size); result->dim = c->dim + 1; @@ -1481,7 +1482,7 @@ cube_c_f8_f8(PG_FUNCTION_ARGS) int size; int i; - size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) *2; + size = offsetof(NDBOX, x[0]) +sizeof(double) * (c->dim + 1) *2; result = (NDBOX *) palloc0(size); SET_VARSIZE(result, size); result->dim = c->dim + 1; diff --git a/contrib/cube/cubedata.h b/contrib/cube/cubedata.h index b5ec0e70c6..1100602cfc 100644 --- a/contrib/cube/cubedata.h +++ b/contrib/cube/cubedata.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/cube/cubedata.h,v 1.9 2007/03/07 21:21:12 teodor Exp $ */ +/* $PostgreSQL: pgsql/contrib/cube/cubedata.h,v 1.10 2009/06/11 14:48:50 momjian Exp $ */ #define CUBE_MAX_DIM (100) @@ -7,7 +7,7 @@ typedef struct NDBOX int32 vl_len_; /* varlena header (do not touch directly!) */ unsigned int dim; double x[1]; -} NDBOX; +} NDBOX; #define DatumGetNDBOX(x) ((NDBOX*)DatumGetPointer(x)) #define PG_GETARG_NDBOX(x) DatumGetNDBOX( PG_DETOAST_DATUM(PG_GETARG_DATUM(x)) ) diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 9cd047b1ea..6f3cc71f16 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -8,7 +8,7 @@ * Darko Prenosil <[email protected]> * Shridhar Daithankar <[email protected]> * - * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.81 2009/06/09 17:41:02 tgl Exp $ + * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.82 2009/06/11 14:48:50 momjian Exp $ * Copyright (c) 2001-2009, PostgreSQL Global Development Group * ALL RIGHTS RESERVED; * @@ -74,7 +74,7 @@ typedef struct remoteConn PGconn *conn; /* Hold the remote connection */ int openCursorCount; /* The number of open cursors */ bool newXactForCursor; /* Opened a transaction for a cursor */ -} remoteConn; +} remoteConn; /* * Internal declarations @@ -82,7 +82,7 @@ typedef struct remoteConn static Datum dblink_record_internal(FunctionCallInfo fcinfo, bool is_async); static remoteConn *getConnectionByName(const char *name); static HTAB *createConnHash(void); -static void createNewConnection(const char *name, remoteConn * rconn); +static void createNewConnection(const char *name, remoteConn *rconn); static void deleteConnection(const char *name); static char **get_pkey_attnames(Oid relid, int16 *numatts); static char **get_text_array_contents(ArrayType *array, int *numitems); @@ -116,7 +116,7 @@ typedef struct remoteConnHashEnt { char name[NAMEDATALEN]; remoteConn *rconn; -} remoteConnHashEnt; +} remoteConnHashEnt; /* initial number of connection hashes */ #define NUMCONN 16 @@ -576,9 +576,9 @@ dblink_fetch(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * 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. + * 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. */ res = PQexec(conn, buf.data); if (!res || @@ -629,8 +629,8 @@ dblink_fetch(PG_FUNCTION_ARGS) "the specified FROM clause rowtype"))); /* - * fast track when no results. We could exit earlier, but then - * we'd not report error if the result tuple type is wrong. + * fast track when no results. We could exit earlier, but then we'd + * not report error if the result tuple type is wrong. */ if (funcctx->max_calls < 1) { @@ -815,7 +815,7 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async) /* shouldn't happen */ elog(ERROR, "wrong number of arguments"); } - else /* is_async */ + else /* is_async */ { /* get async result */ if (PG_NARGS() == 2) @@ -837,106 +837,105 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async) if (!conn) DBLINK_CONN_NOT_AVAIL; - /* synchronous query, or async result retrieval */ - if (!is_async) - res = PQexec(conn, sql); - else - { - res = PQgetResult(conn); - /* NULL means we're all done with the async results */ - if (!res) - { - MemoryContextSwitchTo(oldcontext); - SRF_RETURN_DONE(funcctx); - } - } - - if (!res || - (PQresultStatus(res) != PGRES_COMMAND_OK && - PQresultStatus(res) != PGRES_TUPLES_OK)) + /* synchronous query, or async result retrieval */ + if (!is_async) + res = PQexec(conn, sql); + else + { + res = PQgetResult(conn); + /* NULL means we're all done with the async results */ + if (!res) { - dblink_res_error(conname, res, "could not execute query", fail); - if (freeconn) - PQfinish(conn); MemoryContextSwitchTo(oldcontext); SRF_RETURN_DONE(funcctx); } + } - if (PQresultStatus(res) == PGRES_COMMAND_OK) - { - is_sql_cmd = true; - - /* need a tuple descriptor representing one TEXT column */ - tupdesc = CreateTemplateTupleDesc(1, false); - TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status", - TEXTOID, -1, 0); - - /* - * and save a copy of the command status string to return as - * our result tuple - */ - sql_cmd_status = PQcmdStatus(res); - funcctx->max_calls = 1; - } - else - funcctx->max_calls = PQntuples(res); - - /* got results, keep track of them */ - funcctx->user_fctx = res; - - /* if needed, close the connection to the database and cleanup */ + if (!res || + (PQresultStatus(res) != PGRES_COMMAND_OK && + PQresultStatus(res) != PGRES_TUPLES_OK)) + { + dblink_res_error(conname, res, "could not execute query", fail); if (freeconn) PQfinish(conn); + MemoryContextSwitchTo(oldcontext); + SRF_RETURN_DONE(funcctx); + } - if (!is_sql_cmd) - { - /* get a tuple descriptor for our result type */ - switch (get_call_result_type(fcinfo, NULL, &tupdesc)) - { - case TYPEFUNC_COMPOSITE: - /* success */ - break; - case TYPEFUNC_RECORD: - /* failed to determine actual type of RECORD */ - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function returning record called in context " - "that cannot accept type record"))); - break; - default: - /* result type isn't composite */ - elog(ERROR, "return type must be a row type"); - break; - } + if (PQresultStatus(res) == PGRES_COMMAND_OK) + { + is_sql_cmd = true; - /* make sure we have a persistent copy of the tupdesc */ - tupdesc = CreateTupleDescCopy(tupdesc); - } + /* need a tuple descriptor representing one TEXT column */ + tupdesc = CreateTemplateTupleDesc(1, false); + TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status", + TEXTOID, -1, 0); /* - * check result and tuple descriptor have the same number of - * columns + * and save a copy of the command status string to return as our + * result tuple */ - if (PQnfields(res) != tupdesc->natts) - ereport(ERROR, - (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("remote query result rowtype does not match " - "the specified FROM clause rowtype"))); + sql_cmd_status = PQcmdStatus(res); + funcctx->max_calls = 1; + } + else + funcctx->max_calls = PQntuples(res); - /* fast track when no results */ - if (funcctx->max_calls < 1) + /* got results, keep track of them */ + funcctx->user_fctx = res; + + /* if needed, close the connection to the database and cleanup */ + if (freeconn) + PQfinish(conn); + + if (!is_sql_cmd) + { + /* get a tuple descriptor for our result type */ + switch (get_call_result_type(fcinfo, NULL, &tupdesc)) { - if (res) - PQclear(res); - MemoryContextSwitchTo(oldcontext); - SRF_RETURN_DONE(funcctx); + case TYPEFUNC_COMPOSITE: + /* success */ + break; + case TYPEFUNC_RECORD: + /* failed to determine actual type of RECORD */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("function returning record called in context " + "that cannot accept type record"))); + break; + default: + /* result type isn't composite */ + elog(ERROR, "return type must be a row type"); + break; } - /* store needed metadata for subsequent calls */ - attinmeta = TupleDescGetAttInMetadata(tupdesc); - funcctx->attinmeta = attinmeta; + /* make sure we have a persistent copy of the tupdesc */ + tupdesc = CreateTupleDescCopy(tupdesc); + } + /* + * check result and tuple descriptor have the same number of columns + */ + if (PQnfields(res) != tupdesc->natts) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("remote query result rowtype does not match " + "the specified FROM clause rowtype"))); + + /* fast track when no results */ + if (funcctx->max_calls < 1) + { + if (res) + PQclear(res); MemoryContextSwitchTo(oldcontext); + SRF_RETURN_DONE(funcctx); + } + + /* store needed metadata for subsequent calls */ + attinmeta = TupleDescGetAttInMetadata(tupdesc); + funcctx->attinmeta = attinmeta; + + MemoryContextSwitchTo(oldcontext); } @@ -2014,7 +2013,7 @@ quote_literal_cstr(char *rawstr) rawstr_text = cstring_to_text(rawstr); result_text = DatumGetTextP(DirectFunctionCall1(quote_literal, - PointerGetDatum(rawstr_text))); + PointerGetDatum(rawstr_text))); result = text_to_cstring(result_text); return result; @@ -2033,7 +2032,7 @@ quote_ident_cstr(char *rawstr) rawstr_text = cstring_to_text(rawstr); result_text = DatumGetTextP(DirectFunctionCall1(quote_ident, - PointerGetDatum(rawstr_text))); + PointerGetDatum(rawstr_text))); result = text_to_cstring(result_text); return result; @@ -2229,7 +2228,7 @@ createConnHash(void) } static void -createNewConnection(const char *name, remoteConn * rconn) +createNewConnection(const char *name, remoteConn *rconn) { remoteConnHashEnt *hentry; bool found; @@ -2296,7 +2295,7 @@ dblink_security_check(PGconn *conn, remoteConn *rconn) } /* - * For non-superusers, insist that the connstr specify a password. This + * For non-superusers, insist that the connstr specify a password. This * prevents a password from being picked up from .pgpass, a service file, * the environment, etc. We don't want the postgres user's passwords * to be accessible to non-superusers. @@ -2306,9 +2305,9 @@ dblink_connstr_check(const char *connstr) { if (!superuser()) { - PQconninfoOption *options; - PQconninfoOption *option; - bool connstr_gives_password = false; + PQconninfoOption *options; + PQconninfoOption *option; + bool connstr_gives_password = false; options = PQconninfoParse(connstr, NULL); if (options) @@ -2329,9 +2328,9 @@ dblink_connstr_check(const char *connstr) if (!connstr_gives_password) ereport(ERROR, - (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), - errmsg("password is required"), - errdetail("Non-superusers must provide a password in the connection string."))); + (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), + errmsg("password is required"), + errdetail("Non-superusers must provide a password in the connection string."))); } } @@ -2377,13 +2376,13 @@ dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_ dblink_context_conname = conname; ereport(level, - (errcode(sqlstate), - message_primary ? errmsg("%s", message_primary) : errmsg("unknown error"), - message_detail ? errdetail("%s", message_detail) : 0, - message_hint ? errhint("%s", message_hint) : 0, - message_context ? errcontext("%s", message_context) : 0, - errcontext("Error occurred on dblink connection named \"%s\": %s.", - dblink_context_conname, dblink_context_msg))); + (errcode(sqlstate), + message_primary ? errmsg("%s", message_primary) : errmsg("unknown error"), + message_detail ? errdetail("%s", message_detail) : 0, + message_hint ? errhint("%s", message_hint) : 0, + message_context ? errcontext("%s", message_context) : 0, + errcontext("Error occurred on dblink connection named \"%s\": %s.", + dblink_context_conname, dblink_context_msg))); } /* @@ -2392,12 +2391,12 @@ dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_ static char * get_connect_string(const char *servername) { - ForeignServer *foreign_server = NULL; - UserMapping *user_mapping; - ListCell *cell; - StringInfo buf = makeStringInfo(); + ForeignServer *foreign_server = NULL; + UserMapping *user_mapping; + ListCell *cell; + StringInfo buf = makeStringInfo(); ForeignDataWrapper *fdw; - AclResult aclresult; + AclResult aclresult; /* first gather the server connstr options */ if (strlen(servername) < NAMEDATALEN) @@ -2405,39 +2404,39 @@ get_connect_string(const char *servername) if (foreign_server) { - Oid serverid = foreign_server->serverid; - Oid fdwid = foreign_server->fdwid; - Oid userid = GetUserId(); + Oid serverid = foreign_server->serverid; + Oid fdwid = foreign_server->fdwid; + Oid userid = GetUserId(); user_mapping = GetUserMapping(userid, serverid); - fdw = GetForeignDataWrapper(fdwid); + fdw = GetForeignDataWrapper(fdwid); /* Check permissions, user must have usage on the server. */ aclresult = pg_foreign_server_aclcheck(serverid, userid, ACL_USAGE); if (aclresult != ACLCHECK_OK) aclcheck_error(aclresult, ACL_KIND_FOREIGN_SERVER, foreign_server->servername); - foreach (cell, fdw->options) + foreach(cell, fdw->options) { - DefElem *def = lfirst(cell); + DefElem *def = lfirst(cell); appendStringInfo(buf, "%s='%s' ", def->defname, escape_param_str(strVal(def->arg))); } - foreach (cell, foreign_server->options) + foreach(cell, foreign_server->options) { - DefElem *def = lfirst(cell); - + DefElem *def = lfirst(cell); + appendStringInfo(buf, "%s='%s' ", def->defname, escape_param_str(strVal(def->arg))); } - - foreach (cell, user_mapping->options) + + foreach(cell, user_mapping->options) { - - DefElem *def = lfirst(cell); - + + DefElem *def = lfirst(cell); + appendStringInfo(buf, "%s='%s' ", def->defname, escape_param_str(strVal(def->arg))); } @@ -2456,8 +2455,8 @@ get_connect_string(const char *servername) static char * escape_param_str(const char *str) { - const char *cp; - StringInfo buf = makeStringInfo(); + const char *cp; + StringInfo buf = makeStringInfo(); for (cp = str; *cp; cp++) { diff --git a/contrib/dict_int/dict_int.c b/contrib/dict_int/dict_int.c index 36562a2d7f..e555cdb893 100644 --- a/contrib/dict_int/dict_int.c +++ b/contrib/dict_int/dict_int.c @@ -6,7 +6,7 @@ * Copyright (c) 2007-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/dict_int/dict_int.c,v 1.4 2009/01/01 17:23:32 momjian Exp $ + * $PostgreSQL: pgsql/contrib/dict_int/dict_int.c,v 1.5 2009/06/11 14:48:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ typedef struct { int maxlen; bool rejectlong; -} DictInt; +} DictInt; PG_FUNCTION_INFO_V1(dintdict_init); diff --git a/contrib/earthdistance/earthdistance.c b/contrib/earthdistance/earthdistance.c index 6c191a5c38..4dce1f828e 100644 --- a/contrib/earthdistance/earthdistance.c +++ b/contrib/earthdistance/earthdistance.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/earthdistance/earthdistance.c,v 1.15 2008/04/21 01:11:43 tgl Exp $ */ +/* $PostgreSQL: pgsql/contrib/earthdistance/earthdistance.c,v 1.16 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -91,7 +91,7 @@ geo_distance_internal(Point *pt1, Point *pt2) * distance between the points in miles on earth's surface * * If float8 is passed-by-value, the oldstyle version-0 calling convention - * is unportable, so we use version-1. However, if it's passed-by-reference, + * is unportable, so we use version-1. However, if it's passed-by-reference, * continue to use oldstyle. This is just because we'd like earthdistance * to serve as a canary for any unintentional breakage of version-0 functions * with float8 results. @@ -100,6 +100,7 @@ geo_distance_internal(Point *pt1, Point *pt2) #ifdef USE_FLOAT8_BYVAL Datum geo_distance(PG_FUNCTION_ARGS); + PG_FUNCTION_INFO_V1(geo_distance); Datum @@ -112,8 +113,7 @@ geo_distance(PG_FUNCTION_ARGS) result = geo_distance_internal(pt1, pt2); PG_RETURN_FLOAT8(result); } - -#else /* !USE_FLOAT8_BYVAL */ +#else /* !USE_FLOAT8_BYVAL */ double *geo_distance(Point *pt1, Point *pt2); @@ -126,4 +126,4 @@ geo_distance(Point *pt1, Point *pt2) return resultp; } -#endif /* USE_FLOAT8_BYVAL */ +#endif /* USE_FLOAT8_BYVAL */ diff --git a/contrib/fuzzystrmatch/dmetaphone.c b/contrib/fuzzystrmatch/dmetaphone.c index 5bb07640bf..113acb566a 100644 --- a/contrib/fuzzystrmatch/dmetaphone.c +++ b/contrib/fuzzystrmatch/dmetaphone.c @@ -1,7 +1,7 @@ /* * This is a port of the Double Metaphone algorithm for use in PostgreSQL. * - * $PostgreSQL: pgsql/contrib/fuzzystrmatch/dmetaphone.c,v 1.12 2008/03/25 22:42:41 tgl Exp $ + * $PostgreSQL: pgsql/contrib/fuzzystrmatch/dmetaphone.c,v 1.13 2009/06/11 14:48:51 momjian Exp $ * * Double Metaphone computes 2 "sounds like" strings - a primary and an * alternate. In most cases they are the same, but for foreign names @@ -224,7 +224,7 @@ typedef struct int free_string_on_destroy; } - metastring; +metastring; /* * remaining perl module funcs unchanged except for declaring them static @@ -258,7 +258,7 @@ NewMetaString(char *init_str) static void -DestroyMetaString(metastring * s) +DestroyMetaString(metastring *s) { if (s == NULL) return; @@ -271,7 +271,7 @@ DestroyMetaString(metastring * s) static void -IncreaseBuffer(metastring * s, int chars_needed) +IncreaseBuffer(metastring *s, int chars_needed) { META_REALLOC(s->str, (s->bufsize + chars_needed + 10), char); assert(s->str != NULL); @@ -280,7 +280,7 @@ IncreaseBuffer(metastring * s, int chars_needed) static void -MakeUpper(metastring * s) +MakeUpper(metastring *s) { char *i; @@ -290,7 +290,7 @@ MakeUpper(metastring * s) static int -IsVowel(metastring * s, int pos) +IsVowel(metastring *s, int pos) { char c; @@ -307,7 +307,7 @@ IsVowel(metastring * s, int pos) static int -SlavoGermanic(metastring * s) +SlavoGermanic(metastring *s) { if ((char *) strstr(s->str, "W")) return 1; @@ -323,7 +323,7 @@ SlavoGermanic(metastring * s) static char -GetAt(metastring * s, int pos) +GetAt(metastring *s, int pos) { if ((pos < 0) || (pos >= s->length)) return '\0'; @@ -333,7 +333,7 @@ GetAt(metastring * s, int pos) static void -SetAt(metastring * s, int pos, char c) +SetAt(metastring *s, int pos, char c) { if ((pos < 0) || (pos >= s->length)) return; @@ -346,7 +346,7 @@ SetAt(metastring * s, int pos, char c) Caveats: the START value is 0 based */ static int -StringAt(metastring * s, int start, int length,...) +StringAt(metastring *s, int start, int length,...) { char *test; char *pos; @@ -373,7 +373,7 @@ StringAt(metastring * s, int start, int length,...) static void -MetaphAdd(metastring * s, char *new_str) +MetaphAdd(metastring *s, char *new_str) { int add_length; diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c index 387f124942..b3def054a9 100644 --- a/contrib/fuzzystrmatch/fuzzystrmatch.c +++ b/contrib/fuzzystrmatch/fuzzystrmatch.c @@ -5,7 +5,7 @@ * * Joe Conway <[email protected]> * - * $PostgreSQL: pgsql/contrib/fuzzystrmatch/fuzzystrmatch.c,v 1.29 2009/04/07 15:53:54 tgl Exp $ + * $PostgreSQL: pgsql/contrib/fuzzystrmatch/fuzzystrmatch.c,v 1.30 2009/06/11 14:48:51 momjian Exp $ * Copyright (c) 2001-2009, PostgreSQL Global Development Group * ALL RIGHTS RESERVED; * @@ -90,8 +90,8 @@ soundex_code(char letter) */ #define MAX_LEVENSHTEIN_STRLEN 255 -static int levenshtein_internal(const char *s, const char *t, - int ins_c, int del_c, int sub_c); +static int levenshtein_internal(const char *s, const char *t, + int ins_c, int del_c, int sub_c); /* @@ -186,18 +186,20 @@ getcode(char c) /* * levenshtein_internal - Calculates Levenshtein distance metric - * between supplied strings. Generally - * (1, 1, 1) penalty costs suffices common - * cases, but your mileage may vary. + * between supplied strings. Generally + * (1, 1, 1) penalty costs suffices common + * cases, but your mileage may vary. */ static int levenshtein_internal(const char *s, const char *t, int ins_c, int del_c, int sub_c) { - int m, n; - int *prev; - int *curr; - int i, j; + int m, + n; + int *prev; + int *curr; + int i, + j; const char *x; const char *y; @@ -205,9 +207,8 @@ levenshtein_internal(const char *s, const char *t, n = strlen(t); /* - * If either m or n is 0, the answer is the other value. This makes - * sense since it would take that many insertions to build a matching - * string + * If either m or n is 0, the answer is the other value. This makes sense + * since it would take that many insertions to build a matching string */ if (!m) return n; @@ -230,10 +231,10 @@ levenshtein_internal(const char *s, const char *t, ++n; /* - * Instead of building an (m+1)x(n+1) array, we'll use two - * different arrays of size m+1 for storing accumulated values. - * At each step one represents the "previous" row and one is the - * "current" row of the notional large array. + * Instead of building an (m+1)x(n+1) array, we'll use two different + * arrays of size m+1 for storing accumulated values. At each step one + * represents the "previous" row and one is the "current" row of the + * notional large array. */ prev = (int *) palloc(2 * m * sizeof(int)); curr = prev + m; @@ -245,24 +246,24 @@ levenshtein_internal(const char *s, const char *t, /* Loop through rows of the notional array */ for (y = t, j = 1; j < n; y++, j++) { - int *temp; + int *temp; /* - * First cell must increment sequentially, as we're on the - * j'th row of the (m+1)x(n+1) array. + * First cell must increment sequentially, as we're on the j'th row of + * the (m+1)x(n+1) array. */ curr[0] = j; - + for (x = s, i = 1; i < m; x++, i++) { - int ins; - int del; - int sub; + int ins; + int del; + int sub; /* Calculate costs for probable operations. */ - ins = prev[i] + ins_c; /* Insertion */ - del = curr[i-1] + del_c; /* Deletion */ - sub = prev[i-1] + ((*x == *y) ? 0 : sub_c); /* Substitution */ + ins = prev[i] + ins_c; /* Insertion */ + del = curr[i - 1] + del_c; /* Deletion */ + sub = prev[i - 1] + ((*x == *y) ? 0 : sub_c); /* Substitution */ /* Take the one with minimum cost. */ curr[i] = Min(ins, del); @@ -276,10 +277,10 @@ levenshtein_internal(const char *s, const char *t, } /* - * Because the final value was swapped from the previous row to - * the current row, that's where we'll find it. + * Because the final value was swapped from the previous row to the + * current row, that's where we'll find it. */ - return prev[m-1]; + return prev[m - 1]; } @@ -287,11 +288,11 @@ PG_FUNCTION_INFO_V1(levenshtein_with_costs); Datum levenshtein_with_costs(PG_FUNCTION_ARGS) { - char *src = TextDatumGetCString(PG_GETARG_DATUM(0)); - char *dst = TextDatumGetCString(PG_GETARG_DATUM(1)); - int ins_c = PG_GETARG_INT32(2); - int del_c = PG_GETARG_INT32(3); - int sub_c = PG_GETARG_INT32(4); + char *src = TextDatumGetCString(PG_GETARG_DATUM(0)); + char *dst = TextDatumGetCString(PG_GETARG_DATUM(1)); + int ins_c = PG_GETARG_INT32(2); + int del_c = PG_GETARG_INT32(3); + int sub_c = PG_GETARG_INT32(4); PG_RETURN_INT32(levenshtein_internal(src, dst, ins_c, del_c, sub_c)); } @@ -301,8 +302,8 @@ PG_FUNCTION_INFO_V1(levenshtein); Datum levenshtein(PG_FUNCTION_ARGS) { - char *src = TextDatumGetCString(PG_GETARG_DATUM(0)); - char *dst = TextDatumGetCString(PG_GETARG_DATUM(1)); + char *src = TextDatumGetCString(PG_GETARG_DATUM(0)); + char *dst = TextDatumGetCString(PG_GETARG_DATUM(1)); PG_RETURN_INT32(levenshtein_internal(src, dst, 1, 1, 1)); } @@ -417,9 +418,9 @@ Lookahead(char *word, int how_far) static int -_metaphone(char *word, /* IN */ +_metaphone(char *word, /* IN */ int max_phonemes, - char **phoned_word) /* OUT */ + char **phoned_word) /* OUT */ { int w_idx = 0; /* point in the phonization we're at. */ int p_idx = 0; /* end of the phoned phrase */ diff --git a/contrib/hstore/crc32.c b/contrib/hstore/crc32.c index b1f80fde07..dc5765d056 100644 --- a/contrib/hstore/crc32.c +++ b/contrib/hstore/crc32.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/crc32.c,v 1.3 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/hstore/crc32.c,v 1.4 2009/06/11 14:48:51 momjian Exp $ * * Both POSIX and CRC32 checksums */ diff --git a/contrib/hstore/crc32.h b/contrib/hstore/crc32.h index d2d6c8bd9a..e008b1a664 100644 --- a/contrib/hstore/crc32.h +++ b/contrib/hstore/crc32.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/crc32.h,v 1.2 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/hstore/crc32.h,v 1.3 2009/06/11 14:48:51 momjian Exp $ */ #ifndef _CRC32_H #define _CRC32_H diff --git a/contrib/hstore/hstore.h b/contrib/hstore/hstore.h index 2a2c3bad58..e8ea58b567 100644 --- a/contrib/hstore/hstore.h +++ b/contrib/hstore/hstore.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/hstore/hstore.h,v 1.7 2009/03/15 22:05:17 tgl Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore.h,v 1.8 2009/06/11 14:48:51 momjian Exp $ */ #ifndef __HSTORE_H__ #define __HSTORE_H__ @@ -14,7 +14,7 @@ typedef struct uint32 valisnull:1, pos:31; -} HEntry; +} HEntry; /* these are determined by the sizes of the keylen and vallen fields */ /* in struct HEntry and struct Pairs */ @@ -27,7 +27,7 @@ typedef struct int32 vl_len_; /* varlena header (do not touch directly!) */ int4 size; char data[1]; -} HStore; +} HStore; #define HSHRDSIZE (VARHDRSZ + sizeof(int4)) #define CALCDATASIZE(x, lenstr) ( (x) * sizeof(HEntry) + HSHRDSIZE + (lenstr) ) @@ -45,15 +45,15 @@ typedef struct uint16 vallen; bool isnull; bool needfree; -} Pairs; +} Pairs; int comparePairs(const void *a, const void *b); -int uniquePairs(Pairs * a, int4 l, int4 *buflen); +int uniquePairs(Pairs *a, int4 l, int4 *buflen); -size_t hstoreCheckKeyLen(size_t len); -size_t hstoreCheckValLen(size_t len); +size_t hstoreCheckKeyLen(size_t len); +size_t hstoreCheckValLen(size_t len); #define HStoreContainsStrategyNumber 7 #define HStoreExistsStrategyNumber 9 -#endif /* __HSTORE_H__ */ +#endif /* __HSTORE_H__ */ diff --git a/contrib/hstore/hstore_gin.c b/contrib/hstore/hstore_gin.c index 01d7258f8f..9c9a83d128 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.5 2009/03/25 22:19:01 tgl Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore_gin.c,v 1.6 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -122,6 +122,7 @@ 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); @@ -132,8 +133,8 @@ gin_consistent_hstore(PG_FUNCTION_ARGS) int i; /* - * Index lost information about correspondence of keys - * and values, so we need recheck + * Index lost information about correspondence of keys and values, so + * we need recheck */ *recheck = true; for (i = 0; res && i < 2 * query->size; i++) diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c index ecfed0f5da..0f6eac347c 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.9 2008/05/12 00:00:42 alvherre Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore_gist.c,v 1.10 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -42,7 +42,7 @@ typedef struct int32 vl_len_; /* varlena header (do not touch directly!) */ int4 flag; char data[1]; -} GISTTYPE; +} GISTTYPE; #define ALLISTRUE 0x04 @@ -255,7 +255,7 @@ hemdistsign(BITVECP a, BITVECP b) } static int -hemdist(GISTTYPE * a, GISTTYPE * b) +hemdist(GISTTYPE *a, GISTTYPE *b) { if (ISALLTRUE(a)) { @@ -271,7 +271,7 @@ hemdist(GISTTYPE * a, GISTTYPE * b) } static int4 -unionkey(BITVECP sbase, GISTTYPE * add) +unionkey(BITVECP sbase, GISTTYPE *add) { int4 i; BITVECP sadd = GETSIGN(add); @@ -514,6 +514,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; diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c index 140336a2e6..3b19702520 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.10 2009/04/02 17:57:05 teodor Exp $ + * $PostgreSQL: pgsql/contrib/hstore/hstore_io.c,v 1.11 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -20,7 +20,7 @@ typedef struct Pairs *pairs; int pcur; int plen; -} HSParser; +} HSParser; #define RESIZEPRSBUF \ do { \ @@ -41,7 +41,7 @@ do { \ #define GV_WAITESCESCIN 4 static bool -get_val(HSParser * state, bool ignoreeq, bool *escaped) +get_val(HSParser *state, bool ignoreeq, bool *escaped) { int st = GV_WAITVAL; @@ -165,7 +165,7 @@ get_val(HSParser * state, bool ignoreeq, bool *escaped) static void -parse_hstore(HSParser * state) +parse_hstore(HSParser *state) { int st = WKEY; bool escaped = false; @@ -287,7 +287,7 @@ comparePairs(const void *a, const void *b) } int -uniquePairs(Pairs * a, int4 l, int4 *buflen) +uniquePairs(Pairs *a, int4 l, int4 *buflen) { Pairs *ptr, *res; @@ -328,7 +328,7 @@ uniquePairs(Pairs * a, int4 l, int4 *buflen) } static void -freeHSParse(HSParser * state) +freeHSParse(HSParser *state) { int i; @@ -447,7 +447,7 @@ hstore_out(PG_FUNCTION_ARGS) HStore *in = PG_GETARG_HS(0); int buflen, i, - nnulls=0; + nnulls = 0; char *out, *ptr; char *base = STRPTR(in); @@ -465,11 +465,11 @@ hstore_out(PG_FUNCTION_ARGS) if (entries[i].valisnull) nnulls++; - buflen = (4 /* " */ + 2 /* => */ ) * ( in->size - nnulls ) + - ( 2 /* " */ + 2 /* => */ + 4 /* NULL */ ) * nnulls + - 2 /* , */ * ( in->size - 1 ) + - 2 /* esc */ * (VARSIZE(in) - CALCDATASIZE(in->size, 0)) + - 1 /* \0 */; + buflen = (4 /* " */ + 2 /* => */ ) * (in->size - nnulls) + + (2 /* " */ + 2 /* => */ + 4 /* NULL */ ) * nnulls + + 2 /* , */ * (in->size - 1) + + 2 /* esc */ * (VARSIZE(in) - CALCDATASIZE(in->size, 0)) + + 1 /* \0 */ ; out = ptr = palloc(buflen); for (i = 0; i < in->size; i++) diff --git a/contrib/hstore/hstore_op.c b/contrib/hstore/hstore_op.c index dfd762b029..8d471e30f1 100644 --- a/contrib/hstore/hstore_op.c +++ b/contrib/hstore/hstore_op.c @@ -12,7 +12,7 @@ static HEntry * -findkey(HStore * hs, char *key, int keylen) +findkey(HStore *hs, char *key, int keylen) { HEntry *StopLow = ARRPTR(hs); HEntry *StopHigh = StopLow + hs->size; @@ -407,10 +407,10 @@ typedef struct { HStore *hs; int i; -} AKStore; +} AKStore; static void -setup_firstcall(FuncCallContext *funcctx, HStore * hs) +setup_firstcall(FuncCallContext *funcctx, HStore *hs) { MemoryContext oldcontext; AKStore *st; diff --git a/contrib/intarray/_int.h b/contrib/intarray/_int.h index debc324933..35dbb54796 100644 --- a/contrib/intarray/_int.h +++ b/contrib/intarray/_int.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/intarray/_int.h,v 1.16 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/intarray/_int.h,v 1.17 2009/06/11 14:48:51 momjian Exp $ */ #ifndef ___INT_H__ #define ___INT_H__ @@ -78,7 +78,7 @@ typedef struct int32 vl_len_; /* varlena header (do not touch directly!) */ int4 flag; char data[1]; -} GISTTYPE; +} GISTTYPE; #define ALLISTRUE 0x04 @@ -131,14 +131,14 @@ typedef struct ITEM int2 type; int2 left; int4 val; -} ITEM; +} ITEM; typedef struct { int32 vl_len_; /* varlena header (do not touch directly!) */ int4 size; char data[1]; -} QUERYTYPE; +} QUERYTYPE; #define HDRSIZEQT (VARHDRSZ + sizeof(int4)) #define COMPUTESIZE(size) ( HDRSIZEQT + size * sizeof(ITEM) ) @@ -151,10 +151,10 @@ typedef struct #define OPEN 4 #define CLOSE 5 -bool signconsistent(QUERYTYPE * query, BITVEC sign, bool calcnot); -bool execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot); -bool ginconsistent(QUERYTYPE * query, bool *check); -int4 shorterquery(ITEM * q, int4 len); +bool signconsistent(QUERYTYPE *query, BITVEC sign, bool calcnot); +bool execconsistent(QUERYTYPE *query, ArrayType *array, bool calcnot); +bool ginconsistent(QUERYTYPE *query, bool *check); +int4 shorterquery(ITEM *q, int4 len); int compASC(const void *a, const void *b); @@ -165,4 +165,4 @@ if (ARRNELEMS(a) > 1) \ qsort((void*)ARRPTR(a), ARRNELEMS(a),sizeof(int4), \ (direction) ? compASC : compDESC ) -#endif /* ___INT_H__ */ +#endif /* ___INT_H__ */ diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c index 2cba9b66c1..438db2ca95 100644 --- a/contrib/intarray/_int_bool.c +++ b/contrib/intarray/_int_bool.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/intarray/_int_bool.c,v 1.15 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/intarray/_int_bool.c,v 1.16 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -54,13 +54,13 @@ typedef struct NODE *str; /* number in str */ int4 num; -} WORKSTATE; +} WORKSTATE; /* * get token from query string */ static int4 -gettoken(WORKSTATE * state, int4 *val) +gettoken(WORKSTATE *state, int4 *val) { char nnn[16], *curnnn; @@ -143,7 +143,7 @@ gettoken(WORKSTATE * state, int4 *val) * push new one in polish notation reverse view */ static void -pushquery(WORKSTATE * state, int4 type, int4 val) +pushquery(WORKSTATE *state, int4 type, int4 val) { NODE *tmp = (NODE *) palloc(sizeof(NODE)); @@ -160,7 +160,7 @@ pushquery(WORKSTATE * state, int4 type, int4 val) * make polish notation of query */ static int4 -makepol(WORKSTATE * state) +makepol(WORKSTATE *state) { int4 val, type; @@ -239,7 +239,7 @@ typedef struct * is there value 'val' in array or not ? */ static bool -checkcondition_arr(void *checkval, ITEM * item) +checkcondition_arr(void *checkval, ITEM *item) { int4 *StopLow = ((CHKVAL *) checkval)->arrb; int4 *StopHigh = ((CHKVAL *) checkval)->arre; @@ -261,7 +261,7 @@ checkcondition_arr(void *checkval, ITEM * item) } static bool -checkcondition_bit(void *checkval, ITEM * item) +checkcondition_bit(void *checkval, ITEM *item) { return GETBIT(checkval, HASHVAL(item->val)); } @@ -270,7 +270,7 @@ checkcondition_bit(void *checkval, ITEM * item) * check for boolean condition */ static bool -execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM * item)) +execute(ITEM *curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM *item)) { if (curitem->type == VAL) @@ -302,7 +302,7 @@ execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *che * signconsistent & execconsistent called by *_consistent */ bool -signconsistent(QUERYTYPE * query, BITVEC sign, bool calcnot) +signconsistent(QUERYTYPE *query, BITVEC sign, bool calcnot) { return execute( GETQUERY(query) + query->size - 1, @@ -312,7 +312,7 @@ signconsistent(QUERYTYPE * query, BITVEC sign, bool calcnot) } bool -execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot) +execconsistent(QUERYTYPE *query, ArrayType *array, bool calcnot) { CHKVAL chkval; @@ -333,7 +333,7 @@ typedef struct } GinChkVal; static bool -checkcondition_gin(void *checkval, ITEM * item) +checkcondition_gin(void *checkval, ITEM *item) { GinChkVal *gcv = (GinChkVal *) checkval; @@ -341,7 +341,7 @@ checkcondition_gin(void *checkval, ITEM * item) } bool -ginconsistent(QUERYTYPE * query, bool *check) +ginconsistent(QUERYTYPE *query, bool *check) { GinChkVal gcv; ITEM *items = GETQUERY(query); @@ -408,7 +408,7 @@ boolop(PG_FUNCTION_ARGS) } static void -findoprnd(ITEM * ptr, int4 *pos) +findoprnd(ITEM *ptr, int4 *pos) { #ifdef BS_DEBUG elog(DEBUG3, (ptr[*pos].type == OPR) ? @@ -618,7 +618,7 @@ bqarr_out(PG_FUNCTION_ARGS) } static int4 -countdroptree(ITEM * q, int4 pos) +countdroptree(ITEM *q, int4 pos) { if (q[pos].type == VAL) return 1; @@ -634,7 +634,7 @@ countdroptree(ITEM * q, int4 pos) * we can modify query tree for clearing */ int4 -shorterquery(ITEM * q, int4 len) +shorterquery(ITEM *q, int4 len) { int4 index, posnot, diff --git a/contrib/intarray/_int_gin.c b/contrib/intarray/_int_gin.c index 598cdeca57..2bf8fc54bb 100644 --- a/contrib/intarray/_int_gin.c +++ b/contrib/intarray/_int_gin.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/intarray/_int_gin.c,v 1.9 2009/03/25 22:19:01 tgl Exp $ + * $PostgreSQL: pgsql/contrib/intarray/_int_gin.c,v 1.10 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -90,6 +90,7 @@ ginint4_consistent(PG_FUNCTION_ARGS) { bool *check = (bool *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); + /* int32 nkeys = PG_GETARG_INT32(3); */ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ bool *recheck = (bool *) PG_GETARG_POINTER(5); diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c index 13fee25ec7..29e08eda66 100644 --- a/contrib/intarray/_int_gist.c +++ b/contrib/intarray/_int_gist.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/intarray/_int_gist.c,v 1.22 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/intarray/_int_gist.c,v 1.23 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -42,6 +42,7 @@ g_int_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); ArrayType *query = (ArrayType *) PG_DETOAST_DATUM_COPY(PG_GETARG_POINTER(1)); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool retval; diff --git a/contrib/intarray/_int_op.c b/contrib/intarray/_int_op.c index b29a405e35..54858322a2 100644 --- a/contrib/intarray/_int_op.c +++ b/contrib/intarray/_int_op.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/intarray/_int_op.c,v 1.8 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/intarray/_int_op.c,v 1.9 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" diff --git a/contrib/intarray/_int_tool.c b/contrib/intarray/_int_tool.c index 7f7e4d43a9..8c0ec29c31 100644 --- a/contrib/intarray/_int_tool.c +++ b/contrib/intarray/_int_tool.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/intarray/_int_tool.c,v 1.11 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/intarray/_int_tool.c,v 1.12 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c index d1e3f19037..f9c5986db2 100644 --- a/contrib/intarray/_intbig_gist.c +++ b/contrib/intarray/_intbig_gist.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/intarray/_intbig_gist.c,v 1.19 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/intarray/_intbig_gist.c,v 1.20 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -78,7 +78,7 @@ _intbig_out(PG_FUNCTION_ARGS) ** intbig functions *********************************************************************/ static bool -_intbig_overlap(GISTTYPE * a, ArrayType *b) +_intbig_overlap(GISTTYPE *a, ArrayType *b) { int num = ARRNELEMS(b); int4 *ptr = ARRPTR(b); @@ -96,7 +96,7 @@ _intbig_overlap(GISTTYPE * a, ArrayType *b) } static bool -_intbig_contains(GISTTYPE * a, ArrayType *b) +_intbig_contains(GISTTYPE *a, ArrayType *b) { int num = ARRNELEMS(b); int4 *ptr = ARRPTR(b); @@ -243,7 +243,7 @@ hemdistsign(BITVECP a, BITVECP b) } static int -hemdist(GISTTYPE * a, GISTTYPE * b) +hemdist(GISTTYPE *a, GISTTYPE *b) { if (ISALLTRUE(a)) { @@ -265,7 +265,7 @@ g_intbig_decompress(PG_FUNCTION_ARGS) } static int4 -unionkey(BITVECP sbase, GISTTYPE * add) +unionkey(BITVECP sbase, GISTTYPE *add) { int4 i; BITVECP sadd = GETSIGN(add); @@ -506,6 +506,7 @@ g_intbig_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); ArrayType *query = (ArrayType *) PG_DETOAST_DATUM(PG_GETARG_POINTER(1)); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool retval; diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c index 4991616915..449f70b811 100644 --- a/contrib/isn/isn.c +++ b/contrib/isn/isn.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.10 2009/01/01 17:23:32 momjian Exp $ + * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.11 2009/06/11 14:48:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ enum isn_type INVALID, ANY, EAN13, ISBN, ISMN, ISSN, UPC }; -static const char * const isn_names[] = {"EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN", "ISMN", "ISSN", "UPC"}; +static const char *const isn_names[] = {"EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN", "ISMN", "ISSN", "UPC"}; static bool g_weak = false; static bool g_initialized = false; @@ -336,7 +336,7 @@ checkdig(char *num, unsigned size) * If errorOK is true, just return "false" for bad input. */ static bool -ean2isn(ean13 ean, bool errorOK, ean13 * result, enum isn_type accept) +ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept) { enum isn_type type = INVALID; @@ -668,7 +668,7 @@ eantoobig: * (even if the check digit is valid) */ static bool -string2ean(const char *str, bool errorOK, ean13 * result, +string2ean(const char *str, bool errorOK, ean13 *result, enum isn_type accept) { bool digit, diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c index 3d9145cf6b..15c4cc022d 100644 --- a/contrib/ltree/_ltree_gist.c +++ b/contrib/ltree/_ltree_gist.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/ltree/_ltree_gist.c,v 1.25 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/ltree/_ltree_gist.c,v 1.26 2009/06/11 14:48:51 momjian Exp $ * * * GiST support for ltree[] @@ -59,7 +59,7 @@ static const uint8 number_of_ones[256] = { static void -hashing(BITVECP sign, ltree * t) +hashing(BITVECP sign, ltree *t) { int tlen = t->numlevel; ltree_level *cur = LTREE_FIRST(t); @@ -173,7 +173,7 @@ _ltree_same(PG_FUNCTION_ARGS) } static int4 -unionkey(BITVECP sbase, ltree_gist * add) +unionkey(BITVECP sbase, ltree_gist *add) { int4 i; BITVECP sadd = LTG_SIGN(add); @@ -245,7 +245,7 @@ hemdistsign(BITVECP a, BITVECP b) } static int -hemdist(ltree_gist * a, ltree_gist * b) +hemdist(ltree_gist *a, ltree_gist *b) { if (LTG_ISALLTRUE(a)) { @@ -448,7 +448,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS) } static bool -gist_te(ltree_gist * key, ltree * query) +gist_te(ltree_gist *key, ltree *query) { ltree_level *curq = LTREE_FIRST(query); BITVECP sign = LTG_SIGN(key); @@ -471,13 +471,13 @@ gist_te(ltree_gist * key, ltree * query) } static bool -checkcondition_bit(void *checkval, ITEM * val) +checkcondition_bit(void *checkval, ITEM *val) { return (FLG_CANLOOKSIGN(val->flag)) ? GETBIT(checkval, AHASHVAL(val->val)) : true; } static bool -gist_qtxt(ltree_gist * key, ltxtquery * query) +gist_qtxt(ltree_gist *key, ltxtquery *query) { if (LTG_ISALLTRUE(key)) return true; @@ -490,7 +490,7 @@ gist_qtxt(ltree_gist * key, ltxtquery * query) } static bool -gist_qe(ltree_gist * key, lquery * query) +gist_qe(ltree_gist *key, lquery *query) { lquery_level *curq = LQUERY_FIRST(query); BITVECP sign = LTG_SIGN(key); @@ -529,7 +529,7 @@ gist_qe(ltree_gist * key, lquery * query) } static bool -_arrq_cons(ltree_gist * key, ArrayType *_query) +_arrq_cons(ltree_gist *key, ArrayType *_query) { lquery *query = (lquery *) ARR_DATA_PTR(_query); int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query)); @@ -559,6 +559,7 @@ _ltree_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); char *query = (char *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1))); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); ltree_gist *key = (ltree_gist *) DatumGetPointer(entry->key); diff --git a/contrib/ltree/_ltree_op.c b/contrib/ltree/_ltree_op.c index c0d0a95001..f9e90e978d 100644 --- a/contrib/ltree/_ltree_op.c +++ b/contrib/ltree/_ltree_op.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/ltree/_ltree_op.c,v 1.12 2008/05/17 01:28:19 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/ltree/_ltree_op.c,v 1.13 2009/06/11 14:48:51 momjian Exp $ * * * op function for ltree[] @@ -43,7 +43,7 @@ typedef Datum (*PGCALL2) (PG_FUNCTION_ARGS); #define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) ) static bool -array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree ** found) +array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree **found) { int num = ArrayGetNItems(ARR_NDIM(la), ARR_DIMS(la)); ltree *item = (ltree *) ARR_DATA_PTR(la); diff --git a/contrib/ltree/lquery_op.c b/contrib/ltree/lquery_op.c index 9dc7105574..df4f0794f2 100644 --- a/contrib/ltree/lquery_op.c +++ b/contrib/ltree/lquery_op.c @@ -1,7 +1,7 @@ /* * op function for ltree and lquery * Teodor Sigaev <[email protected]> - * $PostgreSQL: pgsql/contrib/ltree/lquery_op.c,v 1.13 2008/06/30 18:30:48 teodor Exp $ + * $PostgreSQL: pgsql/contrib/ltree/lquery_op.c,v 1.14 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -27,22 +27,22 @@ typedef struct int nt; int posq; int post; -} FieldNot; +} FieldNot; static char * getlexeme(char *start, char *end, int *len) { char *ptr; - int charlen; - - while (start < end && (charlen = pg_mblen(start)) == 1 && t_iseq(start,'_') ) + int charlen; + + while (start < end && (charlen = pg_mblen(start)) == 1 && t_iseq(start, '_')) start += charlen; ptr = start; if (ptr >= end) return NULL; - while (ptr < end && !( (charlen = pg_mblen(ptr)) == 1 && t_iseq(ptr, '_') ) ) + while (ptr < end && !((charlen = pg_mblen(ptr)) == 1 && t_iseq(ptr, '_'))) ptr += charlen; *len = ptr - start; @@ -50,7 +50,7 @@ getlexeme(char *start, char *end, int *len) } bool -compare_subnode(ltree_level * t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend) + compare_subnode(ltree_level *t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend) { char *endt = t->name + t->len; char *endq = qn + len; @@ -90,11 +90,11 @@ compare_subnode(ltree_level * t, char *qn, int len, int (*cmpptr) (const char *, int ltree_strncasecmp(const char *a, const char *b, size_t s) { - char *al = str_tolower(a, s); - char *bl = str_tolower(b, s); - int res; - - res = strncmp(al, bl,s); + char *al = str_tolower(a, s); + char *bl = str_tolower(b, s); + int res; + + res = strncmp(al, bl, s); pfree(al); pfree(bl); @@ -103,7 +103,7 @@ ltree_strncasecmp(const char *a, const char *b, size_t s) } static bool -checkLevel(lquery_level * curq, ltree_level * curt) +checkLevel(lquery_level *curq, ltree_level *curt) { int (*cmpptr) (const char *, const char *, size_t); lquery_variant *curvar = LQL_FIRST(curq); @@ -154,7 +154,7 @@ static struct }; static bool -checkCond(lquery_level * curq, int query_numlevel, ltree_level * curt, int tree_numlevel, FieldNot * ptr) +checkCond(lquery_level *curq, int query_numlevel, ltree_level *curt, int tree_numlevel, FieldNot *ptr) { uint32 low_pos = 0, high_pos = 0, diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h index 9cdfedab04..f16c6f9a32 100644 --- a/contrib/ltree/ltree.h +++ b/contrib/ltree/ltree.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.21 2008/06/30 18:30:48 teodor Exp $ */ +/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.22 2009/06/11 14:48:51 momjian Exp $ */ #ifndef __LTREE_H__ #define __LTREE_H__ @@ -11,7 +11,7 @@ typedef struct { uint16 len; char name[1]; -} ltree_level; +} ltree_level; #define LEVEL_HDRSIZE (offsetof(ltree_level,name)) #define LEVEL_NEXT(x) ( (ltree_level*)( ((char*)(x)) + MAXALIGN(((ltree_level*)(x))->len + LEVEL_HDRSIZE) ) ) @@ -21,7 +21,7 @@ typedef struct int32 vl_len_; /* varlena header (do not touch directly!) */ uint16 numlevel; char data[1]; -} ltree; +} ltree; #define LTREE_HDRSIZE MAXALIGN( offsetof(ltree, data) ) #define LTREE_FIRST(x) ( (ltree_level*)( ((char*)(x))+LTREE_HDRSIZE ) ) @@ -35,7 +35,7 @@ typedef struct uint16 len; uint8 flag; char name[1]; -} lquery_variant; +} lquery_variant; #define LVAR_HDRSIZE MAXALIGN(offsetof(lquery_variant, name)) #define LVAR_NEXT(x) ( (lquery_variant*)( ((char*)(x)) + MAXALIGN(((lquery_variant*)(x))->len) + LVAR_HDRSIZE ) ) @@ -52,7 +52,7 @@ typedef struct uint16 low; uint16 high; char variants[1]; -} lquery_level; +} lquery_level; #define LQL_HDRSIZE MAXALIGN( offsetof(lquery_level,variants) ) #define LQL_NEXT(x) ( (lquery_level*)( ((char*)(x)) + MAXALIGN(((lquery_level*)(x))->totallen) ) ) @@ -73,14 +73,14 @@ typedef struct uint16 firstgood; uint16 flag; char data[1]; -} lquery; +} lquery; #define LQUERY_HDRSIZE MAXALIGN( offsetof(lquery, data) ) #define LQUERY_FIRST(x) ( (lquery_level*)( ((char*)(x))+LQUERY_HDRSIZE ) ) #define LQUERY_HASNOT 0x01 -#define ISALNUM(x) ( t_isalpha(x) || t_isdigit(x) || ( pg_mblen(x) == 1 && t_iseq((x), '_') ) ) +#define ISALNUM(x) ( t_isalpha(x) || t_isdigit(x) || ( pg_mblen(x) == 1 && t_iseq((x), '_') ) ) /* full text query */ @@ -97,7 +97,7 @@ typedef struct ITEM /* user-friendly value */ uint8 length; uint16 distance; -} ITEM; +} ITEM; /* *Storage: @@ -108,7 +108,7 @@ typedef struct int32 vl_len_; /* varlena header (do not touch directly!) */ int4 size; char data[1]; -} ltxtquery; +} ltxtquery; #define HDRSIZEQT MAXALIGN(VARHDRSZ + sizeof(int4)) #define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) ) @@ -153,15 +153,15 @@ Datum ltree_textadd(PG_FUNCTION_ARGS); /* Util function */ Datum ltree_in(PG_FUNCTION_ARGS); -bool ltree_execute(ITEM * curitem, void *checkval, - bool calcnot, bool (*chkcond) (void *checkval, ITEM * val)); +bool ltree_execute(ITEM *curitem, void *checkval, + bool calcnot, bool (*chkcond) (void *checkval, ITEM *val)); -int ltree_compare(const ltree * a, const ltree * b); -bool inner_isparent(const ltree * c, const ltree * p); -bool compare_subnode(ltree_level * t, char *q, int len, - int (*cmpptr) (const char *, const char *, size_t), bool anyend); -ltree *lca_inner(ltree ** a, int len); -int ltree_strncasecmp(const char *a, const char *b, size_t s); +int ltree_compare(const ltree *a, const ltree *b); +bool inner_isparent(const ltree *c, const ltree *p); +bool compare_subnode(ltree_level *t, char *q, int len, + int (*cmpptr) (const char *, const char *, size_t), bool anyend); +ltree *lca_inner(ltree **a, int len); +int ltree_strncasecmp(const char *a, const char *b, size_t s); #define PG_GETARG_LTREE(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) #define PG_GETARG_LTREE_COPY(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) @@ -207,7 +207,7 @@ typedef struct int32 vl_len_; /* varlena header (do not touch directly!) */ uint32 flag; char data[1]; -} ltree_gist; +} ltree_gist; #define LTG_ONENODE 0x01 #define LTG_ALLTRUE 0x02 diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c index d7c9403dc7..d48ca8e1d4 100644 --- a/contrib/ltree/ltree_gist.c +++ b/contrib/ltree/ltree_gist.c @@ -1,7 +1,7 @@ /* * GiST support for ltree * Teodor Sigaev <[email protected]> - * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.24 2008/05/12 00:00:42 alvherre Exp $ + * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.25 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -150,7 +150,7 @@ ltree_same(PG_FUNCTION_ARGS) } static void -hashing(BITVECP sign, ltree * t) +hashing(BITVECP sign, ltree *t) { int tlen = t->numlevel; ltree_level *cur = LTREE_FIRST(t); @@ -271,7 +271,7 @@ typedef struct rix { int index; ltree *r; -} RIX; +} RIX; static int treekey_cmp(const void *a, const void *b) @@ -441,7 +441,7 @@ ltree_picksplit(PG_FUNCTION_ARGS) } static bool -gist_isparent(ltree_gist * key, ltree * query) +gist_isparent(ltree_gist *key, ltree *query) { int4 numlevel = query->numlevel; int i; @@ -461,7 +461,7 @@ gist_isparent(ltree_gist * key, ltree * query) } static ltree * -copy_ltree(ltree * src) +copy_ltree(ltree *src) { ltree *dst = (ltree *) palloc(VARSIZE(src)); @@ -470,7 +470,7 @@ copy_ltree(ltree * src) } static bool -gist_ischild(ltree_gist * key, ltree * query) +gist_ischild(ltree_gist *key, ltree *query) { ltree *left = copy_ltree(LTG_GETLNODE(key)); ltree *right = copy_ltree(LTG_GETRNODE(key)); @@ -495,7 +495,7 @@ gist_ischild(ltree_gist * key, ltree * query) } static bool -gist_qe(ltree_gist * key, lquery * query) +gist_qe(ltree_gist *key, lquery *query) { lquery_level *curq = LQUERY_FIRST(query); BITVECP sign = LTG_SIGN(key); @@ -534,7 +534,7 @@ gist_qe(ltree_gist * key, lquery * query) } static int -gist_tqcmp(ltree * t, lquery * q) +gist_tqcmp(ltree *t, lquery *q) { ltree_level *al = LTREE_FIRST(t); lquery_level *ql = LQUERY_FIRST(q); @@ -563,7 +563,7 @@ gist_tqcmp(ltree * t, lquery * q) } static bool -gist_between(ltree_gist * key, lquery * query) +gist_between(ltree_gist *key, lquery *query) { if (query->firstgood == 0) return true; @@ -578,13 +578,13 @@ gist_between(ltree_gist * key, lquery * query) } static bool -checkcondition_bit(void *checkval, ITEM * val) +checkcondition_bit(void *checkval, ITEM *val) { return (FLG_CANLOOKSIGN(val->flag)) ? GETBIT(checkval, HASHVAL(val->val)) : true; } static bool -gist_qtxt(ltree_gist * key, ltxtquery * query) +gist_qtxt(ltree_gist *key, ltxtquery *query) { if (LTG_ISALLTRUE(key)) return true; @@ -597,7 +597,7 @@ gist_qtxt(ltree_gist * key, ltxtquery * query) } static bool -arrq_cons(ltree_gist * key, ArrayType *_query) +arrq_cons(ltree_gist *key, ArrayType *_query) { lquery *query = (lquery *) ARR_DATA_PTR(_query); int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query)); @@ -626,6 +626,7 @@ ltree_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); ltree_gist *key = (ltree_gist *) DatumGetPointer(entry->key); diff --git a/contrib/ltree/ltree_io.c b/contrib/ltree/ltree_io.c index 19645be38f..a88eb16cb9 100644 --- a/contrib/ltree/ltree_io.c +++ b/contrib/ltree/ltree_io.c @@ -1,7 +1,7 @@ /* * in/out function for ltree and lquery * Teodor Sigaev <[email protected]> - * $PostgreSQL: pgsql/contrib/ltree/ltree_io.c,v 1.17 2008/06/30 18:30:48 teodor Exp $ + * $PostgreSQL: pgsql/contrib/ltree/ltree_io.c,v 1.18 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -32,10 +32,10 @@ Datum lquery_out(PG_FUNCTION_ARGS); typedef struct { char *start; - int len; /* length in bytes */ + int len; /* length in bytes */ int flag; - int wlen; /* length in characters */ -} nodeitem; + int wlen; /* length in characters */ +} nodeitem; #define LTPRS_WAITNAME 0 #define LTPRS_WAITDELIM 1 @@ -52,16 +52,16 @@ ltree_in(PG_FUNCTION_ARGS) int state = LTPRS_WAITNAME; ltree *result; ltree_level *curlevel; - int charlen; - int pos=0; + int charlen; + int pos = 0; ptr = buf; while (*ptr) { charlen = pg_mblen(ptr); - if ( charlen == 1 && t_iseq(ptr, '.') ) + if (charlen == 1 && t_iseq(ptr, '.')) num++; - ptr+=charlen; + ptr += charlen; } list = lptr = (nodeitem *) palloc(sizeof(nodeitem) * (num + 1)); @@ -83,7 +83,7 @@ ltree_in(PG_FUNCTION_ARGS) } else if (state == LTPRS_WAITDELIM) { - if ( charlen == 1 && t_iseq(ptr, '.') ) + if (charlen == 1 && t_iseq(ptr, '.')) { lptr->len = ptr - lptr->start; if (lptr->wlen > 255) @@ -92,7 +92,7 @@ ltree_in(PG_FUNCTION_ARGS) errmsg("name of level is too long"), errdetail("Name length is %d, must " "be < 256, in position %d.", - lptr->wlen, pos))); + lptr->wlen, pos))); totallen += MAXALIGN(lptr->len + LEVEL_HDRSIZE); lptr++; @@ -105,7 +105,7 @@ ltree_in(PG_FUNCTION_ARGS) /* internal error */ elog(ERROR, "internal error in parser"); - ptr+=charlen; + ptr += charlen; lptr->wlen++; pos++; } @@ -209,14 +209,14 @@ lquery_in(PG_FUNCTION_ARGS) bool hasnot = false; bool wasbad = false; int charlen; - int pos=0; + int pos = 0; ptr = buf; while (*ptr) { charlen = pg_mblen(ptr); - if ( charlen == 1 ) + if (charlen == 1) { if (t_iseq(ptr, '.')) num++; @@ -224,7 +224,7 @@ lquery_in(PG_FUNCTION_ARGS) numOR++; } - ptr+=charlen; + ptr += charlen; } num++; @@ -243,7 +243,7 @@ lquery_in(PG_FUNCTION_ARGS) state = LQPRS_WAITDELIM; curqlevel->numvar = 1; } - else if (charlen==1 && t_iseq(ptr, '!')) + else if (charlen == 1 && t_iseq(ptr, '!')) { GETVAR(curqlevel) = lptr = (nodeitem *) palloc0(sizeof(nodeitem) * (numOR + 1)); lptr->start = ptr + 1; @@ -252,7 +252,7 @@ lquery_in(PG_FUNCTION_ARGS) curqlevel->flag |= LQL_NOT; hasnot = true; } - else if (charlen==1 && t_iseq(ptr, '*')) + else if (charlen == 1 && t_iseq(ptr, '*')) state = LQPRS_WAITOPEN; else UNCHAR; @@ -271,28 +271,28 @@ lquery_in(PG_FUNCTION_ARGS) } else if (state == LQPRS_WAITDELIM) { - if (charlen==1 && t_iseq(ptr, '@')) + if (charlen == 1 && t_iseq(ptr, '@')) { if (lptr->start == ptr) UNCHAR; lptr->flag |= LVAR_INCASE; curqlevel->flag |= LVAR_INCASE; } - else if (charlen==1 && t_iseq(ptr, '*')) + else if (charlen == 1 && t_iseq(ptr, '*')) { if (lptr->start == ptr) UNCHAR; lptr->flag |= LVAR_ANYEND; curqlevel->flag |= LVAR_ANYEND; } - else if (charlen==1 && t_iseq(ptr, '%')) + else if (charlen == 1 && t_iseq(ptr, '%')) { if (lptr->start == ptr) UNCHAR; lptr->flag |= LVAR_SUBLEXEME; curqlevel->flag |= LVAR_SUBLEXEME; } - else if (charlen==1 && t_iseq(ptr, '|')) + else if (charlen == 1 && t_iseq(ptr, '|')) { lptr->len = ptr - lptr->start - ((lptr->flag & LVAR_SUBLEXEME) ? 1 : 0) - @@ -304,11 +304,11 @@ lquery_in(PG_FUNCTION_ARGS) errmsg("name of level is too long"), errdetail("Name length is %d, must " "be < 256, in position %d.", - lptr->wlen, pos))); + lptr->wlen, pos))); state = LQPRS_WAITVAR; } - else if (charlen==1 && t_iseq(ptr, '.')) + else if (charlen == 1 && t_iseq(ptr, '.')) { lptr->len = ptr - lptr->start - ((lptr->flag & LVAR_SUBLEXEME) ? 1 : 0) - @@ -320,7 +320,7 @@ lquery_in(PG_FUNCTION_ARGS) errmsg("name of level is too long"), errdetail("Name length is %d, must " "be < 256, in position %d.", - lptr->wlen, pos))); + lptr->wlen, pos))); state = LQPRS_WAITLEVEL; curqlevel = NEXTLEV(curqlevel); @@ -335,9 +335,9 @@ lquery_in(PG_FUNCTION_ARGS) } else if (state == LQPRS_WAITOPEN) { - if (charlen==1 && t_iseq(ptr, '{')) + if (charlen == 1 && t_iseq(ptr, '{')) state = LQPRS_WAITFNUM; - else if (charlen==1 && t_iseq(ptr, '.')) + else if (charlen == 1 && t_iseq(ptr, '.')) { curqlevel->low = 0; curqlevel->high = 0xffff; @@ -349,7 +349,7 @@ lquery_in(PG_FUNCTION_ARGS) } else if (state == LQPRS_WAITFNUM) { - if (charlen==1 && t_iseq(ptr, ',')) + if (charlen == 1 && t_iseq(ptr, ',')) state = LQPRS_WAITSNUM; else if (t_isdigit(ptr)) { @@ -366,7 +366,7 @@ lquery_in(PG_FUNCTION_ARGS) curqlevel->high = atoi(ptr); state = LQPRS_WAITCLOSE; } - else if (charlen==1 && t_iseq(ptr, '}')) + else if (charlen == 1 && t_iseq(ptr, '}')) { curqlevel->high = 0xffff; state = LQPRS_WAITEND; @@ -376,26 +376,26 @@ lquery_in(PG_FUNCTION_ARGS) } else if (state == LQPRS_WAITCLOSE) { - if (charlen==1 && t_iseq(ptr, '}')) + if (charlen == 1 && t_iseq(ptr, '}')) state = LQPRS_WAITEND; else if (!t_isdigit(ptr)) UNCHAR; } else if (state == LQPRS_WAITND) { - if (charlen==1 && t_iseq(ptr, '}')) + if (charlen == 1 && t_iseq(ptr, '}')) { curqlevel->high = curqlevel->low; state = LQPRS_WAITEND; } - else if (charlen==1 && t_iseq(ptr, ',')) + else if (charlen == 1 && t_iseq(ptr, ',')) state = LQPRS_WAITSNUM; else if (!t_isdigit(ptr)) UNCHAR; } else if (state == LQPRS_WAITEND) { - if (charlen==1 && t_iseq(ptr, '.')) + if (charlen == 1 && t_iseq(ptr, '.')) { state = LQPRS_WAITLEVEL; curqlevel = NEXTLEV(curqlevel); @@ -407,8 +407,8 @@ lquery_in(PG_FUNCTION_ARGS) /* internal error */ elog(ERROR, "internal error in parser"); - ptr+=charlen; - if ( state == LQPRS_WAITDELIM ) + ptr += charlen; + if (state == LQPRS_WAITDELIM) lptr->wlen++; pos++; } diff --git a/contrib/ltree/ltree_op.c b/contrib/ltree/ltree_op.c index a6f0ef3f24..2e6d5367d8 100644 --- a/contrib/ltree/ltree_op.c +++ b/contrib/ltree/ltree_op.c @@ -1,7 +1,7 @@ /* * op function for ltree * Teodor Sigaev <[email protected]> - * $PostgreSQL: pgsql/contrib/ltree/ltree_op.c,v 1.19 2008/05/12 00:00:43 alvherre Exp $ + * $PostgreSQL: pgsql/contrib/ltree/ltree_op.c,v 1.20 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -58,7 +58,7 @@ Datum text2ltree(PG_FUNCTION_ARGS); Datum ltreeparentsel(PG_FUNCTION_ARGS); int -ltree_compare(const ltree * a, const ltree * b) +ltree_compare(const ltree *a, const ltree *b) { ltree_level *al = LTREE_FIRST(a); ltree_level *bl = LTREE_FIRST(b); @@ -152,7 +152,7 @@ nlevel(PG_FUNCTION_ARGS) } bool -inner_isparent(const ltree * c, const ltree * p) +inner_isparent(const ltree *c, const ltree *p) { ltree_level *cl = LTREE_FIRST(c); ltree_level *pl = LTREE_FIRST(p); @@ -201,7 +201,7 @@ ltree_risparent(PG_FUNCTION_ARGS) static ltree * -inner_subltree(ltree * t, int4 startpos, int4 endpos) +inner_subltree(ltree *t, int4 startpos, int4 endpos) { char *start = NULL, *end = NULL; @@ -283,7 +283,7 @@ subpath(PG_FUNCTION_ARGS) } static ltree * -ltree_concat(ltree * a, ltree * b) +ltree_concat(ltree *a, ltree *b) { ltree *r; @@ -422,7 +422,7 @@ ltree_textadd(PG_FUNCTION_ARGS) } ltree * -lca_inner(ltree ** a, int len) +lca_inner(ltree **a, int len) { int tmp, num = ((*a)->numlevel) ? (*a)->numlevel - 1 : 0; @@ -626,11 +626,11 @@ ltreeparentsel(PG_FUNCTION_ARGS) else if (hist_size < 100) { /* - * For histogram sizes from 10 to 100, we combine the - * histogram and default selectivities, putting increasingly - * more trust in the histogram for larger sizes. + * For histogram sizes from 10 to 100, we combine the histogram + * and default selectivities, putting increasingly more trust in + * the histogram for larger sizes. */ - double hist_weight = hist_size / 100.0; + double hist_weight = hist_size / 100.0; selec = selec * hist_weight + DEFAULT_PARENT_SEL * (1.0 - hist_weight); diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c index eece52972a..b158c4b441 100644 --- a/contrib/ltree/ltxtquery_io.c +++ b/contrib/ltree/ltxtquery_io.c @@ -1,7 +1,7 @@ /* * txtquery io * Teodor Sigaev <[email protected]> - * $PostgreSQL: pgsql/contrib/ltree/ltxtquery_io.c,v 1.16 2008/06/30 18:30:48 teodor Exp $ + * $PostgreSQL: pgsql/contrib/ltree/ltxtquery_io.c,v 1.17 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -51,30 +51,30 @@ typedef struct int4 sumlen; char *op; char *curop; -} QPRS_STATE; +} QPRS_STATE; /* * get token from query string */ static int4 -gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, uint16 *flag) +gettoken_query(QPRS_STATE *state, int4 *val, int4 *lenval, char **strval, uint16 *flag) { - int charlen; + int charlen; - for(;;) + for (;;) { charlen = pg_mblen(state->buf); switch (state->state) { case WAITOPERAND: - if (charlen==1 && t_iseq(state->buf, '!')) + if (charlen == 1 && t_iseq(state->buf, '!')) { (state->buf)++; *val = (int4) '!'; return OPR; } - else if (charlen==1 && t_iseq(state->buf, '(')) + else if (charlen == 1 && t_iseq(state->buf, '(')) { state->count++; (state->buf)++; @@ -101,11 +101,11 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, uint1 errmsg("modificators syntax error"))); *lenval += charlen; } - else if (charlen==1 && t_iseq(state->buf, '%')) + else if (charlen == 1 && t_iseq(state->buf, '%')) *flag |= LVAR_SUBLEXEME; - else if (charlen==1 && t_iseq(state->buf, '@')) + else if (charlen == 1 && t_iseq(state->buf, '@')) *flag |= LVAR_INCASE; - else if (charlen==1 && t_iseq(state->buf, '*')) + else if (charlen == 1 && t_iseq(state->buf, '*')) *flag |= LVAR_ANYEND; else { @@ -114,14 +114,14 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, uint1 } break; case WAITOPERATOR: - if (charlen==1 && ( t_iseq(state->buf, '&') || t_iseq(state->buf, '|') )) + if (charlen == 1 && (t_iseq(state->buf, '&') || t_iseq(state->buf, '|'))) { state->state = WAITOPERAND; *val = (int4) *(state->buf); (state->buf)++; return OPR; } - else if (charlen==1 && t_iseq(state->buf, ')')) + else if (charlen == 1 && t_iseq(state->buf, ')')) { (state->buf)++; state->count--; @@ -129,7 +129,7 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, uint1 } else if (*(state->buf) == '\0') return (state->count) ? ERR : END; - else if (charlen==1 && !t_iseq(state->buf, ' ')) + else if (charlen == 1 && !t_iseq(state->buf, ' ')) return ERR; break; default: @@ -146,7 +146,7 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, uint1 * push new one in polish notation reverse view */ static void -pushquery(QPRS_STATE * state, int4 type, int4 val, int4 distance, int4 lenval, uint16 flag) +pushquery(QPRS_STATE *state, int4 type, int4 val, int4 distance, int4 lenval, uint16 flag) { NODE *tmp = (NODE *) palloc(sizeof(NODE)); @@ -172,7 +172,7 @@ pushquery(QPRS_STATE * state, int4 type, int4 val, int4 distance, int4 lenval, u * This function is used for query_txt parsing */ static void -pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, uint16 flag) +pushval_asis(QPRS_STATE *state, int type, char *strval, int lenval, uint16 flag) { if (lenval > 0xffff) ereport(ERROR, @@ -203,7 +203,7 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, uint16 flag * make polish notaion of query */ static int4 -makepol(QPRS_STATE * state) +makepol(QPRS_STATE *state) { int4 val = 0, type; @@ -275,7 +275,7 @@ makepol(QPRS_STATE * state) } static void -findoprnd(ITEM * ptr, int4 *pos) +findoprnd(ITEM *ptr, int4 *pos) { if (ptr[*pos].type == VAL || ptr[*pos].type == VALTRUE) { diff --git a/contrib/ltree/ltxtquery_op.c b/contrib/ltree/ltxtquery_op.c index 647d978fec..559c05e2bf 100644 --- a/contrib/ltree/ltxtquery_op.c +++ b/contrib/ltree/ltxtquery_op.c @@ -1,7 +1,7 @@ /* * txtquery operations with ltree * Teodor Sigaev <[email protected]> - * $PostgreSQL: pgsql/contrib/ltree/ltxtquery_op.c,v 1.9 2008/06/30 18:30:48 teodor Exp $ + * $PostgreSQL: pgsql/contrib/ltree/ltxtquery_op.c,v 1.10 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres.h" @@ -16,7 +16,7 @@ PG_FUNCTION_INFO_V1(ltxtq_rexec); * check for boolean condition */ bool -ltree_execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM * val)) +ltree_execute(ITEM *curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM *val)) { if (curitem->type == VAL) return (*chkcond) (checkval, curitem); @@ -50,7 +50,7 @@ typedef struct } CHKVAL; static bool -checkcondition_str(void *checkval, ITEM * val) +checkcondition_str(void *checkval, ITEM *val) { ltree_level *level = LTREE_FIRST(((CHKVAL *) checkval)->node); int tlen = ((CHKVAL *) checkval)->node->numlevel; diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c index 7b9046bb18..9d896b84f5 100644 --- a/contrib/oid2name/oid2name.c +++ b/contrib/oid2name/oid2name.c @@ -5,7 +5,7 @@ * Originally by * B. Palmer, [email protected] 1-17-2001 * - * $PostgreSQL: pgsql/contrib/oid2name/oid2name.c,v 1.35 2009/02/27 09:30:21 petere Exp $ + * $PostgreSQL: pgsql/contrib/oid2name/oid2name.c,v 1.36 2009/06/11 14:48:51 momjian Exp $ */ #include "postgres_fe.h" @@ -24,7 +24,7 @@ typedef struct char **array; int num; int alloc; -} eary; +} eary; /* these are the opts structures for command line params */ struct options @@ -51,8 +51,8 @@ static void help(const char *progname); void get_opts(int, char **, struct options *); void *myalloc(size_t size); char *mystrdup(const char *str); -void add_one_elt(char *eltname, eary * eary); -char *get_comma_elts(eary * eary); +void add_one_elt(char *eltname, eary *eary); +char *get_comma_elts(eary *eary); PGconn *sql_conn(struct options *); int sql_exec(PGconn *, const char *sql, bool quiet); void sql_exec_dumpalldbs(PGconn *, struct options *); @@ -230,18 +230,19 @@ mystrdup(const char *str) * Add one element to a (possibly empty) eary struct. */ void -add_one_elt(char *eltname, eary * eary) +add_one_elt(char *eltname, eary *eary) { if (eary->alloc == 0) { - eary->alloc = 8; - eary->array = (char **) myalloc(8 * sizeof(char *)); + eary ->alloc = 8; + eary ->array = (char **) myalloc(8 * sizeof(char *)); } else if (eary->num >= eary->alloc) { - eary->alloc *= 2; - eary->array = (char **) - realloc(eary->array, eary->alloc * sizeof(char *)); + eary ->alloc *= 2; + eary ->array = (char **) + realloc(eary->array, eary->alloc * sizeof(char *)); + if (!eary->array) { fprintf(stderr, "out of memory"); @@ -249,8 +250,8 @@ add_one_elt(char *eltname, eary * eary) } } - eary->array[eary->num] = mystrdup(eltname); - eary->num++; + eary ->array[eary->num] = mystrdup(eltname); + eary ->num++; } /* @@ -261,7 +262,7 @@ add_one_elt(char *eltname, eary * eary) * SQL statement. */ char * -get_comma_elts(eary * eary) +get_comma_elts(eary *eary) { char *ret, *ptr; @@ -310,8 +311,8 @@ sql_conn(struct options * my_opts) new_pass = false; conn = PQsetdbLogin(my_opts->hostname, my_opts->port, - NULL, /* options */ - NULL, /* tty */ + NULL, /* options */ + NULL, /* tty */ my_opts->dbname, my_opts->username, password); diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c index 85935b9990..4f56864d2e 100644 --- a/contrib/pageinspect/btreefuncs.c +++ b/contrib/pageinspect/btreefuncs.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pageinspect/btreefuncs.c,v 1.9 2009/03/31 22:54:31 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pageinspect/btreefuncs.c,v 1.10 2009/06/11 14:48:51 momjian Exp $ * * * btreefuncs.c @@ -83,7 +83,7 @@ typedef struct BTPageStat } btpo; uint16 btpo_flags; BTCycleId btpo_cycleid; -} BTPageStat; +} BTPageStat; /* ------------------------------------------------- @@ -93,7 +93,7 @@ typedef struct BTPageStat * ------------------------------------------------- */ static void -GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat * stat) +GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat) { Page page = BufferGetPage(buffer); PageHeader phdr = (PageHeader) page; @@ -191,9 +191,9 @@ bt_page_stats(PG_FUNCTION_ARGS) RelationGetRelationName(rel)); /* - * Reject attempts to read non-local temporary relations; we would - * be likely to get wrong data since we have no visibility into the - * owning session's local buffers. + * Reject attempts to read non-local temporary relations; we would be + * likely to get wrong data since we have no visibility into the owning + * session's local buffers. */ if (RELATION_IS_OTHER_TEMP(rel)) ereport(ERROR, @@ -309,14 +309,14 @@ bt_page_items(PG_FUNCTION_ARGS) RelationGetRelationName(rel)); /* - * Reject attempts to read non-local temporary relations; we would - * be likely to get wrong data since we have no visibility into the + * Reject attempts to read non-local temporary relations; we would be + * likely to get wrong data since we have no visibility into the * owning session's local buffers. */ if (RELATION_IS_OTHER_TEMP(rel)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot access temporary tables of other sessions"))); + errmsg("cannot access temporary tables of other sessions"))); if (blkno == 0) elog(ERROR, "block 0 is a meta page"); @@ -458,9 +458,9 @@ bt_metap(PG_FUNCTION_ARGS) RelationGetRelationName(rel)); /* - * Reject attempts to read non-local temporary relations; we would - * be likely to get wrong data since we have no visibility into the - * owning session's local buffers. + * Reject attempts to read non-local temporary relations; we would be + * likely to get wrong data since we have no visibility into the owning + * session's local buffers. */ if (RELATION_IS_OTHER_TEMP(rel)) ereport(ERROR, diff --git a/contrib/pageinspect/fsmfuncs.c b/contrib/pageinspect/fsmfuncs.c index 71f1e23fa6..7f87726651 100644 --- a/contrib/pageinspect/fsmfuncs.c +++ b/contrib/pageinspect/fsmfuncs.c @@ -12,7 +12,7 @@ * Copyright (c) 2007-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/pageinspect/fsmfuncs.c,v 1.2 2009/01/01 17:23:32 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pageinspect/fsmfuncs.c,v 1.3 2009/06/11 14:48:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ #include "miscadmin.h" #include "funcapi.h" -Datum fsm_page_contents(PG_FUNCTION_ARGS); +Datum fsm_page_contents(PG_FUNCTION_ARGS); /* * Dumps the contents of a FSM page. @@ -50,7 +50,7 @@ fsm_page_contents(PG_FUNCTION_ARGS) initStringInfo(&sinfo); - for(i=0; i < NodesPerPage; i++) + for (i = 0; i < NodesPerPage; i++) { if (fsmpage->fp_nodes[i] != 0) appendStringInfo(&sinfo, "%d: %d\n", i, fsmpage->fp_nodes[i]); diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c index 2b8688d0fb..bdd742db5d 100644 --- a/contrib/pageinspect/heapfuncs.c +++ b/contrib/pageinspect/heapfuncs.c @@ -18,7 +18,7 @@ * Copyright (c) 2007-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/pageinspect/heapfuncs.c,v 1.6 2009/01/01 17:23:32 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pageinspect/heapfuncs.c,v 1.7 2009/06/11 14:48:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,7 +72,7 @@ typedef struct heap_page_items_state TupleDesc tupd; Page page; uint16 offset; -} heap_page_items_state; +} heap_page_items_state; Datum heap_page_items(PG_FUNCTION_ARGS) @@ -189,7 +189,7 @@ heap_page_items(PG_FUNCTION_ARGS) (((char *) tuphdr->t_bits) -((char *) tuphdr)); values[11] = CStringGetTextDatum( - bits_to_text(tuphdr->t_bits, bits_len * 8)); + bits_to_text(tuphdr->t_bits, bits_len * 8)); } else nulls[11] = true; diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c index 00e2535eae..9430e855bf 100644 --- a/contrib/pageinspect/rawpage.c +++ b/contrib/pageinspect/rawpage.c @@ -8,7 +8,7 @@ * Copyright (c) 2007-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/pageinspect/rawpage.c,v 1.12 2009/06/08 16:22:44 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pageinspect/rawpage.c,v 1.13 2009/06/11 14:48:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ Datum get_raw_page_fork(PG_FUNCTION_ARGS); Datum page_header(PG_FUNCTION_ARGS); static bytea *get_raw_page_internal(text *relname, ForkNumber forknum, - BlockNumber blkno); + BlockNumber blkno); /* @@ -121,9 +121,9 @@ get_raw_page_internal(text *relname, ForkNumber forknum, BlockNumber blkno) RelationGetRelationName(rel)))); /* - * Reject attempts to read non-local temporary relations; we would - * be likely to get wrong data since we have no visibility into the - * owning session's local buffers. + * Reject attempts to read non-local temporary relations; we would be + * likely to get wrong data since we have no visibility into the owning + * session's local buffers. */ if (RELATION_IS_OTHER_TEMP(rel)) ereport(ERROR, diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c index ef18fa1048..5939f52a04 100644 --- a/contrib/pg_buffercache/pg_buffercache_pages.c +++ b/contrib/pg_buffercache/pg_buffercache_pages.c @@ -3,7 +3,7 @@ * pg_buffercache_pages.c * display some contents of the buffer cache * - * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.15 2008/08/14 12:56:41 heikki Exp $ + * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.16 2009/06/11 14:48:51 momjian Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -37,7 +37,7 @@ typedef struct bool isvalid; bool isdirty; uint16 usagecount; -} BufferCachePagesRec; +} BufferCachePagesRec; /* @@ -47,7 +47,7 @@ typedef struct { TupleDesc tupdesc; BufferCachePagesRec *record; -} BufferCachePagesContext; +} BufferCachePagesContext; /* diff --git a/contrib/pg_freespacemap/pg_freespacemap.c b/contrib/pg_freespacemap/pg_freespacemap.c index 9c16335671..4b1dece12a 100644 --- a/contrib/pg_freespacemap/pg_freespacemap.c +++ b/contrib/pg_freespacemap/pg_freespacemap.c @@ -3,7 +3,7 @@ * pg_freespacemap.c * display contents of a free space map * - * $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.13 2009/04/07 17:57:50 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.14 2009/06/11 14:48:51 momjian Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -27,10 +27,10 @@ PG_FUNCTION_INFO_V1(pg_freespace); Datum pg_freespace(PG_FUNCTION_ARGS) { - Oid relid = PG_GETARG_OID(0); - int64 blkno = PG_GETARG_INT64(1); - int16 freespace; - Relation rel; + Oid relid = PG_GETARG_OID(0); + int64 blkno = PG_GETARG_INT64(1); + int16 freespace; + Relation rel; rel = relation_open(relid, AccessShareLock); diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c index f2a7697178..01f1b1fa38 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.22 2009/05/14 20:31:09 heikki Exp $ + * $PostgreSQL: pgsql/contrib/pg_standby/pg_standby.c,v 1.23 2009/06/11 14:48:51 momjian Exp $ * * * pg_standby.c @@ -91,7 +91,7 @@ char exclusiveCleanupFileName[MAXPGPATH]; /* the file we need to #define SmartFailover 1 #define FastFailover 2 -static int Failover = NoFailover; +static int Failover = NoFailover; #define RESTORE_COMMAND_COPY 0 #define RESTORE_COMMAND_LINK 1 @@ -205,10 +205,10 @@ CustomizableNextWALFileReady() /* * Windows 'cp' sets the final file size before the copy is - * complete, and not yet ready to be opened by pg_standby. - * So we wait for sleeptime secs before attempting to restore. - * If that is not enough, we will rely on the retry/holdoff - * mechanism. GNUWin32's cp does not have this problem. + * complete, and not yet ready to be opened by pg_standby. So we + * wait for sleeptime secs before attempting to restore. If that + * is not enough, we will rely on the retry/holdoff mechanism. + * GNUWin32's cp does not have this problem. */ pg_usleep(sleeptime * 1000000L); #endif @@ -327,10 +327,10 @@ SetWALFileNameForCleanup(void) if (restartWALFileName) { /* - * Don't do cleanup if the restartWALFileName provided - * is later than the xlog file requested. This is an error - * and we must not remove these files from archive. - * This shouldn't happen, but better safe than sorry. + * Don't do cleanup if the restartWALFileName provided is later than + * the xlog file requested. This is an error and we must not remove + * these files from archive. This shouldn't happen, but better safe + * than sorry. */ if (strcmp(restartWALFileName, nextWALFileName) > 0) return false; @@ -376,15 +376,15 @@ SetWALFileNameForCleanup(void) * CheckForExternalTrigger() * * Is there a trigger file? Sets global 'Failover' variable to indicate - * what kind of a trigger file it was. A "fast" trigger file is turned - * into a "smart" file as a side-effect. + * what kind of a trigger file it was. A "fast" trigger file is turned + * into a "smart" file as a side-effect. */ static void CheckForExternalTrigger(void) { - char buf[32]; - int fd; - int len; + char buf[32]; + int fd; + int len; /* * Look for a trigger file, if that option has been selected @@ -397,10 +397,10 @@ CheckForExternalTrigger(void) /* * An empty trigger file performs smart failover. There's a little race - * condition here: if the writer of the trigger file has just created - * the file, but not yet written anything to it, we'll treat that as - * smart shutdown even if the other process was just about to write "fast" - * to it. But that's fine: we'll restore one more WAL file, and when we're + * condition here: if the writer of the trigger file has just created the + * file, but not yet written anything to it, we'll treat that as smart + * shutdown even if the other process was just about to write "fast" to + * it. But that's fine: we'll restore one more WAL file, and when we're * invoked next time, we'll see the word "fast" and fail over immediately. */ if (stat_buf.st_size == 0) @@ -418,7 +418,7 @@ CheckForExternalTrigger(void) fflush(stderr); return; } - + if ((len = read(fd, buf, sizeof(buf))) < 0) { fprintf(stderr, "WARNING: could not read \"%s\": %s\n", @@ -428,7 +428,7 @@ CheckForExternalTrigger(void) return; } buf[len] = '\0'; - + if (strncmp(buf, "smart", 5) == 0) { Failover = SmartFailover; @@ -437,7 +437,7 @@ CheckForExternalTrigger(void) close(fd); return; } - + if (strncmp(buf, "fast", 4) == 0) { Failover = FastFailover; @@ -446,8 +446,8 @@ CheckForExternalTrigger(void) fflush(stderr); /* - * Turn it into a "smart" trigger by truncating the file. Otherwise - * if the server asks us again to restore a segment that was restored + * Turn it into a "smart" trigger by truncating the file. Otherwise if + * the server asks us again to restore a segment that was restored * restored already, we would return "not found" and upset the server. */ if (ftruncate(fd, 0) < 0) @@ -461,7 +461,7 @@ CheckForExternalTrigger(void) return; } close(fd); - + fprintf(stderr, "WARNING: invalid content in \"%s\"\n", triggerPath); fflush(stderr); return; @@ -514,7 +514,7 @@ usage(void) printf("Usage:\n"); printf(" %s [OPTION]... ARCHIVELOCATION NEXTWALFILE XLOGFILEPATH [RESTARTWALFILE]\n", progname); printf("\n" - "with main intended use as a restore_command in the recovery.conf:\n" + "with main intended use as a restore_command in the recovery.conf:\n" " restore_command = 'pg_standby [OPTION]... ARCHIVELOCATION %%f %%p %%r'\n" "e.g.\n" " restore_command = 'pg_standby -l /mnt/server/archiverdir %%f %%p %%r'\n"); @@ -577,16 +577,16 @@ main(int argc, char **argv) * You can send SIGUSR1 to trigger failover. * * Postmaster uses SIGQUIT to request immediate shutdown. The default - * action is to core dump, but we don't want that, so trap it and - * commit suicide without core dump. + * action is to core dump, but we don't want that, so trap it and commit + * suicide without core dump. * - * We used to use SIGINT and SIGQUIT to trigger failover, but that - * turned out to be a bad idea because postmaster uses SIGQUIT to - * request immediate shutdown. We still trap SIGINT, but that may - * change in a future release. + * We used to use SIGINT and SIGQUIT to trigger failover, but that turned + * out to be a bad idea because postmaster uses SIGQUIT to request + * immediate shutdown. We still trap SIGINT, but that may change in a + * future release. */ (void) signal(SIGUSR1, sighandler); - (void) signal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */ + (void) signal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */ #ifndef WIN32 (void) signal(SIGQUIT, sigquit_handler); #endif @@ -777,9 +777,9 @@ main(int argc, char **argv) { /* * Once we have restored this file successfully we can remove some - * prior WAL files. If this restore fails we musn't remove any file - * because some of them will be requested again immediately after - * the failed restore, or when we restart recovery. + * prior WAL files. If this restore fails we musn't remove any + * file because some of them will be requested again immediately + * after the failed restore, or when we restart recovery. */ if (RestoreWALFileForRecovery()) { diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index 34cbb9d0b8..5a818ba042 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-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/pg_stat_statements/pg_stat_statements.c,v 1.2 2009/01/05 13:35:38 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pg_stat_statements/pg_stat_statements.c,v 1.3 2009/06/11 14:48:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,7 +87,7 @@ typedef struct Counters */ typedef struct pgssEntry { - pgssHashKey key; /* hash key of entry - MUST BE FIRST */ + pgssHashKey key; /* hash key of entry - MUST BE FIRST */ Counters counters; /* the statistics for this query */ slock_t mutex; /* protects the counters only */ char query[1]; /* VARIABLE LENGTH ARRAY - MUST BE LAST */ @@ -106,15 +106,17 @@ typedef struct pgssSharedState /*---- Local variables ----*/ /* Current nesting depth of ExecutorRun calls */ -static int nested_level = 0; +static int nested_level = 0; + /* Saved hook values in case of unload */ -static shmem_startup_hook_type prev_shmem_startup_hook = NULL; -static ExecutorStart_hook_type prev_ExecutorStart = NULL; -static ExecutorRun_hook_type prev_ExecutorRun = NULL; -static ExecutorEnd_hook_type prev_ExecutorEnd = NULL; +static shmem_startup_hook_type prev_shmem_startup_hook = NULL; +static ExecutorStart_hook_type prev_ExecutorStart = NULL; +static ExecutorRun_hook_type prev_ExecutorRun = NULL; +static ExecutorEnd_hook_type prev_ExecutorEnd = NULL; + /* Links to shared memory state */ -static pgssSharedState *pgss = NULL; -static HTAB *pgss_hash = NULL; +static pgssSharedState *pgss = NULL; +static HTAB *pgss_hash = NULL; /*---- GUC variables ----*/ @@ -143,11 +145,11 @@ static bool pgss_save; /* whether to save stats across shutdown */ /*---- Function declarations ----*/ -void _PG_init(void); -void _PG_fini(void); +void _PG_init(void); +void _PG_fini(void); -Datum pg_stat_statements_reset(PG_FUNCTION_ARGS); -Datum pg_stat_statements(PG_FUNCTION_ARGS); +Datum pg_stat_statements_reset(PG_FUNCTION_ARGS); +Datum pg_stat_statements(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(pg_stat_statements_reset); PG_FUNCTION_INFO_V1(pg_stat_statements); @@ -156,14 +158,14 @@ static void pgss_shmem_startup(void); static void pgss_shmem_shutdown(int code, Datum arg); static void pgss_ExecutorStart(QueryDesc *queryDesc, int eflags); static void pgss_ExecutorRun(QueryDesc *queryDesc, - ScanDirection direction, - long count); + ScanDirection direction, + long count); static void pgss_ExecutorEnd(QueryDesc *queryDesc); static uint32 pgss_hash_fn(const void *key, Size keysize); -static int pgss_match_fn(const void *key1, const void *key2, Size keysize); +static int pgss_match_fn(const void *key1, const void *key2, Size keysize); static void pgss_store(const char *query, - const Instrumentation *instr, uint32 rows); -static Size pgss_memsize(void); + const Instrumentation *instr, uint32 rows); +static Size pgss_memsize(void); static pgssEntry *entry_alloc(pgssHashKey *key); static void entry_dealloc(void); static void entry_reset(void); @@ -177,11 +179,11 @@ _PG_init(void) { /* * In order to create our shared memory area, we have to be loaded via - * shared_preload_libraries. If not, fall out without hooking into - * any of the main system. (We don't throw error here because it seems - * useful to allow the pg_stat_statements functions to be created even - * when the module isn't active. The functions must protect themselves - * against being called then, however.) + * shared_preload_libraries. If not, fall out without hooking into any of + * the main system. (We don't throw error here because it seems useful to + * allow the pg_stat_statements functions to be created even when the + * module isn't active. The functions must protect themselves against + * being called then, however.) */ if (!process_shared_preload_libraries_in_progress) return; @@ -190,7 +192,7 @@ _PG_init(void) * Define (or redefine) custom GUC variables. */ DefineCustomIntVariable("pg_stat_statements.max", - "Sets the maximum number of statements tracked by pg_stat_statements.", + "Sets the maximum number of statements tracked by pg_stat_statements.", NULL, &pgss_max, 1000, @@ -202,7 +204,7 @@ _PG_init(void) NULL); DefineCustomEnumVariable("pg_stat_statements.track", - "Selects which statements are tracked by pg_stat_statements.", + "Selects which statements are tracked by pg_stat_statements.", NULL, &pgss_track, PGSS_TRACK_TOP, @@ -213,7 +215,7 @@ _PG_init(void) NULL); DefineCustomBoolVariable("pg_stat_statements.save", - "Save pg_stat_statements statistics across server shutdowns.", + "Save pg_stat_statements statistics across server shutdowns.", NULL, &pgss_save, true, @@ -265,7 +267,7 @@ _PG_fini(void) static void pgss_shmem_startup(void) { - bool found; + bool found; HASHCTL info; FILE *file; uint32 header; @@ -294,7 +296,7 @@ pgss_shmem_startup(void) elog(ERROR, "out of shared memory"); if (!found) - { + { /* First time through ... */ pgss->lock = LWLockAssign(); pgss->query_size = pgstat_track_activity_query_size; @@ -305,7 +307,7 @@ pgss_shmem_startup(void) memset(&info, 0, sizeof(info)); info.keysize = sizeof(pgssHashKey); - info.entrysize = offsetof(pgssEntry, query) + query_size; + info.entrysize = offsetof(pgssEntry, query) +query_size; info.hash = pgss_hash_fn; info.match = pgss_match_fn; pgss_hash = ShmemInitHash("pg_stat_statements hash", @@ -318,8 +320,8 @@ pgss_shmem_startup(void) LWLockRelease(AddinShmemInitLock); /* - * If we're in the postmaster (or a standalone backend...), set up a - * shmem exit hook to dump the statistics to disk. + * If we're in the postmaster (or a standalone backend...), set up a shmem + * exit hook to dump the statistics to disk. */ if (!IsUnderPostmaster) on_shmem_exit(pgss_shmem_shutdown, (Datum) 0); @@ -327,8 +329,8 @@ pgss_shmem_startup(void) /* * Attempt to load old statistics from the dump file. * - * Note: we don't bother with locks here, because there should be no - * other processes running when this is called. + * Note: we don't bother with locks here, because there should be no other + * processes running when this is called. */ if (!pgss_save) return; @@ -352,7 +354,7 @@ pgss_shmem_startup(void) for (i = 0; i < num; i++) { pgssEntry temp; - pgssEntry *entry; + pgssEntry *entry; if (fread(&temp, offsetof(pgssEntry, mutex), 1, file) != 1) goto error; @@ -413,10 +415,10 @@ error: static void pgss_shmem_shutdown(int code, Datum arg) { - FILE *file; - HASH_SEQ_STATUS hash_seq; - int32 num_entries; - pgssEntry *entry; + FILE *file; + HASH_SEQ_STATUS hash_seq; + int32 num_entries; + pgssEntry *entry; /* Don't try to dump during a crash. */ if (code) @@ -443,7 +445,7 @@ pgss_shmem_shutdown(int code, Datum arg) hash_seq_init(&hash_seq, pgss_hash); while ((entry = hash_seq_search(&hash_seq)) != NULL) { - int len = entry->key.query_len; + int len = entry->key.query_len; if (fwrite(entry, offsetof(pgssEntry, mutex), 1, file) != 1 || fwrite(entry->query, 1, len, file) != len) @@ -482,9 +484,9 @@ pgss_ExecutorStart(QueryDesc *queryDesc, int eflags) if (pgss_enabled()) { /* - * Set up to track total elapsed time in ExecutorRun. Make sure - * the space is allocated in the per-query context so it will go - * away at ExecutorEnd. + * Set up to track total elapsed time in ExecutorRun. Make sure the + * space is allocated in the per-query context so it will go away at + * ExecutorEnd. */ if (queryDesc->totaltime == NULL) { @@ -529,8 +531,8 @@ pgss_ExecutorEnd(QueryDesc *queryDesc) if (queryDesc->totaltime && pgss_enabled()) { /* - * Make sure stats accumulation is done. (Note: it's okay if - * several levels of hook all do this.) + * Make sure stats accumulation is done. (Note: it's okay if several + * levels of hook all do this.) */ InstrEndLoop(queryDesc->totaltime); @@ -585,9 +587,9 @@ pgss_match_fn(const void *key1, const void *key2, Size keysize) static void pgss_store(const char *query, const Instrumentation *instr, uint32 rows) { - pgssHashKey key; + pgssHashKey key; double usage; - pgssEntry *entry; + pgssEntry *entry; Assert(query != NULL); @@ -658,15 +660,15 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS) Datum pg_stat_statements(PG_FUNCTION_ARGS) { - ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; - TupleDesc tupdesc; - Tuplestorestate *tupstore; - MemoryContext per_query_ctx; - MemoryContext oldcontext; - Oid userid = GetUserId(); - bool is_superuser = superuser(); - HASH_SEQ_STATUS hash_seq; - pgssEntry *entry; + ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; + TupleDesc tupdesc; + Tuplestorestate *tupstore; + MemoryContext per_query_ctx; + MemoryContext oldcontext; + Oid userid = GetUserId(); + bool is_superuser = superuser(); + HASH_SEQ_STATUS hash_seq; + pgssEntry *entry; if (!pgss || !pgss_hash) ereport(ERROR, @@ -727,7 +729,7 @@ pg_stat_statements(PG_FUNCTION_ARGS) if (is_superuser || entry->key.userid == userid) { - char *qstr; + char *qstr; qstr = (char *) pg_do_encoding_conversion((unsigned char *) entry->query, @@ -777,11 +779,11 @@ pg_stat_statements(PG_FUNCTION_ARGS) static Size pgss_memsize(void) { - Size size; - Size entrysize; + Size size; + Size entrysize; size = MAXALIGN(sizeof(pgssSharedState)); - entrysize = offsetof(pgssEntry, query) + pgstat_track_activity_query_size; + entrysize = offsetof(pgssEntry, query) +pgstat_track_activity_query_size; size = add_size(size, hash_estimate_size(pgss_max, entrysize)); return size; @@ -792,7 +794,7 @@ pgss_memsize(void) * caller must hold an exclusive lock on pgss->lock * * Note: despite needing exclusive lock, it's not an error for the target - * entry to already exist. This is because pgss_store releases and + * entry to already exist. This is because pgss_store releases and * reacquires lock after failing to find a match; so someone else could * have made the entry while we waited to get exclusive lock. */ @@ -800,7 +802,7 @@ static pgssEntry * entry_alloc(pgssHashKey *key) { pgssEntry *entry; - bool found; + bool found; /* Caller must have clipped query properly */ Assert(key->query_len < pgss->query_size); @@ -837,8 +839,8 @@ entry_alloc(pgssHashKey *key) static int entry_cmp(const void *lhs, const void *rhs) { - double l_usage = (*(const pgssEntry **)lhs)->counters.usage; - double r_usage = (*(const pgssEntry **)rhs)->counters.usage; + double l_usage = (*(const pgssEntry **) lhs)->counters.usage; + double r_usage = (*(const pgssEntry **) rhs)->counters.usage; if (l_usage < r_usage) return -1; @@ -855,11 +857,11 @@ entry_cmp(const void *lhs, const void *rhs) static void entry_dealloc(void) { - HASH_SEQ_STATUS hash_seq; - pgssEntry **entries; - pgssEntry *entry; - int nvictims; - int i; + HASH_SEQ_STATUS hash_seq; + pgssEntry **entries; + pgssEntry *entry; + int nvictims; + int i; /* Sort entries by usage and deallocate USAGE_DEALLOC_PERCENT of them. */ @@ -891,8 +893,8 @@ entry_dealloc(void) static void entry_reset(void) { - HASH_SEQ_STATUS hash_seq; - pgssEntry *entry; + HASH_SEQ_STATUS hash_seq; + pgssEntry *entry; LWLockAcquire(pgss->lock, LW_EXCLUSIVE); diff --git a/contrib/pg_trgm/trgm.h b/contrib/pg_trgm/trgm.h index 18d6751687..4a89760d71 100644 --- a/contrib/pg_trgm/trgm.h +++ b/contrib/pg_trgm/trgm.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pg_trgm/trgm.h,v 1.10 2008/11/12 13:43:54 teodor Exp $ + * $PostgreSQL: pgsql/contrib/pg_trgm/trgm.h,v 1.11 2009/06/11 14:48:51 momjian Exp $ */ #ifndef __TRGM_H__ #define __TRGM_H__ @@ -31,7 +31,7 @@ typedef char trgm[3]; *(((char*)(a))+2) = *(((char*)(b))+2); \ } while(0); -uint32 trgm2int(trgm *ptr); +uint32 trgm2int(trgm *ptr); #ifdef KEEPONLYALNUM #define ISPRINTABLECHAR(a) ( isascii( *(unsigned char*)(a) ) && (isalnum( *(unsigned char*)(a) ) || *(unsigned char*)(a)==' ') ) @@ -45,7 +45,7 @@ typedef struct int32 vl_len_; /* varlena header (do not touch directly!) */ uint8 flag; char data[1]; -} TRGM; +} TRGM; #define TRGMHDRSIZE (VARHDRSZ + sizeof(uint8)) @@ -87,6 +87,6 @@ typedef char *BITVECP; extern float4 trgm_limit; TRGM *generate_trgm(char *str, int slen); -float4 cnt_sml(TRGM * trg1, TRGM * trg2); +float4 cnt_sml(TRGM *trg1, TRGM *trg2); #endif diff --git a/contrib/pg_trgm/trgm_gin.c b/contrib/pg_trgm/trgm_gin.c index 1a53d1d358..a150f8843e 100644 --- a/contrib/pg_trgm/trgm_gin.c +++ b/contrib/pg_trgm/trgm_gin.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pg_trgm/trgm_gin.c,v 1.7 2009/03/25 22:19:01 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pg_trgm/trgm_gin.c,v 1.8 2009/06/11 14:48:51 momjian Exp $ */ #include "trgm.h" @@ -52,11 +52,11 @@ gin_extract_trgm(PG_FUNCTION_ARGS) /* * Function called from query extracting */ - Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); + Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); - *extra_data = (Pointer*) palloc0(sizeof(Pointer)*(*nentries)); + *extra_data = (Pointer *) palloc0(sizeof(Pointer) * (*nentries)); - *(int32*)(*extra_data) = trglen; + *(int32 *) (*extra_data) = trglen; } } @@ -67,8 +67,9 @@ Datum gin_trgm_consistent(PG_FUNCTION_ARGS) { bool *check = (bool *) PG_GETARG_POINTER(0); + /* StrategyNumber strategy = PG_GETARG_UINT16(1); */ - /* text *query = PG_GETARG_TEXT_P(2); */ + /* text *query = PG_GETARG_TEXT_P(2); */ /* int32 nkeys = PG_GETARG_INT32(3); */ Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); bool *recheck = (bool *) PG_GETARG_POINTER(5); @@ -80,7 +81,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS) /* All cases served by this function are inexact */ *recheck = true; - trglen = *(int32*)extra_data; + trglen = *(int32 *) extra_data; for (i = 0; i < trglen; i++) if (check[i]) diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c index 2720d7fb70..7014394bb2 100644 --- a/contrib/pg_trgm/trgm_gist.c +++ b/contrib/pg_trgm/trgm_gist.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pg_trgm/trgm_gist.c,v 1.15 2008/07/11 11:56:48 teodor Exp $ + * $PostgreSQL: pgsql/contrib/pg_trgm/trgm_gist.c,v 1.16 2009/06/11 14:48:51 momjian Exp $ */ #include "trgm.h" @@ -75,7 +75,7 @@ gtrgm_out(PG_FUNCTION_ARGS) } static void -makesign(BITVECP sign, TRGM * a) +makesign(BITVECP sign, TRGM *a) { int4 k, len = ARRNELEM(a); @@ -164,33 +164,34 @@ gtrgm_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); text *query = PG_GETARG_TEXT_P(1); + /* StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); */ /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); TRGM *key = (TRGM *) DatumGetPointer(entry->key); TRGM *qtrg; bool res = false; - char *cache = (char*) fcinfo->flinfo->fn_extra; + char *cache = (char *) fcinfo->flinfo->fn_extra; /* All cases served by this function are exact */ *recheck = false; - if ( cache == NULL || VARSIZE(cache) != VARSIZE(query) || memcmp( cache, query, VARSIZE(query) ) !=0 ) + if (cache == NULL || VARSIZE(cache) != VARSIZE(query) || memcmp(cache, query, VARSIZE(query)) != 0) { - qtrg = generate_trgm(VARDATA(query), VARSIZE(query) - VARHDRSZ); + qtrg = generate_trgm(VARDATA(query), VARSIZE(query) - VARHDRSZ); if (cache) pfree(cache); fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - MAXALIGN(VARSIZE(query)) + VARSIZE(qtrg) ); - cache = (char*) fcinfo->flinfo->fn_extra; + MAXALIGN(VARSIZE(query)) + VARSIZE(qtrg)); + cache = (char *) fcinfo->flinfo->fn_extra; - memcpy( cache, query, VARSIZE(query) ); - memcpy( cache + MAXALIGN(VARSIZE(query)), qtrg, VARSIZE(qtrg) ); + memcpy(cache, query, VARSIZE(query)); + memcpy(cache + MAXALIGN(VARSIZE(query)), qtrg, VARSIZE(qtrg)); } - qtrg = (TRGM*)( cache + MAXALIGN(VARSIZE(query)) ); + qtrg = (TRGM *) (cache + MAXALIGN(VARSIZE(query))); if (GIST_LEAF(entry)) { /* all leafs contains orig trgm */ @@ -228,7 +229,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) } static int4 -unionkey(BITVECP sbase, TRGM * add) +unionkey(BITVECP sbase, TRGM *add) { int4 i; @@ -375,7 +376,7 @@ hemdistsign(BITVECP a, BITVECP b) } static int -hemdist(TRGM * a, TRGM * b) +hemdist(TRGM *a, TRGM *b) { if (ISALLTRUE(a)) { @@ -425,7 +426,7 @@ typedef struct } CACHESIGN; static void -fillcache(CACHESIGN *item, TRGM * key) +fillcache(CACHESIGN *item, TRGM *key) { item->allistrue = false; if (ISARRKEY(key)) diff --git a/contrib/pg_trgm/trgm_op.c b/contrib/pg_trgm/trgm_op.c index 3d2df22111..19b6747d68 100644 --- a/contrib/pg_trgm/trgm_op.c +++ b/contrib/pg_trgm/trgm_op.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pg_trgm/trgm_op.c,v 1.11 2008/11/12 13:43:54 teodor Exp $ + * $PostgreSQL: pgsql/contrib/pg_trgm/trgm_op.c,v 1.12 2009/06/11 14:48:51 momjian Exp $ */ #include "trgm.h" #include <ctype.h> @@ -39,7 +39,7 @@ comp_trgm(const void *a, const void *b) } static int -unique_array(trgm * a, int len) +unique_array(trgm *a, int len) { trgm *curend, *tmp; @@ -59,7 +59,7 @@ unique_array(trgm * a, int len) } #ifdef KEEPONLYALNUM -#define iswordchr(c) (t_isalpha(c) || t_isdigit(c)) +#define iswordchr(c) (t_isalpha(c) || t_isdigit(c)) #else #define iswordchr(c) (!t_isspace(c)) #endif @@ -68,12 +68,12 @@ unique_array(trgm * a, int len) * Finds first word in string, returns pointer to the word, * endword points to the character after word */ -static char* -find_word(char *str, int lenstr, char **endword, int *charlen) +static char * +find_word(char *str, int lenstr, char **endword, int *charlen) { - char *beginword = str; + char *beginword = str; - while( beginword - str < lenstr && !iswordchr(beginword) ) + while (beginword - str < lenstr && !iswordchr(beginword)) beginword += pg_mblen(beginword); if (beginword - str >= lenstr) @@ -81,7 +81,7 @@ find_word(char *str, int lenstr, char **endword, int *charlen) *endword = beginword; *charlen = 0; - while( *endword - str < lenstr && iswordchr(*endword) ) + while (*endword - str < lenstr && iswordchr(*endword)) { *endword += pg_mblen(*endword); (*charlen)++; @@ -92,11 +92,11 @@ find_word(char *str, int lenstr, char **endword, int *charlen) #ifdef USE_WIDE_UPPER_LOWER static void -cnt_trigram(trgm *tptr, char *str, int bytelen) +cnt_trigram(trgm *tptr, char *str, int bytelen) { - if ( bytelen == 3 ) + if (bytelen == 3) { - CPTRGM(tptr, str); + CPTRGM(tptr, str); } else { @@ -107,8 +107,7 @@ cnt_trigram(trgm *tptr, char *str, int bytelen) FIN_CRC32(crc); /* - * use only 3 upper bytes from crc, hope, it's - * good enough hashing + * use only 3 upper bytes from crc, hope, it's good enough hashing */ CPTRGM(tptr, &crc); } @@ -118,37 +117,37 @@ cnt_trigram(trgm *tptr, char *str, int bytelen) /* * Adds trigramm from words (already padded). */ -static trgm* -make_trigrams( trgm *tptr, char *str, int bytelen, int charlen ) +static trgm * +make_trigrams(trgm *tptr, char *str, int bytelen, int charlen) { - char *ptr = str; + char *ptr = str; - if ( charlen < 3 ) + if (charlen < 3) return tptr; #ifdef USE_WIDE_UPPER_LOWER if (pg_database_encoding_max_length() > 1) { - int lenfirst = pg_mblen(str), - lenmiddle = pg_mblen(str + lenfirst), - lenlast = pg_mblen(str + lenfirst + lenmiddle); + int lenfirst = pg_mblen(str), + lenmiddle = pg_mblen(str + lenfirst), + lenlast = pg_mblen(str + lenfirst + lenmiddle); - while( (ptr - str) + lenfirst + lenmiddle + lenlast <= bytelen ) + while ((ptr - str) + lenfirst + lenmiddle + lenlast <= bytelen) { cnt_trigram(tptr, ptr, lenfirst + lenmiddle + lenlast); ptr += lenfirst; tptr++; - lenfirst = lenmiddle; - lenmiddle = lenlast; - lenlast = pg_mblen(ptr + lenfirst + lenmiddle); + lenfirst = lenmiddle; + lenmiddle = lenlast; + lenlast = pg_mblen(ptr + lenfirst + lenmiddle); } } else #endif { - Assert( bytelen == charlen ); + Assert(bytelen == charlen); while (ptr - str < bytelen - 2 /* number of trigrams = strlen - 2 */ ) { @@ -157,7 +156,7 @@ make_trigrams( trgm *tptr, char *str, int bytelen, int charlen ) tptr++; } } - + return tptr; } @@ -170,9 +169,10 @@ generate_trgm(char *str, int slen) int len, charlen, bytelen; - char *bword, *eword; + char *bword, + *eword; - trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) * 3); + trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) *3); trg->flag = ARRKEY; SET_VARSIZE(trg, TRGMHDRSIZE); @@ -191,7 +191,7 @@ generate_trgm(char *str, int slen) } eword = str; - while( (bword=find_word(eword, slen - (eword-str), &eword, &charlen)) != NULL ) + while ((bword = find_word(eword, slen - (eword - str), &eword, &charlen)) != NULL) { #ifdef IGNORECASE bword = lowerstr_with_len(bword, eword - bword); @@ -205,14 +205,14 @@ generate_trgm(char *str, int slen) #ifdef IGNORECASE pfree(bword); #endif - buf[LPADDING+bytelen] = ' '; - buf[LPADDING+bytelen+1] = ' '; + buf[LPADDING + bytelen] = ' '; + buf[LPADDING + bytelen + 1] = ' '; /* * count trigrams */ - tptr = make_trigrams( tptr, buf, bytelen + LPADDING + RPADDING, - charlen + LPADDING + RPADDING ); + tptr = make_trigrams(tptr, buf, bytelen + LPADDING + RPADDING, + charlen + LPADDING + RPADDING); } pfree(buf); @@ -234,13 +234,13 @@ generate_trgm(char *str, int slen) uint32 trgm2int(trgm *ptr) { - uint32 val = 0; + uint32 val = 0; - val |= *( ((unsigned char*)ptr) ); + val |= *(((unsigned char *) ptr)); val <<= 8; - val |= *( ((unsigned char*)ptr) + 1 ); + val |= *(((unsigned char *) ptr) + 1); val <<= 8; - val |= *( ((unsigned char*)ptr) + 2 ); + val |= *(((unsigned char *) ptr) + 2); return val; } @@ -262,9 +262,9 @@ show_trgm(PG_FUNCTION_ARGS) for (i = 0, ptr = GETARR(trg); i < ARRNELEM(trg); i++, ptr++) { - text *item = (text *) palloc(VARHDRSZ + Max(12, pg_database_encoding_max_length()*3) ); + text *item = (text *) palloc(VARHDRSZ + Max(12, pg_database_encoding_max_length() * 3)); - if ( pg_database_encoding_max_length() > 1 && !ISPRINTABLETRGM(ptr) ) + if (pg_database_encoding_max_length() > 1 && !ISPRINTABLETRGM(ptr)) { snprintf(VARDATA(item), 12, "0x%06x", trgm2int(ptr)); SET_VARSIZE(item, VARHDRSZ + strlen(VARDATA(item))); @@ -297,7 +297,7 @@ show_trgm(PG_FUNCTION_ARGS) } float4 -cnt_sml(TRGM * trg1, TRGM * trg2) +cnt_sml(TRGM *trg1, TRGM *trg2) { trgm *ptr1, *ptr2; diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 6fd7509b0f..85b12b6eca 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.86 2009/05/07 22:01:18 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.87 2009/06/11 14:48:51 momjian Exp $ * Copyright (c) 2000-2009, PostgreSQL Global Development Group * ALL RIGHTS RESERVED; * @@ -110,14 +110,14 @@ char *pgtty = NULL; char *login = NULL; char *dbName; -volatile bool timer_exceeded = false; /* flag from signal handler */ +volatile bool timer_exceeded = false; /* flag from signal handler */ /* variable definitions */ typedef struct { char *name; /* variable name */ char *value; /* its value */ -} Variable; +} Variable; #define MAX_FILES 128 /* max number of SQL script files allowed */ @@ -141,7 +141,7 @@ typedef struct struct timeval txn_begin; /* used for measuring latencies */ int use_file; /* index in sql_files for this client */ bool prepared[MAX_FILES]; -} CState; +} CState; /* * queries read from files @@ -152,21 +152,21 @@ typedef struct typedef enum QueryMode { - QUERY_SIMPLE, /* simple query */ - QUERY_EXTENDED, /* extended query */ - QUERY_PREPARED, /* extended query with prepared statements */ + QUERY_SIMPLE, /* simple query */ + QUERY_EXTENDED, /* extended query */ + QUERY_PREPARED, /* extended query with prepared statements */ NUM_QUERYMODE } QueryMode; -static QueryMode querymode = QUERY_SIMPLE; -static const char *QUERYMODE[] = { "simple", "extended", "prepared" }; +static QueryMode querymode = QUERY_SIMPLE; +static const char *QUERYMODE[] = {"simple", "extended", "prepared"}; typedef struct { int type; /* command type (SQL_COMMAND or META_COMMAND) */ int argc; /* number of commands */ char *argv[MAX_ARGS]; /* command list */ -} Command; +} Command; Command **sql_files[MAX_FILES]; /* SQL script files */ int num_files; /* number of script files */ @@ -221,10 +221,11 @@ static void setalarm(int seconds); /* Calculate total time */ static void -addTime(struct timeval *t1, struct timeval *t2, struct timeval *result) +addTime(struct timeval * t1, struct timeval * t2, struct timeval * result) { - int sec = t1->tv_sec + t2->tv_sec; - int usec = t1->tv_usec + t2->tv_usec; + int sec = t1->tv_sec + t2->tv_sec; + int usec = t1->tv_usec + t2->tv_usec; + if (usec >= 1000000) { usec -= 1000000; @@ -236,10 +237,11 @@ addTime(struct timeval *t1, struct timeval *t2, struct timeval *result) /* Calculate time difference */ static void -diffTime(struct timeval *t1, struct timeval *t2, struct timeval *result) +diffTime(struct timeval * t1, struct timeval * t2, struct timeval * result) { - int sec = t1->tv_sec - t2->tv_sec; - int usec = t1->tv_usec - t2->tv_usec; + int sec = t1->tv_sec - t2->tv_sec; + int usec = t1->tv_usec - t2->tv_usec; + if (usec < 0) { usec += 1000000; @@ -260,7 +262,7 @@ usage(const char *progname) " -F NUM fill factor\n" " -s NUM scaling factor\n" "\nBenchmarking options:\n" - " -c NUM number of concurrent database clients (default: 1)\n" + " -c NUM number of concurrent database clients (default: 1)\n" " -C establish new connection for each transaction\n" " -D VARNAME=VALUE\n" " define variable for use by custom script\n" @@ -272,7 +274,7 @@ usage(const char *progname) " -N do not update tables \"pgbench_tellers\" and \"pgbench_branches\"\n" " -s NUM report this scale factor in output\n" " -S perform SELECT-only transactions\n" - " -t NUM number of transactions each client runs (default: 10)\n" + " -t NUM number of transactions each client runs (default: 10)\n" " -T NUM duration of benchmark test in seconds\n" " -v vacuum all four standard tables before tests\n" "\nCommon options:\n" @@ -362,7 +364,7 @@ doConnect(void) /* throw away response from backend */ static void -discard_response(CState * state) +discard_response(CState *state) { PGresult *res; @@ -376,7 +378,7 @@ discard_response(CState * state) /* check to see if the SQL result was good */ static int -check(CState * state, PGresult *res, int n) +check(CState *state, PGresult *res, int n) { CState *st = &state[n]; @@ -405,7 +407,7 @@ compareVariables(const void *v1, const void *v2) } static char * -getVariable(CState * st, char *name) +getVariable(CState *st, char *name) { Variable key, *var; @@ -427,7 +429,7 @@ getVariable(CState * st, char *name) } static int -putVariable(CState * st, char *name, char *value) +putVariable(CState *st, char *name, char *value) { Variable key, *var; @@ -493,8 +495,8 @@ putVariable(CState * st, char *name, char *value) static char * parseVariable(const char *sql, int *eaten) { - int i = 0; - char *name; + int i = 0; + char *name; do { @@ -516,12 +518,12 @@ parseVariable(const char *sql, int *eaten) static char * replaceVariable(char **sql, char *param, int len, char *value) { - int valueln = strlen(value); + int valueln = strlen(value); if (valueln > len) { - char *tmp; - size_t offset = param - *sql; + char *tmp; + size_t offset = param - *sql; tmp = realloc(*sql, strlen(*sql) - len + valueln + 1); if (tmp == NULL) @@ -541,7 +543,7 @@ replaceVariable(char **sql, char *param, int len, char *value) } static char * -assignVariables(CState * st, char *sql) +assignVariables(CState *st, char *sql) { char *p, *name, @@ -550,12 +552,15 @@ assignVariables(CState * st, char *sql) p = sql; while ((p = strchr(p, ':')) != NULL) { - int eaten; + int eaten; name = parseVariable(p, &eaten); if (name == NULL) { - while (*p == ':') { p++; } + while (*p == ':') + { + p++; + } continue; } @@ -577,10 +582,10 @@ assignVariables(CState * st, char *sql) static void getQueryParams(CState *st, const Command *command, const char **params) { - int i; + int i; for (i = 0; i < command->argc - 1; i++) - params[i] = getVariable(st, command->argv[i+1]); + params[i] = getVariable(st, command->argv[i + 1]); } #define MAX_PREPARE_NAME 32 @@ -591,7 +596,7 @@ preparedStatementName(char *buffer, int file, int state) } static void -doCustom(CState * state, int n, int debug) +doCustom(CState *state, int n, int debug) { PGresult *res; CState *st = &state[n]; @@ -694,7 +699,9 @@ top: if (st->con == NULL) { - struct timeval t1, t2, t3; + struct timeval t1, + t2, + t3; gettimeofday(&t1, NULL); if ((st->con = doConnect()) == NULL) @@ -716,8 +723,8 @@ top: if (commands[st->state]->type == SQL_COMMAND) { - const Command *command = commands[st->state]; - int r; + const Command *command = commands[st->state]; + int r; if (querymode == QUERY_SIMPLE) { @@ -738,15 +745,15 @@ top: } else if (querymode == QUERY_EXTENDED) { - const char *sql = command->argv[0]; - const char *params[MAX_ARGS]; + const char *sql = command->argv[0]; + const char *params[MAX_ARGS]; getQueryParams(st, command, params); if (debug) fprintf(stderr, "client %d sending %s\n", n, sql); r = PQsendQueryParams(st->con, sql, command->argc - 1, - NULL, params, NULL, NULL, 0); + NULL, params, NULL, NULL, 0); } else if (querymode == QUERY_PREPARED) { @@ -755,7 +762,7 @@ top: if (!st->prepared[st->use_file]) { - int j; + int j; for (j = 0; commands[j] != NULL; j++) { @@ -766,7 +773,7 @@ top: continue; preparedStatementName(name, st->use_file, j); res = PQprepare(st->con, name, - commands[j]->argv[0], commands[j]->argc - 1, NULL); + commands[j]->argv[0], commands[j]->argc - 1, NULL); if (PQresultStatus(res) != PGRES_COMMAND_OK) fprintf(stderr, "%s", PQerrorMessage(st->con)); PQclear(res); @@ -780,9 +787,9 @@ top: if (debug) fprintf(stderr, "client %d sending %s\n", n, name); r = PQsendQueryPrepared(st->con, name, command->argc - 1, - params, NULL, NULL, 0); + params, NULL, NULL, 0); } - else /* unknown sql mode */ + else /* unknown sql mode */ r = 0; if (r == 0) @@ -984,7 +991,7 @@ top: /* discard connections */ static void -disconnect_all(CState * state) +disconnect_all(CState *state) { int i; @@ -1002,12 +1009,11 @@ init(void) /* * Note: TPC-B requires at least 100 bytes per row, and the "filler" * fields in these table declarations were intended to comply with that. - * But because they default to NULLs, they don't actually take any - * space. We could fix that by giving them non-null default values. - * However, that would completely break comparability of pgbench - * results with prior versions. Since pgbench has never pretended - * to be fully TPC-B compliant anyway, we stick with the historical - * behavior. + * But because they default to NULLs, they don't actually take any space. + * We could fix that by giving them non-null default values. However, that + * would completely break comparability of pgbench results with prior + * versions. Since pgbench has never pretended to be fully TPC-B + * compliant anyway, we stick with the historical behavior. */ static char *DDLs[] = { "drop table if exists pgbench_branches", @@ -1146,14 +1152,17 @@ parseQuery(Command *cmd, const char *raw_sql) p = sql; while ((p = strchr(p, ':')) != NULL) { - char var[12]; - char *name; - int eaten; + char var[12]; + char *name; + int eaten; name = parseVariable(p, &eaten); if (name == NULL) { - while (*p == ':') { p++; } + while (*p == ':') + { + p++; + } continue; } @@ -1442,7 +1451,7 @@ process_builtin(char *tb) /* print out results */ static void printResults( - int ttype, CState * state, + int ttype, CState *state, struct timeval * start_time, struct timeval * end_time) { double t1, @@ -1506,8 +1515,8 @@ main(int argc, char **argv) CState *state; /* status of clients */ - struct timeval start_time; /* start up time */ - struct timeval end_time; /* end time */ + struct timeval start_time; /* start up time */ + struct timeval end_time; /* end time */ int i; @@ -1787,10 +1796,10 @@ main(int argc, char **argv) { if (duration <= 0) printf("pghost: %s pgport: %s nclients: %d nxacts: %d dbName: %s\n", - pghost, pgport, nclients, nxacts, dbName); + pghost, pgport, nclients, nxacts, dbName); else printf("pghost: %s pgport: %s nclients: %d duration: %d dbName: %s\n", - pghost, pgport, nclients, duration, dbName); + pghost, pgport, nclients, duration, dbName); } /* opening connection... */ @@ -1828,7 +1837,7 @@ main(int argc, char **argv) /* warn if we override user-given -s switch */ if (scale_given) fprintf(stderr, - "Scale option ignored, using pgbench_branches table count = %d\n", + "Scale option ignored, using pgbench_branches table count = %d\n", scale); } @@ -1879,7 +1888,8 @@ main(int argc, char **argv) if (is_connect == 0) { - struct timeval t, now; + struct timeval t, + now; /* make connections to the database */ for (i = 0; i < nclients; i++) @@ -1972,7 +1982,8 @@ main(int argc, char **argv) if (this_usec > 0 && (min_usec == 0 || this_usec < min_usec)) min_usec = this_usec; - FD_SET(sock, &input_mask); + FD_SET (sock, &input_mask); + if (maxsock < sock) maxsock = sock; } @@ -1985,7 +1996,8 @@ main(int argc, char **argv) disconnect_all(state); exit(1); } - FD_SET(sock, &input_mask); + FD_SET (sock, &input_mask); + if (maxsock < sock) maxsock = sock; } @@ -2069,8 +2081,7 @@ setalarm(int seconds) pqsignal(SIGALRM, handle_sig_alarm); alarm(seconds); } - -#else /* WIN32 */ +#else /* WIN32 */ static VOID CALLBACK win32_timer_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired) @@ -2081,12 +2092,12 @@ win32_timer_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired) static void setalarm(int seconds) { - HANDLE queue; - HANDLE timer; + HANDLE queue; + HANDLE timer; /* This function will be called at most once, so we can cheat a bit. */ queue = CreateTimerQueue(); - if (seconds > ((DWORD)-1) / 1000 || + if (seconds > ((DWORD) -1) / 1000 || !CreateTimerQueueTimer(&timer, queue, win32_timer_callback, NULL, seconds * 1000, 0, WT_EXECUTEINTIMERTHREAD | WT_EXECUTEONLYONCE)) @@ -2096,4 +2107,4 @@ setalarm(int seconds) } } -#endif /* WIN32 */ +#endif /* WIN32 */ diff --git a/contrib/pgcrypto/blf.c b/contrib/pgcrypto/blf.c index 7138ffa903..e03c542c0d 100644 --- a/contrib/pgcrypto/blf.c +++ b/contrib/pgcrypto/blf.c @@ -1,7 +1,7 @@ /* * Butchered version of sshblowf.c from putty-0.59. * - * $PostgreSQL: pgsql/contrib/pgcrypto/blf.c,v 1.9 2007/11/15 21:14:31 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/blf.c,v 1.10 2009/06/11 14:48:52 momjian Exp $ */ /* @@ -251,7 +251,7 @@ static const uint32 sbox3[] = { static void blowfish_encrypt(uint32 xL, uint32 xR, uint32 *output, - BlowfishContext * ctx) + BlowfishContext *ctx) { uint32 *S0 = ctx->S0; uint32 *S1 = ctx->S1; @@ -285,7 +285,7 @@ blowfish_encrypt(uint32 xL, uint32 xR, uint32 *output, static void blowfish_decrypt(uint32 xL, uint32 xR, uint32 *output, - BlowfishContext * ctx) + BlowfishContext *ctx) { uint32 *S0 = ctx->S0; uint32 *S1 = ctx->S1; @@ -318,7 +318,7 @@ blowfish_decrypt(uint32 xL, uint32 xR, uint32 *output, } void -blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx) +blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext *ctx) { uint32 xL, xR, @@ -351,7 +351,7 @@ blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx) } void -blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx) +blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext *ctx) { uint32 xL, xR, @@ -384,7 +384,7 @@ blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx) } void -blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx) +blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext *ctx) { uint32 xL, xR, @@ -405,7 +405,7 @@ blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx) } void -blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx) +blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext *ctx) { uint32 xL, xR, @@ -426,7 +426,7 @@ blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx) } void -blowfish_setkey(BlowfishContext * ctx, +blowfish_setkey(BlowfishContext *ctx, const uint8 *key, short keybytes) { uint32 *S0 = ctx->S0; @@ -492,7 +492,7 @@ blowfish_setkey(BlowfishContext * ctx, } void -blowfish_setiv(BlowfishContext * ctx, const uint8 *iv) +blowfish_setiv(BlowfishContext *ctx, const uint8 *iv) { ctx->iv0 = GET_32BIT_MSB_FIRST(iv); ctx->iv1 = GET_32BIT_MSB_FIRST(iv + 4); diff --git a/contrib/pgcrypto/blf.h b/contrib/pgcrypto/blf.h index 6e280d8754..507d7f9055 100644 --- a/contrib/pgcrypto/blf.h +++ b/contrib/pgcrypto/blf.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/pgcrypto/blf.h,v 1.7 2007/11/15 21:14:31 momjian Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/blf.h,v 1.8 2009/06/11 14:48:52 momjian Exp $ */ /* * PuTTY is copyright 1997-2007 Simon Tatham. * @@ -36,11 +36,11 @@ typedef struct P[18]; uint32 iv0, iv1; /* for CBC mode */ -} BlowfishContext; +} BlowfishContext; -void blowfish_setkey(BlowfishContext * ctx, const uint8 *key, short keybytes); -void blowfish_setiv(BlowfishContext * ctx, const uint8 *iv); -void blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx); -void blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext * ctx); -void blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx); -void blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext * ctx); +void blowfish_setkey(BlowfishContext *ctx, const uint8 *key, short keybytes); +void blowfish_setiv(BlowfishContext *ctx, const uint8 *iv); +void blowfish_encrypt_cbc(uint8 *blk, int len, BlowfishContext *ctx); +void blowfish_decrypt_cbc(uint8 *blk, int len, BlowfishContext *ctx); +void blowfish_encrypt_ecb(uint8 *blk, int len, BlowfishContext *ctx); +void blowfish_decrypt_ecb(uint8 *blk, int len, BlowfishContext *ctx); diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c index 84b4d758af..9c1d2d4706 100644 --- a/contrib/pgcrypto/crypt-blowfish.c +++ b/contrib/pgcrypto/crypt-blowfish.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-blowfish.c,v 1.13 2007/11/15 21:14:31 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-blowfish.c,v 1.14 2009/06/11 14:48:52 momjian Exp $ * * This code comes from John the Ripper password cracker, with reentrant * and crypt(3) interfaces added, but optimizations specific to password @@ -59,7 +59,7 @@ typedef struct { BF_word S[4][0x100]; BF_key P; -} BF_ctx; +} BF_ctx; /* * Magic IV for 64 Blowfish encryptions that we do at the end. @@ -367,7 +367,7 @@ do { \ } while (0) static int -BF_decode(BF_word * dst, const char *src, int size) +BF_decode(BF_word *dst, const char *src, int size) { unsigned char *dptr = (unsigned char *) dst; unsigned char *end = dptr + size; @@ -399,7 +399,7 @@ BF_decode(BF_word * dst, const char *src, int size) } static void -BF_encode(char *dst, const BF_word * src, int size) +BF_encode(char *dst, const BF_word *src, int size) { unsigned char *sptr = (unsigned char *) src; unsigned char *end = sptr + size; @@ -436,7 +436,7 @@ BF_encode(char *dst, const BF_word * src, int size) } static void -BF_swap(BF_word * x, int count) +BF_swap(BF_word *x, int count) { /* Swap on little-endian hardware, else do nothing */ #ifndef WORDS_BIGENDIAN @@ -518,7 +518,7 @@ BF_swap(BF_word * x, int count) #if BF_ASM -extern void _BF_body_r(BF_ctx * ctx); +extern void _BF_body_r(BF_ctx *ctx); #define BF_body() \ _BF_body_r(&data.ctx); diff --git a/contrib/pgcrypto/crypt-gensalt.c b/contrib/pgcrypto/crypt-gensalt.c index c3ec01b900..b2ec3da828 100644 --- a/contrib/pgcrypto/crypt-gensalt.c +++ b/contrib/pgcrypto/crypt-gensalt.c @@ -2,7 +2,7 @@ * Written by Solar Designer and placed in the public domain. * See crypt_blowfish.c for more information. * - * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-gensalt.c,v 1.10 2006/10/04 00:29:46 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-gensalt.c,v 1.11 2009/06/11 14:48:52 momjian Exp $ * * This file contains salt generation functions for the traditional and * other common crypt(3) algorithms, except for bcrypt which is defined @@ -122,7 +122,7 @@ static unsigned char BF_itoa64[64 + 1] = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; static void -BF_encode(char *dst, const BF_word * src, int size) +BF_encode(char *dst, const BF_word *src, int size) { unsigned char *sptr = (unsigned char *) src; unsigned char *end = sptr + size; diff --git a/contrib/pgcrypto/fortuna.c b/contrib/pgcrypto/fortuna.c index 5a2596fe78..4e97946ab3 100644 --- a/contrib/pgcrypto/fortuna.c +++ b/contrib/pgcrypto/fortuna.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.8 2006/10/04 00:29:46 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.9 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -176,7 +176,7 @@ md_result(MD_CTX * ctx, uint8 *dst) * initialize state */ static void -init_state(FState * st) +init_state(FState *st) { int i; @@ -190,7 +190,7 @@ init_state(FState * st) * It just needs to change without repeating. */ static void -inc_counter(FState * st) +inc_counter(FState *st) { uint32 *val = (uint32 *) st->counter; @@ -207,7 +207,7 @@ inc_counter(FState * st) * This is called 'cipher in counter mode'. */ static void -encrypt_counter(FState * st, uint8 *dst) +encrypt_counter(FState *st, uint8 *dst) { ciph_encrypt(&st->ciph, st->counter, dst); inc_counter(st); @@ -219,7 +219,7 @@ encrypt_counter(FState * st, uint8 *dst) * microseconds. */ static int -enough_time_passed(FState * st) +enough_time_passed(FState *st) { int ok; struct timeval tv; @@ -252,7 +252,7 @@ enough_time_passed(FState * st) * generate new key from all the pools */ static void -reseed(FState * st) +reseed(FState *st) { unsigned k; unsigned n; @@ -298,7 +298,7 @@ reseed(FState * st) * Pick a random pool. This uses key bytes as random source. */ static unsigned -get_rand_pool(FState * st) +get_rand_pool(FState *st) { unsigned rnd; @@ -318,7 +318,7 @@ get_rand_pool(FState * st) * update pools */ static void -add_entropy(FState * st, const uint8 *data, unsigned len) +add_entropy(FState *st, const uint8 *data, unsigned len) { unsigned pos; uint8 hash[BLOCK]; @@ -349,7 +349,7 @@ add_entropy(FState * st, const uint8 *data, unsigned len) * Just take 2 next blocks as new key */ static void -rekey(FState * st) +rekey(FState *st) { encrypt_counter(st, st->key); encrypt_counter(st, st->key + CIPH_BLOCK); @@ -363,7 +363,7 @@ rekey(FState * st) * entropy over all of the components. */ static void -startup_tricks(FState * st) +startup_tricks(FState *st) { int i; uint8 buf[BLOCK]; @@ -388,7 +388,7 @@ startup_tricks(FState * st) } static void -extract_data(FState * st, unsigned count, uint8 *dst) +extract_data(FState *st, unsigned count, uint8 *dst) { unsigned n; unsigned block_nr = 0; diff --git a/contrib/pgcrypto/imath.c b/contrib/pgcrypto/imath.c index 63b294af24..35dc652d43 100644 --- a/contrib/pgcrypto/imath.c +++ b/contrib/pgcrypto/imath.c @@ -27,7 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.c,v 1.7 2007/07/15 22:43:40 tgl Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.c,v 1.8 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" #include "px.h" @@ -195,7 +195,7 @@ static void s_clamp(mp_int z); static void s_fake(mp_int z, int value, mp_digit vbuf[]); /* Compare two runs of digits of given length, returns <0, 0, >0 */ -static int s_cdig(mp_digit * da, mp_digit * db, mp_size len); +static int s_cdig(mp_digit *da, mp_digit *db, mp_size len); /* Pack the unsigned digits of v into array t */ static int s_vpack(int v, mp_digit t[]); @@ -208,26 +208,26 @@ static int s_vcmp(mp_int a, int v); /* Unsigned magnitude addition; assumes dc is big enough. Carry out is returned (no memory allocated). */ -static mp_digit s_uadd(mp_digit * da, mp_digit * db, mp_digit * dc, +static mp_digit s_uadd(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b); /* Unsigned magnitude subtraction. Assumes dc is big enough. */ -static void s_usub(mp_digit * da, mp_digit * db, mp_digit * dc, +static void s_usub(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b); /* Unsigned recursive multiplication. Assumes dc is big enough. */ -static int s_kmul(mp_digit * da, mp_digit * db, mp_digit * dc, +static int s_kmul(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b); /* Unsigned magnitude multiplication. Assumes dc is big enough. */ -static void s_umul(mp_digit * da, mp_digit * db, mp_digit * dc, +static void s_umul(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b); /* Unsigned recursive squaring. Assumes dc is big enough. */ -static int s_ksqr(mp_digit * da, mp_digit * dc, mp_size size_a); +static int s_ksqr(mp_digit *da, mp_digit *dc, mp_size size_a); /* Unsigned magnitude squaring. Assumes dc is big enough. */ -static void s_usqr(mp_digit * da, mp_digit * dc, mp_size size_a); +static void s_usqr(mp_digit *da, mp_digit *dc, mp_size size_a); /* Single digit addition. Assumes a is big enough. */ static void s_dadd(mp_int a, mp_digit b); @@ -236,7 +236,7 @@ static void s_dadd(mp_int a, mp_digit b); static void s_dmul(mp_int a, mp_digit b); /* Single digit multiplication on buffers; assumes dc is big enough. */ -static void s_dbmul(mp_digit * da, mp_digit b, mp_digit * dc, +static void s_dbmul(mp_digit *da, mp_digit b, mp_digit *dc, mp_size size_a); /* Single digit division. Replaces a with the quotient, @@ -310,7 +310,7 @@ static mp_result s_tobin(mp_int z, unsigned char *buf, int *limpos, int pad); #if 0 /* Dump a representation of the mp_int to standard output */ void s_print(char *tag, mp_int z); -void s_print_buf(char *tag, mp_digit * buf, mp_size num); +void s_print_buf(char *tag, mp_digit *buf, mp_size num); #endif /* {{{ get_default_precision() */ @@ -2294,7 +2294,7 @@ s_alloc(mp_size num) /* {{{ s_realloc(old, num) */ static mp_digit * -s_realloc(mp_digit * old, mp_size num) +s_realloc(mp_digit *old, mp_size num) { mp_digit *new = px_realloc(old, num * sizeof(mp_digit)); @@ -2375,7 +2375,7 @@ s_fake(mp_int z, int value, mp_digit vbuf[]) /* {{{ s_cdig(da, db, len) */ static int -s_cdig(mp_digit * da, mp_digit * db, mp_size len) +s_cdig(mp_digit *da, mp_digit *db, mp_size len) { mp_digit *dat = da + len - 1, *dbt = db + len - 1; @@ -2460,7 +2460,7 @@ s_vcmp(mp_int a, int v) /* {{{ s_uadd(da, db, dc, size_a, size_b) */ static mp_digit -s_uadd(mp_digit * da, mp_digit * db, mp_digit * dc, +s_uadd(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b) { mp_size pos; @@ -2476,7 +2476,7 @@ s_uadd(mp_digit * da, mp_digit * db, mp_digit * dc, /* Add corresponding digits until the shorter number runs out */ for (pos = 0; pos < size_b; ++pos, ++da, ++db, ++dc) { - w = w + (mp_word) * da + (mp_word) * db; + w = w + (mp_word) *da + (mp_word) *db; *dc = LOWER_HALF(w); w = UPPER_HALF(w); } @@ -2499,7 +2499,7 @@ s_uadd(mp_digit * da, mp_digit * db, mp_digit * dc, /* {{{ s_usub(da, db, dc, size_a, size_b) */ static void -s_usub(mp_digit * da, mp_digit * db, mp_digit * dc, +s_usub(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b) { mp_size pos; @@ -2512,7 +2512,7 @@ s_usub(mp_digit * da, mp_digit * db, mp_digit * dc, for (pos = 0; pos < size_b; ++pos, ++da, ++db, ++dc) { w = ((mp_word) MP_DIGIT_MAX + 1 + /* MP_RADIX */ - (mp_word) * da) - w - (mp_word) * db; + (mp_word) *da) - w - (mp_word) *db; *dc = LOWER_HALF(w); w = (UPPER_HALF(w) == 0); @@ -2522,7 +2522,7 @@ s_usub(mp_digit * da, mp_digit * db, mp_digit * dc, for ( /* */ ; pos < size_a; ++pos, ++da, ++dc) { w = ((mp_word) MP_DIGIT_MAX + 1 + /* MP_RADIX */ - (mp_word) * da) - w; + (mp_word) *da) - w; *dc = LOWER_HALF(w); w = (UPPER_HALF(w) == 0); @@ -2537,7 +2537,7 @@ s_usub(mp_digit * da, mp_digit * db, mp_digit * dc, /* {{{ s_kmul(da, db, dc, size_a, size_b) */ static int -s_kmul(mp_digit * da, mp_digit * db, mp_digit * dc, +s_kmul(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b) { mp_size bot_size; @@ -2638,7 +2638,7 @@ s_kmul(mp_digit * da, mp_digit * db, mp_digit * dc, /* {{{ s_umul(da, db, dc, size_a, size_b) */ static void -s_umul(mp_digit * da, mp_digit * db, mp_digit * dc, +s_umul(mp_digit *da, mp_digit *db, mp_digit *dc, mp_size size_a, mp_size size_b) { mp_size a, @@ -2656,7 +2656,7 @@ s_umul(mp_digit * da, mp_digit * db, mp_digit * dc, w = 0; for (b = 0; b < size_b; ++b, ++dbt, ++dct) { - w = (mp_word) * da * (mp_word) * dbt + w + (mp_word) * dct; + w = (mp_word) *da * (mp_word) *dbt + w + (mp_word) *dct; *dct = LOWER_HALF(w); w = UPPER_HALF(w); @@ -2671,7 +2671,7 @@ s_umul(mp_digit * da, mp_digit * db, mp_digit * dc, /* {{{ s_ksqr(da, dc, size_a) */ static int -s_ksqr(mp_digit * da, mp_digit * dc, mp_size size_a) +s_ksqr(mp_digit *da, mp_digit *dc, mp_size size_a) { if (multiply_threshold && size_a > multiply_threshold) { @@ -2736,7 +2736,7 @@ s_ksqr(mp_digit * da, mp_digit * dc, mp_size size_a) /* {{{ s_usqr(da, dc, size_a) */ static void -s_usqr(mp_digit * da, mp_digit * dc, mp_size size_a) +s_usqr(mp_digit *da, mp_digit *dc, mp_size size_a) { mp_size i, j; @@ -2751,7 +2751,7 @@ s_usqr(mp_digit * da, mp_digit * dc, mp_size size_a) continue; /* Take care of the first digit, no rollover */ - w = (mp_word) * dat * (mp_word) * dat + (mp_word) * dct; + w = (mp_word) *dat * (mp_word) *dat + (mp_word) *dct; *dct = LOWER_HALF(w); w = UPPER_HALF(w); ++dat; @@ -2759,8 +2759,8 @@ s_usqr(mp_digit * da, mp_digit * dc, mp_size size_a) for (j = i + 1; j < size_a; ++j, ++dat, ++dct) { - mp_word t = (mp_word) * da * (mp_word) * dat; - mp_word u = w + (mp_word) * dct, + mp_word t = (mp_word) *da * (mp_word) *dat; + mp_word u = w + (mp_word) *dct, ov = 0; /* Check if doubling t will overflow a word */ @@ -2808,13 +2808,13 @@ s_dadd(mp_int a, mp_digit b) mp_digit *da = MP_DIGITS(a); mp_size ua = MP_USED(a); - w = (mp_word) * da + b; + w = (mp_word) *da + b; *da++ = LOWER_HALF(w); w = UPPER_HALF(w); for (ua -= 1; ua > 0; --ua, ++da) { - w = (mp_word) * da + w; + w = (mp_word) *da + w; *da = LOWER_HALF(w); w = UPPER_HALF(w); @@ -2840,7 +2840,7 @@ s_dmul(mp_int a, mp_digit b) while (ua > 0) { - w = (mp_word) * da * b + w; + w = (mp_word) *da * b + w; *da++ = LOWER_HALF(w); w = UPPER_HALF(w); --ua; @@ -2858,13 +2858,13 @@ s_dmul(mp_int a, mp_digit b) /* {{{ s_dbmul(da, b, dc, size_a) */ static void -s_dbmul(mp_digit * da, mp_digit b, mp_digit * dc, mp_size size_a) +s_dbmul(mp_digit *da, mp_digit b, mp_digit *dc, mp_size size_a) { mp_word w = 0; while (size_a > 0) { - w = (mp_word) * da++ * (mp_word) b + w; + w = (mp_word) *da++ * (mp_word) b + w; *dc++ = LOWER_HALF(w); w = UPPER_HALF(w); @@ -3085,13 +3085,13 @@ s_qsub(mp_int z, mp_size p2) for (pos = 0, zp = MP_DIGITS(z); pos < tdig; ++pos, ++zp) { - w = ((mp_word) MP_DIGIT_MAX + 1) - w - (mp_word) * zp; + w = ((mp_word) MP_DIGIT_MAX + 1) - w - (mp_word) *zp; *zp = LOWER_HALF(w); w = UPPER_HALF(w) ? 0 : 1; } - w = ((mp_word) MP_DIGIT_MAX + 1 + hi) - w - (mp_word) * zp; + w = ((mp_word) MP_DIGIT_MAX + 1 + hi) - w - (mp_word) *zp; *zp = LOWER_HALF(w); assert(UPPER_HALF(w) != 0); /* no borrow out should be possible */ @@ -3663,7 +3663,7 @@ s_print(char *tag, mp_int z) } void -s_print_buf(char *tag, mp_digit * buf, mp_size num) +s_print_buf(char *tag, mp_digit *buf, mp_size num) { int i; diff --git a/contrib/pgcrypto/imath.h b/contrib/pgcrypto/imath.h index 5bc335e582..09d0e3e818 100644 --- a/contrib/pgcrypto/imath.h +++ b/contrib/pgcrypto/imath.h @@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.h,v 1.6 2007/11/15 21:14:31 momjian Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.h,v 1.7 2009/06/11 14:48:52 momjian Exp $ */ #ifndef IMATH_H_ #define IMATH_H_ @@ -60,7 +60,8 @@ typedef struct mpz mp_size alloc; mp_size used; mp_sign sign; -} mpz_t, *mp_int; +} mpz_t , + *mp_int; #define MP_DIGITS(Z) ((Z)->digits) #define MP_ALLOC(Z) ((Z)->alloc) @@ -117,10 +118,10 @@ mp_result mp_int_mul_pow2(mp_int a, int p2, mp_int c); mp_result mp_int_sqr(mp_int a, mp_int c); /* c = a * a */ mp_result -mp_int_div(mp_int a, mp_int b, /* q = a / b */ +mp_int_div(mp_int a, mp_int b, /* q = a / b */ mp_int q, mp_int r); /* r = a % b */ mp_result -mp_int_div_value(mp_int a, int value, /* q = a / value */ +mp_int_div_value(mp_int a, int value, /* q = a / value */ mp_int q, int *r); /* r = a % value */ mp_result mp_int_div_pow2(mp_int a, int p2, /* q = a / 2^p2 */ @@ -210,7 +211,7 @@ const char *mp_error_string(mp_result res); #if 0 void s_print(char *tag, mp_int z); -void s_print_buf(char *tag, mp_digit * buf, mp_size num); +void s_print_buf(char *tag, mp_digit *buf, mp_size num); #endif #endif /* end IMATH_H_ */ diff --git a/contrib/pgcrypto/internal-sha2.c b/contrib/pgcrypto/internal-sha2.c index d5530c39ed..1e36a369e0 100644 --- a/contrib/pgcrypto/internal-sha2.c +++ b/contrib/pgcrypto/internal-sha2.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/internal-sha2.c,v 1.2 2006/10/04 00:29:46 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/internal-sha2.c,v 1.3 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -36,27 +36,27 @@ #include "px.h" #include "sha2.h" -void init_sha224(PX_MD * h); -void init_sha256(PX_MD * h); -void init_sha384(PX_MD * h); -void init_sha512(PX_MD * h); +void init_sha224(PX_MD *h); +void init_sha256(PX_MD *h); +void init_sha384(PX_MD *h); +void init_sha512(PX_MD *h); /* SHA224 */ static unsigned -int_sha224_len(PX_MD * h) +int_sha224_len(PX_MD *h) { return SHA224_DIGEST_LENGTH; } static unsigned -int_sha224_block_len(PX_MD * h) +int_sha224_block_len(PX_MD *h) { return SHA224_BLOCK_LENGTH; } static void -int_sha224_update(PX_MD * h, const uint8 *data, unsigned dlen) +int_sha224_update(PX_MD *h, const uint8 *data, unsigned dlen) { SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr; @@ -64,7 +64,7 @@ int_sha224_update(PX_MD * h, const uint8 *data, unsigned dlen) } static void -int_sha224_reset(PX_MD * h) +int_sha224_reset(PX_MD *h) { SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr; @@ -72,7 +72,7 @@ int_sha224_reset(PX_MD * h) } static void -int_sha224_finish(PX_MD * h, uint8 *dst) +int_sha224_finish(PX_MD *h, uint8 *dst) { SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr; @@ -80,7 +80,7 @@ int_sha224_finish(PX_MD * h, uint8 *dst) } static void -int_sha224_free(PX_MD * h) +int_sha224_free(PX_MD *h) { SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr; @@ -92,19 +92,19 @@ int_sha224_free(PX_MD * h) /* SHA256 */ static unsigned -int_sha256_len(PX_MD * h) +int_sha256_len(PX_MD *h) { return SHA256_DIGEST_LENGTH; } static unsigned -int_sha256_block_len(PX_MD * h) +int_sha256_block_len(PX_MD *h) { return SHA256_BLOCK_LENGTH; } static void -int_sha256_update(PX_MD * h, const uint8 *data, unsigned dlen) +int_sha256_update(PX_MD *h, const uint8 *data, unsigned dlen) { SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; @@ -112,7 +112,7 @@ int_sha256_update(PX_MD * h, const uint8 *data, unsigned dlen) } static void -int_sha256_reset(PX_MD * h) +int_sha256_reset(PX_MD *h) { SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; @@ -120,7 +120,7 @@ int_sha256_reset(PX_MD * h) } static void -int_sha256_finish(PX_MD * h, uint8 *dst) +int_sha256_finish(PX_MD *h, uint8 *dst) { SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; @@ -128,7 +128,7 @@ int_sha256_finish(PX_MD * h, uint8 *dst) } static void -int_sha256_free(PX_MD * h) +int_sha256_free(PX_MD *h) { SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; @@ -140,19 +140,19 @@ int_sha256_free(PX_MD * h) /* SHA384 */ static unsigned -int_sha384_len(PX_MD * h) +int_sha384_len(PX_MD *h) { return SHA384_DIGEST_LENGTH; } static unsigned -int_sha384_block_len(PX_MD * h) +int_sha384_block_len(PX_MD *h) { return SHA384_BLOCK_LENGTH; } static void -int_sha384_update(PX_MD * h, const uint8 *data, unsigned dlen) +int_sha384_update(PX_MD *h, const uint8 *data, unsigned dlen) { SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; @@ -160,7 +160,7 @@ int_sha384_update(PX_MD * h, const uint8 *data, unsigned dlen) } static void -int_sha384_reset(PX_MD * h) +int_sha384_reset(PX_MD *h) { SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; @@ -168,7 +168,7 @@ int_sha384_reset(PX_MD * h) } static void -int_sha384_finish(PX_MD * h, uint8 *dst) +int_sha384_finish(PX_MD *h, uint8 *dst) { SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; @@ -176,7 +176,7 @@ int_sha384_finish(PX_MD * h, uint8 *dst) } static void -int_sha384_free(PX_MD * h) +int_sha384_free(PX_MD *h) { SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; @@ -188,19 +188,19 @@ int_sha384_free(PX_MD * h) /* SHA512 */ static unsigned -int_sha512_len(PX_MD * h) +int_sha512_len(PX_MD *h) { return SHA512_DIGEST_LENGTH; } static unsigned -int_sha512_block_len(PX_MD * h) +int_sha512_block_len(PX_MD *h) { return SHA512_BLOCK_LENGTH; } static void -int_sha512_update(PX_MD * h, const uint8 *data, unsigned dlen) +int_sha512_update(PX_MD *h, const uint8 *data, unsigned dlen) { SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; @@ -208,7 +208,7 @@ int_sha512_update(PX_MD * h, const uint8 *data, unsigned dlen) } static void -int_sha512_reset(PX_MD * h) +int_sha512_reset(PX_MD *h) { SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; @@ -216,7 +216,7 @@ int_sha512_reset(PX_MD * h) } static void -int_sha512_finish(PX_MD * h, uint8 *dst) +int_sha512_finish(PX_MD *h, uint8 *dst) { SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; @@ -224,7 +224,7 @@ int_sha512_finish(PX_MD * h, uint8 *dst) } static void -int_sha512_free(PX_MD * h) +int_sha512_free(PX_MD *h) { SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; @@ -236,7 +236,7 @@ int_sha512_free(PX_MD * h) /* init functions */ void -init_sha224(PX_MD * md) +init_sha224(PX_MD *md) { SHA224_CTX *ctx; @@ -256,7 +256,7 @@ init_sha224(PX_MD * md) } void -init_sha256(PX_MD * md) +init_sha256(PX_MD *md) { SHA256_CTX *ctx; @@ -276,7 +276,7 @@ init_sha256(PX_MD * md) } void -init_sha384(PX_MD * md) +init_sha384(PX_MD *md) { SHA384_CTX *ctx; @@ -296,7 +296,7 @@ init_sha384(PX_MD * md) } void -init_sha512(PX_MD * md) +init_sha512(PX_MD *md) { SHA512_CTX *ctx; diff --git a/contrib/pgcrypto/internal.c b/contrib/pgcrypto/internal.c index 56634aa32a..84bda624a4 100644 --- a/contrib/pgcrypto/internal.c +++ b/contrib/pgcrypto/internal.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.28 2008/02/17 02:09:26 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.29 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -75,18 +75,18 @@ #define SHA1_BLOCK_SIZE 64 #define MD5_BLOCK_SIZE 64 -static void init_md5(PX_MD * h); -static void init_sha1(PX_MD * h); +static void init_md5(PX_MD *h); +static void init_sha1(PX_MD *h); -void init_sha224(PX_MD * h); -void init_sha256(PX_MD * h); -void init_sha384(PX_MD * h); -void init_sha512(PX_MD * h); +void init_sha224(PX_MD *h); +void init_sha256(PX_MD *h); +void init_sha384(PX_MD *h); +void init_sha512(PX_MD *h); struct int_digest { char *name; - void (*init) (PX_MD * h); + void (*init) (PX_MD *h); }; static const struct int_digest @@ -103,19 +103,19 @@ static const struct int_digest /* MD5 */ static unsigned -int_md5_len(PX_MD * h) +int_md5_len(PX_MD *h) { return MD5_DIGEST_LENGTH; } static unsigned -int_md5_block_len(PX_MD * h) +int_md5_block_len(PX_MD *h) { return MD5_BLOCK_SIZE; } static void -int_md5_update(PX_MD * h, const uint8 *data, unsigned dlen) +int_md5_update(PX_MD *h, const uint8 *data, unsigned dlen) { MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; @@ -123,7 +123,7 @@ int_md5_update(PX_MD * h, const uint8 *data, unsigned dlen) } static void -int_md5_reset(PX_MD * h) +int_md5_reset(PX_MD *h) { MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; @@ -131,7 +131,7 @@ int_md5_reset(PX_MD * h) } static void -int_md5_finish(PX_MD * h, uint8 *dst) +int_md5_finish(PX_MD *h, uint8 *dst) { MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; @@ -139,7 +139,7 @@ int_md5_finish(PX_MD * h, uint8 *dst) } static void -int_md5_free(PX_MD * h) +int_md5_free(PX_MD *h) { MD5_CTX *ctx = (MD5_CTX *) h->p.ptr; @@ -151,19 +151,19 @@ int_md5_free(PX_MD * h) /* SHA1 */ static unsigned -int_sha1_len(PX_MD * h) +int_sha1_len(PX_MD *h) { return SHA1_DIGEST_LENGTH; } static unsigned -int_sha1_block_len(PX_MD * h) +int_sha1_block_len(PX_MD *h) { return SHA1_BLOCK_SIZE; } static void -int_sha1_update(PX_MD * h, const uint8 *data, unsigned dlen) +int_sha1_update(PX_MD *h, const uint8 *data, unsigned dlen) { SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr; @@ -171,7 +171,7 @@ int_sha1_update(PX_MD * h, const uint8 *data, unsigned dlen) } static void -int_sha1_reset(PX_MD * h) +int_sha1_reset(PX_MD *h) { SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr; @@ -179,7 +179,7 @@ int_sha1_reset(PX_MD * h) } static void -int_sha1_finish(PX_MD * h, uint8 *dst) +int_sha1_finish(PX_MD *h, uint8 *dst) { SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr; @@ -187,7 +187,7 @@ int_sha1_finish(PX_MD * h, uint8 *dst) } static void -int_sha1_free(PX_MD * h) +int_sha1_free(PX_MD *h) { SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr; @@ -199,7 +199,7 @@ int_sha1_free(PX_MD * h) /* init functions */ static void -init_md5(PX_MD * md) +init_md5(PX_MD *md) { MD5_CTX *ctx; @@ -219,7 +219,7 @@ init_md5(PX_MD * md) } static void -init_sha1(PX_MD * md) +init_sha1(PX_MD *md) { SHA1_CTX *ctx; @@ -260,7 +260,7 @@ struct int_ctx }; static void -intctx_free(PX_Cipher * c) +intctx_free(PX_Cipher *c) { struct int_ctx *cx = (struct int_ctx *) c->ptr; @@ -280,25 +280,25 @@ intctx_free(PX_Cipher * c) #define MODE_CBC 1 static unsigned -rj_block_size(PX_Cipher * c) +rj_block_size(PX_Cipher *c) { return 128 / 8; } static unsigned -rj_key_size(PX_Cipher * c) +rj_key_size(PX_Cipher *c) { return 256 / 8; } static unsigned -rj_iv_size(PX_Cipher * c) +rj_iv_size(PX_Cipher *c) { return 128 / 8; } static int -rj_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) +rj_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv) { struct int_ctx *cx = (struct int_ctx *) c->ptr; @@ -327,7 +327,7 @@ rj_real_init(struct int_ctx * cx, int dir) } static int -rj_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +rj_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { struct int_ctx *cx = (struct int_ctx *) c->ptr; @@ -357,7 +357,7 @@ rj_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) } static int -rj_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +rj_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { struct int_ctx *cx = (struct int_ctx *) c->ptr; @@ -418,25 +418,25 @@ rj_load(int mode) */ static unsigned -bf_block_size(PX_Cipher * c) +bf_block_size(PX_Cipher *c) { return 8; } static unsigned -bf_key_size(PX_Cipher * c) +bf_key_size(PX_Cipher *c) { return 448 / 8; } static unsigned -bf_iv_size(PX_Cipher * c) +bf_iv_size(PX_Cipher *c) { return 8; } static int -bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) +bf_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv) { struct int_ctx *cx = (struct int_ctx *) c->ptr; @@ -448,7 +448,7 @@ bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) } static int -bf_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +bf_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { struct int_ctx *cx = (struct int_ctx *) c->ptr; BlowfishContext *bfctx = &cx->ctx.bf; @@ -473,7 +473,7 @@ bf_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) } static int -bf_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +bf_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { struct int_ctx *cx = (struct int_ctx *) c->ptr; BlowfishContext *bfctx = &cx->ctx.bf; @@ -577,7 +577,7 @@ static const PX_Alias int_aliases[] = { /* PUBLIC FUNCTIONS */ int -px_find_digest(const char *name, PX_MD ** res) +px_find_digest(const char *name, PX_MD **res) { const struct int_digest *p; PX_MD *h; @@ -596,7 +596,7 @@ px_find_digest(const char *name, PX_MD ** res) } int -px_find_cipher(const char *name, PX_Cipher ** res) +px_find_cipher(const char *name, PX_Cipher **res) { int i; PX_Cipher *c = NULL; diff --git a/contrib/pgcrypto/mbuf.c b/contrib/pgcrypto/mbuf.c index 920e10f6ca..d3eee2ee4f 100644 --- a/contrib/pgcrypto/mbuf.c +++ b/contrib/pgcrypto/mbuf.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.c,v 1.4 2007/07/15 23:57:13 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.c,v 1.5 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -47,25 +47,25 @@ struct MBuf }; int -mbuf_avail(MBuf * mbuf) +mbuf_avail(MBuf *mbuf) { return mbuf->data_end - mbuf->read_pos; } int -mbuf_size(MBuf * mbuf) +mbuf_size(MBuf *mbuf) { return mbuf->data_end - mbuf->data; } int -mbuf_tell(MBuf * mbuf) +mbuf_tell(MBuf *mbuf) { return mbuf->read_pos - mbuf->data; } int -mbuf_free(MBuf * mbuf) +mbuf_free(MBuf *mbuf) { if (mbuf->own_data) { @@ -77,7 +77,7 @@ mbuf_free(MBuf * mbuf) } static void -prepare_room(MBuf * mbuf, int block_len) +prepare_room(MBuf *mbuf, int block_len) { uint8 *newbuf; unsigned newlen; @@ -99,7 +99,7 @@ prepare_room(MBuf * mbuf, int block_len) } int -mbuf_append(MBuf * dst, const uint8 *buf, int len) +mbuf_append(MBuf *dst, const uint8 *buf, int len) { if (dst->no_write) { @@ -154,7 +154,7 @@ mbuf_create_from_data(const uint8 *data, int len) int -mbuf_grab(MBuf * mbuf, int len, uint8 **data_p) +mbuf_grab(MBuf *mbuf, int len, uint8 **data_p) { if (len > mbuf_avail(mbuf)) len = mbuf_avail(mbuf); @@ -167,14 +167,14 @@ mbuf_grab(MBuf * mbuf, int len, uint8 **data_p) } int -mbuf_rewind(MBuf * mbuf) +mbuf_rewind(MBuf *mbuf) { mbuf->read_pos = mbuf->data; return 0; } int -mbuf_steal_data(MBuf * mbuf, uint8 **data_p) +mbuf_steal_data(MBuf *mbuf, uint8 **data_p) { int len = mbuf_size(mbuf); @@ -203,7 +203,7 @@ struct PullFilter }; int -pullf_create(PullFilter ** pf_p, const PullFilterOps * op, void *init_arg, PullFilter * src) +pullf_create(PullFilter **pf_p, const PullFilterOps *op, void *init_arg, PullFilter *src) { PullFilter *pf; void *priv; @@ -242,7 +242,7 @@ pullf_create(PullFilter ** pf_p, const PullFilterOps * op, void *init_arg, PullF } void -pullf_free(PullFilter * pf) +pullf_free(PullFilter *pf) { if (pf->op->free) pf->op->free(pf->priv); @@ -259,7 +259,7 @@ pullf_free(PullFilter * pf) /* may return less data than asked, 0 means eof */ int -pullf_read(PullFilter * pf, int len, uint8 **data_p) +pullf_read(PullFilter *pf, int len, uint8 **data_p) { int res; @@ -276,7 +276,7 @@ pullf_read(PullFilter * pf, int len, uint8 **data_p) } int -pullf_read_max(PullFilter * pf, int len, uint8 **data_p, uint8 *tmpbuf) +pullf_read_max(PullFilter *pf, int len, uint8 **data_p, uint8 *tmpbuf) { int res, total; @@ -313,7 +313,7 @@ pullf_read_max(PullFilter * pf, int len, uint8 **data_p, uint8 *tmpbuf) * caller wants exatly len bytes and dont bother with references */ int -pullf_read_fixed(PullFilter * src, int len, uint8 *dst) +pullf_read_fixed(PullFilter *src, int len, uint8 *dst) { int res; uint8 *p; @@ -335,7 +335,7 @@ pullf_read_fixed(PullFilter * src, int len, uint8 *dst) * read from MBuf */ static int -pull_from_mbuf(void *arg, PullFilter * src, int len, +pull_from_mbuf(void *arg, PullFilter *src, int len, uint8 **data_p, uint8 *buf, int buflen) { MBuf *mbuf = arg; @@ -348,7 +348,7 @@ static const struct PullFilterOps mbuf_reader = { }; int -pullf_create_mbuf_reader(PullFilter ** mp_p, MBuf * src) +pullf_create_mbuf_reader(PullFilter **mp_p, MBuf *src) { return pullf_create(mp_p, &mbuf_reader, src, NULL); } @@ -369,7 +369,7 @@ struct PushFilter }; int -pushf_create(PushFilter ** mp_p, const PushFilterOps * op, void *init_arg, PushFilter * next) +pushf_create(PushFilter **mp_p, const PushFilterOps *op, void *init_arg, PushFilter *next) { PushFilter *mp; void *priv; @@ -408,7 +408,7 @@ pushf_create(PushFilter ** mp_p, const PushFilterOps * op, void *init_arg, PushF } void -pushf_free(PushFilter * mp) +pushf_free(PushFilter *mp) { if (mp->op->free) mp->op->free(mp->priv); @@ -424,7 +424,7 @@ pushf_free(PushFilter * mp) } void -pushf_free_all(PushFilter * mp) +pushf_free_all(PushFilter *mp) { PushFilter *tmp; @@ -437,7 +437,7 @@ pushf_free_all(PushFilter * mp) } static int -wrap_process(PushFilter * mp, const uint8 *data, int len) +wrap_process(PushFilter *mp, const uint8 *data, int len) { int res; @@ -452,7 +452,7 @@ wrap_process(PushFilter * mp, const uint8 *data, int len) /* consumes all data, returns len on success */ int -pushf_write(PushFilter * mp, const uint8 *data, int len) +pushf_write(PushFilter *mp, const uint8 *data, int len) { int need, res; @@ -512,7 +512,7 @@ pushf_write(PushFilter * mp, const uint8 *data, int len) } int -pushf_flush(PushFilter * mp) +pushf_flush(PushFilter *mp) { int res; @@ -542,7 +542,7 @@ pushf_flush(PushFilter * mp) * write to MBuf */ static int -push_into_mbuf(PushFilter * next, void *arg, const uint8 *data, int len) +push_into_mbuf(PushFilter *next, void *arg, const uint8 *data, int len) { int res = 0; MBuf *mbuf = arg; @@ -557,7 +557,7 @@ static const struct PushFilterOps mbuf_filter = { }; int -pushf_create_mbuf_writer(PushFilter ** res, MBuf * dst) +pushf_create_mbuf_writer(PushFilter **res, MBuf *dst) { return pushf_create(res, &mbuf_filter, dst, NULL); } diff --git a/contrib/pgcrypto/mbuf.h b/contrib/pgcrypto/mbuf.h index 91ef821ed4..aa2b5596ee 100644 --- a/contrib/pgcrypto/mbuf.h +++ b/contrib/pgcrypto/mbuf.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.h,v 1.2 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.h,v 1.3 2009/06/11 14:48:52 momjian Exp $ */ #ifndef __PX_MBUF_H @@ -44,15 +44,15 @@ struct PushFilterOps * should return needed buffer size, 0- no buffering, <0 on error if NULL, * no buffering, and priv=init_arg */ - int (*init) (PushFilter * next, void *init_arg, void **priv_p); + int (*init) (PushFilter *next, void *init_arg, void **priv_p); /* * send data to next. should consume all? if null, it will be simply * copied (in-place) returns 0 on error */ - int (*push) (PushFilter * next, void *priv, + int (*push) (PushFilter *next, void *priv, const uint8 *src, int len); - int (*flush) (PushFilter * next, void *priv); + int (*flush) (PushFilter *next, void *priv); void (*free) (void *priv); }; @@ -62,13 +62,13 @@ struct PullFilterOps * should return needed buffer size, 0- no buffering, <0 on error if NULL, * no buffering, and priv=init_arg */ - int (*init) (void **priv_p, void *init_arg, PullFilter * src); + int (*init) (void **priv_p, void *init_arg, PullFilter *src); /* * request data from src, put result ptr to data_p can use ptr from src or * use buf as work area if NULL in-place copy */ - int (*pull) (void *priv, PullFilter * src, int len, + int (*pull) (void *priv, PullFilter *src, int len, uint8 **data_p, uint8 *buf, int buflen); void (*free) (void *priv); }; @@ -78,39 +78,39 @@ struct PullFilterOps */ MBuf *mbuf_create(int len); MBuf *mbuf_create_from_data(const uint8 *data, int len); -int mbuf_tell(MBuf * mbuf); -int mbuf_avail(MBuf * mbuf); -int mbuf_size(MBuf * mbuf); -int mbuf_grab(MBuf * mbuf, int len, uint8 **data_p); -int mbuf_steal_data(MBuf * mbuf, uint8 **data_p); -int mbuf_append(MBuf * dst, const uint8 *buf, int cnt); -int mbuf_rewind(MBuf * mbuf); -int mbuf_free(MBuf * mbuf); +int mbuf_tell(MBuf *mbuf); +int mbuf_avail(MBuf *mbuf); +int mbuf_size(MBuf *mbuf); +int mbuf_grab(MBuf *mbuf, int len, uint8 **data_p); +int mbuf_steal_data(MBuf *mbuf, uint8 **data_p); +int mbuf_append(MBuf *dst, const uint8 *buf, int cnt); +int mbuf_rewind(MBuf *mbuf); +int mbuf_free(MBuf *mbuf); /* * Push filter */ -int pushf_create(PushFilter ** res, const PushFilterOps * ops, void *init_arg, - PushFilter * next); -int pushf_write(PushFilter * mp, const uint8 *data, int len); -void pushf_free_all(PushFilter * mp); -void pushf_free(PushFilter * mp); -int pushf_flush(PushFilter * mp); +int pushf_create(PushFilter **res, const PushFilterOps *ops, void *init_arg, + PushFilter *next); +int pushf_write(PushFilter *mp, const uint8 *data, int len); +void pushf_free_all(PushFilter *mp); +void pushf_free(PushFilter *mp); +int pushf_flush(PushFilter *mp); -int pushf_create_mbuf_writer(PushFilter ** mp_p, MBuf * mbuf); +int pushf_create_mbuf_writer(PushFilter **mp_p, MBuf *mbuf); /* * Pull filter */ -int pullf_create(PullFilter ** res, const PullFilterOps * ops, - void *init_arg, PullFilter * src); -int pullf_read(PullFilter * mp, int len, uint8 **data_p); -int pullf_read_max(PullFilter * mp, int len, +int pullf_create(PullFilter **res, const PullFilterOps *ops, + void *init_arg, PullFilter *src); +int pullf_read(PullFilter *mp, int len, uint8 **data_p); +int pullf_read_max(PullFilter *mp, int len, uint8 **data_p, uint8 *tmpbuf); -void pullf_free(PullFilter * mp); -int pullf_read_fixed(PullFilter * src, int len, uint8 *dst); +void pullf_free(PullFilter *mp); +int pullf_read_fixed(PullFilter *src, int len, uint8 *dst); -int pullf_create_mbuf_reader(PullFilter ** pf_p, MBuf * mbuf); +int pullf_create_mbuf_reader(PullFilter **pf_p, MBuf *mbuf); #define GETBYTE(pf, dst) \ do { \ diff --git a/contrib/pgcrypto/md5.c b/contrib/pgcrypto/md5.c index 851c5c888b..8083d1f280 100644 --- a/contrib/pgcrypto/md5.c +++ b/contrib/pgcrypto/md5.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.14 2007/04/06 05:36:50 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.15 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -136,7 +136,7 @@ static const uint8 md5_paddat[MD5_BUFLEN] = { static void md5_calc(uint8 *, md5_ctxt *); void -md5_init(md5_ctxt * ctxt) +md5_init(md5_ctxt *ctxt) { ctxt->md5_n = 0; ctxt->md5_i = 0; @@ -148,7 +148,7 @@ md5_init(md5_ctxt * ctxt) } void -md5_loop(md5_ctxt * ctxt, const uint8 *input, unsigned len) +md5_loop(md5_ctxt *ctxt, const uint8 *input, unsigned len) { unsigned int gap, i; @@ -175,7 +175,7 @@ md5_loop(md5_ctxt * ctxt, const uint8 *input, unsigned len) } void -md5_pad(md5_ctxt * ctxt) +md5_pad(md5_ctxt *ctxt) { unsigned int gap; @@ -213,7 +213,7 @@ md5_pad(md5_ctxt * ctxt) } void -md5_result(uint8 *digest, md5_ctxt * ctxt) +md5_result(uint8 *digest, md5_ctxt *ctxt) { /* 4 byte words */ #ifndef WORDS_BIGENDIAN @@ -243,7 +243,7 @@ static uint32 X[16]; #endif static void -md5_calc(uint8 *b64, md5_ctxt * ctxt) +md5_calc(uint8 *b64, md5_ctxt *ctxt) { uint32 A = ctxt->md5_sta; uint32 B = ctxt->md5_stb; diff --git a/contrib/pgcrypto/md5.h b/contrib/pgcrypto/md5.h index 933dcaa9b9..eb7c620b48 100644 --- a/contrib/pgcrypto/md5.h +++ b/contrib/pgcrypto/md5.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.h,v 1.9 2005/10/15 02:49:06 momjian Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.h,v 1.10 2009/06/11 14:48:52 momjian Exp $ */ /* $KAME: md5.h,v 1.3 2000/02/22 14:01:18 itojun Exp $ */ /* @@ -59,7 +59,7 @@ typedef struct unsigned int md5_i; uint8 md5_buf[MD5_BUFLEN]; -} md5_ctxt; +} md5_ctxt; extern void md5_init(md5_ctxt *); extern void md5_loop(md5_ctxt *, const uint8 *, unsigned int); diff --git a/contrib/pgcrypto/openssl.c b/contrib/pgcrypto/openssl.c index 0f46580005..bb0b4eefd3 100644 --- a/contrib/pgcrypto/openssl.c +++ b/contrib/pgcrypto/openssl.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.32 2007/11/15 21:14:31 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.33 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -169,10 +169,10 @@ EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *res, unsigned int *len) #include "sha2.c" #include "internal-sha2.c" -typedef void (*init_f) (PX_MD * md); +typedef void (*init_f) (PX_MD *md); static int -compat_find_digest(const char *name, PX_MD ** res) +compat_find_digest(const char *name, PX_MD **res) { init_f init = NULL; @@ -203,10 +203,10 @@ typedef struct OSSLDigest { const EVP_MD *algo; EVP_MD_CTX ctx; -} OSSLDigest; +} OSSLDigest; static unsigned -digest_result_size(PX_MD * h) +digest_result_size(PX_MD *h) { OSSLDigest *digest = (OSSLDigest *) h->p.ptr; @@ -214,7 +214,7 @@ digest_result_size(PX_MD * h) } static unsigned -digest_block_size(PX_MD * h) +digest_block_size(PX_MD *h) { OSSLDigest *digest = (OSSLDigest *) h->p.ptr; @@ -222,7 +222,7 @@ digest_block_size(PX_MD * h) } static void -digest_reset(PX_MD * h) +digest_reset(PX_MD *h) { OSSLDigest *digest = (OSSLDigest *) h->p.ptr; @@ -230,7 +230,7 @@ digest_reset(PX_MD * h) } static void -digest_update(PX_MD * h, const uint8 *data, unsigned dlen) +digest_update(PX_MD *h, const uint8 *data, unsigned dlen) { OSSLDigest *digest = (OSSLDigest *) h->p.ptr; @@ -238,7 +238,7 @@ digest_update(PX_MD * h, const uint8 *data, unsigned dlen) } static void -digest_finish(PX_MD * h, uint8 *dst) +digest_finish(PX_MD *h, uint8 *dst) { OSSLDigest *digest = (OSSLDigest *) h->p.ptr; @@ -246,7 +246,7 @@ digest_finish(PX_MD * h, uint8 *dst) } static void -digest_free(PX_MD * h) +digest_free(PX_MD *h) { OSSLDigest *digest = (OSSLDigest *) h->p.ptr; @@ -261,7 +261,7 @@ static int px_openssl_initialized = 0; /* PUBLIC functions */ int -px_find_digest(const char *name, PX_MD ** res) +px_find_digest(const char *name, PX_MD **res) { const EVP_MD *md; PX_MD *h; @@ -310,9 +310,9 @@ px_find_digest(const char *name, PX_MD ** res) struct ossl_cipher { - int (*init) (PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv); - int (*encrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res); - int (*decrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res); + int (*init) (PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv); + int (*encrypt) (PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res); + int (*decrypt) (PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res); int block_size; int max_key_size; @@ -346,12 +346,12 @@ typedef struct unsigned klen; unsigned init; const struct ossl_cipher *ciph; -} ossldata; +} ossldata; /* generic */ static unsigned -gen_ossl_block_size(PX_Cipher * c) +gen_ossl_block_size(PX_Cipher *c) { ossldata *od = (ossldata *) c->ptr; @@ -359,7 +359,7 @@ gen_ossl_block_size(PX_Cipher * c) } static unsigned -gen_ossl_key_size(PX_Cipher * c) +gen_ossl_key_size(PX_Cipher *c) { ossldata *od = (ossldata *) c->ptr; @@ -367,7 +367,7 @@ gen_ossl_key_size(PX_Cipher * c) } static unsigned -gen_ossl_iv_size(PX_Cipher * c) +gen_ossl_iv_size(PX_Cipher *c) { unsigned ivlen; ossldata *od = (ossldata *) c->ptr; @@ -377,7 +377,7 @@ gen_ossl_iv_size(PX_Cipher * c) } static void -gen_ossl_free(PX_Cipher * c) +gen_ossl_free(PX_Cipher *c) { ossldata *od = (ossldata *) c->ptr; @@ -422,7 +422,7 @@ bf_check_supported_key_len(void) } static int -bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) +bf_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv) { ossldata *od = c->ptr; static int bf_is_strong = -1; @@ -450,7 +450,7 @@ bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) } static int -bf_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +bf_ecb_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); unsigned i; @@ -462,7 +462,7 @@ bf_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) } static int -bf_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +bf_ecb_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c), i; @@ -474,7 +474,7 @@ bf_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) } static int -bf_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +bf_cbc_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -483,7 +483,7 @@ bf_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) } static int -bf_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +bf_cbc_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -492,7 +492,7 @@ bf_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) } static int -bf_cfb64_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +bf_cfb64_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -502,7 +502,7 @@ bf_cfb64_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) } static int -bf_cfb64_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +bf_cfb64_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -514,7 +514,7 @@ bf_cfb64_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) /* DES */ static int -ossl_des_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) +ossl_des_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv) { ossldata *od = c->ptr; DES_cblock xkey; @@ -532,7 +532,7 @@ ossl_des_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) } static int -ossl_des_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_des_ecb_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); @@ -547,7 +547,7 @@ ossl_des_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_des_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_des_ecb_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); @@ -562,7 +562,7 @@ ossl_des_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_des_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_des_cbc_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -573,7 +573,7 @@ ossl_des_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_des_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_des_cbc_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -586,7 +586,7 @@ ossl_des_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, /* DES3 */ static int -ossl_des3_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) +ossl_des3_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv) { ossldata *od = c->ptr; DES_cblock xkey1, @@ -617,7 +617,7 @@ ossl_des3_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) } static int -ossl_des3_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_des3_ecb_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); @@ -631,7 +631,7 @@ ossl_des3_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_des3_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_des3_ecb_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); @@ -645,7 +645,7 @@ ossl_des3_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_des3_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_des3_cbc_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -657,7 +657,7 @@ ossl_des3_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_des3_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_des3_cbc_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -671,7 +671,7 @@ ossl_des3_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, /* CAST5 */ static int -ossl_cast_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) +ossl_cast_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv) { ossldata *od = c->ptr; unsigned bs = gen_ossl_block_size(c); @@ -685,7 +685,7 @@ ossl_cast_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) } static int -ossl_cast_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +ossl_cast_ecb_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); ossldata *od = c->ptr; @@ -697,7 +697,7 @@ ossl_cast_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *re } static int -ossl_cast_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +ossl_cast_ecb_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); ossldata *od = c->ptr; @@ -709,7 +709,7 @@ ossl_cast_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *re } static int -ossl_cast_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +ossl_cast_cbc_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -718,7 +718,7 @@ ossl_cast_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *re } static int -ossl_cast_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res) +ossl_cast_cbc_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -729,7 +729,7 @@ ossl_cast_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *re /* AES */ static int -ossl_aes_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) +ossl_aes_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv) { ossldata *od = c->ptr; unsigned bs = gen_ossl_block_size(c); @@ -753,7 +753,7 @@ ossl_aes_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) } static int -ossl_aes_key_init(ossldata * od, int type) +ossl_aes_key_init(ossldata *od, int type) { int err; @@ -776,7 +776,7 @@ ossl_aes_key_init(ossldata * od, int type) } static int -ossl_aes_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_aes_ecb_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); @@ -794,7 +794,7 @@ ossl_aes_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_aes_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_aes_ecb_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { unsigned bs = gen_ossl_block_size(c); @@ -812,7 +812,7 @@ ossl_aes_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_aes_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_aes_cbc_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -827,7 +827,7 @@ ossl_aes_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, } static int -ossl_aes_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, +ossl_aes_cbc_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res) { ossldata *od = c->ptr; @@ -945,7 +945,7 @@ static const struct ossl_cipher_lookup ossl_cipher_types[] = { /* PUBLIC functions */ int -px_find_cipher(const char *name, PX_Cipher ** res) +px_find_cipher(const char *name, PX_Cipher **res) { const struct ossl_cipher_lookup *i; PX_Cipher *c = NULL; diff --git a/contrib/pgcrypto/pgp-cfb.c b/contrib/pgcrypto/pgp-cfb.c index 811bb7c2c3..bd05ccc94e 100644 --- a/contrib/pgcrypto/pgp-cfb.c +++ b/contrib/pgcrypto/pgp-cfb.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.3 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.4 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -35,7 +35,7 @@ #include "px.h" #include "pgp.h" -typedef int (*mix_data_t) (PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst); +typedef int (*mix_data_t) (PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst); struct PGP_CFB { @@ -50,7 +50,7 @@ struct PGP_CFB }; int -pgp_cfb_create(PGP_CFB ** ctx_p, int algo, const uint8 *key, int key_len, +pgp_cfb_create(PGP_CFB **ctx_p, int algo, const uint8 *key, int key_len, int resync, uint8 *iv) { int res; @@ -82,7 +82,7 @@ pgp_cfb_create(PGP_CFB ** ctx_p, int algo, const uint8 *key, int key_len, } void -pgp_cfb_free(PGP_CFB * ctx) +pgp_cfb_free(PGP_CFB *ctx) { px_cipher_free(ctx->ciph); memset(ctx, 0, sizeof(*ctx)); @@ -93,7 +93,7 @@ pgp_cfb_free(PGP_CFB * ctx) * Data processing for normal CFB. (PGP_PKT_SYMENCRYPTED_DATA_MDC) */ static int -mix_encrypt_normal(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) +mix_encrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) { int i; @@ -104,7 +104,7 @@ mix_encrypt_normal(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) } static int -mix_decrypt_normal(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) +mix_decrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) { int i; @@ -124,7 +124,7 @@ mix_decrypt_normal(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) * thus its all concentrated here. */ static int -mix_encrypt_resync(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) +mix_encrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) { int i, n; @@ -156,7 +156,7 @@ mix_encrypt_resync(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) } static int -mix_decrypt_resync(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) +mix_decrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) { int i, n; @@ -196,7 +196,7 @@ mix_decrypt_resync(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) * common code for both encrypt and decrypt. */ static int -cfb_process(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst, +cfb_process(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst, mix_data_t mix_data) { int n; @@ -249,7 +249,7 @@ cfb_process(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst, */ int -pgp_cfb_encrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) +pgp_cfb_encrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) { mix_data_t mix = ctx->resync ? mix_encrypt_resync : mix_encrypt_normal; @@ -257,7 +257,7 @@ pgp_cfb_encrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) } int -pgp_cfb_decrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) +pgp_cfb_decrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) { mix_data_t mix = ctx->resync ? mix_decrypt_resync : mix_decrypt_normal; diff --git a/contrib/pgcrypto/pgp-compress.c b/contrib/pgcrypto/pgp-compress.c index 9d2f61ed8e..41f5855247 100644 --- a/contrib/pgcrypto/pgp-compress.c +++ b/contrib/pgcrypto/pgp-compress.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.7 2007/11/15 21:14:31 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.8 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -69,7 +69,7 @@ z_free(void *priv, void *addr) } static int -compress_init(PushFilter * next, void *init_arg, void **priv_p) +compress_init(PushFilter *next, void *init_arg, void **priv_p) { int res; struct ZipStat *st; @@ -107,7 +107,7 @@ compress_init(PushFilter * next, void *init_arg, void **priv_p) /* cant handle zero-len incoming data, but shouldnt */ static int -compress_process(PushFilter * next, void *priv, const uint8 *data, int len) +compress_process(PushFilter *next, void *priv, const uint8 *data, int len) { int res, n_out; @@ -140,7 +140,7 @@ compress_process(PushFilter * next, void *priv, const uint8 *data, int len) } static int -compress_flush(PushFilter * next, void *priv) +compress_flush(PushFilter *next, void *priv) { int res, zres, @@ -185,7 +185,7 @@ static const PushFilterOps }; int -pgp_compress_filter(PushFilter ** res, PGP_Context * ctx, PushFilter * dst) +pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst) { return pushf_create(res, &compress_filter, ctx, dst); } @@ -204,7 +204,7 @@ struct DecomprData }; static int -decompress_init(void **priv_p, void *arg, PullFilter * src) +decompress_init(void **priv_p, void *arg, PullFilter *src) { PGP_Context *ctx = arg; struct DecomprData *dec; @@ -237,7 +237,7 @@ decompress_init(void **priv_p, void *arg, PullFilter * src) } static int -decompress_read(void *priv, PullFilter * src, int len, +decompress_read(void *priv, PullFilter *src, int len, uint8 **data_p, uint8 *buf, int buflen) { int res; @@ -308,20 +308,20 @@ static const PullFilterOps }; int -pgp_decompress_filter(PullFilter ** res, PGP_Context * ctx, PullFilter * src) +pgp_decompress_filter(PullFilter **res, PGP_Context *ctx, PullFilter *src) { return pullf_create(res, &decompress_filter, ctx, src); } #else /* !HAVE_ZLIB */ int -pgp_compress_filter(PushFilter ** res, PGP_Context * ctx, PushFilter * dst) +pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst) { return PXE_PGP_UNSUPPORTED_COMPR; } int -pgp_decompress_filter(PullFilter ** res, PGP_Context * ctx, PullFilter * src) +pgp_decompress_filter(PullFilter **res, PGP_Context *ctx, PullFilter *src) { return PXE_PGP_UNSUPPORTED_COMPR; } diff --git a/contrib/pgcrypto/pgp-decrypt.c b/contrib/pgcrypto/pgp-decrypt.c index 77973a5c31..9df5c717f2 100644 --- a/contrib/pgcrypto/pgp-decrypt.c +++ b/contrib/pgcrypto/pgp-decrypt.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.7 2005/11/22 18:17:04 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.8 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -49,7 +49,7 @@ #define MAX_CHUNK (16*1024*1024) static int -parse_new_len(PullFilter * src, int *len_p) +parse_new_len(PullFilter *src, int *len_p) { uint8 b; int len; @@ -92,7 +92,7 @@ parse_new_len(PullFilter * src, int *len_p) } static int -parse_old_len(PullFilter * src, int *len_p, int lentype) +parse_old_len(PullFilter *src, int *len_p, int lentype) { uint8 b; int len; @@ -126,7 +126,7 @@ parse_old_len(PullFilter * src, int *len_p, int lentype) /* returns pkttype or 0 on eof */ int -pgp_parse_pkt_hdr(PullFilter * src, uint8 *tag, int *len_p, int allow_ctx) +pgp_parse_pkt_hdr(PullFilter *src, uint8 *tag, int *len_p, int allow_ctx) { int lentype; int res; @@ -172,7 +172,7 @@ struct PktData }; static int -pktreader_pull(void *priv, PullFilter * src, int len, +pktreader_pull(void *priv, PullFilter *src, int len, uint8 **data_p, uint8 *buf, int buflen) { int res; @@ -220,8 +220,8 @@ static struct PullFilterOps pktreader_filter = { /* needs helper function to pass several parameters */ int -pgp_create_pkt_reader(PullFilter ** pf_p, PullFilter * src, int len, - int pkttype, PGP_Context * ctx) +pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len, + int pkttype, PGP_Context *ctx) { int res; struct PktData *pkt = px_alloc(sizeof(*pkt)); @@ -239,7 +239,7 @@ pgp_create_pkt_reader(PullFilter ** pf_p, PullFilter * src, int len, */ static int -prefix_init(void **priv_p, void *arg, PullFilter * src) +prefix_init(void **priv_p, void *arg, PullFilter *src) { PGP_Context *ctx = arg; int len; @@ -294,7 +294,7 @@ static struct PullFilterOps prefix_filter = { */ static int -decrypt_init(void **priv_p, void *arg, PullFilter * src) +decrypt_init(void **priv_p, void *arg, PullFilter *src) { PGP_CFB *cfb = arg; @@ -305,7 +305,7 @@ decrypt_init(void **priv_p, void *arg, PullFilter * src) } static int -decrypt_read(void *priv, PullFilter * src, int len, +decrypt_read(void *priv, PullFilter *src, int len, uint8 **data_p, uint8 *buf, int buflen) { PGP_CFB *cfb = priv; @@ -331,7 +331,7 @@ struct PullFilterOps pgp_decrypt_filter = { */ static int -mdc_init(void **priv_p, void *arg, PullFilter * src) +mdc_init(void **priv_p, void *arg, PullFilter *src) { PGP_Context *ctx = arg; @@ -351,7 +351,7 @@ mdc_free(void *priv) } static int -mdc_finish(PGP_Context * ctx, PullFilter * src, +mdc_finish(PGP_Context *ctx, PullFilter *src, int len, uint8 **data_p) { int res; @@ -407,7 +407,7 @@ mdc_finish(PGP_Context * ctx, PullFilter * src, } static int -mdc_read(void *priv, PullFilter * src, int len, +mdc_read(void *priv, PullFilter *src, int len, uint8 **data_p, uint8 *buf, int buflen) { int res; @@ -460,7 +460,7 @@ struct MDCBufData }; static int -mdcbuf_init(void **priv_p, void *arg, PullFilter * src) +mdcbuf_init(void **priv_p, void *arg, PullFilter *src) { PGP_Context *ctx = arg; struct MDCBufData *st; @@ -520,7 +520,7 @@ mdcbuf_load_mdc(struct MDCBufData * st, uint8 *src, int len) } static int -mdcbuf_refill(struct MDCBufData * st, PullFilter * src) +mdcbuf_refill(struct MDCBufData * st, PullFilter *src) { uint8 *data; int res; @@ -564,7 +564,7 @@ mdcbuf_refill(struct MDCBufData * st, PullFilter * src) } static int -mdcbuf_read(void *priv, PullFilter * src, int len, +mdcbuf_read(void *priv, PullFilter *src, int len, uint8 **data_p, uint8 *buf, int buflen) { struct MDCBufData *st = priv; @@ -606,7 +606,7 @@ static struct PullFilterOps mdcbuf_filter = { * Decrypt separate session key */ static int -decrypt_key(PGP_Context * ctx, const uint8 *src, int len) +decrypt_key(PGP_Context *ctx, const uint8 *src, int len) { int res; uint8 algo; @@ -639,7 +639,7 @@ decrypt_key(PGP_Context * ctx, const uint8 *src, int len) * Handle key packet */ static int -parse_symenc_sesskey(PGP_Context * ctx, PullFilter * src) +parse_symenc_sesskey(PGP_Context *ctx, PullFilter *src) { uint8 *p; int res; @@ -708,7 +708,7 @@ parse_symenc_sesskey(PGP_Context * ctx, PullFilter * src) } static int -copy_crlf(MBuf * dst, uint8 *data, int len, int *got_cr) +copy_crlf(MBuf *dst, uint8 *data, int len, int *got_cr) { uint8 *data_end = data + len; uint8 tmpbuf[1024]; @@ -757,7 +757,7 @@ copy_crlf(MBuf * dst, uint8 *data, int len, int *got_cr) } static int -parse_literal_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) +parse_literal_data(PGP_Context *ctx, MBuf *dst, PullFilter *pkt) { int type; int name_len; @@ -824,11 +824,11 @@ parse_literal_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) } /* process_data_packets and parse_compressed_data call each other */ -static int process_data_packets(PGP_Context * ctx, MBuf * dst, - PullFilter * src, int allow_compr, int need_mdc); +static int process_data_packets(PGP_Context *ctx, MBuf *dst, + PullFilter *src, int allow_compr, int need_mdc); static int -parse_compressed_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) +parse_compressed_data(PGP_Context *ctx, MBuf *dst, PullFilter *pkt) { int res; uint8 type; @@ -868,7 +868,7 @@ parse_compressed_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) } static int -process_data_packets(PGP_Context * ctx, MBuf * dst, PullFilter * src, +process_data_packets(PGP_Context *ctx, MBuf *dst, PullFilter *src, int allow_compr, int need_mdc) { uint8 tag; @@ -975,7 +975,7 @@ process_data_packets(PGP_Context * ctx, MBuf * dst, PullFilter * src, } static int -parse_symenc_data(PGP_Context * ctx, PullFilter * pkt, MBuf * dst) +parse_symenc_data(PGP_Context *ctx, PullFilter *pkt, MBuf *dst) { int res; PGP_CFB *cfb = NULL; @@ -1009,7 +1009,7 @@ out: } static int -parse_symenc_mdc_data(PGP_Context * ctx, PullFilter * pkt, MBuf * dst) +parse_symenc_mdc_data(PGP_Context *ctx, PullFilter *pkt, MBuf *dst) { int res; PGP_CFB *cfb = NULL; @@ -1061,7 +1061,7 @@ out: * skip over packet contents */ int -pgp_skip_packet(PullFilter * pkt) +pgp_skip_packet(PullFilter *pkt) { int res = 1; uint8 *tmp; @@ -1075,7 +1075,7 @@ pgp_skip_packet(PullFilter * pkt) * expect to be at packet end, any data is error */ int -pgp_expect_packet_end(PullFilter * pkt) +pgp_expect_packet_end(PullFilter *pkt) { int res = 1; uint8 *tmp; @@ -1093,7 +1093,7 @@ pgp_expect_packet_end(PullFilter * pkt) } int -pgp_decrypt(PGP_Context * ctx, MBuf * msrc, MBuf * mdst) +pgp_decrypt(PGP_Context *ctx, MBuf *msrc, MBuf *mdst) { int res; PullFilter *src = NULL; diff --git a/contrib/pgcrypto/pgp-encrypt.c b/contrib/pgcrypto/pgp-encrypt.c index e2c928154b..48f2f01f62 100644 --- a/contrib/pgcrypto/pgp-encrypt.c +++ b/contrib/pgcrypto/pgp-encrypt.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-encrypt.c,v 1.3 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-encrypt.c,v 1.4 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -66,7 +66,7 @@ render_newlen(uint8 *h, int len) } static int -write_tag_only(PushFilter * dst, int tag) +write_tag_only(PushFilter *dst, int tag) { uint8 hdr = 0xC0 | tag; @@ -74,7 +74,7 @@ write_tag_only(PushFilter * dst, int tag) } static int -write_normal_header(PushFilter * dst, int tag, int len) +write_normal_header(PushFilter *dst, int tag, int len) { uint8 hdr[8]; uint8 *h = hdr; @@ -90,7 +90,7 @@ write_normal_header(PushFilter * dst, int tag, int len) */ static int -mdc_init(PushFilter * dst, void *init_arg, void **priv_p) +mdc_init(PushFilter *dst, void *init_arg, void **priv_p) { int res; PX_MD *md; @@ -104,7 +104,7 @@ mdc_init(PushFilter * dst, void *init_arg, void **priv_p) } static int -mdc_write(PushFilter * dst, void *priv, const uint8 *data, int len) +mdc_write(PushFilter *dst, void *priv, const uint8 *data, int len) { PX_MD *md = priv; @@ -113,7 +113,7 @@ mdc_write(PushFilter * dst, void *priv, const uint8 *data, int len) } static int -mdc_flush(PushFilter * dst, void *priv) +mdc_flush(PushFilter *dst, void *priv) { int res; uint8 pkt[2 + MDC_DIGEST_LEN]; @@ -156,7 +156,7 @@ struct EncStat }; static int -encrypt_init(PushFilter * next, void *init_arg, void **priv_p) +encrypt_init(PushFilter *next, void *init_arg, void **priv_p) { struct EncStat *st; PGP_Context *ctx = init_arg; @@ -188,7 +188,7 @@ encrypt_init(PushFilter * next, void *init_arg, void **priv_p) } static int -encrypt_process(PushFilter * next, void *priv, const uint8 *data, int len) +encrypt_process(PushFilter *next, void *priv, const uint8 *data, int len) { int res; struct EncStat *st = priv; @@ -236,7 +236,7 @@ struct PktStreamStat }; static int -pkt_stream_init(PushFilter * next, void *init_arg, void **priv_p) +pkt_stream_init(PushFilter *next, void *init_arg, void **priv_p) { struct PktStreamStat *st; @@ -249,7 +249,7 @@ pkt_stream_init(PushFilter * next, void *init_arg, void **priv_p) } static int -pkt_stream_process(PushFilter * next, void *priv, const uint8 *data, int len) +pkt_stream_process(PushFilter *next, void *priv, const uint8 *data, int len) { int res; uint8 hdr[8]; @@ -275,7 +275,7 @@ pkt_stream_process(PushFilter * next, void *priv, const uint8 *data, int len) } static int -pkt_stream_flush(PushFilter * next, void *priv) +pkt_stream_flush(PushFilter *next, void *priv) { int res; uint8 hdr[8]; @@ -308,7 +308,7 @@ static const PushFilterOps pkt_stream_filter = { }; int -pgp_create_pkt_writer(PushFilter * dst, int tag, PushFilter ** res_p) +pgp_create_pkt_writer(PushFilter *dst, int tag, PushFilter **res_p) { int res; @@ -324,7 +324,7 @@ pgp_create_pkt_writer(PushFilter * dst, int tag, PushFilter ** res_p) */ static int -crlf_process(PushFilter * dst, void *priv, const uint8 *data, int len) +crlf_process(PushFilter *dst, void *priv, const uint8 *data, int len) { const uint8 *data_end = data + len; const uint8 *p2, @@ -371,7 +371,7 @@ static const PushFilterOps crlf_filter = { * Initialize literal data packet */ static int -init_litdata_packet(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) +init_litdata_packet(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) { int res; int hdrlen; @@ -426,7 +426,7 @@ init_litdata_packet(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) * Initialize compression filter */ static int -init_compress(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) +init_compress(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) { int res; uint8 type = ctx->compress_algo; @@ -454,7 +454,7 @@ init_compress(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) * Initialize encdata packet */ static int -init_encdata_packet(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) +init_encdata_packet(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) { int res; int tag; @@ -475,7 +475,7 @@ init_encdata_packet(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) * write prefix */ static int -write_prefix(PGP_Context * ctx, PushFilter * dst) +write_prefix(PGP_Context *ctx, PushFilter *dst) { uint8 prefix[PGP_MAX_BLOCK + 2]; int res, @@ -499,7 +499,7 @@ write_prefix(PGP_Context * ctx, PushFilter * dst) */ static int -symencrypt_sesskey(PGP_Context * ctx, uint8 *dst) +symencrypt_sesskey(PGP_Context *ctx, uint8 *dst) { int res; PGP_CFB *cfb; @@ -519,7 +519,7 @@ symencrypt_sesskey(PGP_Context * ctx, uint8 *dst) /* 5.3: Symmetric-Key Encrypted Session-Key */ static int -write_symenc_sesskey(PGP_Context * ctx, PushFilter * dst) +write_symenc_sesskey(PGP_Context *ctx, PushFilter *dst) { uint8 pkt[256]; int pktlen; @@ -560,7 +560,7 @@ write_symenc_sesskey(PGP_Context * ctx, PushFilter * dst) * key setup */ static int -init_s2k_key(PGP_Context * ctx) +init_s2k_key(PGP_Context *ctx) { int res; @@ -576,7 +576,7 @@ init_s2k_key(PGP_Context * ctx) } static int -init_sess_key(PGP_Context * ctx) +init_sess_key(PGP_Context *ctx) { int res; @@ -600,7 +600,7 @@ init_sess_key(PGP_Context * ctx) * combine */ int -pgp_encrypt(PGP_Context * ctx, MBuf * src, MBuf * dst) +pgp_encrypt(PGP_Context *ctx, MBuf *src, MBuf *dst) { int res; int len; diff --git a/contrib/pgcrypto/pgp-info.c b/contrib/pgcrypto/pgp-info.c index 9f887ec6d9..a51a553236 100644 --- a/contrib/pgcrypto/pgp-info.c +++ b/contrib/pgcrypto/pgp-info.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-info.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-info.c,v 1.5 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -35,7 +35,7 @@ #include "pgp.h" static int -read_pubkey_keyid(PullFilter * pkt, uint8 *keyid_buf) +read_pubkey_keyid(PullFilter *pkt, uint8 *keyid_buf) { int res; PGP_PubKey *pk = NULL; @@ -68,7 +68,7 @@ err: } static int -read_pubenc_keyid(PullFilter * pkt, uint8 *keyid_buf) +read_pubenc_keyid(PullFilter *pkt, uint8 *keyid_buf) { uint8 ver; int res; @@ -109,7 +109,7 @@ static const uint8 any_key[] = * dst should have room for 17 bytes */ int -pgp_get_keyid(MBuf * pgp_data, char *dst) +pgp_get_keyid(MBuf *pgp_data, char *dst) { int res; PullFilter *src; diff --git a/contrib/pgcrypto/pgp-mpi-internal.c b/contrib/pgcrypto/pgp-mpi-internal.c index d2b5d0c8de..283946b17d 100644 --- a/contrib/pgcrypto/pgp-mpi-internal.c +++ b/contrib/pgcrypto/pgp-mpi-internal.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.7 2006/10/04 00:29:46 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.8 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -46,7 +46,7 @@ mp_new() } static void -mp_clear_free(mpz_t * a) +mp_clear_free(mpz_t *a) { if (!a) return; @@ -56,7 +56,7 @@ mp_clear_free(mpz_t * a) static int -mp_px_rand(uint32 bits, mpz_t * res) +mp_px_rand(uint32 bits, mpz_t *res) { int err; unsigned bytes = (bits + 7) / 8; @@ -88,7 +88,7 @@ mp_px_rand(uint32 bits, mpz_t * res) } static void -mp_modmul(mpz_t * a, mpz_t * b, mpz_t * p, mpz_t * res) +mp_modmul(mpz_t *a, mpz_t *b, mpz_t *p, mpz_t *res) { mpz_t *tmp = mp_new(); @@ -98,7 +98,7 @@ mp_modmul(mpz_t * a, mpz_t * b, mpz_t * p, mpz_t * res) } static mpz_t * -mpi_to_bn(PGP_MPI * n) +mpi_to_bn(PGP_MPI *n) { mpz_t *bn = mp_new(); @@ -117,7 +117,7 @@ mpi_to_bn(PGP_MPI * n) } static PGP_MPI * -bn_to_mpi(mpz_t * bn) +bn_to_mpi(mpz_t *bn) { int res; PGP_MPI *n; @@ -164,8 +164,8 @@ decide_k_bits(int p_bits) } int -pgp_elgamal_encrypt(PGP_PubKey * pk, PGP_MPI * _m, - PGP_MPI ** c1_p, PGP_MPI ** c2_p) +pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *_m, + PGP_MPI **c1_p, PGP_MPI **c2_p) { int res = PXE_PGP_MATH_FAILED; int k_bits; @@ -214,8 +214,8 @@ err: } int -pgp_elgamal_decrypt(PGP_PubKey * pk, PGP_MPI * _c1, PGP_MPI * _c2, - PGP_MPI ** msg_p) +pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *_c1, PGP_MPI *_c2, + PGP_MPI **msg_p) { int res = PXE_PGP_MATH_FAILED; mpz_t *c1 = mpi_to_bn(_c1); @@ -252,7 +252,7 @@ err: } int -pgp_rsa_encrypt(PGP_PubKey * pk, PGP_MPI * _m, PGP_MPI ** c_p) +pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *_m, PGP_MPI **c_p) { int res = PXE_PGP_MATH_FAILED; mpz_t *m = mpi_to_bn(_m); @@ -280,7 +280,7 @@ err: } int -pgp_rsa_decrypt(PGP_PubKey * pk, PGP_MPI * _c, PGP_MPI ** m_p) +pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *_c, PGP_MPI **m_p) { int res = PXE_PGP_MATH_FAILED; mpz_t *c = mpi_to_bn(_c); diff --git a/contrib/pgcrypto/pgp-mpi-openssl.c b/contrib/pgcrypto/pgp-mpi-openssl.c index 0e692e35d2..f2b25de090 100644 --- a/contrib/pgcrypto/pgp-mpi-openssl.c +++ b/contrib/pgcrypto/pgp-mpi-openssl.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-openssl.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-openssl.c,v 1.5 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -37,7 +37,7 @@ #include "pgp.h" static BIGNUM * -mpi_to_bn(PGP_MPI * n) +mpi_to_bn(PGP_MPI *n) { BIGNUM *bn = BN_bin2bn(n->data, n->bytes, NULL); @@ -99,8 +99,8 @@ decide_k_bits(int p_bits) } int -pgp_elgamal_encrypt(PGP_PubKey * pk, PGP_MPI * _m, - PGP_MPI ** c1_p, PGP_MPI ** c2_p) +pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *_m, + PGP_MPI **c1_p, PGP_MPI **c2_p) { int res = PXE_PGP_MATH_FAILED; int k_bits; @@ -162,8 +162,8 @@ err: } int -pgp_elgamal_decrypt(PGP_PubKey * pk, PGP_MPI * _c1, PGP_MPI * _c2, - PGP_MPI ** msg_p) +pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *_c1, PGP_MPI *_c2, + PGP_MPI **msg_p) { int res = PXE_PGP_MATH_FAILED; BIGNUM *c1 = mpi_to_bn(_c1); @@ -213,7 +213,7 @@ err: } int -pgp_rsa_encrypt(PGP_PubKey * pk, PGP_MPI * _m, PGP_MPI ** c_p) +pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *_m, PGP_MPI **c_p) { int res = PXE_PGP_MATH_FAILED; BIGNUM *m = mpi_to_bn(_m); @@ -249,7 +249,7 @@ err: } int -pgp_rsa_decrypt(PGP_PubKey * pk, PGP_MPI * _c, PGP_MPI ** m_p) +pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *_c, PGP_MPI **m_p) { int res = PXE_PGP_MATH_FAILED; BIGNUM *c = mpi_to_bn(_c); diff --git a/contrib/pgcrypto/pgp-mpi.c b/contrib/pgcrypto/pgp-mpi.c index da0edb1361..3f2ec0f5c7 100644 --- a/contrib/pgcrypto/pgp-mpi.c +++ b/contrib/pgcrypto/pgp-mpi.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi.c,v 1.5 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -35,7 +35,7 @@ #include "pgp.h" int -pgp_mpi_alloc(int bits, PGP_MPI ** mpi) +pgp_mpi_alloc(int bits, PGP_MPI **mpi) { PGP_MPI *n; int len = (bits + 7) / 8; @@ -54,7 +54,7 @@ pgp_mpi_alloc(int bits, PGP_MPI ** mpi) } int -pgp_mpi_create(uint8 *data, int bits, PGP_MPI ** mpi) +pgp_mpi_create(uint8 *data, int bits, PGP_MPI **mpi) { int res; PGP_MPI *n; @@ -68,7 +68,7 @@ pgp_mpi_create(uint8 *data, int bits, PGP_MPI ** mpi) } int -pgp_mpi_free(PGP_MPI * mpi) +pgp_mpi_free(PGP_MPI *mpi) { if (mpi == NULL) return 0; @@ -78,7 +78,7 @@ pgp_mpi_free(PGP_MPI * mpi) } int -pgp_mpi_read(PullFilter * src, PGP_MPI ** mpi) +pgp_mpi_read(PullFilter *src, PGP_MPI **mpi) { int res; uint8 hdr[2]; @@ -103,7 +103,7 @@ pgp_mpi_read(PullFilter * src, PGP_MPI ** mpi) } int -pgp_mpi_write(PushFilter * dst, PGP_MPI * n) +pgp_mpi_write(PushFilter *dst, PGP_MPI *n) { int res; uint8 buf[2]; @@ -117,7 +117,7 @@ pgp_mpi_write(PushFilter * dst, PGP_MPI * n) } int -pgp_mpi_hash(PX_MD * md, PGP_MPI * n) +pgp_mpi_hash(PX_MD *md, PGP_MPI *n) { uint8 buf[2]; @@ -130,7 +130,7 @@ pgp_mpi_hash(PX_MD * md, PGP_MPI * n) } unsigned -pgp_mpi_cksum(unsigned cksum, PGP_MPI * n) +pgp_mpi_cksum(unsigned cksum, PGP_MPI *n) { int i; diff --git a/contrib/pgcrypto/pgp-pgsql.c b/contrib/pgcrypto/pgp-pgsql.c index 5ffa5ad0a9..530a3d38d8 100644 --- a/contrib/pgcrypto/pgp-pgsql.c +++ b/contrib/pgcrypto/pgp-pgsql.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.10 2008/05/04 16:42:41 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.11 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -79,7 +79,7 @@ PG_FUNCTION_INFO_V1(pg_dearmor); * Mix a block of data into RNG. */ static void -add_block_entropy(PX_MD * md, text *data) +add_block_entropy(PX_MD *md, text *data) { uint8 sha1[20]; @@ -215,7 +215,7 @@ fill_expect(struct debug_expect * ex, int text_mode) } while (0) static void -check_expect(PGP_Context * ctx, struct debug_expect * ex) +check_expect(PGP_Context *ctx, struct debug_expect * ex) { EX_CHECK(cipher_algo); EX_CHECK(s2k_mode); @@ -235,7 +235,7 @@ show_debug(const char *msg) } static int -set_arg(PGP_Context * ctx, char *key, char *val, +set_arg(PGP_Context *ctx, char *key, char *val, struct debug_expect * ex) { int res = 0; @@ -362,7 +362,7 @@ downcase_convert(const uint8 *s, int len) } static int -parse_args(PGP_Context * ctx, uint8 *args, int arg_len, +parse_args(PGP_Context *ctx, uint8 *args, int arg_len, struct debug_expect * ex) { char *str = downcase_convert(args, arg_len); @@ -407,7 +407,7 @@ create_mbuf_from_vardata(text *data) } static void -init_work(PGP_Context ** ctx_p, int is_text, +init_work(PGP_Context **ctx_p, int is_text, text *args, struct debug_expect * ex) { int err = pgp_init(ctx_p); diff --git a/contrib/pgcrypto/pgp-pubdec.c b/contrib/pgcrypto/pgp-pubdec.c index 600a1e2531..cb32708fee 100644 --- a/contrib/pgcrypto/pgp-pubdec.c +++ b/contrib/pgcrypto/pgp-pubdec.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubdec.c,v 1.5 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubdec.c,v 1.6 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -95,7 +95,7 @@ control_cksum(uint8 *msg, int msglen) } static int -decrypt_elgamal(PGP_PubKey * pk, PullFilter * pkt, PGP_MPI ** m_p) +decrypt_elgamal(PGP_PubKey *pk, PullFilter *pkt, PGP_MPI **m_p) { int res; PGP_MPI *c1 = NULL; @@ -122,7 +122,7 @@ out: } static int -decrypt_rsa(PGP_PubKey * pk, PullFilter * pkt, PGP_MPI ** m_p) +decrypt_rsa(PGP_PubKey *pk, PullFilter *pkt, PGP_MPI **m_p) { int res; PGP_MPI *c; @@ -148,7 +148,7 @@ static const uint8 any_key[] = {0, 0, 0, 0, 0, 0, 0, 0}; int -pgp_parse_pubenc_sesskey(PGP_Context * ctx, PullFilter * pkt) +pgp_parse_pubenc_sesskey(PGP_Context *ctx, PullFilter *pkt) { int ver; int algo; diff --git a/contrib/pgcrypto/pgp-pubenc.c b/contrib/pgcrypto/pgp-pubenc.c index de729476f5..0e9ebb4285 100644 --- a/contrib/pgcrypto/pgp-pubenc.c +++ b/contrib/pgcrypto/pgp-pubenc.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubenc.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubenc.c,v 1.5 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -86,7 +86,7 @@ pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p) } static int -create_secmsg(PGP_Context * ctx, PGP_MPI ** msg_p, int full_bytes) +create_secmsg(PGP_Context *ctx, PGP_MPI **msg_p, int full_bytes) { uint8 *secmsg; int res, @@ -136,7 +136,7 @@ create_secmsg(PGP_Context * ctx, PGP_MPI ** msg_p, int full_bytes) } static int -encrypt_and_write_elgamal(PGP_Context * ctx, PGP_PubKey * pk, PushFilter * pkt) +encrypt_and_write_elgamal(PGP_Context *ctx, PGP_PubKey *pk, PushFilter *pkt) { int res; PGP_MPI *m = NULL, @@ -167,7 +167,7 @@ err: } static int -encrypt_and_write_rsa(PGP_Context * ctx, PGP_PubKey * pk, PushFilter * pkt) +encrypt_and_write_rsa(PGP_Context *ctx, PGP_PubKey *pk, PushFilter *pkt) { int res; PGP_MPI *m = NULL, @@ -193,7 +193,7 @@ err: } int -pgp_write_pubenc_sesskey(PGP_Context * ctx, PushFilter * dst) +pgp_write_pubenc_sesskey(PGP_Context *ctx, PushFilter *dst) { int res; PGP_PubKey *pk = ctx->pub_key; diff --git a/contrib/pgcrypto/pgp-pubkey.c b/contrib/pgcrypto/pgp-pubkey.c index 3904561806..62b6e1ab0e 100644 --- a/contrib/pgcrypto/pgp-pubkey.c +++ b/contrib/pgcrypto/pgp-pubkey.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubkey.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubkey.c,v 1.5 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -35,7 +35,7 @@ #include "pgp.h" int -pgp_key_alloc(PGP_PubKey ** pk_p) +pgp_key_alloc(PGP_PubKey **pk_p) { PGP_PubKey *pk; @@ -46,7 +46,7 @@ pgp_key_alloc(PGP_PubKey ** pk_p) } void -pgp_key_free(PGP_PubKey * pk) +pgp_key_free(PGP_PubKey *pk) { if (pk == NULL) return; @@ -82,7 +82,7 @@ pgp_key_free(PGP_PubKey * pk) } static int -calc_key_id(PGP_PubKey * pk) +calc_key_id(PGP_PubKey *pk) { int res; PX_MD *md; @@ -156,7 +156,7 @@ calc_key_id(PGP_PubKey * pk) } int -_pgp_read_public_key(PullFilter * pkt, PGP_PubKey ** pk_p) +_pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p) { int res; PGP_PubKey *pk; @@ -251,7 +251,7 @@ out: #define HIDE_SHA1 254 static int -check_key_sha1(PullFilter * src, PGP_PubKey * pk) +check_key_sha1(PullFilter *src, PGP_PubKey *pk) { int res; uint8 got_sha1[20]; @@ -297,7 +297,7 @@ err: } static int -check_key_cksum(PullFilter * src, PGP_PubKey * pk) +check_key_cksum(PullFilter *src, PGP_PubKey *pk) { int res; unsigned got_cksum, @@ -335,7 +335,7 @@ check_key_cksum(PullFilter * src, PGP_PubKey * pk) } static int -process_secret_key(PullFilter * pkt, PGP_PubKey ** pk_p, +process_secret_key(PullFilter *pkt, PGP_PubKey **pk_p, const uint8 *key, int key_len) { int res; @@ -456,7 +456,7 @@ process_secret_key(PullFilter * pkt, PGP_PubKey ** pk_p, } static int -internal_read_key(PullFilter * src, PGP_PubKey ** pk_p, +internal_read_key(PullFilter *src, PGP_PubKey **pk_p, const uint8 *psw, int psw_len, int pubtype) { PullFilter *pkt = NULL; @@ -563,7 +563,7 @@ internal_read_key(PullFilter * src, PGP_PubKey ** pk_p, } int -pgp_set_pubkey(PGP_Context * ctx, MBuf * keypkt, +pgp_set_pubkey(PGP_Context *ctx, MBuf *keypkt, const uint8 *key, int key_len, int pubtype) { int res; diff --git a/contrib/pgcrypto/pgp-s2k.c b/contrib/pgcrypto/pgp-s2k.c index 84def87db6..326b1bbf31 100644 --- a/contrib/pgcrypto/pgp-s2k.c +++ b/contrib/pgcrypto/pgp-s2k.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-s2k.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-s2k.c,v 1.5 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -36,7 +36,7 @@ #include "pgp.h" static int -calc_s2k_simple(PGP_S2K * s2k, PX_MD * md, const uint8 *key, +calc_s2k_simple(PGP_S2K *s2k, PX_MD *md, const uint8 *key, unsigned key_len) { unsigned md_bs, @@ -81,7 +81,7 @@ calc_s2k_simple(PGP_S2K * s2k, PX_MD * md, const uint8 *key, } static int -calc_s2k_salted(PGP_S2K * s2k, PX_MD * md, const uint8 *key, unsigned key_len) +calc_s2k_salted(PGP_S2K *s2k, PX_MD *md, const uint8 *key, unsigned key_len) { unsigned md_bs, md_rlen; @@ -126,7 +126,7 @@ calc_s2k_salted(PGP_S2K * s2k, PX_MD * md, const uint8 *key, unsigned key_len) } static int -calc_s2k_iter_salted(PGP_S2K * s2k, PX_MD * md, const uint8 *key, +calc_s2k_iter_salted(PGP_S2K *s2k, PX_MD *md, const uint8 *key, unsigned key_len) { unsigned md_bs, @@ -213,7 +213,7 @@ decide_count(unsigned rand_byte) } int -pgp_s2k_fill(PGP_S2K * s2k, int mode, int digest_algo) +pgp_s2k_fill(PGP_S2K *s2k, int mode, int digest_algo) { int res = 0; uint8 tmp; @@ -244,7 +244,7 @@ pgp_s2k_fill(PGP_S2K * s2k, int mode, int digest_algo) } int -pgp_s2k_read(PullFilter * src, PGP_S2K * s2k) +pgp_s2k_read(PullFilter *src, PGP_S2K *s2k) { int res = 0; @@ -270,7 +270,7 @@ pgp_s2k_read(PullFilter * src, PGP_S2K * s2k) } int -pgp_s2k_process(PGP_S2K * s2k, int cipher, const uint8 *key, int key_len) +pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int key_len) { int res; PX_MD *md; diff --git a/contrib/pgcrypto/pgp.c b/contrib/pgcrypto/pgp.c index e9e732e4be..ce6f199a9e 100644 --- a/contrib/pgcrypto/pgp.c +++ b/contrib/pgcrypto/pgp.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.c,v 1.3 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.c,v 1.4 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -165,7 +165,7 @@ pgp_get_cipher_block_size(int code) } int -pgp_load_cipher(int code, PX_Cipher ** res) +pgp_load_cipher(int code, PX_Cipher **res) { int err; const struct cipher_info *i = get_cipher_info(code); @@ -181,7 +181,7 @@ pgp_load_cipher(int code, PX_Cipher ** res) } int -pgp_load_digest(int code, PX_MD ** res) +pgp_load_digest(int code, PX_MD **res) { int err; const char *name = pgp_get_digest_name(code); @@ -197,7 +197,7 @@ pgp_load_digest(int code, PX_MD ** res) } int -pgp_init(PGP_Context ** ctx_p) +pgp_init(PGP_Context **ctx_p) { PGP_Context *ctx; @@ -221,7 +221,7 @@ pgp_init(PGP_Context ** ctx_p) } int -pgp_free(PGP_Context * ctx) +pgp_free(PGP_Context *ctx) { if (ctx->pub_key) pgp_key_free(ctx->pub_key); @@ -231,28 +231,28 @@ pgp_free(PGP_Context * ctx) } int -pgp_disable_mdc(PGP_Context * ctx, int disable) +pgp_disable_mdc(PGP_Context *ctx, int disable) { ctx->disable_mdc = disable ? 1 : 0; return 0; } int -pgp_set_sess_key(PGP_Context * ctx, int use) +pgp_set_sess_key(PGP_Context *ctx, int use) { ctx->use_sess_key = use ? 1 : 0; return 0; } int -pgp_set_convert_crlf(PGP_Context * ctx, int doit) +pgp_set_convert_crlf(PGP_Context *ctx, int doit) { ctx->convert_crlf = doit ? 1 : 0; return 0; } int -pgp_set_s2k_mode(PGP_Context * ctx, int mode) +pgp_set_s2k_mode(PGP_Context *ctx, int mode) { int err = PXE_OK; @@ -271,7 +271,7 @@ pgp_set_s2k_mode(PGP_Context * ctx, int mode) } int -pgp_set_compress_algo(PGP_Context * ctx, int algo) +pgp_set_compress_algo(PGP_Context *ctx, int algo) { switch (algo) { @@ -286,7 +286,7 @@ pgp_set_compress_algo(PGP_Context * ctx, int algo) } int -pgp_set_compress_level(PGP_Context * ctx, int level) +pgp_set_compress_level(PGP_Context *ctx, int level) { if (level >= 0 && level <= 9) { @@ -297,14 +297,14 @@ pgp_set_compress_level(PGP_Context * ctx, int level) } int -pgp_set_text_mode(PGP_Context * ctx, int mode) +pgp_set_text_mode(PGP_Context *ctx, int mode) { ctx->text_mode = mode; return 0; } int -pgp_set_cipher_algo(PGP_Context * ctx, const char *name) +pgp_set_cipher_algo(PGP_Context *ctx, const char *name) { int code = pgp_get_cipher_code(name); @@ -315,7 +315,7 @@ pgp_set_cipher_algo(PGP_Context * ctx, const char *name) } int -pgp_set_s2k_cipher_algo(PGP_Context * ctx, const char *name) +pgp_set_s2k_cipher_algo(PGP_Context *ctx, const char *name) { int code = pgp_get_cipher_code(name); @@ -326,7 +326,7 @@ pgp_set_s2k_cipher_algo(PGP_Context * ctx, const char *name) } int -pgp_set_s2k_digest_algo(PGP_Context * ctx, const char *name) +pgp_set_s2k_digest_algo(PGP_Context *ctx, const char *name) { int code = pgp_get_digest_code(name); @@ -337,20 +337,20 @@ pgp_set_s2k_digest_algo(PGP_Context * ctx, const char *name) } int -pgp_get_unicode_mode(PGP_Context * ctx) +pgp_get_unicode_mode(PGP_Context *ctx) { return ctx->unicode_mode; } int -pgp_set_unicode_mode(PGP_Context * ctx, int mode) +pgp_set_unicode_mode(PGP_Context *ctx, int mode) { ctx->unicode_mode = mode ? 1 : 0; return 0; } int -pgp_set_symkey(PGP_Context * ctx, const uint8 *key, int len) +pgp_set_symkey(PGP_Context *ctx, const uint8 *key, int len) { if (key == NULL || len < 1) return PXE_ARGUMENT_ERROR; diff --git a/contrib/pgcrypto/pgp.h b/contrib/pgcrypto/pgp.h index 223a8a073f..7860d830c4 100644 --- a/contrib/pgcrypto/pgp.h +++ b/contrib/pgcrypto/pgp.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.h,v 1.5 2009/03/25 15:03:13 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.h,v 1.6 2009/06/11 14:48:52 momjian Exp $ */ enum PGP_S2K_TYPE @@ -224,91 +224,91 @@ struct PGP_PubKey int can_encrypt; }; -int pgp_init(PGP_Context ** ctx); -int pgp_encrypt(PGP_Context * ctx, MBuf * src, MBuf * dst); -int pgp_decrypt(PGP_Context * ctx, MBuf * src, MBuf * dst); -int pgp_free(PGP_Context * ctx); +int pgp_init(PGP_Context **ctx); +int pgp_encrypt(PGP_Context *ctx, MBuf *src, MBuf *dst); +int pgp_decrypt(PGP_Context *ctx, MBuf *src, MBuf *dst); +int pgp_free(PGP_Context *ctx); int pgp_get_digest_code(const char *name); int pgp_get_cipher_code(const char *name); const char *pgp_get_digest_name(int code); const char *pgp_get_cipher_name(int code); -int pgp_set_cipher_algo(PGP_Context * ctx, const char *name); -int pgp_set_s2k_mode(PGP_Context * ctx, int type); -int pgp_set_s2k_cipher_algo(PGP_Context * ctx, const char *name); -int pgp_set_s2k_digest_algo(PGP_Context * ctx, const char *name); -int pgp_set_convert_crlf(PGP_Context * ctx, int doit); -int pgp_disable_mdc(PGP_Context * ctx, int disable); -int pgp_set_sess_key(PGP_Context * ctx, int use); -int pgp_set_compress_algo(PGP_Context * ctx, int algo); -int pgp_set_compress_level(PGP_Context * ctx, int level); -int pgp_set_text_mode(PGP_Context * ctx, int mode); -int pgp_set_unicode_mode(PGP_Context * ctx, int mode); -int pgp_get_unicode_mode(PGP_Context * ctx); - -int pgp_set_symkey(PGP_Context * ctx, const uint8 *key, int klen); -int pgp_set_pubkey(PGP_Context * ctx, MBuf * keypkt, +int pgp_set_cipher_algo(PGP_Context *ctx, const char *name); +int pgp_set_s2k_mode(PGP_Context *ctx, int type); +int pgp_set_s2k_cipher_algo(PGP_Context *ctx, const char *name); +int pgp_set_s2k_digest_algo(PGP_Context *ctx, const char *name); +int pgp_set_convert_crlf(PGP_Context *ctx, int doit); +int pgp_disable_mdc(PGP_Context *ctx, int disable); +int pgp_set_sess_key(PGP_Context *ctx, int use); +int pgp_set_compress_algo(PGP_Context *ctx, int algo); +int pgp_set_compress_level(PGP_Context *ctx, int level); +int pgp_set_text_mode(PGP_Context *ctx, int mode); +int pgp_set_unicode_mode(PGP_Context *ctx, int mode); +int pgp_get_unicode_mode(PGP_Context *ctx); + +int pgp_set_symkey(PGP_Context *ctx, const uint8 *key, int klen); +int pgp_set_pubkey(PGP_Context *ctx, MBuf *keypkt, const uint8 *key, int klen, int pubtype); -int pgp_get_keyid(MBuf * pgp_data, char *dst); +int pgp_get_keyid(MBuf *pgp_data, char *dst); /* internal functions */ -int pgp_load_digest(int c, PX_MD ** res); -int pgp_load_cipher(int c, PX_Cipher ** res); +int pgp_load_digest(int c, PX_MD **res); +int pgp_load_cipher(int c, PX_Cipher **res); int pgp_get_cipher_key_size(int c); int pgp_get_cipher_block_size(int c); -int pgp_s2k_fill(PGP_S2K * s2k, int mode, int digest_algo); -int pgp_s2k_read(PullFilter * src, PGP_S2K * s2k); -int pgp_s2k_process(PGP_S2K * s2k, int cipher, const uint8 *key, int klen); +int pgp_s2k_fill(PGP_S2K *s2k, int mode, int digest_algo); +int pgp_s2k_read(PullFilter *src, PGP_S2K *s2k); +int pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int klen); typedef struct PGP_CFB PGP_CFB; int -pgp_cfb_create(PGP_CFB ** ctx_p, int algo, +pgp_cfb_create(PGP_CFB **ctx_p, int algo, const uint8 *key, int key_len, int recync, uint8 *iv); -void pgp_cfb_free(PGP_CFB * ctx); -int pgp_cfb_encrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst); -int pgp_cfb_decrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst); +void pgp_cfb_free(PGP_CFB *ctx); +int pgp_cfb_encrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst); +int pgp_cfb_decrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst); int pgp_armor_encode(const uint8 *src, unsigned len, uint8 *dst); int pgp_armor_decode(const uint8 *src, unsigned len, uint8 *dst); unsigned pgp_armor_enc_len(unsigned len); unsigned pgp_armor_dec_len(unsigned len); -int pgp_compress_filter(PushFilter ** res, PGP_Context * ctx, PushFilter * dst); -int pgp_decompress_filter(PullFilter ** res, PGP_Context * ctx, PullFilter * src); +int pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst); +int pgp_decompress_filter(PullFilter **res, PGP_Context *ctx, PullFilter *src); -int pgp_key_alloc(PGP_PubKey ** pk_p); -void pgp_key_free(PGP_PubKey * pk); -int _pgp_read_public_key(PullFilter * pkt, PGP_PubKey ** pk_p); +int pgp_key_alloc(PGP_PubKey **pk_p); +void pgp_key_free(PGP_PubKey *pk); +int _pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p); -int pgp_parse_pubenc_sesskey(PGP_Context * ctx, PullFilter * pkt); -int pgp_create_pkt_reader(PullFilter ** pf_p, PullFilter * src, int len, - int pkttype, PGP_Context * ctx); -int pgp_parse_pkt_hdr(PullFilter * src, uint8 *tag, int *len_p, +int pgp_parse_pubenc_sesskey(PGP_Context *ctx, PullFilter *pkt); +int pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len, + int pkttype, PGP_Context *ctx); +int pgp_parse_pkt_hdr(PullFilter *src, uint8 *tag, int *len_p, int allow_ctx); -int pgp_skip_packet(PullFilter * pkt); -int pgp_expect_packet_end(PullFilter * pkt); - -int pgp_write_pubenc_sesskey(PGP_Context * ctx, PushFilter * dst); -int pgp_create_pkt_writer(PushFilter * dst, int tag, PushFilter ** res_p); - -int pgp_mpi_alloc(int bits, PGP_MPI ** mpi); -int pgp_mpi_create(uint8 *data, int bits, PGP_MPI ** mpi); -int pgp_mpi_free(PGP_MPI * mpi); -int pgp_mpi_read(PullFilter * src, PGP_MPI ** mpi); -int pgp_mpi_write(PushFilter * dst, PGP_MPI * n); -int pgp_mpi_hash(PX_MD * md, PGP_MPI * n); -unsigned pgp_mpi_cksum(unsigned cksum, PGP_MPI * n); - -int pgp_elgamal_encrypt(PGP_PubKey * pk, PGP_MPI * m, - PGP_MPI ** c1, PGP_MPI ** c2); -int pgp_elgamal_decrypt(PGP_PubKey * pk, PGP_MPI * c1, PGP_MPI * c2, - PGP_MPI ** m); -int pgp_rsa_encrypt(PGP_PubKey * pk, PGP_MPI * m, PGP_MPI ** c); -int pgp_rsa_decrypt(PGP_PubKey * pk, PGP_MPI * c, PGP_MPI ** m); +int pgp_skip_packet(PullFilter *pkt); +int pgp_expect_packet_end(PullFilter *pkt); + +int pgp_write_pubenc_sesskey(PGP_Context *ctx, PushFilter *dst); +int pgp_create_pkt_writer(PushFilter *dst, int tag, PushFilter **res_p); + +int pgp_mpi_alloc(int bits, PGP_MPI **mpi); +int pgp_mpi_create(uint8 *data, int bits, PGP_MPI **mpi); +int pgp_mpi_free(PGP_MPI *mpi); +int pgp_mpi_read(PullFilter *src, PGP_MPI **mpi); +int pgp_mpi_write(PushFilter *dst, PGP_MPI *n); +int pgp_mpi_hash(PX_MD *md, PGP_MPI *n); +unsigned pgp_mpi_cksum(unsigned cksum, PGP_MPI *n); + +int pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *m, + PGP_MPI **c1, PGP_MPI **c2); +int pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *c1, PGP_MPI *c2, + PGP_MPI **m); +int pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *m, PGP_MPI **c); +int pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *c, PGP_MPI **m); extern struct PullFilterOps pgp_decrypt_filter; diff --git a/contrib/pgcrypto/px-hmac.c b/contrib/pgcrypto/px-hmac.c index fa4233903c..3b2016190e 100644 --- a/contrib/pgcrypto/px-hmac.c +++ b/contrib/pgcrypto/px-hmac.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/px-hmac.c,v 1.7 2005/07/11 15:07:59 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/px-hmac.c,v 1.8 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -37,19 +37,19 @@ #define HMAC_OPAD 0x5C static unsigned -hmac_result_size(PX_HMAC * h) +hmac_result_size(PX_HMAC *h) { return px_md_result_size(h->md); } static unsigned -hmac_block_size(PX_HMAC * h) +hmac_block_size(PX_HMAC *h) { return px_md_block_size(h->md); } static void -hmac_init(PX_HMAC * h, const uint8 *key, unsigned klen) +hmac_init(PX_HMAC *h, const uint8 *key, unsigned klen) { unsigned bs, hlen, @@ -84,7 +84,7 @@ hmac_init(PX_HMAC * h, const uint8 *key, unsigned klen) } static void -hmac_reset(PX_HMAC * h) +hmac_reset(PX_HMAC *h) { PX_MD *md = h->md; unsigned bs = px_md_block_size(md); @@ -94,13 +94,13 @@ hmac_reset(PX_HMAC * h) } static void -hmac_update(PX_HMAC * h, const uint8 *data, unsigned dlen) +hmac_update(PX_HMAC *h, const uint8 *data, unsigned dlen) { px_md_update(h->md, data, dlen); } static void -hmac_finish(PX_HMAC * h, uint8 *dst) +hmac_finish(PX_HMAC *h, uint8 *dst) { PX_MD *md = h->md; unsigned bs, @@ -124,7 +124,7 @@ hmac_finish(PX_HMAC * h, uint8 *dst) } static void -hmac_free(PX_HMAC * h) +hmac_free(PX_HMAC *h) { unsigned bs; @@ -142,7 +142,7 @@ hmac_free(PX_HMAC * h) /* PUBLIC FUNCTIONS */ int -px_find_hmac(const char *name, PX_HMAC ** res) +px_find_hmac(const char *name, PX_HMAC **res) { int err; PX_MD *md; diff --git a/contrib/pgcrypto/px.c b/contrib/pgcrypto/px.c index d1b22d7ec7..f2db06a898 100644 --- a/contrib/pgcrypto/px.c +++ b/contrib/pgcrypto/px.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.17 2007/11/15 21:14:31 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.18 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -106,7 +106,7 @@ px_strerror(int err) const char * -px_resolve_alias(const PX_Alias * list, const char *name) +px_resolve_alias(const PX_Alias *list, const char *name) { while (list->name) { @@ -146,19 +146,19 @@ px_debug(const char *fmt,...) */ static unsigned -combo_encrypt_len(PX_Combo * cx, unsigned dlen) +combo_encrypt_len(PX_Combo *cx, unsigned dlen) { return dlen + 512; } static unsigned -combo_decrypt_len(PX_Combo * cx, unsigned dlen) +combo_decrypt_len(PX_Combo *cx, unsigned dlen) { return dlen; } static int -combo_init(PX_Combo * cx, const uint8 *key, unsigned klen, +combo_init(PX_Combo *cx, const uint8 *key, unsigned klen, const uint8 *iv, unsigned ivlen) { int err; @@ -199,7 +199,7 @@ combo_init(PX_Combo * cx, const uint8 *key, unsigned klen, } static int -combo_encrypt(PX_Combo * cx, const uint8 *data, unsigned dlen, +combo_encrypt(PX_Combo *cx, const uint8 *data, unsigned dlen, uint8 *res, unsigned *rlen) { int err = 0; @@ -270,7 +270,7 @@ out: } static int -combo_decrypt(PX_Combo * cx, const uint8 *data, unsigned dlen, +combo_decrypt(PX_Combo *cx, const uint8 *data, unsigned dlen, uint8 *res, unsigned *rlen) { unsigned bs, @@ -327,7 +327,7 @@ block_error: } static void -combo_free(PX_Combo * cx) +combo_free(PX_Combo *cx) { if (cx->cipher) px_cipher_free(cx->cipher); @@ -380,7 +380,7 @@ parse_cipher_name(char *full, char **cipher, char **pad) /* provider */ int -px_find_combo(const char *name, PX_Combo ** res) +px_find_combo(const char *name, PX_Combo **res) { int err; char *buf, diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h index 257d6015bc..c916e9361c 100644 --- a/contrib/pgcrypto/px.h +++ b/contrib/pgcrypto/px.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.18 2007/08/23 16:15:51 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.19 2009/06/11 14:48:52 momjian Exp $ */ #ifndef __PX_H @@ -116,12 +116,12 @@ typedef struct px_combo PX_Combo; struct px_digest { - unsigned (*result_size) (PX_MD * h); - unsigned (*block_size) (PX_MD * h); - void (*reset) (PX_MD * h); - void (*update) (PX_MD * h, const uint8 *data, unsigned dlen); - void (*finish) (PX_MD * h, uint8 *dst); - void (*free) (PX_MD * h); + unsigned (*result_size) (PX_MD *h); + unsigned (*block_size) (PX_MD *h); + void (*reset) (PX_MD *h); + void (*update) (PX_MD *h, const uint8 *data, unsigned dlen); + void (*finish) (PX_MD *h, uint8 *dst); + void (*free) (PX_MD *h); /* private */ union { @@ -138,13 +138,13 @@ struct px_alias struct px_hmac { - unsigned (*result_size) (PX_HMAC * h); - unsigned (*block_size) (PX_HMAC * h); - void (*reset) (PX_HMAC * h); - void (*update) (PX_HMAC * h, const uint8 *data, unsigned dlen); - void (*finish) (PX_HMAC * h, uint8 *dst); - void (*free) (PX_HMAC * h); - void (*init) (PX_HMAC * h, const uint8 *key, unsigned klen); + unsigned (*result_size) (PX_HMAC *h); + unsigned (*block_size) (PX_HMAC *h); + void (*reset) (PX_HMAC *h); + void (*update) (PX_HMAC *h, const uint8 *data, unsigned dlen); + void (*finish) (PX_HMAC *h, uint8 *dst); + void (*free) (PX_HMAC *h); + void (*init) (PX_HMAC *h, const uint8 *key, unsigned klen); PX_MD *md; /* private */ @@ -157,14 +157,14 @@ struct px_hmac struct px_cipher { - unsigned (*block_size) (PX_Cipher * c); - unsigned (*key_size) (PX_Cipher * c); /* max key len */ - unsigned (*iv_size) (PX_Cipher * c); - - int (*init) (PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv); - int (*encrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res); - int (*decrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res); - void (*free) (PX_Cipher * c); + unsigned (*block_size) (PX_Cipher *c); + unsigned (*key_size) (PX_Cipher *c); /* max key len */ + unsigned (*iv_size) (PX_Cipher *c); + + int (*init) (PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv); + int (*encrypt) (PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res); + int (*decrypt) (PX_Cipher *c, const uint8 *data, unsigned dlen, uint8 *res); + void (*free) (PX_Cipher *c); /* private */ void *ptr; int pstat; /* mcrypt uses it */ @@ -172,24 +172,24 @@ struct px_cipher struct px_combo { - int (*init) (PX_Combo * cx, const uint8 *key, unsigned klen, + int (*init) (PX_Combo *cx, const uint8 *key, unsigned klen, const uint8 *iv, unsigned ivlen); - int (*encrypt) (PX_Combo * cx, const uint8 *data, unsigned dlen, + int (*encrypt) (PX_Combo *cx, const uint8 *data, unsigned dlen, uint8 *res, unsigned *rlen); - int (*decrypt) (PX_Combo * cx, const uint8 *data, unsigned dlen, + int (*decrypt) (PX_Combo *cx, const uint8 *data, unsigned dlen, uint8 *res, unsigned *rlen); - unsigned (*encrypt_len) (PX_Combo * cx, unsigned dlen); - unsigned (*decrypt_len) (PX_Combo * cx, unsigned dlen); - void (*free) (PX_Combo * cx); + unsigned (*encrypt_len) (PX_Combo *cx, unsigned dlen); + unsigned (*decrypt_len) (PX_Combo *cx, unsigned dlen); + void (*free) (PX_Combo *cx); PX_Cipher *cipher; unsigned padding; }; -int px_find_digest(const char *name, PX_MD ** res); -int px_find_hmac(const char *name, PX_HMAC ** res); -int px_find_cipher(const char *name, PX_Cipher ** res); -int px_find_combo(const char *name, PX_Combo ** res); +int px_find_digest(const char *name, PX_MD **res); +int px_find_hmac(const char *name, PX_HMAC **res); +int px_find_cipher(const char *name, PX_Cipher **res); +int px_find_combo(const char *name, PX_Combo **res); int px_get_random_bytes(uint8 *dst, unsigned count); int px_get_pseudo_random_bytes(uint8 *dst, unsigned count); @@ -199,7 +199,7 @@ unsigned px_acquire_system_randomness(uint8 *dst); const char *px_strerror(int err); -const char *px_resolve_alias(const PX_Alias * aliases, const char *name); +const char *px_resolve_alias(const PX_Alias *aliases, const char *name); void px_set_debug_handler(void (*handler) (const char *)); diff --git a/contrib/pgcrypto/rijndael.c b/contrib/pgcrypto/rijndael.c index 97f97bd543..cf9eca91dc 100644 --- a/contrib/pgcrypto/rijndael.c +++ b/contrib/pgcrypto/rijndael.c @@ -1,6 +1,6 @@ /* $OpenBSD: rijndael.c,v 1.6 2000/12/09 18:51:34 markus Exp $ */ -/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.13 2007/04/06 05:36:50 tgl Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.14 2009/06/11 14:48:52 momjian Exp $ */ /* This is an independent implementation of the encryption algorithm: */ /* */ @@ -302,7 +302,7 @@ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ } while (0) rijndael_ctx * -rijndael_set_key(rijndael_ctx * ctx, const u4byte * in_key, const u4byte key_len, +rijndael_set_key(rijndael_ctx *ctx, const u4byte *in_key, const u4byte key_len, int encrypt) { u4byte i, @@ -384,7 +384,7 @@ do { \ } while (0) void -rijndael_encrypt(rijndael_ctx * ctx, const u4byte * in_blk, u4byte * out_blk) +rijndael_encrypt(rijndael_ctx *ctx, const u4byte *in_blk, u4byte *out_blk) { u4byte k_len = ctx->k_len; u4byte *e_key = ctx->e_key; @@ -448,7 +448,7 @@ do { \ } while (0) void -rijndael_decrypt(rijndael_ctx * ctx, const u4byte * in_blk, u4byte * out_blk) +rijndael_decrypt(rijndael_ctx *ctx, const u4byte *in_blk, u4byte *out_blk) { u4byte b0[4], b1[4], @@ -501,7 +501,7 @@ rijndael_decrypt(rijndael_ctx * ctx, const u4byte * in_blk, u4byte * out_blk) */ void -aes_set_key(rijndael_ctx * ctx, const uint8 *key, unsigned keybits, int enc) +aes_set_key(rijndael_ctx *ctx, const uint8 *key, unsigned keybits, int enc) { uint32 *k; @@ -510,7 +510,7 @@ aes_set_key(rijndael_ctx * ctx, const uint8 *key, unsigned keybits, int enc) } void -aes_ecb_encrypt(rijndael_ctx * ctx, uint8 *data, unsigned len) +aes_ecb_encrypt(rijndael_ctx *ctx, uint8 *data, unsigned len) { unsigned bs = 16; uint32 *d; @@ -526,7 +526,7 @@ aes_ecb_encrypt(rijndael_ctx * ctx, uint8 *data, unsigned len) } void -aes_ecb_decrypt(rijndael_ctx * ctx, uint8 *data, unsigned len) +aes_ecb_decrypt(rijndael_ctx *ctx, uint8 *data, unsigned len) { unsigned bs = 16; uint32 *d; @@ -542,7 +542,7 @@ aes_ecb_decrypt(rijndael_ctx * ctx, uint8 *data, unsigned len) } void -aes_cbc_encrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len) +aes_cbc_encrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len) { uint32 *iv = (uint32 *) iva; uint32 *d = (uint32 *) data; @@ -564,7 +564,7 @@ aes_cbc_encrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len) } void -aes_cbc_decrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len) +aes_cbc_decrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len) { uint32 *d = (uint32 *) data; unsigned bs = 16; diff --git a/contrib/pgcrypto/rijndael.h b/contrib/pgcrypto/rijndael.h index e5e862323f..e4c4229170 100644 --- a/contrib/pgcrypto/rijndael.h +++ b/contrib/pgcrypto/rijndael.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.h,v 1.6 2008/05/17 01:28:21 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.h,v 1.7 2009/06/11 14:48:52 momjian Exp $ * * $OpenBSD: rijndael.h,v 1.3 2001/05/09 23:01:32 markus Exp $ */ @@ -36,7 +36,7 @@ typedef struct _rijndael_ctx int decrypt; u4byte e_key[64]; u4byte d_key[64]; -} rijndael_ctx; +} rijndael_ctx; /* 2. Standard interface for AES cryptographic routines */ @@ -51,10 +51,10 @@ void rijndael_decrypt(rijndael_ctx *, const u4byte *, u4byte *); /* conventional interface */ -void aes_set_key(rijndael_ctx * ctx, const uint8 *key, unsigned keybits, int enc); -void aes_ecb_encrypt(rijndael_ctx * ctx, uint8 *data, unsigned len); -void aes_ecb_decrypt(rijndael_ctx * ctx, uint8 *data, unsigned len); -void aes_cbc_encrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len); -void aes_cbc_decrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len); +void aes_set_key(rijndael_ctx *ctx, const uint8 *key, unsigned keybits, int enc); +void aes_ecb_encrypt(rijndael_ctx *ctx, uint8 *data, unsigned len); +void aes_ecb_decrypt(rijndael_ctx *ctx, uint8 *data, unsigned len); +void aes_cbc_encrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len); +void aes_cbc_decrypt(rijndael_ctx *ctx, uint8 *iva, uint8 *data, unsigned len); #endif /* _RIJNDAEL_H_ */ diff --git a/contrib/pgcrypto/sha2.c b/contrib/pgcrypto/sha2.c index c2e9da965b..9cd58a08ab 100644 --- a/contrib/pgcrypto/sha2.c +++ b/contrib/pgcrypto/sha2.c @@ -33,7 +33,7 @@ * * $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ * - * $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.10 2007/11/15 21:14:31 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.11 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" @@ -250,7 +250,7 @@ static const uint64 sha512_initial_hash_value[8] = { /*** SHA-256: *********************************************************/ void -SHA256_Init(SHA256_CTX * context) +SHA256_Init(SHA256_CTX *context) { if (context == NULL) return; @@ -286,7 +286,7 @@ SHA256_Init(SHA256_CTX * context) } while(0) static void -SHA256_Transform(SHA256_CTX * context, const uint8 *data) +SHA256_Transform(SHA256_CTX *context, const uint8 *data) { uint32 a, b, @@ -357,7 +357,7 @@ SHA256_Transform(SHA256_CTX * context, const uint8 *data) #else /* SHA2_UNROLL_TRANSFORM */ static void -SHA256_Transform(SHA256_CTX * context, const uint8 *data) +SHA256_Transform(SHA256_CTX *context, const uint8 *data) { uint32 a, b, @@ -447,7 +447,7 @@ SHA256_Transform(SHA256_CTX * context, const uint8 *data) #endif /* SHA2_UNROLL_TRANSFORM */ void -SHA256_Update(SHA256_CTX * context, const uint8 *data, size_t len) +SHA256_Update(SHA256_CTX *context, const uint8 *data, size_t len) { size_t freespace, usedspace; @@ -500,7 +500,7 @@ SHA256_Update(SHA256_CTX * context, const uint8 *data, size_t len) } static void -SHA256_Last(SHA256_CTX * context) +SHA256_Last(SHA256_CTX *context) { unsigned int usedspace; @@ -548,7 +548,7 @@ SHA256_Last(SHA256_CTX * context) } void -SHA256_Final(uint8 digest[], SHA256_CTX * context) +SHA256_Final(uint8 digest[], SHA256_CTX *context) { /* If no digest buffer is passed, we don't bother doing this: */ if (digest != NULL) @@ -576,7 +576,7 @@ SHA256_Final(uint8 digest[], SHA256_CTX * context) /*** SHA-512: *********************************************************/ void -SHA512_Init(SHA512_CTX * context) +SHA512_Init(SHA512_CTX *context) { if (context == NULL) return; @@ -615,7 +615,7 @@ SHA512_Init(SHA512_CTX * context) } while(0) static void -SHA512_Transform(SHA512_CTX * context, const uint8 *data) +SHA512_Transform(SHA512_CTX *context, const uint8 *data) { uint64 a, b, @@ -683,7 +683,7 @@ SHA512_Transform(SHA512_CTX * context, const uint8 *data) #else /* SHA2_UNROLL_TRANSFORM */ static void -SHA512_Transform(SHA512_CTX * context, const uint8 *data) +SHA512_Transform(SHA512_CTX *context, const uint8 *data) { uint64 a, b, @@ -773,7 +773,7 @@ SHA512_Transform(SHA512_CTX * context, const uint8 *data) #endif /* SHA2_UNROLL_TRANSFORM */ void -SHA512_Update(SHA512_CTX * context, const uint8 *data, size_t len) +SHA512_Update(SHA512_CTX *context, const uint8 *data, size_t len) { size_t freespace, usedspace; @@ -826,7 +826,7 @@ SHA512_Update(SHA512_CTX * context, const uint8 *data, size_t len) } static void -SHA512_Last(SHA512_CTX * context) +SHA512_Last(SHA512_CTX *context) { unsigned int usedspace; @@ -876,7 +876,7 @@ SHA512_Last(SHA512_CTX * context) } void -SHA512_Final(uint8 digest[], SHA512_CTX * context) +SHA512_Final(uint8 digest[], SHA512_CTX *context) { /* If no digest buffer is passed, we don't bother doing this: */ if (digest != NULL) @@ -905,7 +905,7 @@ SHA512_Final(uint8 digest[], SHA512_CTX * context) /*** SHA-384: *********************************************************/ void -SHA384_Init(SHA384_CTX * context) +SHA384_Init(SHA384_CTX *context) { if (context == NULL) return; @@ -915,13 +915,13 @@ SHA384_Init(SHA384_CTX * context) } void -SHA384_Update(SHA384_CTX * context, const uint8 *data, size_t len) +SHA384_Update(SHA384_CTX *context, const uint8 *data, size_t len) { SHA512_Update((SHA512_CTX *) context, data, len); } void -SHA384_Final(uint8 digest[], SHA384_CTX * context) +SHA384_Final(uint8 digest[], SHA384_CTX *context) { /* If no digest buffer is passed, we don't bother doing this: */ if (digest != NULL) @@ -949,7 +949,7 @@ SHA384_Final(uint8 digest[], SHA384_CTX * context) /*** SHA-224: *********************************************************/ void -SHA224_Init(SHA224_CTX * context) +SHA224_Init(SHA224_CTX *context) { if (context == NULL) return; @@ -959,13 +959,13 @@ SHA224_Init(SHA224_CTX * context) } void -SHA224_Update(SHA224_CTX * context, const uint8 *data, size_t len) +SHA224_Update(SHA224_CTX *context, const uint8 *data, size_t len) { SHA256_Update((SHA256_CTX *) context, data, len); } void -SHA224_Final(uint8 digest[], SHA224_CTX * context) +SHA224_Final(uint8 digest[], SHA224_CTX *context) { /* If no digest buffer is passed, we don't bother doing this: */ if (digest != NULL) diff --git a/contrib/pgcrypto/sha2.h b/contrib/pgcrypto/sha2.h index f6fde39c5b..8d593c60e5 100644 --- a/contrib/pgcrypto/sha2.h +++ b/contrib/pgcrypto/sha2.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.h,v 1.4 2006/07/13 04:15:25 neilc Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.h,v 1.5 2009/06/11 14:48:52 momjian Exp $ */ /* $OpenBSD: sha2.h,v 1.2 2004/04/28 23:11:57 millert Exp $ */ /* @@ -70,13 +70,13 @@ typedef struct _SHA256_CTX uint32 state[8]; uint64 bitcount; uint8 buffer[SHA256_BLOCK_LENGTH]; -} SHA256_CTX; +} SHA256_CTX; typedef struct _SHA512_CTX { uint64 state[8]; uint64 bitcount[2]; uint8 buffer[SHA512_BLOCK_LENGTH]; -} SHA512_CTX; +} SHA512_CTX; typedef SHA256_CTX SHA224_CTX; typedef SHA512_CTX SHA384_CTX; diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c index e41c59e798..e0d21a8926 100644 --- a/contrib/pgrowlocks/pgrowlocks.c +++ b/contrib/pgrowlocks/pgrowlocks.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgrowlocks/pgrowlocks.c,v 1.11 2008/06/19 00:46:03 alvherre Exp $ + * $PostgreSQL: pgsql/contrib/pgrowlocks/pgrowlocks.c,v 1.12 2009/06/11 14:48:52 momjian Exp $ * * Copyright (c) 2005-2006 Tatsuo Ishii * @@ -57,7 +57,7 @@ typedef struct Relation rel; HeapScanDesc scan; int ncolumns; -} MyData; +} MyData; Datum pgrowlocks(PG_FUNCTION_ARGS) diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c index b00ae5b766..83b50bb432 100644 --- a/contrib/pgstattuple/pgstatindex.c +++ b/contrib/pgstattuple/pgstatindex.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgstattuple/pgstatindex.c,v 1.12 2009/03/31 22:54:31 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgstattuple/pgstatindex.c,v 1.13 2009/06/11 14:48:52 momjian Exp $ * * * pgstatindex @@ -76,7 +76,7 @@ typedef struct BTIndexStat uint64 free_space; uint64 fragments; -} BTIndexStat; +} BTIndexStat; /* ------------------------------------------------------ * pgstatindex() @@ -91,8 +91,8 @@ pgstatindex(PG_FUNCTION_ARGS) Relation rel; RangeVar *relrv; Datum result; - BlockNumber nblocks; - BlockNumber blkno; + BlockNumber nblocks; + BlockNumber blkno; BTIndexStat indexStat; if (!superuser()) @@ -108,9 +108,9 @@ pgstatindex(PG_FUNCTION_ARGS) RelationGetRelationName(rel)); /* - * Reject attempts to read non-local temporary relations; we would - * be likely to get wrong data since we have no visibility into the - * owning session's local buffers. + * Reject attempts to read non-local temporary relations; we would be + * likely to get wrong data since we have no visibility into the owning + * session's local buffers. */ if (RELATION_IS_OTHER_TEMP(rel)) ereport(ERROR, diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index c2c5d11e5a..5d6168f77d 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.37 2009/03/31 22:54:31 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.38 2009/06/11 14:48:52 momjian Exp $ * * Copyright (c) 2001,2002 Tatsuo Ishii * @@ -59,30 +59,30 @@ typedef struct pgstattuple_type uint64 dead_tuple_count; uint64 dead_tuple_len; uint64 free_space; /* free/reusable space in bytes */ -} pgstattuple_type; +} pgstattuple_type; typedef void (*pgstat_page) (pgstattuple_type *, Relation, BlockNumber); -static Datum build_pgstattuple_type(pgstattuple_type * stat, +static Datum build_pgstattuple_type(pgstattuple_type *stat, FunctionCallInfo fcinfo); static Datum pgstat_relation(Relation rel, FunctionCallInfo fcinfo); static Datum pgstat_heap(Relation rel, FunctionCallInfo fcinfo); -static void pgstat_btree_page(pgstattuple_type * stat, +static void pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno); -static void pgstat_hash_page(pgstattuple_type * stat, +static void pgstat_hash_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno); -static void pgstat_gist_page(pgstattuple_type * stat, +static void pgstat_gist_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno); static Datum pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn, FunctionCallInfo fcinfo); -static void pgstat_index_page(pgstattuple_type * stat, Page page, +static void pgstat_index_page(pgstattuple_type *stat, Page page, OffsetNumber minoff, OffsetNumber maxoff); /* * build_pgstattuple_type -- build a pgstattuple_type tuple */ static Datum -build_pgstattuple_type(pgstattuple_type * stat, FunctionCallInfo fcinfo) +build_pgstattuple_type(pgstattuple_type *stat, FunctionCallInfo fcinfo) { #define NCOLUMNS 9 #define NCHARS 32 @@ -200,9 +200,9 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo) const char *err; /* - * Reject attempts to read non-local temporary relations; we would - * be likely to get wrong data since we have no visibility into the - * owning session's local buffers. + * Reject attempts to read non-local temporary relations; we would be + * likely to get wrong data since we have no visibility into the owning + * session's local buffers. */ if (RELATION_IS_OTHER_TEMP(rel)) ereport(ERROR, @@ -331,7 +331,7 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo) * pgstat_btree_page -- check tuples in a btree page */ static void -pgstat_btree_page(pgstattuple_type * stat, Relation rel, BlockNumber blkno) +pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno) { Buffer buf; Page page; @@ -374,7 +374,7 @@ pgstat_btree_page(pgstattuple_type * stat, Relation rel, BlockNumber blkno) * pgstat_hash_page -- check tuples in a hash page */ static void -pgstat_hash_page(pgstattuple_type * stat, Relation rel, BlockNumber blkno) +pgstat_hash_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno) { Buffer buf; Page page; @@ -417,7 +417,7 @@ pgstat_hash_page(pgstattuple_type * stat, Relation rel, BlockNumber blkno) * pgstat_gist_page -- check tuples in a gist page */ static void -pgstat_gist_page(pgstattuple_type * stat, Relation rel, BlockNumber blkno) +pgstat_gist_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno) { Buffer buf; Page page; @@ -480,7 +480,7 @@ pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn, * pgstat_index_page -- for generic index page */ static void -pgstat_index_page(pgstattuple_type * stat, Page page, +pgstat_index_page(pgstattuple_type *stat, Page page, OffsetNumber minoff, OffsetNumber maxoff) { OffsetNumber i; diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 8a95a1d5cc..930a35b009 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/seg/seg.c,v 1.24 2008/05/17 01:28:22 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/seg/seg.c,v 1.25 2009/06/11 14:48:52 momjian Exp $ * ****************************************************************************** This file contains routines that can be bound to a Postgres backend and @@ -53,49 +53,49 @@ Datum seg_center(PG_FUNCTION_ARGS); /* ** GiST support methods */ -bool gseg_consistent(GISTENTRY *entry, - SEG * query, - StrategyNumber strategy, - Oid subtype, - bool *recheck); +bool gseg_consistent(GISTENTRY *entry, + SEG *query, + StrategyNumber strategy, + Oid subtype, + bool *recheck); GISTENTRY *gseg_compress(GISTENTRY *entry); GISTENTRY *gseg_decompress(GISTENTRY *entry); float *gseg_penalty(GISTENTRY *origentry, GISTENTRY *newentry, float *result); GIST_SPLITVEC *gseg_picksplit(GistEntryVector *entryvec, GIST_SPLITVEC *v); -bool gseg_leaf_consistent(SEG * key, SEG * query, StrategyNumber strategy); -bool gseg_internal_consistent(SEG * key, SEG * query, StrategyNumber strategy); +bool gseg_leaf_consistent(SEG *key, SEG *query, StrategyNumber strategy); +bool gseg_internal_consistent(SEG *key, SEG *query, StrategyNumber strategy); SEG *gseg_union(GistEntryVector *entryvec, int *sizep); -SEG *gseg_binary_union(SEG * r1, SEG * r2, int *sizep); -bool *gseg_same(SEG * b1, SEG * b2, bool *result); +SEG *gseg_binary_union(SEG *r1, SEG *r2, int *sizep); +bool *gseg_same(SEG *b1, SEG *b2, bool *result); /* ** R-tree support functions */ -bool seg_same(SEG * a, SEG * b); -bool seg_contains_int(SEG * a, int *b); -bool seg_contains_float4(SEG * a, float4 *b); -bool seg_contains_float8(SEG * a, float8 *b); -bool seg_contains(SEG * a, SEG * b); -bool seg_contained(SEG * a, SEG * b); -bool seg_overlap(SEG * a, SEG * b); -bool seg_left(SEG * a, SEG * b); -bool seg_over_left(SEG * a, SEG * b); -bool seg_right(SEG * a, SEG * b); -bool seg_over_right(SEG * a, SEG * b); -SEG *seg_union(SEG * a, SEG * b); -SEG *seg_inter(SEG * a, SEG * b); -void rt_seg_size(SEG * a, float *sz); +bool seg_same(SEG *a, SEG *b); +bool seg_contains_int(SEG *a, int *b); +bool seg_contains_float4(SEG *a, float4 *b); +bool seg_contains_float8(SEG *a, float8 *b); +bool seg_contains(SEG *a, SEG *b); +bool seg_contained(SEG *a, SEG *b); +bool seg_overlap(SEG *a, SEG *b); +bool seg_left(SEG *a, SEG *b); +bool seg_over_left(SEG *a, SEG *b); +bool seg_right(SEG *a, SEG *b); +bool seg_over_right(SEG *a, SEG *b); +SEG *seg_union(SEG *a, SEG *b); +SEG *seg_inter(SEG *a, SEG *b); +void rt_seg_size(SEG *a, float *sz); /* ** Various operators */ -int32 seg_cmp(SEG * a, SEG * b); -bool seg_lt(SEG * a, SEG * b); -bool seg_le(SEG * a, SEG * b); -bool seg_gt(SEG * a, SEG * b); -bool seg_ge(SEG * a, SEG * b); -bool seg_different(SEG * a, SEG * b); +int32 seg_cmp(SEG *a, SEG *b); +bool seg_lt(SEG *a, SEG *b); +bool seg_le(SEG *a, SEG *b); +bool seg_gt(SEG *a, SEG *b); +bool seg_ge(SEG *a, SEG *b); +bool seg_different(SEG *a, SEG *b); /* ** Auxiliary funxtions @@ -168,7 +168,7 @@ seg_out(PG_FUNCTION_ARGS) Datum seg_center(PG_FUNCTION_ARGS) { - SEG *seg = (SEG *) PG_GETARG_POINTER(0); + SEG *seg = (SEG *) PG_GETARG_POINTER(0); PG_RETURN_FLOAT4(((float) seg->lower + (float) seg->upper) / 2.0); } @@ -176,7 +176,7 @@ seg_center(PG_FUNCTION_ARGS) Datum seg_lower(PG_FUNCTION_ARGS) { - SEG *seg = (SEG *) PG_GETARG_POINTER(0); + SEG *seg = (SEG *) PG_GETARG_POINTER(0); PG_RETURN_FLOAT4(seg->lower); } @@ -184,7 +184,7 @@ seg_lower(PG_FUNCTION_ARGS) Datum seg_upper(PG_FUNCTION_ARGS) { - SEG *seg = (SEG *) PG_GETARG_POINTER(0); + SEG *seg = (SEG *) PG_GETARG_POINTER(0); PG_RETURN_FLOAT4(seg->upper); } @@ -202,7 +202,7 @@ seg_upper(PG_FUNCTION_ARGS) */ bool gseg_consistent(GISTENTRY *entry, - SEG * query, + SEG *query, StrategyNumber strategy, Oid subtype, bool *recheck) @@ -449,7 +449,7 @@ gseg_picksplit(GistEntryVector *entryvec, ** Equality methods */ bool * -gseg_same(SEG * b1, SEG * b2, bool *result) +gseg_same(SEG *b1, SEG *b2, bool *result) { if (seg_same(b1, b2)) *result = TRUE; @@ -467,8 +467,8 @@ gseg_same(SEG * b1, SEG * b2, bool *result) ** SUPPORT ROUTINES */ bool -gseg_leaf_consistent(SEG * key, - SEG * query, +gseg_leaf_consistent(SEG *key, + SEG *query, StrategyNumber strategy) { bool retval; @@ -512,8 +512,8 @@ gseg_leaf_consistent(SEG * key, } bool -gseg_internal_consistent(SEG * key, - SEG * query, +gseg_internal_consistent(SEG *key, + SEG *query, StrategyNumber strategy) { bool retval; @@ -555,7 +555,7 @@ gseg_internal_consistent(SEG * key, } SEG * -gseg_binary_union(SEG * r1, SEG * r2, int *sizep) +gseg_binary_union(SEG *r1, SEG *r2, int *sizep) { SEG *retval; @@ -567,13 +567,13 @@ gseg_binary_union(SEG * r1, SEG * r2, int *sizep) bool -seg_contains(SEG * a, SEG * b) +seg_contains(SEG *a, SEG *b) { return ((a->lower <= b->lower) && (a->upper >= b->upper)); } bool -seg_contained(SEG * a, SEG * b) +seg_contained(SEG *a, SEG *b) { return (seg_contains(b, a)); } @@ -583,7 +583,7 @@ seg_contained(SEG * a, SEG * b) *****************************************************************************/ bool -seg_same(SEG * a, SEG * b) +seg_same(SEG *a, SEG *b) { return seg_cmp(a, b) == 0; } @@ -591,7 +591,7 @@ seg_same(SEG * a, SEG * b) /* seg_overlap -- does a overlap b? */ bool -seg_overlap(SEG * a, SEG * b) +seg_overlap(SEG *a, SEG *b) { return ( ((a->upper >= b->upper) && (a->lower <= b->upper)) @@ -603,7 +603,7 @@ seg_overlap(SEG * a, SEG * b) /* seg_overleft -- is the right edge of (a) located at or left of the right edge of (b)? */ bool -seg_over_left(SEG * a, SEG * b) +seg_over_left(SEG *a, SEG *b) { return (a->upper <= b->upper); } @@ -611,7 +611,7 @@ seg_over_left(SEG * a, SEG * b) /* seg_left -- is (a) entirely on the left of (b)? */ bool -seg_left(SEG * a, SEG * b) +seg_left(SEG *a, SEG *b) { return (a->upper < b->lower); } @@ -619,7 +619,7 @@ seg_left(SEG * a, SEG * b) /* seg_right -- is (a) entirely on the right of (b)? */ bool -seg_right(SEG * a, SEG * b) +seg_right(SEG *a, SEG *b) { return (a->lower > b->upper); } @@ -627,14 +627,14 @@ seg_right(SEG * a, SEG * b) /* seg_overright -- is the left edge of (a) located at or right of the left edge of (b)? */ bool -seg_over_right(SEG * a, SEG * b) +seg_over_right(SEG *a, SEG *b) { return (a->lower >= b->lower); } SEG * -seg_union(SEG * a, SEG * b) +seg_union(SEG *a, SEG *b) { SEG *n; @@ -673,7 +673,7 @@ seg_union(SEG * a, SEG * b) SEG * -seg_inter(SEG * a, SEG * b) +seg_inter(SEG *a, SEG *b) { SEG *n; @@ -711,7 +711,7 @@ seg_inter(SEG * a, SEG * b) } void -rt_seg_size(SEG * a, float *size) +rt_seg_size(SEG *a, float *size) { if (a == (SEG *) NULL || a->upper <= a->lower) *size = 0.0; @@ -724,7 +724,7 @@ rt_seg_size(SEG * a, float *size) Datum seg_size(PG_FUNCTION_ARGS) { - SEG *seg = (SEG *) PG_GETARG_POINTER(0); + SEG *seg = (SEG *) PG_GETARG_POINTER(0); PG_RETURN_FLOAT4((float) Abs(seg->upper - seg->lower)); } @@ -734,7 +734,7 @@ seg_size(PG_FUNCTION_ARGS) * Miscellaneous operators *****************************************************************************/ int32 -seg_cmp(SEG * a, SEG * b) +seg_cmp(SEG *a, SEG *b) { /* * First compare on lower boundary position @@ -853,31 +853,31 @@ seg_cmp(SEG * a, SEG * b) } bool -seg_lt(SEG * a, SEG * b) +seg_lt(SEG *a, SEG *b) { return seg_cmp(a, b) < 0; } bool -seg_le(SEG * a, SEG * b) +seg_le(SEG *a, SEG *b) { return seg_cmp(a, b) <= 0; } bool -seg_gt(SEG * a, SEG * b) +seg_gt(SEG *a, SEG *b) { return seg_cmp(a, b) > 0; } bool -seg_ge(SEG * a, SEG * b) +seg_ge(SEG *a, SEG *b) { return seg_cmp(a, b) >= 0; } bool -seg_different(SEG * a, SEG * b) +seg_different(SEG *a, SEG *b) { return seg_cmp(a, b) != 0; } @@ -1042,19 +1042,19 @@ restore(char *result, float val, int n) */ bool -seg_contains_int(SEG * a, int *b) +seg_contains_int(SEG *a, int *b) { return ((a->lower <= *b) && (a->upper >= *b)); } bool -seg_contains_float4(SEG * a, float4 *b) +seg_contains_float4(SEG *a, float4 *b) { return ((a->lower <= *b) && (a->upper >= *b)); } bool -seg_contains_float8(SEG * a, float8 *b) +seg_contains_float8(SEG *a, float8 *b) { return ((a->lower <= *b) && (a->upper >= *b)); } diff --git a/contrib/seg/segdata.h b/contrib/seg/segdata.h index ce177fb80b..c92854da83 100644 --- a/contrib/seg/segdata.h +++ b/contrib/seg/segdata.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/seg/segdata.h,v 1.5 2008/05/17 01:28:22 adunstan Exp $ + * $PostgreSQL: pgsql/contrib/seg/segdata.h,v 1.6 2009/06/11 14:48:52 momjian Exp $ */ typedef struct SEG { @@ -9,4 +9,4 @@ typedef struct SEG char u_sigd; char l_ext; char u_ext; -} SEG; +} SEG; diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c index f555414664..f79317a1b1 100644 --- a/contrib/spi/autoinc.c +++ b/contrib/spi/autoinc.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/spi/autoinc.c,v 1.16 2009/01/07 13:44:36 tgl Exp $ + * $PostgreSQL: pgsql/contrib/spi/autoinc.c,v 1.17 2009/06/11 14:48:52 momjian Exp $ */ #include "postgres.h" diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c index aaef7b4977..5a446c3709 100644 --- a/contrib/spi/refint.c +++ b/contrib/spi/refint.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/spi/refint.c,v 1.34 2009/01/07 13:44:36 tgl Exp $ + * $PostgreSQL: pgsql/contrib/spi/refint.c,v 1.35 2009/06/11 14:48:52 momjian Exp $ * * * refint.c -- set of functions to define referential integrity @@ -24,14 +24,14 @@ typedef struct char *ident; int nplans; SPIPlanPtr *splan; -} EPlan; +} EPlan; static EPlan *FPlans = NULL; static int nFPlans = 0; static EPlan *PPlans = NULL; static int nPPlans = 0; -static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans); +static EPlan *find_plan(char *ident, EPlan **eplan, int *nplans); /* * check_primary_key () -- check that key in tuple being inserted/updated @@ -613,7 +613,7 @@ check_foreign_key(PG_FUNCTION_ARGS) } static EPlan * -find_plan(char *ident, EPlan ** eplan, int *nplans) +find_plan(char *ident, EPlan **eplan, int *nplans) { EPlan *newp; int i; diff --git a/contrib/spi/timetravel.c b/contrib/spi/timetravel.c index a949d2d817..577767d81f 100644 --- a/contrib/spi/timetravel.c +++ b/contrib/spi/timetravel.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/spi/timetravel.c,v 1.30 2009/01/07 13:44:36 tgl Exp $ + * $PostgreSQL: pgsql/contrib/spi/timetravel.c,v 1.31 2009/06/11 14:48:52 momjian Exp $ * * * timetravel.c -- function to get time travel feature @@ -29,7 +29,7 @@ typedef struct { char *ident; SPIPlanPtr splan; -} EPlan; +} EPlan; static EPlan *Plans = NULL; /* for UPDATE/DELETE */ static int nPlans = 0; @@ -38,12 +38,12 @@ typedef struct _TTOffList { struct _TTOffList *next; char name[1]; -} TTOffList; +} TTOffList; static TTOffList TTOff = {NULL, {0}}; static int findTTStatus(char *name); -static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans); +static EPlan *find_plan(char *ident, EPlan **eplan, int *nplans); /* * timetravel () -- @@ -517,7 +517,7 @@ currabstime() */ static EPlan * -find_plan(char *ident, EPlan ** eplan, int *nplans) +find_plan(char *ident, EPlan **eplan, int *nplans) { EPlan *newp; int i; diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 5829c84111..48512bd934 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.59 2009/01/07 13:44:36 tgl Exp $ + * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.60 2009/06/11 14:48:52 momjian Exp $ * * * tablefunc @@ -93,7 +93,7 @@ typedef struct float8 stddev; /* stddev of the distribution */ float8 carry_val; /* hold second generated value */ bool use_carry; /* use second generated value */ -} normal_rand_fctx; +} normal_rand_fctx; #define xpfree(var_) \ do { \ @@ -124,7 +124,7 @@ typedef struct crosstab_cat_desc { char *catname; /* full category name */ int attidx; /* zero based */ -} crosstab_cat_desc; +} crosstab_cat_desc; #define MAX_CATNAME_LEN NAMEDATALEN #define INIT_CATS 64 @@ -163,7 +163,7 @@ typedef struct crosstab_hashent { char internal_catname[MAX_CATNAME_LEN]; crosstab_cat_desc *catdesc; -} crosstab_HashEnt; +} crosstab_HashEnt; /* * normal_rand - return requested number of random values @@ -440,8 +440,8 @@ crosstab(PG_FUNCTION_ARGS) } /* - * Check that return tupdesc is compatible with the data we got from - * SPI, at least based on number and type of attributes + * Check that return tupdesc is compatible with the data we got from SPI, + * at least based on number and type of attributes */ if (!compatCrosstabTupleDescs(tupdesc, spi_tupdesc)) ereport(ERROR, @@ -465,8 +465,8 @@ crosstab(PG_FUNCTION_ARGS) MemoryContextSwitchTo(oldcontext); /* - * Generate attribute metadata needed later to produce tuples from raw - * C strings + * Generate attribute metadata needed later to produce tuples from raw C + * strings */ attinmeta = TupleDescGetAttInMetadata(tupdesc); @@ -488,8 +488,8 @@ crosstab(PG_FUNCTION_ARGS) values = (char **) palloc0((1 + num_categories) * sizeof(char *)); /* - * now loop through the sql results and assign each value in - * sequence to the next category + * now loop through the sql results and assign each value in sequence + * to the next category */ for (i = 0; i < num_categories; i++) { @@ -507,16 +507,16 @@ crosstab(PG_FUNCTION_ARGS) rowid = SPI_getvalue(spi_tuple, spi_tupdesc, 1); /* - * If this is the first pass through the values for this - * rowid, set the first column to rowid + * If this is the first pass through the values for this rowid, + * set the first column to rowid */ if (i == 0) { xpstrdup(values[0], rowid); /* - * Check to see if the rowid is the same as that of the - * last tuple sent -- if so, skip this tuple entirely + * Check to see if the rowid is the same as that of the last + * tuple sent -- if so, skip this tuple entirely */ if (!firstpass && xstreq(lastrowid, rowid)) { @@ -533,18 +533,18 @@ crosstab(PG_FUNCTION_ARGS) if (xstreq(rowid, values[0])) { /* - * Get the next category item value, which is always - * attribute number three. + * Get the next category item value, which is always attribute + * number three. * - * Be careful to assign the value to the array index based - * on which category we are presently processing. + * Be careful to assign the value to the array index based on + * which category we are presently processing. */ values[1 + i] = SPI_getvalue(spi_tuple, spi_tupdesc, 3); /* * increment the counter since we consume a row for each - * category, but not for last pass because the outer loop - * will do that for us + * category, but not for last pass because the outer loop will + * do that for us */ if (i < (num_categories - 1)) call_cntr++; @@ -553,9 +553,9 @@ crosstab(PG_FUNCTION_ARGS) else { /* - * We'll fill in NULLs for the missing values, but we need - * to decrement the counter since this sql result row - * doesn't belong to the current output tuple. + * We'll fill in NULLs for the missing values, but we need to + * decrement the counter since this sql result row doesn't + * belong to the current output tuple. */ call_cntr--; xpfree(rowid); @@ -690,7 +690,7 @@ crosstab_hash(PG_FUNCTION_ARGS) crosstab_hash, tupdesc, per_query_ctx, - rsinfo->allowedModes & SFRM_Materialize_Random); + rsinfo->allowedModes & SFRM_Materialize_Random); /* * SFRM_Materialize mode expects us to return a NULL Datum. The actual @@ -1059,7 +1059,7 @@ connectby_text(PG_FUNCTION_ARGS) show_branch, show_serial, per_query_ctx, - rsinfo->allowedModes & SFRM_Materialize_Random, + rsinfo->allowedModes & SFRM_Materialize_Random, attinmeta); rsinfo->setDesc = tupdesc; @@ -1139,7 +1139,7 @@ connectby_text_serial(PG_FUNCTION_ARGS) show_branch, show_serial, per_query_ctx, - rsinfo->allowedModes & SFRM_Materialize_Random, + rsinfo->allowedModes & SFRM_Materialize_Random, attinmeta); rsinfo->setDesc = tupdesc; @@ -1603,7 +1603,7 @@ quote_literal_cstr(char *rawstr) rawstr_text = cstring_to_text(rawstr); result_text = DatumGetTextP(DirectFunctionCall1(quote_literal, - PointerGetDatum(rawstr_text))); + PointerGetDatum(rawstr_text))); result = text_to_cstring(result_text); return result; diff --git a/contrib/tablefunc/tablefunc.h b/contrib/tablefunc/tablefunc.h index b2044cbc14..f884b55c33 100644 --- a/contrib/tablefunc/tablefunc.h +++ b/contrib/tablefunc/tablefunc.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.h,v 1.15 2009/01/01 17:23:32 momjian Exp $ + * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.h,v 1.16 2009/06/11 14:48:52 momjian Exp $ * * * tablefunc diff --git a/contrib/test_parser/test_parser.c b/contrib/test_parser/test_parser.c index e3634a8355..2317f25d0f 100644 --- a/contrib/test_parser/test_parser.c +++ b/contrib/test_parser/test_parser.c @@ -6,7 +6,7 @@ * Copyright (c) 2007-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/test_parser/test_parser.c,v 1.5 2009/01/01 17:23:32 momjian Exp $ + * $PostgreSQL: pgsql/contrib/test_parser/test_parser.c,v 1.6 2009/06/11 14:48:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ typedef struct char *buffer; /* text to parse */ int len; /* length of the text in buffer */ int pos; /* position of the parser */ -} ParserState; +} ParserState; /* copy-paste from wparser.h of tsearch2 */ typedef struct diff --git a/contrib/tsearch2/tsearch2.c b/contrib/tsearch2/tsearch2.c index 2544bc24c1..2452ec69b4 100644 --- a/contrib/tsearch2/tsearch2.c +++ b/contrib/tsearch2/tsearch2.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.9 2009/01/28 18:31:32 teodor Exp $ + * $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.10 2009/06/11 14:48:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -367,7 +367,7 @@ tsa_tsearch2(PG_FUNCTION_ARGS) { TriggerData *trigdata; Trigger *trigger; - char **tgargs, + char **tgargs, **tgargs_old; int i; Datum res; diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c index 9ab70f9431..71db0ac269 100644 --- a/contrib/uuid-ossp/uuid-ossp.c +++ b/contrib/uuid-ossp/uuid-ossp.c @@ -4,7 +4,7 @@ * * Copyright (c) 2007-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.10 2009/01/01 18:21:19 momjian Exp $ + * $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.11 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,7 +67,7 @@ PG_FUNCTION_INFO_V1(uuid_generate_v5); static void pguuid_complain(uuid_rc_t rc) { - char *err = uuid_error(rc); + char *err = uuid_error(rc); if (err != NULL) ereport(ERROR, @@ -80,7 +80,7 @@ pguuid_complain(uuid_rc_t rc) } static char * -uuid_to_string(const uuid_t * uuid) +uuid_to_string(const uuid_t *uuid) { char *buf = palloc(UUID_LEN_STR + 1); void *ptr = buf; @@ -96,7 +96,7 @@ uuid_to_string(const uuid_t * uuid) static void -string_to_uuid(const char *str, uuid_t * uuid) +string_to_uuid(const char *str, uuid_t *uuid) { uuid_rc_t rc; @@ -164,7 +164,7 @@ uuid_ns_x500(PG_FUNCTION_ARGS) static Datum -uuid_generate_internal(int mode, const uuid_t * ns, const char *name) +uuid_generate_internal(int mode, const uuid_t *ns, const char *name) { uuid_t *uuid; char *str; diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index d5244a1ce3..203e53905b 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.22 2009/01/07 13:44:36 tgl Exp $ + * $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.23 2009/06/11 14:48:53 momjian Exp $ * * Parser interface for DOM-based parser (libxml) rather than * stream-based SAX-type parser @@ -36,15 +36,15 @@ void elog_error(int level, char *explain, int force); void pgxml_parser_init(void); static xmlChar *pgxmlNodeSetToText(xmlNodeSetPtr nodeset, - xmlChar * toptagname, xmlChar * septagname, - xmlChar * plainsep); + xmlChar *toptagname, xmlChar *septagname, + xmlChar *plainsep); -text *pgxml_result_to_text(xmlXPathObjectPtr res, xmlChar * toptag, - xmlChar * septag, xmlChar * plainsep); +text *pgxml_result_to_text(xmlXPathObjectPtr res, xmlChar *toptag, + xmlChar *septag, xmlChar *plainsep); xmlChar *pgxml_texttoxmlchar(text *textstring); -static xmlXPathObjectPtr pgxml_xpath(text *document, xmlChar * xpath); +static xmlXPathObjectPtr pgxml_xpath(text *document, xmlChar *xpath); Datum xml_is_well_formed(PG_FUNCTION_ARGS); @@ -216,11 +216,11 @@ xml_encode_special_chars(PG_FUNCTION_ARGS) } static xmlChar -* + * pgxmlNodeSetToText(xmlNodeSetPtr nodeset, - xmlChar * toptagname, - xmlChar * septagname, - xmlChar * plainsep) + xmlChar *toptagname, + xmlChar *septagname, + xmlChar *plainsep) { /* Function translates a nodeset into a text representation */ @@ -510,7 +510,7 @@ xpath_bool(PG_FUNCTION_ARGS) /* Core function to evaluate XPath query */ xmlXPathObjectPtr -pgxml_xpath(text *document, xmlChar * xpath) +pgxml_xpath(text *document, xmlChar *xpath) { xmlDocPtr doctree; @@ -566,9 +566,9 @@ pgxml_xpath(text *document, xmlChar * xpath) text * pgxml_result_to_text(xmlXPathObjectPtr res, - xmlChar * toptag, - xmlChar * septag, - xmlChar * plainsep) + xmlChar *toptag, + xmlChar *septag, + xmlChar *plainsep) { xmlChar *xpresstr; text *xpres; @@ -814,7 +814,7 @@ xpath_table(PG_FUNCTION_ARGS) /* Parse the document */ if (xmldoc) doctree = xmlParseMemory(xmldoc, strlen(xmldoc)); - else /* treat NULL as not well-formed */ + else /* treat NULL as not well-formed */ doctree = NULL; if (doctree == NULL) diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c index 4ca176ed2e..08816b273a 100644 --- a/contrib/xml2/xslt_proc.c +++ b/contrib/xml2/xslt_proc.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.14 2009/01/07 13:44:36 tgl Exp $ + * $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.15 2009/06/11 14:48:53 momjian Exp $ * * XSLT processing functions (requiring libxslt) * diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index 6499549177..ac5749c713 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -50,7 +50,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.126 2009/03/30 04:08:43 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.127 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -388,7 +388,7 @@ nocachegetattr(HeapTuple tuple, * Now check to see if any preceding bits are null... */ { - int byte = attnum >> 3; + int byte = attnum >> 3; int finalbit = attnum & 0x07; /* check for nulls "before" final bit of last byte */ @@ -1183,7 +1183,7 @@ slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull) { if (tuple == NULL) /* internal error */ elog(ERROR, "cannot extract system attribute from virtual tuple"); - if (tuple == &(slot->tts_minhdr)) /* internal error */ + if (tuple == &(slot->tts_minhdr)) /* internal error */ elog(ERROR, "cannot extract system attribute from minimal tuple"); return heap_getsysattr(tuple, attnum, tupleDesc, isnull); } @@ -1369,7 +1369,7 @@ slot_attisnull(TupleTableSlot *slot, int attnum) { if (tuple == NULL) /* internal error */ elog(ERROR, "cannot extract system attribute from virtual tuple"); - if (tuple == &(slot->tts_minhdr)) /* internal error */ + if (tuple == &(slot->tts_minhdr)) /* internal error */ elog(ERROR, "cannot extract system attribute from minimal tuple"); return heap_attisnull(tuple, attnum); } diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index 839d242913..cd3b88654b 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.87 2009/01/01 17:23:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.88 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,7 +86,7 @@ index_form_tuple(TupleDesc tupleDescriptor, * try to compress it in-line. */ if (!VARATT_IS_EXTENDED(DatumGetPointer(untoasted_values[i])) && - VARSIZE(DatumGetPointer(untoasted_values[i])) > TOAST_INDEX_TARGET && + VARSIZE(DatumGetPointer(untoasted_values[i])) > TOAST_INDEX_TARGET && (att->attstorage == 'x' || att->attstorage == 'm')) { Datum cvalue = toast_compress_datum(untoasted_values[i]); @@ -270,7 +270,7 @@ nocache_index_getattr(IndexTuple tup, * Now check to see if any preceding bits are null... */ { - int byte = attnum >> 3; + int byte = attnum >> 3; int finalbit = attnum & 0x07; /* check for nulls "before" final bit of last byte */ diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 324c978132..13a09dd9b3 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.104 2009/01/01 17:23:34 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.105 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -71,7 +71,7 @@ printtup_create_DR(CommandDest dest) { DR_printtup *self = (DR_printtup *) palloc0(sizeof(DR_printtup)); - self->pub.receiveSlot = printtup; /* might get changed later */ + self->pub.receiveSlot = printtup; /* might get changed later */ self->pub.rStartup = printtup_startup; self->pub.rShutdown = printtup_shutdown; self->pub.rDestroy = printtup_destroy; diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 2668fd8bfe..b970601b1c 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.27 2009/05/24 22:22:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.28 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,7 +65,7 @@ static relopt_bool boolRelOpts[] = true }, /* list terminator */ - { { NULL } } + {{NULL}} }; static relopt_int intRelOpts[] = @@ -158,7 +158,7 @@ static relopt_int intRelOpts[] = }, 150000000, 0, 2000000000 }, /* list terminator */ - { { NULL } } + {{NULL}} }; static relopt_real realRelOpts[] = @@ -180,21 +180,21 @@ static relopt_real realRelOpts[] = 0.1, 0.0, 100.0 }, /* list terminator */ - { { NULL } } + {{NULL}} }; static relopt_string stringRelOpts[] = { /* list terminator */ - { { NULL } } + {{NULL}} }; static relopt_gen **relOpts = NULL; static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT; -static int num_custom_options = 0; +static int num_custom_options = 0; static relopt_gen **custom_options = NULL; -static bool need_initialization = true; +static bool need_initialization = true; static void initialize_reloptions(void); static void parse_one_reloption(relopt_value *option, char *text_str, @@ -202,15 +202,15 @@ static void parse_one_reloption(relopt_value *option, char *text_str, /* * initialize_reloptions - * initialization routine, must be called before parsing + * initialization routine, must be called before parsing * * Initialize the relOpts array and fill each variable's type and name length. */ static void initialize_reloptions(void) { - int i; - int j = 0; + int i; + int j = 0; for (i = 0; boolRelOpts[i].gen.name; i++) j++; @@ -272,8 +272,8 @@ initialize_reloptions(void) /* * add_reloption_kind - * Create a new relopt_kind value, to be used in custom reloptions by - * user-defined AMs. + * Create a new relopt_kind value, to be used in custom reloptions by + * user-defined AMs. */ relopt_kind add_reloption_kind(void) @@ -282,24 +282,24 @@ add_reloption_kind(void) if (last_assigned_kind >= RELOPT_KIND_MAX) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("user-defined relation parameter types limit exceeded"))); + errmsg("user-defined relation parameter types limit exceeded"))); last_assigned_kind <<= 1; return (relopt_kind) last_assigned_kind; } /* * add_reloption - * Add an already-created custom reloption to the list, and recompute the - * main parser table. + * Add an already-created custom reloption to the list, and recompute the + * main parser table. */ static void add_reloption(relopt_gen *newoption) { - static int max_custom_options = 0; + static int max_custom_options = 0; if (num_custom_options >= max_custom_options) { - MemoryContext oldcxt; + MemoryContext oldcxt; oldcxt = MemoryContextSwitchTo(TopMemoryContext); @@ -312,7 +312,7 @@ add_reloption(relopt_gen *newoption) { max_custom_options *= 2; custom_options = repalloc(custom_options, - max_custom_options * sizeof(relopt_gen *)); + max_custom_options * sizeof(relopt_gen *)); } MemoryContextSwitchTo(oldcxt); } @@ -323,15 +323,15 @@ add_reloption(relopt_gen *newoption) /* * allocate_reloption - * Allocate a new reloption and initialize the type-agnostic fields - * (for types other than string) + * Allocate a new reloption and initialize the type-agnostic fields + * (for types other than string) */ static relopt_gen * allocate_reloption(bits32 kinds, int type, char *name, char *desc) { - MemoryContext oldcxt; - size_t size; - relopt_gen *newoption; + MemoryContext oldcxt; + size_t size; + relopt_gen *newoption; Assert(type != RELOPT_TYPE_STRING); @@ -350,7 +350,7 @@ allocate_reloption(bits32 kinds, int type, char *name, char *desc) break; default: elog(ERROR, "unsupported option type"); - return NULL; /* keep compiler quiet */ + return NULL; /* keep compiler quiet */ } newoption = palloc(size); @@ -371,12 +371,12 @@ allocate_reloption(bits32 kinds, int type, char *name, char *desc) /* * add_bool_reloption - * Add a new boolean reloption + * Add a new boolean reloption */ void add_bool_reloption(bits32 kinds, char *name, char *desc, bool default_val) { - relopt_bool *newoption; + relopt_bool *newoption; newoption = (relopt_bool *) allocate_reloption(kinds, RELOPT_TYPE_BOOL, name, desc); @@ -387,13 +387,13 @@ add_bool_reloption(bits32 kinds, char *name, char *desc, bool default_val) /* * add_int_reloption - * Add a new integer reloption + * Add a new integer reloption */ void add_int_reloption(bits32 kinds, char *name, char *desc, int default_val, int min_val, int max_val) { - relopt_int *newoption; + relopt_int *newoption; newoption = (relopt_int *) allocate_reloption(kinds, RELOPT_TYPE_INT, name, desc); @@ -406,13 +406,13 @@ add_int_reloption(bits32 kinds, char *name, char *desc, int default_val, /* * add_real_reloption - * Add a new float reloption + * Add a new float reloption */ void add_real_reloption(bits32 kinds, char *name, char *desc, double default_val, - double min_val, double max_val) + double min_val, double max_val) { - relopt_real *newoption; + relopt_real *newoption; newoption = (relopt_real *) allocate_reloption(kinds, RELOPT_TYPE_REAL, name, desc); @@ -428,7 +428,7 @@ add_real_reloption(bits32 kinds, char *name, char *desc, double default_val, * Add a new string reloption * * "validator" is an optional function pointer that can be used to test the - * validity of the values. It must elog(ERROR) when the argument string is + * validity of the values. It must elog(ERROR) when the argument string is * not acceptable for the variable. Note that the default value must pass * the validation. */ @@ -436,9 +436,9 @@ void add_string_reloption(bits32 kinds, char *name, char *desc, char *default_val, validate_string_relopt validator) { - MemoryContext oldcxt; - relopt_string *newoption; - int default_len = 0; + MemoryContext oldcxt; + relopt_string *newoption; + int default_len = 0; oldcxt = MemoryContextSwitchTo(TopMemoryContext); @@ -495,7 +495,7 @@ add_string_reloption(bits32 kinds, char *name, char *desc, char *default_val, * Note that this is not responsible for determining whether the options * are valid, but it does check that namespaces for all the options given are * listed in validnsps. The NULL namespace is always valid and needs not be - * explicitely listed. Passing a NULL pointer means that only the NULL + * explicitely listed. Passing a NULL pointer means that only the NULL * namespace is valid. * * Both oldOptions and the result are text arrays (or NULL for "default"), @@ -538,7 +538,7 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace, /* Search for a match in defList */ foreach(cell, defList) { - DefElem *def = (DefElem *) lfirst(cell); + DefElem *def = (DefElem *) lfirst(cell); int kw_len; /* ignore if not in the same namespace */ @@ -574,7 +574,7 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace, */ foreach(cell, defList) { - DefElem *def = (DefElem *) lfirst(cell); + DefElem *def = (DefElem *) lfirst(cell); if (isReset) { @@ -590,13 +590,13 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace, Size len; /* - * Error out if the namespace is not valid. A NULL namespace - * is always valid. + * Error out if the namespace is not valid. A NULL namespace is + * always valid. */ if (def->defnamespace != NULL) { - bool valid = false; - int i; + bool valid = false; + int i; if (validnsps) { @@ -719,10 +719,10 @@ untransformRelOptions(Datum options) bytea * extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, Oid amoptions) { - bytea *options; - bool isnull; - Datum datum; - Form_pg_class classForm; + bytea *options; + bool isnull; + Datum datum; + Form_pg_class classForm; datum = fastgetattr(tuple, Anum_pg_class_reloptions, @@ -768,7 +768,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, Oid amoptions) * is returned. * * Note: values of type int, bool and real are allocated as part of the - * returned array. Values of type string are allocated separately and must + * returned array. Values of type string are allocated separately and must * be freed by the caller. */ relopt_value * @@ -894,31 +894,31 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len, parsed = parse_bool(value, &option->values.bool_val); if (validate && !parsed) ereport(ERROR, - (errmsg("invalid value for boolean option \"%s\": %s", - option->gen->name, value))); + (errmsg("invalid value for boolean option \"%s\": %s", + option->gen->name, value))); } break; case RELOPT_TYPE_INT: { - relopt_int *optint = (relopt_int *) option->gen; + relopt_int *optint = (relopt_int *) option->gen; parsed = parse_int(value, &option->values.int_val, 0, NULL); if (validate && !parsed) ereport(ERROR, - (errmsg("invalid value for integer option \"%s\": %s", - option->gen->name, value))); + (errmsg("invalid value for integer option \"%s\": %s", + option->gen->name, value))); if (validate && (option->values.int_val < optint->min || option->values.int_val > optint->max)) ereport(ERROR, - (errmsg("value %s out of bounds for option \"%s\"", - value, option->gen->name), - errdetail("Valid values are between \"%d\" and \"%d\".", - optint->min, optint->max))); + (errmsg("value %s out of bounds for option \"%s\"", + value, option->gen->name), + errdetail("Valid values are between \"%d\" and \"%d\".", + optint->min, optint->max))); } break; case RELOPT_TYPE_REAL: { - relopt_real *optreal = (relopt_real *) option->gen; + relopt_real *optreal = (relopt_real *) option->gen; parsed = parse_real(value, &option->values.real_val); if (validate && !parsed) @@ -928,15 +928,15 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len, if (validate && (option->values.real_val < optreal->min || option->values.real_val > optreal->max)) ereport(ERROR, - (errmsg("value %s out of bounds for option \"%s\"", - value, option->gen->name), - errdetail("Valid values are between \"%f\" and \"%f\".", - optreal->min, optreal->max))); + (errmsg("value %s out of bounds for option \"%s\"", + value, option->gen->name), + errdetail("Valid values are between \"%f\" and \"%f\".", + optreal->min, optreal->max))); } break; case RELOPT_TYPE_STRING: { - relopt_string *optstring = (relopt_string *) option->gen; + relopt_string *optstring = (relopt_string *) option->gen; option->values.string_val = value; nofree = true; @@ -947,7 +947,7 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len, break; default: elog(ERROR, "unsupported reloption type %d", option->gen->type); - parsed = true; /* quiet compiler */ + parsed = true; /* quiet compiler */ break; } @@ -967,8 +967,8 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len, void * allocateReloptStruct(Size base, relopt_value *options, int numoptions) { - Size size = base; - int i; + Size size = base; + int i; for (i = 0; i < numoptions; i++) if (options[i].gen->type == RELOPT_TYPE_STRING) @@ -994,21 +994,21 @@ fillRelOptions(void *rdopts, Size basesize, bool validate, const relopt_parse_elt *elems, int numelems) { - int i; - int offset = basesize; + int i; + int offset = basesize; for (i = 0; i < numoptions; i++) { - int j; - bool found = false; + int j; + bool found = false; for (j = 0; j < numelems; j++) { if (pg_strcasecmp(options[i].gen->name, elems[j].optname) == 0) { relopt_string *optstring; - char *itempos = ((char *) rdopts) + elems[j].offset; - char *string_val; + char *itempos = ((char *) rdopts) + elems[j].offset; + char *string_val; switch (options[i].gen->type) { @@ -1069,31 +1069,31 @@ fillRelOptions(void *rdopts, Size basesize, bytea * default_reloptions(Datum reloptions, bool validate, relopt_kind kind) { - relopt_value *options; - StdRdOptions *rdopts; - int numoptions; + relopt_value *options; + StdRdOptions *rdopts; + int numoptions; static const relopt_parse_elt tab[] = { {"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)}, {"autovacuum_enabled", RELOPT_TYPE_BOOL, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, enabled)}, {"autovacuum_vacuum_threshold", RELOPT_TYPE_INT, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_threshold)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_threshold)}, {"autovacuum_analyze_threshold", RELOPT_TYPE_INT, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_threshold)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, analyze_threshold)}, {"autovacuum_vacuum_cost_delay", RELOPT_TYPE_INT, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_delay)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_cost_delay)}, {"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_limit)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_cost_limit)}, {"autovacuum_freeze_min_age", RELOPT_TYPE_INT, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_min_age)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_min_age)}, {"autovacuum_freeze_max_age", RELOPT_TYPE_INT, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_max_age)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_max_age)}, {"autovacuum_freeze_table_age", RELOPT_TYPE_INT, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_table_age)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_table_age)}, {"autovacuum_vacuum_scale_factor", RELOPT_TYPE_REAL, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_scale_factor)}, + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_scale_factor)}, {"autovacuum_analyze_scale_factor", RELOPT_TYPE_REAL, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_scale_factor)} + offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, analyze_scale_factor)} }; options = parseRelOptions(reloptions, validate, kind, &numoptions); diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index ea16913c8e..79efec0969 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.125 2009/01/22 20:16:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.126 2009/06/11 14:48:53 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -55,8 +55,8 @@ CreateTemplateTupleDesc(int natts, bool hasoid) * pointers. * * Note: Only the fixed part of pg_attribute rows is included in tuple - * descriptors, so we only need ATTRIBUTE_FIXED_PART_SIZE space - * per attr. That might need alignment padding, however. + * descriptors, so we only need ATTRIBUTE_FIXED_PART_SIZE space per attr. + * That might need alignment padding, however. */ attroffset = sizeof(struct tupleDesc) + natts * sizeof(Form_pg_attribute); attroffset = MAXALIGN(attroffset); diff --git a/src/backend/access/gin/ginarrayproc.c b/src/backend/access/gin/ginarrayproc.c index 717caaad8b..feff95f1d8 100644 --- a/src/backend/access/gin/ginarrayproc.c +++ b/src/backend/access/gin/ginarrayproc.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.15 2009/03/25 22:19:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.16 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -95,6 +95,7 @@ ginarrayconsistent(PG_FUNCTION_ARGS) bool *check = (bool *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); + /* int32 nkeys = PG_GETARG_INT32(3); */ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ bool *recheck = (bool *) PG_GETARG_POINTER(5); diff --git a/src/backend/access/gin/ginbulk.c b/src/backend/access/gin/ginbulk.c index a7258619ae..2e800ce44a 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.15 2009/03/24 20:17:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginbulk.c,v 1.16 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ @@ -84,7 +84,7 @@ ginInsertData(BuildAccumulator *accum, EntryAccumulator *entry, ItemPointer heap static Datum getDatumCopy(BuildAccumulator *accum, OffsetNumber attnum, Datum value) { - Form_pg_attribute att = accum->ginstate->origTupdesc->attrs[ attnum - 1 ]; + Form_pg_attribute att = accum->ginstate->origTupdesc->attrs[attnum - 1]; Datum res; if (att->attbyval) @@ -161,8 +161,8 @@ ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum * then calls itself for each parts */ static void -ginChooseElem(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, - Datum *entries, uint32 nentry, +ginChooseElem(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, + Datum *entries, uint32 nentry, uint32 low, uint32 high, uint32 offset) { uint32 pos; @@ -187,8 +187,8 @@ ginChooseElem(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, * next middle on left part and middle of right part. */ void -ginInsertRecordBA(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, - Datum *entries, int32 nentry) +ginInsertRecordBA(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber attnum, + Datum *entries, int32 nentry) { uint32 i, nbit = 0, diff --git a/src/backend/access/gin/gindatapage.c b/src/backend/access/gin/gindatapage.c index 22199102dd..ebbdaa33e5 100644 --- a/src/backend/access/gin/gindatapage.c +++ b/src/backend/access/gin/gindatapage.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/gindatapage.c,v 1.15 2009/06/06 02:39:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/gindatapage.c,v 1.16 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ @@ -47,7 +47,7 @@ MergeItemPointers(ItemPointerData *dst, while (aptr - a < na && bptr - b < nb) { - int cmp = compareItemPointers(aptr, bptr); + int cmp = compareItemPointers(aptr, bptr); if (cmp > 0) *dptr++ = *bptr++; diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c index f35994db95..c4659cde1f 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.20 2009/06/06 02:39:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.21 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ @@ -46,23 +46,23 @@ * Attributes of an index tuple are different for single and multicolumn index. * For single-column case, index tuple stores only value to be indexed. * For multicolumn case, it stores two attributes: column number of value - * and value. + * and value. */ IndexTuple GinFormTuple(GinState *ginstate, OffsetNumber attnum, Datum key, ItemPointerData *ipd, uint32 nipd) { - bool isnull[2] = {FALSE,FALSE}; + bool isnull[2] = {FALSE, FALSE}; IndexTuple itup; - if ( ginstate->oneCol ) + if (ginstate->oneCol) itup = index_form_tuple(ginstate->origTupdesc, &key, isnull); else { - Datum datums[2]; + Datum datums[2]; datums[0] = UInt16GetDatum(attnum); datums[1] = key; - itup = index_form_tuple(ginstate->tupdesc[attnum-1], datums, isnull); + itup = index_form_tuple(ginstate->tupdesc[attnum - 1], datums, isnull); } GinSetOrigSizePosting(itup, IndexTupleSize(itup)); @@ -136,12 +136,12 @@ entryIsMoveRight(GinBtree btree, Page page) if (GinPageRightMost(page)) return FALSE; - itup = getRightMostTuple(page); + itup = getRightMostTuple(page); if (compareAttEntries(btree->ginstate, - btree->entryAttnum, btree->entryValue, - gintuple_get_attrnum(btree->ginstate, itup), - gin_index_getattr(btree->ginstate, itup)) > 0) + btree->entryAttnum, btree->entryValue, + gintuple_get_attrnum(btree->ginstate, itup), + gin_index_getattr(btree->ginstate, itup)) > 0) return TRUE; return FALSE; @@ -187,10 +187,10 @@ entryLocateEntry(GinBtree btree, GinBtreeStack *stack) else { itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, mid)); - result = compareAttEntries(btree->ginstate, - btree->entryAttnum, btree->entryValue, - gintuple_get_attrnum(btree->ginstate, itup), - gin_index_getattr(btree->ginstate, itup)); + result = compareAttEntries(btree->ginstate, + btree->entryAttnum, btree->entryValue, + gintuple_get_attrnum(btree->ginstate, itup), + gin_index_getattr(btree->ginstate, itup)); } if (result == 0) @@ -252,10 +252,10 @@ entryLocateLeafEntry(GinBtree btree, GinBtreeStack *stack) int result; itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, mid)); - result = compareAttEntries(btree->ginstate, - btree->entryAttnum, btree->entryValue, - gintuple_get_attrnum(btree->ginstate, itup), - gin_index_getattr(btree->ginstate, itup)); + result = compareAttEntries(btree->ginstate, + btree->entryAttnum, btree->entryValue, + gintuple_get_attrnum(btree->ginstate, itup), + gin_index_getattr(btree->ginstate, itup)); if (result == 0) { stack->off = mid; diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c index f474ad6598..20887ba56c 100644 --- a/src/backend/access/gin/ginfast.c +++ b/src/backend/access/gin/ginfast.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginfast.c,v 1.2 2009/03/24 22:06:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginfast.c,v 1.3 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,9 +33,9 @@ typedef struct DatumArray { - Datum *values; /* expansible array */ - int32 nvalues; /* current number of valid entries */ - int32 maxvalues; /* allocated size of array */ + Datum *values; /* expansible array */ + int32 nvalues; /* current number of valid entries */ + int32 maxvalues; /* allocated size of array */ } DatumArray; @@ -46,11 +46,14 @@ static int32 writeListPage(Relation index, Buffer buffer, IndexTuple *tuples, int32 ntuples, BlockNumber rightlink) { - Page page = BufferGetPage(buffer); - int i, freesize, size=0; - OffsetNumber l, off; - char *workspace; - char *ptr; + Page page = BufferGetPage(buffer); + int i, + freesize, + size = 0; + OffsetNumber l, + off; + char *workspace; + char *ptr; /* workspace could be a local array; we use palloc for alignment */ workspace = palloc(BLCKSZ); @@ -62,15 +65,15 @@ writeListPage(Relation index, Buffer buffer, off = FirstOffsetNumber; ptr = workspace; - for(i=0; i<ntuples; i++) + for (i = 0; i < ntuples; i++) { - int this_size = IndexTupleSize(tuples[i]); + int this_size = IndexTupleSize(tuples[i]); memcpy(ptr, tuples[i], this_size); ptr += this_size; size += this_size; - l = PageAddItem(page, (Item)tuples[i], this_size, off, false, false); + l = PageAddItem(page, (Item) tuples[i], this_size, off, false, false); if (l == InvalidOffsetNumber) elog(ERROR, "failed to add item to index page in \"%s\"", @@ -84,10 +87,10 @@ writeListPage(Relation index, Buffer buffer, GinPageGetOpaque(page)->rightlink = rightlink; /* - * tail page may contain only the whole row(s) or final - * part of row placed on previous pages + * tail page may contain only the whole row(s) or final part of row placed + * on previous pages */ - if ( rightlink == InvalidBlockNumber ) + if (rightlink == InvalidBlockNumber) { GinPageSetFullRow(page); GinPageGetOpaque(page)->maxoff = 1; @@ -103,15 +106,15 @@ writeListPage(Relation index, Buffer buffer, if (!index->rd_istemp) { - XLogRecData rdata[2]; - ginxlogInsertListPage data; - XLogRecPtr recptr; + XLogRecData rdata[2]; + ginxlogInsertListPage data; + XLogRecPtr recptr; rdata[0].buffer = buffer; rdata[0].buffer_std = true; - rdata[0].data = (char*)&data; + rdata[0].data = (char *) &data; rdata[0].len = sizeof(ginxlogInsertListPage); - rdata[0].next = rdata+1; + rdata[0].next = rdata + 1; rdata[1].buffer = InvalidBuffer; rdata[1].data = workspace; @@ -140,27 +143,29 @@ static void makeSublist(Relation index, IndexTuple *tuples, int32 ntuples, GinMetaPageData *res) { - Buffer curBuffer = InvalidBuffer; - Buffer prevBuffer = InvalidBuffer; - int i, size = 0, tupsize; - int startTuple = 0; + Buffer curBuffer = InvalidBuffer; + Buffer prevBuffer = InvalidBuffer; + int i, + size = 0, + tupsize; + int startTuple = 0; Assert(ntuples > 0); /* * Split tuples into pages */ - for(i=0;i<ntuples;i++) + for (i = 0; i < ntuples; i++) { - if ( curBuffer == InvalidBuffer ) + if (curBuffer == InvalidBuffer) { curBuffer = GinNewBuffer(index); - if ( prevBuffer != InvalidBuffer ) + if (prevBuffer != InvalidBuffer) { res->nPendingPages++; writeListPage(index, prevBuffer, - tuples+startTuple, i-startTuple, + tuples + startTuple, i - startTuple, BufferGetBlockNumber(curBuffer)); } else @@ -175,7 +180,7 @@ makeSublist(Relation index, IndexTuple *tuples, int32 ntuples, tupsize = MAXALIGN(IndexTupleSize(tuples[i])) + sizeof(ItemIdData); - if ( size + tupsize >= GinListPageSize ) + if (size + tupsize >= GinListPageSize) { /* won't fit, force a new page and reprocess */ i--; @@ -192,7 +197,7 @@ makeSublist(Relation index, IndexTuple *tuples, int32 ntuples, */ res->tail = BufferGetBlockNumber(curBuffer); res->tailFreeSize = writeListPage(index, curBuffer, - tuples+startTuple, ntuples-startTuple, + tuples + startTuple, ntuples - startTuple, InvalidBlockNumber); res->nPendingPages++; /* that was only one heap tuple */ @@ -207,17 +212,17 @@ void ginHeapTupleFastInsert(Relation index, GinState *ginstate, GinTupleCollector *collector) { - Buffer metabuffer; - Page metapage; - GinMetaPageData *metadata = NULL; - XLogRecData rdata[2]; - Buffer buffer = InvalidBuffer; - Page page = NULL; - ginxlogUpdateMeta data; - bool separateList = false; - bool needCleanup = false; - - if ( collector->ntuples == 0 ) + Buffer metabuffer; + Page metapage; + GinMetaPageData *metadata = NULL; + XLogRecData rdata[2]; + Buffer buffer = InvalidBuffer; + Page page = NULL; + ginxlogUpdateMeta data; + bool separateList = false; + bool needCleanup = false; + + if (collector->ntuples == 0) return; data.node = index->rd_node; @@ -232,7 +237,7 @@ ginHeapTupleFastInsert(Relation index, GinState *ginstate, metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); metapage = BufferGetPage(metabuffer); - if ( collector->sumsize + collector->ntuples * sizeof(ItemIdData) > GIN_PAGE_FREESIZE ) + if (collector->sumsize + collector->ntuples * sizeof(ItemIdData) > GIN_PAGE_FREESIZE) { /* * Total size is greater than one page => make sublist @@ -244,8 +249,8 @@ ginHeapTupleFastInsert(Relation index, GinState *ginstate, LockBuffer(metabuffer, GIN_EXCLUSIVE); metadata = GinPageGetMeta(metapage); - if ( metadata->head == InvalidBlockNumber || - collector->sumsize + collector->ntuples * sizeof(ItemIdData) > metadata->tailFreeSize ) + if (metadata->head == InvalidBlockNumber || + collector->sumsize + collector->ntuples * sizeof(ItemIdData) > metadata->tailFreeSize) { /* * Pending list is empty or total size is greater than freespace @@ -258,14 +263,14 @@ ginHeapTupleFastInsert(Relation index, GinState *ginstate, } } - if ( separateList ) + if (separateList) { - GinMetaPageData sublist; + GinMetaPageData sublist; /* * We should make sublist separately and append it to the tail */ - memset( &sublist, 0, sizeof(GinMetaPageData) ); + memset(&sublist, 0, sizeof(GinMetaPageData)); makeSublist(index, collector->tuples, collector->ntuples, &sublist); @@ -275,14 +280,14 @@ ginHeapTupleFastInsert(Relation index, GinState *ginstate, LockBuffer(metabuffer, GIN_EXCLUSIVE); metadata = GinPageGetMeta(metapage); - if ( metadata->head == InvalidBlockNumber ) + if (metadata->head == InvalidBlockNumber) { /* * Sublist becomes main list */ START_CRIT_SECTION(); - memcpy(metadata, &sublist, sizeof(GinMetaPageData) ); - memcpy(&data.metadata, &sublist, sizeof(GinMetaPageData) ); + memcpy(metadata, &sublist, sizeof(GinMetaPageData)); + memcpy(&data.metadata, &sublist, sizeof(GinMetaPageData)); } else { @@ -305,7 +310,7 @@ ginHeapTupleFastInsert(Relation index, GinState *ginstate, metadata->nPendingPages += sublist.nPendingPages; metadata->nPendingHeapTuples += sublist.nPendingHeapTuples; - memcpy(&data.metadata, metadata, sizeof(GinMetaPageData) ); + memcpy(&data.metadata, metadata, sizeof(GinMetaPageData)); data.newRightlink = sublist.head; MarkBufferDirty(buffer); @@ -317,21 +322,23 @@ ginHeapTupleFastInsert(Relation index, GinState *ginstate, * Insert into tail page, metapage is already locked */ - OffsetNumber l, off; - int i, tupsize; - char *ptr; + OffsetNumber l, + off; + int i, + tupsize; + char *ptr; buffer = ReadBuffer(index, metadata->tail); LockBuffer(buffer, GIN_EXCLUSIVE); page = BufferGetPage(buffer); off = (PageIsEmpty(page)) ? FirstOffsetNumber : - OffsetNumberNext(PageGetMaxOffsetNumber(page)); + OffsetNumberNext(PageGetMaxOffsetNumber(page)); rdata[0].next = rdata + 1; rdata[1].buffer = buffer; rdata[1].buffer_std = true; - ptr = rdata[1].data = (char *) palloc( collector->sumsize ); + ptr = rdata[1].data = (char *) palloc(collector->sumsize); rdata[1].len = collector->sumsize; rdata[1].next = NULL; @@ -342,44 +349,44 @@ ginHeapTupleFastInsert(Relation index, GinState *ginstate, /* * Increase counter of heap tuples */ - Assert( GinPageGetOpaque(page)->maxoff <= metadata->nPendingHeapTuples ); + Assert(GinPageGetOpaque(page)->maxoff <= metadata->nPendingHeapTuples); GinPageGetOpaque(page)->maxoff++; metadata->nPendingHeapTuples++; - for(i=0; i<collector->ntuples; i++) + for (i = 0; i < collector->ntuples; i++) { tupsize = IndexTupleSize(collector->tuples[i]); - l = PageAddItem(page, (Item)collector->tuples[i], tupsize, off, false, false); + l = PageAddItem(page, (Item) collector->tuples[i], tupsize, off, false, false); if (l == InvalidOffsetNumber) elog(ERROR, "failed to add item to index page in \"%s\"", - RelationGetRelationName(index)); + RelationGetRelationName(index)); memcpy(ptr, collector->tuples[i], tupsize); - ptr+=tupsize; + ptr += tupsize; off++; } metadata->tailFreeSize -= collector->sumsize + collector->ntuples * sizeof(ItemIdData); - memcpy(&data.metadata, metadata, sizeof(GinMetaPageData) ); + memcpy(&data.metadata, metadata, sizeof(GinMetaPageData)); MarkBufferDirty(buffer); } /* - * Make real write + * Make real write */ MarkBufferDirty(metabuffer); - if ( !index->rd_istemp ) + if (!index->rd_istemp) { - XLogRecPtr recptr; + XLogRecPtr recptr; recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_UPDATE_META_PAGE, rdata); PageSetLSN(metapage, recptr); PageSetTLI(metapage, ThisTimeLineID); - if ( buffer != InvalidBuffer ) + if (buffer != InvalidBuffer) { PageSetLSN(page, recptr); PageSetTLI(page, ThisTimeLineID); @@ -390,23 +397,22 @@ ginHeapTupleFastInsert(Relation index, GinState *ginstate, UnlockReleaseBuffer(buffer); /* - * Force pending list cleanup when it becomes too long. - * And, ginInsertCleanup could take significant amount of - * time, so we prefer to call it when it can do all the work in a - * single collection cycle. In non-vacuum mode, it shouldn't - * require maintenance_work_mem, so fire it while pending list is - * still small enough to fit into work_mem. + * Force pending list cleanup when it becomes too long. And, + * ginInsertCleanup could take significant amount of time, so we prefer to + * call it when it can do all the work in a single collection cycle. In + * non-vacuum mode, it shouldn't require maintenance_work_mem, so fire it + * while pending list is still small enough to fit into work_mem. * * ginInsertCleanup() should not be called inside our CRIT_SECTION. */ - if ( metadata->nPendingPages * GIN_PAGE_FREESIZE > work_mem * 1024L ) + if (metadata->nPendingPages * GIN_PAGE_FREESIZE > work_mem * 1024L) needCleanup = true; UnlockReleaseBuffer(metabuffer); END_CRIT_SECTION(); - if ( needCleanup ) + if (needCleanup) ginInsertCleanup(index, ginstate, false, NULL); } @@ -432,17 +438,17 @@ ginHeapTupleFastCollect(Relation index, GinState *ginstate, /* * Allocate/reallocate memory for storing collected tuples */ - if ( collector->tuples == NULL ) + if (collector->tuples == NULL) { collector->lentuples = nentries * index->rd_att->natts; - collector->tuples = (IndexTuple*)palloc(sizeof(IndexTuple) * collector->lentuples); + collector->tuples = (IndexTuple *) palloc(sizeof(IndexTuple) * collector->lentuples); } - while ( collector->ntuples + nentries > collector->lentuples ) + while (collector->ntuples + nentries > collector->lentuples) { collector->lentuples *= 2; - collector->tuples = (IndexTuple*)repalloc( collector->tuples, - sizeof(IndexTuple) * collector->lentuples); + collector->tuples = (IndexTuple *) repalloc(collector->tuples, + sizeof(IndexTuple) * collector->lentuples); } /* @@ -450,13 +456,13 @@ ginHeapTupleFastCollect(Relation index, GinState *ginstate, */ for (i = 0; i < nentries; i++) { - int32 tupsize; + int32 tupsize; collector->tuples[collector->ntuples + i] = GinFormTuple(ginstate, attnum, entries[i], NULL, 0); collector->tuples[collector->ntuples + i]->t_tid = *item; tupsize = IndexTupleSize(collector->tuples[collector->ntuples + i]); - if ( tupsize > TOAST_INDEX_TARGET || tupsize >= GinMaxItemSize) + if (tupsize > TOAST_INDEX_TARGET || tupsize >= GinMaxItemSize) elog(ERROR, "huge tuple"); collector->sumsize += tupsize; @@ -480,9 +486,9 @@ static bool shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, IndexBulkDeleteResult *stats) { - Page metapage; - GinMetaPageData *metadata; - BlockNumber blknoToDelete; + Page metapage; + GinMetaPageData *metadata; + BlockNumber blknoToDelete; metapage = BufferGetPage(metabuffer); metadata = GinPageGetMeta(metapage); @@ -490,12 +496,12 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, do { - Page page; - int i; - int64 nDeletedHeapTuples = 0; - ginxlogDeleteListPages data; - XLogRecData rdata[1]; - Buffer buffers[GIN_NDELETE_AT_ONCE]; + Page page; + int i; + int64 nDeletedHeapTuples = 0; + ginxlogDeleteListPages data; + XLogRecData rdata[1]; + Buffer buffers[GIN_NDELETE_AT_ONCE]; data.node = index->rd_node; @@ -507,24 +513,24 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, data.ndeleted = 0; while (data.ndeleted < GIN_NDELETE_AT_ONCE && blknoToDelete != newHead) { - data.toDelete[ data.ndeleted ] = blknoToDelete; - buffers[ data.ndeleted ] = ReadBuffer(index, blknoToDelete); - LockBuffer( buffers[ data.ndeleted ], GIN_EXCLUSIVE ); - page = BufferGetPage( buffers[ data.ndeleted ] ); + data.toDelete[data.ndeleted] = blknoToDelete; + buffers[data.ndeleted] = ReadBuffer(index, blknoToDelete); + LockBuffer(buffers[data.ndeleted], GIN_EXCLUSIVE); + page = BufferGetPage(buffers[data.ndeleted]); data.ndeleted++; - if ( GinPageIsDeleted(page) ) + if (GinPageIsDeleted(page)) { /* concurrent cleanup process is detected */ - for(i=0;i<data.ndeleted;i++) - UnlockReleaseBuffer( buffers[i] ); + for (i = 0; i < data.ndeleted; i++) + UnlockReleaseBuffer(buffers[i]); return true; } nDeletedHeapTuples += GinPageGetOpaque(page)->maxoff; - blknoToDelete = GinPageGetOpaque( page )->rightlink; + blknoToDelete = GinPageGetOpaque(page)->rightlink; } if (stats) @@ -534,50 +540,50 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, metadata->head = blknoToDelete; - Assert( metadata->nPendingPages >= data.ndeleted ); + Assert(metadata->nPendingPages >= data.ndeleted); metadata->nPendingPages -= data.ndeleted; - Assert( metadata->nPendingHeapTuples >= nDeletedHeapTuples ); + Assert(metadata->nPendingHeapTuples >= nDeletedHeapTuples); metadata->nPendingHeapTuples -= nDeletedHeapTuples; - if ( blknoToDelete == InvalidBlockNumber ) + if (blknoToDelete == InvalidBlockNumber) { metadata->tail = InvalidBlockNumber; metadata->tailFreeSize = 0; metadata->nPendingPages = 0; metadata->nPendingHeapTuples = 0; } - memcpy( &data.metadata, metadata, sizeof(GinMetaPageData)); + memcpy(&data.metadata, metadata, sizeof(GinMetaPageData)); - MarkBufferDirty( metabuffer ); + MarkBufferDirty(metabuffer); - for(i=0; i<data.ndeleted; i++) + for (i = 0; i < data.ndeleted; i++) { - page = BufferGetPage( buffers[ i ] ); - GinPageGetOpaque( page )->flags = GIN_DELETED; - MarkBufferDirty( buffers[ i ] ); + page = BufferGetPage(buffers[i]); + GinPageGetOpaque(page)->flags = GIN_DELETED; + MarkBufferDirty(buffers[i]); } - if ( !index->rd_istemp ) + if (!index->rd_istemp) { - XLogRecPtr recptr; + XLogRecPtr recptr; recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_DELETE_LISTPAGE, rdata); PageSetLSN(metapage, recptr); PageSetTLI(metapage, ThisTimeLineID); - for(i=0; i<data.ndeleted; i++) + for (i = 0; i < data.ndeleted; i++) { - page = BufferGetPage( buffers[ i ] ); + page = BufferGetPage(buffers[i]); PageSetLSN(page, recptr); PageSetTLI(page, ThisTimeLineID); } } - for(i=0; i<data.ndeleted; i++) - UnlockReleaseBuffer( buffers[ i ] ); + for (i = 0; i < data.ndeleted; i++) + UnlockReleaseBuffer(buffers[i]); END_CRIT_SECTION(); - } while( blknoToDelete != newHead ); + } while (blknoToDelete != newHead); return false; } @@ -586,14 +592,14 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, static void addDatum(DatumArray *datums, Datum datum) { - if ( datums->nvalues >= datums->maxvalues) + if (datums->nvalues >= datums->maxvalues) { datums->maxvalues *= 2; - datums->values = (Datum*)repalloc(datums->values, - sizeof(Datum)*datums->maxvalues); + datums->values = (Datum *) repalloc(datums->values, + sizeof(Datum) * datums->maxvalues); } - datums->values[ datums->nvalues++ ] = datum; + datums->values[datums->nvalues++] = datum; } /* @@ -606,31 +612,33 @@ static void processPendingPage(BuildAccumulator *accum, DatumArray *da, Page page, OffsetNumber startoff) { - ItemPointerData heapptr; - OffsetNumber i,maxoff; - OffsetNumber attrnum, curattnum; + ItemPointerData heapptr; + OffsetNumber i, + maxoff; + OffsetNumber attrnum, + curattnum; /* reset *da to empty */ da->nvalues = 0; maxoff = PageGetMaxOffsetNumber(page); - Assert( maxoff >= FirstOffsetNumber ); + Assert(maxoff >= FirstOffsetNumber); ItemPointerSetInvalid(&heapptr); attrnum = 0; for (i = startoff; i <= maxoff; i = OffsetNumberNext(i)) { - IndexTuple itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, i)); + IndexTuple itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, i)); curattnum = gintuple_get_attrnum(accum->ginstate, itup); - if ( !ItemPointerIsValid(&heapptr) ) + if (!ItemPointerIsValid(&heapptr)) { heapptr = itup->t_tid; attrnum = curattnum; } - else if ( !(ItemPointerEquals(&heapptr, &itup->t_tid) && - curattnum == attrnum) ) + else if (!(ItemPointerEquals(&heapptr, &itup->t_tid) && + curattnum == attrnum)) { /* * We can insert several datums per call, but only for one heap @@ -652,7 +660,7 @@ processPendingPage(BuildAccumulator *accum, DatumArray *da, * * This can be called concurrently by multiple backends, so it must cope. * On first glance it looks completely not concurrent-safe and not crash-safe - * either. The reason it's okay is that multiple insertion of the same entry + * either. The reason it's okay is that multiple insertion of the same entry * is detected and treated as a no-op by gininsert.c. If we crash after * posting entries to the main index and before removing them from the * pending list, it's okay because when we redo the posting later on, nothing @@ -671,20 +679,23 @@ void ginInsertCleanup(Relation index, GinState *ginstate, bool vac_delay, IndexBulkDeleteResult *stats) { - Buffer metabuffer, buffer; - Page metapage, page; - GinMetaPageData *metadata; - MemoryContext opCtx, oldCtx; - BuildAccumulator accum; - DatumArray datums; - BlockNumber blkno; + Buffer metabuffer, + buffer; + Page metapage, + page; + GinMetaPageData *metadata; + MemoryContext opCtx, + oldCtx; + BuildAccumulator accum; + DatumArray datums; + BlockNumber blkno; metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); LockBuffer(metabuffer, GIN_SHARE); metapage = BufferGetPage(metabuffer); metadata = GinPageGetMeta(metapage); - if ( metadata->head == InvalidBlockNumber ) + if (metadata->head == InvalidBlockNumber) { /* Nothing to do */ UnlockReleaseBuffer(metabuffer); @@ -702,7 +713,7 @@ ginInsertCleanup(Relation index, GinState *ginstate, LockBuffer(metabuffer, GIN_UNLOCK); /* - * Initialize. All temporary space will be in opCtx + * Initialize. All temporary space will be in opCtx */ opCtx = AllocSetContextCreate(CurrentMemoryContext, "GIN insert cleanup temporary context", @@ -712,24 +723,24 @@ ginInsertCleanup(Relation index, GinState *ginstate, oldCtx = MemoryContextSwitchTo(opCtx); - datums.maxvalues=128; + datums.maxvalues = 128; datums.nvalues = 0; - datums.values = (Datum*)palloc(sizeof(Datum)*datums.maxvalues); + datums.values = (Datum *) palloc(sizeof(Datum) * datums.maxvalues); ginInitBA(&accum); accum.ginstate = ginstate; /* - * At the top of this loop, we have pin and lock on the current page - * of the pending list. However, we'll release that before exiting - * the loop. Note we also have pin but not lock on the metapage. + * At the top of this loop, we have pin and lock on the current page of + * the pending list. However, we'll release that before exiting the loop. + * Note we also have pin but not lock on the metapage. */ - for(;;) + for (;;) { - if ( GinPageIsDeleted(page) ) + if (GinPageIsDeleted(page)) { /* another cleanup process is running concurrently */ - UnlockReleaseBuffer( buffer ); + UnlockReleaseBuffer(buffer); break; } @@ -742,9 +753,9 @@ ginInsertCleanup(Relation index, GinState *ginstate, vacuum_delay_point(); /* - * Is it time to flush memory to disk? Flush if we are at the end - * of the pending list, or if we have a full row and memory is - * getting full. + * Is it time to flush memory to disk? Flush if we are at the end of + * the pending list, or if we have a full row and memory is getting + * full. * * XXX using up maintenance_work_mem here is probably unreasonably * much, since vacuum might already be using that much. @@ -754,15 +765,16 @@ ginInsertCleanup(Relation index, GinState *ginstate, (accum.allocatedMemory >= maintenance_work_mem * 1024L || accum.maxdepth > GIN_MAX_TREE_DEPTH))) { - ItemPointerData *list; - uint32 nlist; - Datum entry; - OffsetNumber maxoff, attnum; + ItemPointerData *list; + uint32 nlist; + Datum entry; + OffsetNumber maxoff, + attnum; /* - * Unlock current page to increase performance. - * Changes of page will be checked later by comparing - * maxoff after completion of memory flush. + * Unlock current page to increase performance. Changes of page + * will be checked later by comparing maxoff after completion of + * memory flush. */ maxoff = PageGetMaxOffsetNumber(page); LockBuffer(buffer, GIN_UNLOCK); @@ -785,7 +797,7 @@ ginInsertCleanup(Relation index, GinState *ginstate, LockBuffer(metabuffer, GIN_EXCLUSIVE); LockBuffer(buffer, GIN_SHARE); - if ( GinPageIsDeleted(page) ) + if (GinPageIsDeleted(page)) { /* another cleanup process is running concurrently */ UnlockReleaseBuffer(buffer); @@ -795,16 +807,16 @@ ginInsertCleanup(Relation index, GinState *ginstate, /* * While we left the page unlocked, more stuff might have gotten - * added to it. If so, process those entries immediately. There + * added to it. If so, process those entries immediately. There * shouldn't be very many, so we don't worry about the fact that * we're doing this with exclusive lock. Insertion algorithm * gurantees that inserted row(s) will not continue on next page. * NOTE: intentionally no vacuum_delay_point in this loop. */ - if ( PageGetMaxOffsetNumber(page) != maxoff ) + if (PageGetMaxOffsetNumber(page) != maxoff) { ginInitBA(&accum); - processPendingPage(&accum, &datums, page, maxoff+1); + processPendingPage(&accum, &datums, page, maxoff + 1); while ((list = ginGetEntry(&accum, &attnum, &entry, &nlist)) != NULL) ginEntryInsert(index, ginstate, attnum, entry, list, nlist, FALSE); @@ -814,26 +826,27 @@ ginInsertCleanup(Relation index, GinState *ginstate, * Remember next page - it will become the new list head */ blkno = GinPageGetOpaque(page)->rightlink; - UnlockReleaseBuffer(buffer); /* shiftList will do exclusive locking */ + UnlockReleaseBuffer(buffer); /* shiftList will do exclusive + * locking */ /* * remove readed pages from pending list, at this point all * content of readed pages is in regular structure */ - if ( shiftList(index, metabuffer, blkno, stats) ) + if (shiftList(index, metabuffer, blkno, stats)) { /* another cleanup process is running concurrently */ LockBuffer(metabuffer, GIN_UNLOCK); break; } - Assert( blkno == metadata->head ); + Assert(blkno == metadata->head); LockBuffer(metabuffer, GIN_UNLOCK); /* * if we removed the whole pending list just exit */ - if ( blkno == InvalidBlockNumber ) + if (blkno == InvalidBlockNumber) break; /* @@ -842,7 +855,7 @@ ginInsertCleanup(Relation index, GinState *ginstate, MemoryContextReset(opCtx); ginInitBA(&accum); datums.nvalues = 0; - datums.values = (Datum*)palloc(sizeof(Datum)*datums.maxvalues); + datums.values = (Datum *) palloc(sizeof(Datum) * datums.maxvalues); } else { diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c index d57ee8febb..f5e0f788d1 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.26 2009/05/19 02:48:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.27 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ @@ -25,10 +25,10 @@ typedef struct pendingPosition { - Buffer pendingBuffer; - OffsetNumber firstOffset; - OffsetNumber lastOffset; - ItemPointerData item; + Buffer pendingBuffer; + OffsetNumber firstOffset; + OffsetNumber lastOffset; + ItemPointerData item; } pendingPosition; @@ -64,19 +64,19 @@ findItemInPage(Page page, ItemPointer item, OffsetNumber *off) * Goes to the next page if current offset is outside of bounds */ static bool -moveRightIfItNeeded( GinBtreeData *btree, GinBtreeStack *stack ) +moveRightIfItNeeded(GinBtreeData *btree, GinBtreeStack *stack) { - Page page = BufferGetPage(stack->buffer); + Page page = BufferGetPage(stack->buffer); - if ( stack->off > PageGetMaxOffsetNumber(page) ) + if (stack->off > PageGetMaxOffsetNumber(page)) { /* * We scanned the whole page, so we should take right page */ stack->blkno = GinPageGetOpaque(page)->rightlink; - if ( GinPageRightMost(page) ) - return false; /* no more pages */ + if (GinPageRightMost(page)) + return false; /* no more pages */ LockBuffer(stack->buffer, GIN_UNLOCK); stack->buffer = ReleaseAndReadBuffer(stack->buffer, btree->index, stack->blkno); @@ -92,12 +92,12 @@ moveRightIfItNeeded( GinBtreeData *btree, GinBtreeStack *stack ) * in scanEntry->partialMatch TIDBitmap */ static void -scanForItems( Relation index, GinScanEntry scanEntry, BlockNumber rootPostingTree ) +scanForItems(Relation index, GinScanEntry scanEntry, BlockNumber rootPostingTree) { GinPostingTreeScan *gdi; - Buffer buffer; - Page page; - BlockNumber blkno; + Buffer buffer; + Page page; + BlockNumber blkno; gdi = prepareScanPostingTree(index, rootPostingTree, TRUE); @@ -110,23 +110,23 @@ scanForItems( Relation index, GinScanEntry scanEntry, BlockNumber rootPostingTre /* * Goes through all leaves */ - for(;;) + for (;;) { page = BufferGetPage(buffer); - if ((GinPageGetOpaque(page)->flags & GIN_DELETED) == 0 && GinPageGetOpaque(page)->maxoff >= FirstOffsetNumber ) + if ((GinPageGetOpaque(page)->flags & GIN_DELETED) == 0 && GinPageGetOpaque(page)->maxoff >= FirstOffsetNumber) { - tbm_add_tuples( scanEntry->partialMatch, - (ItemPointer)GinDataPageGetItem(page, FirstOffsetNumber), - GinPageGetOpaque(page)->maxoff, false); + tbm_add_tuples(scanEntry->partialMatch, + (ItemPointer) GinDataPageGetItem(page, FirstOffsetNumber), + GinPageGetOpaque(page)->maxoff, false); scanEntry->predictNumberResult += GinPageGetOpaque(page)->maxoff; } blkno = GinPageGetOpaque(page)->rightlink; - if ( GinPageRightMost(page) ) + if (GinPageRightMost(page)) { UnlockReleaseBuffer(buffer); - return; /* no more pages */ + return; /* no more pages */ } LockBuffer(buffer, GIN_UNLOCK); @@ -142,21 +142,21 @@ scanForItems( Relation index, GinScanEntry scanEntry, BlockNumber rootPostingTre * Returns true if done, false if it's needed to restart scan from scratch */ static bool -computePartialMatchList( GinBtreeData *btree, GinBtreeStack *stack, GinScanEntry scanEntry ) +computePartialMatchList(GinBtreeData *btree, GinBtreeStack *stack, GinScanEntry scanEntry) { - Page page; - IndexTuple itup; + Page page; + IndexTuple itup; Datum idatum; int32 cmp; - scanEntry->partialMatch = tbm_create( work_mem * 1024L ); + scanEntry->partialMatch = tbm_create(work_mem * 1024L); - for(;;) + for (;;) { /* * stack->off points to the interested entry, buffer is already locked */ - if ( moveRightIfItNeeded(btree, stack) == false ) + if (moveRightIfItNeeded(btree, stack) == false) return true; page = BufferGetPage(stack->buffer); @@ -165,10 +165,10 @@ computePartialMatchList( GinBtreeData *btree, GinBtreeStack *stack, GinScanEntry /* * If tuple stores another attribute then stop scan */ - if ( gintuple_get_attrnum( btree->ginstate, itup ) != scanEntry->attnum ) + if (gintuple_get_attrnum(btree->ginstate, itup) != scanEntry->attnum) return true; - idatum = gin_index_getattr( btree->ginstate, itup ); + idatum = gin_index_getattr(btree->ginstate, itup); /*---------- @@ -178,74 +178,74 @@ computePartialMatchList( GinBtreeData *btree, GinBtreeStack *stack, GinScanEntry * case cmp < 0 => not match and continue scan *---------- */ - cmp = DatumGetInt32(FunctionCall4(&btree->ginstate->comparePartialFn[scanEntry->attnum-1], + cmp = DatumGetInt32(FunctionCall4(&btree->ginstate->comparePartialFn[scanEntry->attnum - 1], scanEntry->entry, idatum, UInt16GetDatum(scanEntry->strategy), - PointerGetDatum(scanEntry->extra_data))); + PointerGetDatum(scanEntry->extra_data))); - if ( cmp > 0 ) + if (cmp > 0) return true; - else if ( cmp < 0 ) + else if (cmp < 0) { stack->off++; continue; } - if ( GinIsPostingTree(itup) ) + if (GinIsPostingTree(itup)) { BlockNumber rootPostingTree = GinGetPostingTree(itup); Datum newDatum, - savedDatum = datumCopy ( - idatum, - btree->ginstate->origTupdesc->attrs[scanEntry->attnum-1]->attbyval, - btree->ginstate->origTupdesc->attrs[scanEntry->attnum-1]->attlen - ); + savedDatum = datumCopy( + idatum, + btree->ginstate->origTupdesc->attrs[scanEntry->attnum - 1]->attbyval, + btree->ginstate->origTupdesc->attrs[scanEntry->attnum - 1]->attlen + ); + /* - * We should unlock current page (but not unpin) during - * tree scan to prevent deadlock with vacuum processes. + * We should unlock current page (but not unpin) during tree scan + * to prevent deadlock with vacuum processes. * * We save current entry value (savedDatum) to be able to refind * our tuple after re-locking */ LockBuffer(stack->buffer, GIN_UNLOCK); - scanForItems( btree->index, scanEntry, rootPostingTree ); + scanForItems(btree->index, scanEntry, rootPostingTree); /* - * We lock again the entry page and while it was unlocked - * insert might occured, so we need to refind our position + * We lock again the entry page and while it was unlocked insert + * might occured, so we need to refind our position */ LockBuffer(stack->buffer, GIN_SHARE); page = BufferGetPage(stack->buffer); - if ( !GinPageIsLeaf(page) ) + if (!GinPageIsLeaf(page)) { /* - * Root page becomes non-leaf while we unlock it. We - * will start again, this situation doesn't cause - * often - root can became a non-leaf only one per - * life of index. + * Root page becomes non-leaf while we unlock it. We will + * start again, this situation doesn't cause often - root can + * became a non-leaf only one per life of index. */ return false; } - for(;;) + for (;;) { - if ( moveRightIfItNeeded(btree, stack) == false ) - elog(ERROR, "lost saved point in index"); /* must not happen !!! */ + if (moveRightIfItNeeded(btree, stack) == false) + elog(ERROR, "lost saved point in index"); /* must not happen !!! */ page = BufferGetPage(stack->buffer); itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, stack->off)); - newDatum = gin_index_getattr( btree->ginstate, itup ); + newDatum = gin_index_getattr(btree->ginstate, itup); - if ( gintuple_get_attrnum( btree->ginstate, itup ) != scanEntry->attnum ) - elog(ERROR, "lost saved point in index"); /* must not happen !!! */ + if (gintuple_get_attrnum(btree->ginstate, itup) != scanEntry->attnum) + elog(ERROR, "lost saved point in index"); /* must not happen !!! */ - if ( compareEntries(btree->ginstate, scanEntry->attnum, newDatum, savedDatum) == 0 ) + if (compareEntries(btree->ginstate, scanEntry->attnum, newDatum, savedDatum) == 0) { /* Found! */ - if ( btree->ginstate->origTupdesc->attrs[scanEntry->attnum-1]->attbyval == false ) - pfree( DatumGetPointer(savedDatum) ); + if (btree->ginstate->origTupdesc->attrs[scanEntry->attnum - 1]->attbyval == false) + pfree(DatumGetPointer(savedDatum)); break; } @@ -254,8 +254,8 @@ computePartialMatchList( GinBtreeData *btree, GinBtreeStack *stack, GinScanEntry } else { - tbm_add_tuples( scanEntry->partialMatch, GinGetPosting(itup), GinGetNPosting(itup), false); - scanEntry->predictNumberResult += GinGetNPosting(itup); + tbm_add_tuples(scanEntry->partialMatch, GinGetPosting(itup), GinGetNPosting(itup), false); + scanEntry->predictNumberResult += GinGetNPosting(itup); } /* @@ -273,10 +273,10 @@ computePartialMatchList( GinBtreeData *btree, GinBtreeStack *stack, GinScanEntry static void startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry) { - GinBtreeData btreeEntry; - GinBtreeStack *stackEntry; - Page page; - bool needUnlock = TRUE; + GinBtreeData btreeEntry; + GinBtreeStack *stackEntry; + Page page; + bool needUnlock = TRUE; entry->buffer = InvalidBuffer; entry->offset = InvalidOffsetNumber; @@ -294,8 +294,8 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry) } /* - * we should find entry, and begin scan of posting tree - * or just store posting list in memory + * we should find entry, and begin scan of posting tree or just store + * posting list in memory */ prepareEntryScan(&btreeEntry, index, entry->attnum, entry->entry, ginstate); @@ -305,27 +305,26 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry) entry->isFinished = TRUE; - if ( entry->isPartialMatch ) + if (entry->isPartialMatch) { /* - * btreeEntry.findItem points to the first equal or greater value - * than needed. So we will scan further and collect all - * ItemPointers + * btreeEntry.findItem points to the first equal or greater value than + * needed. So we will scan further and collect all ItemPointers */ btreeEntry.findItem(&btreeEntry, stackEntry); - if ( computePartialMatchList( &btreeEntry, stackEntry, entry ) == false ) + if (computePartialMatchList(&btreeEntry, stackEntry, entry) == false) { /* - * GIN tree was seriously restructured, so we will - * cleanup all found data and rescan. See comments near - * 'return false' in computePartialMatchList() + * GIN tree was seriously restructured, so we will cleanup all + * found data and rescan. See comments near 'return false' in + * computePartialMatchList() */ - if ( entry->partialMatch ) + if (entry->partialMatch) { if (entry->partialMatchIterator) tbm_end_iterate(entry->partialMatchIterator); entry->partialMatchIterator = NULL; - tbm_free( entry->partialMatch ); + tbm_free(entry->partialMatch); entry->partialMatch = NULL; } LockBuffer(stackEntry->buffer, GIN_UNLOCK); @@ -335,7 +334,7 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry) return; } - if ( entry->partialMatch && !tbm_is_empty(entry->partialMatch) ) + if (entry->partialMatch && !tbm_is_empty(entry->partialMatch)) { entry->partialMatchIterator = tbm_begin_iterate(entry->partialMatch); entry->isFinished = FALSE; @@ -352,22 +351,22 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry) Page page; /* - * We should unlock entry page before make deal with - * posting tree to prevent deadlocks with vacuum processes. - * Because entry is never deleted from page and posting tree is - * never reduced to the posting list, we can unlock page after - * getting BlockNumber of root of posting tree. + * We should unlock entry page before make deal with posting tree + * to prevent deadlocks with vacuum processes. Because entry is + * never deleted from page and posting tree is never reduced to + * the posting list, we can unlock page after getting BlockNumber + * of root of posting tree. */ LockBuffer(stackEntry->buffer, GIN_UNLOCK); needUnlock = FALSE; gdi = prepareScanPostingTree(index, rootPostingTree, TRUE); entry->buffer = scanBeginPostingTree(gdi); + /* * We keep buffer pinned because we need to prevent deletion of - * page during scan. See GIN's vacuum implementation. RefCount - * is increased to keep buffer pinned after freeGinBtreeStack() - * call. + * page during scan. See GIN's vacuum implementation. RefCount is + * increased to keep buffer pinned after freeGinBtreeStack() call. */ IncrBufferRefCount(entry->buffer); @@ -377,10 +376,10 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry) /* * Keep page content in memory to prevent durable page locking */ - entry->list = (ItemPointerData *) palloc( BLCKSZ ); + entry->list = (ItemPointerData *) palloc(BLCKSZ); entry->nlist = GinPageGetOpaque(page)->maxoff; - memcpy( entry->list, GinDataPageGetItem(page, FirstOffsetNumber), - GinPageGetOpaque(page)->maxoff * sizeof(ItemPointerData) ); + memcpy(entry->list, GinDataPageGetItem(page, FirstOffsetNumber), + GinPageGetOpaque(page)->maxoff * sizeof(ItemPointerData)); LockBuffer(entry->buffer, GIN_UNLOCK); freeGinBtreeStack(gdi->stack); @@ -397,7 +396,7 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry) } if (needUnlock) - LockBuffer(stackEntry->buffer, GIN_UNLOCK); + LockBuffer(stackEntry->buffer, GIN_UNLOCK); freeGinBtreeStack(stackEntry); } @@ -419,10 +418,10 @@ startScanKey(Relation index, GinState *ginstate, GinScanKey key) if (GinFuzzySearchLimit > 0) { /* - * If all of keys more than threshold we will try to reduce - * result, we hope (and only hope, for intersection operation of - * array our supposition isn't true), that total result will not - * more than minimal predictNumberResult. + * If all of keys more than threshold we will try to reduce result, we + * hope (and only hope, for intersection operation of array our + * supposition isn't true), that total result will not more than + * minimal predictNumberResult. */ for (i = 0; i < key->nentries; i++) @@ -459,7 +458,7 @@ entryGetNextItem(Relation index, GinScanEntry entry) Page page; BlockNumber blkno; - for(;;) + for (;;) { entry->offset++; @@ -471,7 +470,7 @@ entryGetNextItem(Relation index, GinScanEntry entry) LockBuffer(entry->buffer, GIN_SHARE); page = BufferGetPage(entry->buffer); - for(;;) + for (;;) { /* * It's needed to go by right link. During that we should refind @@ -501,20 +500,20 @@ entryGetNextItem(Relation index, GinScanEntry entry) * Found position equal to or greater than stored */ entry->nlist = GinPageGetOpaque(page)->maxoff; - memcpy( entry->list, GinDataPageGetItem(page, FirstOffsetNumber), - GinPageGetOpaque(page)->maxoff * sizeof(ItemPointerData) ); + memcpy(entry->list, GinDataPageGetItem(page, FirstOffsetNumber), + GinPageGetOpaque(page)->maxoff * sizeof(ItemPointerData)); LockBuffer(entry->buffer, GIN_UNLOCK); - if ( !ItemPointerIsValid(&entry->curItem) || - compareItemPointers( &entry->curItem, entry->list + entry->offset - 1 ) == 0 ) + if (!ItemPointerIsValid(&entry->curItem) || + compareItemPointers(&entry->curItem, entry->list + entry->offset - 1) == 0) { /* - * First pages are deleted or empty, or we found exact position, - * so break inner loop and continue outer one. + * First pages are deleted or empty, or we found exact + * position, so break inner loop and continue outer one. */ - break; + break; } /* @@ -543,7 +542,7 @@ entryGetItem(Relation index, GinScanEntry entry) entry->isFinished = entry->master->isFinished; entry->curItem = entry->master->curItem; } - else if ( entry->partialMatch ) + else if (entry->partialMatch) { do { @@ -552,7 +551,7 @@ entryGetItem(Relation index, GinScanEntry entry) { entry->partialMatchResult = tbm_iterate(entry->partialMatchIterator); - if ( entry->partialMatchResult == NULL ) + if (entry->partialMatchResult == NULL) { ItemPointerSet(&entry->curItem, InvalidBlockNumber, InvalidOffsetNumber); tbm_end_iterate(entry->partialMatchIterator); @@ -562,22 +561,23 @@ entryGetItem(Relation index, GinScanEntry entry) } /* - * reset counter to the beginning of entry->partialMatchResult. - * Note: entry->offset is still greater than - * partialMatchResult->ntuples if partialMatchResult is - * lossy. So, on next call we will get next result from - * TIDBitmap. + * reset counter to the beginning of + * entry->partialMatchResult. Note: entry->offset is still + * greater than partialMatchResult->ntuples if + * partialMatchResult is lossy. So, on next call we will get + * next result from TIDBitmap. */ entry->offset = 0; } - if ( entry->partialMatchResult->ntuples < 0 ) + if (entry->partialMatchResult->ntuples < 0) { /* * lossy result, so we need to check the whole page */ ItemPointerSetLossyPage(&entry->curItem, entry->partialMatchResult->blockno); + /* * We might as well fall out of the loop; we could not * estimate number of results on this page to support correct @@ -618,7 +618,7 @@ entryGetItem(Relation index, GinScanEntry entry) * Sets key->curItem to new found heap item pointer for one scan key * Returns isFinished, ie TRUE means we did NOT get a new item pointer! * Also, *keyrecheck is set true if recheck is needed for this scan key. - * Note: lossy page could be returned after items from the same page. + * Note: lossy page could be returned after items from the same page. */ static bool keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, @@ -636,10 +636,10 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, { /* * move forward from previously value and set new curItem, which is - * minimal from entries->curItems. Lossy page is encoded by ItemPointer - * with max value for offset (0xffff), so if there is an non-lossy entries - * on lossy page they will returned too and after that the whole page. - * That's not a problem for resulting tidbitmap. + * minimal from entries->curItems. Lossy page is encoded by + * ItemPointer with max value for offset (0xffff), so if there is an + * non-lossy entries on lossy page they will returned too and after + * that the whole page. That's not a problem for resulting tidbitmap. */ ItemPointerSetMax(&key->curItem); for (i = 0; i < key->nentries; i++) @@ -649,9 +649,9 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, if (key->entryRes[i]) { /* - * Move forward only entries which was the least - * on previous call, key->entryRes[i] points that - * current entry was a result of loop/call. + * Move forward only entries which was the least on previous + * call, key->entryRes[i] points that current entry was a + * result of loop/call. */ if (entry->isFinished == FALSE && entryGetItem(index, entry) == FALSE) { @@ -685,10 +685,10 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, /*---------- * entryRes array is used for: * - as an argument for consistentFn - * - entry->curItem with corresponding key->entryRes[i] == false are - * greater than key->curItem, so next loop/call they should be - * renewed by entryGetItem(). So, we need to set up an array before - * checking of lossy page. + * - entry->curItem with corresponding key->entryRes[i] == false are + * greater than key->curItem, so next loop/call they should be + * renewed by entryGetItem(). So, we need to set up an array before + * checking of lossy page. *---------- */ for (i = 0; i < key->nentries; i++) @@ -717,7 +717,7 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, return FALSE; oldCtx = MemoryContextSwitchTo(tempCtx); - res = DatumGetBool(FunctionCall6(&ginstate->consistentFn[key->attnum-1], + res = DatumGetBool(FunctionCall6(&ginstate->consistentFn[key->attnum - 1], PointerGetDatum(key->entryRes), UInt16GetDatum(key->strategy), key->query, @@ -745,35 +745,36 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, static bool scanGetCandidate(IndexScanDesc scan, pendingPosition *pos) { - OffsetNumber maxoff; - Page page; - IndexTuple itup; + OffsetNumber maxoff; + Page page; + IndexTuple itup; - ItemPointerSetInvalid( &pos->item ); - for(;;) + ItemPointerSetInvalid(&pos->item); + for (;;) { page = BufferGetPage(pos->pendingBuffer); maxoff = PageGetMaxOffsetNumber(page); - if ( pos->firstOffset > maxoff ) + if (pos->firstOffset > maxoff) { BlockNumber blkno = GinPageGetOpaque(page)->rightlink; - if ( blkno == InvalidBlockNumber ) + + if (blkno == InvalidBlockNumber) { UnlockReleaseBuffer(pos->pendingBuffer); - pos->pendingBuffer=InvalidBuffer; + pos->pendingBuffer = InvalidBuffer; return false; } else { /* - * Here we must prevent deletion of next page by - * insertcleanup process, which may be trying to obtain - * exclusive lock on current page. So, we lock next - * page before releasing the current one + * Here we must prevent deletion of next page by insertcleanup + * process, which may be trying to obtain exclusive lock on + * current page. So, we lock next page before releasing the + * current one */ - Buffer tmpbuf = ReadBuffer(scan->indexRelation, blkno); + Buffer tmpbuf = ReadBuffer(scan->indexRelation, blkno); LockBuffer(tmpbuf, GIN_SHARE); UnlockReleaseBuffer(pos->pendingBuffer); @@ -786,12 +787,12 @@ scanGetCandidate(IndexScanDesc scan, pendingPosition *pos) { itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, pos->firstOffset)); pos->item = itup->t_tid; - if ( GinPageHasFullRow(page) ) + if (GinPageHasFullRow(page)) { /* * find itempointer to the next row */ - for(pos->lastOffset = pos->firstOffset+1; pos->lastOffset<=maxoff; pos->lastOffset++) + for (pos->lastOffset = pos->firstOffset + 1; pos->lastOffset <= maxoff; pos->lastOffset++) { itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, pos->lastOffset)); if (!ItemPointerEquals(&pos->item, &itup->t_tid)) @@ -807,9 +808,9 @@ scanGetCandidate(IndexScanDesc scan, pendingPosition *pos) } /* - * Now pos->firstOffset points to the first tuple of current heap row, - * pos->lastOffset points to the first tuple of second heap row (or - * to the end of page) + * Now pos->firstOffset points to the first tuple of current heap + * row, pos->lastOffset points to the first tuple of second heap + * row (or to the end of page) */ break; @@ -830,23 +831,23 @@ static bool matchPartialInPendingList(GinState *ginstate, Page page, OffsetNumber off, OffsetNumber maxoff, Datum value, OffsetNumber attrnum, - Datum *datum, bool *datumExtracted, + Datum *datum, bool *datumExtracted, StrategyNumber strategy, Pointer extra_data) { - IndexTuple itup; - int32 cmp; + IndexTuple itup; + int32 cmp; - while ( off < maxoff ) + while (off < maxoff) { itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, off)); - if ( attrnum != gintuple_get_attrnum(ginstate, itup) ) + if (attrnum != gintuple_get_attrnum(ginstate, itup)) return false; - if (datumExtracted[ off-1 ] == false) + if (datumExtracted[off - 1] == false) { - datum[ off-1 ] = gin_index_getattr(ginstate, itup); - datumExtracted[ off-1 ] = true; + datum[off - 1] = gin_index_getattr(ginstate, itup); + datumExtracted[off - 1] = true; } /*---------- @@ -856,9 +857,9 @@ matchPartialInPendingList(GinState *ginstate, Page page, * case cmp < 0 => not match and continue scan *---------- */ - cmp = DatumGetInt32(FunctionCall4(&ginstate->comparePartialFn[attrnum-1], + cmp = DatumGetInt32(FunctionCall4(&ginstate->comparePartialFn[attrnum - 1], value, - datum[off-1], + datum[off - 1], UInt16GetDatum(strategy), PointerGetDatum(extra_data))); if (cmp == 0) @@ -882,12 +883,13 @@ matchPartialInPendingList(GinState *ginstate, Page page, static bool collectDatumForItem(IndexScanDesc scan, pendingPosition *pos) { - GinScanOpaque so = (GinScanOpaque) scan->opaque; - OffsetNumber attrnum; - Page page; - IndexTuple itup; - int i, j; - bool hasMatch = false; + GinScanOpaque so = (GinScanOpaque) scan->opaque; + OffsetNumber attrnum; + Page page; + IndexTuple itup; + int i, + j; + bool hasMatch = false; /* * Resets entryRes @@ -895,38 +897,40 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos) for (i = 0; i < so->nkeys; i++) { GinScanKey key = so->keys + i; - memset( key->entryRes, FALSE, key->nentries ); + + memset(key->entryRes, FALSE, key->nentries); } - for(;;) + for (;;) { - Datum datum[ BLCKSZ/sizeof(IndexTupleData) ]; - bool datumExtracted[ BLCKSZ/sizeof(IndexTupleData) ]; + Datum datum[BLCKSZ / sizeof(IndexTupleData)]; + bool datumExtracted[BLCKSZ / sizeof(IndexTupleData)]; - Assert( pos->lastOffset > pos->firstOffset ); - memset(datumExtracted + pos->firstOffset - 1, 0, sizeof(bool) * (pos->lastOffset - pos->firstOffset )); + Assert(pos->lastOffset > pos->firstOffset); + memset(datumExtracted + pos->firstOffset - 1, 0, sizeof(bool) * (pos->lastOffset - pos->firstOffset)); page = BufferGetPage(pos->pendingBuffer); - for(i = 0; i < so->nkeys; i++) + for (i = 0; i < so->nkeys; i++) { - GinScanKey key = so->keys + i; + GinScanKey key = so->keys + i; - for(j=0; j<key->nentries; j++) + for (j = 0; j < key->nentries; j++) { - OffsetNumber StopLow = pos->firstOffset, - StopHigh = pos->lastOffset, - StopMiddle; - GinScanEntry entry = key->scanEntry + j; + OffsetNumber StopLow = pos->firstOffset, + StopHigh = pos->lastOffset, + StopMiddle; + GinScanEntry entry = key->scanEntry + j; /* already true - do not extra work */ - if ( key->entryRes[j] ) + if (key->entryRes[j]) continue; /* - * Interested tuples are from pos->firstOffset to pos->lastOffset - * and they are ordered by (attnum, Datum) as it's done in entry tree - * So we could use binary search to prevent linear scanning + * Interested tuples are from pos->firstOffset to + * pos->lastOffset and they are ordered by (attnum, Datum) as + * it's done in entry tree So we could use binary search to + * prevent linear scanning */ while (StopLow < StopHigh) { @@ -941,53 +945,53 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos) StopLow = StopMiddle + 1; else { - int res; + int res; - if (datumExtracted[ StopMiddle-1 ] == false) + if (datumExtracted[StopMiddle - 1] == false) { - datum[ StopMiddle-1 ] = gin_index_getattr(&so->ginstate, itup); - datumExtracted[ StopMiddle-1 ] = true; + datum[StopMiddle - 1] = gin_index_getattr(&so->ginstate, itup); + datumExtracted[StopMiddle - 1] = true; } - res = compareEntries(&so->ginstate, - entry->attnum, - entry->entry, - datum[ StopMiddle-1 ]); + res = compareEntries(&so->ginstate, + entry->attnum, + entry->entry, + datum[StopMiddle - 1]); - if ( res == 0 ) + if (res == 0) { /* - * The exact match causes, so we just scan from - * current position to find a partial match. - * See comment above about tuple's ordering. + * The exact match causes, so we just scan from + * current position to find a partial match. See + * comment above about tuple's ordering. */ - if ( entry->isPartialMatch ) + if (entry->isPartialMatch) key->entryRes[j] = matchPartialInPendingList(&so->ginstate, - page, StopMiddle, + page, StopMiddle, pos->lastOffset, entry->entry, entry->attnum, datum, datumExtracted, entry->strategy, - entry->extra_data); + entry->extra_data); else key->entryRes[j] = true; break; } - else if ( res < 0 ) + else if (res < 0) StopHigh = StopMiddle; else StopLow = StopMiddle + 1; } } - if ( StopLow>=StopHigh && entry->isPartialMatch ) + if (StopLow >= StopHigh && entry->isPartialMatch) { - /* - * The exact match wasn't found, so we need to start - * scan from first tuple greater then current entry - * See comment above about tuple's ordering. + /* + * The exact match wasn't found, so we need to start scan + * from first tuple greater then current entry See comment + * above about tuple's ordering. */ key->entryRes[j] = matchPartialInPendingList(&so->ginstate, @@ -1007,7 +1011,7 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos) pos->firstOffset = pos->lastOffset; - if ( GinPageHasFullRow(page) ) + if (GinPageHasFullRow(page)) { /* * We scan all values from one tuple, go to next one @@ -1020,12 +1024,13 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos) ItemPointerData item = pos->item; /* - * need to get next portion of tuples of row containing - * on several pages + * need to get next portion of tuples of row containing on several + * pages */ - if ( scanGetCandidate(scan, pos) == false || !ItemPointerEquals(&pos->item, &item) ) - elog(ERROR,"Could not process tuple"); /* XXX should not be here ! */ + if (scanGetCandidate(scan, pos) == false || !ItemPointerEquals(&pos->item, &item)) + elog(ERROR, "Could not process tuple"); /* XXX should not be + * here ! */ } } @@ -1039,12 +1044,14 @@ static void scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids) { GinScanOpaque so = (GinScanOpaque) scan->opaque; - MemoryContext oldCtx; - bool recheck, keyrecheck, match; - int i; - pendingPosition pos; - Buffer metabuffer = ReadBuffer(scan->indexRelation, GIN_METAPAGE_BLKNO); - BlockNumber blkno; + MemoryContext oldCtx; + bool recheck, + keyrecheck, + match; + int i; + pendingPosition pos; + Buffer metabuffer = ReadBuffer(scan->indexRelation, GIN_METAPAGE_BLKNO); + BlockNumber blkno; *ntids = 0; @@ -1052,39 +1059,38 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids) blkno = GinPageGetMeta(BufferGetPage(metabuffer))->head; /* - * fetch head of list before unlocking metapage. - * head page must be pinned to prevent deletion by vacuum process + * fetch head of list before unlocking metapage. head page must be pinned + * to prevent deletion by vacuum process */ - if ( blkno == InvalidBlockNumber ) + if (blkno == InvalidBlockNumber) { /* No pending list, so proceed with normal scan */ - UnlockReleaseBuffer( metabuffer ); + UnlockReleaseBuffer(metabuffer); return; } pos.pendingBuffer = ReadBuffer(scan->indexRelation, blkno); LockBuffer(pos.pendingBuffer, GIN_SHARE); pos.firstOffset = FirstOffsetNumber; - UnlockReleaseBuffer( metabuffer ); + UnlockReleaseBuffer(metabuffer); /* - * loop for each heap row. scanGetCandidate returns full row - * or row's tuples from first page. + * loop for each heap row. scanGetCandidate returns full row or row's + * tuples from first page. */ - while( scanGetCandidate(scan, &pos) ) + while (scanGetCandidate(scan, &pos)) { - /* - * Check entries in tuple and setup entryRes array - * If tuples of heap's row are placed on several pages - * collectDatumForItem will read all of that pages. + * Check entries in tuple and setup entryRes array If tuples of heap's + * row are placed on several pages collectDatumForItem will read all + * of that pages. */ if (!collectDatumForItem(scan, &pos)) continue; /* - * Matching of entries of one row is finished, - * so check row by consistent function. + * Matching of entries of one row is finished, so check row by + * consistent function. */ oldCtx = MemoryContextSwitchTo(so->tempCtx); recheck = false; @@ -1092,11 +1098,11 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids) for (i = 0; i < so->nkeys; i++) { - GinScanKey key = so->keys + i; + GinScanKey key = so->keys + i; keyrecheck = true; - if (!DatumGetBool(FunctionCall6(&so->ginstate.consistentFn[key->attnum-1], + if (!DatumGetBool(FunctionCall6(&so->ginstate.consistentFn[key->attnum - 1], PointerGetDatum(key->entryRes), UInt16GetDatum(key->strategy), key->query, @@ -1114,7 +1120,7 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids) MemoryContextSwitchTo(oldCtx); MemoryContextReset(so->tempCtx); - if ( match ) + if (match) { tbm_add_tuples(tbm, &pos.item, 1, recheck); (*ntids)++; @@ -1137,10 +1143,10 @@ scanGetItem(IndexScanDesc scan, ItemPointerData *item, bool *recheck) * We return recheck = true if any of the keyGetItem calls return * keyrecheck = true. Note that because the second loop might advance * some keys, this could theoretically be too conservative. In practice - * though, we expect that a consistentFn's recheck result will depend - * only on the operator and the query, so for any one key it should - * stay the same regardless of advancing to new items. So it's not - * worth working harder. + * though, we expect that a consistentFn's recheck result will depend only + * on the operator and the query, so for any one key it should stay the + * same regardless of advancing to new items. So it's not worth working + * harder. */ *recheck = false; @@ -1165,13 +1171,13 @@ scanGetItem(IndexScanDesc scan, ItemPointerData *item, bool *recheck) { int cmp = compareItemPointers(item, &key->curItem); - if ( cmp != 0 && (ItemPointerIsLossyPage(item) || ItemPointerIsLossyPage(&key->curItem)) ) + if (cmp != 0 && (ItemPointerIsLossyPage(item) || ItemPointerIsLossyPage(&key->curItem))) { /* * if one of ItemPointers points to the whole page then * compare only page's number */ - if ( ItemPointerGetBlockNumber(item) == ItemPointerGetBlockNumber(&key->curItem) ) + if (ItemPointerGetBlockNumber(item) == ItemPointerGetBlockNumber(&key->curItem)) cmp = 0; else cmp = (ItemPointerGetBlockNumber(item) > ItemPointerGetBlockNumber(&key->curItem)) ? 1 : -1; @@ -1205,7 +1211,7 @@ Datum gingetbitmap(PG_FUNCTION_ARGS) { IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0); - TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1); + TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1); int64 ntids; if (GinIsNewKey(scan)) @@ -1217,15 +1223,14 @@ gingetbitmap(PG_FUNCTION_ARGS) ntids = 0; /* - * First, scan the pending list and collect any matching entries into - * the bitmap. After we scan a pending item, some other backend could - * post it into the main index, and so we might visit it a second time - * during the main scan. This is okay because we'll just re-set the - * same bit in the bitmap. (The possibility of duplicate visits is a - * major reason why GIN can't support the amgettuple API, however.) - * Note that it would not do to scan the main index before the pending - * list, since concurrent cleanup could then make us miss entries - * entirely. + * First, scan the pending list and collect any matching entries into the + * bitmap. After we scan a pending item, some other backend could post it + * into the main index, and so we might visit it a second time during the + * main scan. This is okay because we'll just re-set the same bit in the + * bitmap. (The possibility of duplicate visits is a major reason why GIN + * can't support the amgettuple API, however.) Note that it would not do + * to scan the main index before the pending list, since concurrent + * cleanup could then make us miss entries entirely. */ scanPendingInsert(scan, tbm, &ntids); @@ -1244,7 +1249,7 @@ gingetbitmap(PG_FUNCTION_ARGS) if (!scanGetItem(scan, &iptr, &recheck)) break; - if ( ItemPointerIsLossyPage(&iptr) ) + if (ItemPointerIsLossyPage(&iptr)) tbm_add_page(tbm, ItemPointerGetBlockNumber(&iptr)); else tbm_add_tuples(tbm, &iptr, 1, recheck); diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c index ef3d4bbb03..2adaed43d4 100644 --- a/src/backend/access/gin/gininsert.c +++ b/src/backend/access/gin/gininsert.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.21 2009/06/06 02:39:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.22 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ @@ -100,15 +100,15 @@ static IndexTuple addItemPointersToTuple(Relation index, GinState *ginstate, GinBtreeStack *stack, IndexTuple old, ItemPointerData *items, uint32 nitem, bool isBuild) { - Datum key = gin_index_getattr(ginstate, old); - OffsetNumber attnum = gintuple_get_attrnum(ginstate, old); - IndexTuple res = GinFormTuple(ginstate, attnum, key, - NULL, nitem + GinGetNPosting(old)); + Datum key = gin_index_getattr(ginstate, old); + OffsetNumber attnum = gintuple_get_attrnum(ginstate, old); + IndexTuple res = GinFormTuple(ginstate, attnum, key, + NULL, nitem + GinGetNPosting(old)); if (res) { /* good, small enough */ - uint32 newnitem; + uint32 newnitem; newnitem = MergeItemPointers(GinGetPosting(res), GinGetPosting(old), GinGetNPosting(old), @@ -236,15 +236,15 @@ ginBuildCallback(Relation index, HeapTuple htup, Datum *values, { GinBuildState *buildstate = (GinBuildState *) state; MemoryContext oldCtx; - int i; + int i; oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx); - for(i=0; i<buildstate->ginstate.origTupdesc->natts;i++) - if ( !isnull[i] ) - buildstate->indtuples += ginHeapTupleBulkInsert(buildstate, - (OffsetNumber)(i+1), values[i], - &htup->t_self); + for (i = 0; i < buildstate->ginstate.origTupdesc->natts; i++) + if (!isnull[i]) + buildstate->indtuples += ginHeapTupleBulkInsert(buildstate, + (OffsetNumber) (i + 1), values[i], + &htup->t_self); /* If we've maxed out our available memory, dump everything to the index */ /* Also dump if the tree seems to be getting too unbalanced */ @@ -254,7 +254,7 @@ ginBuildCallback(Relation index, HeapTuple htup, Datum *values, ItemPointerData *list; Datum entry; uint32 nlist; - OffsetNumber attnum; + OffsetNumber attnum; while ((list = ginGetEntry(&buildstate->accum, &attnum, &entry, &nlist)) != NULL) { @@ -279,7 +279,8 @@ ginbuild(PG_FUNCTION_ARGS) IndexBuildResult *result; double reltuples; GinBuildState buildstate; - Buffer RootBuffer, MetaBuffer; + Buffer RootBuffer, + MetaBuffer; ItemPointerData *list; Datum entry; uint32 nlist; @@ -316,7 +317,7 @@ ginbuild(PG_FUNCTION_ARGS) rdata.next = NULL; recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_CREATE_INDEX, &rdata); - + page = BufferGetPage(RootBuffer); PageSetLSN(page, recptr); PageSetTLI(page, ThisTimeLineID); @@ -420,7 +421,7 @@ gininsert(PG_FUNCTION_ARGS) MemoryContext oldCtx; MemoryContext insertCtx; uint32 res = 0; - int i; + int i; insertCtx = AllocSetContextCreate(CurrentMemoryContext, "Gin insert temporary context", @@ -432,24 +433,24 @@ gininsert(PG_FUNCTION_ARGS) initGinState(&ginstate, index); - if ( GinGetUseFastUpdate(index) ) + if (GinGetUseFastUpdate(index)) { - GinTupleCollector collector; + GinTupleCollector collector; memset(&collector, 0, sizeof(GinTupleCollector)); - for(i=0; i<ginstate.origTupdesc->natts;i++) - if ( !isnull[i] ) + for (i = 0; i < ginstate.origTupdesc->natts; i++) + if (!isnull[i]) res += ginHeapTupleFastCollect(index, &ginstate, &collector, - (OffsetNumber)(i+1), values[i], ht_ctid); + (OffsetNumber) (i + 1), values[i], ht_ctid); ginHeapTupleFastInsert(index, &ginstate, &collector); } else { - for(i=0; i<ginstate.origTupdesc->natts;i++) - if ( !isnull[i] ) - res += ginHeapTupleInsert(index, &ginstate, - (OffsetNumber)(i+1), values[i], ht_ctid); + for (i = 0; i < ginstate.origTupdesc->natts; i++) + if (!isnull[i]) + res += ginHeapTupleInsert(index, &ginstate, + (OffsetNumber) (i + 1), values[i], ht_ctid); } diff --git a/src/backend/access/gin/ginscan.c b/src/backend/access/gin/ginscan.c index a3d1135708..bda97033ad 100644 --- a/src/backend/access/gin/ginscan.c +++ b/src/backend/access/gin/ginscan.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.23 2009/04/05 11:32:01 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.24 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ ginbeginscan(PG_FUNCTION_ARGS) static void fillScanKey(GinState *ginstate, GinScanKey key, OffsetNumber attnum, Datum query, - Datum *entryValues, bool *partial_matches, uint32 nEntryValues, + Datum *entryValues, bool *partial_matches, uint32 nEntryValues, StrategyNumber strategy, Pointer *extra_data) { uint32 i, @@ -68,8 +68,8 @@ fillScanKey(GinState *ginstate, GinScanKey key, OffsetNumber attnum, Datum query key->scanEntry[i].strategy = strategy; key->scanEntry[i].list = NULL; key->scanEntry[i].nlist = 0; - key->scanEntry[i].isPartialMatch = ( ginstate->canPartialMatch[attnum - 1] && partial_matches ) - ? partial_matches[i] : false; + key->scanEntry[i].isPartialMatch = (ginstate->canPartialMatch[attnum - 1] && partial_matches) + ? partial_matches[i] : false; /* link to the equals entry in current scan key */ key->scanEntry[i].master = NULL; @@ -172,12 +172,12 @@ newScanKey(IndexScanDesc scan) ScanKey skey = &scankey[i]; Datum *entryValues; int32 nEntryValues = 0; - bool *partial_matches = NULL; - Pointer *extra_data = NULL; + bool *partial_matches = NULL; + Pointer *extra_data = NULL; /* - * Assume, that GIN-indexable operators are strict, so - * nothing could be found + * Assume, that GIN-indexable operators are strict, so nothing could + * be found */ if (skey->sk_flags & SK_ISNULL) { @@ -196,8 +196,8 @@ newScanKey(IndexScanDesc scan) if (nEntryValues < 0) { /* - * extractQueryFn signals that nothing can match, so we can - * just set isVoidRes flag. No need to examine any more keys. + * extractQueryFn signals that nothing can match, so we can just + * set isVoidRes flag. No need to examine any more keys. */ so->isVoidRes = true; break; @@ -206,10 +206,10 @@ newScanKey(IndexScanDesc scan) if (entryValues == NULL || nEntryValues == 0) { /* - * extractQueryFn signals that everything matches. This would - * require a full scan, which we can't do, but perhaps there - * is another scankey that provides a restriction to use. So - * we keep going and check only at the end. + * extractQueryFn signals that everything matches. This would + * require a full scan, which we can't do, but perhaps there is + * another scankey that provides a restriction to use. So we keep + * going and check only at the end. */ continue; } diff --git a/src/backend/access/gin/ginutil.c b/src/backend/access/gin/ginutil.c index e0951a6a4f..3834ae3b56 100644 --- a/src/backend/access/gin/ginutil.c +++ b/src/backend/access/gin/ginutil.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginutil.c,v 1.21 2009/03/24 20:17:11 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginutil.c,v 1.22 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #include "access/genam.h" #include "access/gin.h" #include "access/reloptions.h" -#include "catalog/pg_type.h" +#include "catalog/pg_type.h" #include "storage/bufmgr.h" #include "storage/freespace.h" #include "storage/indexfsm.h" @@ -25,44 +25,44 @@ void initGinState(GinState *state, Relation index) { - int i; + int i; state->origTupdesc = index->rd_att; state->oneCol = (index->rd_att->natts == 1) ? true : false; - for(i=0;i<index->rd_att->natts;i++) + for (i = 0; i < index->rd_att->natts; i++) { - state->tupdesc[i] = CreateTemplateTupleDesc(2,false); + state->tupdesc[i] = CreateTemplateTupleDesc(2, false); - TupleDescInitEntry( state->tupdesc[i], (AttrNumber) 1, NULL, - INT2OID, -1, 0); - TupleDescInitEntry( state->tupdesc[i], (AttrNumber) 2, NULL, - index->rd_att->attrs[i]->atttypid, - index->rd_att->attrs[i]->atttypmod, - index->rd_att->attrs[i]->attndims - ); + TupleDescInitEntry(state->tupdesc[i], (AttrNumber) 1, NULL, + INT2OID, -1, 0); + TupleDescInitEntry(state->tupdesc[i], (AttrNumber) 2, NULL, + index->rd_att->attrs[i]->atttypid, + index->rd_att->attrs[i]->atttypmod, + index->rd_att->attrs[i]->attndims + ); fmgr_info_copy(&(state->compareFn[i]), - index_getprocinfo(index, i+1, GIN_COMPARE_PROC), - CurrentMemoryContext); + index_getprocinfo(index, i + 1, GIN_COMPARE_PROC), + CurrentMemoryContext); fmgr_info_copy(&(state->extractValueFn[i]), - index_getprocinfo(index, i+1, GIN_EXTRACTVALUE_PROC), - CurrentMemoryContext); + index_getprocinfo(index, i + 1, GIN_EXTRACTVALUE_PROC), + CurrentMemoryContext); fmgr_info_copy(&(state->extractQueryFn[i]), - index_getprocinfo(index, i+1, GIN_EXTRACTQUERY_PROC), - CurrentMemoryContext); + index_getprocinfo(index, i + 1, GIN_EXTRACTQUERY_PROC), + CurrentMemoryContext); fmgr_info_copy(&(state->consistentFn[i]), - index_getprocinfo(index, i+1, GIN_CONSISTENT_PROC), - CurrentMemoryContext); + index_getprocinfo(index, i + 1, GIN_CONSISTENT_PROC), + CurrentMemoryContext); /* * Check opclass capability to do partial match. */ - if ( index_getprocid(index, i+1, GIN_COMPARE_PARTIAL_PROC) != InvalidOid ) + if (index_getprocid(index, i + 1, GIN_COMPARE_PARTIAL_PROC) != InvalidOid) { fmgr_info_copy(&(state->comparePartialFn[i]), - index_getprocinfo(index, i+1, GIN_COMPARE_PARTIAL_PROC), + index_getprocinfo(index, i + 1, GIN_COMPARE_PARTIAL_PROC), CurrentMemoryContext); state->canPartialMatch[i] = true; @@ -82,21 +82,21 @@ gintuple_get_attrnum(GinState *ginstate, IndexTuple tuple) { OffsetNumber colN = FirstOffsetNumber; - if ( !ginstate->oneCol ) + if (!ginstate->oneCol) { - Datum res; - bool isnull; + Datum res; + bool isnull; /* - * First attribute is always int16, so we can safely use any - * tuple descriptor to obtain first attribute of tuple + * First attribute is always int16, so we can safely use any tuple + * descriptor to obtain first attribute of tuple */ res = index_getattr(tuple, FirstOffsetNumber, ginstate->tupdesc[0], &isnull); Assert(!isnull); colN = DatumGetUInt16(res); - Assert( colN >= FirstOffsetNumber && colN <= ginstate->origTupdesc->natts ); + Assert(colN >= FirstOffsetNumber && colN <= ginstate->origTupdesc->natts); } return colN; @@ -108,10 +108,10 @@ gintuple_get_attrnum(GinState *ginstate, IndexTuple tuple) Datum gin_index_getattr(GinState *ginstate, IndexTuple tuple) { - bool isnull; - Datum res; + bool isnull; + Datum res; - if ( ginstate->oneCol ) + if (ginstate->oneCol) { /* * Single column index doesn't store attribute numbers in tuples @@ -122,8 +122,8 @@ gin_index_getattr(GinState *ginstate, IndexTuple tuple) else { /* - * Since the datum type depends on which index column it's from, - * we must be careful to use the right tuple descriptor here. + * Since the datum type depends on which index column it's from, we + * must be careful to use the right tuple descriptor here. */ OffsetNumber colN = gintuple_get_attrnum(ginstate, tuple); @@ -216,8 +216,8 @@ GinInitBuffer(Buffer b, uint32 f) void GinInitMetabuffer(Buffer b) { - GinMetaPageData *metadata; - Page page = BufferGetPage(b); + GinMetaPageData *metadata; + Page page = BufferGetPage(b); GinInitPage(page, GIN_META, BufferGetPageSize(b)); @@ -234,7 +234,7 @@ compareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, Datum b) { return DatumGetInt32( FunctionCall2( - &ginstate->compareFn[attnum-1], + &ginstate->compareFn[attnum - 1], a, b ) ); @@ -242,12 +242,12 @@ compareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, Datum b) int compareAttEntries(GinState *ginstate, OffsetNumber attnum_a, Datum a, - OffsetNumber attnum_b, Datum b) + OffsetNumber attnum_b, Datum b) { - if ( attnum_a == attnum_b ) - return compareEntries( ginstate, attnum_a, a, b); + if (attnum_a == attnum_b) + return compareEntries(ginstate, attnum_a, a, b); - return ( attnum_a < attnum_b ) ? -1 : 1; + return (attnum_a < attnum_b) ? -1 : 1; } typedef struct @@ -275,7 +275,7 @@ extractEntriesS(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nen Datum *entries; entries = (Datum *) DatumGetPointer(FunctionCall2( - &ginstate->extractValueFn[attnum-1], + &ginstate->extractValueFn[attnum - 1], value, PointerGetDatum(nentries) )); @@ -288,7 +288,7 @@ extractEntriesS(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nen { cmpEntriesData arg; - arg.cmpDatumFunc = &ginstate->compareFn[attnum-1]; + arg.cmpDatumFunc = &ginstate->compareFn[attnum - 1]; arg.needUnique = needUnique; qsort_arg(entries, *nentries, sizeof(Datum), (qsort_arg_comparator) cmpEntries, (void *) &arg); @@ -348,7 +348,7 @@ ginoptions(PG_FUNCTION_ARGS) rdopts = allocateReloptStruct(sizeof(GinOptions), options, numoptions); fillRelOptions((void *) rdopts, sizeof(GinOptions), options, numoptions, - validate, tab, lengthof(tab)); + validate, tab, lengthof(tab)); pfree(options); diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c index 934bf7c362..7f2ff9896f 100644 --- a/src/backend/access/gin/ginvacuum.c +++ b/src/backend/access/gin/ginvacuum.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.29 2009/06/06 22:13:50 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.30 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ @@ -533,8 +533,8 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3 if (GinGetNPosting(itup) != newN) { - Datum value; - OffsetNumber attnum; + Datum value; + OffsetNumber attnum; /* * Some ItemPointers was deleted, so we should remake our @@ -724,9 +724,9 @@ ginvacuumcleanup(PG_FUNCTION_ARGS) PG_RETURN_POINTER(stats); } - /* - * Set up all-zero stats and cleanup pending inserts - * if ginbulkdelete wasn't called + /* + * Set up all-zero stats and cleanup pending inserts if ginbulkdelete + * wasn't called */ if (stats == NULL) { @@ -758,7 +758,7 @@ ginvacuumcleanup(PG_FUNCTION_ARGS) if (needLock) UnlockRelationForExtension(index, ExclusiveLock); - totFreePages = 0; + totFreePages = 0; for (blkno = GIN_ROOT_BLKNO + 1; blkno < npages; blkno++) { diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c index 03cdc1129c..1f008b727f 100644 --- a/src/backend/access/gin/ginxlog.c +++ b/src/backend/access/gin/ginxlog.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginxlog.c,v 1.18 2009/03/24 20:17:11 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginxlog.c,v 1.19 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -71,7 +71,8 @@ static void ginRedoCreateIndex(XLogRecPtr lsn, XLogRecord *record) { RelFileNode *node = (RelFileNode *) XLogRecGetData(record); - Buffer RootBuffer, MetaBuffer; + Buffer RootBuffer, + MetaBuffer; Page page; MetaBuffer = XLogReadBuffer(*node, GIN_METAPAGE_BLKNO, true); @@ -446,7 +447,7 @@ ginRedoDeletePage(XLogRecPtr lsn, XLogRecord *record) static void ginRedoUpdateMetapage(XLogRecPtr lsn, XLogRecord *record) { - ginxlogUpdateMeta *data = (ginxlogUpdateMeta*) XLogRecGetData(record); + ginxlogUpdateMeta *data = (ginxlogUpdateMeta *) XLogRecGetData(record); Buffer metabuffer; Page metapage; @@ -455,39 +456,41 @@ ginRedoUpdateMetapage(XLogRecPtr lsn, XLogRecord *record) if (!XLByteLE(lsn, PageGetLSN(metapage))) { - memcpy( GinPageGetMeta(metapage), &data->metadata, sizeof(GinMetaPageData)); + memcpy(GinPageGetMeta(metapage), &data->metadata, sizeof(GinMetaPageData)); PageSetLSN(metapage, lsn); PageSetTLI(metapage, ThisTimeLineID); MarkBufferDirty(metabuffer); } - if ( data->ntuples > 0 ) + if (data->ntuples > 0) { /* * insert into tail page */ if (!(record->xl_info & XLR_BKP_BLOCK_1)) { - Buffer buffer = XLogReadBuffer(data->node, data->metadata.tail, false); - Page page = BufferGetPage(buffer); + Buffer buffer = XLogReadBuffer(data->node, data->metadata.tail, false); + Page page = BufferGetPage(buffer); - if ( !XLByteLE(lsn, PageGetLSN(page))) + if (!XLByteLE(lsn, PageGetLSN(page))) { - OffsetNumber l, off = (PageIsEmpty(page)) ? FirstOffsetNumber : - OffsetNumberNext(PageGetMaxOffsetNumber(page)); - int i, tupsize; - IndexTuple tuples = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogUpdateMeta)); - - for(i=0; i<data->ntuples; i++) + OffsetNumber l, + off = (PageIsEmpty(page)) ? FirstOffsetNumber : + OffsetNumberNext(PageGetMaxOffsetNumber(page)); + int i, + tupsize; + IndexTuple tuples = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogUpdateMeta)); + + for (i = 0; i < data->ntuples; i++) { tupsize = IndexTupleSize(tuples); - l = PageAddItem(page, (Item)tuples, tupsize, off, false, false); + l = PageAddItem(page, (Item) tuples, tupsize, off, false, false); if (l == InvalidOffsetNumber) elog(ERROR, "failed to add item to index page"); - tuples = (IndexTuple)( ((char*)tuples) + tupsize ); + tuples = (IndexTuple) (((char *) tuples) + tupsize); } /* @@ -502,16 +505,16 @@ ginRedoUpdateMetapage(XLogRecPtr lsn, XLogRecord *record) UnlockReleaseBuffer(buffer); } } - else if ( data->prevTail != InvalidBlockNumber ) + else if (data->prevTail != InvalidBlockNumber) { /* * New tail */ - Buffer buffer = XLogReadBuffer(data->node, data->prevTail, false); - Page page = BufferGetPage(buffer); + Buffer buffer = XLogReadBuffer(data->node, data->prevTail, false); + Page page = BufferGetPage(buffer); - if ( !XLByteLE(lsn, PageGetLSN(page))) + if (!XLByteLE(lsn, PageGetLSN(page))) { GinPageGetOpaque(page)->rightlink = data->newRightlink; @@ -528,12 +531,14 @@ ginRedoUpdateMetapage(XLogRecPtr lsn, XLogRecord *record) static void ginRedoInsertListPage(XLogRecPtr lsn, XLogRecord *record) { - ginxlogInsertListPage *data = (ginxlogInsertListPage*) XLogRecGetData(record); - Buffer buffer; - Page page; - OffsetNumber l, off = FirstOffsetNumber; - int i, tupsize; - IndexTuple tuples = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogInsertListPage)); + ginxlogInsertListPage *data = (ginxlogInsertListPage *) XLogRecGetData(record); + Buffer buffer; + Page page; + OffsetNumber l, + off = FirstOffsetNumber; + int i, + tupsize; + IndexTuple tuples = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogInsertListPage)); if (record->xl_info & XLR_BKP_BLOCK_1) return; @@ -543,7 +548,7 @@ ginRedoInsertListPage(XLogRecPtr lsn, XLogRecord *record) GinInitBuffer(buffer, GIN_LIST); GinPageGetOpaque(page)->rightlink = data->rightlink; - if ( data->rightlink == InvalidBlockNumber ) + if (data->rightlink == InvalidBlockNumber) { /* tail of sublist */ GinPageSetFullRow(page); @@ -554,16 +559,16 @@ ginRedoInsertListPage(XLogRecPtr lsn, XLogRecord *record) GinPageGetOpaque(page)->maxoff = 0; } - for(i=0; i<data->ntuples; i++) + for (i = 0; i < data->ntuples; i++) { tupsize = IndexTupleSize(tuples); - l = PageAddItem(page, (Item)tuples, tupsize, off, false, false); + l = PageAddItem(page, (Item) tuples, tupsize, off, false, false); if (l == InvalidOffsetNumber) elog(ERROR, "failed to add item to index page"); - tuples = (IndexTuple)( ((char*)tuples) + tupsize ); + tuples = (IndexTuple) (((char *) tuples) + tupsize); } PageSetLSN(page, lsn); @@ -576,28 +581,28 @@ ginRedoInsertListPage(XLogRecPtr lsn, XLogRecord *record) static void ginRedoDeleteListPages(XLogRecPtr lsn, XLogRecord *record) { - ginxlogDeleteListPages *data = (ginxlogDeleteListPages*) XLogRecGetData(record); + ginxlogDeleteListPages *data = (ginxlogDeleteListPages *) XLogRecGetData(record); Buffer metabuffer; Page metapage; - int i; + int i; metabuffer = XLogReadBuffer(data->node, GIN_METAPAGE_BLKNO, false); metapage = BufferGetPage(metabuffer); if (!XLByteLE(lsn, PageGetLSN(metapage))) { - memcpy( GinPageGetMeta(metapage), &data->metadata, sizeof(GinMetaPageData)); + memcpy(GinPageGetMeta(metapage), &data->metadata, sizeof(GinMetaPageData)); PageSetLSN(metapage, lsn); PageSetTLI(metapage, ThisTimeLineID); MarkBufferDirty(metabuffer); } - for(i=0; i<data->ndeleted; i++) + for (i = 0; i < data->ndeleted; i++) { - Buffer buffer = XLogReadBuffer(data->node,data->toDelete[i],false); - Page page = BufferGetPage(buffer); + Buffer buffer = XLogReadBuffer(data->node, data->toDelete[i], false); + Page page = BufferGetPage(buffer); - if ( !XLByteLE(lsn, PageGetLSN(page))) + if (!XLByteLE(lsn, PageGetLSN(page))) { GinPageGetOpaque(page)->flags = GIN_DELETED; @@ -645,7 +650,7 @@ gin_redo(XLogRecPtr lsn, XLogRecord *record) case XLOG_GIN_INSERT_LISTPAGE: ginRedoInsertListPage(lsn, record); break; - case XLOG_GIN_DELETE_LISTPAGE: + case XLOG_GIN_DELETE_LISTPAGE: ginRedoDeleteListPages(lsn, record); break; default: @@ -705,15 +710,15 @@ gin_desc(StringInfo buf, uint8 xl_info, char *rec) break; case XLOG_GIN_UPDATE_META_PAGE: appendStringInfo(buf, "Update metapage, "); - desc_node(buf, ((ginxlogUpdateMeta *) rec)->node, ((ginxlogUpdateMeta *) rec)->metadata.tail); + desc_node(buf, ((ginxlogUpdateMeta *) rec)->node, ((ginxlogUpdateMeta *) rec)->metadata.tail); break; case XLOG_GIN_INSERT_LISTPAGE: appendStringInfo(buf, "Insert new list page, "); - desc_node(buf, ((ginxlogInsertListPage *) rec)->node, ((ginxlogInsertListPage *) rec)->blkno); + desc_node(buf, ((ginxlogInsertListPage *) rec)->node, ((ginxlogInsertListPage *) rec)->blkno); break; case XLOG_GIN_DELETE_LISTPAGE: appendStringInfo(buf, "Delete list pages (%d), ", ((ginxlogDeleteListPages *) rec)->ndeleted); - desc_node(buf, ((ginxlogDeleteListPages *) rec)->node, ((ginxlogDeleteListPages *) rec)->metadata.head); + desc_node(buf, ((ginxlogDeleteListPages *) rec)->node, ((ginxlogDeleteListPages *) rec)->metadata.head); break; default: elog(PANIC, "gin_desc: unknown op code %u", info); diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index 9701d30e38..e7ca8f6476 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.80 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.81 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,7 +79,7 @@ gistgettuple(PG_FUNCTION_ARGS) so = (GISTScanOpaque) scan->opaque; - if (dir != ForwardScanDirection) + if (dir != ForwardScanDirection) elog(ERROR, "GiST doesn't support other scan directions than forward"); /* @@ -101,8 +101,8 @@ Datum gistgetbitmap(PG_FUNCTION_ARGS) { IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0); - TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1); - int64 ntids; + TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1); + int64 ntids; ntids = gistnext(scan, tbm); @@ -136,10 +136,10 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm) so = (GISTScanOpaque) scan->opaque; - if ( so->qual_ok == false ) + if (so->qual_ok == false) return 0; - if ( so->curbuf == InvalidBuffer ) + if (so->curbuf == InvalidBuffer) { if (ItemPointerIsValid(&so->curpos) == false) { @@ -155,7 +155,7 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm) stk->block = GIST_ROOT_BLKNO; pgstat_count_index_scan(scan->indexRelation); - } + } else { /* scan is finished */ @@ -164,25 +164,25 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm) } /* - * check stored pointers from last visit + * check stored pointers from last visit */ - if ( so->nPageData > 0 ) + if (so->nPageData > 0) { /* * gistgetmulti never should go here */ - Assert( tbm == NULL ); + Assert(tbm == NULL); - if ( so->curPageData < so->nPageData ) + if (so->curPageData < so->nPageData) { - scan->xs_ctup.t_self = so->pageData[ so->curPageData ].heapPtr; - scan->xs_recheck = so->pageData[ so->curPageData ].recheck; + scan->xs_ctup.t_self = so->pageData[so->curPageData].heapPtr; + scan->xs_recheck = so->pageData[so->curPageData].recheck; ItemPointerSet(&so->curpos, - BufferGetBlockNumber(so->curbuf), - so->pageData[ so->curPageData ].pageOffset); + BufferGetBlockNumber(so->curbuf), + so->pageData[so->curPageData].pageOffset); - so->curPageData ++; + so->curPageData++; return 1; } @@ -227,7 +227,7 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm) if (!XLogRecPtrIsInvalid(so->stack->parentlsn) && XLByteLT(so->stack->parentlsn, opaque->nsn) && opaque->rightlink != InvalidBlockNumber /* sanity check */ && - (so->stack->next == NULL || so->stack->next->block != opaque->rightlink) /* check if already + (so->stack->next == NULL || so->stack->next->block != opaque->rightlink) /* check if already added */ ) { /* detect page split, follow right link to add pages */ @@ -272,12 +272,12 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm) if (!OffsetNumberIsValid(n)) { /* - * If we was called from gistgettuple and current buffer contains - * something matched then make a recursive call - it will return - * ItemPointer from so->pageData. But we save buffer pinned to - * support tuple's killing + * If we was called from gistgettuple and current buffer + * contains something matched then make a recursive call - it + * will return ItemPointer from so->pageData. But we save + * buffer pinned to support tuple's killing */ - if ( !tbm && so->nPageData > 0 ) + if (!tbm && so->nPageData > 0) { LockBuffer(so->curbuf, GIST_UNLOCK); return gistnext(scan, NULL); @@ -324,12 +324,12 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm) ntids++; if (tbm != NULL) tbm_add_tuples(tbm, &it->t_tid, 1, scan->xs_recheck); - else + else { - so->pageData[ so->nPageData ].heapPtr = it->t_tid; - so->pageData[ so->nPageData ].pageOffset = n; - so->pageData[ so->nPageData ].recheck = scan->xs_recheck; - so->nPageData ++; + so->pageData[so->nPageData].heapPtr = it->t_tid; + so->pageData[so->nPageData].pageOffset = n; + so->pageData[so->nPageData].recheck = scan->xs_recheck; + so->nPageData++; } } } @@ -437,8 +437,8 @@ gistindex_keytest(IndexTuple tuple, /* * Call the Consistent function to evaluate the test. The * arguments are the index datum (as a GISTENTRY*), the comparison - * datum, the comparison operator's strategy number and - * subtype from pg_amop, and the recheck flag. + * datum, the comparison operator's strategy number and subtype + * from pg_amop, and the recheck flag. * * (Presently there's no need to pass the subtype since it'll * always be zero, but might as well pass it for possible future diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c index 396b93ab97..ef44380e77 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.16 2009/04/06 14:27:27 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.17 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,6 +86,7 @@ gist_box_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); BOX *query = PG_GETARG_BOX_P(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); @@ -279,11 +280,11 @@ chooseLR(GIST_SPLITVEC *v, static void fallbackSplit(GistEntryVector *entryvec, GIST_SPLITVEC *v) { - OffsetNumber i, - maxoff; - BOX *unionL = NULL, - *unionR = NULL; - int nbytes; + OffsetNumber i, + maxoff; + BOX *unionL = NULL, + *unionR = NULL; + int nbytes; maxoff = entryvec->n - 1; @@ -294,7 +295,7 @@ fallbackSplit(GistEntryVector *entryvec, GIST_SPLITVEC *v) for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - BOX * cur = DatumGetBoxP(entryvec->vector[i].key); + BOX *cur = DatumGetBoxP(entryvec->vector[i].key); if (i <= (maxoff - FirstOffsetNumber + 1) / 2) { @@ -767,6 +768,7 @@ gist_poly_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); POLYGON *query = PG_GETARG_POLYGON_P(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); bool result; @@ -843,6 +845,7 @@ gist_circle_consistent(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); CIRCLE *query = PG_GETARG_CIRCLE_P(1); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); + /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); BOX bbox; diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index 68924332b7..aed3e95b4e 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.75 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.76 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -94,11 +94,13 @@ gistrescan(PG_FUNCTION_ARGS) * Next, if any of keys is a NULL and that key is not marked with * SK_SEARCHNULL then nothing can be found. */ - for (i = 0; i < scan->numberOfKeys; i++) { + for (i = 0; i < scan->numberOfKeys; i++) + { scan->keyData[i].sk_func = so->giststate->consistentFn[scan->keyData[i].sk_attno - 1]; - if ( scan->keyData[i].sk_flags & SK_ISNULL ) { - if ( (scan->keyData[i].sk_flags & SK_SEARCHNULL) == 0 ) + if (scan->keyData[i].sk_flags & SK_ISNULL) + { + if ((scan->keyData[i].sk_flags & SK_SEARCHNULL) == 0) so->qual_ok = false; } } diff --git a/src/backend/access/gist/gistsplit.c b/src/backend/access/gist/gistsplit.c index 0d11e7c9ab..c5e5f6f13a 100644 --- a/src/backend/access/gist/gistsplit.c +++ b/src/backend/access/gist/gistsplit.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistsplit.c,v 1.9 2009/06/10 20:02:15 petere Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistsplit.c,v 1.10 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -281,7 +281,7 @@ supportSecondarySplit(Relation r, GISTSTATE *giststate, int attno, GIST_SPLITVEC } /* - * Trivial picksplit implementaion. Function called only + * Trivial picksplit implementaion. Function called only * if user-defined picksplit puts all keys to the one page. * That is a bug of user-defined picksplit but we'd like * to "fix" that. @@ -289,10 +289,10 @@ supportSecondarySplit(Relation r, GISTSTATE *giststate, int attno, GIST_SPLITVEC static void genericPickSplit(GISTSTATE *giststate, GistEntryVector *entryvec, GIST_SPLITVEC *v, int attno) { - OffsetNumber i, - maxoff; - int nbytes; - GistEntryVector *evec; + OffsetNumber i, + maxoff; + int nbytes; + GistEntryVector *evec; maxoff = entryvec->n - 1; @@ -320,21 +320,21 @@ genericPickSplit(GISTSTATE *giststate, GistEntryVector *entryvec, GIST_SPLITVEC * Form unions of each page */ - evec = palloc( sizeof(GISTENTRY) * entryvec->n + GEVHDRSZ ); + evec = palloc(sizeof(GISTENTRY) * entryvec->n + GEVHDRSZ); evec->n = v->spl_nleft; - memcpy(evec->vector, entryvec->vector + FirstOffsetNumber, - sizeof(GISTENTRY) * evec->n); - v->spl_ldatum = FunctionCall2(&giststate->unionFn[attno], - PointerGetDatum(evec), - PointerGetDatum(&nbytes)); + memcpy(evec->vector, entryvec->vector + FirstOffsetNumber, + sizeof(GISTENTRY) * evec->n); + v->spl_ldatum = FunctionCall2(&giststate->unionFn[attno], + PointerGetDatum(evec), + PointerGetDatum(&nbytes)); evec->n = v->spl_nright; - memcpy(evec->vector, entryvec->vector + FirstOffsetNumber + v->spl_nleft, - sizeof(GISTENTRY) * evec->n); - v->spl_rdatum = FunctionCall2(&giststate->unionFn[attno], - PointerGetDatum(evec), - PointerGetDatum(&nbytes)); + memcpy(evec->vector, entryvec->vector + FirstOffsetNumber + v->spl_nleft, + sizeof(GISTENTRY) * evec->n); + v->spl_rdatum = FunctionCall2(&giststate->unionFn[attno], + PointerGetDatum(evec), + PointerGetDatum(&nbytes)); } /* @@ -365,17 +365,17 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec PointerGetDatum(entryvec), PointerGetDatum(sv)); - if ( sv->spl_nleft == 0 || sv->spl_nright == 0 ) + if (sv->spl_nleft == 0 || sv->spl_nright == 0) { ereport(DEBUG1, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("picksplit method for %d column of index \"%s\" failed", - attno+1, RelationGetRelationName(r)), + errmsg("picksplit method for %d column of index \"%s\" failed", + attno + 1, RelationGetRelationName(r)), errhint("The index is not optimal. To optimize it, contact a developer, or try to use the column as the second one in the CREATE INDEX command."))); /* - * Reinit GIST_SPLITVEC. Although that fields are not used - * by genericPickSplit(), let us set up it for further processing + * Reinit GIST_SPLITVEC. Although that fields are not used by + * genericPickSplit(), let us set up it for further processing */ sv->spl_ldatum_exists = (v->spl_lisnull[attno]) ? false : true; sv->spl_rdatum_exists = (v->spl_risnull[attno]) ? false : true; diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index fa1e3088ad..78eb378725 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.33 2009/01/05 17:14:28 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.34 2009/06/11 14:48:53 momjian Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -43,7 +43,8 @@ gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off) for (i = 0; i < len; i++) { - Size sz = IndexTupleSize(itup[i]); + Size sz = IndexTupleSize(itup[i]); + l = PageAddItem(page, (Item) itup[i], sz, off, false, false); if (l == InvalidOffsetNumber) elog(ERROR, "failed to add item to GiST index page, item %d out of %d, size %d bytes", diff --git a/src/backend/access/gist/gistvacuum.c b/src/backend/access/gist/gistvacuum.c index 833e6c574e..975f9d8c56 100644 --- a/src/backend/access/gist/gistvacuum.c +++ b/src/backend/access/gist/gistvacuum.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.44 2009/06/06 22:13:50 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.45 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -510,7 +510,7 @@ gistvacuumcleanup(PG_FUNCTION_ARGS) Relation rel = info->index; BlockNumber npages, blkno; - BlockNumber totFreePages; + BlockNumber totFreePages; BlockNumber lastBlock = GIST_ROOT_BLKNO, lastFilledBlock = GIST_ROOT_BLKNO; bool needLock; diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index 4c1cd5ceda..49b6594f1e 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.111 2009/06/06 22:13:50 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.112 2009/06/11 14:48:53 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -52,7 +52,7 @@ hashbuild(PG_FUNCTION_ARGS) Relation index = (Relation) PG_GETARG_POINTER(1); IndexInfo *indexInfo = (IndexInfo *) PG_GETARG_POINTER(2); IndexBuildResult *result; - BlockNumber relpages; + BlockNumber relpages; double reltuples; uint32 num_buckets; HashBuildState buildstate; @@ -76,12 +76,12 @@ hashbuild(PG_FUNCTION_ARGS) * (assuming their hash codes are pretty random) there will be no locality * of access to the index, and if the index is bigger than available RAM * then we'll thrash horribly. To prevent that scenario, we can sort the - * tuples by (expected) bucket number. However, such a sort is useless + * tuples by (expected) bucket number. However, such a sort is useless * overhead when the index does fit in RAM. We choose to sort if the * initial index size exceeds NBuffers. * - * NOTE: this test will need adjustment if a bucket is ever different - * from one page. + * NOTE: this test will need adjustment if a bucket is ever different from + * one page. */ if (num_buckets >= (uint32) NBuffers) buildstate.spool = _h_spoolinit(index, num_buckets); @@ -285,7 +285,7 @@ Datum hashgetbitmap(PG_FUNCTION_ARGS) { IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0); - TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1); + TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1); HashScanOpaque so = (HashScanOpaque) scan->opaque; bool res; int64 ntids = 0; @@ -294,7 +294,7 @@ hashgetbitmap(PG_FUNCTION_ARGS) while (res) { - bool add_tuple; + bool add_tuple; /* * Skip killed tuples if asked to. @@ -312,7 +312,7 @@ hashgetbitmap(PG_FUNCTION_ARGS) add_tuple = true; /* Save tuple ID, and continue scanning */ - if (add_tuple) + if (add_tuple) { /* Note we mark the tuple ID as requiring recheck */ tbm_add_tuples(tbm, &scan->xs_ctup.t_self, 1, true); @@ -481,7 +481,7 @@ hashbulkdelete(PG_FUNCTION_ARGS) * each bucket. */ metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE); - metap = HashPageGetMeta(BufferGetPage(metabuf)); + metap = HashPageGetMeta(BufferGetPage(metabuf)); orig_maxbucket = metap->hashm_maxbucket; orig_ntuples = metap->hashm_ntuples; memcpy(&local_metapage, metap, sizeof(local_metapage)); diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index 4561a09481..3242e2713e 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.58 2009/02/09 21:18:28 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.59 2009/06/11 14:48:53 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -225,35 +225,35 @@ hashvarlena(PG_FUNCTION_ARGS) * are sometimes the same for one pair and different for another pair. * This was tested for: * * pairs that differed by one bit, by two bits, in any combination - * of top bits of (a,b,c), or in any combination of bottom bits of - * (a,b,c). + * of top bits of (a,b,c), or in any combination of bottom bits of + * (a,b,c). * * "differ" is defined as +, -, ^, or ~^. For + and -, I transformed - * the output delta to a Gray code (a^(a>>1)) so a string of 1's (as - * is commonly produced by subtraction) look like a single 1-bit - * difference. + * the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + * is commonly produced by subtraction) look like a single 1-bit + * difference. * * the base values were pseudorandom, all zero but one bit set, or - * all zero plus a counter that starts at zero. - * + * all zero plus a counter that starts at zero. + * * This does not achieve avalanche. There are input bits of (a,b,c) * that fail to affect some output bits of (a,b,c), especially of a. The * most thoroughly mixed value is c, but it doesn't really even achieve - * avalanche in c. - * + * avalanche in c. + * * This allows some parallelism. Read-after-writes are good at doubling * the number of bits affected, so the goal of mixing pulls in the opposite - * direction from the goal of parallelism. I did what I could. Rotates + * direction from the goal of parallelism. I did what I could. Rotates * seem to cost as much as shifts on every machine I could lay my hands on, * and rotates are much kinder to the top and bottom bits, so I used rotates. *---------- */ #define mix(a,b,c) \ { \ - a -= c; a ^= rot(c, 4); c += b; \ - b -= a; b ^= rot(a, 6); a += c; \ - c -= b; c ^= rot(b, 8); b += a; \ - a -= c; a ^= rot(c,16); c += b; \ - b -= a; b ^= rot(a,19); a += c; \ - c -= b; c ^= rot(b, 4); b += a; \ + a -= c; a ^= rot(c, 4); c += b; \ + b -= a; b ^= rot(a, 6); a += c; \ + c -= b; c ^= rot(b, 8); b += a; \ + a -= c; a ^= rot(c,16); c += b; \ + b -= a; b ^= rot(a,19); a += c; \ + c -= b; c ^= rot(b, 4); b += a; \ } /*---------- @@ -262,20 +262,20 @@ hashvarlena(PG_FUNCTION_ARGS) * Pairs of (a,b,c) values differing in only a few bits will usually * produce values of c that look totally different. This was tested for * * pairs that differed by one bit, by two bits, in any combination - * of top bits of (a,b,c), or in any combination of bottom bits of - * (a,b,c). + * of top bits of (a,b,c), or in any combination of bottom bits of + * (a,b,c). * * "differ" is defined as +, -, ^, or ~^. For + and -, I transformed - * the output delta to a Gray code (a^(a>>1)) so a string of 1's (as - * is commonly produced by subtraction) look like a single 1-bit - * difference. + * the output delta to a Gray code (a^(a>>1)) so a string of 1's (as + * is commonly produced by subtraction) look like a single 1-bit + * difference. * * the base values were pseudorandom, all zero but one bit set, or - * all zero plus a counter that starts at zero. - * + * all zero plus a counter that starts at zero. + * * The use of separate functions for mix() and final() allow for a * substantial performance increase since final() does not need to * do well in reverse, but is does need to affect all output bits. * mix(), on the other hand, does not need to affect all output - * bits (affecting 32 bits is enough). The original hash function had + * bits (affecting 32 bits is enough). The original hash function had * a single mixing operation that had to satisfy both sets of requirements * and was slower as a result. *---------- @@ -374,9 +374,9 @@ hash_any(register const unsigned char *k, register int keylen) /* fall through */ case 1: a += ((uint32) k[0] << 24); - /* case 0: nothing left to add */ + /* case 0: nothing left to add */ } -#else /* !WORDS_BIGENDIAN */ +#else /* !WORDS_BIGENDIAN */ switch (len) { case 11: @@ -413,9 +413,9 @@ hash_any(register const unsigned char *k, register int keylen) /* fall through */ case 1: a += k[0]; - /* case 0: nothing left to add */ + /* case 0: nothing left to add */ } -#endif /* WORDS_BIGENDIAN */ +#endif /* WORDS_BIGENDIAN */ } else { @@ -428,11 +428,11 @@ hash_any(register const unsigned char *k, register int keylen) a += (k[3] + ((uint32) k[2] << 8) + ((uint32) k[1] << 16) + ((uint32) k[0] << 24)); b += (k[7] + ((uint32) k[6] << 8) + ((uint32) k[5] << 16) + ((uint32) k[4] << 24)); c += (k[11] + ((uint32) k[10] << 8) + ((uint32) k[9] << 16) + ((uint32) k[8] << 24)); -#else /* !WORDS_BIGENDIAN */ +#else /* !WORDS_BIGENDIAN */ a += (k[0] + ((uint32) k[1] << 8) + ((uint32) k[2] << 16) + ((uint32) k[3] << 24)); b += (k[4] + ((uint32) k[5] << 8) + ((uint32) k[6] << 16) + ((uint32) k[7] << 24)); c += (k[8] + ((uint32) k[9] << 8) + ((uint32) k[10] << 16) + ((uint32) k[11] << 24)); -#endif /* WORDS_BIGENDIAN */ +#endif /* WORDS_BIGENDIAN */ mix(a, b, c); k += 12; len -= 12; @@ -465,9 +465,9 @@ hash_any(register const unsigned char *k, register int keylen) a += ((uint32) k[1] << 16); case 1: a += ((uint32) k[0] << 24); - /* case 0: nothing left to add */ + /* case 0: nothing left to add */ } -#else /* !WORDS_BIGENDIAN */ +#else /* !WORDS_BIGENDIAN */ switch (len) /* all the case statements fall through */ { case 11: @@ -493,9 +493,9 @@ hash_any(register const unsigned char *k, register int keylen) a += ((uint32) k[1] << 8); case 1: a += k[0]; - /* case 0: nothing left to add */ + /* case 0: nothing left to add */ } -#endif /* WORDS_BIGENDIAN */ +#endif /* WORDS_BIGENDIAN */ } final(a, b, c); diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index f47d213298..bd1f930e06 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.79 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.80 2009/06/11 14:48:53 momjian Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -361,8 +361,8 @@ _hash_metapinit(Relation rel, double num_tuples) /* * Choose the number of initial bucket pages to match the fill factor * given the estimated number of tuples. We round up the result to the - * next power of 2, however, and always force at least 2 bucket pages. - * The upper limit is determined by considerations explained in + * next power of 2, however, and always force at least 2 bucket pages. The + * upper limit is determined by considerations explained in * _hash_expandtable(). */ dnumbuckets = num_tuples / ffactor; @@ -421,8 +421,8 @@ _hash_metapinit(Relation rel, double num_tuples) /* * We initialize the index with N buckets, 0 .. N-1, occupying physical - * blocks 1 to N. The first freespace bitmap page is in block N+1. - * Since N is a power of 2, we can set the masks this way: + * blocks 1 to N. The first freespace bitmap page is in block N+1. Since + * N is a power of 2, we can set the masks this way: */ metap->hashm_maxbucket = metap->hashm_lowmask = num_buckets - 1; metap->hashm_highmask = (num_buckets << 1) - 1; @@ -438,8 +438,8 @@ _hash_metapinit(Relation rel, double num_tuples) /* * Release buffer lock on the metapage while we initialize buckets. * Otherwise, we'll be in interrupt holdoff and the CHECK_FOR_INTERRUPTS - * won't accomplish anything. It's a bad idea to hold buffer locks - * for long intervals in any case, since that can block the bgwriter. + * won't accomplish anything. It's a bad idea to hold buffer locks for + * long intervals in any case, since that can block the bgwriter. */ _hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_NOLOCK); @@ -552,8 +552,8 @@ _hash_expandtable(Relation rel, Buffer metabuf) * _hash_alloc_buckets() would fail, but if we supported buckets smaller * than a disk block then this would be an independent constraint. * - * If you change this, see also the maximum initial number of buckets - * in _hash_metapinit(). + * If you change this, see also the maximum initial number of buckets in + * _hash_metapinit(). */ if (metap->hashm_maxbucket >= (uint32) 0x7FFFFFFE) goto fail; @@ -839,8 +839,8 @@ _hash_splitbucket(Relation rel, } /* - * Fetch the item's hash key (conveniently stored in the item) - * and determine which bucket it now belongs in. + * Fetch the item's hash key (conveniently stored in the item) and + * determine which bucket it now belongs in. */ itup = (IndexTuple) PageGetItem(opage, PageGetItemId(opage, ooffnum)); bucket = _hash_hashkey2bucket(_hash_get_indextuple_hashkey(itup), diff --git a/src/backend/access/hash/hashscan.c b/src/backend/access/hash/hashscan.c index 8cd371e902..1b0ce2c739 100644 --- a/src/backend/access/hash/hashscan.c +++ b/src/backend/access/hash/hashscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashscan.c,v 1.46 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashscan.c,v 1.47 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,8 +59,8 @@ ReleaseResources_hash(void) /* * Release all HashScanList items belonging to the current ResourceOwner. * Note that we do not release the underlying IndexScanDesc; that's in - * executor memory and will go away on its own (in fact quite possibly - * has gone away already, so we mustn't try to touch it here). + * executor memory and will go away on its own (in fact quite possibly has + * gone away already, so we mustn't try to touch it here). * * Note: this should be a no-op during normal query shutdown. However, in * an abort situation ExecutorEnd is not called and so there may be open diff --git a/src/backend/access/hash/hashsearch.c b/src/backend/access/hash/hashsearch.c index 5a9763fe9a..fec2f5d78a 100644 --- a/src/backend/access/hash/hashsearch.c +++ b/src/backend/access/hash/hashsearch.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.56 2009/05/05 19:36:32 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.57 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -312,15 +312,15 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) for (;;) { /* - * check if we're still in the range of items with - * the target hash key + * check if we're still in the range of items with the + * target hash key */ if (offnum <= maxoff) { Assert(offnum >= FirstOffsetNumber); itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offnum)); if (so->hashso_sk_hash == _hash_get_indextuple_hashkey(itup)) - break; /* yes, so exit for-loop */ + break; /* yes, so exit for-loop */ } /* @@ -353,15 +353,15 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) for (;;) { /* - * check if we're still in the range of items with - * the target hash key + * check if we're still in the range of items with the + * target hash key */ if (offnum >= FirstOffsetNumber) { Assert(offnum <= maxoff); itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offnum)); if (so->hashso_sk_hash == _hash_get_indextuple_hashkey(itup)) - break; /* yes, so exit for-loop */ + break; /* yes, so exit for-loop */ } /* diff --git a/src/backend/access/hash/hashsort.c b/src/backend/access/hash/hashsort.c index 6ba8362a9e..00e7dc5f5d 100644 --- a/src/backend/access/hash/hashsort.c +++ b/src/backend/access/hash/hashsort.c @@ -8,7 +8,7 @@ * thrashing. We use tuplesort.c to sort the given index tuples into order. * * Note: if the number of rows in the table has been underestimated, - * bucket splits may occur during the index build. In that case we'd + * bucket splits may occur during the index build. In that case we'd * be inserting into two or more buckets for each possible masked-off * hash code value. That's no big problem though, since we'll still have * plenty of locality of access. @@ -18,7 +18,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashsort.c,v 1.2 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashsort.c,v 1.3 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,13 +52,13 @@ _h_spoolinit(Relation index, uint32 num_buckets) hspool->index = index; /* - * Determine the bitmask for hash code values. Since there are currently + * Determine the bitmask for hash code values. Since there are currently * num_buckets buckets in the index, the appropriate mask can be computed * as follows. * - * Note: at present, the passed-in num_buckets is always a power of 2, - * so we could just compute num_buckets - 1. We prefer not to assume - * that here, though. + * Note: at present, the passed-in num_buckets is always a power of 2, so + * we could just compute num_buckets - 1. We prefer not to assume that + * here, though. */ hash_mask = (((uint32) 1) << _hash_log2(num_buckets)) - 1; diff --git a/src/backend/access/hash/hashutil.c b/src/backend/access/hash/hashutil.c index 42e79376f8..ba1d6fbbf5 100644 --- a/src/backend/access/hash/hashutil.c +++ b/src/backend/access/hash/hashutil.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.59 2009/01/05 17:14:28 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.60 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,10 +29,10 @@ bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup) { /* - * Currently, we can't check any of the scan conditions since we do - * not have the original index entry value to supply to the sk_func. - * Always return true; we expect that hashgettuple already set the - * recheck flag to make the main indexscan code do it. + * Currently, we can't check any of the scan conditions since we do not + * have the original index entry value to supply to the sk_func. Always + * return true; we expect that hashgettuple already set the recheck flag + * to make the main indexscan code do it. */ #ifdef NOT_USED TupleDesc tupdesc = RelationGetDescr(scan->indexRelation); @@ -240,8 +240,8 @@ _hash_get_indextuple_hashkey(IndexTuple itup) char *attp; /* - * We assume the hash key is the first attribute and can't be null, - * so this can be done crudely but very very cheaply ... + * We assume the hash key is the first attribute and can't be null, so + * this can be done crudely but very very cheaply ... */ attp = (char *) itup + IndexInfoFindDataOffset(itup->t_info); return *((uint32 *) attp); @@ -253,10 +253,10 @@ _hash_get_indextuple_hashkey(IndexTuple itup) IndexTuple _hash_form_tuple(Relation index, Datum *values, bool *isnull) { - IndexTuple itup; - uint32 hashkey; - Datum hashkeydatum; - TupleDesc hashdesc; + IndexTuple itup; + uint32 hashkey; + Datum hashkeydatum; + TupleDesc hashdesc; if (isnull[0]) hashkeydatum = (Datum) 0; @@ -280,14 +280,14 @@ _hash_form_tuple(Relation index, Datum *values, bool *isnull) * * Returns the offset of the first index entry having hashkey >= hash_value, * or the page's max offset plus one if hash_value is greater than all - * existing hash keys in the page. This is the appropriate place to start + * existing hash keys in the page. This is the appropriate place to start * a search, or to insert a new item. */ OffsetNumber _hash_binsearch(Page page, uint32 hash_value) { - OffsetNumber upper; - OffsetNumber lower; + OffsetNumber upper; + OffsetNumber lower; /* Loop invariant: lower <= desired place <= upper */ upper = PageGetMaxOffsetNumber(page) + 1; @@ -295,9 +295,9 @@ _hash_binsearch(Page page, uint32 hash_value) while (upper > lower) { - OffsetNumber off; - IndexTuple itup; - uint32 hashkey; + OffsetNumber off; + IndexTuple itup; + uint32 hashkey; off = (upper + lower) / 2; Assert(OffsetNumberIsValid(off)); @@ -324,8 +324,8 @@ _hash_binsearch(Page page, uint32 hash_value) OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value) { - OffsetNumber upper; - OffsetNumber lower; + OffsetNumber upper; + OffsetNumber lower; /* Loop invariant: lower <= desired place <= upper */ upper = PageGetMaxOffsetNumber(page); @@ -333,9 +333,9 @@ _hash_binsearch_last(Page page, uint32 hash_value) while (upper > lower) { - IndexTuple itup; - OffsetNumber off; - uint32 hashkey; + IndexTuple itup; + OffsetNumber off; + uint32 hashkey; off = (upper + lower + 1) / 2; Assert(OffsetNumberIsValid(off)); diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 1f6edf6caf..2e45c041a6 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.276 2009/06/10 18:54:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.277 2009/06/11 14:48:53 momjian Exp $ * * * INTERFACE ROUTINES @@ -69,7 +69,7 @@ /* GUC variable */ -bool synchronize_seqscans = true; +bool synchronize_seqscans = true; static HeapScanDesc heap_beginscan_internal(Relation relation, @@ -116,9 +116,9 @@ initscan(HeapScanDesc scan, ScanKey key, bool is_rescan) * strategy and enable synchronized scanning (see syncscan.c). Although * the thresholds for these features could be different, we make them the * same so that there are only two behaviors to tune rather than four. - * (However, some callers need to be able to disable one or both of - * these behaviors, independently of the size of the table; also there - * is a GUC variable that can disable synchronized scanning.) + * (However, some callers need to be able to disable one or both of these + * behaviors, independently of the size of the table; also there is a GUC + * variable that can disable synchronized scanning.) * * During a rescan, don't make a new strategy object if we don't have to. */ @@ -146,8 +146,8 @@ initscan(HeapScanDesc scan, ScanKey key, bool is_rescan) if (is_rescan) { /* - * If rescan, keep the previous startblock setting so that rewinding - * a cursor doesn't generate surprising results. Reset the syncscan + * If rescan, keep the previous startblock setting so that rewinding a + * cursor doesn't generate surprising results. Reset the syncscan * setting, though. */ scan->rs_syncscan = (allow_sync && synchronize_seqscans); @@ -1793,7 +1793,7 @@ void FreeBulkInsertState(BulkInsertState bistate) { if (bistate->current_buf != InvalidBuffer) - ReleaseBuffer(bistate->current_buf); + ReleaseBuffer(bistate->current_buf); FreeAccessStrategy(bistate->strategy); pfree(bistate); } @@ -1977,7 +1977,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, /* Clear the bit in the visibility map if necessary */ if (all_visible_cleared) - visibilitymap_clear(relation, + visibilitymap_clear(relation, ItemPointerGetBlockNumber(&(heaptup->t_self))); /* @@ -3437,8 +3437,8 @@ l3: LockBuffer(*buffer, BUFFER_LOCK_UNLOCK); /* - * Don't update the visibility map here. Locking a tuple doesn't - * change visibility info. + * Don't update the visibility map here. Locking a tuple doesn't change + * visibility info. */ /* @@ -4115,11 +4115,11 @@ heap_xlog_clean(XLogRecPtr lsn, XLogRecord *record, bool clean_move) nowunused, nunused, clean_move); - freespace = PageGetHeapFreeSpace(page); /* needed to update FSM below */ + freespace = PageGetHeapFreeSpace(page); /* needed to update FSM below */ /* - * Note: we don't worry about updating the page's prunability hints. - * At worst this will cause an extra prune cycle to occur soon. + * Note: we don't worry about updating the page's prunability hints. At + * worst this will cause an extra prune cycle to occur soon. */ PageSetLSN(page, lsn); @@ -4217,17 +4217,18 @@ heap_xlog_delete(XLogRecPtr lsn, XLogRecord *record) OffsetNumber offnum; ItemId lp = NULL; HeapTupleHeader htup; - BlockNumber blkno; + BlockNumber blkno; blkno = ItemPointerGetBlockNumber(&(xlrec->target.tid)); /* - * The visibility map always needs to be updated, even if the heap page - * is already up-to-date. + * The visibility map always needs to be updated, even if the heap page is + * already up-to-date. */ if (xlrec->all_visible_cleared) { - Relation reln = CreateFakeRelcacheEntry(xlrec->target.node); + Relation reln = CreateFakeRelcacheEntry(xlrec->target.node); + visibilitymap_clear(reln, blkno); FreeFakeRelcacheEntry(reln); } @@ -4294,17 +4295,18 @@ heap_xlog_insert(XLogRecPtr lsn, XLogRecord *record) xl_heap_header xlhdr; uint32 newlen; Size freespace; - BlockNumber blkno; + BlockNumber blkno; blkno = ItemPointerGetBlockNumber(&(xlrec->target.tid)); /* - * The visibility map always needs to be updated, even if the heap page - * is already up-to-date. + * The visibility map always needs to be updated, even if the heap page is + * already up-to-date. */ if (xlrec->all_visible_cleared) { - Relation reln = CreateFakeRelcacheEntry(xlrec->target.node); + Relation reln = CreateFakeRelcacheEntry(xlrec->target.node); + visibilitymap_clear(reln, blkno); FreeFakeRelcacheEntry(reln); } @@ -4361,7 +4363,7 @@ heap_xlog_insert(XLogRecPtr lsn, XLogRecord *record) if (offnum == InvalidOffsetNumber) elog(PANIC, "heap_insert_redo: failed to add tuple"); - freespace = PageGetHeapFreeSpace(page); /* needed to update FSM below */ + freespace = PageGetHeapFreeSpace(page); /* needed to update FSM below */ PageSetLSN(page, lsn); PageSetTLI(page, ThisTimeLineID); @@ -4374,8 +4376,8 @@ heap_xlog_insert(XLogRecPtr lsn, XLogRecord *record) /* * If the page is running low on free space, update the FSM as well. - * Arbitrarily, our definition of "low" is less than 20%. We can't do - * much better than that without knowing the fill-factor for the table. + * Arbitrarily, our definition of "low" is less than 20%. We can't do much + * better than that without knowing the fill-factor for the table. * * XXX: We don't get here if the page was restored from full page image. * We don't bother to update the FSM in that case, it doesn't need to be @@ -4410,12 +4412,13 @@ heap_xlog_update(XLogRecPtr lsn, XLogRecord *record, bool move, bool hot_update) Size freespace; /* - * The visibility map always needs to be updated, even if the heap page - * is already up-to-date. + * The visibility map always needs to be updated, even if the heap page is + * already up-to-date. */ if (xlrec->all_visible_cleared) { - Relation reln = CreateFakeRelcacheEntry(xlrec->target.node); + Relation reln = CreateFakeRelcacheEntry(xlrec->target.node); + visibilitymap_clear(reln, ItemPointerGetBlockNumber(&xlrec->target.tid)); FreeFakeRelcacheEntry(reln); @@ -4504,12 +4507,13 @@ heap_xlog_update(XLogRecPtr lsn, XLogRecord *record, bool move, bool hot_update) newt:; /* - * The visibility map always needs to be updated, even if the heap page - * is already up-to-date. + * The visibility map always needs to be updated, even if the heap page is + * already up-to-date. */ if (xlrec->new_all_visible_cleared) { - Relation reln = CreateFakeRelcacheEntry(xlrec->target.node); + Relation reln = CreateFakeRelcacheEntry(xlrec->target.node); + visibilitymap_clear(reln, ItemPointerGetBlockNumber(&xlrec->newtid)); FreeFakeRelcacheEntry(reln); } @@ -4595,7 +4599,7 @@ newsame:; if (xlrec->new_all_visible_cleared) PageClearAllVisible(page); - freespace = PageGetHeapFreeSpace(page); /* needed to update FSM below */ + freespace = PageGetHeapFreeSpace(page); /* needed to update FSM below */ PageSetLSN(page, lsn); PageSetTLI(page, ThisTimeLineID); @@ -4604,8 +4608,8 @@ newsame:; /* * If the page is running low on free space, update the FSM as well. - * Arbitrarily, our definition of "low" is less than 20%. We can't do - * much better than that without knowing the fill-factor for the table. + * Arbitrarily, our definition of "low" is less than 20%. We can't do much + * better than that without knowing the fill-factor for the table. * * However, don't update the FSM on HOT updates, because after crash * recovery, either the old or the new tuple will certainly be dead and @@ -4619,7 +4623,7 @@ newsame:; */ if (!hot_update && freespace < BLCKSZ / 5) XLogRecordPageWithFreeSpace(xlrec->target.node, - ItemPointerGetBlockNumber(&(xlrec->newtid)), freespace); + ItemPointerGetBlockNumber(&(xlrec->newtid)), freespace); } static void diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 1d70e6c01a..7ed8612357 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.75 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.76 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ static Buffer ReadBufferBI(Relation relation, BlockNumber targetBlock, BulkInsertState bistate) { - Buffer buffer; + Buffer buffer; /* If not bulk-insert, exactly like ReadBuffer */ if (!bistate) @@ -118,7 +118,7 @@ ReadBufferBI(Relation relation, BlockNumber targetBlock, * happen if space is freed in that page after heap_update finds there's not * enough there). In that case, the page will be pinned and locked only once. * - * We normally use FSM to help us find free space. However, + * We normally use FSM to help us find free space. However, * if HEAP_INSERT_SKIP_FSM is specified, we just append a new empty page to * the end of the relation if the tuple won't fit on the current target page. * This can save some cycles when we know the relation is new and doesn't @@ -133,7 +133,7 @@ ReadBufferBI(Relation relation, BlockNumber targetBlock, * for additional constraints needed for safe usage of this behavior.) * * The caller can also provide a BulkInsertState object to optimize many - * insertions into the same relation. This keeps a pin on the current + * insertions into the same relation. This keeps a pin on the current * insertion target page (to save pin/unpin cycles) and also passes a * BULKWRITE buffer selection strategy object to the buffer manager. * Passing NULL for bistate selects the default behavior. @@ -186,7 +186,7 @@ RelationGetBufferForTuple(Relation relation, Size len, /* * We first try to put the tuple on the same page we last inserted a tuple - * on, as cached in the BulkInsertState or relcache entry. If that + * on, as cached in the BulkInsertState or relcache entry. If that * doesn't work, we ask the Free Space Map to locate a suitable page. * Since the FSM's info might be out of date, we have to be prepared to * loop around and retry multiple times. (To insure this isn't an infinite diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 4b445c7ad8..71ea689d0e 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.17 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.18 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ typedef struct { TransactionId new_prune_xid; /* new prune hint value for page */ - int nredirected; /* numbers of entries in arrays below */ + int nredirected; /* numbers of entries in arrays below */ int ndead; int nunused; /* arrays that accumulate indexes of items to be changed */ @@ -159,21 +159,21 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, /* * Our strategy is to scan the page and make lists of items to change, - * then apply the changes within a critical section. This keeps as - * much logic as possible out of the critical section, and also ensures - * that WAL replay will work the same as the normal case. + * then apply the changes within a critical section. This keeps as much + * logic as possible out of the critical section, and also ensures that + * WAL replay will work the same as the normal case. * - * First, inform inval.c that upcoming CacheInvalidateHeapTuple calls - * are nontransactional. + * First, inform inval.c that upcoming CacheInvalidateHeapTuple calls are + * nontransactional. */ if (redirect_move) BeginNonTransactionalInvalidation(); /* - * 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. + * 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. */ prstate.new_prune_xid = InvalidTransactionId; prstate.nredirected = prstate.ndead = prstate.nunused = 0; @@ -204,9 +204,9 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, } /* - * Send invalidation messages for any tuples we are about to move. - * It is safe to do this now, even though we could theoretically still - * fail before making the actual page update, because a useless cache + * Send invalidation messages for any tuples we are about to move. It is + * safe to do this now, even though we could theoretically still fail + * before making the actual page update, because a useless cache * invalidation doesn't hurt anything. Also, no one else can reload the * tuples while we have exclusive buffer lock, so it's not too early to * send the invals. This avoids sending the invals while inside the @@ -222,9 +222,8 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, if (prstate.nredirected > 0 || prstate.ndead > 0 || prstate.nunused > 0) { /* - * Apply the planned item changes, then repair page fragmentation, - * and update the page's hint bit about whether it has free line - * pointers. + * Apply the planned item changes, then repair page fragmentation, and + * update the page's hint bit about whether it has free line pointers. */ heap_page_prune_execute(buffer, prstate.redirected, prstate.nredirected, @@ -268,8 +267,8 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, { /* * If we didn't prune anything, but have found a new value for the - * pd_prune_xid field, update it and mark the buffer dirty. - * This is treated as a non-WAL-logged hint. + * pd_prune_xid field, update it and mark the buffer dirty. This is + * treated as a non-WAL-logged hint. * * Also clear the "page is full" flag if it is set, since there's no * point in repeating the prune/defrag process until something else @@ -334,8 +333,8 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, * OldestXmin is the cutoff XID used to identify dead tuples. * * We don't actually change the page here, except perhaps for hint-bit updates - * caused by HeapTupleSatisfiesVacuum. We just add entries to the arrays in - * prstate showing the changes to be made. Items to be redirected are added + * caused by HeapTupleSatisfiesVacuum. We just add entries to the arrays in + * prstate showing the changes to be made. Items to be redirected are added * to the redirected[] array (two entries per redirection); items to be set to * LP_DEAD state are added to nowdead[]; and items to be set to LP_UNUSED * state are added to nowunused[]. @@ -598,19 +597,19 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum, else if (redirect_move && ItemIdIsRedirected(rootlp)) { /* - * If we desire to eliminate LP_REDIRECT items by moving tuples, - * make a redirection entry for each redirected root item; this - * will cause heap_page_prune_execute to actually do the move. - * (We get here only when there are no DEAD tuples in the chain; - * otherwise the redirection entry was made above.) + * If we desire to eliminate LP_REDIRECT items by moving tuples, make + * a redirection entry for each redirected root item; this will cause + * heap_page_prune_execute to actually do the move. (We get here only + * when there are no DEAD tuples in the chain; otherwise the + * redirection entry was made above.) */ heap_prune_record_redirect(prstate, rootoffnum, chainitems[1]); redirect_target = chainitems[1]; } /* - * If we are going to implement a redirect by moving tuples, we have - * to issue a cache invalidation against the redirection target tuple, + * If we are going to implement a redirect by moving tuples, we have to + * issue a cache invalidation against the redirection target tuple, * because its CTID will be effectively changed by the move. Note that * CacheInvalidateHeapTuple only queues the request, it doesn't send it; * if we fail before reaching EndNonTransactionalInvalidation, nothing @@ -693,7 +692,7 @@ heap_prune_record_unused(PruneState *prstate, OffsetNumber offnum) * buffer, and is inside a critical section. * * This is split out because it is also used by heap_xlog_clean() - * to replay the WAL record when needed after a crash. Note that the + * to replay the WAL record when needed after a crash. Note that the * arguments are identical to those of log_heap_clean(). */ void diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index f6a16b8492..6f00c24845 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.17 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.18 2009/06/11 14:48:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -577,7 +577,7 @@ raw_heap_insert(RewriteState state, HeapTuple tup) heaptup = toast_insert_or_update(state->rs_new_rel, tup, NULL, HEAP_INSERT_SKIP_FSM | (state->rs_use_wal ? - 0 : HEAP_INSERT_SKIP_WAL)); + 0 : HEAP_INSERT_SKIP_WAL)); else heaptup = tup; diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c index 35019a543c..a3203085b7 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.92 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.93 2009/06/11 14:48:54 momjian Exp $ * * * INTERFACE ROUTINES @@ -1073,8 +1073,8 @@ toast_compress_datum(Datum value) Assert(!VARATT_IS_COMPRESSED(DatumGetPointer(value))); /* - * No point in wasting a palloc cycle if value size is out of the - * allowed range for compression + * No point in wasting a palloc cycle if value size is out of the allowed + * range for compression */ if (valsize < PGLZ_strategy_default->min_input_size || valsize > PGLZ_strategy_default->max_input_size) @@ -1087,10 +1087,10 @@ toast_compress_datum(Datum value) * because it might be satisfied with having saved as little as one byte * in the compressed data --- which could turn into a net loss once you * consider header and alignment padding. Worst case, the compressed - * format might require three padding bytes (plus header, which is included - * in VARSIZE(tmp)), whereas the uncompressed format would take only one - * header byte and no padding if the value is short enough. So we insist - * on a savings of more than 2 bytes to ensure we have a gain. + * format might require three padding bytes (plus header, which is + * included in VARSIZE(tmp)), whereas the uncompressed format would take + * only one header byte and no padding if the value is short enough. So + * we insist on a savings of more than 2 bytes to ensure we have a gain. */ if (pglz_compress(VARDATA_ANY(DatumGetPointer(value)), valsize, (PGLZ_Header *) tmp, PGLZ_strategy_default) && @@ -1130,7 +1130,7 @@ toast_save_datum(Relation rel, Datum value, int options) struct { struct varlena hdr; - char data[TOAST_MAX_CHUNK_SIZE]; /* make struct big enough */ + char data[TOAST_MAX_CHUNK_SIZE]; /* make struct big enough */ int32 align_it; /* ensure struct is aligned well enough */ } chunk_data; int32 chunk_size; @@ -1295,8 +1295,8 @@ toast_delete_datum(Relation rel, Datum value) /* * Find all the chunks. (We don't actually care whether we see them in - * sequence or not, but since we've already locked the index we might - * as well use systable_beginscan_ordered.) + * sequence or not, but since we've already locked the index we might as + * well use systable_beginscan_ordered.) */ toastscan = systable_beginscan_ordered(toastrel, toastidx, SnapshotToast, 1, &toastkey); @@ -1598,7 +1598,7 @@ toast_fetch_datum_slice(struct varlena * attr, int32 sliceoffset, int32 length) */ nextidx = startchunk; toastscan = systable_beginscan_ordered(toastrel, toastidx, - SnapshotToast, nscankeys, toastkey); + SnapshotToast, nscankeys, toastkey); while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL) { /* diff --git a/src/backend/access/heap/visibilitymap.c b/src/backend/access/heap/visibilitymap.c index 2b5a0704ed..d425e772b9 100644 --- a/src/backend/access/heap/visibilitymap.c +++ b/src/backend/access/heap/visibilitymap.c @@ -8,10 +8,10 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/visibilitymap.c,v 1.3 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/visibilitymap.c,v 1.4 2009/06/11 14:48:54 momjian Exp $ * * INTERFACE ROUTINES - * visibilitymap_clear - clear a bit in the visibility map + * visibilitymap_clear - clear a bit in the visibility map * visibilitymap_pin - pin a map page for setting a bit * visibilitymap_set - set a bit in a previously pinned page * visibilitymap_test - test if a bit is set @@ -144,7 +144,7 @@ visibilitymap_clear(Relation rel, BlockNumber heapBlk) mapBuffer = vm_readbuf(rel, mapBlock, false); if (!BufferIsValid(mapBuffer)) - return; /* nothing to do */ + return; /* nothing to do */ LockBuffer(mapBuffer, BUFFER_LOCK_EXCLUSIVE); map = PageGetContents(BufferGetPage(mapBuffer)); @@ -295,10 +295,11 @@ void visibilitymap_truncate(Relation rel, BlockNumber nheapblocks) { BlockNumber newnblocks; + /* last remaining block, byte, and bit */ BlockNumber truncBlock = HEAPBLK_TO_MAPBLOCK(nheapblocks); - uint32 truncByte = HEAPBLK_TO_MAPBYTE(nheapblocks); - uint8 truncBit = HEAPBLK_TO_MAPBIT(nheapblocks); + uint32 truncByte = HEAPBLK_TO_MAPBYTE(nheapblocks); + uint8 truncBit = HEAPBLK_TO_MAPBIT(nheapblocks); #ifdef TRACE_VISIBILITYMAP elog(DEBUG1, "vm_truncate %s %d", RelationGetRelationName(rel), nheapblocks); @@ -315,14 +316,14 @@ visibilitymap_truncate(Relation rel, BlockNumber nheapblocks) * Unless the new size is exactly at a visibility map page boundary, the * tail bits in the last remaining map page, representing truncated heap * blocks, need to be cleared. This is not only tidy, but also necessary - * because we don't get a chance to clear the bits if the heap is - * extended again. + * because we don't get a chance to clear the bits if the heap is extended + * again. */ if (truncByte != 0 || truncBit != 0) { - Buffer mapBuffer; - Page page; - char *map; + Buffer mapBuffer; + Page page; + char *map; newnblocks = truncBlock + 1; @@ -344,11 +345,8 @@ visibilitymap_truncate(Relation rel, BlockNumber nheapblocks) /* * Mask out the unwanted bits of the last remaining byte. * - * ((1 << 0) - 1) = 00000000 - * ((1 << 1) - 1) = 00000001 - * ... - * ((1 << 6) - 1) = 00111111 - * ((1 << 7) - 1) = 01111111 + * ((1 << 0) - 1) = 00000000 ((1 << 1) - 1) = 00000001 ... ((1 << 6) - + * 1) = 00111111 ((1 << 7) - 1) = 01111111 */ map[truncByte] &= (1 << truncBit) - 1; @@ -368,8 +366,8 @@ visibilitymap_truncate(Relation rel, BlockNumber nheapblocks) rel->rd_istemp); /* - * Need to invalidate the relcache entry, because rd_vm_nblocks - * seen by other backends is no longer valid. + * Need to invalidate the relcache entry, because rd_vm_nblocks seen by + * other backends is no longer valid. */ if (!InRecovery) CacheInvalidateRelcache(rel); @@ -386,7 +384,7 @@ visibilitymap_truncate(Relation rel, BlockNumber nheapblocks) static Buffer vm_readbuf(Relation rel, BlockNumber blkno, bool extend) { - Buffer buf; + Buffer buf; RelationOpenSmgr(rel); @@ -433,20 +431,20 @@ static void vm_extend(Relation rel, BlockNumber vm_nblocks) { BlockNumber vm_nblocks_now; - Page pg; + Page pg; pg = (Page) palloc(BLCKSZ); PageInit(pg, BLCKSZ, 0); /* - * We use the relation extension lock to lock out other backends trying - * to extend the visibility map at the same time. It also locks out - * extension of the main fork, unnecessarily, but extending the - * visibility map happens seldom enough that it doesn't seem worthwhile to - * have a separate lock tag type for it. + * We use the relation extension lock to lock out other backends trying to + * extend the visibility map at the same time. It also locks out extension + * of the main fork, unnecessarily, but extending the visibility map + * happens seldom enough that it doesn't seem worthwhile to have a + * separate lock tag type for it. * - * Note that another backend might have extended or created the - * relation before we get the lock. + * Note that another backend might have extended or created the relation + * before we get the lock. */ LockRelationForExtension(rel, ExclusiveLock); diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index 9193ee40eb..a79c392071 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.73 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.74 2009/06/11 14:48:54 momjian Exp $ * * NOTES * many of the old access method routines have been turned into @@ -197,7 +197,7 @@ systable_beginscan(Relation heapRelation, /* Change attribute numbers to be index column numbers. */ for (i = 0; i < nkeys; i++) { - int j; + int j; for (j = 0; j < irel->rd_index->indnatts; j++) { @@ -241,12 +241,13 @@ systable_getnext(SysScanDesc sysscan) if (sysscan->irel) { htup = index_getnext(sysscan->iscan, ForwardScanDirection); + /* - * We currently don't need to support lossy index operators for - * any system catalog scan. It could be done here, using the - * scan keys to drive the operator calls, if we arranged to save - * the heap attnums during systable_beginscan(); this is practical - * because we still wouldn't need to support indexes on expressions. + * We currently don't need to support lossy index operators for any + * system catalog scan. It could be done here, using the scan keys to + * drive the operator calls, if we arranged to save the heap attnums + * during systable_beginscan(); this is practical because we still + * wouldn't need to support indexes on expressions. */ if (htup && sysscan->iscan->xs_recheck) elog(ERROR, "system catalog scans with lossy index conditions are not implemented"); @@ -326,7 +327,7 @@ systable_endscan(SysScanDesc sysscan) * index order. Also, for largely historical reasons, the index to use * is opened and locked by the caller, not here. * - * Currently we do not support non-index-based scans here. (In principle + * Currently we do not support non-index-based scans here. (In principle * we could do a heapscan and sort, but the uses are in places that * probably don't need to still work with corrupted catalog indexes.) * For the moment, therefore, these functions are merely the thinnest of @@ -360,7 +361,7 @@ systable_beginscan_ordered(Relation heapRelation, /* Change attribute numbers to be index column numbers. */ for (i = 0; i < nkeys; i++) { - int j; + int j; for (j = 0; j < indexRelation->rd_index->indnatts; j++) { diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 197fa3b041..32623965c7 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.113 2009/03/24 20:17:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.114 2009/06/11 14:48:54 momjian Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relation OID @@ -21,7 +21,7 @@ * index_markpos - mark a scan position * index_restrpos - restore a scan position * index_getnext - get the next tuple from a scan - * index_getbitmap - get all tuples from a scan + * index_getbitmap - get all tuples from a scan * index_bulk_delete - bulk deletion of index tuples * index_vacuum_cleanup - post-deletion cleanup of an index * index_getprocid - get a support procedure OID @@ -461,9 +461,9 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) /* * The AM's gettuple proc finds the next index entry matching the - * scan keys, and puts the TID in xs_ctup.t_self (ie, *tid). - * It should also set scan->xs_recheck, though we pay no - * attention to that here. + * scan keys, and puts the TID in xs_ctup.t_self (ie, *tid). It + * should also set scan->xs_recheck, though we pay no attention to + * that here. */ found = DatumGetBool(FunctionCall2(procedure, PointerGetDatum(scan), diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index b0d14319b7..a06faa2020 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.169 2009/01/01 17:23:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.170 2009/06/11 14:48:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -374,7 +374,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, * removing any LP_DEAD tuples. * * On entry, *buf and *offsetptr point to the first legal position - * where the new tuple could be inserted. The caller should hold an + * where the new tuple could be inserted. The caller should hold an * exclusive lock on *buf. *offsetptr can also be set to * InvalidOffsetNumber, in which case the function will search for the * right location within the page if needed. On exit, they point to the @@ -951,7 +951,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, sopaque = (BTPageOpaque) PageGetSpecialPointer(spage); if (sopaque->btpo_prev != ropaque->btpo_prev) elog(PANIC, "right sibling's left-link doesn't match: " - "block %u links to %u instead of expected %u in index \"%s\"", + "block %u links to %u instead of expected %u in index \"%s\"", ropaque->btpo_next, sopaque->btpo_prev, ropaque->btpo_prev, RelationGetRelationName(rel)); diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index 55d947e9f2..2b76e7cd45 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.170 2009/06/06 22:13:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.171 2009/06/11 14:48:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -290,7 +290,7 @@ Datum btgetbitmap(PG_FUNCTION_ARGS) { IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0); - TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1); + TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1); BTScanOpaque so = (BTScanOpaque) scan->opaque; int64 ntids = 0; ItemPointer heapTid; @@ -579,9 +579,8 @@ btvacuumcleanup(PG_FUNCTION_ARGS) /* * During a non-FULL vacuum it's quite possible for us to be fooled by * concurrent page splits into double-counting some index tuples, so - * disbelieve any total that exceeds the underlying heap's count ... - * if we know that accurately. Otherwise this might just make matters - * worse. + * disbelieve any total that exceeds the underlying heap's count ... if we + * know that accurately. Otherwise this might just make matters worse. */ if (!info->vacuum_full && !info->estimated_count) { diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c index 3de7d50e01..d132d6bdee 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.54 2009/01/20 18:59:37 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.55 2009/06/11 14:48:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -338,8 +338,8 @@ btree_xlog_split(bool onleft, bool isroot, _bt_restore_page(rpage, datapos, datalen); /* - * On leaf level, the high key of the left page is equal to the - * first key on the right page. + * On leaf level, the high key of the left page is equal to the first key + * on the right page. */ if (xlrec->level == 0) { @@ -936,7 +936,7 @@ btree_xlog_cleanup(void) buf = XLogReadBuffer(action->node, action->delblk, false); if (BufferIsValid(buf)) { - Relation reln; + Relation reln; reln = CreateFakeRelcacheEntry(action->node); if (_bt_pagedel(reln, buf, NULL, true) == 0) diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index 368d2c9d1a..8544725abb 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -26,7 +26,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.52 2009/01/20 18:59:37 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.53 2009/06/11 14:48:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,7 +81,7 @@ static bool CLOGPagePrecedes(int page1, int page2); static void WriteZeroPageXlogRec(int pageno); static void WriteTruncateXlogRec(int pageno); static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids, - TransactionId *subxids, XidStatus status, + TransactionId *subxids, XidStatus status, XLogRecPtr lsn, int pageno); static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, int slotno); @@ -112,10 +112,10 @@ static void set_status_by_pages(int nsubxids, TransactionId *subxids, * the same CLOG page as xid. If they all are, then the lock will be grabbed * only once, and the status will be set to committed directly. Otherwise * we must - * 1. set sub-committed all subxids that are not on the same page as the - * main xid - * 2. atomically set committed the main xid and the subxids on the same page - * 3. go over the first bunch again and set them committed + * 1. set sub-committed all subxids that are not on the same page as the + * main xid + * 2. atomically set committed the main xid and the subxids on the same page + * 3. go over the first bunch again and set them committed * Note that as far as concurrent checkers are concerned, main transaction * commit as a whole is still atomic. * @@ -126,13 +126,13 @@ static void set_status_by_pages(int nsubxids, TransactionId *subxids, * page2: set t2,t3 as sub-committed * page3: set t4 as sub-committed * 2. update page1: - * set t1 as sub-committed, + * set t1 as sub-committed, * then set t as committed, then set t1 as committed * 3. update pages2-3: * page2: set t2,t3 as committed * page3: set t4 as committed - * + * * NB: this is a low-level routine and is NOT the preferred entry point * for most uses; functions in transam.c are the intended callers. * @@ -142,16 +142,17 @@ static void set_status_by_pages(int nsubxids, TransactionId *subxids, */ void TransactionIdSetTreeStatus(TransactionId xid, int nsubxids, - TransactionId *subxids, XidStatus status, XLogRecPtr lsn) + TransactionId *subxids, XidStatus status, XLogRecPtr lsn) { - int pageno = TransactionIdToPage(xid); /* get page of parent */ - int i; + int pageno = TransactionIdToPage(xid); /* get page of parent */ + int i; Assert(status == TRANSACTION_STATUS_COMMITTED || status == TRANSACTION_STATUS_ABORTED); /* - * See how many subxids, if any, are on the same page as the parent, if any. + * See how many subxids, if any, are on the same page as the parent, if + * any. */ for (i = 0; i < nsubxids; i++) { @@ -172,14 +173,14 @@ TransactionIdSetTreeStatus(TransactionId xid, int nsubxids, } else { - int nsubxids_on_first_page = i; + int nsubxids_on_first_page = i; /* * If this is a commit then we care about doing this correctly (i.e. - * using the subcommitted intermediate status). By here, we know we're - * updating more than one page of clog, so we must mark entries that - * are *not* on the first page so that they show as subcommitted before - * we then return to update the status to fully committed. + * using the subcommitted intermediate status). By here, we know + * we're updating more than one page of clog, so we must mark entries + * that are *not* on the first page so that they show as subcommitted + * before we then return to update the status to fully committed. * * To avoid touching the first page twice, skip marking subcommitted * for the subxids on that first page. @@ -217,13 +218,13 @@ static void set_status_by_pages(int nsubxids, TransactionId *subxids, XidStatus status, XLogRecPtr lsn) { - int pageno = TransactionIdToPage(subxids[0]); - int offset = 0; - int i = 0; + int pageno = TransactionIdToPage(subxids[0]); + int offset = 0; + int i = 0; while (i < nsubxids) { - int num_on_page = 0; + int num_on_page = 0; while (TransactionIdToPage(subxids[i]) == pageno && i < nsubxids) { @@ -251,7 +252,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids, XLogRecPtr lsn, int pageno) { int slotno; - int i; + int i; Assert(status == TRANSACTION_STATUS_COMMITTED || status == TRANSACTION_STATUS_ABORTED || @@ -275,9 +276,9 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids, * * If we update more than one xid on this page while it is being written * out, we might find that some of the bits go to disk and others don't. - * If we are updating commits on the page with the top-level xid that could - * break atomicity, so we subcommit the subxids first before we mark the - * top-level commit. + * If we are updating commits on the page with the top-level xid that + * could break atomicity, so we subcommit the subxids first before we mark + * the top-level commit. */ if (TransactionIdIsValid(xid)) { @@ -336,7 +337,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i curval == TRANSACTION_STATUS_COMMITTED) return; - /* + /* * Current state change should be from 0 or subcommitted to target state * or we should already be there when replaying changes during recovery. */ diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 4685ccdf10..4a43579c40 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.52 2009/04/23 00:23:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.53 2009/06/11 14:48:54 momjian Exp $ * * NOTES * Each global transaction is associated with a global transaction @@ -233,7 +233,7 @@ MarkAsPreparing(TransactionId xid, const char *gid, ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("prepared transactions are disabled"), - errhint("Set max_prepared_transactions to a nonzero value."))); + errhint("Set max_prepared_transactions to a nonzero value."))); LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE); diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index ac330411aa..2b6a222477 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.273 2009/05/13 20:27:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.274 2009/06/11 14:48:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -456,7 +456,7 @@ GetCurrentSubTransactionId(void) * * "used" must be TRUE if the caller intends to use the command ID to mark * inserted/updated/deleted tuples. FALSE means the ID is being fetched - * for read-only purposes (ie, as a snapshot validity cutoff). See + * for read-only purposes (ie, as a snapshot validity cutoff). See * CommandCounterIncrement() for discussion. */ CommandId @@ -566,7 +566,8 @@ TransactionIdIsCurrentTransactionId(TransactionId xid) */ for (s = CurrentTransactionState; s != NULL; s = s->parent) { - int low, high; + int low, + high; if (s->state == TRANS_ABORT) continue; @@ -579,8 +580,8 @@ TransactionIdIsCurrentTransactionId(TransactionId xid) high = s->nChildXids - 1; while (low <= high) { - int middle; - TransactionId probe; + int middle; + TransactionId probe; middle = low + (high - low) / 2; probe = s->childXids[middle]; @@ -604,33 +605,31 @@ void CommandCounterIncrement(void) { /* - * If the current value of the command counter hasn't been "used" to - * mark tuples, we need not increment it, since there's no need to - * distinguish a read-only command from others. This helps postpone - * command counter overflow, and keeps no-op CommandCounterIncrement - * operations cheap. + * If the current value of the command counter hasn't been "used" to mark + * tuples, we need not increment it, since there's no need to distinguish + * a read-only command from others. This helps postpone command counter + * overflow, and keeps no-op CommandCounterIncrement operations cheap. */ if (currentCommandIdUsed) { currentCommandId += 1; - if (currentCommandId == FirstCommandId) /* check for overflow */ + if (currentCommandId == FirstCommandId) /* check for overflow */ { currentCommandId -= 1; ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("cannot have more than 2^32-1 commands in a transaction"))); + errmsg("cannot have more than 2^32-1 commands in a transaction"))); } currentCommandIdUsed = false; /* Propagate new command ID into static snapshots */ SnapshotSetCommandId(currentCommandId); - + /* - * Make any catalog changes done by the just-completed command - * visible in the local syscache. We obviously don't need to do - * this after a read-only command. (But see hacks in inval.c - * to make real sure we don't think a command that queued inval - * messages was read-only.) + * Make any catalog changes done by the just-completed command visible + * in the local syscache. We obviously don't need to do this after a + * read-only command. (But see hacks in inval.c to make real sure we + * don't think a command that queued inval messages was read-only.) */ AtCommit_LocalCache(); } @@ -638,11 +637,11 @@ CommandCounterIncrement(void) /* * Make any other backends' catalog changes visible to me. * - * XXX this is probably in the wrong place: CommandCounterIncrement - * should be purely a local operation, most likely. However fooling - * with this will affect asynchronous cross-backend interactions, - * which doesn't seem like a wise thing to do in late beta, so save - * improving this for another day - tgl 2007-11-30 + * XXX this is probably in the wrong place: CommandCounterIncrement should + * be purely a local operation, most likely. However fooling with this + * will affect asynchronous cross-backend interactions, which doesn't seem + * like a wise thing to do in late beta, so save improving this for + * another day - tgl 2007-11-30 */ AtStart_Cache(); } @@ -1086,14 +1085,14 @@ AtSubCommit_childXids(void) /* Allocate or enlarge the parent array if necessary */ if (s->parent->maxChildXids < new_nChildXids) { - int new_maxChildXids; - TransactionId *new_childXids; + int new_maxChildXids; + TransactionId *new_childXids; /* * Make it 2x what's needed right now, to avoid having to enlarge it - * repeatedly. But we can't go above MaxAllocSize. (The latter - * limit is what ensures that we don't need to worry about integer - * overflow here or in the calculation of new_nChildXids.) + * repeatedly. But we can't go above MaxAllocSize. (The latter limit + * is what ensures that we don't need to worry about integer overflow + * here or in the calculation of new_nChildXids.) */ new_maxChildXids = Min(new_nChildXids * 2, (int) (MaxAllocSize / sizeof(TransactionId))); @@ -1111,13 +1110,13 @@ AtSubCommit_childXids(void) */ if (s->parent->childXids == NULL) new_childXids = - MemoryContextAlloc(TopTransactionContext, + MemoryContextAlloc(TopTransactionContext, new_maxChildXids * sizeof(TransactionId)); else - new_childXids = repalloc(s->parent->childXids, - new_maxChildXids * sizeof(TransactionId)); + new_childXids = repalloc(s->parent->childXids, + new_maxChildXids * sizeof(TransactionId)); - s->parent->childXids = new_childXids; + s->parent->childXids = new_childXids; s->parent->maxChildXids = new_maxChildXids; } @@ -1126,9 +1125,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; @@ -1801,15 +1800,15 @@ PrepareTransaction(void) /* NOTIFY and flatfiles will be handled below */ /* - * Don't allow PREPARE TRANSACTION if we've accessed a temporary table - * in this transaction. Having the prepared xact hold locks on another + * Don't allow PREPARE TRANSACTION if we've accessed a temporary table in + * this transaction. Having the prepared xact hold locks on another * backend's temp table seems a bad idea --- for instance it would prevent - * the backend from exiting. There are other problems too, such as how - * to clean up the source backend's local buffers and ON COMMIT state - * if the prepared xact includes a DROP of a temp table. + * the backend from exiting. There are other problems too, such as how to + * clean up the source backend's local buffers and ON COMMIT state if the + * prepared xact includes a DROP of a temp table. * - * We must check this after executing any ON COMMIT actions, because - * they might still access a temp relation. + * We must check this after executing any ON COMMIT actions, because they + * might still access a temp relation. * * XXX In principle this could be relaxed to allow some useful special * cases, such as a temp table created and dropped all within the @@ -2021,8 +2020,8 @@ AbortTransaction(void) /* * Reset user ID which might have been changed transiently. We need this * to clean up in case control escaped out of a SECURITY DEFINER function - * or other local change of CurrentUserId; therefore, the prior value - * of SecurityDefinerContext also needs to be restored. + * or other local change of CurrentUserId; therefore, the prior value of + * SecurityDefinerContext also needs to be restored. * * (Note: it is not necessary to restore session authorization or role * settings here because those can only be changed via GUC, and GUC will @@ -3749,8 +3748,8 @@ CommitSubTransaction(void) /* Must CCI to ensure commands of subtransaction are seen as done */ CommandCounterIncrement(); - /* - * Prior to 8.4 we marked subcommit in clog at this point. We now only + /* + * Prior to 8.4 we marked subcommit in clog at this point. We now only * perform that step, if required, as part of the atomic update of the * whole transaction tree at top level commit or abort. */ @@ -3868,8 +3867,8 @@ AbortSubTransaction(void) s->state = TRANS_ABORT; /* - * Reset user ID which might have been changed transiently. (See notes - * in AbortTransaction.) + * Reset user ID which might have been changed transiently. (See notes in + * AbortTransaction.) */ SetUserIdAndContext(s->prevUser, s->prevSecDefCxt); @@ -4089,7 +4088,7 @@ ShowTransactionStateRec(TransactionState s) if (s->nChildXids > 0) { - int i; + int i; appendStringInfo(&buf, "%u", s->childXids[0]); for (i = 1; i < s->nChildXids; i++) @@ -4241,7 +4240,7 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid) for (i = 0; i < xlrec->nrels; i++) { SMgrRelation srel = smgropen(xlrec->xnodes[i]); - ForkNumber fork; + ForkNumber fork; for (fork = 0; fork <= MAX_FORKNUM; fork++) { @@ -4284,7 +4283,7 @@ xact_redo_abort(xl_xact_abort *xlrec, TransactionId xid) for (i = 0; i < xlrec->nrels; i++) { SMgrRelation srel = smgropen(xlrec->xnodes[i]); - ForkNumber fork; + ForkNumber fork; for (fork = 0; fork <= MAX_FORKNUM; fork++) { @@ -4353,7 +4352,8 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec) appendStringInfo(buf, "; rels:"); for (i = 0; i < xlrec->nrels; i++) { - char *path = relpath(xlrec->xnodes[i], MAIN_FORKNUM); + char *path = relpath(xlrec->xnodes[i], MAIN_FORKNUM); + appendStringInfo(buf, " %s", path); pfree(path); } @@ -4380,7 +4380,8 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec) appendStringInfo(buf, "; rels:"); for (i = 0; i < xlrec->nrels; i++) { - char *path = relpath(xlrec->xnodes[i], MAIN_FORKNUM); + char *path = relpath(xlrec->xnodes[i], MAIN_FORKNUM); + appendStringInfo(buf, " %s", path); pfree(path); } diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index b6171c78c0..d521fa6e7b 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.342 2009/06/02 06:18:06 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.343 2009/06/11 14:48:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,7 +69,7 @@ bool XLogArchiveMode = false; char *XLogArchiveCommand = NULL; bool fullPageWrites = true; bool log_checkpoints = false; -int sync_method = DEFAULT_SYNC_METHOD; +int sync_method = DEFAULT_SYNC_METHOD; #ifdef WAL_DEBUG bool XLOG_DEBUG = false; @@ -122,7 +122,7 @@ CheckpointStatsData CheckpointStats; TimeLineID ThisTimeLineID = 0; /* - * Are we doing recovery from XLOG? + * Are we doing recovery from XLOG? * * This is only ever true in the startup process, even if the system is still * in recovery. Prior to 8.4, all activity during recovery were carried out @@ -336,9 +336,8 @@ typedef struct XLogCtlData bool SharedRecoveryInProgress; /* - * During recovery, we keep a copy of the latest checkpoint record - * here. Used by the background writer when it wants to create - * a restartpoint. + * During recovery, we keep a copy of the latest checkpoint record here. + * Used by the background writer when it wants to create a restartpoint. * * Protected by info_lck. */ @@ -422,8 +421,9 @@ static XLogRecPtr ReadRecPtr; /* start of last record read */ static XLogRecPtr EndRecPtr; /* end+1 of last record read */ static XLogRecord *nextRecord = NULL; static TimeLineID lastPageTLI = 0; -static XLogRecPtr minRecoveryPoint; /* local copy of ControlFile->minRecoveryPoint */ -static bool updateMinRecoveryPoint = true; +static XLogRecPtr minRecoveryPoint; /* local copy of + * ControlFile->minRecoveryPoint */ +static bool updateMinRecoveryPoint = true; static bool InRedo = false; @@ -432,6 +432,7 @@ static bool InRedo = false; */ static volatile sig_atomic_t got_SIGHUP = false; static volatile sig_atomic_t shutdown_requested = false; + /* * Flag set when executing a restore command, to tell SIGTERM signal handler * that it's safe to just proc_exit. @@ -482,6 +483,7 @@ static void writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, static void WriteControlFile(void); static void ReadControlFile(void); static char *str_time(pg_time_t tnow); + #ifdef WAL_DEBUG static void xlog_outrec(StringInfo buf, XLogRecord *record); #endif @@ -490,7 +492,7 @@ static void pg_start_backup_callback(int code, Datum arg); static bool read_backup_label(XLogRecPtr *checkPointLoc, XLogRecPtr *minRecoveryLoc); static void rm_redo_error_callback(void *arg); -static int get_sync_bit(int method); +static int get_sync_bit(int method); /* @@ -1260,9 +1262,9 @@ XLogArchiveIsBusy(const char *xlog) return false; /* - * Check to see if the WAL file has been removed by checkpoint, - * which implies it has already been archived, and explains why we - * can't see a status file for it. + * Check to see if the WAL file has been removed by checkpoint, which + * implies it has already been archived, and explains why we can't see a + * status file for it. */ snprintf(archiveStatusPath, MAXPGPATH, XLOGDIR "/%s", xlog); if (stat(archiveStatusPath, &stat_buf) != 0 && @@ -1775,8 +1777,8 @@ XLogSetAsyncCommitLSN(XLogRecPtr asyncCommitLSN) * Advance minRecoveryPoint in control file. * * If we crash during recovery, we must reach this point again before the - * database is consistent. - * + * database is consistent. + * * If 'force' is true, 'lsn' argument is ignored. Otherwise, minRecoveryPoint * is is only updated if it's not already greater than or equal to 'lsn'. */ @@ -1802,7 +1804,7 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force) { /* use volatile pointer to prevent code rearrangement */ volatile XLogCtlData *xlogctl = XLogCtl; - XLogRecPtr newMinRecoveryPoint; + XLogRecPtr newMinRecoveryPoint; /* * To avoid having to update the control file too often, we update it @@ -2567,7 +2569,7 @@ 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 + * the OS to release any cached pages. But do not do so if WAL archiving * is active, because archiver process could use the cache to read the WAL * segment. Also, don't bother with it if we are using O_DIRECT, since * the kernel is presumably not caching in that case. @@ -2663,19 +2665,19 @@ RestoreArchivedFile(char *path, const char *xlogfname, /* * Calculate the archive file cutoff point for use during log shipping - * replication. All files earlier than this point can be deleted - * from the archive, though there is no requirement to do so. + * replication. All files earlier than this point can be deleted from the + * archive, though there is no requirement to do so. * * We initialise this with the filename of an InvalidXLogRecPtr, which - * will prevent the deletion of any WAL files from the archive - * because of the alphabetic sorting property of WAL filenames. + * will prevent the deletion of any WAL files from the archive because of + * the alphabetic sorting property of WAL filenames. * * Once we have successfully located the redo pointer of the checkpoint * from which we start recovery we never request a file prior to the redo - * pointer of the last restartpoint. When redo begins we know that we - * have successfully located it, so there is no need for additional - * status flags to signify the point when we can begin deleting WAL files - * from the archive. + * pointer of the last restartpoint. When redo begins we know that we have + * successfully located it, so there is no need for additional status + * flags to signify the point when we can begin deleting WAL files from + * the archive. */ if (InRedo) { @@ -2821,9 +2823,9 @@ RestoreArchivedFile(char *path, const char *xlogfname, * On SIGTERM, assume we have received a fast shutdown request, and exit * cleanly. It's pure chance whether we receive the SIGTERM first, or the * child process. If we receive it first, the signal handler will call - * proc_exit, otherwise we do it here. If we or the child process - * received SIGTERM for any other reason than a fast shutdown request, - * postmaster will perform an immediate shutdown when it sees us exiting + * proc_exit, otherwise we do it here. If we or the child process received + * SIGTERM for any other reason than a fast shutdown request, postmaster + * will perform an immediate shutdown when it sees us exiting * unexpectedly. * * Per the Single Unix Spec, shells report exit status > 128 when a called @@ -2871,19 +2873,19 @@ ExecuteRecoveryEndCommand(void) /* * Calculate the archive file cutoff point for use during log shipping - * replication. All files earlier than this point can be deleted - * from the archive, though there is no requirement to do so. + * replication. All files earlier than this point can be deleted from the + * archive, though there is no requirement to do so. * * We initialise this with the filename of an InvalidXLogRecPtr, which - * will prevent the deletion of any WAL files from the archive - * because of the alphabetic sorting property of WAL filenames. + * will prevent the deletion of any WAL files from the archive because of + * the alphabetic sorting property of WAL filenames. * * Once we have successfully located the redo pointer of the checkpoint * from which we start recovery we never request a file prior to the redo - * pointer of the last restartpoint. When redo begins we know that we - * have successfully located it, so there is no need for additional - * status flags to signify the point when we can begin deleting WAL files - * from the archive. + * pointer of the last restartpoint. When redo begins we know that we have + * successfully located it, so there is no need for additional status + * flags to signify the point when we can begin deleting WAL files from + * the archive. */ if (InRedo) { @@ -2948,14 +2950,14 @@ ExecuteRecoveryEndCommand(void) { /* * If the failure was due to any sort of signal, it's best to punt and - * abort recovery. See also detailed comments on signals in + * abort recovery. See also detailed comments on signals in * RestoreArchivedFile(). */ signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 125; ereport(signaled ? FATAL : WARNING, (errmsg("recovery_end_command \"%s\": return code %d", - xlogRecoveryEndCmd, rc))); + xlogRecoveryEndCmd, rc))); } } @@ -3101,12 +3103,12 @@ static void ValidateXLOGDirectoryStructure(void) { char path[MAXPGPATH]; - struct stat stat_buf; + struct stat stat_buf; /* Check for pg_xlog; if it doesn't exist, error out */ if (stat(XLOGDIR, &stat_buf) != 0 || !S_ISDIR(stat_buf.st_mode)) - ereport(FATAL, + ereport(FATAL, (errmsg("required WAL directory \"%s\" does not exist", XLOGDIR))); @@ -3116,7 +3118,7 @@ ValidateXLOGDirectoryStructure(void) { /* Check for weird cases where it exists but isn't a directory */ if (!S_ISDIR(stat_buf.st_mode)) - ereport(FATAL, + ereport(FATAL, (errmsg("required WAL directory \"%s\" does not exist", path))); } @@ -3125,7 +3127,7 @@ ValidateXLOGDirectoryStructure(void) ereport(LOG, (errmsg("creating missing WAL directory \"%s\"", path))); if (mkdir(path, 0700) < 0) - ereport(FATAL, + ereport(FATAL, (errmsg("could not create missing directory \"%s\": %m", path))); } @@ -3187,7 +3189,7 @@ CleanupBackupHistory(void) * ignoring them as already applied, but that's not a huge drawback. * * If 'cleanup' is true, a cleanup lock is used when restoring blocks. - * Otherwise, a normal exclusive lock is used. At the moment, that's just + * Otherwise, a normal exclusive lock is used. At the moment, that's just * pro forma, because there can't be any regular backends in the system * during recovery. The 'cleanup' argument applies to all backup blocks * in the WAL record, that suffices for now. @@ -4283,8 +4285,8 @@ ReadControlFile(void) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized with PG_CONTROL_VERSION %d (0x%08x)," - " but the server was compiled with PG_CONTROL_VERSION %d (0x%08x).", - ControlFile->pg_control_version, ControlFile->pg_control_version, + " but the server was compiled with PG_CONTROL_VERSION %d (0x%08x).", + ControlFile->pg_control_version, ControlFile->pg_control_version, PG_CONTROL_VERSION, PG_CONTROL_VERSION), errhint("This could be a problem of mismatched byte ordering. It looks like you need to initdb."))); @@ -4309,8 +4311,8 @@ ReadControlFile(void) /* * Do compatibility checking immediately. If the database isn't - * compatible with the backend executable, we want to abort before we - * can possibly do any damage. + * compatible with the backend executable, we want to abort before we can + * possibly do any damage. */ if (ControlFile->catalog_version_no != CATALOG_VERSION_NO) ereport(FATAL, @@ -4402,14 +4404,14 @@ ReadControlFile(void) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized without USE_FLOAT4_BYVAL" - " but the server was compiled with USE_FLOAT4_BYVAL."), + " but the server was compiled with USE_FLOAT4_BYVAL."), errhint("It looks like you need to recompile or initdb."))); #else if (ControlFile->float4ByVal != false) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with USE_FLOAT4_BYVAL" - " but the server was compiled without USE_FLOAT4_BYVAL."), + errdetail("The database cluster was initialized with USE_FLOAT4_BYVAL" + " but the server was compiled without USE_FLOAT4_BYVAL."), errhint("It looks like you need to recompile or initdb."))); #endif @@ -4418,14 +4420,14 @@ ReadControlFile(void) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized without USE_FLOAT8_BYVAL" - " but the server was compiled with USE_FLOAT8_BYVAL."), + " but the server was compiled with USE_FLOAT8_BYVAL."), errhint("It looks like you need to recompile or initdb."))); #else if (ControlFile->float8ByVal != false) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with USE_FLOAT8_BYVAL" - " but the server was compiled without USE_FLOAT8_BYVAL."), + errdetail("The database cluster was initialized with USE_FLOAT8_BYVAL" + " but the server was compiled without USE_FLOAT8_BYVAL."), errhint("It looks like you need to recompile or initdb."))); #endif } @@ -4848,9 +4850,9 @@ readRecoveryCommandFile(void) * does nothing if a recovery_target is not also set */ if (!parse_bool(tok2, &recoveryTargetInclusive)) - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("parameter \"recovery_target_inclusive\" requires a Boolean value"))); + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("parameter \"recovery_target_inclusive\" requires a Boolean value"))); ereport(LOG, (errmsg("recovery_target_inclusive = %s", tok2))); } @@ -5204,8 +5206,8 @@ StartupXLOG(void) /* * Verify that pg_xlog and pg_xlog/archive_status exist. In cases where - * someone has performed a copy for PITR, these directories may have - * been excluded and need to be re-created. + * someone has performed a copy for PITR, these directories may have been + * excluded and need to be re-created. */ ValidateXLOGDirectoryStructure(); @@ -5437,6 +5439,7 @@ StartupXLOG(void) bool recoveryApply = true; bool reachedMinRecoveryPoint = false; ErrorContextCallback errcontext; + /* use volatile pointer to prevent code rearrangement */ volatile XLogCtlData *xlogctl = XLogCtl; @@ -5454,7 +5457,7 @@ StartupXLOG(void) else ereport(LOG, (errmsg("redo starts at %X/%X, consistency will be reached at %X/%X", - ReadRecPtr.xlogid, ReadRecPtr.xrecoff, + ReadRecPtr.xlogid, ReadRecPtr.xrecoff, minRecoveryPoint.xlogid, minRecoveryPoint.xrecoff))); /* @@ -5512,17 +5515,17 @@ StartupXLOG(void) proc_exit(1); /* - * Have we reached our safe starting point? If so, we can - * tell postmaster that the database is consistent now. + * Have we reached our safe starting point? If so, we can tell + * postmaster that the database is consistent now. */ - if (!reachedMinRecoveryPoint && - XLByteLE(minRecoveryPoint, EndRecPtr)) + if (!reachedMinRecoveryPoint && + XLByteLE(minRecoveryPoint, EndRecPtr)) { reachedMinRecoveryPoint = true; if (InArchiveRecovery) { ereport(LOG, - (errmsg("consistent recovery state reached"))); + (errmsg("consistent recovery state reached"))); if (IsUnderPostmaster) SendPostmasterSignal(PMSIGNAL_RECOVERY_CONSISTENT); } @@ -5554,9 +5557,8 @@ StartupXLOG(void) } /* - * Update shared replayEndRecPtr before replaying this - * record, so that XLogFlush will update minRecoveryPoint - * correctly. + * Update shared replayEndRecPtr before replaying this record, + * so that XLogFlush will update minRecoveryPoint correctly. */ SpinLockAcquire(&xlogctl->info_lck); xlogctl->replayEndRecPtr = EndRecPtr; @@ -5819,9 +5821,9 @@ bool RecoveryInProgress(void) { /* - * We check shared state each time only until we leave recovery mode. - * We can't re-enter recovery, so we rely on the local state variable - * after that. + * We check shared state each time only until we leave recovery mode. We + * can't re-enter recovery, so we rely on the local state variable after + * that. */ if (!LocalRecoveryInProgress) return false; @@ -6114,11 +6116,11 @@ ShutdownXLOG(int code, Datum arg) static void LogCheckpointStart(int flags, bool restartpoint) { - char *msg; + char *msg; /* - * XXX: This is hopelessly untranslatable. We could call gettext_noop - * for the main message, but what about all the flags? + * XXX: This is hopelessly untranslatable. We could call gettext_noop for + * the main message, but what about all the flags? */ if (restartpoint) msg = "restartpoint starting:%s%s%s%s%s%s"; @@ -6561,7 +6563,7 @@ CheckPointGuts(XLogRecPtr checkPointRedo, int flags) /* * This is used during WAL recovery to establish a point from which recovery - * can roll forward without replaying the entire recovery log. This function + * can roll forward without replaying the entire recovery log. This function * is called each time a checkpoint record is read from XLOG. It is stored * in shared memory, so that it can be used as a restartpoint later on. */ @@ -6569,6 +6571,7 @@ static void RecoveryRestartPoint(const CheckPoint *checkPoint) { int rmid; + /* use volatile pointer to prevent code rearrangement */ volatile XLogCtlData *xlogctl = XLogCtl; @@ -6592,8 +6595,8 @@ RecoveryRestartPoint(const CheckPoint *checkPoint) } /* - * Copy the checkpoint record to shared memory, so that bgwriter can - * use it the next time it wants to perform a restartpoint. + * Copy the checkpoint record to shared memory, so that bgwriter can use + * it the next time it wants to perform a restartpoint. */ SpinLockAcquire(&xlogctl->info_lck); XLogCtl->lastCheckPointRecPtr = ReadRecPtr; @@ -6613,8 +6616,9 @@ RecoveryRestartPoint(const CheckPoint *checkPoint) bool CreateRestartPoint(int flags) { - XLogRecPtr lastCheckPointRecPtr; - CheckPoint lastCheckPoint; + XLogRecPtr lastCheckPointRecPtr; + CheckPoint lastCheckPoint; + /* use volatile pointer to prevent code rearrangement */ volatile XLogCtlData *xlogctl = XLogCtl; @@ -6630,14 +6634,14 @@ CreateRestartPoint(int flags) memcpy(&lastCheckPoint, &XLogCtl->lastCheckPoint, sizeof(CheckPoint)); SpinLockRelease(&xlogctl->info_lck); - /* + /* * Check that we're still in recovery mode. It's ok if we exit recovery * mode after this check, the restart point is valid anyway. */ if (!RecoveryInProgress()) { ereport(DEBUG2, - (errmsg("skipping restartpoint, recovery has already ended"))); + (errmsg("skipping restartpoint, recovery has already ended"))); LWLockRelease(CheckpointLock); return false; } @@ -6653,16 +6657,17 @@ CreateRestartPoint(int flags) * possible in case of immediate shutdown, though. * * We don't explicitly advance minRecoveryPoint when we do create a - * restartpoint. It's assumed that flushing the buffers will do that - * as a side-effect. + * restartpoint. It's assumed that flushing the buffers will do that as a + * side-effect. */ if (XLogRecPtrIsInvalid(lastCheckPointRecPtr) || XLByteLE(lastCheckPoint.redo, ControlFile->checkPointCopy.redo)) { - XLogRecPtr InvalidXLogRecPtr = {0, 0}; + XLogRecPtr InvalidXLogRecPtr = {0, 0}; + ereport(DEBUG2, (errmsg("skipping restartpoint, already performed at %X/%X", - lastCheckPoint.redo.xlogid, lastCheckPoint.redo.xrecoff))); + lastCheckPoint.redo.xlogid, lastCheckPoint.redo.xrecoff))); UpdateMinRecoveryPoint(InvalidXLogRecPtr, true); LWLockRelease(CheckpointLock); @@ -6694,9 +6699,9 @@ CreateRestartPoint(int flags) LWLockRelease(ControlFileLock); /* - * Currently, there is no need to truncate pg_subtrans during recovery. - * If we did do that, we will need to have called StartupSUBTRANS() - * already and then TruncateSUBTRANS() would go here. + * Currently, there is no need to truncate pg_subtrans during recovery. If + * we did do that, we will need to have called StartupSUBTRANS() already + * and then TruncateSUBTRANS() would go here. */ /* All real work is done, but log before releasing lock. */ @@ -6705,12 +6710,12 @@ |