mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Replace int2/int4 in C code with int16/int32
The latter was already the dominant use, and it's preferable because in C the convention is that intXX means XX bits. Therefore, allowing mixed use of int2, int4, int8, int16, int32 is obviously confusing. Remove the typedefs for int2 and int4 for now. They don't seem to be widely used outside of the PostgreSQL source tree, and the few uses can probably be cleaned up by the time this ships.
This commit is contained in:
@ -159,8 +159,8 @@ typedef struct
|
||||
bool needfree; /* need to pfree the value? */
|
||||
} Pairs;
|
||||
|
||||
extern int hstoreUniquePairs(Pairs *a, int4 l, int4 *buflen);
|
||||
extern HStore *hstorePairs(Pairs *pairs, int4 pcount, int4 buflen);
|
||||
extern int hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen);
|
||||
extern HStore *hstorePairs(Pairs *pairs, int32 pcount, int32 buflen);
|
||||
|
||||
extern size_t hstoreCheckKeyLen(size_t len);
|
||||
extern size_t hstoreCheckValLen(size_t len);
|
||||
|
@ -40,7 +40,7 @@ typedef char *BITVECP;
|
||||
typedef struct
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
int4 flag;
|
||||
int32 flag;
|
||||
char data[1];
|
||||
} GISTTYPE;
|
||||
|
||||
@ -48,7 +48,7 @@ typedef struct
|
||||
|
||||
#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
|
||||
|
||||
#define GTHDRSIZE (VARHDRSZ + sizeof(int4))
|
||||
#define GTHDRSIZE (VARHDRSZ + sizeof(int32))
|
||||
#define CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
|
||||
|
||||
#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
|
||||
@ -143,7 +143,7 @@ ghstore_compress(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else if (!ISALLTRUE(DatumGetPointer(entry->key)))
|
||||
{
|
||||
int4 i;
|
||||
int32 i;
|
||||
GISTTYPE *res;
|
||||
BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
|
||||
|
||||
@ -192,7 +192,7 @@ ghstore_same(PG_FUNCTION_ARGS)
|
||||
*result = false;
|
||||
else
|
||||
{
|
||||
int4 i;
|
||||
int32 i;
|
||||
BITVECP sa = GETSIGN(a),
|
||||
sb = GETSIGN(b);
|
||||
|
||||
@ -209,10 +209,10 @@ ghstore_same(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
static int4
|
||||
static int32
|
||||
sizebitvec(BITVECP sign)
|
||||
{
|
||||
int4 size = 0,
|
||||
int32 size = 0,
|
||||
i;
|
||||
|
||||
LOOPBYTE
|
||||
@ -253,10 +253,10 @@ hemdist(GISTTYPE *a, GISTTYPE *b)
|
||||
return hemdistsign(GETSIGN(a), GETSIGN(b));
|
||||
}
|
||||
|
||||
static int4
|
||||
static int32
|
||||
unionkey(BITVECP sbase, GISTTYPE *add)
|
||||
{
|
||||
int4 i;
|
||||
int32 i;
|
||||
BITVECP sadd = GETSIGN(add);
|
||||
|
||||
if (ISALLTRUE(add))
|
||||
@ -270,12 +270,12 @@ Datum
|
||||
ghstore_union(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
|
||||
int4 len = entryvec->n;
|
||||
int32 len = entryvec->n;
|
||||
|
||||
int *size = (int *) PG_GETARG_POINTER(1);
|
||||
BITVEC base;
|
||||
int4 i;
|
||||
int4 flag = 0;
|
||||
int32 i;
|
||||
int32 flag = 0;
|
||||
GISTTYPE *result;
|
||||
|
||||
MemSet((void *) base, 0, sizeof(BITVEC));
|
||||
@ -316,7 +316,7 @@ ghstore_penalty(PG_FUNCTION_ARGS)
|
||||
typedef struct
|
||||
{
|
||||
OffsetNumber pos;
|
||||
int4 cost;
|
||||
int32 cost;
|
||||
} SPLITCOST;
|
||||
|
||||
static int
|
||||
@ -339,11 +339,11 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
|
||||
*datum_r;
|
||||
BITVECP union_l,
|
||||
union_r;
|
||||
int4 size_alpha,
|
||||
int32 size_alpha,
|
||||
size_beta;
|
||||
int4 size_waste,
|
||||
int32 size_waste,
|
||||
waste = -1;
|
||||
int4 nbytes;
|
||||
int32 nbytes;
|
||||
OffsetNumber seed_1 = 0,
|
||||
seed_2 = 0;
|
||||
OffsetNumber *left,
|
||||
|
@ -36,7 +36,7 @@ typedef struct
|
||||
do { \
|
||||
if ( state->cur - state->word + 1 >= state->wordlen ) \
|
||||
{ \
|
||||
int4 clen = state->cur - state->word; \
|
||||
int32 clen = state->cur - state->word; \
|
||||
state->wordlen *= 2; \
|
||||
state->word = (char*)repalloc( (void*)state->word, state->wordlen ); \
|
||||
state->cur = state->word + clen; \
|
||||
@ -74,7 +74,7 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped)
|
||||
}
|
||||
else if (*(state->ptr) == '=' && !ignoreeq)
|
||||
{
|
||||
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int4) (state->ptr - state->begin));
|
||||
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
|
||||
}
|
||||
else if (*(state->ptr) == '\\')
|
||||
{
|
||||
@ -215,7 +215,7 @@ parse_hstore(HSParser *state)
|
||||
}
|
||||
else if (!isspace((unsigned char) *(state->ptr)))
|
||||
{
|
||||
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int4) (state->ptr - state->begin));
|
||||
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
|
||||
}
|
||||
}
|
||||
else if (st == WGT)
|
||||
@ -230,7 +230,7 @@ parse_hstore(HSParser *state)
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int4) (state->ptr - state->begin));
|
||||
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
|
||||
}
|
||||
}
|
||||
else if (st == WVAL)
|
||||
@ -263,7 +263,7 @@ parse_hstore(HSParser *state)
|
||||
}
|
||||
else if (!isspace((unsigned char) *(state->ptr)))
|
||||
{
|
||||
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int4) (state->ptr - state->begin));
|
||||
elog(ERROR, "Syntax error near '%c' at position %d", *(state->ptr), (int32) (state->ptr - state->begin));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -304,7 +304,7 @@ comparePairs(const void *a, const void *b)
|
||||
* and (b) who knows whether they might be needed by some caller.
|
||||
*/
|
||||
int
|
||||
hstoreUniquePairs(Pairs *a, int4 l, int4 *buflen)
|
||||
hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen)
|
||||
{
|
||||
Pairs *ptr,
|
||||
*res;
|
||||
@ -367,14 +367,14 @@ hstoreCheckValLen(size_t len)
|
||||
|
||||
|
||||
HStore *
|
||||
hstorePairs(Pairs *pairs, int4 pcount, int4 buflen)
|
||||
hstorePairs(Pairs *pairs, int32 pcount, int32 buflen)
|
||||
{
|
||||
HStore *out;
|
||||
HEntry *entry;
|
||||
char *ptr;
|
||||
char *buf;
|
||||
int4 len;
|
||||
int4 i;
|
||||
int32 len;
|
||||
int32 i;
|
||||
|
||||
len = CALCDATASIZE(pcount, buflen);
|
||||
out = palloc(len);
|
||||
@ -402,7 +402,7 @@ Datum
|
||||
hstore_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
HSParser state;
|
||||
int4 buflen;
|
||||
int32 buflen;
|
||||
HStore *out;
|
||||
|
||||
state.begin = PG_GETARG_CSTRING(0);
|
||||
@ -422,11 +422,11 @@ Datum hstore_recv(PG_FUNCTION_ARGS);
|
||||
Datum
|
||||
hstore_recv(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int4 buflen;
|
||||
int32 buflen;
|
||||
HStore *out;
|
||||
Pairs *pairs;
|
||||
int4 i;
|
||||
int4 pcount;
|
||||
int32 i;
|
||||
int32 pcount;
|
||||
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
||||
|
||||
pcount = pq_getmsgint(buf, 4);
|
||||
@ -518,7 +518,7 @@ Datum hstore_from_arrays(PG_FUNCTION_ARGS);
|
||||
Datum
|
||||
hstore_from_arrays(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int4 buflen;
|
||||
int32 buflen;
|
||||
HStore *out;
|
||||
Pairs *pairs;
|
||||
Datum *key_datums;
|
||||
@ -632,7 +632,7 @@ hstore_from_array(PG_FUNCTION_ARGS)
|
||||
ArrayType *in_array = PG_GETARG_ARRAYTYPE_P(0);
|
||||
int ndims = ARR_NDIM(in_array);
|
||||
int count;
|
||||
int4 buflen;
|
||||
int32 buflen;
|
||||
HStore *out;
|
||||
Pairs *pairs;
|
||||
Datum *in_datums;
|
||||
@ -737,7 +737,7 @@ Datum
|
||||
hstore_from_record(PG_FUNCTION_ARGS)
|
||||
{
|
||||
HeapTupleHeader rec;
|
||||
int4 buflen;
|
||||
int32 buflen;
|
||||
HStore *out;
|
||||
Pairs *pairs;
|
||||
Oid tupType;
|
||||
|
Reference in New Issue
Block a user