mirror of
https://github.com/postgres/postgres.git
synced 2025-12-24 06:01:07 +03:00
pgindent run for 8.3.
This commit is contained in:
@@ -50,7 +50,7 @@ typedef struct
|
||||
int comparePairs(const void *a, const void *b);
|
||||
int uniquePairs(Pairs * a, int4 l, int4 *buflen);
|
||||
|
||||
#define HStoreContainsStrategyNumber 7
|
||||
#define HStoreExistsStrategyNumber 9
|
||||
#define HStoreContainsStrategyNumber 7
|
||||
#define HStoreExistsStrategyNumber 9
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#include "hstore.h"
|
||||
|
||||
#include "access/gin.h"
|
||||
#include "access/gin.h"
|
||||
|
||||
#define KEYFLAG 'K'
|
||||
#define VALFLAG 'V'
|
||||
#define NULLFLAG 'N'
|
||||
#define KEYFLAG 'K'
|
||||
#define VALFLAG 'V'
|
||||
#define NULLFLAG 'N'
|
||||
|
||||
PG_FUNCTION_INFO_V1(gin_extract_hstore);
|
||||
Datum gin_extract_hstore(PG_FUNCTION_ARGS);
|
||||
Datum gin_extract_hstore(PG_FUNCTION_ARGS);
|
||||
|
||||
static text*
|
||||
makeitem( char *str, int len )
|
||||
static text *
|
||||
makeitem(char *str, int len)
|
||||
{
|
||||
text *item;
|
||||
text *item;
|
||||
|
||||
item = (text*)palloc( VARHDRSZ + len + 1 );
|
||||
item = (text *) palloc(VARHDRSZ + len + 1);
|
||||
SET_VARSIZE(item, VARHDRSZ + len + 1);
|
||||
|
||||
if ( str && len > 0 )
|
||||
memcpy( VARDATA(item)+1, str, len );
|
||||
if (str && len > 0)
|
||||
memcpy(VARDATA(item) + 1, str, len);
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -26,37 +26,37 @@ makeitem( char *str, int len )
|
||||
Datum
|
||||
gin_extract_hstore(PG_FUNCTION_ARGS)
|
||||
{
|
||||
HStore *hs = PG_GETARG_HS(0);
|
||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
||||
Datum *entries = NULL;
|
||||
HStore *hs = PG_GETARG_HS(0);
|
||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
||||
Datum *entries = NULL;
|
||||
|
||||
*nentries = 2*hs->size;
|
||||
*nentries = 2 * hs->size;
|
||||
|
||||
if ( hs->size > 0 )
|
||||
if (hs->size > 0)
|
||||
{
|
||||
HEntry *ptr = ARRPTR(hs);
|
||||
char *words = STRPTR(hs);
|
||||
int i=0;
|
||||
HEntry *ptr = ARRPTR(hs);
|
||||
char *words = STRPTR(hs);
|
||||
int i = 0;
|
||||
|
||||
entries = (Datum*)palloc( sizeof(Datum) * 2 * hs->size );
|
||||
entries = (Datum *) palloc(sizeof(Datum) * 2 * hs->size);
|
||||
|
||||
while (ptr - ARRPTR(hs) < hs->size)
|
||||
{
|
||||
text *item;
|
||||
text *item;
|
||||
|
||||
item = makeitem( words + ptr->pos, ptr->keylen );
|
||||
item = makeitem(words + ptr->pos, ptr->keylen);
|
||||
*VARDATA(item) = KEYFLAG;
|
||||
entries[i++] = PointerGetDatum(item);
|
||||
|
||||
if ( ptr->valisnull )
|
||||
if (ptr->valisnull)
|
||||
{
|
||||
item = makeitem( NULL, 0 );
|
||||
item = makeitem(NULL, 0);
|
||||
*VARDATA(item) = NULLFLAG;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
item = makeitem( words + ptr->pos + ptr->keylen, ptr->vallen );
|
||||
item = makeitem(words + ptr->pos + ptr->keylen, ptr->vallen);
|
||||
*VARDATA(item) = VALFLAG;
|
||||
}
|
||||
entries[i++] = PointerGetDatum(item);
|
||||
@@ -65,36 +65,37 @@ gin_extract_hstore(PG_FUNCTION_ARGS)
|
||||
}
|
||||
}
|
||||
|
||||
PG_FREE_IF_COPY(hs,0);
|
||||
PG_FREE_IF_COPY(hs, 0);
|
||||
PG_RETURN_POINTER(entries);
|
||||
}
|
||||
|
||||
PG_FUNCTION_INFO_V1(gin_extract_hstore_query);
|
||||
Datum gin_extract_hstore_query(PG_FUNCTION_ARGS);
|
||||
Datum gin_extract_hstore_query(PG_FUNCTION_ARGS);
|
||||
|
||||
Datum
|
||||
gin_extract_hstore_query(PG_FUNCTION_ARGS)
|
||||
{
|
||||
StrategyNumber strategy = PG_GETARG_UINT16(2);
|
||||
|
||||
if ( strategy == HStoreContainsStrategyNumber )
|
||||
if (strategy == HStoreContainsStrategyNumber)
|
||||
{
|
||||
PG_RETURN_DATUM( DirectFunctionCall2(
|
||||
gin_extract_hstore,
|
||||
PG_GETARG_DATUM(0),
|
||||
PG_GETARG_DATUM(1)
|
||||
));
|
||||
PG_RETURN_DATUM(DirectFunctionCall2(
|
||||
gin_extract_hstore,
|
||||
PG_GETARG_DATUM(0),
|
||||
PG_GETARG_DATUM(1)
|
||||
));
|
||||
}
|
||||
else if ( strategy == HStoreExistsStrategyNumber )
|
||||
else if (strategy == HStoreExistsStrategyNumber)
|
||||
{
|
||||
text *item, *q = PG_GETARG_TEXT_P(0);
|
||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
||||
Datum *entries = NULL;
|
||||
text *item,
|
||||
*q = PG_GETARG_TEXT_P(0);
|
||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
||||
Datum *entries = NULL;
|
||||
|
||||
*nentries = 1;
|
||||
entries = (Datum*)palloc( sizeof(Datum) );
|
||||
entries = (Datum *) palloc(sizeof(Datum));
|
||||
|
||||
item = makeitem( VARDATA(q), VARSIZE(q)-VARHDRSZ );
|
||||
item = makeitem(VARDATA(q), VARSIZE(q) - VARHDRSZ);
|
||||
*VARDATA(item) = KEYFLAG;
|
||||
entries[0] = PointerGetDatum(item);
|
||||
|
||||
@@ -107,29 +108,28 @@ gin_extract_hstore_query(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
PG_FUNCTION_INFO_V1(gin_consistent_hstore);
|
||||
Datum gin_consistent_hstore(PG_FUNCTION_ARGS);
|
||||
Datum gin_consistent_hstore(PG_FUNCTION_ARGS);
|
||||
|
||||
Datum
|
||||
gin_consistent_hstore(PG_FUNCTION_ARGS)
|
||||
{
|
||||
StrategyNumber strategy = PG_GETARG_UINT16(1);
|
||||
bool res = true;
|
||||
bool res = true;
|
||||
|
||||
if ( strategy == HStoreContainsStrategyNumber )
|
||||
if (strategy == HStoreContainsStrategyNumber)
|
||||
{
|
||||
bool *check = (bool *) PG_GETARG_POINTER(0);
|
||||
HStore *query = PG_GETARG_HS(2);
|
||||
int i;
|
||||
bool *check = (bool *) PG_GETARG_POINTER(0);
|
||||
HStore *query = PG_GETARG_HS(2);
|
||||
int i;
|
||||
|
||||
for(i=0;res && i<2*query->size;i++)
|
||||
if ( check[i] == false )
|
||||
for (i = 0; res && i < 2 * query->size; i++)
|
||||
if (check[i] == false)
|
||||
res = false;
|
||||
}
|
||||
else if ( strategy == HStoreExistsStrategyNumber )
|
||||
else if (strategy == HStoreExistsStrategyNumber)
|
||||
res = true;
|
||||
else
|
||||
elog(ERROR, "Unsupported strategy number: %d", strategy);
|
||||
|
||||
PG_RETURN_BOOL(res);
|
||||
}
|
||||
|
||||
|
||||
@@ -275,13 +275,13 @@ tconvert(PG_FUNCTION_ARGS)
|
||||
int len;
|
||||
HStore *out;
|
||||
|
||||
if ( PG_ARGISNULL(0) )
|
||||
if (PG_ARGISNULL(0))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
key = PG_GETARG_TEXT_P(0);
|
||||
|
||||
if ( PG_ARGISNULL(1) )
|
||||
len = CALCDATASIZE(1, VARSIZE(key) );
|
||||
if (PG_ARGISNULL(1))
|
||||
len = CALCDATASIZE(1, VARSIZE(key));
|
||||
else
|
||||
{
|
||||
val = PG_GETARG_TEXT_P(1);
|
||||
@@ -292,7 +292,7 @@ tconvert(PG_FUNCTION_ARGS)
|
||||
out->size = 1;
|
||||
|
||||
ARRPTR(out)->keylen = VARSIZE(key) - VARHDRSZ;
|
||||
if ( PG_ARGISNULL(1) )
|
||||
if (PG_ARGISNULL(1))
|
||||
{
|
||||
ARRPTR(out)->vallen = 0;
|
||||
ARRPTR(out)->valisnull = true;
|
||||
@@ -537,18 +537,18 @@ hs_contains(PG_FUNCTION_ARGS)
|
||||
|
||||
if (entry)
|
||||
{
|
||||
if ( te->valisnull || entry->valisnull )
|
||||
if (te->valisnull || entry->valisnull)
|
||||
{
|
||||
if ( !(te->valisnull && entry->valisnull) )
|
||||
if (!(te->valisnull && entry->valisnull))
|
||||
res = false;
|
||||
}
|
||||
else if ( te->vallen != entry->vallen ||
|
||||
strncmp(
|
||||
vv + entry->pos + entry->keylen,
|
||||
tv + te->pos + te->keylen,
|
||||
te->vallen)
|
||||
)
|
||||
res = false;
|
||||
else if (te->vallen != entry->vallen ||
|
||||
strncmp(
|
||||
vv + entry->pos + entry->keylen,
|
||||
tv + te->pos + te->keylen,
|
||||
te->vallen)
|
||||
)
|
||||
res = false;
|
||||
}
|
||||
else
|
||||
res = false;
|
||||
|
||||
Reference in New Issue
Block a user