1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Replace int2/int4 in C code with int16/int32

The latter was already the dominant use, and it's preferable because
in C the convention is that intXX means XX bits.  Therefore, allowing
mixed use of int2, int4, int8, int16, int32 is obviously confusing.

Remove the typedefs for int2 and int4 for now.  They don't seem to be
widely used outside of the PostgreSQL source tree, and the few uses
can probably be cleaned up by the time this ships.
This commit is contained in:
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

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

View File

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

View File

@@ -34,11 +34,11 @@
CATALOG(pg_am,2601)
{
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
* if AM does not have a fixed set of strategy
* assignments. */
int2 amsupport; /* total number of support functions that this
int16 amsupport; /* total number of support functions that this
* AM uses */
bool amcanorder; /* does AM support order by column value? */
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 amoplefttype; /* operator's left 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? */
Oid amopopr; /* the operator's pg_operator OID */
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 amproclefttype; /* procedure's left 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 */
} FormData_pg_amproc;

View File

@@ -31,7 +31,7 @@
CATALOG(pg_attrdef,2604)
{
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 */
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
* should use the default setting.
*/
int4 attstattarget;
int32 attstattarget;
/*
* attlen is a copy of the typlen field from pg_type for this attribute.
* See atttypid comments above.
*/
int2 attlen;
int16 attlen;
/*
* 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.
*/
int2 attnum;
int16 attnum;
/*
* attndims is the declared number of dimensions, if an array type,
* otherwise zero.
*/
int4 attndims;
int32 attndims;
/*
* 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
* up the attribute walking process.
*/
int4 attcacheoff;
int32 attcacheoff;
/*
* 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
* 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
@@ -140,7 +140,7 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(75) BK
bool attislocal;
/* Number of times inherited from direct parent relation(s) */
int4 attinhcount;
int32 attinhcount;
/* attribute's collation */
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 rolcanlogin; /* allowed to log in as session user? */
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! */
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 */
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) */
int4 relallvisible; /* # of all-visible blocks (not always
int32 relallvisible; /* # of all-visible blocks (not always
* up-to-date) */
Oid reltoastrelid; /* OID of toast table; 0 if none */
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 */
char relpersistence; /* see RELPERSISTENCE_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
* (with attnums ranging from 1 to relnatts) for this class. It may also
* 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 relhaspkey; /* has (or has had) PRIMARY KEY index */
bool relhasrules; /* has (or has had) any rules */

View File

@@ -34,7 +34,7 @@ CATALOG(pg_collation,3456)
NameData collname; /* collation name */
Oid collnamespace; /* OID of namespace containing 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 collctype; /* LC_CTYPE setting */
} FormData_pg_collation;

View File

@@ -86,7 +86,7 @@ CATALOG(pg_constraint,2606)
bool conislocal;
/* Number of times inherited from direct parent relation(s) */
int4 coninhcount;
int32 coninhcount;
/* Has a local definition and cannot be inherited */
bool connoinherit;
@@ -97,12 +97,12 @@ CATALOG(pg_constraint,2606)
* Columns of conrelid that the constraint applies to, if known (this is
* NULL for trigger constraints)
*/
int2 conkey[1];
int16 conkey[1];
/*
* 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

View File

@@ -42,8 +42,8 @@ CATALOG(pg_conversion,2607)
NameData conname;
Oid connamespace;
Oid conowner;
int4 conforencoding;
int4 contoencoding;
int32 conforencoding;
int32 contoencoding;
regproc conproc;
bool condefault;
} 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 */
Oid datdba; /* owner of database */
int4 encoding; /* character encoding */
int32 encoding; /* character encoding */
NameData datcollate; /* LC_COLLATE setting */
NameData datctype; /* LC_CTYPE setting */
bool datistemplate; /* allowed as CREATE DATABASE template? */
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 */
TransactionId datfrozenxid; /* all Xids < this are frozen in 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 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.
*/
Oid refclassid; /* OID of table containing object */
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

View File

@@ -49,7 +49,7 @@ CATALOG(pg_description,2609) BKI_WITHOUT_OIDS
{
Oid objoid; /* OID of object itself */
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 */
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 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 indisprimary; /* is this index for primary key? */
bool indisexclusion; /* is this index for exclusion constraint? */

View File

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

View File

@@ -31,7 +31,7 @@
CATALOG(pg_largeobject,2613) BKI_WITHOUT_OIDS
{
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 */
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 proretset; /* returns a set? */
char provolatile; /* see PROVOLATILE_ categories below */
int2 pronargs; /* number of arguments */
int2 pronargdefaults; /* number of arguments with defaults */
int16 pronargs; /* number of arguments */
int16 pronargdefaults; /* number of arguments with defaults */
Oid prorettype; /* OID of result type */
/*

View File

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

View File

@@ -24,7 +24,7 @@ CATALOG(pg_seclabel,3596) BKI_WITHOUT_OIDS
{
Oid objoid; /* OID of the object itself */
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 */
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 classid; /* OID of table containing object */
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

View File

@@ -32,7 +32,7 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS
{
/* These fields form the unique key for the entry: */
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 */
/* 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
* tuples.
*/
int4 stawidth;
int32 stawidth;
/* ----------------
* stadistinct indicates the (approximate) number of distinct non-null
@@ -84,11 +84,11 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS
* ----------------
*/
int2 stakind1;
int2 stakind2;
int2 stakind3;
int2 stakind4;
int2 stakind5;
int16 stakind1;
int16 stakind2;
int16 stakind3;
int16 stakind4;
int16 stakind5;
Oid staop1;
Oid staop2;

View File

@@ -38,7 +38,7 @@ CATALOG(pg_trigger,2620)
Oid tgrelid; /* relation trigger is attached to */
NameData tgname; /* trigger's name */
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 */
char tgenabled; /* trigger's firing configuration WRT
* session_replication_role */
@@ -48,7 +48,7 @@ CATALOG(pg_trigger,2620)
Oid tgconstraint; /* associated pg_constraint entry, if any */
bool tgdeferrable; /* constraint trigger is deferrable */
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

View File

@@ -33,8 +33,8 @@
CATALOG(pg_ts_config_map,3603) BKI_WITHOUT_OIDS
{
Oid mapcfg; /* OID of configuration owning this entry */
int4 maptokentype; /* token type from parser */
int4 mapseqno; /* order in which to consult dictionaries */
int32 maptokentype; /* token type from parser */
int32 mapseqno; /* order in which to consult dictionaries */
Oid mapdict; /* dictionary to consult */
} 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
* null-terminated C string.
*/
int2 typlen;
int16 typlen;
/*
* 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
* domain.
*/
int4 typtypmod;
int32 typtypmod;
/*
* typndims is the declared number of dimensions for an array domain type
* (i.e., typbasetype is an array type). Otherwise zero.
*/
int4 typndims;
int32 typndims;
/*
* Collation: 0 if type cannot use collations, DEFAULT_COLLATION_OID for

View File

@@ -98,9 +98,9 @@ typedef struct VacAttrStats
*/
bool stats_valid;
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 */
int2 stakind[STATISTIC_NUM_SLOTS];
int16 stakind[STATISTIC_NUM_SLOTS];
Oid staop[STATISTIC_NUM_SLOTS];
int numnumbers[STATISTIC_NUM_SLOTS];
float4 *stanumbers[STATISTIC_NUM_SLOTS];
@@ -114,7 +114,7 @@ typedef struct VacAttrStats
* elements. It should then overwrite these fields.
*/
Oid statypid[STATISTIC_NUM_SLOTS];
int2 statyplen[STATISTIC_NUM_SLOTS];
int16 statyplen[STATISTIC_NUM_SLOTS];
bool statypbyval[STATISTIC_NUM_SLOTS];
char statypalign[STATISTIC_NUM_SLOTS];

View File

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

View File

@@ -21,7 +21,7 @@
*
* Structure of tsvector datatype:
* 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
* tsCompareString() (ie, memcmp of lexeme strings).
* WordEntry->pos gives the number of bytes from end of WordEntry
@@ -232,13 +232,13 @@ typedef union
typedef struct
{
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 */
} TSQueryData;
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
* 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,
char *token, int tokenlen,
int2 tokenweights, /* bitmap as described
int16 tokenweights, /* bitmap as described
* in QueryOperand
* struct */
bool prefix);
@@ -53,7 +53,7 @@ extern TSQuery parse_tsquery(char *buf,
/* Functions for use by PushFunction implementations */
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 pushOperator(TSQueryParserState state, int8 oper);
@@ -83,12 +83,12 @@ typedef struct
typedef struct
{
ParsedWord *words;
int4 lenwords;
int4 curwords;
int4 pos;
int32 lenwords;
int32 curwords;
int32 pos;
} 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:
@@ -98,7 +98,7 @@ extern void parsetext(Oid cfgId, ParsedText *prs, char *buf, int4 buflen);
*/
extern void hlparsetext(Oid cfgId, HeadlineParsedText *prs, TSQuery query,
char *buf, int4 buflen);
char *buf, int32 buflen);
extern text *generateHeadline(HeadlineParsedText *prs);
/*
@@ -164,14 +164,14 @@ extern Datum gin_tsquery_consistent_6args(PG_FUNCTION_ARGS);
/*
* TSQuery Utilities
*/
extern QueryItem *clean_NOT(QueryItem *ptr, int4 *len);
extern QueryItem *clean_fakeval(QueryItem *ptr, int4 *len);
extern QueryItem *clean_NOT(QueryItem *ptr, int32 *len);
extern QueryItem *clean_fakeval(QueryItem *ptr, int32 *len);
typedef struct QTNode
{
QueryItem *valnode;
uint32 flags;
int4 nchild;
int32 nchild;
char *word;
uint32 sign;
struct QTNode **child;

View File

@@ -256,7 +256,7 @@ extern Datum int2shl(PG_FUNCTION_ARGS);
extern Datum int2shr(PG_FUNCTION_ARGS);
extern Datum generate_series_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 */
extern Datum namein(PG_FUNCTION_ARGS);