Commit f99a569a authored by Bruce Momjian's avatar Bruce Momjian

pgindent run for 8.2.

parent 451e419e
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Darko Prenosil <Darko.Prenosil@finteh.hr> * Darko Prenosil <Darko.Prenosil@finteh.hr>
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in> * Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
* *
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.58 2006/09/02 21:11:15 joe Exp $ * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.59 2006/10/04 00:29:44 momjian Exp $
* Copyright (c) 2001-2006, PostgreSQL Global Development Group * Copyright (c) 2001-2006, PostgreSQL Global Development Group
* ALL RIGHTS RESERVED; * ALL RIGHTS RESERVED;
* *
...@@ -362,11 +362,11 @@ dblink_open(PG_FUNCTION_ARGS) ...@@ -362,11 +362,11 @@ dblink_open(PG_FUNCTION_ARGS)
DBLINK_RES_INTERNALERROR("begin error"); DBLINK_RES_INTERNALERROR("begin error");
PQclear(res); PQclear(res);
rconn->newXactForCursor = TRUE; rconn->newXactForCursor = TRUE;
/* /*
* Since transaction state was IDLE, we force cursor count to * Since transaction state was IDLE, we force cursor count to
* initially be 0. This is needed as a previous ABORT might * initially be 0. This is needed as a previous ABORT might have wiped
* have wiped out our transaction without maintaining the * out our transaction without maintaining the cursor count for us.
* cursor count for us.
*/ */
rconn->openCursorCount = 0; rconn->openCursorCount = 0;
} }
...@@ -621,8 +621,8 @@ dblink_fetch(PG_FUNCTION_ARGS) ...@@ -621,8 +621,8 @@ dblink_fetch(PG_FUNCTION_ARGS)
if (PQnfields(res) != tupdesc->natts) if (PQnfields(res) != tupdesc->natts)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("remote query result rowtype does not match " errmsg("remote query result rowtype does not match "
"the specified FROM clause rowtype"))); "the specified FROM clause rowtype")));
/* fast track when no results */ /* fast track when no results */
if (funcctx->max_calls < 1) if (funcctx->max_calls < 1)
...@@ -827,7 +827,7 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get) ...@@ -827,7 +827,7 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
if (!res || if (!res ||
(PQresultStatus(res) != PGRES_COMMAND_OK && (PQresultStatus(res) != PGRES_COMMAND_OK &&
PQresultStatus(res) != PGRES_TUPLES_OK)) PQresultStatus(res) != PGRES_TUPLES_OK))
{ {
if (fail) if (fail)
DBLINK_RES_ERROR("sql error"); DBLINK_RES_ERROR("sql error");
...@@ -839,33 +839,33 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get) ...@@ -839,33 +839,33 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
SRF_RETURN_DONE(funcctx); SRF_RETURN_DONE(funcctx);
} }
} }
if (PQresultStatus(res) == PGRES_COMMAND_OK) if (PQresultStatus(res) == PGRES_COMMAND_OK)
{ {
is_sql_cmd = true; is_sql_cmd = true;
/* need a tuple descriptor representing one TEXT column */ /* need a tuple descriptor representing one TEXT column */
tupdesc = CreateTemplateTupleDesc(1, false); tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status", TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status",
TEXTOID, -1, 0); TEXTOID, -1, 0);
/* /*
* and save a copy of the command status string to return as our * and save a copy of the command status string to return as
* result tuple * our result tuple
*/ */
sql_cmd_status = PQcmdStatus(res); sql_cmd_status = PQcmdStatus(res);
funcctx->max_calls = 1; funcctx->max_calls = 1;
} }
else else
funcctx->max_calls = PQntuples(res); funcctx->max_calls = PQntuples(res);
/* got results, keep track of them */ /* got results, keep track of them */
funcctx->user_fctx = res; funcctx->user_fctx = res;
/* if needed, close the connection to the database and cleanup */ /* if needed, close the connection to the database and cleanup */
if (freeconn) if (freeconn)
PQfinish(conn); PQfinish(conn);
if (!is_sql_cmd) if (!is_sql_cmd)
{ {
/* get a tuple descriptor for our result type */ /* get a tuple descriptor for our result type */
...@@ -878,26 +878,29 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get) ...@@ -878,26 +878,29 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
/* failed to determine actual type of RECORD */ /* failed to determine actual type of RECORD */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("function returning record called in context " errmsg("function returning record called in context "
"that cannot accept type record"))); "that cannot accept type record")));
break; break;
default: default:
/* result type isn't composite */ /* result type isn't composite */
elog(ERROR, "return type must be a row type"); elog(ERROR, "return type must be a row type");
break; break;
} }
/* make sure we have a persistent copy of the tupdesc */ /* make sure we have a persistent copy of the tupdesc */
tupdesc = CreateTupleDescCopy(tupdesc); tupdesc = CreateTupleDescCopy(tupdesc);
} }
/* check result and tuple descriptor have the same number of columns */ /*
* check result and tuple descriptor have the same number of
* columns
*/
if (PQnfields(res) != tupdesc->natts) if (PQnfields(res) != tupdesc->natts)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("remote query result rowtype does not match " errmsg("remote query result rowtype does not match "
"the specified FROM clause rowtype"))); "the specified FROM clause rowtype")));
/* fast track when no results */ /* fast track when no results */
if (funcctx->max_calls < 1) if (funcctx->max_calls < 1)
{ {
...@@ -905,11 +908,11 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get) ...@@ -905,11 +908,11 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
PQclear(res); PQclear(res);
SRF_RETURN_DONE(funcctx); SRF_RETURN_DONE(funcctx);
} }
/* store needed metadata for subsequent calls */ /* store needed metadata for subsequent calls */
attinmeta = TupleDescGetAttInMetadata(tupdesc); attinmeta = TupleDescGetAttInMetadata(tupdesc);
funcctx->attinmeta = attinmeta; funcctx->attinmeta = attinmeta;
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
} }
else else
...@@ -991,9 +994,9 @@ PG_FUNCTION_INFO_V1(dblink_get_connections); ...@@ -991,9 +994,9 @@ PG_FUNCTION_INFO_V1(dblink_get_connections);
Datum Datum
dblink_get_connections(PG_FUNCTION_ARGS) dblink_get_connections(PG_FUNCTION_ARGS)
{ {
HASH_SEQ_STATUS status; HASH_SEQ_STATUS status;
remoteConnHashEnt *hentry; remoteConnHashEnt *hentry;
ArrayBuildState *astate = NULL; ArrayBuildState *astate = NULL;
if (remoteConnHash) if (remoteConnHash)
{ {
...@@ -1019,19 +1022,19 @@ dblink_get_connections(PG_FUNCTION_ARGS) ...@@ -1019,19 +1022,19 @@ dblink_get_connections(PG_FUNCTION_ARGS)
* *
* Returns 1 if the connection is busy, 0 otherwise * Returns 1 if the connection is busy, 0 otherwise
* Params: * Params:
* text connection_name - name of the connection to check * text connection_name - name of the connection to check
* *
*/ */
PG_FUNCTION_INFO_V1(dblink_is_busy); PG_FUNCTION_INFO_V1(dblink_is_busy);
Datum Datum
dblink_is_busy(PG_FUNCTION_ARGS) dblink_is_busy(PG_FUNCTION_ARGS)
{ {
char *msg; char *msg;
PGconn *conn = NULL; PGconn *conn = NULL;
char *conname = NULL; char *conname = NULL;
char *connstr = NULL; char *connstr = NULL;
remoteConn *rconn = NULL; remoteConn *rconn = NULL;
bool freeconn = false; bool freeconn = false;
DBLINK_INIT; DBLINK_INIT;
DBLINK_GET_CONN; DBLINK_GET_CONN;
...@@ -1045,27 +1048,27 @@ dblink_is_busy(PG_FUNCTION_ARGS) ...@@ -1045,27 +1048,27 @@ dblink_is_busy(PG_FUNCTION_ARGS)
/* /*
* Cancels a running request on a connection * Cancels a running request on a connection
* *
* Returns text: * Returns text:
* "OK" if the cancel request has been sent correctly, * "OK" if the cancel request has been sent correctly,
* an error message otherwise * an error message otherwise
* *
* Params: * Params:
* text connection_name - name of the connection to check * text connection_name - name of the connection to check
* *
*/ */
PG_FUNCTION_INFO_V1(dblink_cancel_query); PG_FUNCTION_INFO_V1(dblink_cancel_query);
Datum Datum
dblink_cancel_query(PG_FUNCTION_ARGS) dblink_cancel_query(PG_FUNCTION_ARGS)
{ {
char *msg; char *msg;
int res = 0; int res = 0;
PGconn *conn = NULL; PGconn *conn = NULL;
char *conname = NULL; char *conname = NULL;
char *connstr = NULL; char *connstr = NULL;
remoteConn *rconn = NULL; remoteConn *rconn = NULL;
bool freeconn = false; bool freeconn = false;
PGcancel *cancel; PGcancel *cancel;
char errbuf[256]; char errbuf[256];
DBLINK_INIT; DBLINK_INIT;
DBLINK_GET_CONN; DBLINK_GET_CONN;
...@@ -1077,7 +1080,7 @@ dblink_cancel_query(PG_FUNCTION_ARGS) ...@@ -1077,7 +1080,7 @@ dblink_cancel_query(PG_FUNCTION_ARGS)
PQfreeCancel(cancel); PQfreeCancel(cancel);
if (res == 0) if (res == 0)
PG_RETURN_TEXT_P(GET_TEXT("OK")); PG_RETURN_TEXT_P(GET_TEXT("OK"));
else else
PG_RETURN_TEXT_P(GET_TEXT(errbuf)); PG_RETURN_TEXT_P(GET_TEXT(errbuf));
} }
...@@ -1086,23 +1089,23 @@ dblink_cancel_query(PG_FUNCTION_ARGS) ...@@ -1086,23 +1089,23 @@ dblink_cancel_query(PG_FUNCTION_ARGS)
/* /*
* Get error message from a connection * Get error message from a connection
* *
* Returns text: * Returns text:
* "OK" if no error, an error message otherwise * "OK" if no error, an error message otherwise
* *
* Params: * Params:
* text connection_name - name of the connection to check * text connection_name - name of the connection to check
* *
*/ */
PG_FUNCTION_INFO_V1(dblink_error_message); PG_FUNCTION_INFO_V1(dblink_error_message);
Datum Datum
dblink_error_message(PG_FUNCTION_ARGS) dblink_error_message(PG_FUNCTION_ARGS)
{ {
char *msg; char *msg;
PGconn *conn = NULL; PGconn *conn = NULL;
char *conname = NULL; char *conname = NULL;
char *connstr = NULL; char *connstr = NULL;
remoteConn *rconn = NULL; remoteConn *rconn = NULL;
bool freeconn = false; bool freeconn = false;
DBLINK_INIT; DBLINK_INIT;
DBLINK_GET_CONN; DBLINK_GET_CONN;
...@@ -1859,7 +1862,7 @@ get_sql_delete(Oid relid, int2vector *pkattnums, int16 pknumatts, char **tgt_pka ...@@ -1859,7 +1862,7 @@ get_sql_delete(Oid relid, int2vector *pkattnums, int16 pknumatts, char **tgt_pka
char *relname; char *relname;
TupleDesc tupdesc; TupleDesc tupdesc;
int natts; int natts;
StringInfoData buf; StringInfoData buf;
int i; int i;
initStringInfo(&buf); initStringInfo(&buf);
......
...@@ -11,39 +11,42 @@ ...@@ -11,39 +11,42 @@
#include "storage/bufpage.h" #include "storage/bufpage.h"
typedef struct { typedef struct
uint16 keylen; {
uint16 vallen; uint16 keylen;
uint32 uint16 vallen;
valisnull:1, uint32
pos:31; valisnull:1,
} HEntry; pos:31;
} HEntry;
typedef struct {
int4 len; typedef struct
int4 size; {
char data[1]; int4 len;
} HStore; int4 size;
char data[1];
} HStore;
#define HSHRDSIZE (2*sizeof(int4)) #define HSHRDSIZE (2*sizeof(int4))
#define CALCDATASIZE(x, lenstr) ( (x) * sizeof(HEntry) + HSHRDSIZE + (lenstr) ) #define CALCDATASIZE(x, lenstr) ( (x) * sizeof(HEntry) + HSHRDSIZE + (lenstr) )
#define ARRPTR(x) ( (HEntry*) ( (char*)(x) + HSHRDSIZE ) ) #define ARRPTR(x) ( (HEntry*) ( (char*)(x) + HSHRDSIZE ) )
#define STRPTR(x) ( (char*)(x) + HSHRDSIZE + ( sizeof(HEntry) * ((HStore*)x)->size ) ) #define STRPTR(x) ( (char*)(x) + HSHRDSIZE + ( sizeof(HEntry) * ((HStore*)x)->size ) )
#define PG_GETARG_HS(x) ((HStore*)PG_DETOAST_DATUM(PG_GETARG_DATUM(x))) #define PG_GETARG_HS(x) ((HStore*)PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))
typedef struct { typedef struct
char *key; {
char *val; char *key;
uint16 keylen; char *val;
uint16 vallen; uint16 keylen;
bool isnull; uint16 vallen;
bool needfree; bool isnull;
} Pairs; bool needfree;
} Pairs;
int comparePairs(const void *a, const void *b); int comparePairs(const void *a, const void *b);
int uniquePairs(Pairs * a, int4 l, int4 *buflen); int uniquePairs(Pairs * a, int4 l, int4 *buflen);
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -154,17 +154,17 @@ typedef struct ...@@ -154,17 +154,17 @@ typedef struct
#define COMPUTESIZE(size) ( HDRSIZEQT + size * sizeof(ITEM) ) #define COMPUTESIZE(size) ( HDRSIZEQT + size * sizeof(ITEM) )
#define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT )
#define END 0 #define END 0
#define ERR 1 #define ERR 1
#define VAL 2 #define VAL 2
#define OPR 3 #define OPR 3
#define OPEN 4 #define OPEN 4
#define CLOSE 5 #define CLOSE 5
bool signconsistent(QUERYTYPE * query, BITVEC sign, bool calcnot); bool signconsistent(QUERYTYPE * query, BITVEC sign, bool calcnot);
bool execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot); bool execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot);
bool ginconsistent(QUERYTYPE * query, bool *check); bool ginconsistent(QUERYTYPE * query, bool *check);
int4 shorterquery(ITEM * q, int4 len); int4 shorterquery(ITEM * q, int4 len);
int compASC(const void *a, const void *b); int compASC(const void *a, const void *b);
......
...@@ -232,7 +232,7 @@ typedef struct ...@@ -232,7 +232,7 @@ typedef struct
* is there value 'val' in array or not ? * is there value 'val' in array or not ?
*/ */
static bool static bool
checkcondition_arr(void *checkval, ITEM *item) checkcondition_arr(void *checkval, ITEM * item)
{ {
int4 *StopLow = ((CHKVAL *) checkval)->arrb; int4 *StopLow = ((CHKVAL *) checkval)->arrb;
int4 *StopHigh = ((CHKVAL *) checkval)->arre; int4 *StopHigh = ((CHKVAL *) checkval)->arre;
...@@ -254,7 +254,7 @@ checkcondition_arr(void *checkval, ITEM *item) ...@@ -254,7 +254,7 @@ checkcondition_arr(void *checkval, ITEM *item)
} }
static bool static bool
checkcondition_bit(void *checkval, ITEM *item) checkcondition_bit(void *checkval, ITEM * item)
{ {
return GETBIT(checkval, HASHVAL(item->val)); return GETBIT(checkval, HASHVAL(item->val));
} }
...@@ -263,7 +263,7 @@ checkcondition_bit(void *checkval, ITEM *item) ...@@ -263,7 +263,7 @@ checkcondition_bit(void *checkval, ITEM *item)
* check for boolean condition * check for boolean condition
*/ */
static bool 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) if (curitem->type == VAL)
...@@ -319,38 +319,42 @@ execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot) ...@@ -319,38 +319,42 @@ execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot)
); );
} }
typedef struct { typedef struct
ITEM *first; {
bool *mapped_check; ITEM *first;
} GinChkVal; bool *mapped_check;
} GinChkVal;
static bool static bool
checkcondition_gin(void *checkval, ITEM *item) { checkcondition_gin(void *checkval, ITEM * item)
GinChkVal *gcv = (GinChkVal*)checkval; {
GinChkVal *gcv = (GinChkVal *) checkval;
return gcv->mapped_check[ item - gcv->first ]; return gcv->mapped_check[item - gcv->first];
} }
bool bool
ginconsistent(QUERYTYPE * query, bool *check) { ginconsistent(QUERYTYPE * query, bool *check)
GinChkVal gcv; {
ITEM *items = GETQUERY(query); GinChkVal gcv;
int i, j=0; ITEM *items = GETQUERY(query);
int i,
j = 0;
if ( query->size < 0 ) if (query->size < 0)
return FALSE; return FALSE;
gcv.first = items; gcv.first = items;
gcv.mapped_check = (bool*)palloc( sizeof(bool)*query->size ); gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size);
for(i=0; i<query->size; i++) for (i = 0; i < query->size; i++)
if ( items[i].type == VAL ) if (items[i].type == VAL)
gcv.mapped_check[ i ] = check[ j++ ]; gcv.mapped_check[i] = check[j++];
return execute( return execute(
GETQUERY(query) + query->size - 1, GETQUERY(query) + query->size - 1,
(void *) &gcv, true, (void *) &gcv, true,
checkcondition_gin checkcondition_gin
); );
} }
/* /*
......
#include "_int.h" #include "_int.h"
PG_FUNCTION_INFO_V1(ginint4_queryextract); PG_FUNCTION_INFO_V1(ginint4_queryextract);
Datum ginint4_queryextract(PG_FUNCTION_ARGS); Datum ginint4_queryextract(PG_FUNCTION_ARGS);
Datum Datum
ginint4_queryextract(PG_FUNCTION_ARGS) { ginint4_queryextract(PG_FUNCTION_ARGS)
uint32 *nentries = (uint32*)PG_GETARG_POINTER(1); {
StrategyNumber strategy = PG_GETARG_UINT16(2); uint32 *nentries = (uint32 *) PG_GETARG_POINTER(1);
Datum *res = NULL; StrategyNumber strategy = PG_GETARG_UINT16(2);
Datum *res = NULL;
*nentries = 0; *nentries = 0;
if ( strategy == BooleanSearchStrategy ) { if (strategy == BooleanSearchStrategy)
QUERYTYPE *query = (QUERYTYPE*)PG_DETOAST_DATUM_COPY(PG_GETARG_POINTER(0)); {
ITEM *items = GETQUERY(query); QUERYTYPE *query = (QUERYTYPE *) PG_DETOAST_DATUM_COPY(PG_GETARG_POINTER(0));
int i; ITEM *items = GETQUERY(query);
int i;
if (query->size == 0) if (query->size == 0)
PG_RETURN_POINTER(NULL); PG_RETURN_POINTER(NULL);
if ( shorterquery(items, query->size) == 0 ) if (shorterquery(items, query->size) == 0)
elog(ERROR,"Query requires full scan, GIN doesn't support it"); elog(ERROR, "Query requires full scan, GIN doesn't support it");
pfree( query ); pfree(query);
query = (QUERYTYPE*)PG_DETOAST_DATUM(PG_GETARG_POINTER(0)); query = (QUERYTYPE *) PG_DETOAST_DATUM(PG_GETARG_POINTER(0));
items = GETQUERY(query); items = GETQUERY(query);
res = (Datum*)palloc(sizeof(Datum) * query->size); res = (Datum *) palloc(sizeof(Datum) * query->size);
*nentries = 0; *nentries = 0;
for(i=0;i<query->size;i++) for (i = 0; i < query->size; i++)
if ( items[i].type == VAL ) { if (items[i].type == VAL)
res[*nentries] = Int32GetDatum( items[i].val ); {
res[*nentries] = Int32GetDatum(items[i].val);
(*nentries)++; (*nentries)++;
} }
} else { }
ArrayType *query = PG_GETARG_ARRAYTYPE_P(0); else
int4 *arr; {
uint32 i; ArrayType *query = PG_GETARG_ARRAYTYPE_P(0);
int4 *arr;
uint32 i;
CHECKARRVALID(query); CHECKARRVALID(query);
*nentries=ARRNELEMS(query); *nentries = ARRNELEMS(query);
if ( *nentries > 0 ) { if (*nentries > 0)
res = (Datum*)palloc(sizeof(Datum) * (*nentries)); {
res = (Datum *) palloc(sizeof(Datum) * (*nentries));
arr=ARRPTR(query);
for(i=0;i<*nentries;i++) arr = ARRPTR(query);
res[i] = Int32GetDatum( arr[i] ); for (i = 0; i < *nentries; i++)
res[i] = Int32GetDatum(arr[i]);
} }
} }
PG_RETURN_POINTER( res ); PG_RETURN_POINTER(res);
} }
PG_FUNCTION_INFO_V1(ginint4_consistent); PG_FUNCTION_INFO_V1(ginint4_consistent);
Datum ginint4_consistent(PG_FUNCTION_ARGS); Datum ginint4_consistent(PG_FUNCTION_ARGS);
Datum Datum
ginint4_consistent(PG_FUNCTION_ARGS) { ginint4_consistent(PG_FUNCTION_ARGS)
bool *check = (bool*)PG_GETARG_POINTER(0); {
StrategyNumber strategy = PG_GETARG_UINT16(1); bool *check = (bool *) PG_GETARG_POINTER(0);
int res=FALSE; StrategyNumber strategy = PG_GETARG_UINT16(1);
int res = FALSE;
/* we can do not check array carefully, it's done by previous ginarrayextract call */
/*
switch( strategy ) { * we can do not check array carefully, it's done by previous
case RTOverlapStrategyNumber: * ginarrayextract call
case RTContainedByStrategyNumber: */
case RTOldContainedByStrategyNumber:
/* at least one element in check[] is true, so result = true */ switch (strategy)
{
res = TRUE; case RTOverlapStrategyNumber:
break; case RTContainedByStrategyNumber:
case RTSameStrategyNumber: case RTOldContainedByStrategyNumber:
case RTContainsStrategyNumber: /* at least one element in check[] is true, so result = true */
case RTOldContainsStrategyNumber:
res = TRUE; res = TRUE;
do { break;
ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); case RTSameStrategyNumber:
int i, nentries=ARRNELEMS(query); case RTContainsStrategyNumber:
case RTOldContainsStrategyNumber:
for(i=0;i<nentries;i++) res = TRUE;
if ( !check[i] ) { do
res = FALSE; {
break; ArrayType *query = PG_GETARG_ARRAYTYPE_P(2);
} int i,
} while(0); nentries = ARRNELEMS(query);
break;
case BooleanSearchStrategy: for (i = 0; i < nentries; i++)
do { if (!check[i])
QUERYTYPE *query = (QUERYTYPE*)PG_DETOAST_DATUM(PG_GETARG_POINTER(2)); {
res = ginconsistent( query, check ); res = FALSE;
} while(0); break;
}
} while (0);
break; break;
default: case BooleanSearchStrategy:
elog(ERROR, "ginint4_consistent: unknown strategy number: %d", strategy); do
} {
QUERYTYPE *query = (QUERYTYPE *) PG_DETOAST_DATUM(PG_GETARG_POINTER(2));
res = ginconsistent(query, check);
} while (0);
break;
default:
elog(ERROR, "ginint4_consistent: unknown strategy number: %d", strategy);
}
PG_RETURN_BOOL(res); PG_RETURN_BOOL(res);
} }
...@@ -36,19 +36,21 @@ g_int_consistent(PG_FUNCTION_ARGS) ...@@ -36,19 +36,21 @@ g_int_consistent(PG_FUNCTION_ARGS)
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
bool retval; bool retval;
if (strategy == BooleanSearchStrategy) { if (strategy == BooleanSearchStrategy)
{
retval = execconsistent((QUERYTYPE *) query, retval = execconsistent((QUERYTYPE *) query,
(ArrayType *) DatumGetPointer(entry->key), (ArrayType *) DatumGetPointer(entry->key),
GIST_LEAF(entry)); GIST_LEAF(entry));
pfree( query ); pfree(query);
PG_RETURN_BOOL(retval); PG_RETURN_BOOL(retval);
} }
/* sort query for fast search, key is already sorted */ /* sort query for fast search, key is already sorted */
CHECKARRVALID(query); CHECKARRVALID(query);
if (ARRISVOID(query)) { if (ARRISVOID(query))
pfree( query ); {
pfree(query);
PG_RETURN_BOOL(false); PG_RETURN_BOOL(false);
} }
PREPAREARR(query); PREPAREARR(query);
...@@ -88,7 +90,7 @@ g_int_consistent(PG_FUNCTION_ARGS) ...@@ -88,7 +90,7 @@ g_int_consistent(PG_FUNCTION_ARGS)
default: default:
retval = FALSE; retval = FALSE;
} }
pfree( query ); pfree(query);
PG_RETURN_BOOL(retval); PG_RETURN_BOOL(retval);
} }
...@@ -156,7 +158,7 @@ g_int_compress(PG_FUNCTION_ARGS) ...@@ -156,7 +158,7 @@ g_int_compress(PG_FUNCTION_ARGS)
retval = palloc(sizeof(GISTENTRY)); retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r), gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page, entry->offset, FALSE); entry->rel, entry->page, entry->offset, FALSE);
PG_RETURN_POINTER(retval); PG_RETURN_POINTER(retval);
} }
...@@ -203,7 +205,7 @@ g_int_compress(PG_FUNCTION_ARGS) ...@@ -203,7 +205,7 @@ g_int_compress(PG_FUNCTION_ARGS)
r = resize_intArrayType(r, len); r = resize_intArrayType(r, len);
retval = palloc(sizeof(GISTENTRY)); retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r), gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page, entry->offset, FALSE); entry->rel, entry->page, entry->offset, FALSE);
PG_RETURN_POINTER(retval); PG_RETURN_POINTER(retval);
} }
else else
...@@ -240,7 +242,7 @@ g_int_decompress(PG_FUNCTION_ARGS) ...@@ -240,7 +242,7 @@ g_int_decompress(PG_FUNCTION_ARGS)
{ {
retval = palloc(sizeof(GISTENTRY)); retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(in), gistentryinit(*retval, PointerGetDatum(in),
entry->rel, entry->page, entry->offset, FALSE); entry->rel, entry->page, entry->offset, FALSE);
PG_RETURN_POINTER(retval); PG_RETURN_POINTER(retval);
} }
...@@ -331,7 +333,7 @@ typedef struct ...@@ -331,7 +333,7 @@ typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
float cost; float cost;
} SPLITCOST; } SPLITCOST;
static int static int
comparecost(const void *a, const void *b) comparecost(const void *a, const void *b)
......
...@@ -89,22 +89,27 @@ inner_int_union(ArrayType *a, ArrayType *b) ...@@ -89,22 +89,27 @@ inner_int_union(ArrayType *a, ArrayType *b)
if (!r) if (!r)
{ {
int na = ARRNELEMS(a), int na = ARRNELEMS(a),
nb = ARRNELEMS(b); nb = ARRNELEMS(b);
int *da = ARRPTR(a), int *da = ARRPTR(a),
*db = ARRPTR(b); *db = ARRPTR(b);
int i,j, *dr; int i,
j,
*dr;
r = new_intArrayType(na + nb); r = new_intArrayType(na + nb);
dr = ARRPTR(r); dr = ARRPTR(r);
/* union */ /* union */
i = j = 0; i = j = 0;
while (i < na && j < nb) { while (i < na && j < nb)
if (da[i] == db[j]) { {
if (da[i] == db[j])
{
*dr++ = da[i++]; *dr++ = da[i++];
j++; j++;
} else if (da[i] < db[j]) }
else if (da[i] < db[j])
*dr++ = da[i++]; *dr++ = da[i++];
else else
*dr++ = db[j++]; *dr++ = db[j++];
...@@ -115,7 +120,7 @@ inner_int_union(ArrayType *a, ArrayType *b) ...@@ -115,7 +120,7 @@ inner_int_union(ArrayType *a, ArrayType *b)
while (j < nb) while (j < nb)
*dr++ = db[j++]; *dr++ = db[j++];
r = resize_intArrayType(r, dr-ARRPTR(r)); r = resize_intArrayType(r, dr - ARRPTR(r));
} }
if (ARRNELEMS(r) > 1) if (ARRNELEMS(r) > 1)
......
...@@ -214,7 +214,7 @@ sizebitvec(BITVECP sign) ...@@ -214,7 +214,7 @@ sizebitvec(BITVECP sign)
i; i;
LOOPBYTE( LOOPBYTE(
size += number_of_ones[(unsigned char) sign[i]]; size += number_of_ones[(unsigned char) sign[i]];
); );
return size; return size;
} }
...@@ -227,8 +227,8 @@ hemdistsign(BITVECP a, BITVECP b) ...@@ -227,8 +227,8 @@ hemdistsign(BITVECP a, BITVECP b)
dist = 0; dist = 0;
LOOPBYTE( LOOPBYTE(
diff = (unsigned char) (a[i] ^ b[i]); diff = (unsigned char) (a[i] ^ b[i]);
dist += number_of_ones[diff]; dist += number_of_ones[diff];
); );
return dist; return dist;
} }
...@@ -318,7 +318,7 @@ typedef struct ...@@ -318,7 +318,7 @@ typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int4 cost;
} SPLITCOST; } SPLITCOST;
static int static int
comparecost(const void *a, const void *b) comparecost(const void *a, const void *b)
...@@ -506,16 +506,17 @@ g_intbig_consistent(PG_FUNCTION_ARGS) ...@@ -506,16 +506,17 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
if (strategy == BooleanSearchStrategy) if (strategy == BooleanSearchStrategy)
{ {
retval =signconsistent((QUERYTYPE *) query, retval = signconsistent((QUERYTYPE *) query,
GETSIGN(DatumGetPointer(entry->key)), GETSIGN(DatumGetPointer(entry->key)),
false); false);
PG_FREE_IF_COPY( query, 1 ); PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(retval); PG_RETURN_BOOL(retval);
} }
CHECKARRVALID(query); CHECKARRVALID(query);
if (ARRISVOID(query)) { if (ARRISVOID(query))
PG_FREE_IF_COPY( query, 1 ); {
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(FALSE); PG_RETURN_BOOL(FALSE);
} }
...@@ -602,6 +603,6 @@ g_intbig_consistent(PG_FUNCTION_ARGS) ...@@ -602,6 +603,6 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
default: default:
retval = FALSE; retval = FALSE;
} }
PG_FREE_IF_COPY( query, 1 ); PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(retval); PG_RETURN_BOOL(retval);
} }
This diff is collapsed.
/* /*
* ISBN.h * ISBN.h
* PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC) * PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
* *
...@@ -7,39 +7,39 @@ ...@@ -7,39 +7,39 @@
* http://www.isbn.org/ * http://www.isbn.org/
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/contrib/isn/ISBN.h,v 1.1 2006/09/09 04:07:52 tgl Exp $ * $PostgreSQL: pgsql/contrib/isn/ISBN.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
* *
* 0-393-04002-X => 039304002(X) <=> 039304002 <=> (978)039304002 <=> 978039304002(9) <=> 978-0-393-04002-9 * 0-393-04002-X => 039304002(X) <=> 039304002 <=> (978)039304002 <=> 978039304002(9) <=> 978-0-393-04002-9
* *
* *
* ISBN 0 3 9 3 0 4 0 0 2 * ISBN 0 3 9 3 0 4 0 0 2
* Weight 10 9 8 7 6 5 4 3 2 * Weight 10 9 8 7 6 5 4 3 2
* Product 0 + 27 + 72 + 21 + 0 + 20 + 0 + 0 + 4 = 144 * Product 0 + 27 + 72 + 21 + 0 + 20 + 0 + 0 + 4 = 144
* 144 / 11 = 13 remainder 1 * 144 / 11 = 13 remainder 1
* Check digit 11 - 1 = 10 = X * Check digit 11 - 1 = 10 = X
* => 0-393-04002-X * => 0-393-04002-X
* *
* ISBN 9 7 8 0 3 9 3 0 4 0 0 2 * ISBN 9 7 8 0 3 9 3 0 4 0 0 2
* Weight 1 3 1 3 1 3 1 3 1 3 1 3 * Weight 1 3 1 3 1 3 1 3 1 3 1 3
* Product 9 + 21 + 8 + 0 + 3 + 27 + 3 + 0 + 4 + 0 + 0 + 6 = 81 * Product 9 + 21 + 8 + 0 + 3 + 27 + 3 + 0 + 4 + 0 + 0 + 6 = 81
* 81 / 10 = 8 remainder 1 * 81 / 10 = 8 remainder 1
* Check digit 10 - 1 = 9 * Check digit 10 - 1 = 9
* => 978-0-393-04002-9 * => 978-0-393-04002-9
* *
*/ */
/* where the digit set begins, and how many of them are in the table */ /* where the digit set begins, and how many of them are in the table */
const unsigned ISBN_index[10][2] = { const unsigned ISBN_index[10][2] = {
{0, 6}, {0, 6},
{6, 6}, {6, 6},
{12, 8}, {12, 8},
{20, 10}, {20, 10},
{30, 6}, {30, 6},
{36, 12}, {36, 12},
{48, 0}, {48, 0},
{48, 5}, {48, 5},
{53, 59}, {53, 59},
{112, 573}, {112, 573},
}; };
const char *ISBN_range[][2] = { const char *ISBN_range[][2] = {
......
/* /*
* ISMN.h * ISMN.h
* PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC) * PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
* *
...@@ -6,23 +6,23 @@ ...@@ -6,23 +6,23 @@
* http://www.ismn-international.org * http://www.ismn-international.org
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/contrib/isn/ISMN.h,v 1.1 2006/09/09 04:07:52 tgl Exp $ * $PostgreSQL: pgsql/contrib/isn/ISMN.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
* *
* M-3452-4680-5 <=> (0)-3452-4680-5 <=> 0345246805 <=> 9790345246805 <=> 979-0-3452-4680-5 * M-3452-4680-5 <=> (0)-3452-4680-5 <=> 0345246805 <=> 9790345246805 <=> 979-0-3452-4680-5
* *
* (M counts as 3) * (M counts as 3)
* ISMN M 3 4 5 2 4 6 8 0 * ISMN M 3 4 5 2 4 6 8 0
* Weight 3 1 3 1 3 1 3 1 3 * Weight 3 1 3 1 3 1 3 1 3
* Product 9 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 65 * Product 9 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 65
* 65 / 10 = 6 remainder 5 * 65 / 10 = 6 remainder 5
* Check digit 10 - 5 = 5 * Check digit 10 - 5 = 5
* => M-3452-4680-5 * => M-3452-4680-5
* *
* ISMN 9 7 9 0 3 4 5 2 4 6 8 0 * ISMN 9 7 9 0 3 4 5 2 4 6 8 0
* Weight 1 3 1 3 1 3 1 3 1 3 1 3 * Weight 1 3 1 3 1 3 1 3 1 3 1 3
* Product 9 + 21 + 9 + 0 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 95 * Product 9 + 21 + 9 + 0 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 95
* 95 / 10 = 9 remainder 5 * 95 / 10 = 9 remainder 5
* Check digit 10 - 5 = 5 * Check digit 10 - 5 = 5
* => 979-0-3452-4680-5 * => 979-0-3452-4680-5
* *
* Since mod10(9*1 + 7*3 + 9*1 + 0*3) = mod10(M*3) = mod10(3*3) = 9; the check digit remains the same. * Since mod10(9*1 + 7*3 + 9*1 + 0*3) = mod10(M*3) = mod10(3*3) = 9; the check digit remains the same.
...@@ -31,16 +31,16 @@ ...@@ -31,16 +31,16 @@
/* where the digit set begins, and how many of them are in the table */ /* where the digit set begins, and how many of them are in the table */
const unsigned ISMN_index[10][2] = { const unsigned ISMN_index[10][2] = {
{0, 5}, {0, 5},
{5, 0}, {5, 0},
{5, 0}, {5, 0},
{5, 0}, {5, 0},
{5, 0}, {5, 0},
{5, 0}, {5, 0},
{5, 0}, {5, 0},
{5, 0}, {5, 0},
{5, 0}, {5, 0},
{5, 0}, {5, 0},
}; };
const char *ISMN_range[][2] = { const char *ISMN_range[][2] = {
{"0-000", "0-099"}, {"0-000", "0-099"},
......
/* /*
* ISSN.h * ISSN.h
* PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC) * PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
* *
...@@ -6,25 +6,25 @@ ...@@ -6,25 +6,25 @@
* http://www.issn.org/ * http://www.issn.org/
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/contrib/isn/ISSN.h,v 1.1 2006/09/09 04:07:52 tgl Exp $ * $PostgreSQL: pgsql/contrib/isn/ISSN.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
* *
* 1144-875X <=> 1144875(X) <=> 1144875 <=> (977)1144875 <=> 9771144875(00) <=> 977114487500(7) <=> 977-1144-875-00-7 * 1144-875X <=> 1144875(X) <=> 1144875 <=> (977)1144875 <=> 9771144875(00) <=> 977114487500(7) <=> 977-1144-875-00-7
* *
* *
* ISSN 1 1 4 4 8 7 5 * ISSN 1 1 4 4 8 7 5
* Weight 8 7 6 5 4 3 2 * Weight 8 7 6 5 4 3 2
* Product 8 + 7 + 24 + 20 + 32 + 21 + 10 = 122 * Product 8 + 7 + 24 + 20 + 32 + 21 + 10 = 122
* 122 / 11 = 11 remainder 1 * 122 / 11 = 11 remainder 1
* Check digit 11 - 1 = 10 = X * Check digit 11 - 1 = 10 = X
* => 1144-875X * => 1144-875X
* *
* ISSN 9 7 7 1 1 4 4 8 7 5 0 0 * ISSN 9 7 7 1 1 4 4 8 7 5 0 0
* Weight 1 3 1 3 1 3 1 3 1 3 1 3 * Weight 1 3 1 3 1 3 1 3 1 3 1 3
* Product 9 + 21 + 7 + 3 + 1 + 12 + 4 + 24 + 7 + 15 + 0 + 0 = 103 * Product 9 + 21 + 7 + 3 + 1 + 12 + 4 + 24 + 7 + 15 + 0 + 0 = 103
* 103 / 10 = 10 remainder 3 * 103 / 10 = 10 remainder 3
* Check digit 10 - 3 = 7 * Check digit 10 - 3 = 7
* => 977-1144875-00-7 ?? <- suplemental number (number of the week, month, etc.) * => 977-1144875-00-7 ?? <- suplemental number (number of the week, month, etc.)
* ^^ 00 for non-daily publications (01=Monday, 02=Tuesday, ...) * ^^ 00 for non-daily publications (01=Monday, 02=Tuesday, ...)
* *
* The hyphenation is always in after the four digits of the ISSN code. * The hyphenation is always in after the four digits of the ISSN code.
* *
...@@ -32,16 +32,16 @@ ...@@ -32,16 +32,16 @@
/* where the digit set begins, and how many of them are in the table */ /* where the digit set begins, and how many of them are in the table */
const unsigned ISSN_index[10][2] = { const unsigned ISSN_index[10][2] = {
{0, 1}, {0, 1},
{0, 1}, {0, 1},
{0, 1}, {0, 1},
{0, 1}, {0, 1},
{0, 1}, {0, 1},
{0, 1}, {0, 1},
{0, 1}, {0, 1},
{0, 1}, {0, 1},
{0, 1}, {0, 1},
{0, 1}, {0, 1},
}; };
const char *ISSN_range[][2] = { const char *ISSN_range[][2] = {
{"0000-000", "9999-999"}, {"0000-000", "9999-999"},
......
/* /*
* ISSN.h * ISSN.h
* PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC) * PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
* *
* No information available for UPC prefixes * No information available for UPC prefixes
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/contrib/isn/UPC.h,v 1.1 2006/09/09 04:07:52 tgl Exp $ * $PostgreSQL: pgsql/contrib/isn/UPC.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
* *
*/ */
/* where the digit set begins, and how many of them are in the table */ /* where the digit set begins, and how many of them are in the table */
const unsigned UPC_index[10][2] = { const unsigned UPC_index[10][2] = {
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
}; };
const char *UPC_range[][2] = { const char *UPC_range[][2] = {
{NULL, NULL} {NULL, NULL}
......
This diff is collapsed.
...@@ -219,7 +219,7 @@ sizebitvec(BITVECP sign) ...@@ -219,7 +219,7 @@ sizebitvec(BITVECP sign)
i; i;
ALOOPBYTE( ALOOPBYTE(
size += number_of_ones[(unsigned char) sign[i]]; size += number_of_ones[(unsigned char) sign[i]];
); );
return size; return size;
} }
...@@ -232,8 +232,8 @@ hemdistsign(BITVECP a, BITVECP b) ...@@ -232,8 +232,8 @@ hemdistsign(BITVECP a, BITVECP b)
dist = 0; dist = 0;
ALOOPBYTE( ALOOPBYTE(
diff = (unsigned char) (a[i] ^ b[i]); diff = (unsigned char) (a[i] ^ b[i]);
dist += number_of_ones[diff]; dist += number_of_ones[diff];
); );
return dist; return dist;
} }
...@@ -270,7 +270,7 @@ typedef struct ...@@ -270,7 +270,7 @@ typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int4 cost;
} SPLITCOST; } SPLITCOST;
static int static int
comparecost(const void *a, const void *b) comparecost(const void *a, const void *b)
...@@ -580,6 +580,6 @@ _ltree_consistent(PG_FUNCTION_ARGS) ...@@ -580,6 +580,6 @@ _ltree_consistent(PG_FUNCTION_ARGS)
/* internal error */ /* internal error */
elog(ERROR, "unrecognized StrategyNumber: %d", strategy); elog(ERROR, "unrecognized StrategyNumber: %d", strategy);
} }
PG_FREE_IF_COPY(query,1); PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(res); PG_RETURN_BOOL(res);
} }
/* /*
* op function for ltree and lquery * op function for ltree and lquery
* Teodor Sigaev <teodor@stack.net> * Teodor Sigaev <teodor@stack.net>
* $PostgreSQL: pgsql/contrib/ltree/lquery_op.c,v 1.10 2006/03/11 04:38:29 momjian Exp $ * $PostgreSQL: pgsql/contrib/ltree/lquery_op.c,v 1.11 2006/10/04 00:29:45 momjian Exp $
*/ */
#include "ltree.h" #include "ltree.h"
...@@ -46,7 +46,7 @@ getlexeme(char *start, char *end, int *len) ...@@ -46,7 +46,7 @@ getlexeme(char *start, char *end, int *len)
} }
bool 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 *endt = t->name + t->len;
char *endq = qn + len; char *endq = qn + len;
......
/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.16 2006/07/11 16:00:44 teodor Exp $ */ /* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.17 2006/10/04 00:29:45 momjian Exp $ */
#ifndef __LTREE_H__ #ifndef __LTREE_H__
#define __LTREE_H__ #define __LTREE_H__
...@@ -163,7 +163,7 @@ bool compare_subnode(ltree_level * t, char *q, int len, ...@@ -163,7 +163,7 @@ bool compare_subnode(ltree_level * t, char *q, int len,
ltree *lca_inner(ltree ** a, int len); ltree *lca_inner(ltree ** a, int len);
#define PG_GETARG_LTREE(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) #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)))) #define PG_GETARG_LTREE_COPY(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
#define PG_GETARG_LQUERY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) #define PG_GETARG_LQUERY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
#define PG_GETARG_LQUERY_COPY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) #define PG_GETARG_LQUERY_COPY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
#define PG_GETARG_LTXTQUERY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) #define PG_GETARG_LTXTQUERY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
......
/* /*
* GiST support for ltree * GiST support for ltree
* Teodor Sigaev <teodor@stack.net> * Teodor Sigaev <teodor@stack.net>
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.18 2006/08/08 15:45:18 teodor Exp $ * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.19 2006/10/04 00:29:45 momjian Exp $
*/ */
#include "ltree.h" #include "ltree.h"
...@@ -457,8 +457,10 @@ gist_isparent(ltree_gist * key, ltree * query) ...@@ -457,8 +457,10 @@ gist_isparent(ltree_gist * key, ltree * query)
} }
static ltree * static ltree *
copy_ltree( ltree *src ) { copy_ltree(ltree * src)
ltree *dst = (ltree*)palloc(src->len); {
ltree *dst = (ltree *) palloc(src->len);
memcpy(dst, src, src->len); memcpy(dst, src, src->len);
return dst; return dst;
} }
...@@ -466,9 +468,9 @@ copy_ltree( ltree *src ) { ...@@ -466,9 +468,9 @@ copy_ltree( ltree *src ) {
static bool static bool
gist_ischild(ltree_gist * key, ltree * query) gist_ischild(ltree_gist * key, ltree * query)
{ {
ltree *left = copy_ltree(LTG_GETLNODE(key)); ltree *left = copy_ltree(LTG_GETLNODE(key));
ltree *right = copy_ltree(LTG_GETRNODE(key)); ltree *right = copy_ltree(LTG_GETRNODE(key));
bool res = true; bool res = true;
if (left->numlevel > query->numlevel) if (left->numlevel > query->numlevel)
left->numlevel = query->numlevel; left->numlevel = query->numlevel;
...@@ -711,6 +713,6 @@ ltree_consistent(PG_FUNCTION_ARGS) ...@@ -711,6 +713,6 @@ ltree_consistent(PG_FUNCTION_ARGS)
elog(ERROR, "unrecognized StrategyNumber: %d", strategy); elog(ERROR, "unrecognized StrategyNumber: %d", strategy);
} }
PG_FREE_IF_COPY(query,1); PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(res); PG_RETURN_BOOL(res);
} }
/* /*
* op function for ltree * op function for ltree
* Teodor Sigaev <teodor@stack.net> * Teodor Sigaev <teodor@stack.net>
* $PostgreSQL: pgsql/contrib/ltree/ltree_op.c,v 1.13 2006/09/20 19:50:21 tgl Exp $ * $PostgreSQL: pgsql/contrib/ltree/ltree_op.c,v 1.14 2006/10/04 00:29:45 momjian Exp $
*/ */
#include "ltree.h" #include "ltree.h"
...@@ -620,8 +620,8 @@ ltreeparentsel(PG_FUNCTION_ARGS) ...@@ -620,8 +620,8 @@ ltreeparentsel(PG_FUNCTION_ARGS)
/* /*
* If the histogram is large enough, see what fraction of it the * If the histogram is large enough, see what fraction of it the
* constant is "<@" to, and assume that's representative of the * constant is "<@" to, and assume that's representative of the
* non-MCV population. Otherwise use the default selectivity for * non-MCV population. Otherwise use the default selectivity for the
* the non-MCV population. * non-MCV population.
*/ */
selec = histogram_selectivity(&vardata, &contproc, selec = histogram_selectivity(&vardata, &contproc,
constval, varonleft, constval, varonleft,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* pg_buffercache_pages.c * pg_buffercache_pages.c
* display some contents of the buffer cache * display some contents of the buffer cache
* *
* $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.8 2006/07/23 03:07:57 tgl Exp $ * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.9 2006/10/04 00:29:45 momjian Exp $
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -74,7 +74,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) ...@@ -74,7 +74,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
{ {
int i; int i;
volatile BufferDesc *bufHdr; volatile BufferDesc *bufHdr;
funcctx = SRF_FIRSTCALL_INIT(); funcctx = SRF_FIRSTCALL_INIT();
...@@ -123,9 +123,9 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) ...@@ -123,9 +123,9 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
/* /*
* To get a consistent picture of the buffer state, we must lock * To get a consistent picture of the buffer state, we must lock all
* all partitions of the buffer map. Needless to say, this is * partitions of the buffer map. Needless to say, this is horrible
* horrible for concurrency... * for concurrency...
*/ */
for (i = 0; i < NUM_BUFFER_PARTITIONS; i++) for (i = 0; i < NUM_BUFFER_PARTITIONS; i++)
LWLockAcquire(FirstBufMappingLock + i, LW_SHARED); LWLockAcquire(FirstBufMappingLock + i, LW_SHARED);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* pg_freespacemap.c * pg_freespacemap.c
* display some contents of the free space relation and page maps. * display some contents of the free space relation and page maps.
* *
* $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.7 2006/09/21 20:31:21 tgl Exp $ * $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.8 2006/10/04 00:29:45 momjian Exp $
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
#include "storage/freespace.h" #include "storage/freespace.h"
#define NUM_FREESPACE_PAGES_ELEM 5 #define NUM_FREESPACE_PAGES_ELEM 5
#define NUM_FREESPACE_RELATIONS_ELEM 7 #define NUM_FREESPACE_RELATIONS_ELEM 7
#if defined(WIN32) || defined(__CYGWIN__) #if defined(WIN32) || defined(__CYGWIN__)
/* Need DLLIMPORT for some things that are not so marked in main headers */ /* Need DLLIMPORT for some things that are not so marked in main headers */
extern DLLIMPORT int MaxFSMPages; extern DLLIMPORT int MaxFSMPages;
extern DLLIMPORT int MaxFSMRelations; extern DLLIMPORT int MaxFSMRelations;
extern DLLIMPORT volatile uint32 InterruptHoldoffCount; extern DLLIMPORT volatile uint32 InterruptHoldoffCount;
#endif #endif
...@@ -35,12 +35,12 @@ Datum pg_freespacemap_relations(PG_FUNCTION_ARGS); ...@@ -35,12 +35,12 @@ Datum pg_freespacemap_relations(PG_FUNCTION_ARGS);
*/ */
typedef struct typedef struct
{ {
Oid reltablespace; Oid reltablespace;
Oid reldatabase; Oid reldatabase;
Oid relfilenode; Oid relfilenode;
BlockNumber relblocknumber; BlockNumber relblocknumber;
Size bytes; Size bytes;
bool isindex; bool isindex;
} FreeSpacePagesRec; } FreeSpacePagesRec;
...@@ -49,14 +49,14 @@ typedef struct ...@@ -49,14 +49,14 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
Oid reltablespace; Oid reltablespace;
Oid reldatabase; Oid reldatabase;
Oid relfilenode; Oid relfilenode;
Size avgrequest; Size avgrequest;
BlockNumber interestingpages; BlockNumber interestingpages;
int storedpages; int storedpages;
int nextpage; int nextpage;
bool isindex; bool isindex;
} FreeSpaceRelationsRec; } FreeSpaceRelationsRec;
...@@ -66,8 +66,8 @@ typedef struct ...@@ -66,8 +66,8 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
TupleDesc tupdesc; TupleDesc tupdesc;
FreeSpacePagesRec *record; FreeSpacePagesRec *record;
} FreeSpacePagesContext; } FreeSpacePagesContext;
...@@ -76,8 +76,8 @@ typedef struct ...@@ -76,8 +76,8 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
TupleDesc tupdesc; TupleDesc tupdesc;
FreeSpaceRelationsRec *record; FreeSpaceRelationsRec *record;
} FreeSpaceRelationsContext; } FreeSpaceRelationsContext;
...@@ -89,21 +89,21 @@ PG_FUNCTION_INFO_V1(pg_freespacemap_pages); ...@@ -89,21 +89,21 @@ PG_FUNCTION_INFO_V1(pg_freespacemap_pages);
Datum Datum
pg_freespacemap_pages(PG_FUNCTION_ARGS) pg_freespacemap_pages(PG_FUNCTION_ARGS)
{ {
FuncCallContext *funcctx; FuncCallContext *funcctx;
Datum result; Datum result;
MemoryContext oldcontext; MemoryContext oldcontext;
FreeSpacePagesContext *fctx; /* User function context. */ FreeSpacePagesContext *fctx; /* User function context. */
TupleDesc tupledesc; TupleDesc tupledesc;
HeapTuple tuple; HeapTuple tuple;
FSMHeader *FreeSpaceMap; /* FSM main structure. */ FSMHeader *FreeSpaceMap; /* FSM main structure. */
FSMRelation *fsmrel; /* Individual relation. */ FSMRelation *fsmrel; /* Individual relation. */
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
{ {
int i; int i;
int numPages; /* Max possible no. of pages in map. */ int numPages; /* Max possible no. of pages in map. */
int nPages; /* Mapped pages for a relation. */ int nPages; /* Mapped pages for a relation. */
/* /*
* Get the free space map data structure. * Get the free space map data structure.
*/ */
...@@ -138,8 +138,8 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS) ...@@ -138,8 +138,8 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
fctx->tupdesc = BlessTupleDesc(tupledesc); fctx->tupdesc = BlessTupleDesc(tupledesc);
/* /*
* Allocate numPages worth of FreeSpacePagesRec records, this is * Allocate numPages worth of FreeSpacePagesRec records, this is an
* an upper bound. * upper bound.
*/ */
fctx->record = (FreeSpacePagesRec *) palloc(sizeof(FreeSpacePagesRec) * numPages); fctx->record = (FreeSpacePagesRec *) palloc(sizeof(FreeSpacePagesRec) * numPages);
...@@ -147,16 +147,16 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS) ...@@ -147,16 +147,16 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
/* /*
* Lock free space map and scan though all the relations. * Lock free space map and scan though all the relations. For each
* For each relation, gets all its mapped pages. * relation, gets all its mapped pages.
*/ */
LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE); LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE);
i = 0; i = 0;
for (fsmrel = FreeSpaceMap->usageList; fsmrel; fsmrel = fsmrel->nextUsage) for (fsmrel = FreeSpaceMap->usageList; fsmrel; fsmrel = fsmrel->nextUsage)
{ {
if (fsmrel->isIndex) if (fsmrel->isIndex)
{ {
/* Index relation. */ /* Index relation. */
IndexFSMPageData *page; IndexFSMPageData *page;
...@@ -169,9 +169,9 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS) ...@@ -169,9 +169,9 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
fctx->record[i].reltablespace = fsmrel->key.spcNode; fctx->record[i].reltablespace = fsmrel->key.spcNode;
fctx->record[i].reldatabase = fsmrel->key.dbNode; fctx->record[i].reldatabase = fsmrel->key.dbNode;
fctx->record[i].relfilenode = fsmrel->key.relNode; fctx->record[i].relfilenode = fsmrel->key.relNode;
fctx->record[i].relblocknumber = IndexFSMPageGetPageNum(page); fctx->record[i].relblocknumber = IndexFSMPageGetPageNum(page);
fctx->record[i].bytes = 0; fctx->record[i].bytes = 0;
fctx->record[i].isindex = true; fctx->record[i].isindex = true;
page++; page++;
i++; i++;
...@@ -191,9 +191,9 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS) ...@@ -191,9 +191,9 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
fctx->record[i].reldatabase = fsmrel->key.dbNode; fctx->record[i].reldatabase = fsmrel->key.dbNode;
fctx->record[i].relfilenode = fsmrel->key.relNode; fctx->record[i].relfilenode = fsmrel->key.relNode;
fctx->record[i].relblocknumber = FSMPageGetPageNum(page); fctx->record[i].relblocknumber = FSMPageGetPageNum(page);
fctx->record[i].bytes = FSMPageGetSpace(page); fctx->record[i].bytes = FSMPageGetSpace(page);
fctx->record[i].isindex = false; fctx->record[i].isindex = false;
page++; page++;
i++; i++;
} }
...@@ -216,7 +216,7 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS) ...@@ -216,7 +216,7 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
if (funcctx->call_cntr < funcctx->max_calls) if (funcctx->call_cntr < funcctx->max_calls)
{ {
int i = funcctx->call_cntr; int i = funcctx->call_cntr;
FreeSpacePagesRec *record = &fctx->record[i]; FreeSpacePagesRec *record = &fctx->record[i];
Datum values[NUM_FREESPACE_PAGES_ELEM]; Datum values[NUM_FREESPACE_PAGES_ELEM];
bool nulls[NUM_FREESPACE_PAGES_ELEM]; bool nulls[NUM_FREESPACE_PAGES_ELEM];
...@@ -261,20 +261,20 @@ PG_FUNCTION_INFO_V1(pg_freespacemap_relations); ...@@ -261,20 +261,20 @@ PG_FUNCTION_INFO_V1(pg_freespacemap_relations);
Datum Datum
pg_freespacemap_relations(PG_FUNCTION_ARGS) pg_freespacemap_relations(PG_FUNCTION_ARGS)
{ {
FuncCallContext *funcctx; FuncCallContext *funcctx;
Datum result; Datum result;
MemoryContext oldcontext; MemoryContext oldcontext;
FreeSpaceRelationsContext *fctx; /* User function context. */ FreeSpaceRelationsContext *fctx; /* User function context. */
TupleDesc tupledesc; TupleDesc tupledesc;
HeapTuple tuple; HeapTuple tuple;
FSMHeader *FreeSpaceMap; /* FSM main structure. */ FSMHeader *FreeSpaceMap; /* FSM main structure. */
FSMRelation *fsmrel; /* Individual relation. */ FSMRelation *fsmrel; /* Individual relation. */
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
{ {
int i; int i;
int numRelations; /* Max no. of Relations in map. */ int numRelations; /* Max no. of Relations in map. */
/* /*
* Get the free space map data structure. * Get the free space map data structure.
*/ */
...@@ -313,8 +313,8 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS) ...@@ -313,8 +313,8 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS)
fctx->tupdesc = BlessTupleDesc(tupledesc); fctx->tupdesc = BlessTupleDesc(tupledesc);
/* /*
* Allocate numRelations worth of FreeSpaceRelationsRec records, * Allocate numRelations worth of FreeSpaceRelationsRec records, this
* this is also an upper bound. * is also an upper bound.
*/ */
fctx->record = (FreeSpaceRelationsRec *) palloc(sizeof(FreeSpaceRelationsRec) * numRelations); fctx->record = (FreeSpaceRelationsRec *) palloc(sizeof(FreeSpaceRelationsRec) * numRelations);
...@@ -328,12 +328,12 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS) ...@@ -328,12 +328,12 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS)
i = 0; i = 0;
for (fsmrel = FreeSpaceMap->usageList; fsmrel; fsmrel = fsmrel->nextUsage) for (fsmrel = FreeSpaceMap->usageList; fsmrel; fsmrel = fsmrel->nextUsage)
{ {
fctx->record[i].reltablespace = fsmrel->key.spcNode; fctx->record[i].reltablespace = fsmrel->key.spcNode;
fctx->record[i].reldatabase = fsmrel->key.dbNode; fctx->record[i].reldatabase = fsmrel->key.dbNode;
fctx->record[i].relfilenode = fsmrel->key.relNode; fctx->record[i].relfilenode = fsmrel->key.relNode;
fctx->record[i].avgrequest = (int64)fsmrel->avgRequest; fctx->record[i].avgrequest = (int64) fsmrel->avgRequest;
fctx->record[i].interestingpages = fsmrel->interestingPages; fctx->record[i].interestingpages = fsmrel->interestingPages;
fctx->record[i].storedpages = fsmrel->storedPages; fctx->record[i].storedpages = fsmrel->storedPages;
fctx->record[i].nextpage = fsmrel->nextPage; fctx->record[i].nextpage = fsmrel->nextPage;
...@@ -358,7 +358,7 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS) ...@@ -358,7 +358,7 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS)
if (funcctx->call_cntr < funcctx->max_calls) if (funcctx->call_cntr < funcctx->max_calls)
{ {
int i = funcctx->call_cntr; int i = funcctx->call_cntr;
FreeSpaceRelationsRec *record = &fctx->record[i]; FreeSpaceRelationsRec *record = &fctx->record[i];
Datum values[NUM_FREESPACE_RELATIONS_ELEM]; Datum values[NUM_FREESPACE_RELATIONS_ELEM];
bool nulls[NUM_FREESPACE_RELATIONS_ELEM]; bool nulls[NUM_FREESPACE_RELATIONS_ELEM];
...@@ -368,6 +368,7 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS) ...@@ -368,6 +368,7 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS)
nulls[1] = false; nulls[1] = false;
values[2] = ObjectIdGetDatum(record->relfilenode); values[2] = ObjectIdGetDatum(record->relfilenode);
nulls[2] = false; nulls[2] = false;
/* /*
* avgrequest isn't meaningful for an index * avgrequest isn't meaningful for an index
*/ */
......
...@@ -307,7 +307,7 @@ sizebitvec(BITVECP sign) ...@@ -307,7 +307,7 @@ sizebitvec(BITVECP sign)
i; i;
LOOPBYTE( LOOPBYTE(
size += number_of_ones[(unsigned char) sign[i]]; size += number_of_ones[(unsigned char) sign[i]];
); );
return size; return size;
} }
...@@ -320,8 +320,8 @@ hemdistsign(BITVECP a, BITVECP b) ...@@ -320,8 +320,8 @@ hemdistsign(BITVECP a, BITVECP b)
dist = 0; dist = 0;
LOOPBYTE( LOOPBYTE(
diff = (unsigned char) (a[i] ^ b[i]); diff = (unsigned char) (a[i] ^ b[i]);
dist += number_of_ones[diff]; dist += number_of_ones[diff];
); );
return dist; return dist;
} }
...@@ -393,7 +393,7 @@ typedef struct ...@@ -393,7 +393,7 @@ typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int4 cost;
} SPLITCOST; } SPLITCOST;
static int static int
comparecost(const void *a, const void *b) comparecost(const void *a, const void *b)
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Written by Solar Designer and placed in the public domain. * Written by Solar Designer and placed in the public domain.
* See crypt_blowfish.c for more information. * See crypt_blowfish.c for more information.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-gensalt.c,v 1.9 2006/07/13 04:15:24 neilc Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-gensalt.c,v 1.10 2006/10/04 00:29:46 momjian Exp $
* *
* This file contains salt generation functions for the traditional and * This file contains salt generation functions for the traditional and
* other common crypt(3) algorithms, except for bcrypt which is defined * other common crypt(3) algorithms, except for bcrypt which is defined
...@@ -64,9 +64,9 @@ _crypt_gensalt_extended_rn(unsigned long count, ...@@ -64,9 +64,9 @@ _crypt_gensalt_extended_rn(unsigned long count,
output[2] = _crypt_itoa64[(count >> 6) & 0x3f]; output[2] = _crypt_itoa64[(count >> 6) & 0x3f];
output[3] = _crypt_itoa64[(count >> 12) & 0x3f]; output[3] = _crypt_itoa64[(count >> 12) & 0x3f];
output[4] = _crypt_itoa64[(count >> 18) & 0x3f]; output[4] = _crypt_itoa64[(count >> 18) & 0x3f];
value = (unsigned long)(unsigned char) input[0] | value = (unsigned long) (unsigned char) input[0] |
((unsigned long)(unsigned char) input[1] << 8) | ((unsigned long) (unsigned char) input[1] << 8) |
((unsigned long)(unsigned char) input[2] << 16); ((unsigned long) (unsigned char) input[2] << 16);
output[5] = _crypt_itoa64[value & 0x3f]; output[5] = _crypt_itoa64[value & 0x3f];
output[6] = _crypt_itoa64[(value >> 6) & 0x3f]; output[6] = _crypt_itoa64[(value >> 6) & 0x3f];
output[7] = _crypt_itoa64[(value >> 12) & 0x3f]; output[7] = _crypt_itoa64[(value >> 12) & 0x3f];
...@@ -92,9 +92,9 @@ _crypt_gensalt_md5_rn(unsigned long count, ...@@ -92,9 +92,9 @@ _crypt_gensalt_md5_rn(unsigned long count,
output[0] = '$'; output[0] = '$';
output[1] = '1'; output[1] = '1';
output[2] = '$'; output[2] = '$';
value = (unsigned long)(unsigned char) input[0] | value = (unsigned long) (unsigned char) input[0] |
((unsigned long)(unsigned char) input[1] << 8) | ((unsigned long) (unsigned char) input[1] << 8) |
((unsigned long)(unsigned char) input[2] << 16); ((unsigned long) (unsigned char) input[2] << 16);
output[3] = _crypt_itoa64[value & 0x3f]; output[3] = _crypt_itoa64[value & 0x3f];
output[4] = _crypt_itoa64[(value >> 6) & 0x3f]; output[4] = _crypt_itoa64[(value >> 6) & 0x3f];
output[5] = _crypt_itoa64[(value >> 12) & 0x3f]; output[5] = _crypt_itoa64[(value >> 12) & 0x3f];
...@@ -103,9 +103,9 @@ _crypt_gensalt_md5_rn(unsigned long count, ...@@ -103,9 +103,9 @@ _crypt_gensalt_md5_rn(unsigned long count,
if (size >= 6 && output_size >= 3 + 4 + 4 + 1) if (size >= 6 && output_size >= 3 + 4 + 4 + 1)
{ {
value = (unsigned long)(unsigned char) input[3] | value = (unsigned long) (unsigned char) input[3] |
((unsigned long)(unsigned char) input[4] << 8) | ((unsigned long) (unsigned char) input[4] << 8) |
((unsigned long)(unsigned char) input[5] << 16); ((unsigned long) (unsigned char) input[5] << 16);
output[7] = _crypt_itoa64[value & 0x3f]; output[7] = _crypt_itoa64[value & 0x3f];
output[8] = _crypt_itoa64[(value >> 6) & 0x3f]; output[8] = _crypt_itoa64[(value >> 6) & 0x3f];
output[9] = _crypt_itoa64[(value >> 12) & 0x3f]; output[9] = _crypt_itoa64[(value >> 12) & 0x3f];
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $ * $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.7 2006/07/13 04:15:24 neilc Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.8 2006/10/04 00:29:46 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -24,7 +24,7 @@ static const char _crypt_a64[] = ...@@ -24,7 +24,7 @@ static const char _crypt_a64[] =
static void static void
_crypt_to64(char *s, unsigned long v, int n) _crypt_to64(char *s, unsigned long v, int n)
{ {
while (--n >= 0) while (--n >= 0)
{ {
*s++ = _crypt_a64[v & 0x3f]; *s++ = _crypt_a64[v & 0x3f];
v >>= 6; v >>= 6;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment