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:
Peter Eisentraut 2012-06-25 01:51:46 +03:00
parent 7eb8c78514
commit b8b2e3b2de
75 changed files with 411 additions and 404 deletions

View File

@ -77,7 +77,7 @@ gbt_int2key_cmp(const void *a, const void *b)
static float8 static float8
gbt_int2_dist(const void *a, const void *b) gbt_int2_dist(const void *a, const void *b)
{ {
return GET_FLOAT_DISTANCE(int2, a, b); return GET_FLOAT_DISTANCE(int16, a, b);
} }
@ -100,10 +100,10 @@ Datum int2_dist(PG_FUNCTION_ARGS);
Datum Datum
int2_dist(PG_FUNCTION_ARGS) int2_dist(PG_FUNCTION_ARGS)
{ {
int2 a = PG_GETARG_INT16(0); int16 a = PG_GETARG_INT16(0);
int2 b = PG_GETARG_INT16(1); int16 b = PG_GETARG_INT16(1);
int2 r; int16 r;
int2 ra; int16 ra;
r = a - b; r = a - b;
ra = Abs(r); ra = Abs(r);

View File

@ -78,7 +78,7 @@ gbt_int4key_cmp(const void *a, const void *b)
static float8 static float8
gbt_int4_dist(const void *a, const void *b) gbt_int4_dist(const void *a, const void *b)
{ {
return GET_FLOAT_DISTANCE(int4, a, b); return GET_FLOAT_DISTANCE(int32, a, b);
} }
@ -101,10 +101,10 @@ Datum int4_dist(PG_FUNCTION_ARGS);
Datum Datum
int4_dist(PG_FUNCTION_ARGS) int4_dist(PG_FUNCTION_ARGS)
{ {
int4 a = PG_GETARG_INT32(0); int32 a = PG_GETARG_INT32(0);
int4 b = PG_GETARG_INT32(1); int32 b = PG_GETARG_INT32(1);
int4 r; int32 r;
int4 ra; int32 ra;
r = a - b; r = a - b;
ra = Abs(r); ra = Abs(r);

View File

@ -266,7 +266,7 @@ cube_subset(PG_FUNCTION_ARGS)
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR), (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
errmsg("cannot work with arrays containing NULLs"))); errmsg("cannot work with arrays containing NULLs")));
dx = (int4 *) ARR_DATA_PTR(idx); dx = (int32 *) ARR_DATA_PTR(idx);
dim = ARRNELEMS(idx); dim = ARRNELEMS(idx);
size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim; size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim;
@ -1360,7 +1360,7 @@ cube_enlarge(PG_FUNCTION_ARGS)
{ {
NDBOX *a = PG_GETARG_NDBOX(0); NDBOX *a = PG_GETARG_NDBOX(0);
double r = PG_GETARG_FLOAT8(1); double r = PG_GETARG_FLOAT8(1);
int4 n = PG_GETARG_INT32(2); int32 n = PG_GETARG_INT32(2);
NDBOX *result; NDBOX *result;
int dim = 0; int dim = 0;
int size; int size;

View File

@ -159,8 +159,8 @@ typedef struct
bool needfree; /* need to pfree the value? */ bool needfree; /* need to pfree the value? */
} Pairs; } Pairs;
extern int hstoreUniquePairs(Pairs *a, int4 l, int4 *buflen); extern int hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen);
extern HStore *hstorePairs(Pairs *pairs, int4 pcount, int4 buflen); extern HStore *hstorePairs(Pairs *pairs, int32 pcount, int32 buflen);
extern size_t hstoreCheckKeyLen(size_t len); extern size_t hstoreCheckKeyLen(size_t len);
extern size_t hstoreCheckValLen(size_t len); extern size_t hstoreCheckValLen(size_t len);

View File

@ -40,7 +40,7 @@ typedef char *BITVECP;
typedef struct typedef struct
{ {
int32 vl_len_; /* varlena header (do not touch directly!) */ int32 vl_len_; /* varlena header (do not touch directly!) */
int4 flag; int32 flag;
char data[1]; char data[1];
} GISTTYPE; } GISTTYPE;
@ -48,7 +48,7 @@ typedef struct
#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE ) #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 CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) ) #define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
@ -143,7 +143,7 @@ ghstore_compress(PG_FUNCTION_ARGS)
} }
else if (!ISALLTRUE(DatumGetPointer(entry->key))) else if (!ISALLTRUE(DatumGetPointer(entry->key)))
{ {
int4 i; int32 i;
GISTTYPE *res; GISTTYPE *res;
BITVECP sign = GETSIGN(DatumGetPointer(entry->key)); BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
@ -192,7 +192,7 @@ ghstore_same(PG_FUNCTION_ARGS)
*result = false; *result = false;
else else
{ {
int4 i; int32 i;
BITVECP sa = GETSIGN(a), BITVECP sa = GETSIGN(a),
sb = GETSIGN(b); sb = GETSIGN(b);
@ -209,10 +209,10 @@ ghstore_same(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
static int4 static int32
sizebitvec(BITVECP sign) sizebitvec(BITVECP sign)
{ {
int4 size = 0, int32 size = 0,
i; i;
LOOPBYTE LOOPBYTE
@ -253,10 +253,10 @@ hemdist(GISTTYPE *a, GISTTYPE *b)
return hemdistsign(GETSIGN(a), GETSIGN(b)); return hemdistsign(GETSIGN(a), GETSIGN(b));
} }
static int4 static int32
unionkey(BITVECP sbase, GISTTYPE *add) unionkey(BITVECP sbase, GISTTYPE *add)
{ {
int4 i; int32 i;
BITVECP sadd = GETSIGN(add); BITVECP sadd = GETSIGN(add);
if (ISALLTRUE(add)) if (ISALLTRUE(add))
@ -270,12 +270,12 @@ Datum
ghstore_union(PG_FUNCTION_ARGS) ghstore_union(PG_FUNCTION_ARGS)
{ {
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int4 len = entryvec->n; int32 len = entryvec->n;
int *size = (int *) PG_GETARG_POINTER(1); int *size = (int *) PG_GETARG_POINTER(1);
BITVEC base; BITVEC base;
int4 i; int32 i;
int4 flag = 0; int32 flag = 0;
GISTTYPE *result; GISTTYPE *result;
MemSet((void *) base, 0, sizeof(BITVEC)); MemSet((void *) base, 0, sizeof(BITVEC));
@ -316,7 +316,7 @@ ghstore_penalty(PG_FUNCTION_ARGS)
typedef struct typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int32 cost;
} SPLITCOST; } SPLITCOST;
static int static int
@ -339,11 +339,11 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
*datum_r; *datum_r;
BITVECP union_l, BITVECP union_l,
union_r; union_r;
int4 size_alpha, int32 size_alpha,
size_beta; size_beta;
int4 size_waste, int32 size_waste,
waste = -1; waste = -1;
int4 nbytes; int32 nbytes;
OffsetNumber seed_1 = 0, OffsetNumber seed_1 = 0,
seed_2 = 0; seed_2 = 0;
OffsetNumber *left, OffsetNumber *left,

View File

@ -36,7 +36,7 @@ typedef struct
do { \ do { \
if ( state->cur - state->word + 1 >= state->wordlen ) \ if ( state->cur - state->word + 1 >= state->wordlen ) \
{ \ { \
int4 clen = state->cur - state->word; \ int32 clen = state->cur - state->word; \
state->wordlen *= 2; \ state->wordlen *= 2; \
state->word = (char*)repalloc( (void*)state->word, state->wordlen ); \ state->word = (char*)repalloc( (void*)state->word, state->wordlen ); \
state->cur = state->word + clen; \ state->cur = state->word + clen; \
@ -74,7 +74,7 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped)
} }
else if (*(state->ptr) == '=' && !ignoreeq) 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) == '\\') else if (*(state->ptr) == '\\')
{ {
@ -215,7 +215,7 @@ parse_hstore(HSParser *state)
} }
else if (!isspace((unsigned char) *(state->ptr))) 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) else if (st == WGT)
@ -230,7 +230,7 @@ parse_hstore(HSParser *state)
} }
else 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) else if (st == WVAL)
@ -263,7 +263,7 @@ parse_hstore(HSParser *state)
} }
else if (!isspace((unsigned char) *(state->ptr))) 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 else
@ -304,7 +304,7 @@ comparePairs(const void *a, const void *b)
* and (b) who knows whether they might be needed by some caller. * and (b) who knows whether they might be needed by some caller.
*/ */
int int
hstoreUniquePairs(Pairs *a, int4 l, int4 *buflen) hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen)
{ {
Pairs *ptr, Pairs *ptr,
*res; *res;
@ -367,14 +367,14 @@ hstoreCheckValLen(size_t len)
HStore * HStore *
hstorePairs(Pairs *pairs, int4 pcount, int4 buflen) hstorePairs(Pairs *pairs, int32 pcount, int32 buflen)
{ {
HStore *out; HStore *out;
HEntry *entry; HEntry *entry;
char *ptr; char *ptr;
char *buf; char *buf;
int4 len; int32 len;
int4 i; int32 i;
len = CALCDATASIZE(pcount, buflen); len = CALCDATASIZE(pcount, buflen);
out = palloc(len); out = palloc(len);
@ -402,7 +402,7 @@ Datum
hstore_in(PG_FUNCTION_ARGS) hstore_in(PG_FUNCTION_ARGS)
{ {
HSParser state; HSParser state;
int4 buflen; int32 buflen;
HStore *out; HStore *out;
state.begin = PG_GETARG_CSTRING(0); state.begin = PG_GETARG_CSTRING(0);
@ -422,11 +422,11 @@ Datum hstore_recv(PG_FUNCTION_ARGS);
Datum Datum
hstore_recv(PG_FUNCTION_ARGS) hstore_recv(PG_FUNCTION_ARGS)
{ {
int4 buflen; int32 buflen;
HStore *out; HStore *out;
Pairs *pairs; Pairs *pairs;
int4 i; int32 i;
int4 pcount; int32 pcount;
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
pcount = pq_getmsgint(buf, 4); pcount = pq_getmsgint(buf, 4);
@ -518,7 +518,7 @@ Datum hstore_from_arrays(PG_FUNCTION_ARGS);
Datum Datum
hstore_from_arrays(PG_FUNCTION_ARGS) hstore_from_arrays(PG_FUNCTION_ARGS)
{ {
int4 buflen; int32 buflen;
HStore *out; HStore *out;
Pairs *pairs; Pairs *pairs;
Datum *key_datums; Datum *key_datums;
@ -632,7 +632,7 @@ hstore_from_array(PG_FUNCTION_ARGS)
ArrayType *in_array = PG_GETARG_ARRAYTYPE_P(0); ArrayType *in_array = PG_GETARG_ARRAYTYPE_P(0);
int ndims = ARR_NDIM(in_array); int ndims = ARR_NDIM(in_array);
int count; int count;
int4 buflen; int32 buflen;
HStore *out; HStore *out;
Pairs *pairs; Pairs *pairs;
Datum *in_datums; Datum *in_datums;
@ -737,7 +737,7 @@ Datum
hstore_from_record(PG_FUNCTION_ARGS) hstore_from_record(PG_FUNCTION_ARGS)
{ {
HeapTupleHeader rec; HeapTupleHeader rec;
int4 buflen; int32 buflen;
HStore *out; HStore *out;
Pairs *pairs; Pairs *pairs;
Oid tupType; Oid tupType;

View File

@ -10,7 +10,7 @@
#define MAXNUMRANGE 100 #define MAXNUMRANGE 100
/* useful macros for accessing int4 arrays */ /* useful macros for accessing int4 arrays */
#define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) ) #define ARRPTR(x) ( (int32 *) ARR_DATA_PTR(x) )
#define ARRNELEMS(x) ArrayGetNItems(ARR_NDIM(x), ARR_DIMS(x)) #define ARRNELEMS(x) ArrayGetNItems(ARR_NDIM(x), ARR_DIMS(x))
/* reject arrays we can't handle; to wit, those containing nulls */ /* reject arrays we can't handle; to wit, those containing nulls */
@ -71,7 +71,7 @@ typedef char *BITVECP;
typedef struct typedef struct
{ {
int32 vl_len_; /* varlena header (do not touch directly!) */ int32 vl_len_; /* varlena header (do not touch directly!) */
int4 flag; int32 flag;
char data[1]; char data[1];
} GISTTYPE; } GISTTYPE;
@ -79,7 +79,7 @@ typedef struct
#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE ) #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 CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) ) #define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
@ -93,7 +93,7 @@ typedef void (*formfloat) (ArrayType *, float *);
/* /*
* useful functions * useful functions
*/ */
bool isort(int4 *a, int len); bool isort(int32 *a, int len);
ArrayType *new_intArrayType(int num); ArrayType *new_intArrayType(int num);
ArrayType *copy_intArrayType(ArrayType *a); ArrayType *copy_intArrayType(ArrayType *a);
ArrayType *resize_intArrayType(ArrayType *a, int num); ArrayType *resize_intArrayType(ArrayType *a, int num);
@ -123,15 +123,15 @@ void gensign(BITVEC sign, int *a, int len);
*/ */
typedef struct ITEM typedef struct ITEM
{ {
int2 type; int16 type;
int2 left; int16 left;
int4 val; int32 val;
} ITEM; } ITEM;
typedef struct QUERYTYPE typedef struct QUERYTYPE
{ {
int32 vl_len_; /* varlena header (do not touch directly!) */ int32 vl_len_; /* varlena header (do not touch directly!) */
int4 size; /* number of ITEMs */ int32 size; /* number of ITEMs */
ITEM items[1]; /* variable length array */ ITEM items[1]; /* variable length array */
} QUERYTYPE; } QUERYTYPE;
@ -167,7 +167,7 @@ int compDESC(const void *a, const void *b);
do { \ do { \
int _nelems_ = ARRNELEMS(a); \ int _nelems_ = ARRNELEMS(a); \
if (_nelems_ > 1) \ if (_nelems_ > 1) \
qsort((void*) ARRPTR(a), _nelems_, sizeof(int4), \ qsort((void*) ARRPTR(a), _nelems_, sizeof(int32), \
(direction) ? compASC : compDESC ); \ (direction) ? compASC : compDESC ); \
} while(0) } while(0)

View File

@ -34,27 +34,27 @@ Datum querytree(PG_FUNCTION_ARGS);
*/ */
typedef struct NODE typedef struct NODE
{ {
int4 type; int32 type;
int4 val; int32 val;
struct NODE *next; struct NODE *next;
} NODE; } NODE;
typedef struct typedef struct
{ {
char *buf; char *buf;
int4 state; int32 state;
int4 count; int32 count;
/* reverse polish notation in list (for temporary usage) */ /* reverse polish notation in list (for temporary usage) */
NODE *str; NODE *str;
/* number in str */ /* number in str */
int4 num; int32 num;
} WORKSTATE; } WORKSTATE;
/* /*
* get token from query string * get token from query string
*/ */
static int4 static int32
gettoken(WORKSTATE *state, int4 *val) gettoken(WORKSTATE *state, int32 *val)
{ {
char nnn[16]; char nnn[16];
int innn; int innn;
@ -79,7 +79,7 @@ gettoken(WORKSTATE *state, int4 *val)
else if (*(state->buf) == '!') else if (*(state->buf) == '!')
{ {
(state->buf)++; (state->buf)++;
*val = (int4) '!'; *val = (int32) '!';
return OPR; return OPR;
} }
else if (*(state->buf) == '(') else if (*(state->buf) == '(')
@ -103,7 +103,7 @@ gettoken(WORKSTATE *state, int4 *val)
nnn[innn] = '\0'; nnn[innn] = '\0';
errno = 0; errno = 0;
lval = strtol(nnn, NULL, 0); lval = strtol(nnn, NULL, 0);
*val = (int4) lval; *val = (int32) lval;
if (errno != 0 || (long) *val != lval) if (errno != 0 || (long) *val != lval)
return ERR; return ERR;
state->state = WAITOPERATOR; state->state = WAITOPERATOR;
@ -115,7 +115,7 @@ gettoken(WORKSTATE *state, int4 *val)
if (*(state->buf) == '&' || *(state->buf) == '|') if (*(state->buf) == '&' || *(state->buf) == '|')
{ {
state->state = WAITOPERAND; state->state = WAITOPERAND;
*val = (int4) *(state->buf); *val = (int32) *(state->buf);
(state->buf)++; (state->buf)++;
return OPR; return OPR;
} }
@ -143,7 +143,7 @@ gettoken(WORKSTATE *state, int4 *val)
* push new one in polish notation reverse view * push new one in polish notation reverse view
*/ */
static void static void
pushquery(WORKSTATE *state, int4 type, int4 val) pushquery(WORKSTATE *state, int32 type, int32 val)
{ {
NODE *tmp = (NODE *) palloc(sizeof(NODE)); NODE *tmp = (NODE *) palloc(sizeof(NODE));
@ -159,13 +159,13 @@ pushquery(WORKSTATE *state, int4 type, int4 val)
/* /*
* make polish notation of query * make polish notation of query
*/ */
static int4 static int32
makepol(WORKSTATE *state) makepol(WORKSTATE *state)
{ {
int4 val, int32 val,
type; type;
int4 stack[STACKDEPTH]; int32 stack[STACKDEPTH];
int4 lenstack = 0; int32 lenstack = 0;
/* since this function recurses, it could be driven to stack overflow */ /* since this function recurses, it could be driven to stack overflow */
check_stack_depth(); check_stack_depth();
@ -176,15 +176,15 @@ makepol(WORKSTATE *state)
{ {
case VAL: case VAL:
pushquery(state, type, val); pushquery(state, type, val);
while (lenstack && (stack[lenstack - 1] == (int4) '&' || while (lenstack && (stack[lenstack - 1] == (int32) '&' ||
stack[lenstack - 1] == (int4) '!')) stack[lenstack - 1] == (int32) '!'))
{ {
lenstack--; lenstack--;
pushquery(state, OPR, stack[lenstack]); pushquery(state, OPR, stack[lenstack]);
} }
break; break;
case OPR: case OPR:
if (lenstack && val == (int4) '|') if (lenstack && val == (int32) '|')
pushquery(state, OPR, val); pushquery(state, OPR, val);
else else
{ {
@ -199,8 +199,8 @@ makepol(WORKSTATE *state)
case OPEN: case OPEN:
if (makepol(state) == ERR) if (makepol(state) == ERR)
return ERR; return ERR;
while (lenstack && (stack[lenstack - 1] == (int4) '&' || while (lenstack && (stack[lenstack - 1] == (int32) '&' ||
stack[lenstack - 1] == (int4) '!')) stack[lenstack - 1] == (int32) '!'))
{ {
lenstack--; lenstack--;
pushquery(state, OPR, stack[lenstack]); pushquery(state, OPR, stack[lenstack]);
@ -234,8 +234,8 @@ makepol(WORKSTATE *state)
typedef struct typedef struct
{ {
int4 *arrb; int32 *arrb;
int4 *arre; int32 *arre;
} CHKVAL; } CHKVAL;
/* /*
@ -244,9 +244,9 @@ typedef struct
static bool static bool
checkcondition_arr(void *checkval, ITEM *item) checkcondition_arr(void *checkval, ITEM *item)
{ {
int4 *StopLow = ((CHKVAL *) checkval)->arrb; int32 *StopLow = ((CHKVAL *) checkval)->arrb;
int4 *StopHigh = ((CHKVAL *) checkval)->arre; int32 *StopHigh = ((CHKVAL *) checkval)->arre;
int4 *StopMiddle; int32 *StopMiddle;
/* Loop invariant: StopLow <= val < StopHigh */ /* Loop invariant: StopLow <= val < StopHigh */
@ -281,13 +281,13 @@ execute(ITEM *curitem, void *checkval, bool calcnot,
if (curitem->type == VAL) if (curitem->type == VAL)
return (*chkcond) (checkval, curitem); return (*chkcond) (checkval, curitem);
else if (curitem->val == (int4) '!') else if (curitem->val == (int32) '!')
{ {
return (calcnot) ? return (calcnot) ?
((execute(curitem - 1, checkval, calcnot, chkcond)) ? false : true) ((execute(curitem - 1, checkval, calcnot, chkcond)) ? false : true)
: true; : true;
} }
else if (curitem->val == (int4) '&') else if (curitem->val == (int32) '&')
{ {
if (execute(curitem + curitem->left, checkval, calcnot, chkcond)) if (execute(curitem + curitem->left, checkval, calcnot, chkcond))
return execute(curitem - 1, checkval, calcnot, chkcond); return execute(curitem - 1, checkval, calcnot, chkcond);
@ -379,7 +379,7 @@ contains_required_value(ITEM *curitem)
if (curitem->type == VAL) if (curitem->type == VAL)
return true; return true;
else if (curitem->val == (int4) '!') else if (curitem->val == (int32) '!')
{ {
/* /*
* Assume anything under a NOT is non-required. For some cases with * Assume anything under a NOT is non-required. For some cases with
@ -388,7 +388,7 @@ contains_required_value(ITEM *curitem)
*/ */
return false; return false;
} }
else if (curitem->val == (int4) '&') else if (curitem->val == (int32) '&')
{ {
/* If either side has a required value, we're good */ /* If either side has a required value, we're good */
if (contains_required_value(curitem + curitem->left)) if (contains_required_value(curitem + curitem->left))
@ -449,7 +449,7 @@ boolop(PG_FUNCTION_ARGS)
} }
static void static void
findoprnd(ITEM *ptr, int4 *pos) findoprnd(ITEM *ptr, int32 *pos)
{ {
#ifdef BS_DEBUG #ifdef BS_DEBUG
elog(DEBUG3, (ptr[*pos].type == OPR) ? elog(DEBUG3, (ptr[*pos].type == OPR) ?
@ -460,7 +460,7 @@ findoprnd(ITEM *ptr, int4 *pos)
ptr[*pos].left = 0; ptr[*pos].left = 0;
(*pos)--; (*pos)--;
} }
else if (ptr[*pos].val == (int4) '!') else if (ptr[*pos].val == (int32) '!')
{ {
ptr[*pos].left = -1; ptr[*pos].left = -1;
(*pos)--; (*pos)--;
@ -469,7 +469,7 @@ findoprnd(ITEM *ptr, int4 *pos)
else else
{ {
ITEM *curitem = &ptr[*pos]; ITEM *curitem = &ptr[*pos];
int4 tmp = *pos; int32 tmp = *pos;
(*pos)--; (*pos)--;
findoprnd(ptr, pos); findoprnd(ptr, pos);
@ -487,12 +487,12 @@ bqarr_in(PG_FUNCTION_ARGS)
{ {
char *buf = (char *) PG_GETARG_POINTER(0); char *buf = (char *) PG_GETARG_POINTER(0);
WORKSTATE state; WORKSTATE state;
int4 i; int32 i;
QUERYTYPE *query; QUERYTYPE *query;
int4 commonlen; int32 commonlen;
ITEM *ptr; ITEM *ptr;
NODE *tmp; NODE *tmp;
int4 pos = 0; int32 pos = 0;
#ifdef BS_DEBUG #ifdef BS_DEBUG
StringInfoData pbuf; StringInfoData pbuf;
@ -553,11 +553,11 @@ typedef struct
ITEM *curpol; ITEM *curpol;
char *buf; char *buf;
char *cur; char *cur;
int4 buflen; int32 buflen;
} INFIX; } INFIX;
#define RESIZEBUF(inf,addsize) while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) { \ #define RESIZEBUF(inf,addsize) while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) { \
int4 len = inf->cur - inf->buf; \ int32 len = inf->cur - inf->buf; \
inf->buflen *= 2; \ inf->buflen *= 2; \
inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \
inf->cur = inf->buf + len; \ inf->cur = inf->buf + len; \
@ -573,7 +573,7 @@ infix(INFIX *in, bool first)
in->cur = strchr(in->cur, '\0'); in->cur = strchr(in->cur, '\0');
in->curpol--; in->curpol--;
} }
else if (in->curpol->val == (int4) '!') else if (in->curpol->val == (int32) '!')
{ {
bool isopr = false; bool isopr = false;
@ -599,11 +599,11 @@ infix(INFIX *in, bool first)
} }
else else
{ {
int4 op = in->curpol->val; int32 op = in->curpol->val;
INFIX nrm; INFIX nrm;
in->curpol--; in->curpol--;
if (op == (int4) '|' && !first) if (op == (int32) '|' && !first)
{ {
RESIZEBUF(in, 2); RESIZEBUF(in, 2);
sprintf(in->cur, "( "); sprintf(in->cur, "( ");
@ -627,7 +627,7 @@ infix(INFIX *in, bool first)
in->cur = strchr(in->cur, '\0'); in->cur = strchr(in->cur, '\0');
pfree(nrm.buf); pfree(nrm.buf);
if (op == (int4) '|' && !first) if (op == (int32) '|' && !first)
{ {
RESIZEBUF(in, 2); RESIZEBUF(in, 2);
sprintf(in->cur, " )"); sprintf(in->cur, " )");

View File

@ -65,7 +65,7 @@ ginint4_queryextract(PG_FUNCTION_ARGS)
*nentries = ARRNELEMS(query); *nentries = ARRNELEMS(query);
if (*nentries > 0) if (*nentries > 0)
{ {
int4 *arr; int32 *arr;
int32 i; int32 i;
res = (Datum *) palloc(sizeof(Datum) * (*nentries)); res = (Datum *) palloc(sizeof(Datum) * (*nentries));

View File

@ -106,7 +106,7 @@ g_int_union(PG_FUNCTION_ARGS)
{ {
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1); int *size = (int *) PG_GETARG_POINTER(1);
int4 i, int32 i,
*ptr; *ptr;
ArrayType *res; ArrayType *res;
int totlen = 0; int totlen = 0;
@ -128,7 +128,7 @@ g_int_union(PG_FUNCTION_ARGS)
int nel; int nel;
nel = ARRNELEMS(ent); nel = ARRNELEMS(ent);
memcpy(ptr, ARRPTR(ent), nel * sizeof(int4)); memcpy(ptr, ARRPTR(ent), nel * sizeof(int32));
ptr += nel; ptr += nel;
} }
@ -317,8 +317,8 @@ g_int_same(PG_FUNCTION_ARGS)
ArrayType *a = PG_GETARG_ARRAYTYPE_P(0); ArrayType *a = PG_GETARG_ARRAYTYPE_P(0);
ArrayType *b = PG_GETARG_ARRAYTYPE_P(1); ArrayType *b = PG_GETARG_ARRAYTYPE_P(1);
bool *result = (bool *) PG_GETARG_POINTER(2); bool *result = (bool *) PG_GETARG_POINTER(2);
int4 n = ARRNELEMS(a); int32 n = ARRNELEMS(a);
int4 *da, int32 *da,
*db; *db;
CHECKARRVALID(a); CHECKARRVALID(a);

View File

@ -186,11 +186,11 @@ rt__int_size(ArrayType *a, float *size)
/* Sort the given data (len >= 2). Return true if any duplicates found */ /* Sort the given data (len >= 2). Return true if any duplicates found */
bool bool
isort(int4 *a, int len) isort(int32 *a, int len)
{ {
int4 cur, int32 cur,
prev; prev;
int4 *pcur, int32 *pcur,
*pprev, *pprev,
*end; *end;
bool r = FALSE; bool r = FALSE;
@ -268,7 +268,7 @@ copy_intArrayType(ArrayType *a)
int n = ARRNELEMS(a); int n = ARRNELEMS(a);
r = new_intArrayType(n); r = new_intArrayType(n);
memcpy(ARRPTR(r), ARRPTR(a), n * sizeof(int4)); memcpy(ARRPTR(r), ARRPTR(a), n * sizeof(int32));
return r; return r;
} }
@ -389,15 +389,15 @@ int_to_intset(int32 n)
int int
compASC(const void *a, const void *b) compASC(const void *a, const void *b)
{ {
if (*(const int4 *) a == *(const int4 *) b) if (*(const int32 *) a == *(const int32 *) b)
return 0; return 0;
return (*(const int4 *) a > *(const int4 *) b) ? 1 : -1; return (*(const int32 *) a > *(const int32 *) b) ? 1 : -1;
} }
int int
compDESC(const void *a, const void *b) compDESC(const void *a, const void *b)
{ {
if (*(const int4 *) a == *(const int4 *) b) if (*(const int32 *) a == *(const int32 *) b)
return 0; return 0;
return (*(const int4 *) a < *(const int4 *) b) ? 1 : -1; return (*(const int32 *) a < *(const int32 *) b) ? 1 : -1;
} }

View File

@ -81,7 +81,7 @@ static bool
_intbig_overlap(GISTTYPE *a, ArrayType *b) _intbig_overlap(GISTTYPE *a, ArrayType *b)
{ {
int num = ARRNELEMS(b); int num = ARRNELEMS(b);
int4 *ptr = ARRPTR(b); int32 *ptr = ARRPTR(b);
CHECKARRVALID(b); CHECKARRVALID(b);
@ -99,7 +99,7 @@ static bool
_intbig_contains(GISTTYPE *a, ArrayType *b) _intbig_contains(GISTTYPE *a, ArrayType *b)
{ {
int num = ARRNELEMS(b); int num = ARRNELEMS(b);
int4 *ptr = ARRPTR(b); int32 *ptr = ARRPTR(b);
CHECKARRVALID(b); CHECKARRVALID(b);
@ -128,7 +128,7 @@ g_intbig_same(PG_FUNCTION_ARGS)
*result = false; *result = false;
else else
{ {
int4 i; int32 i;
BITVECP sa = GETSIGN(a), BITVECP sa = GETSIGN(a),
sb = GETSIGN(b); sb = GETSIGN(b);
@ -154,7 +154,7 @@ g_intbig_compress(PG_FUNCTION_ARGS)
{ {
GISTENTRY *retval; GISTENTRY *retval;
ArrayType *in = DatumGetArrayTypeP(entry->key); ArrayType *in = DatumGetArrayTypeP(entry->key);
int4 *ptr; int32 *ptr;
int num; int num;
GISTTYPE *res = (GISTTYPE *) palloc0(CALCGTSIZE(0)); GISTTYPE *res = (GISTTYPE *) palloc0(CALCGTSIZE(0));
@ -216,10 +216,10 @@ g_intbig_compress(PG_FUNCTION_ARGS)
} }
static int4 static int32
sizebitvec(BITVECP sign) sizebitvec(BITVECP sign)
{ {
int4 size = 0, int32 size = 0,
i; i;
LOOPBYTE LOOPBYTE
@ -264,10 +264,10 @@ g_intbig_decompress(PG_FUNCTION_ARGS)
PG_RETURN_DATUM(PG_GETARG_DATUM(0)); PG_RETURN_DATUM(PG_GETARG_DATUM(0));
} }
static int4 static int32
unionkey(BITVECP sbase, GISTTYPE *add) unionkey(BITVECP sbase, GISTTYPE *add)
{ {
int4 i; int32 i;
BITVECP sadd = GETSIGN(add); BITVECP sadd = GETSIGN(add);
if (ISALLTRUE(add)) if (ISALLTRUE(add))
@ -283,9 +283,9 @@ g_intbig_union(PG_FUNCTION_ARGS)
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1); int *size = (int *) PG_GETARG_POINTER(1);
BITVEC base; BITVEC base;
int4 i, int32 i,
len; len;
int4 flag = 0; int32 flag = 0;
GISTTYPE *result; GISTTYPE *result;
MemSet((void *) base, 0, sizeof(BITVEC)); MemSet((void *) base, 0, sizeof(BITVEC));
@ -326,7 +326,7 @@ g_intbig_penalty(PG_FUNCTION_ARGS)
typedef struct typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int32 cost;
} SPLITCOST; } SPLITCOST;
static int static int
@ -347,11 +347,11 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
*datum_r; *datum_r;
BITVECP union_l, BITVECP union_l,
union_r; union_r;
int4 size_alpha, int32 size_alpha,
size_beta; size_beta;
int4 size_waste, int32 size_waste,
waste = -1; waste = -1;
int4 nbytes; int32 nbytes;
OffsetNumber seed_1 = 0, OffsetNumber seed_1 = 0,
seed_2 = 0; seed_2 = 0;
OffsetNumber *left, OffsetNumber *left,
@ -538,7 +538,7 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
{ {
int i, int i,
num = ARRNELEMS(query); num = ARRNELEMS(query);
int4 *ptr = ARRPTR(query); int32 *ptr = ARRPTR(query);
BITVEC qp; BITVEC qp;
BITVECP dq, BITVECP dq,
de; de;
@ -577,7 +577,7 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
{ {
int i, int i,
num = ARRNELEMS(query); num = ARRNELEMS(query);
int4 *ptr = ARRPTR(query); int32 *ptr = ARRPTR(query);
BITVEC qp; BITVEC qp;
BITVECP dq, BITVECP dq,
de; de;

View File

@ -83,7 +83,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
{ /* ltree */ { /* ltree */
ltree_gist *key; ltree_gist *key;
ArrayType *val = DatumGetArrayTypeP(entry->key); ArrayType *val = DatumGetArrayTypeP(entry->key);
int4 len = LTG_HDRSIZE + ASIGLEN; int32 len = LTG_HDRSIZE + ASIGLEN;
int num = ArrayGetNItems(ARR_NDIM(val), ARR_DIMS(val)); int num = ArrayGetNItems(ARR_NDIM(val), ARR_DIMS(val));
ltree *item = (ltree *) ARR_DATA_PTR(val); ltree *item = (ltree *) ARR_DATA_PTR(val);
@ -115,7 +115,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
} }
else if (!LTG_ISALLTRUE(entry->key)) else if (!LTG_ISALLTRUE(entry->key))
{ {
int4 i, int32 i,
len; len;
ltree_gist *key; ltree_gist *key;
@ -154,7 +154,7 @@ _ltree_same(PG_FUNCTION_ARGS)
*result = false; *result = false;
else else
{ {
int4 i; int32 i;
BITVECP sa = LTG_SIGN(a), BITVECP sa = LTG_SIGN(a),
sb = LTG_SIGN(b); sb = LTG_SIGN(b);
@ -171,10 +171,10 @@ _ltree_same(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
static int4 static int32
unionkey(BITVECP sbase, ltree_gist *add) unionkey(BITVECP sbase, ltree_gist *add)
{ {
int4 i; int32 i;
BITVECP sadd = LTG_SIGN(add); BITVECP sadd = LTG_SIGN(add);
if (LTG_ISALLTRUE(add)) if (LTG_ISALLTRUE(add))
@ -191,9 +191,9 @@ _ltree_union(PG_FUNCTION_ARGS)
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1); int *size = (int *) PG_GETARG_POINTER(1);
ABITVEC base; ABITVEC base;
int4 i, int32 i,
len; len;
int4 flag = 0; int32 flag = 0;
ltree_gist *result; ltree_gist *result;
MemSet((void *) base, 0, sizeof(ABITVEC)); MemSet((void *) base, 0, sizeof(ABITVEC));
@ -217,10 +217,10 @@ _ltree_union(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
static int4 static int32
sizebitvec(BITVECP sign) sizebitvec(BITVECP sign)
{ {
int4 size = 0, int32 size = 0,
i; i;
ALOOPBYTE ALOOPBYTE
@ -274,7 +274,7 @@ _ltree_penalty(PG_FUNCTION_ARGS)
typedef struct typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int32 cost;
} SPLITCOST; } SPLITCOST;
static int static int
@ -294,11 +294,11 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
*datum_r; *datum_r;
BITVECP union_l, BITVECP union_l,
union_r; union_r;
int4 size_alpha, int32 size_alpha,
size_beta; size_beta;
int4 size_waste, int32 size_waste,
waste = -1; waste = -1;
int4 nbytes; int32 nbytes;
OffsetNumber seed_1 = 0, OffsetNumber seed_1 = 0,
seed_2 = 0; seed_2 = 0;
OffsetNumber *left, OffsetNumber *left,

View File

@ -30,7 +30,7 @@ typedef struct
typedef struct typedef struct
{ {
int4 val; int32 val;
uint16 len; uint16 len;
uint8 flag; uint8 flag;
char name[1]; char name[1];
@ -89,9 +89,9 @@ typedef struct
*/ */
typedef struct ITEM typedef struct ITEM
{ {
int2 type; int16 type;
int2 left; int16 left;
int4 val; int32 val;
uint8 flag; uint8 flag;
/* user-friendly value */ /* user-friendly value */
uint8 length; uint8 length;
@ -105,11 +105,11 @@ typedef struct ITEM
typedef struct typedef struct
{ {
int32 vl_len_; /* varlena header (do not touch directly!) */ int32 vl_len_; /* varlena header (do not touch directly!) */
int4 size; int32 size;
char data[1]; char data[1];
} ltxtquery; } ltxtquery;
#define HDRSIZEQT MAXALIGN(VARHDRSZ + sizeof(int4)) #define HDRSIZEQT MAXALIGN(VARHDRSZ + sizeof(int32))
#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) ) #define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) )
#define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT )
#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((ltxtquery*)x)->size * sizeof(ITEM) ) #define GETOPERAND(x) ( (char*)GETQUERY(x) + ((ltxtquery*)x)->size * sizeof(ITEM) )
@ -173,7 +173,7 @@ int ltree_strncasecmp(const char *a, const char *b, size_t s);
#define BITBYTE 8 #define BITBYTE 8
#define SIGLENINT 2 #define SIGLENINT 2
#define SIGLEN ( sizeof(int4)*SIGLENINT ) #define SIGLEN ( sizeof(int32)*SIGLENINT )
#define SIGLENBIT (SIGLEN*BITBYTE) #define SIGLENBIT (SIGLEN*BITBYTE)
typedef unsigned char BITVEC[SIGLEN]; typedef unsigned char BITVEC[SIGLEN];
typedef unsigned char *BITVECP; typedef unsigned char *BITVECP;
@ -229,7 +229,7 @@ typedef struct
/* GiST support for ltree[] */ /* GiST support for ltree[] */
#define ASIGLENINT (7) #define ASIGLENINT (7)
#define ASIGLEN (sizeof(int4)*ASIGLENINT) #define ASIGLEN (sizeof(int32)*ASIGLENINT)
#define ASIGLENBIT (ASIGLEN*BITBYTE) #define ASIGLENBIT (ASIGLEN*BITBYTE)
typedef unsigned char ABITVEC[ASIGLEN]; typedef unsigned char ABITVEC[ASIGLEN];

View File

@ -70,7 +70,7 @@ ltree_compress(PG_FUNCTION_ARGS)
{ /* ltree */ { /* ltree */
ltree_gist *key; ltree_gist *key;
ltree *val = (ltree *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); ltree *val = (ltree *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
int4 len = LTG_HDRSIZE + VARSIZE(val); int32 len = LTG_HDRSIZE + VARSIZE(val);
key = (ltree_gist *) palloc(len); key = (ltree_gist *) palloc(len);
SET_VARSIZE(key, len); SET_VARSIZE(key, len);
@ -118,7 +118,7 @@ ltree_same(PG_FUNCTION_ARGS)
*result = (ISEQ(LTG_NODE(a), LTG_NODE(b))) ? true : false; *result = (ISEQ(LTG_NODE(a), LTG_NODE(b))) ? true : false;
else else
{ {
int4 i; int32 i;
BITVECP sa = LTG_SIGN(a), BITVECP sa = LTG_SIGN(a),
sb = LTG_SIGN(b); sb = LTG_SIGN(b);
@ -169,7 +169,7 @@ ltree_union(PG_FUNCTION_ARGS)
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1); int *size = (int *) PG_GETARG_POINTER(1);
BITVEC base; BITVEC base;
int4 i, int32 i,
j; j;
ltree_gist *result, ltree_gist *result,
*cur; *cur;
@ -253,7 +253,7 @@ ltree_penalty(PG_FUNCTION_ARGS)
ltree_gist *origval = (ltree_gist *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); ltree_gist *origval = (ltree_gist *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
ltree_gist *newval = (ltree_gist *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); ltree_gist *newval = (ltree_gist *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
float *penalty = (float *) PG_GETARG_POINTER(2); float *penalty = (float *) PG_GETARG_POINTER(2);
int4 cmpr, int32 cmpr,
cmpl; cmpl;
cmpl = ltree_compare(LTG_GETLNODE(origval), LTG_GETLNODE(newval)); cmpl = ltree_compare(LTG_GETLNODE(origval), LTG_GETLNODE(newval));
@ -287,7 +287,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1); GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
OffsetNumber j; OffsetNumber j;
int4 i; int32 i;
RIX *array; RIX *array;
OffsetNumber maxoff; OffsetNumber maxoff;
int nbytes; int nbytes;
@ -441,7 +441,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
static bool static bool
gist_isparent(ltree_gist *key, ltree *query) gist_isparent(ltree_gist *key, ltree *query)
{ {
int4 numlevel = query->numlevel; int32 numlevel = query->numlevel;
int i; int i;
for (i = query->numlevel; i >= 0; i--) for (i = query->numlevel; i >= 0; i--)

View File

@ -200,7 +200,7 @@ ltree_risparent(PG_FUNCTION_ARGS)
static ltree * static ltree *
inner_subltree(ltree *t, int4 startpos, int4 endpos) inner_subltree(ltree *t, int32 startpos, int32 endpos)
{ {
char *start = NULL, char *start = NULL,
*end = NULL; *end = NULL;
@ -252,9 +252,9 @@ Datum
subpath(PG_FUNCTION_ARGS) subpath(PG_FUNCTION_ARGS)
{ {
ltree *t = PG_GETARG_LTREE(0); ltree *t = PG_GETARG_LTREE(0);
int4 start = PG_GETARG_INT32(1); int32 start = PG_GETARG_INT32(1);
int4 len = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0; int32 len = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int4 end; int32 end;
ltree *res; ltree *res;
end = start + len; end = start + len;

View File

@ -28,10 +28,10 @@ Datum ltxtq_out(PG_FUNCTION_ARGS);
*/ */
typedef struct NODE typedef struct NODE
{ {
int4 type; int32 type;
int4 val; int32 val;
int2 distance; int16 distance;
int2 length; int16 length;
uint16 flag; uint16 flag;
struct NODE *next; struct NODE *next;
} NODE; } NODE;
@ -39,16 +39,16 @@ typedef struct NODE
typedef struct typedef struct
{ {
char *buf; char *buf;
int4 state; int32 state;
int4 count; int32 count;
/* reverse polish notation in list (for temporary usage) */ /* reverse polish notation in list (for temporary usage) */
NODE *str; NODE *str;
/* number in str */ /* number in str */
int4 num; int32 num;
/* user-friendly operand */ /* user-friendly operand */
int4 lenop; int32 lenop;
int4 sumlen; int32 sumlen;
char *op; char *op;
char *curop; char *curop;
} QPRS_STATE; } QPRS_STATE;
@ -56,8 +56,8 @@ typedef struct
/* /*
* get token from query string * get token from query string
*/ */
static int4 static int32
gettoken_query(QPRS_STATE *state, int4 *val, int4 *lenval, char **strval, uint16 *flag) gettoken_query(QPRS_STATE *state, int32 *val, int32 *lenval, char **strval, uint16 *flag)
{ {
int charlen; int charlen;
@ -71,7 +71,7 @@ gettoken_query(QPRS_STATE *state, int4 *val, int4 *lenval, char **strval, uint16
if (charlen == 1 && t_iseq(state->buf, '!')) if (charlen == 1 && t_iseq(state->buf, '!'))
{ {
(state->buf)++; (state->buf)++;
*val = (int4) '!'; *val = (int32) '!';
return OPR; return OPR;
} }
else if (charlen == 1 && t_iseq(state->buf, '(')) else if (charlen == 1 && t_iseq(state->buf, '('))
@ -117,7 +117,7 @@ gettoken_query(QPRS_STATE *state, int4 *val, int4 *lenval, char **strval, uint16
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; state->state = WAITOPERAND;
*val = (int4) *(state->buf); *val = (int32) *(state->buf);
(state->buf)++; (state->buf)++;
return OPR; return OPR;
} }
@ -146,7 +146,7 @@ gettoken_query(QPRS_STATE *state, int4 *val, int4 *lenval, char **strval, uint16
* push new one in polish notation reverse view * push new one in polish notation reverse view
*/ */
static void static void
pushquery(QPRS_STATE *state, int4 type, int4 val, int4 distance, int4 lenval, uint16 flag) pushquery(QPRS_STATE *state, int32 type, int32 val, int32 distance, int32 lenval, uint16 flag)
{ {
NODE *tmp = (NODE *) palloc(sizeof(NODE)); NODE *tmp = (NODE *) palloc(sizeof(NODE));
@ -184,7 +184,7 @@ pushval_asis(QPRS_STATE *state, int type, char *strval, int lenval, uint16 flag)
while (state->curop - state->op + lenval + 1 >= state->lenop) while (state->curop - state->op + lenval + 1 >= state->lenop)
{ {
int4 tmp = state->curop - state->op; int32 tmp = state->curop - state->op;
state->lenop *= 2; state->lenop *= 2;
state->op = (char *) repalloc((void *) state->op, state->lenop); state->op = (char *) repalloc((void *) state->op, state->lenop);
@ -202,15 +202,15 @@ pushval_asis(QPRS_STATE *state, int type, char *strval, int lenval, uint16 flag)
/* /*
* make polish notaion of query * make polish notaion of query
*/ */
static int4 static int32
makepol(QPRS_STATE *state) makepol(QPRS_STATE *state)
{ {
int4 val = 0, int32 val = 0,
type; type;
int4 lenval = 0; int32 lenval = 0;
char *strval = NULL; char *strval = NULL;
int4 stack[STACKDEPTH]; int32 stack[STACKDEPTH];
int4 lenstack = 0; int32 lenstack = 0;
uint16 flag = 0; uint16 flag = 0;
while ((type = gettoken_query(state, &val, &lenval, &strval, &flag)) != END) while ((type = gettoken_query(state, &val, &lenval, &strval, &flag)) != END)
@ -219,15 +219,15 @@ makepol(QPRS_STATE *state)
{ {
case VAL: case VAL:
pushval_asis(state, VAL, strval, lenval, flag); pushval_asis(state, VAL, strval, lenval, flag);
while (lenstack && (stack[lenstack - 1] == (int4) '&' || while (lenstack && (stack[lenstack - 1] == (int32) '&' ||
stack[lenstack - 1] == (int4) '!')) stack[lenstack - 1] == (int32) '!'))
{ {
lenstack--; lenstack--;
pushquery(state, OPR, stack[lenstack], 0, 0, 0); pushquery(state, OPR, stack[lenstack], 0, 0, 0);
} }
break; break;
case OPR: case OPR:
if (lenstack && val == (int4) '|') if (lenstack && val == (int32) '|')
pushquery(state, OPR, val, 0, 0, 0); pushquery(state, OPR, val, 0, 0, 0);
else else
{ {
@ -241,8 +241,8 @@ makepol(QPRS_STATE *state)
case OPEN: case OPEN:
if (makepol(state) == ERR) if (makepol(state) == ERR)
return ERR; return ERR;
while (lenstack && (stack[lenstack - 1] == (int4) '&' || while (lenstack && (stack[lenstack - 1] == (int32) '&' ||
stack[lenstack - 1] == (int4) '!')) stack[lenstack - 1] == (int32) '!'))
{ {
lenstack--; lenstack--;
pushquery(state, OPR, stack[lenstack], 0, 0, 0); pushquery(state, OPR, stack[lenstack], 0, 0, 0);
@ -275,14 +275,14 @@ makepol(QPRS_STATE *state)
} }
static void static void
findoprnd(ITEM *ptr, int4 *pos) findoprnd(ITEM *ptr, int32 *pos)
{ {
if (ptr[*pos].type == VAL || ptr[*pos].type == VALTRUE) if (ptr[*pos].type == VAL || ptr[*pos].type == VALTRUE)
{ {
ptr[*pos].left = 0; ptr[*pos].left = 0;
(*pos)++; (*pos)++;
} }
else if (ptr[*pos].val == (int4) '!') else if (ptr[*pos].val == (int32) '!')
{ {
ptr[*pos].left = 1; ptr[*pos].left = 1;
(*pos)++; (*pos)++;
@ -291,7 +291,7 @@ findoprnd(ITEM *ptr, int4 *pos)
else else
{ {
ITEM *curitem = &ptr[*pos]; ITEM *curitem = &ptr[*pos];
int4 tmp = *pos; int32 tmp = *pos;
(*pos)++; (*pos)++;
findoprnd(ptr, pos); findoprnd(ptr, pos);
@ -308,12 +308,12 @@ static ltxtquery *
queryin(char *buf) queryin(char *buf)
{ {
QPRS_STATE state; QPRS_STATE state;
int4 i; int32 i;
ltxtquery *query; ltxtquery *query;
int4 commonlen; int32 commonlen;
ITEM *ptr; ITEM *ptr;
NODE *tmp; NODE *tmp;
int4 pos = 0; int32 pos = 0;
#ifdef BS_DEBUG #ifdef BS_DEBUG
char pbuf[16384], char pbuf[16384],
@ -390,13 +390,13 @@ typedef struct
char *buf; char *buf;
char *cur; char *cur;
char *op; char *op;
int4 buflen; int32 buflen;
} INFIX; } INFIX;
#define RESIZEBUF(inf,addsize) \ #define RESIZEBUF(inf,addsize) \
while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \ while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \
{ \ { \
int4 len = (inf)->cur - (inf)->buf; \ int32 len = (inf)->cur - (inf)->buf; \
(inf)->buflen *= 2; \ (inf)->buflen *= 2; \
(inf)->buf = (char*) repalloc( (void*)(inf)->buf, (inf)->buflen ); \ (inf)->buf = (char*) repalloc( (void*)(inf)->buf, (inf)->buflen ); \
(inf)->cur = (inf)->buf + len; \ (inf)->cur = (inf)->buf + len; \
@ -438,7 +438,7 @@ infix(INFIX *in, bool first)
*(in->cur) = '\0'; *(in->cur) = '\0';
in->curpol++; in->curpol++;
} }
else if (in->curpol->val == (int4) '!') else if (in->curpol->val == (int32) '!')
{ {
bool isopr = false; bool isopr = false;
@ -464,11 +464,11 @@ infix(INFIX *in, bool first)
} }
else else
{ {
int4 op = in->curpol->val; int32 op = in->curpol->val;
INFIX nrm; INFIX nrm;
in->curpol++; in->curpol++;
if (op == (int4) '|' && !first) if (op == (int32) '|' && !first)
{ {
RESIZEBUF(in, 2); RESIZEBUF(in, 2);
sprintf(in->cur, "( "); sprintf(in->cur, "( ");
@ -493,7 +493,7 @@ infix(INFIX *in, bool first)
in->cur = strchr(in->cur, '\0'); in->cur = strchr(in->cur, '\0');
pfree(nrm.buf); pfree(nrm.buf);
if (op == (int4) '|' && !first) if (op == (int32) '|' && !first)
{ {
RESIZEBUF(in, 2); RESIZEBUF(in, 2);
sprintf(in->cur, " )"); sprintf(in->cur, " )");

View File

@ -20,13 +20,13 @@ ltree_execute(ITEM *curitem, void *checkval, bool calcnot, bool (*chkcond) (void
{ {
if (curitem->type == VAL) if (curitem->type == VAL)
return (*chkcond) (checkval, curitem); return (*chkcond) (checkval, curitem);
else if (curitem->val == (int4) '!') else if (curitem->val == (int32) '!')
{ {
return (calcnot) ? return (calcnot) ?
((ltree_execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true) ((ltree_execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
: true; : true;
} }
else if (curitem->val == (int4) '&') else if (curitem->val == (int32) '&')
{ {
if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond)) if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
return ltree_execute(curitem + 1, checkval, calcnot, chkcond); return ltree_execute(curitem + 1, checkval, calcnot, chkcond);

View File

@ -78,10 +78,10 @@ gtrgm_out(PG_FUNCTION_ARGS)
static void static void
makesign(BITVECP sign, TRGM *a) makesign(BITVECP sign, TRGM *a)
{ {
int4 k, int32 k,
len = ARRNELEM(a); len = ARRNELEM(a);
trgm *ptr = GETARR(a); trgm *ptr = GETARR(a);
int4 tmp = 0; int32 tmp = 0;
MemSet((void *) sign, 0, sizeof(BITVEC)); MemSet((void *) sign, 0, sizeof(BITVEC));
SETBIT(sign, SIGLENBIT); /* set last unused bit */ SETBIT(sign, SIGLENBIT); /* set last unused bit */
@ -112,7 +112,7 @@ gtrgm_compress(PG_FUNCTION_ARGS)
else if (ISSIGNKEY(DatumGetPointer(entry->key)) && else if (ISSIGNKEY(DatumGetPointer(entry->key)) &&
!ISALLTRUE(DatumGetPointer(entry->key))) !ISALLTRUE(DatumGetPointer(entry->key)))
{ {
int4 i, int32 i,
len; len;
TRGM *res; TRGM *res;
BITVECP sign = GETSIGN(DatumGetPointer(entry->key)); BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
@ -160,14 +160,14 @@ gtrgm_decompress(PG_FUNCTION_ARGS)
} }
} }
static int4 static int32
cnt_sml_sign_common(TRGM *qtrg, BITVECP sign) cnt_sml_sign_common(TRGM *qtrg, BITVECP sign)
{ {
int4 count = 0; int32 count = 0;
int4 k, int32 k,
len = ARRNELEM(qtrg); len = ARRNELEM(qtrg);
trgm *ptr = GETARR(qtrg); trgm *ptr = GETARR(qtrg);
int4 tmp = 0; int32 tmp = 0;
for (k = 0; k < len; k++) for (k = 0; k < len; k++)
{ {
@ -267,8 +267,8 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
} }
else else
{ /* non-leaf contains signature */ { /* non-leaf contains signature */
int4 count = cnt_sml_sign_common(qtrg, GETSIGN(key)); int32 count = cnt_sml_sign_common(qtrg, GETSIGN(key));
int4 len = ARRNELEM(qtrg); int32 len = ARRNELEM(qtrg);
if (len == 0) if (len == 0)
res = false; res = false;
@ -379,8 +379,8 @@ gtrgm_distance(PG_FUNCTION_ARGS)
} }
else else
{ /* non-leaf contains signature */ { /* non-leaf contains signature */
int4 count = cnt_sml_sign_common(qtrg, GETSIGN(key)); int32 count = cnt_sml_sign_common(qtrg, GETSIGN(key));
int4 len = ARRNELEM(qtrg); int32 len = ARRNELEM(qtrg);
res = (len == 0) ? -1.0 : 1.0 - ((float8) count) / ((float8) len); res = (len == 0) ? -1.0 : 1.0 - ((float8) count) / ((float8) len);
} }
@ -394,10 +394,10 @@ gtrgm_distance(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(res); PG_RETURN_FLOAT8(res);
} }
static int4 static int32
unionkey(BITVECP sbase, TRGM *add) unionkey(BITVECP sbase, TRGM *add)
{ {
int4 i; int32 i;
if (ISSIGNKEY(add)) if (ISSIGNKEY(add))
{ {
@ -412,7 +412,7 @@ unionkey(BITVECP sbase, TRGM *add)
else else
{ {
trgm *ptr = GETARR(add); trgm *ptr = GETARR(add);
int4 tmp = 0; int32 tmp = 0;
for (i = 0; i < ARRNELEM(add); i++) for (i = 0; i < ARRNELEM(add); i++)
{ {
@ -428,11 +428,11 @@ Datum
gtrgm_union(PG_FUNCTION_ARGS) gtrgm_union(PG_FUNCTION_ARGS)
{ {
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int4 len = entryvec->n; int32 len = entryvec->n;
int *size = (int *) PG_GETARG_POINTER(1); int *size = (int *) PG_GETARG_POINTER(1);
BITVEC base; BITVEC base;
int4 i; int32 i;
int4 flag = 0; int32 flag = 0;
TRGM *result; TRGM *result;
MemSet((void *) base, 0, sizeof(BITVEC)); MemSet((void *) base, 0, sizeof(BITVEC));
@ -474,7 +474,7 @@ gtrgm_same(PG_FUNCTION_ARGS)
*result = false; *result = false;
else else
{ {
int4 i; int32 i;
BITVECP sa = GETSIGN(a), BITVECP sa = GETSIGN(a),
sb = GETSIGN(b); sb = GETSIGN(b);
@ -491,7 +491,7 @@ gtrgm_same(PG_FUNCTION_ARGS)
} }
else else
{ /* a and b ISARRKEY */ { /* a and b ISARRKEY */
int4 lena = ARRNELEM(a), int32 lena = ARRNELEM(a),
lenb = ARRNELEM(b); lenb = ARRNELEM(b);
if (lena != lenb) if (lena != lenb)
@ -500,7 +500,7 @@ gtrgm_same(PG_FUNCTION_ARGS)
{ {
trgm *ptra = GETARR(a), trgm *ptra = GETARR(a),
*ptrb = GETARR(b); *ptrb = GETARR(b);
int4 i; int32 i;
*result = true; *result = true;
for (i = 0; i < lena; i++) for (i = 0; i < lena; i++)
@ -515,10 +515,10 @@ gtrgm_same(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
static int4 static int32
sizebitvec(BITVECP sign) sizebitvec(BITVECP sign)
{ {
int4 size = 0, int32 size = 0,
i; i;
LOOPBYTE LOOPBYTE
@ -634,7 +634,7 @@ fillcache(CACHESIGN *item, TRGM *key)
typedef struct typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int32 cost;
} SPLITCOST; } SPLITCOST;
static int static int
@ -675,11 +675,11 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
*datum_r; *datum_r;
BITVECP union_l, BITVECP union_l,
union_r; union_r;
int4 size_alpha, int32 size_alpha,
size_beta; size_beta;
int4 size_waste, int32 size_waste,
waste = -1; waste = -1;
int4 nbytes; int32 nbytes;
OffsetNumber seed_1 = 0, OffsetNumber seed_1 = 0,
seed_2 = 0; seed_2 = 0;
OffsetNumber *left, OffsetNumber *left,

View File

@ -1739,6 +1739,13 @@ PG_MODULE_MAGIC;
/* 4-byte integer, passed by value */ /* 4-byte integer, passed by value */
typedef int int4; typedef int int4;
</programlisting> </programlisting>
(The actual PostgreSQL C code calls this type <type>int32</type>, because
it is a convention in C that <type>int<replaceable>XX</replaceable></type>
means <replaceable>XX</replaceable> <emphasis>bits</emphasis>. Note
therefore also that the C type <type>int8</type> is 1 byte in size. The
SQL type <type>int8</type> is called <type>int64</type> in C. See also
<xref linkend="xfunc-c-type-table">.)
</para> </para>
<para> <para>
@ -1801,7 +1808,7 @@ typedef struct
<programlisting> <programlisting>
typedef struct { typedef struct {
int4 length; int32 length;
char data[1]; char data[1];
} text; } text;
</programlisting> </programlisting>
@ -1913,7 +1920,7 @@ memcpy(destination->data, buffer, 40);
</row> </row>
<row> <row>
<entry><type>smallint</type> (<type>int2</type>)</entry> <entry><type>smallint</type> (<type>int2</type>)</entry>
<entry><type>int2</type> or <type>int16</type></entry> <entry><type>int16</type></entry>
<entry><filename>postgres.h</filename></entry> <entry><filename>postgres.h</filename></entry>
</row> </row>
<row> <row>
@ -1923,7 +1930,7 @@ memcpy(destination->data, buffer, 40);
</row> </row>
<row> <row>
<entry><type>integer</type> (<type>int4</type>)</entry> <entry><type>integer</type> (<type>int4</type>)</entry>
<entry><type>int4</type> or <type>int32</type></entry> <entry><type>int32</type></entry>
<entry><filename>postgres.h</filename></entry> <entry><filename>postgres.h</filename></entry>
</row> </row>
<row> <row>

View File

@ -135,7 +135,7 @@ hashint2vector(PG_FUNCTION_ARGS)
{ {
int2vector *key = (int2vector *) PG_GETARG_POINTER(0); int2vector *key = (int2vector *) PG_GETARG_POINTER(0);
return hash_any((unsigned char *) key->values, key->dim1 * sizeof(int2)); return hash_any((unsigned char *) key->values, key->dim1 * sizeof(int16));
} }
Datum Datum

View File

@ -50,7 +50,7 @@ spg_quad_config(PG_FUNCTION_ARGS)
* Points on one of the axes are taken to lie in the lowest-numbered * Points on one of the axes are taken to lie in the lowest-numbered
* adjacent quadrant. * adjacent quadrant.
*/ */
static int2 static int16
getQuadrant(Point *centroid, Point *tst) getQuadrant(Point *centroid, Point *tst)
{ {
if ((SPTEST(point_above, tst, centroid) || if ((SPTEST(point_above, tst, centroid) ||

View File

@ -31,6 +31,8 @@ sub Catalogs
# There are a few types which are given one name in the C source, but a # There are a few types which are given one name in the C source, but a
# different name at the SQL level. These are enumerated here. # different name at the SQL level. These are enumerated here.
my %RENAME_ATTTYPE = ( my %RENAME_ATTTYPE = (
'int16' => 'int2',
'int32' => 'int4',
'Oid' => 'oid', 'Oid' => 'oid',
'NameData' => 'name', 'NameData' => 'name',
'TransactionId' => 'xid' 'TransactionId' => 'xid'

View File

@ -3332,7 +3332,7 @@ get_conversion_oid(List *name, bool missing_ok)
* FindDefaultConversionProc - find default encoding conversion proc * FindDefaultConversionProc - find default encoding conversion proc
*/ */
Oid Oid
FindDefaultConversionProc(int4 for_encoding, int4 to_encoding) FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
{ {
Oid proc; Oid proc;
ListCell *l; ListCell *l;

View File

@ -91,7 +91,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
values[Anum_pg_type_typname - 1] = NameGetDatum(&name); values[Anum_pg_type_typname - 1] = NameGetDatum(&name);
values[Anum_pg_type_typnamespace - 1] = ObjectIdGetDatum(typeNamespace); values[Anum_pg_type_typnamespace - 1] = ObjectIdGetDatum(typeNamespace);
values[Anum_pg_type_typowner - 1] = ObjectIdGetDatum(ownerId); values[Anum_pg_type_typowner - 1] = ObjectIdGetDatum(ownerId);
values[Anum_pg_type_typlen - 1] = Int16GetDatum(sizeof(int4)); values[Anum_pg_type_typlen - 1] = Int16GetDatum(sizeof(int32));
values[Anum_pg_type_typbyval - 1] = BoolGetDatum(true); values[Anum_pg_type_typbyval - 1] = BoolGetDatum(true);
values[Anum_pg_type_typtype - 1] = CharGetDatum(TYPTYPE_PSEUDO); values[Anum_pg_type_typtype - 1] = CharGetDatum(TYPTYPE_PSEUDO);
values[Anum_pg_type_typcategory - 1] = CharGetDatum(TYPCATEGORY_PSEUDOTYPE); values[Anum_pg_type_typcategory - 1] = CharGetDatum(TYPCATEGORY_PSEUDOTYPE);

View File

@ -1204,9 +1204,9 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
/* swap size statistics too, since new rel has freshly-updated stats */ /* swap size statistics too, since new rel has freshly-updated stats */
{ {
int4 swap_pages; int32 swap_pages;
float4 swap_tuples; float4 swap_tuples;
int4 swap_allvisible; int32 swap_allvisible;
swap_pages = relform1->relpages; swap_pages = relform1->relpages;
relform1->relpages = relform2->relpages; relform1->relpages = relform2->relpages;

View File

@ -121,7 +121,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
{ {
int16 tgtype; int16 tgtype;
int ncolumns; int ncolumns;
int2 *columns; int16 *columns;
int2vector *tgattr; int2vector *tgattr;
Node *whenClause; Node *whenClause;
List *whenRtable; List *whenRtable;
@ -589,11 +589,11 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
ListCell *cell; ListCell *cell;
int i = 0; int i = 0;
columns = (int2 *) palloc(ncolumns * sizeof(int2)); columns = (int16 *) palloc(ncolumns * sizeof(int16));
foreach(cell, stmt->columns) foreach(cell, stmt->columns)
{ {
char *name = strVal(lfirst(cell)); char *name = strVal(lfirst(cell));
int2 attnum; int16 attnum;
int j; int j;
/* Lookup column name. System columns are not allowed */ /* Lookup column name. System columns are not allowed */
@ -1501,9 +1501,9 @@ RelationBuildTriggers(Relation relation)
build->tgnattr = pg_trigger->tgattr.dim1; build->tgnattr = pg_trigger->tgattr.dim1;
if (build->tgnattr > 0) if (build->tgnattr > 0)
{ {
build->tgattr = (int2 *) palloc(build->tgnattr * sizeof(int2)); build->tgattr = (int16 *) palloc(build->tgnattr * sizeof(int16));
memcpy(build->tgattr, &(pg_trigger->tgattr.values), memcpy(build->tgattr, &(pg_trigger->tgattr.values),
build->tgnattr * sizeof(int2)); build->tgnattr * sizeof(int16));
} }
else else
build->tgattr = NULL; build->tgattr = NULL;
@ -1654,11 +1654,11 @@ CopyTriggerDesc(TriggerDesc *trigdesc)
trigger->tgname = pstrdup(trigger->tgname); trigger->tgname = pstrdup(trigger->tgname);
if (trigger->tgnattr > 0) if (trigger->tgnattr > 0)
{ {
int2 *newattr; int16 *newattr;
newattr = (int2 *) palloc(trigger->tgnattr * sizeof(int2)); newattr = (int16 *) palloc(trigger->tgnattr * sizeof(int16));
memcpy(newattr, trigger->tgattr, memcpy(newattr, trigger->tgattr,
trigger->tgnattr * sizeof(int2)); trigger->tgnattr * sizeof(int16));
trigger->tgattr = newattr; trigger->tgattr = newattr;
} }
if (trigger->tgnargs > 0) if (trigger->tgnargs > 0)
@ -1772,7 +1772,7 @@ equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2)
return false; return false;
if (trig1->tgnattr > 0 && if (trig1->tgnattr > 0 &&
memcmp(trig1->tgattr, trig2->tgattr, memcmp(trig1->tgattr, trig2->tgattr,
trig1->tgnattr * sizeof(int2)) != 0) trig1->tgnattr * sizeof(int16)) != 0)
return false; return false;
for (j = 0; j < trig1->tgnargs; j++) for (j = 0; j < trig1->tgnargs; j++)
if (strcmp(trig1->tgargs[j], trig2->tgargs[j]) != 0) if (strcmp(trig1->tgargs[j], trig2->tgargs[j]) != 0)

View File

@ -987,7 +987,7 @@ generate_setop_tlist(List *colTypes, List *colCollations,
expr = (Node *) makeConst(INT4OID, expr = (Node *) makeConst(INT4OID,
-1, -1,
InvalidOid, InvalidOid,
sizeof(int4), sizeof(int32),
Int32GetDatum(flag), Int32GetDatum(flag),
false, false,
true); true);

View File

@ -1578,7 +1578,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
for (i = 0; i < index_form->indnatts; i++) for (i = 0; i < index_form->indnatts; i++)
{ {
int2 attnum = index_form->indkey.values[i]; int16 attnum = index_form->indkey.values[i];
Form_pg_attribute attform; Form_pg_attribute attform;
char *attname; char *attname;
Oid defopclass; Oid defopclass;

View File

@ -49,7 +49,7 @@ compareWORD(const void *a, const void *b)
} }
static int static int
uniqueWORD(ParsedWord *a, int4 l) uniqueWORD(ParsedWord *a, int32 l)
{ {
ParsedWord *ptr, ParsedWord *ptr,
*res; *res;
@ -265,9 +265,9 @@ to_tsvector(PG_FUNCTION_ARGS)
* and different variants are ORred together. * and different variants are ORred together.
*/ */
static void static void
pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int2 weight, bool prefix) pushval_morph(Datum opaque, TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
{ {
int4 count = 0; int32 count = 0;
ParsedText prs; ParsedText prs;
uint32 variant, uint32 variant,
pos, pos,
@ -333,7 +333,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
text *in = PG_GETARG_TEXT_P(1); text *in = PG_GETARG_TEXT_P(1);
TSQuery query; TSQuery query;
QueryItem *res; QueryItem *res;
int4 len; int32 len;
query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), false); query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), false);
@ -357,7 +357,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
if (len != query->size) if (len != query->size)
{ {
char *oldoperand = GETOPERAND(query); char *oldoperand = GETOPERAND(query);
int4 lenoperand = VARSIZE(query) - (oldoperand - (char *) query); int32 lenoperand = VARSIZE(query) - (oldoperand - (char *) query);
Assert(len < query->size); Assert(len < query->size);
@ -389,7 +389,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
text *in = PG_GETARG_TEXT_P(1); text *in = PG_GETARG_TEXT_P(1);
TSQuery query; TSQuery query;
QueryItem *res; QueryItem *res;
int4 len; int32 len;
query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), true); query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), true);
@ -408,7 +408,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
if (len != query->size) if (len != query->size)
{ {
char *oldoperand = GETOPERAND(query); char *oldoperand = GETOPERAND(query);
int4 lenoperand = VARSIZE(query) - (oldoperand - (char *) query); int32 lenoperand = VARSIZE(query) - (oldoperand - (char *) query);
Assert(len < query->size); Assert(len < query->size);

View File

@ -592,7 +592,7 @@ generateHeadline(HeadlineParsedText *prs)
char *ptr; char *ptr;
int len = 128; int len = 128;
int numfragments = 0; int numfragments = 0;
int2 infrag = 0; int16 infrag = 0;
HeadlineWordEntry *wrd = prs->words; HeadlineWordEntry *wrd = prs->words;

View File

@ -2133,12 +2133,12 @@ mark_fragment(HeadlineParsedText *prs, int highlight, int startpos, int endpos)
typedef struct typedef struct
{ {
int4 startpos; int32 startpos;
int4 endpos; int32 endpos;
int4 poslen; int32 poslen;
int4 curlen; int32 curlen;
int2 in; int16 in;
int2 excluded; int16 excluded;
} CoverPos; } CoverPos;
static void static void
@ -2191,24 +2191,24 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight,
int shortword, int min_words, int shortword, int min_words,
int max_words, int max_fragments) int max_words, int max_fragments)
{ {
int4 poslen, int32 poslen,
curlen, curlen,
i, i,
f, f,
num_f = 0; num_f = 0;
int4 stretch, int32 stretch,
maxstretch, maxstretch,
posmarker; posmarker;
int4 startpos = 0, int32 startpos = 0,
endpos = 0, endpos = 0,
p = 0, p = 0,
q = 0; q = 0;
int4 numcovers = 0, int32 numcovers = 0,
maxcovers = 32; maxcovers = 32;
int4 minI, int32 minI,
minwords, minwords,
maxitems; maxitems;
CoverPos *covers; CoverPos *covers;

View File

@ -4713,8 +4713,8 @@ array_smaller(PG_FUNCTION_ARGS)
typedef struct generate_subscripts_fctx typedef struct generate_subscripts_fctx
{ {
int4 lower; int32 lower;
int4 upper; int32 upper;
bool reverse; bool reverse;
} generate_subscripts_fctx; } generate_subscripts_fctx;

View File

@ -40,7 +40,7 @@
#define SAMESIGN(a,b) (((a) < 0) == ((b) < 0)) #define SAMESIGN(a,b) (((a) < 0) == ((b) < 0))
#define Int2VectorSize(n) (offsetof(int2vector, values) + (n) * sizeof(int2)) #define Int2VectorSize(n) (offsetof(int2vector, values) + (n) * sizeof(int16))
typedef struct typedef struct
{ {
@ -109,14 +109,14 @@ int2send(PG_FUNCTION_ARGS)
* If int2s is NULL then caller must fill values[] afterward * If int2s is NULL then caller must fill values[] afterward
*/ */
int2vector * int2vector *
buildint2vector(const int2 *int2s, int n) buildint2vector(const int16 *int2s, int n)
{ {
int2vector *result; int2vector *result;
result = (int2vector *) palloc0(Int2VectorSize(n)); result = (int2vector *) palloc0(Int2VectorSize(n));
if (n > 0 && int2s) if (n > 0 && int2s)
memcpy(result->values, int2s, n * sizeof(int2)); memcpy(result->values, int2s, n * sizeof(int16));
/* /*
* Attach standard array header. For historical reasons, we set the index * Attach standard array header. For historical reasons, we set the index
@ -266,7 +266,7 @@ int2vectoreq(PG_FUNCTION_ARGS)
if (a->dim1 != b->dim1) if (a->dim1 != b->dim1)
PG_RETURN_BOOL(false); PG_RETURN_BOOL(false);
PG_RETURN_BOOL(memcmp(a->values, b->values, a->dim1 * sizeof(int2)) == 0); PG_RETURN_BOOL(memcmp(a->values, b->values, a->dim1 * sizeof(int16)) == 0);
} }

View File

@ -2394,7 +2394,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
char *rulename; char *rulename;
char ev_type; char ev_type;
Oid ev_class; Oid ev_class;
int2 ev_attr; int16 ev_attr;
bool is_instead; bool is_instead;
char *ev_qual; char *ev_qual;
char *ev_action; char *ev_action;
@ -2584,7 +2584,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
Query *query; Query *query;
char ev_type; char ev_type;
Oid ev_class; Oid ev_class;
int2 ev_attr; int16 ev_attr;
bool is_instead; bool is_instead;
char *ev_qual; char *ev_qual;
char *ev_action; char *ev_action;
@ -2603,7 +2603,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
ev_class = (Oid) SPI_getbinval(ruletup, rulettc, fno, &isnull); ev_class = (Oid) SPI_getbinval(ruletup, rulettc, fno, &isnull);
fno = SPI_fnumber(rulettc, "ev_attr"); fno = SPI_fnumber(rulettc, "ev_attr");
ev_attr = (int2) SPI_getbinval(ruletup, rulettc, fno, &isnull); ev_attr = (int16) SPI_getbinval(ruletup, rulettc, fno, &isnull);
fno = SPI_fnumber(rulettc, "is_instead"); fno = SPI_fnumber(rulettc, "is_instead");
is_instead = (bool) SPI_getbinval(ruletup, rulettc, fno, &isnull); is_instead = (bool) SPI_getbinval(ruletup, rulettc, fno, &isnull);

View File

@ -109,7 +109,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
if (query->size > 0) if (query->size > 0)
{ {
QueryItem *item = GETQUERY(query); QueryItem *item = GETQUERY(query);
int4 i, int32 i,
j; j;
bool *partialmatch; bool *partialmatch;
int *map_item_operand; int *map_item_operand;

View File

@ -22,7 +22,7 @@
#define SIGLENINT 31 /* >121 => key will toast, so it will not work #define SIGLENINT 31 /* >121 => key will toast, so it will not work
* !!! */ * !!! */
#define SIGLEN ( sizeof(int4) * SIGLENINT ) #define SIGLEN ( sizeof(int32) * SIGLENINT )
#define SIGLENBIT (SIGLEN * BITS_PER_BYTE) #define SIGLENBIT (SIGLEN * BITS_PER_BYTE)
typedef char BITVEC[SIGLEN]; typedef char BITVEC[SIGLEN];
@ -49,7 +49,7 @@ typedef char *BITVECP;
typedef struct typedef struct
{ {
int32 vl_len_; /* varlena header (do not touch directly!) */ int32 vl_len_; /* varlena header (do not touch directly!) */
int4 flag; int32 flag;
char data[1]; char data[1];
} SignTSVector; } SignTSVector;
@ -61,12 +61,12 @@ typedef struct
#define ISSIGNKEY(x) ( ((SignTSVector*)(x))->flag & SIGNKEY ) #define ISSIGNKEY(x) ( ((SignTSVector*)(x))->flag & SIGNKEY )
#define ISALLTRUE(x) ( ((SignTSVector*)(x))->flag & ALLISTRUE ) #define ISALLTRUE(x) ( ((SignTSVector*)(x))->flag & ALLISTRUE )
#define GTHDRSIZE ( VARHDRSZ + sizeof(int4) ) #define GTHDRSIZE ( VARHDRSZ + sizeof(int32) )
#define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) ) #define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int32)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) )
#define GETSIGN(x) ( (BITVECP)( (char*)(x)+GTHDRSIZE ) ) #define GETSIGN(x) ( (BITVECP)( (char*)(x)+GTHDRSIZE ) )
#define GETARR(x) ( (int4*)( (char*)(x)+GTHDRSIZE ) ) #define GETARR(x) ( (int32*)( (char*)(x)+GTHDRSIZE ) )
#define ARRNELEM(x) ( ( VARSIZE(x) - GTHDRSIZE )/sizeof(int4) ) #define ARRNELEM(x) ( ( VARSIZE(x) - GTHDRSIZE )/sizeof(int32) )
/* Number of one-bits in an unsigned byte */ /* Number of one-bits in an unsigned byte */
static const uint8 number_of_ones[256] = { static const uint8 number_of_ones[256] = {
@ -88,7 +88,7 @@ static const uint8 number_of_ones[256] = {
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
}; };
static int4 sizebitvec(BITVECP sign); static int32 sizebitvec(BITVECP sign);
Datum Datum
gtsvectorin(PG_FUNCTION_ARGS) gtsvectorin(PG_FUNCTION_ARGS)
@ -131,8 +131,8 @@ gtsvectorout(PG_FUNCTION_ARGS)
static int static int
compareint(const void *va, const void *vb) compareint(const void *va, const void *vb)
{ {
int4 a = *((const int4 *) va); int32 a = *((const int32 *) va);
int4 b = *((const int4 *) vb); int32 b = *((const int32 *) vb);
if (a == b) if (a == b)
return 0; return 0;
@ -140,13 +140,13 @@ compareint(const void *va, const void *vb)
} }
/* /*
* Removes duplicates from an array of int4. 'l' is * Removes duplicates from an array of int32. 'l' is
* size of the input array. Returns the new size of the array. * size of the input array. Returns the new size of the array.
*/ */
static int static int
uniqueint(int4 *a, int4 l) uniqueint(int32 *a, int32 l)
{ {
int4 *ptr, int32 *ptr,
*res; *res;
if (l <= 1) if (l <= 1)
@ -154,7 +154,7 @@ uniqueint(int4 *a, int4 l)
ptr = res = a; ptr = res = a;
qsort((void *) a, l, sizeof(int4), compareint); qsort((void *) a, l, sizeof(int32), compareint);
while (ptr - a < l) while (ptr - a < l)
if (*ptr != *res) if (*ptr != *res)
@ -167,9 +167,9 @@ uniqueint(int4 *a, int4 l)
static void static void
makesign(BITVECP sign, SignTSVector *a) makesign(BITVECP sign, SignTSVector *a)
{ {
int4 k, int32 k,
len = ARRNELEM(a); len = ARRNELEM(a);
int4 *ptr = GETARR(a); int32 *ptr = GETARR(a);
MemSet((void *) sign, 0, sizeof(BITVEC)); MemSet((void *) sign, 0, sizeof(BITVEC));
for (k = 0; k < len; k++) for (k = 0; k < len; k++)
@ -186,8 +186,8 @@ gtsvector_compress(PG_FUNCTION_ARGS)
{ /* tsvector */ { /* tsvector */
SignTSVector *res; SignTSVector *res;
TSVector val = DatumGetTSVector(entry->key); TSVector val = DatumGetTSVector(entry->key);
int4 len; int32 len;
int4 *arr; int32 *arr;
WordEntry *ptr = ARRPTR(val); WordEntry *ptr = ARRPTR(val);
char *words = STRPTR(val); char *words = STRPTR(val);
@ -205,7 +205,7 @@ gtsvector_compress(PG_FUNCTION_ARGS)
COMP_CRC32(c, words + ptr->pos, ptr->len); COMP_CRC32(c, words + ptr->pos, ptr->len);
FIN_CRC32(c); FIN_CRC32(c);
*arr = *(int4 *) &c; *arr = *(int32 *) &c;
arr++; arr++;
ptr++; ptr++;
} }
@ -243,7 +243,7 @@ gtsvector_compress(PG_FUNCTION_ARGS)
else if (ISSIGNKEY(DatumGetPointer(entry->key)) && else if (ISSIGNKEY(DatumGetPointer(entry->key)) &&
!ISALLTRUE(DatumGetPointer(entry->key))) !ISALLTRUE(DatumGetPointer(entry->key)))
{ {
int4 i, int32 i,
len; len;
SignTSVector *res; SignTSVector *res;
BITVECP sign = GETSIGN(DatumGetPointer(entry->key)); BITVECP sign = GETSIGN(DatumGetPointer(entry->key));
@ -289,8 +289,8 @@ gtsvector_decompress(PG_FUNCTION_ARGS)
typedef struct typedef struct
{ {
int4 *arrb; int32 *arrb;
int4 *arre; int32 *arre;
} CHKVAL; } CHKVAL;
/* /*
@ -299,9 +299,9 @@ typedef struct
static bool static bool
checkcondition_arr(void *checkval, QueryOperand *val) checkcondition_arr(void *checkval, QueryOperand *val)
{ {
int4 *StopLow = ((CHKVAL *) checkval)->arrb; int32 *StopLow = ((CHKVAL *) checkval)->arrb;
int4 *StopHigh = ((CHKVAL *) checkval)->arre; int32 *StopHigh = ((CHKVAL *) checkval)->arre;
int4 *StopMiddle; int32 *StopMiddle;
/* Loop invariant: StopLow <= val < StopHigh */ /* Loop invariant: StopLow <= val < StopHigh */
@ -378,10 +378,10 @@ gtsvector_consistent(PG_FUNCTION_ARGS)
} }
} }
static int4 static int32
unionkey(BITVECP sbase, SignTSVector *add) unionkey(BITVECP sbase, SignTSVector *add)
{ {
int4 i; int32 i;
if (ISSIGNKEY(add)) if (ISSIGNKEY(add))
{ {
@ -395,7 +395,7 @@ unionkey(BITVECP sbase, SignTSVector *add)
} }
else else
{ {
int4 *ptr = GETARR(add); int32 *ptr = GETARR(add);
for (i = 0; i < ARRNELEM(add); i++) for (i = 0; i < ARRNELEM(add); i++)
HASH(sbase, ptr[i]); HASH(sbase, ptr[i]);
@ -410,9 +410,9 @@ gtsvector_union(PG_FUNCTION_ARGS)
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1); int *size = (int *) PG_GETARG_POINTER(1);
BITVEC base; BITVEC base;
int4 i, int32 i,
len; len;
int4 flag = 0; int32 flag = 0;
SignTSVector *result; SignTSVector *result;
MemSet((void *) base, 0, sizeof(BITVEC)); MemSet((void *) base, 0, sizeof(BITVEC));
@ -454,7 +454,7 @@ gtsvector_same(PG_FUNCTION_ARGS)
*result = false; *result = false;
else else
{ {
int4 i; int32 i;
BITVECP sa = GETSIGN(a), BITVECP sa = GETSIGN(a),
sb = GETSIGN(b); sb = GETSIGN(b);
@ -471,16 +471,16 @@ gtsvector_same(PG_FUNCTION_ARGS)
} }
else else
{ /* a and b ISARRKEY */ { /* a and b ISARRKEY */
int4 lena = ARRNELEM(a), int32 lena = ARRNELEM(a),
lenb = ARRNELEM(b); lenb = ARRNELEM(b);
if (lena != lenb) if (lena != lenb)
*result = false; *result = false;
else else
{ {
int4 *ptra = GETARR(a), int32 *ptra = GETARR(a),
*ptrb = GETARR(b); *ptrb = GETARR(b);
int4 i; int32 i;
*result = true; *result = true;
for (i = 0; i < lena; i++) for (i = 0; i < lena; i++)
@ -495,10 +495,10 @@ gtsvector_same(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
static int4 static int32
sizebitvec(BITVECP sign) sizebitvec(BITVECP sign)
{ {
int4 size = 0, int32 size = 0,
i; i;
LOOPBYTE LOOPBYTE
@ -587,7 +587,7 @@ fillcache(CACHESIGN *item, SignTSVector *key)
typedef struct typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int32 cost;
} SPLITCOST; } SPLITCOST;
static int static int
@ -630,11 +630,11 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
*datum_r; *datum_r;
BITVECP union_l, BITVECP union_l,
union_r; union_r;
int4 size_alpha, int32 size_alpha,
size_beta; size_beta;
int4 size_waste, int32 size_waste,
waste = -1; waste = -1;
int4 nbytes; int32 nbytes;
OffsetNumber seed_1 = 0, OffsetNumber seed_1 = 0,
seed_2 = 0; seed_2 = 0;
OffsetNumber *left, OffsetNumber *left,

View File

@ -271,7 +271,7 @@ pushValue_internal(TSQueryParserState state, pg_crc32 valcrc, int distance, int
* of the string. * of the string.
*/ */
void void
pushValue(TSQueryParserState state, char *strval, int lenval, int2 weight, bool prefix) pushValue(TSQueryParserState state, char *strval, int lenval, int16 weight, bool prefix)
{ {
pg_crc32 valcrc; pg_crc32 valcrc;

View File

@ -150,7 +150,7 @@ gtsquery_penalty(PG_FUNCTION_ARGS)
typedef struct typedef struct
{ {
OffsetNumber pos; OffsetNumber pos;
int4 cost; int32 cost;
} SPLITCOST; } SPLITCOST;
static int static int
@ -174,11 +174,11 @@ gtsquery_picksplit(PG_FUNCTION_ARGS)
j; j;
TSQuerySign datum_l, TSQuerySign datum_l,
datum_r; datum_r;
int4 size_alpha, int32 size_alpha,
size_beta; size_beta;
int4 size_waste, int32 size_waste,
waste = -1; waste = -1;
int4 nbytes; int32 nbytes;
OffsetNumber seed_1 = 0, OffsetNumber seed_1 = 0,
seed_2 = 0; seed_2 = 0;
OffsetNumber *left, OffsetNumber *left,

View File

@ -40,7 +40,7 @@ static float calc_rank_and(float *w, TSVector t, TSQuery q);
* Returns a weight of a word collocation * Returns a weight of a word collocation
*/ */
static float4 static float4
word_distance(int4 w) word_distance(int32 w)
{ {
if (w > 100) if (w > 100)
return 1e-30f; return 1e-30f;
@ -213,7 +213,7 @@ calc_rank_and(float *w, TSVector t, TSQuery q)
*firstentry; *firstentry;
WordEntryPos *post, WordEntryPos *post,
*ct; *ct;
int4 dimt, int32 dimt,
lenct, lenct,
dist, dist,
nitem; nitem;
@ -283,7 +283,7 @@ calc_rank_or(float *w, TSVector t, TSQuery q)
WordEntry *entry, WordEntry *entry,
*firstentry; *firstentry;
WordEntryPos *post; WordEntryPos *post;
int4 dimt, int32 dimt,
j, j,
i, i,
nitem; nitem;
@ -297,7 +297,7 @@ calc_rank_or(float *w, TSVector t, TSQuery q)
{ {
float resj, float resj,
wjm; wjm;
int4 jm; int32 jm;
firstentry = entry = find_wordentry(t, q, item[i], &nitem); firstentry = entry = find_wordentry(t, q, item[i], &nitem);
if (!entry) if (!entry)
@ -347,7 +347,7 @@ calc_rank_or(float *w, TSVector t, TSQuery q)
} }
static float static float
calc_rank(float *w, TSVector t, TSQuery q, int4 method) calc_rank(float *w, TSVector t, TSQuery q, int32 method)
{ {
QueryItem *item = GETQUERY(q); QueryItem *item = GETQUERY(q);
float res = 0.0; float res = 0.0;
@ -621,7 +621,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
WordEntry *entry, WordEntry *entry,
*firstentry; *firstentry;
WordEntryPos *post; WordEntryPos *post;
int4 dimt, int32 dimt,
j, j,
i, i,
nitem; nitem;

View File

@ -309,7 +309,7 @@ tsvectorout(PG_FUNCTION_ARGS)
{ {
TSVector out = PG_GETARG_TSVECTOR(0); TSVector out = PG_GETARG_TSVECTOR(0);
char *outbuf; char *outbuf;
int4 i, int32 i,
lenbuf = 0, lenbuf = 0,
pp; pp;
WordEntry *ptr = ARRPTR(out); WordEntry *ptr = ARRPTR(out);

View File

@ -51,7 +51,7 @@ typedef struct StatEntry
typedef struct typedef struct
{ {
int4 weight; int32 weight;
uint32 maxdepth; uint32 maxdepth;
@ -221,7 +221,7 @@ Datum
tsvector_length(PG_FUNCTION_ARGS) tsvector_length(PG_FUNCTION_ARGS)
{ {
TSVector in = PG_GETARG_TSVECTOR(0); TSVector in = PG_GETARG_TSVECTOR(0);
int4 ret = in->size; int32 ret = in->size;
PG_FREE_IF_COPY(in, 0); PG_FREE_IF_COPY(in, 0);
PG_RETURN_INT32(ret); PG_RETURN_INT32(ret);
@ -293,10 +293,10 @@ tsvector_setweight(PG_FUNCTION_ARGS)
* Add positions from src to dest after offsetting them by maxpos. * Add positions from src to dest after offsetting them by maxpos.
* Return the number added (might be less than expected due to overflow) * Return the number added (might be less than expected due to overflow)
*/ */
static int4 static int32
add_pos(TSVector src, WordEntry *srcptr, add_pos(TSVector src, WordEntry *srcptr,
TSVector dest, WordEntry *destptr, TSVector dest, WordEntry *destptr,
int4 maxpos) int32 maxpos)
{ {
uint16 *clen = &_POSVECPTR(dest, destptr)->npos; uint16 *clen = &_POSVECPTR(dest, destptr)->npos;
int i; int i;
@ -552,7 +552,7 @@ tsvector_concat(PG_FUNCTION_ARGS)
* *
* if isPrefix = true then it returns zero value iff b has prefix a * if isPrefix = true then it returns zero value iff b has prefix a
*/ */
int4 int32
tsCompareString(char *a, int lena, char *b, int lenb, bool prefix) tsCompareString(char *a, int lena, char *b, int lenb, bool prefix)
{ {
int cmp; int cmp;

View File

@ -195,7 +195,7 @@ typedef signed char GinNullCategory;
*/ */
#define GinCategoryOffset(itup,ginstate) \ #define GinCategoryOffset(itup,ginstate) \
(IndexInfoFindDataOffset((itup)->t_info) + \ (IndexInfoFindDataOffset((itup)->t_info) + \
((ginstate)->oneCol ? 0 : sizeof(int2))) ((ginstate)->oneCol ? 0 : sizeof(int16)))
#define GinGetNullCategory(itup,ginstate) \ #define GinGetNullCategory(itup,ginstate) \
(*((GinNullCategory *) ((char*)(itup) + GinCategoryOffset(itup,ginstate)))) (*((GinNullCategory *) ((char*)(itup) + GinCategoryOffset(itup,ginstate))))
#define GinSetNullCategory(itup,ginstate,c) \ #define GinSetNullCategory(itup,ginstate,c) \

View File

@ -329,8 +329,6 @@ typedef signed int Offset;
/* /*
* Common Postgres datatype names (as used in the catalogs) * Common Postgres datatype names (as used in the catalogs)
*/ */
typedef int16 int2;
typedef int32 int4;
typedef float float4; typedef float float4;
typedef double float8; typedef double float8;
@ -424,7 +422,7 @@ typedef struct
Oid elemtype; Oid elemtype;
int dim1; int dim1;
int lbound1; int lbound1;
int2 values[1]; /* VARIABLE LENGTH ARRAY */ int16 values[1]; /* VARIABLE LENGTH ARRAY */
} int2vector; /* VARIABLE LENGTH STRUCT */ } int2vector; /* VARIABLE LENGTH STRUCT */
typedef struct typedef struct

View File

@ -133,7 +133,7 @@ extern void PopOverrideSearchPath(void);
extern Oid get_collation_oid(List *collname, bool missing_ok); extern Oid get_collation_oid(List *collname, bool missing_ok);
extern Oid get_conversion_oid(List *conname, bool missing_ok); extern Oid get_conversion_oid(List *conname, bool missing_ok);
extern Oid FindDefaultConversionProc(int4 for_encoding, int4 to_encoding); extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
/* initialization & transaction cleanup code */ /* initialization & transaction cleanup code */
extern void InitializeSearchPath(void); extern void InitializeSearchPath(void);

View File

@ -34,11 +34,11 @@
CATALOG(pg_am,2601) CATALOG(pg_am,2601)
{ {
NameData amname; /* access method name */ NameData amname; /* access method name */
int2 amstrategies; /* total number of strategies (operators) by int16 amstrategies; /* total number of strategies (operators) by
* which we can traverse/search this AM. Zero * which we can traverse/search this AM. Zero
* if AM does not have a fixed set of strategy * if AM does not have a fixed set of strategy
* assignments. */ * assignments. */
int2 amsupport; /* total number of support functions that this int16 amsupport; /* total number of support functions that this
* AM uses */ * AM uses */
bool amcanorder; /* does AM support order by column value? */ bool amcanorder; /* does AM support order by column value? */
bool amcanorderbyop; /* does AM support order by operator result? */ bool amcanorderbyop; /* does AM support order by operator result? */

View File

@ -58,7 +58,7 @@ CATALOG(pg_amop,2602)
Oid amopfamily; /* the index opfamily this entry is for */ Oid amopfamily; /* the index opfamily this entry is for */
Oid amoplefttype; /* operator's left input data type */ Oid amoplefttype; /* operator's left input data type */
Oid amoprighttype; /* operator's right input data type */ Oid amoprighttype; /* operator's right input data type */
int2 amopstrategy; /* operator strategy number */ int16 amopstrategy; /* operator strategy number */
char amoppurpose; /* is operator for 's'earch or 'o'rdering? */ char amoppurpose; /* is operator for 's'earch or 'o'rdering? */
Oid amopopr; /* the operator's pg_operator OID */ Oid amopopr; /* the operator's pg_operator OID */
Oid amopmethod; /* the index access method this entry is for */ Oid amopmethod; /* the index access method this entry is for */

View File

@ -47,7 +47,7 @@ CATALOG(pg_amproc,2603)
Oid amprocfamily; /* the index opfamily this entry is for */ Oid amprocfamily; /* the index opfamily this entry is for */
Oid amproclefttype; /* procedure's left input data type */ Oid amproclefttype; /* procedure's left input data type */
Oid amprocrighttype; /* procedure's right input data type */ Oid amprocrighttype; /* procedure's right input data type */
int2 amprocnum; /* support procedure index */ int16 amprocnum; /* support procedure index */
regproc amproc; /* OID of the proc */ regproc amproc; /* OID of the proc */
} FormData_pg_amproc; } FormData_pg_amproc;

View File

@ -31,7 +31,7 @@
CATALOG(pg_attrdef,2604) CATALOG(pg_attrdef,2604)
{ {
Oid adrelid; /* OID of table containing attribute */ Oid adrelid; /* OID of table containing attribute */
int2 adnum; /* attnum of attribute */ int16 adnum; /* attnum of attribute */
#ifdef CATALOG_VARLEN /* variable-length fields start here */ #ifdef CATALOG_VARLEN /* variable-length fields start here */
pg_node_tree adbin; /* nodeToString representation of default */ pg_node_tree adbin; /* nodeToString representation of default */

View File

@ -54,13 +54,13 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
* that no value has been explicitly set for this column, so ANALYZE * that no value has been explicitly set for this column, so ANALYZE
* should use the default setting. * should use the default setting.
*/ */
int4 attstattarget; int32 attstattarget;
/* /*
* attlen is a copy of the typlen field from pg_type for this attribute. * attlen is a copy of the typlen field from pg_type for this attribute.
* See atttypid comments above. * See atttypid comments above.
*/ */
int2 attlen; int16 attlen;
/* /*
* attnum is the "attribute number" for the attribute: A value that * attnum is the "attribute number" for the attribute: A value that
@ -75,13 +75,13 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
* *
* Note that (attnum - 1) is often used as the index to an array. * Note that (attnum - 1) is often used as the index to an array.
*/ */
int2 attnum; int16 attnum;
/* /*
* attndims is the declared number of dimensions, if an array type, * attndims is the declared number of dimensions, if an array type,
* otherwise zero. * otherwise zero.
*/ */
int4 attndims; int32 attndims;
/* /*
* fastgetattr() uses attcacheoff to cache byte offsets of attributes in * fastgetattr() uses attcacheoff to cache byte offsets of attributes in
@ -90,7 +90,7 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
* descriptor, we may then update attcacheoff in the copies. This speeds * descriptor, we may then update attcacheoff in the copies. This speeds
* up the attribute walking process. * up the attribute walking process.
*/ */
int4 attcacheoff; int32 attcacheoff;
/* /*
* atttypmod records type-specific data supplied at table creation time * atttypmod records type-specific data supplied at table creation time
@ -98,7 +98,7 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
* type-specific input and output functions as the third argument. The * type-specific input and output functions as the third argument. The
* value will generally be -1 for types that do not need typmod. * value will generally be -1 for types that do not need typmod.
*/ */
int4 atttypmod; int32 atttypmod;
/* /*
* attbyval is a copy of the typbyval field from pg_type for this * attbyval is a copy of the typbyval field from pg_type for this
@ -140,7 +140,7 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
bool attislocal; bool attislocal;
/* Number of times inherited from direct parent relation(s) */ /* Number of times inherited from direct parent relation(s) */
int4 attinhcount; int32 attinhcount;
/* attribute's collation */ /* attribute's collation */
Oid attcollation; Oid attcollation;

View File

@ -52,7 +52,7 @@ CATALOG(pg_authid,1260) BKI_SHARED_RELATION BKI_ROWTYPE_OID(2842) BKI_SCHEMA_MAC
bool rolcatupdate; /* allowed to alter catalogs manually? */ bool rolcatupdate; /* allowed to alter catalogs manually? */
bool rolcanlogin; /* allowed to log in as session user? */ bool rolcanlogin; /* allowed to log in as session user? */
bool rolreplication; /* role used for streaming replication */ bool rolreplication; /* role used for streaming replication */
int4 rolconnlimit; /* max connections allowed (-1=no limit) */ int32 rolconnlimit; /* max connections allowed (-1=no limit) */
/* remaining fields may be null; use heap_getattr to read them! */ /* remaining fields may be null; use heap_getattr to read them! */
text rolpassword; /* password, if any */ text rolpassword; /* password, if any */

View File

@ -43,9 +43,9 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
/* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */ /* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
Oid reltablespace; /* identifier of table space for relation */ Oid reltablespace; /* identifier of table space for relation */
int4 relpages; /* # of blocks (not always up-to-date) */ int32 relpages; /* # of blocks (not always up-to-date) */
float4 reltuples; /* # of tuples (not always up-to-date) */ float4 reltuples; /* # of tuples (not always up-to-date) */
int4 relallvisible; /* # of all-visible blocks (not always int32 relallvisible; /* # of all-visible blocks (not always
* up-to-date) */ * up-to-date) */
Oid reltoastrelid; /* OID of toast table; 0 if none */ Oid reltoastrelid; /* OID of toast table; 0 if none */
Oid reltoastidxid; /* if toast table, OID of chunk_id index */ Oid reltoastidxid; /* if toast table, OID of chunk_id index */
@ -53,14 +53,14 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
bool relisshared; /* T if shared across databases */ bool relisshared; /* T if shared across databases */
char relpersistence; /* see RELPERSISTENCE_xxx constants below */ char relpersistence; /* see RELPERSISTENCE_xxx constants below */
char relkind; /* see RELKIND_xxx constants below */ char relkind; /* see RELKIND_xxx constants below */
int2 relnatts; /* number of user attributes */ int16 relnatts; /* number of user attributes */
/* /*
* Class pg_attribute must contain exactly "relnatts" user attributes * Class pg_attribute must contain exactly "relnatts" user attributes
* (with attnums ranging from 1 to relnatts) for this class. It may also * (with attnums ranging from 1 to relnatts) for this class. It may also
* contain entries with negative attnums for system attributes. * contain entries with negative attnums for system attributes.
*/ */
int2 relchecks; /* # of CHECK constraints for class */ int16 relchecks; /* # of CHECK constraints for class */
bool relhasoids; /* T if we generate OIDs for rows of rel */ bool relhasoids; /* T if we generate OIDs for rows of rel */
bool relhaspkey; /* has (or has had) PRIMARY KEY index */ bool relhaspkey; /* has (or has had) PRIMARY KEY index */
bool relhasrules; /* has (or has had) any rules */ bool relhasrules; /* has (or has had) any rules */

View File

@ -34,7 +34,7 @@ CATALOG(pg_collation,3456)
NameData collname; /* collation name */ NameData collname; /* collation name */
Oid collnamespace; /* OID of namespace containing collation */ Oid collnamespace; /* OID of namespace containing collation */
Oid collowner; /* owner of collation */ Oid collowner; /* owner of collation */
int4 collencoding; /* encoding for this collation; -1 = "all" */ int32 collencoding; /* encoding for this collation; -1 = "all" */
NameData collcollate; /* LC_COLLATE setting */ NameData collcollate; /* LC_COLLATE setting */
NameData collctype; /* LC_CTYPE setting */ NameData collctype; /* LC_CTYPE setting */
} FormData_pg_collation; } FormData_pg_collation;

View File

@ -86,7 +86,7 @@ CATALOG(pg_constraint,2606)
bool conislocal; bool conislocal;
/* Number of times inherited from direct parent relation(s) */ /* Number of times inherited from direct parent relation(s) */
int4 coninhcount; int32 coninhcount;
/* Has a local definition and cannot be inherited */ /* Has a local definition and cannot be inherited */
bool connoinherit; bool connoinherit;
@ -97,12 +97,12 @@ CATALOG(pg_constraint,2606)
* Columns of conrelid that the constraint applies to, if known (this is * Columns of conrelid that the constraint applies to, if known (this is
* NULL for trigger constraints) * NULL for trigger constraints)
*/ */
int2 conkey[1]; int16 conkey[1];
/* /*
* If a foreign key, the referenced columns of confrelid * If a foreign key, the referenced columns of confrelid
*/ */
int2 confkey[1]; int16 confkey[1];
/* /*
* If a foreign key, the OIDs of the PK = FK equality operators for each * If a foreign key, the OIDs of the PK = FK equality operators for each

View File

@ -42,8 +42,8 @@ CATALOG(pg_conversion,2607)
NameData conname; NameData conname;
Oid connamespace; Oid connamespace;
Oid conowner; Oid conowner;
int4 conforencoding; int32 conforencoding;
int4 contoencoding; int32 contoencoding;
regproc conproc; regproc conproc;
bool condefault; bool condefault;
} FormData_pg_conversion; } FormData_pg_conversion;

View File

@ -33,12 +33,12 @@ CATALOG(pg_database,1262) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248) BKI_SCHEMA_M
{ {
NameData datname; /* database name */ NameData datname; /* database name */
Oid datdba; /* owner of database */ Oid datdba; /* owner of database */
int4 encoding; /* character encoding */ int32 encoding; /* character encoding */
NameData datcollate; /* LC_COLLATE setting */ NameData datcollate; /* LC_COLLATE setting */
NameData datctype; /* LC_CTYPE setting */ NameData datctype; /* LC_CTYPE setting */
bool datistemplate; /* allowed as CREATE DATABASE template? */ bool datistemplate; /* allowed as CREATE DATABASE template? */
bool datallowconn; /* new connections allowed? */ bool datallowconn; /* new connections allowed? */
int4 datconnlimit; /* max connections allowed (-1=no limit) */ int32 datconnlimit; /* max connections allowed (-1=no limit) */
Oid datlastsysoid; /* highest OID to consider a system OID */ Oid datlastsysoid; /* highest OID to consider a system OID */
TransactionId datfrozenxid; /* all Xids < this are frozen in this DB */ TransactionId datfrozenxid; /* all Xids < this are frozen in this DB */
Oid dattablespace; /* default table space for this DB */ Oid dattablespace; /* default table space for this DB */

View File

@ -37,14 +37,14 @@ CATALOG(pg_depend,2608) BKI_WITHOUT_OIDS
*/ */
Oid classid; /* OID of table containing object */ Oid classid; /* OID of table containing object */
Oid objid; /* OID of object itself */ Oid objid; /* OID of object itself */
int4 objsubid; /* column number, or 0 if not used */ int32 objsubid; /* column number, or 0 if not used */
/* /*
* Identification of the independent (referenced) object. * Identification of the independent (referenced) object.
*/ */
Oid refclassid; /* OID of table containing object */ Oid refclassid; /* OID of table containing object */
Oid refobjid; /* OID of object itself */ Oid refobjid; /* OID of object itself */
int4 refobjsubid; /* column number, or 0 if not used */ int32 refobjsubid; /* column number, or 0 if not used */
/* /*
* Precise semantics of the relationship are specified by the deptype * Precise semantics of the relationship are specified by the deptype

View File

@ -49,7 +49,7 @@ CATALOG(pg_description,2609) BKI_WITHOUT_OIDS
{ {
Oid objoid; /* OID of object itself */ Oid objoid; /* OID of object itself */
Oid classoid; /* OID of table containing object */ Oid classoid; /* OID of table containing object */
int4 objsubid; /* column number, or 0 if not used */ int32 objsubid; /* column number, or 0 if not used */
#ifdef CATALOG_VARLEN /* variable-length fields start here */ #ifdef CATALOG_VARLEN /* variable-length fields start here */
text description; /* description of object */ text description; /* description of object */

View File

@ -32,7 +32,7 @@ CATALOG(pg_index,2610) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
{ {
Oid indexrelid; /* OID of the index */ Oid indexrelid; /* OID of the index */
Oid indrelid; /* OID of the relation it indexes */ Oid indrelid; /* OID of the relation it indexes */
int2 indnatts; /* number of columns in index */ int16 indnatts; /* number of columns in index */
bool indisunique; /* is this a unique index? */ bool indisunique; /* is this a unique index? */
bool indisprimary; /* is this index for primary key? */ bool indisprimary; /* is this index for primary key? */
bool indisexclusion; /* is this index for exclusion constraint? */ bool indisexclusion; /* is this index for exclusion constraint? */

View File

@ -32,7 +32,7 @@ CATALOG(pg_inherits,2611) BKI_WITHOUT_OIDS
{ {
Oid inhrelid; Oid inhrelid;
Oid inhparent; Oid inhparent;
int4 inhseqno; int32 inhseqno;
} FormData_pg_inherits; } FormData_pg_inherits;
/* ---------------- /* ----------------

View File

@ -31,7 +31,7 @@
CATALOG(pg_largeobject,2613) BKI_WITHOUT_OIDS CATALOG(pg_largeobject,2613) BKI_WITHOUT_OIDS
{ {
Oid loid; /* Identifier of large object */ Oid loid; /* Identifier of large object */
int4 pageno; /* Page number (starting from 0) */ int32 pageno; /* Page number (starting from 0) */
/* data has variable length, but we allow direct access; see inv_api.c */ /* data has variable length, but we allow direct access; see inv_api.c */
bytea data; /* Data for page (may be zero-length) */ bytea data; /* Data for page (may be zero-length) */

View File

@ -50,8 +50,8 @@ CATALOG(pg_proc,1255) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81) BKI_SCHEMA_MACRO
bool proisstrict; /* strict with respect to NULLs? */ bool proisstrict; /* strict with respect to NULLs? */
bool proretset; /* returns a set? */ bool proretset; /* returns a set? */
char provolatile; /* see PROVOLATILE_ categories below */ char provolatile; /* see PROVOLATILE_ categories below */
int2 pronargs; /* number of arguments */ int16 pronargs; /* number of arguments */
int2 pronargdefaults; /* number of arguments with defaults */ int16 pronargdefaults; /* number of arguments with defaults */
Oid prorettype; /* OID of result type */ Oid prorettype; /* OID of result type */
/* /*

View File

@ -35,7 +35,7 @@ CATALOG(pg_rewrite,2618)
{ {
NameData rulename; NameData rulename;
Oid ev_class; Oid ev_class;
int2 ev_attr; int16 ev_attr;
char ev_type; char ev_type;
char ev_enabled; char ev_enabled;
bool is_instead; bool is_instead;

View File

@ -24,7 +24,7 @@ CATALOG(pg_seclabel,3596) BKI_WITHOUT_OIDS
{ {
Oid objoid; /* OID of the object itself */ Oid objoid; /* OID of the object itself */
Oid classoid; /* OID of table containing the object */ Oid classoid; /* OID of table containing the object */
int4 objsubid; /* column number, or 0 if not used */ int32 objsubid; /* column number, or 0 if not used */
#ifdef CATALOG_VARLEN /* variable-length fields start here */ #ifdef CATALOG_VARLEN /* variable-length fields start here */
text provider; /* name of label provider */ text provider; /* name of label provider */

View File

@ -39,7 +39,7 @@ CATALOG(pg_shdepend,1214) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
Oid dbid; /* OID of database containing object */ Oid dbid; /* OID of database containing object */
Oid classid; /* OID of table containing object */ Oid classid; /* OID of table containing object */
Oid objid; /* OID of object itself */ Oid objid; /* OID of object itself */
int4 objsubid; /* column number, or 0 if not used */ int32 objsubid; /* column number, or 0 if not used */
/* /*
* Identification of the independent (referenced) object. This is always * Identification of the independent (referenced) object. This is always

View File

@ -32,7 +32,7 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS
{ {
/* These fields form the unique key for the entry: */ /* These fields form the unique key for the entry: */
Oid starelid; /* relation containing attribute */ Oid starelid; /* relation containing attribute */
int2 staattnum; /* attribute (column) stats are for */ int16 staattnum; /* attribute (column) stats are for */
bool stainherit; /* true if inheritance children are included */ bool stainherit; /* true if inheritance children are included */
/* the fraction of the column's entries that are NULL: */ /* the fraction of the column's entries that are NULL: */
@ -48,7 +48,7 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS
* the statistic, which is to estimate sizes of in-memory hash tables of * the statistic, which is to estimate sizes of in-memory hash tables of
* tuples. * tuples.
*/ */
int4 stawidth; int32 stawidth;
/* ---------------- /* ----------------
* stadistinct indicates the (approximate) number of distinct non-null * stadistinct indicates the (approximate) number of distinct non-null
@ -84,11 +84,11 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS
* ---------------- * ----------------
*/ */
int2 stakind1; int16 stakind1;
int2 stakind2; int16 stakind2;
int2 stakind3; int16 stakind3;
int2 stakind4; int16 stakind4;
int2 stakind5; int16 stakind5;
Oid staop1; Oid staop1;
Oid staop2; Oid staop2;

View File

@ -38,7 +38,7 @@ CATALOG(pg_trigger,2620)
Oid tgrelid; /* relation trigger is attached to */ Oid tgrelid; /* relation trigger is attached to */
NameData tgname; /* trigger's name */ NameData tgname; /* trigger's name */
Oid tgfoid; /* OID of function to be called */ Oid tgfoid; /* OID of function to be called */
int2 tgtype; /* BEFORE/AFTER/INSTEAD, UPDATE/DELETE/INSERT, int16 tgtype; /* BEFORE/AFTER/INSTEAD, UPDATE/DELETE/INSERT,
* ROW/STATEMENT; see below */ * ROW/STATEMENT; see below */
char tgenabled; /* trigger's firing configuration WRT char tgenabled; /* trigger's firing configuration WRT
* session_replication_role */ * session_replication_role */
@ -48,7 +48,7 @@ CATALOG(pg_trigger,2620)
Oid tgconstraint; /* associated pg_constraint entry, if any */ Oid tgconstraint; /* associated pg_constraint entry, if any */
bool tgdeferrable; /* constraint trigger is deferrable */ bool tgdeferrable; /* constraint trigger is deferrable */
bool tginitdeferred; /* constraint trigger is deferred initially */ bool tginitdeferred; /* constraint trigger is deferred initially */
int2 tgnargs; /* # of extra arguments in tgargs */ int16 tgnargs; /* # of extra arguments in tgargs */
/* /*
* Variable-length fields start here, but we allow direct access to * Variable-length fields start here, but we allow direct access to

View File

@ -33,8 +33,8 @@
CATALOG(pg_ts_config_map,3603) BKI_WITHOUT_OIDS CATALOG(pg_ts_config_map,3603) BKI_WITHOUT_OIDS
{ {
Oid mapcfg; /* OID of configuration owning this entry */ Oid mapcfg; /* OID of configuration owning this entry */
int4 maptokentype; /* token type from parser */ int32 maptokentype; /* token type from parser */
int4 mapseqno; /* order in which to consult dictionaries */ int32 mapseqno; /* order in which to consult dictionaries */
Oid mapdict; /* dictionary to consult */ Oid mapdict; /* dictionary to consult */
} FormData_pg_ts_config_map; } FormData_pg_ts_config_map;

View File

@ -47,7 +47,7 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71) BKI_SCHEMA_MACRO
* "varlena" type (one that has a length word), -2 to indicate a * "varlena" type (one that has a length word), -2 to indicate a
* null-terminated C string. * null-terminated C string.
*/ */
int2 typlen; int16 typlen;
/* /*
* typbyval determines whether internal Postgres routines pass a value of * typbyval determines whether internal Postgres routines pass a value of
@ -185,13 +185,13 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71) BKI_SCHEMA_MACRO
* type (-1 if base type does not use a typmod). -1 if this type is not a * type (-1 if base type does not use a typmod). -1 if this type is not a
* domain. * domain.
*/ */
int4 typtypmod; int32 typtypmod;
/* /*
* typndims is the declared number of dimensions for an array domain type * typndims is the declared number of dimensions for an array domain type
* (i.e., typbasetype is an array type). Otherwise zero. * (i.e., typbasetype is an array type). Otherwise zero.
*/ */
int4 typndims; int32 typndims;
/* /*
* Collation: 0 if type cannot use collations, DEFAULT_COLLATION_OID for * Collation: 0 if type cannot use collations, DEFAULT_COLLATION_OID for

View File

@ -98,9 +98,9 @@ typedef struct VacAttrStats
*/ */
bool stats_valid; bool stats_valid;
float4 stanullfrac; /* fraction of entries that are NULL */ float4 stanullfrac; /* fraction of entries that are NULL */
int4 stawidth; /* average width of column values */ int32 stawidth; /* average width of column values */
float4 stadistinct; /* # distinct values */ float4 stadistinct; /* # distinct values */
int2 stakind[STATISTIC_NUM_SLOTS]; int16 stakind[STATISTIC_NUM_SLOTS];
Oid staop[STATISTIC_NUM_SLOTS]; Oid staop[STATISTIC_NUM_SLOTS];
int numnumbers[STATISTIC_NUM_SLOTS]; int numnumbers[STATISTIC_NUM_SLOTS];
float4 *stanumbers[STATISTIC_NUM_SLOTS]; float4 *stanumbers[STATISTIC_NUM_SLOTS];
@ -114,7 +114,7 @@ typedef struct VacAttrStats
* elements. It should then overwrite these fields. * elements. It should then overwrite these fields.
*/ */
Oid statypid[STATISTIC_NUM_SLOTS]; Oid statypid[STATISTIC_NUM_SLOTS];
int2 statyplen[STATISTIC_NUM_SLOTS]; int16 statyplen[STATISTIC_NUM_SLOTS];
bool statypbyval[STATISTIC_NUM_SLOTS]; bool statypbyval[STATISTIC_NUM_SLOTS];
char statypalign[STATISTIC_NUM_SLOTS]; char statypalign[STATISTIC_NUM_SLOTS];

View File

@ -49,14 +49,14 @@ typedef struct
typedef struct typedef struct
{ {
HeadlineWordEntry *words; HeadlineWordEntry *words;
int4 lenwords; int32 lenwords;
int4 curwords; int32 curwords;
char *startsel; char *startsel;
char *stopsel; char *stopsel;
char *fragdelim; char *fragdelim;
int2 startsellen; int16 startsellen;
int2 stopsellen; int16 stopsellen;
int2 fragdelimlen; int16 fragdelimlen;
} HeadlineParsedText; } HeadlineParsedText;
/* /*

View File

@ -21,7 +21,7 @@
* *
* Structure of tsvector datatype: * Structure of tsvector datatype:
* 1) standard varlena header * 1) standard varlena header
* 2) int4 size - number of lexemes (WordEntry array entries) * 2) int32 size - number of lexemes (WordEntry array entries)
* 3) Array of WordEntry - one per lexeme; must be sorted according to * 3) Array of WordEntry - one per lexeme; must be sorted according to
* tsCompareString() (ie, memcmp of lexeme strings). * tsCompareString() (ie, memcmp of lexeme strings).
* WordEntry->pos gives the number of bytes from end of WordEntry * WordEntry->pos gives the number of bytes from end of WordEntry
@ -232,13 +232,13 @@ typedef union
typedef struct typedef struct
{ {
int32 vl_len_; /* varlena header (do not touch directly!) */ int32 vl_len_; /* varlena header (do not touch directly!) */
int4 size; /* number of QueryItems */ int32 size; /* number of QueryItems */
char data[1]; /* data starts here */ char data[1]; /* data starts here */
} TSQueryData; } TSQueryData;
typedef TSQueryData *TSQuery; typedef TSQueryData *TSQuery;
#define HDRSIZETQ ( VARHDRSZ + sizeof(int4) ) #define HDRSIZETQ ( VARHDRSZ + sizeof(int32) )
/* Computes the size of header and all QueryItems. size is the number of /* Computes the size of header and all QueryItems. size is the number of
* QueryItems, and lenofoperand is the total length of all operands * QueryItems, and lenofoperand is the total length of all operands

View File

@ -42,7 +42,7 @@ typedef struct TSQueryParserStateData *TSQueryParserState;
typedef void (*PushFunction) (Datum opaque, TSQueryParserState state, typedef void (*PushFunction) (Datum opaque, TSQueryParserState state,
char *token, int tokenlen, char *token, int tokenlen,
int2 tokenweights, /* bitmap as described int16 tokenweights, /* bitmap as described
* in QueryOperand * in QueryOperand
* struct */ * struct */
bool prefix); bool prefix);
@ -53,7 +53,7 @@ extern TSQuery parse_tsquery(char *buf,
/* Functions for use by PushFunction implementations */ /* Functions for use by PushFunction implementations */
extern void pushValue(TSQueryParserState state, extern void pushValue(TSQueryParserState state,
char *strval, int lenval, int2 weight, bool prefix); char *strval, int lenval, int16 weight, bool prefix);
extern void pushStop(TSQueryParserState state); extern void pushStop(TSQueryParserState state);
extern void pushOperator(TSQueryParserState state, int8 oper); extern void pushOperator(TSQueryParserState state, int8 oper);
@ -83,12 +83,12 @@ typedef struct
typedef struct typedef struct
{ {
ParsedWord *words; ParsedWord *words;
int4 lenwords; int32 lenwords;
int4 curwords; int32 curwords;
int4 pos; int32 pos;
} ParsedText; } ParsedText;
extern void parsetext(Oid cfgId, ParsedText *prs, char *buf, int4 buflen); extern void parsetext(Oid cfgId, ParsedText *prs, char *buf, int32 buflen);
/* /*
* headline framework, flow in common to generate: * headline framework, flow in common to generate:
@ -98,7 +98,7 @@ extern void parsetext(Oid cfgId, ParsedText *prs, char *buf, int4 buflen);
*/ */
extern void hlparsetext(Oid cfgId, HeadlineParsedText *prs, TSQuery query, extern void hlparsetext(Oid cfgId, HeadlineParsedText *prs, TSQuery query,
char *buf, int4 buflen); char *buf, int32 buflen);
extern text *generateHeadline(HeadlineParsedText *prs); extern text *generateHeadline(HeadlineParsedText *prs);
/* /*
@ -164,14 +164,14 @@ extern Datum gin_tsquery_consistent_6args(PG_FUNCTION_ARGS);
/* /*
* TSQuery Utilities * TSQuery Utilities
*/ */
extern QueryItem *clean_NOT(QueryItem *ptr, int4 *len); extern QueryItem *clean_NOT(QueryItem *ptr, int32 *len);
extern QueryItem *clean_fakeval(QueryItem *ptr, int4 *len); extern QueryItem *clean_fakeval(QueryItem *ptr, int32 *len);
typedef struct QTNode typedef struct QTNode
{ {
QueryItem *valnode; QueryItem *valnode;
uint32 flags; uint32 flags;
int4 nchild; int32 nchild;
char *word; char *word;
uint32 sign; uint32 sign;
struct QTNode **child; struct QTNode **child;

View File

@ -256,7 +256,7 @@ extern Datum int2shl(PG_FUNCTION_ARGS);
extern Datum int2shr(PG_FUNCTION_ARGS); extern Datum int2shr(PG_FUNCTION_ARGS);
extern Datum generate_series_int4(PG_FUNCTION_ARGS); extern Datum generate_series_int4(PG_FUNCTION_ARGS);
extern Datum generate_series_step_int4(PG_FUNCTION_ARGS); extern Datum generate_series_step_int4(PG_FUNCTION_ARGS);
extern int2vector *buildint2vector(const int2 *int2s, int n); extern int2vector *buildint2vector(const int16 *int2s, int n);
/* name.c */ /* name.c */
extern Datum namein(PG_FUNCTION_ARGS); extern Datum namein(PG_FUNCTION_ARGS);

View File

@ -245,8 +245,8 @@ ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compa
/* /*
* Sets values from PGresult. * Sets values from PGresult.
*/ */
static int2 value_is_null = -1; static int16 value_is_null = -1;
static int2 value_is_not_null = 0; static int16 value_is_not_null = 0;
void void
ecpg_set_compat_sqlda(int lineno, struct sqlda_compat ** _sqlda, const PGresult *res, int row, enum COMPAT_MODE compat) ecpg_set_compat_sqlda(int lineno, struct sqlda_compat ** _sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)