mirror of
https://github.com/simtactics/niotso.git
synced 2025-07-04 13:47:05 -04:00
work in progress, cleaned up the directories and split them up into folder which make more sense, Still need to compile libvitaboy and all the tools
This commit is contained in:
parent
66ce473514
commit
948bd8474c
1786 changed files with 571812 additions and 15332 deletions
321
deps/libpq/include/utils/acl.h
vendored
Normal file
321
deps/libpq/include/utils/acl.h
vendored
Normal file
|
@ -0,0 +1,321 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* acl.h
|
||||
* Definition of (and support for) access control list data structures.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/acl.h
|
||||
*
|
||||
* NOTES
|
||||
* An ACL array is simply an array of AclItems, representing the union
|
||||
* of the privileges represented by the individual items. A zero-length
|
||||
* array represents "no privileges". There are no assumptions about the
|
||||
* ordering of the items, but we do expect that there are no two entries
|
||||
* in the array with the same grantor and grantee.
|
||||
*
|
||||
* For backward-compatibility purposes we have to allow null ACL entries
|
||||
* in system catalogs. A null ACL will be treated as meaning "default
|
||||
* protection" (i.e., whatever acldefault() returns).
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef ACL_H
|
||||
#define ACL_H
|
||||
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "utils/array.h"
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
/*
|
||||
* typedef AclMode is declared in parsenodes.h, also the individual privilege
|
||||
* bit meanings are defined there
|
||||
*/
|
||||
|
||||
#define ACL_ID_PUBLIC 0 /* placeholder for id in a PUBLIC acl item */
|
||||
|
||||
/*
|
||||
* AclItem
|
||||
*
|
||||
* Note: must be same size on all platforms, because the size is hardcoded
|
||||
* in the pg_type.h entry for aclitem.
|
||||
*/
|
||||
typedef struct AclItem
|
||||
{
|
||||
Oid ai_grantee; /* ID that this item grants privs to */
|
||||
Oid ai_grantor; /* grantor of privs */
|
||||
AclMode ai_privs; /* privilege bits */
|
||||
} AclItem;
|
||||
|
||||
/*
|
||||
* The upper 16 bits of the ai_privs field of an AclItem are the grant option
|
||||
* bits, and the lower 16 bits are the actual privileges. We use "rights"
|
||||
* to mean the combined grant option and privilege bits fields.
|
||||
*/
|
||||
#define ACLITEM_GET_PRIVS(item) ((item).ai_privs & 0xFFFF)
|
||||
#define ACLITEM_GET_GOPTIONS(item) (((item).ai_privs >> 16) & 0xFFFF)
|
||||
#define ACLITEM_GET_RIGHTS(item) ((item).ai_privs)
|
||||
|
||||
#define ACL_GRANT_OPTION_FOR(privs) (((AclMode) (privs) & 0xFFFF) << 16)
|
||||
#define ACL_OPTION_TO_PRIVS(privs) (((AclMode) (privs) >> 16) & 0xFFFF)
|
||||
|
||||
#define ACLITEM_SET_PRIVS(item,privs) \
|
||||
((item).ai_privs = ((item).ai_privs & ~((AclMode) 0xFFFF)) | \
|
||||
((AclMode) (privs) & 0xFFFF))
|
||||
#define ACLITEM_SET_GOPTIONS(item,goptions) \
|
||||
((item).ai_privs = ((item).ai_privs & ~(((AclMode) 0xFFFF) << 16)) | \
|
||||
(((AclMode) (goptions) & 0xFFFF) << 16))
|
||||
#define ACLITEM_SET_RIGHTS(item,rights) \
|
||||
((item).ai_privs = (AclMode) (rights))
|
||||
|
||||
#define ACLITEM_SET_PRIVS_GOPTIONS(item,privs,goptions) \
|
||||
((item).ai_privs = ((AclMode) (privs) & 0xFFFF) | \
|
||||
(((AclMode) (goptions) & 0xFFFF) << 16))
|
||||
|
||||
|
||||
#define ACLITEM_ALL_PRIV_BITS ((AclMode) 0xFFFF)
|
||||
#define ACLITEM_ALL_GOPTION_BITS ((AclMode) 0xFFFF << 16)
|
||||
|
||||
/*
|
||||
* Definitions for convenient access to Acl (array of AclItem).
|
||||
* These are standard PostgreSQL arrays, but are restricted to have one
|
||||
* dimension and no nulls. We also ignore the lower bound when reading,
|
||||
* and set it to one when writing.
|
||||
*
|
||||
* CAUTION: as of PostgreSQL 7.1, these arrays are toastable (just like all
|
||||
* other array types). Therefore, be careful to detoast them with the
|
||||
* macros provided, unless you know for certain that a particular array
|
||||
* can't have been toasted.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Acl a one-dimensional array of AclItem
|
||||
*/
|
||||
typedef ArrayType Acl;
|
||||
|
||||
#define ACL_NUM(ACL) (ARR_DIMS(ACL)[0])
|
||||
#define ACL_DAT(ACL) ((AclItem *) ARR_DATA_PTR(ACL))
|
||||
#define ACL_N_SIZE(N) (ARR_OVERHEAD_NONULLS(1) + ((N) * sizeof(AclItem)))
|
||||
#define ACL_SIZE(ACL) ARR_SIZE(ACL)
|
||||
|
||||
/*
|
||||
* fmgr macros for these types
|
||||
*/
|
||||
#define DatumGetAclItemP(X) ((AclItem *) DatumGetPointer(X))
|
||||
#define PG_GETARG_ACLITEM_P(n) DatumGetAclItemP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_ACLITEM_P(x) PG_RETURN_POINTER(x)
|
||||
|
||||
#define DatumGetAclP(X) ((Acl *) PG_DETOAST_DATUM(X))
|
||||
#define DatumGetAclPCopy(X) ((Acl *) PG_DETOAST_DATUM_COPY(X))
|
||||
#define PG_GETARG_ACL_P(n) DatumGetAclP(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_ACL_P_COPY(n) DatumGetAclPCopy(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_ACL_P(x) PG_RETURN_POINTER(x)
|
||||
|
||||
/*
|
||||
* ACL modification opcodes for aclupdate
|
||||
*/
|
||||
#define ACL_MODECHG_ADD 1
|
||||
#define ACL_MODECHG_DEL 2
|
||||
#define ACL_MODECHG_EQL 3
|
||||
|
||||
/*
|
||||
* External representations of the privilege bits --- aclitemin/aclitemout
|
||||
* represent each possible privilege bit with a distinct 1-character code
|
||||
*/
|
||||
#define ACL_INSERT_CHR 'a' /* formerly known as "append" */
|
||||
#define ACL_SELECT_CHR 'r' /* formerly known as "read" */
|
||||
#define ACL_UPDATE_CHR 'w' /* formerly known as "write" */
|
||||
#define ACL_DELETE_CHR 'd'
|
||||
#define ACL_TRUNCATE_CHR 'D' /* super-delete, as it were */
|
||||
#define ACL_REFERENCES_CHR 'x'
|
||||
#define ACL_TRIGGER_CHR 't'
|
||||
#define ACL_EXECUTE_CHR 'X'
|
||||
#define ACL_USAGE_CHR 'U'
|
||||
#define ACL_CREATE_CHR 'C'
|
||||
#define ACL_CREATE_TEMP_CHR 'T'
|
||||
#define ACL_CONNECT_CHR 'c'
|
||||
|
||||
/* string holding all privilege code chars, in order by bitmask position */
|
||||
#define ACL_ALL_RIGHTS_STR "arwdDxtXUCTc"
|
||||
|
||||
/*
|
||||
* Bitmasks defining "all rights" for each supported object type
|
||||
*/
|
||||
#define ACL_ALL_RIGHTS_COLUMN (ACL_INSERT|ACL_SELECT|ACL_UPDATE|ACL_REFERENCES)
|
||||
#define ACL_ALL_RIGHTS_RELATION (ACL_INSERT|ACL_SELECT|ACL_UPDATE|ACL_DELETE|ACL_TRUNCATE|ACL_REFERENCES|ACL_TRIGGER)
|
||||
#define ACL_ALL_RIGHTS_SEQUENCE (ACL_USAGE|ACL_SELECT|ACL_UPDATE)
|
||||
#define ACL_ALL_RIGHTS_DATABASE (ACL_CREATE|ACL_CREATE_TEMP|ACL_CONNECT)
|
||||
#define ACL_ALL_RIGHTS_FDW (ACL_USAGE)
|
||||
#define ACL_ALL_RIGHTS_FOREIGN_SERVER (ACL_USAGE)
|
||||
#define ACL_ALL_RIGHTS_FUNCTION (ACL_EXECUTE)
|
||||
#define ACL_ALL_RIGHTS_LANGUAGE (ACL_USAGE)
|
||||
#define ACL_ALL_RIGHTS_LARGEOBJECT (ACL_SELECT|ACL_UPDATE)
|
||||
#define ACL_ALL_RIGHTS_NAMESPACE (ACL_USAGE|ACL_CREATE)
|
||||
#define ACL_ALL_RIGHTS_TABLESPACE (ACL_CREATE)
|
||||
|
||||
/* operation codes for pg_*_aclmask */
|
||||
typedef enum
|
||||
{
|
||||
ACLMASK_ALL, /* normal case: compute all bits */
|
||||
ACLMASK_ANY /* return when result is known nonzero */
|
||||
} AclMaskHow;
|
||||
|
||||
/* result codes for pg_*_aclcheck */
|
||||
typedef enum
|
||||
{
|
||||
ACLCHECK_OK = 0,
|
||||
ACLCHECK_NO_PRIV,
|
||||
ACLCHECK_NOT_OWNER
|
||||
} AclResult;
|
||||
|
||||
/* this enum covers all object types that can have privilege errors */
|
||||
/* currently it's only used to tell aclcheck_error what to say */
|
||||
typedef enum AclObjectKind
|
||||
{
|
||||
ACL_KIND_COLUMN, /* pg_attribute */
|
||||
ACL_KIND_CLASS, /* pg_class */
|
||||
ACL_KIND_SEQUENCE, /* pg_sequence */
|
||||
ACL_KIND_DATABASE, /* pg_database */
|
||||
ACL_KIND_PROC, /* pg_proc */
|
||||
ACL_KIND_OPER, /* pg_operator */
|
||||
ACL_KIND_TYPE, /* pg_type */
|
||||
ACL_KIND_LANGUAGE, /* pg_language */
|
||||
ACL_KIND_LARGEOBJECT, /* pg_largeobject */
|
||||
ACL_KIND_NAMESPACE, /* pg_namespace */
|
||||
ACL_KIND_OPCLASS, /* pg_opclass */
|
||||
ACL_KIND_OPFAMILY, /* pg_opfamily */
|
||||
ACL_KIND_COLLATION, /* pg_collation */
|
||||
ACL_KIND_CONVERSION, /* pg_conversion */
|
||||
ACL_KIND_TABLESPACE, /* pg_tablespace */
|
||||
ACL_KIND_TSDICTIONARY, /* pg_ts_dict */
|
||||
ACL_KIND_TSCONFIGURATION, /* pg_ts_config */
|
||||
ACL_KIND_FDW, /* pg_foreign_data_wrapper */
|
||||
ACL_KIND_FOREIGN_SERVER, /* pg_foreign_server */
|
||||
ACL_KIND_EXTENSION, /* pg_extension */
|
||||
MAX_ACL_KIND /* MUST BE LAST */
|
||||
} AclObjectKind;
|
||||
|
||||
|
||||
/*
|
||||
* routines used internally
|
||||
*/
|
||||
extern Acl *acldefault(GrantObjectType objtype, Oid ownerId);
|
||||
extern Acl *get_user_default_acl(GrantObjectType objtype, Oid ownerId,
|
||||
Oid nsp_oid);
|
||||
|
||||
extern Acl *aclupdate(const Acl *old_acl, const AclItem *mod_aip,
|
||||
int modechg, Oid ownerId, DropBehavior behavior);
|
||||
extern Acl *aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId);
|
||||
extern Acl *make_empty_acl(void);
|
||||
extern Acl *aclcopy(const Acl *orig_acl);
|
||||
extern Acl *aclconcat(const Acl *left_acl, const Acl *right_acl);
|
||||
extern Acl *aclmerge(const Acl *left_acl, const Acl *right_acl, Oid ownerId);
|
||||
extern void aclitemsort(Acl *acl);
|
||||
extern bool aclequal(const Acl *left_acl, const Acl *right_acl);
|
||||
|
||||
extern AclMode aclmask(const Acl *acl, Oid roleid, Oid ownerId,
|
||||
AclMode mask, AclMaskHow how);
|
||||
extern int aclmembers(const Acl *acl, Oid **roleids);
|
||||
|
||||
extern bool has_privs_of_role(Oid member, Oid role);
|
||||
extern bool is_member_of_role(Oid member, Oid role);
|
||||
extern bool is_member_of_role_nosuper(Oid member, Oid role);
|
||||
extern bool is_admin_of_role(Oid member, Oid role);
|
||||
extern void check_is_member_of_role(Oid member, Oid role);
|
||||
extern Oid get_role_oid(const char *rolname, bool missing_ok);
|
||||
|
||||
extern void select_best_grantor(Oid roleId, AclMode privileges,
|
||||
const Acl *acl, Oid ownerId,
|
||||
Oid *grantorId, AclMode *grantOptions);
|
||||
|
||||
extern void initialize_acl(void);
|
||||
|
||||
/*
|
||||
* SQL functions (from acl.c)
|
||||
*/
|
||||
extern Datum aclitemin(PG_FUNCTION_ARGS);
|
||||
extern Datum aclitemout(PG_FUNCTION_ARGS);
|
||||
extern Datum aclinsert(PG_FUNCTION_ARGS);
|
||||
extern Datum aclremove(PG_FUNCTION_ARGS);
|
||||
extern Datum aclcontains(PG_FUNCTION_ARGS);
|
||||
extern Datum makeaclitem(PG_FUNCTION_ARGS);
|
||||
extern Datum aclitem_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum hash_aclitem(PG_FUNCTION_ARGS);
|
||||
extern Datum aclexplode(PG_FUNCTION_ARGS);
|
||||
|
||||
/*
|
||||
* prototypes for functions in aclchk.c
|
||||
*/
|
||||
extern void ExecuteGrantStmt(GrantStmt *stmt);
|
||||
extern void ExecAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *stmt);
|
||||
|
||||
extern void RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid);
|
||||
extern void RemoveDefaultACLById(Oid defaclOid);
|
||||
|
||||
extern AclMode pg_attribute_aclmask(Oid table_oid, AttrNumber attnum,
|
||||
Oid roleid, AclMode mask, AclMaskHow how);
|
||||
extern AclMode pg_class_aclmask(Oid table_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how);
|
||||
extern AclMode pg_database_aclmask(Oid db_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how);
|
||||
extern AclMode pg_proc_aclmask(Oid proc_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how);
|
||||
extern AclMode pg_language_aclmask(Oid lang_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how);
|
||||
extern AclMode pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how, Snapshot snapshot);
|
||||
extern AclMode pg_namespace_aclmask(Oid nsp_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how);
|
||||
extern AclMode pg_tablespace_aclmask(Oid spc_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how);
|
||||
extern AclMode pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how);
|
||||
extern AclMode pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
|
||||
AclMode mask, AclMaskHow how);
|
||||
|
||||
extern AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum,
|
||||
Oid roleid, AclMode mode);
|
||||
extern AclResult pg_attribute_aclcheck_all(Oid table_oid, Oid roleid,
|
||||
AclMode mode, AclMaskHow how);
|
||||
extern AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode);
|
||||
extern AclResult pg_database_aclcheck(Oid db_oid, Oid roleid, AclMode mode);
|
||||
extern AclResult pg_proc_aclcheck(Oid proc_oid, Oid roleid, AclMode mode);
|
||||
extern AclResult pg_language_aclcheck(Oid lang_oid, Oid roleid, AclMode mode);
|
||||
extern AclResult pg_largeobject_aclcheck_snapshot(Oid lang_oid, Oid roleid,
|
||||
AclMode mode, Snapshot snapshot);
|
||||
extern AclResult pg_namespace_aclcheck(Oid nsp_oid, Oid roleid, AclMode mode);
|
||||
extern AclResult pg_tablespace_aclcheck(Oid spc_oid, Oid roleid, AclMode mode);
|
||||
extern AclResult pg_foreign_data_wrapper_aclcheck(Oid fdw_oid, Oid roleid, AclMode mode);
|
||||
extern AclResult pg_foreign_server_aclcheck(Oid srv_oid, Oid roleid, AclMode mode);
|
||||
|
||||
extern void aclcheck_error(AclResult aclerr, AclObjectKind objectkind,
|
||||
const char *objectname);
|
||||
|
||||
extern void aclcheck_error_col(AclResult aclerr, AclObjectKind objectkind,
|
||||
const char *objectname, const char *colname);
|
||||
|
||||
/* ownercheck routines just return true (owner) or false (not) */
|
||||
extern bool pg_class_ownercheck(Oid class_oid, Oid roleid);
|
||||
extern bool pg_type_ownercheck(Oid type_oid, Oid roleid);
|
||||
extern bool pg_oper_ownercheck(Oid oper_oid, Oid roleid);
|
||||
extern bool pg_proc_ownercheck(Oid proc_oid, Oid roleid);
|
||||
extern bool pg_language_ownercheck(Oid lan_oid, Oid roleid);
|
||||
extern bool pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid);
|
||||
extern bool pg_namespace_ownercheck(Oid nsp_oid, Oid roleid);
|
||||
extern bool pg_tablespace_ownercheck(Oid spc_oid, Oid roleid);
|
||||
extern bool pg_opclass_ownercheck(Oid opc_oid, Oid roleid);
|
||||
extern bool pg_opfamily_ownercheck(Oid opf_oid, Oid roleid);
|
||||
extern bool pg_database_ownercheck(Oid db_oid, Oid roleid);
|
||||
extern bool pg_collation_ownercheck(Oid coll_oid, Oid roleid);
|
||||
extern bool pg_conversion_ownercheck(Oid conv_oid, Oid roleid);
|
||||
extern bool pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid);
|
||||
extern bool pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid);
|
||||
extern bool pg_foreign_data_wrapper_ownercheck(Oid srv_oid, Oid roleid);
|
||||
extern bool pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid);
|
||||
extern bool pg_extension_ownercheck(Oid ext_oid, Oid roleid);
|
||||
extern bool has_createrole_privilege(Oid roleid);
|
||||
|
||||
#endif /* ACL_H */
|
292
deps/libpq/include/utils/array.h
vendored
Normal file
292
deps/libpq/include/utils/array.h
vendored
Normal file
|
@ -0,0 +1,292 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* array.h
|
||||
* Declarations for Postgres arrays.
|
||||
*
|
||||
* A standard varlena array has the following internal structure:
|
||||
* <vl_len_> - standard varlena header word
|
||||
* <ndim> - number of dimensions of the array
|
||||
* <dataoffset> - offset to stored data, or 0 if no nulls bitmap
|
||||
* <elemtype> - element type OID
|
||||
* <dimensions> - length of each array axis (C array of int)
|
||||
* <lower bnds> - lower boundary of each dimension (C array of int)
|
||||
* <null bitmap> - bitmap showing locations of nulls (OPTIONAL)
|
||||
* <actual data> - whatever is the stored data
|
||||
*
|
||||
* The <dimensions> and <lower bnds> arrays each have ndim elements.
|
||||
*
|
||||
* The <null bitmap> may be omitted if the array contains no NULL elements.
|
||||
* If it is absent, the <dataoffset> field is zero and the offset to the
|
||||
* stored data must be computed on-the-fly. If the bitmap is present,
|
||||
* <dataoffset> is nonzero and is equal to the offset from the array start
|
||||
* to the first data element (including any alignment padding). The bitmap
|
||||
* follows the same conventions as tuple null bitmaps, ie, a 1 indicates
|
||||
* a non-null entry and the LSB of each bitmap byte is used first.
|
||||
*
|
||||
* The actual data starts on a MAXALIGN boundary. Individual items in the
|
||||
* array are aligned as specified by the array element type. They are
|
||||
* stored in row-major order (last subscript varies most rapidly).
|
||||
*
|
||||
* NOTE: it is important that array elements of toastable datatypes NOT be
|
||||
* toasted, since the tupletoaster won't know they are there. (We could
|
||||
* support compressed toasted items; only out-of-line items are dangerous.
|
||||
* However, it seems preferable to store such items uncompressed and allow
|
||||
* the toaster to compress the whole array as one input.)
|
||||
*
|
||||
*
|
||||
* The OIDVECTOR and INT2VECTOR datatypes are storage-compatible with
|
||||
* generic arrays, but they support only one-dimensional arrays with no
|
||||
* nulls (and no null bitmap).
|
||||
*
|
||||
* There are also some "fixed-length array" datatypes, such as NAME and
|
||||
* POINT. These are simply a sequence of a fixed number of items each
|
||||
* of a fixed-length datatype, with no overhead; the item size must be
|
||||
* a multiple of its alignment requirement, because we do no padding.
|
||||
* We support subscripting on these types, but array_in() and array_out()
|
||||
* only work with varlena arrays.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/array.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef ARRAY_H
|
||||
#define ARRAY_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
/*
|
||||
* Arrays are varlena objects, so must meet the varlena convention that
|
||||
* the first int32 of the object contains the total object size in bytes.
|
||||
* Be sure to use VARSIZE() and SET_VARSIZE() to access it, though!
|
||||
*
|
||||
* CAUTION: if you change the header for ordinary arrays you will also
|
||||
* need to change the headers for oidvector and int2vector!
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
int ndim; /* # of dimensions */
|
||||
int32 dataoffset; /* offset to data, or 0 if no bitmap */
|
||||
Oid elemtype; /* element type OID */
|
||||
} ArrayType;
|
||||
|
||||
/*
|
||||
* working state for accumArrayResult() and friends
|
||||
*/
|
||||
typedef struct ArrayBuildState
|
||||
{
|
||||
MemoryContext mcontext; /* where all the temp stuff is kept */
|
||||
Datum *dvalues; /* array of accumulated Datums */
|
||||
bool *dnulls; /* array of is-null flags for Datums */
|
||||
int alen; /* allocated length of above arrays */
|
||||
int nelems; /* number of valid entries in above arrays */
|
||||
Oid element_type; /* data type of the Datums */
|
||||
int16 typlen; /* needed info about datatype */
|
||||
bool typbyval;
|
||||
char typalign;
|
||||
} ArrayBuildState;
|
||||
|
||||
/*
|
||||
* structure to cache type metadata needed for array manipulation
|
||||
*/
|
||||
typedef struct ArrayMetaState
|
||||
{
|
||||
Oid element_type;
|
||||
int16 typlen;
|
||||
bool typbyval;
|
||||
char typalign;
|
||||
char typdelim;
|
||||
Oid typioparam;
|
||||
Oid typiofunc;
|
||||
FmgrInfo proc;
|
||||
} ArrayMetaState;
|
||||
|
||||
/*
|
||||
* private state needed by array_map (here because caller must provide it)
|
||||
*/
|
||||
typedef struct ArrayMapState
|
||||
{
|
||||
ArrayMetaState inp_extra;
|
||||
ArrayMetaState ret_extra;
|
||||
} ArrayMapState;
|
||||
|
||||
/* ArrayIteratorData is private in arrayfuncs.c */
|
||||
typedef struct ArrayIteratorData *ArrayIterator;
|
||||
|
||||
/*
|
||||
* fmgr macros for array objects
|
||||
*/
|
||||
#define DatumGetArrayTypeP(X) ((ArrayType *) PG_DETOAST_DATUM(X))
|
||||
#define DatumGetArrayTypePCopy(X) ((ArrayType *) PG_DETOAST_DATUM_COPY(X))
|
||||
#define PG_GETARG_ARRAYTYPE_P(n) DatumGetArrayTypeP(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_ARRAYTYPE_P_COPY(n) DatumGetArrayTypePCopy(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_ARRAYTYPE_P(x) PG_RETURN_POINTER(x)
|
||||
|
||||
/*
|
||||
* Access macros for array header fields.
|
||||
*
|
||||
* ARR_DIMS returns a pointer to an array of array dimensions (number of
|
||||
* elements along the various array axes).
|
||||
*
|
||||
* ARR_LBOUND returns a pointer to an array of array lower bounds.
|
||||
*
|
||||
* That is: if the third axis of an array has elements 5 through 8, then
|
||||
* ARR_DIMS(a)[2] == 4 and ARR_LBOUND(a)[2] == 5.
|
||||
*
|
||||
* Unlike C, the default lower bound is 1.
|
||||
*/
|
||||
#define ARR_SIZE(a) VARSIZE(a)
|
||||
#define ARR_NDIM(a) ((a)->ndim)
|
||||
#define ARR_HASNULL(a) ((a)->dataoffset != 0)
|
||||
#define ARR_ELEMTYPE(a) ((a)->elemtype)
|
||||
|
||||
#define ARR_DIMS(a) \
|
||||
((int *) (((char *) (a)) + sizeof(ArrayType)))
|
||||
#define ARR_LBOUND(a) \
|
||||
((int *) (((char *) (a)) + sizeof(ArrayType) + \
|
||||
sizeof(int) * ARR_NDIM(a)))
|
||||
|
||||
#define ARR_NULLBITMAP(a) \
|
||||
(ARR_HASNULL(a) ? \
|
||||
(bits8 *) (((char *) (a)) + sizeof(ArrayType) + \
|
||||
2 * sizeof(int) * ARR_NDIM(a)) \
|
||||
: (bits8 *) NULL)
|
||||
|
||||
/*
|
||||
* The total array header size (in bytes) for an array with the specified
|
||||
* number of dimensions and total number of items.
|
||||
*/
|
||||
#define ARR_OVERHEAD_NONULLS(ndims) \
|
||||
MAXALIGN(sizeof(ArrayType) + 2 * sizeof(int) * (ndims))
|
||||
#define ARR_OVERHEAD_WITHNULLS(ndims, nitems) \
|
||||
MAXALIGN(sizeof(ArrayType) + 2 * sizeof(int) * (ndims) + \
|
||||
((nitems) + 7) / 8)
|
||||
|
||||
#define ARR_DATA_OFFSET(a) \
|
||||
(ARR_HASNULL(a) ? (a)->dataoffset : ARR_OVERHEAD_NONULLS(ARR_NDIM(a)))
|
||||
|
||||
/*
|
||||
* Returns a pointer to the actual array data.
|
||||
*/
|
||||
#define ARR_DATA_PTR(a) \
|
||||
(((char *) (a)) + ARR_DATA_OFFSET(a))
|
||||
|
||||
|
||||
/*
|
||||
* GUC parameter
|
||||
*/
|
||||
extern bool Array_nulls;
|
||||
|
||||
/*
|
||||
* prototypes for functions defined in arrayfuncs.c
|
||||
*/
|
||||
extern Datum array_in(PG_FUNCTION_ARGS);
|
||||
extern Datum array_out(PG_FUNCTION_ARGS);
|
||||
extern Datum array_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum array_send(PG_FUNCTION_ARGS);
|
||||
extern Datum array_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum array_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum array_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum array_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum array_le(PG_FUNCTION_ARGS);
|
||||
extern Datum array_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum btarraycmp(PG_FUNCTION_ARGS);
|
||||
extern Datum hash_array(PG_FUNCTION_ARGS);
|
||||
extern Datum arrayoverlap(PG_FUNCTION_ARGS);
|
||||
extern Datum arraycontains(PG_FUNCTION_ARGS);
|
||||
extern Datum arraycontained(PG_FUNCTION_ARGS);
|
||||
extern Datum array_ndims(PG_FUNCTION_ARGS);
|
||||
extern Datum array_dims(PG_FUNCTION_ARGS);
|
||||
extern Datum array_lower(PG_FUNCTION_ARGS);
|
||||
extern Datum array_upper(PG_FUNCTION_ARGS);
|
||||
extern Datum array_length(PG_FUNCTION_ARGS);
|
||||
extern Datum array_larger(PG_FUNCTION_ARGS);
|
||||
extern Datum array_smaller(PG_FUNCTION_ARGS);
|
||||
extern Datum generate_subscripts(PG_FUNCTION_ARGS);
|
||||
extern Datum generate_subscripts_nodir(PG_FUNCTION_ARGS);
|
||||
extern Datum array_fill(PG_FUNCTION_ARGS);
|
||||
extern Datum array_fill_with_lower_bounds(PG_FUNCTION_ARGS);
|
||||
extern Datum array_unnest(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum array_ref(ArrayType *array, int nSubscripts, int *indx,
|
||||
int arraytyplen, int elmlen, bool elmbyval, char elmalign,
|
||||
bool *isNull);
|
||||
extern ArrayType *array_set(ArrayType *array, int nSubscripts, int *indx,
|
||||
Datum dataValue, bool isNull,
|
||||
int arraytyplen, int elmlen, bool elmbyval, char elmalign);
|
||||
extern ArrayType *array_get_slice(ArrayType *array, int nSubscripts,
|
||||
int *upperIndx, int *lowerIndx,
|
||||
int arraytyplen, int elmlen, bool elmbyval, char elmalign);
|
||||
extern ArrayType *array_set_slice(ArrayType *array, int nSubscripts,
|
||||
int *upperIndx, int *lowerIndx,
|
||||
ArrayType *srcArray, bool isNull,
|
||||
int arraytyplen, int elmlen, bool elmbyval, char elmalign);
|
||||
|
||||
extern Datum array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType,
|
||||
ArrayMapState *amstate);
|
||||
|
||||
extern void array_bitmap_copy(bits8 *destbitmap, int destoffset,
|
||||
const bits8 *srcbitmap, int srcoffset,
|
||||
int nitems);
|
||||
|
||||
extern ArrayType *construct_array(Datum *elems, int nelems,
|
||||
Oid elmtype,
|
||||
int elmlen, bool elmbyval, char elmalign);
|
||||
extern ArrayType *construct_md_array(Datum *elems,
|
||||
bool *nulls,
|
||||
int ndims,
|
||||
int *dims,
|
||||
int *lbs,
|
||||
Oid elmtype, int elmlen, bool elmbyval, char elmalign);
|
||||
extern ArrayType *construct_empty_array(Oid elmtype);
|
||||
extern void deconstruct_array(ArrayType *array,
|
||||
Oid elmtype,
|
||||
int elmlen, bool elmbyval, char elmalign,
|
||||
Datum **elemsp, bool **nullsp, int *nelemsp);
|
||||
extern bool array_contains_nulls(ArrayType *array);
|
||||
extern ArrayBuildState *accumArrayResult(ArrayBuildState *astate,
|
||||
Datum dvalue, bool disnull,
|
||||
Oid element_type,
|
||||
MemoryContext rcontext);
|
||||
extern Datum makeArrayResult(ArrayBuildState *astate,
|
||||
MemoryContext rcontext);
|
||||
extern Datum makeMdArrayResult(ArrayBuildState *astate, int ndims,
|
||||
int *dims, int *lbs, MemoryContext rcontext, bool release);
|
||||
|
||||
extern ArrayIterator array_create_iterator(ArrayType *arr, int slice_ndim);
|
||||
extern bool array_iterate(ArrayIterator iterator, Datum *value, bool *isnull);
|
||||
extern void array_free_iterator(ArrayIterator iterator);
|
||||
|
||||
/*
|
||||
* prototypes for functions defined in arrayutils.c
|
||||
*/
|
||||
|
||||
extern int ArrayGetOffset(int n, const int *dim, const int *lb, const int *indx);
|
||||
extern int ArrayGetOffset0(int n, const int *tup, const int *scale);
|
||||
extern int ArrayGetNItems(int ndim, const int *dims);
|
||||
extern void mda_get_range(int n, int *span, const int *st, const int *endp);
|
||||
extern void mda_get_prod(int n, const int *range, int *prod);
|
||||
extern void mda_get_offset_values(int n, int *dist, const int *prod, const int *span);
|
||||
extern int mda_next_tuple(int n, int *curr, const int *span);
|
||||
extern int32 *ArrayGetIntegerTypmods(ArrayType *arr, int *n);
|
||||
|
||||
/*
|
||||
* prototypes for functions defined in array_userfuncs.c
|
||||
*/
|
||||
extern Datum array_push(PG_FUNCTION_ARGS);
|
||||
extern Datum array_cat(PG_FUNCTION_ARGS);
|
||||
|
||||
extern ArrayType *create_singleton_array(FunctionCallInfo fcinfo,
|
||||
Oid element_type,
|
||||
Datum element,
|
||||
bool isNull,
|
||||
int ndims);
|
||||
|
||||
extern Datum array_agg_transfn(PG_FUNCTION_ARGS);
|
||||
extern Datum array_agg_finalfn(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* ARRAY_H */
|
20
deps/libpq/include/utils/ascii.h
vendored
Normal file
20
deps/libpq/include/utils/ascii.h
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*-----------------------------------------------------------------------
|
||||
* ascii.h
|
||||
*
|
||||
* Portions Copyright (c) 1999-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
* src/include/utils/ascii.h
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _ASCII_H_
|
||||
#define _ASCII_H_
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
extern Datum to_ascii_encname(PG_FUNCTION_ARGS);
|
||||
extern Datum to_ascii_enc(PG_FUNCTION_ARGS);
|
||||
extern Datum to_ascii_default(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* _ASCII_H_ */
|
28
deps/libpq/include/utils/attoptcache.h
vendored
Normal file
28
deps/libpq/include/utils/attoptcache.h
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* attoptcache.h
|
||||
* Attribute options cache.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/attoptcache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SPCCACHE_H
|
||||
#define SPCCACHE_H
|
||||
|
||||
/*
|
||||
* Attribute options.
|
||||
*/
|
||||
typedef struct AttributeOpts
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
float8 n_distinct;
|
||||
float8 n_distinct_inherited;
|
||||
} AttributeOpts;
|
||||
|
||||
AttributeOpts *get_attribute_options(Oid spcid, int attnum);
|
||||
|
||||
#endif /* SPCCACHE_H */
|
1093
deps/libpq/include/utils/builtins.h
vendored
Normal file
1093
deps/libpq/include/utils/builtins.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
52
deps/libpq/include/utils/bytea.h
vendored
Normal file
52
deps/libpq/include/utils/bytea.h
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* bytea.h
|
||||
* Declarations for BYTEA data type support.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/bytea.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef BYTEA_H
|
||||
#define BYTEA_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BYTEA_OUTPUT_ESCAPE,
|
||||
BYTEA_OUTPUT_HEX
|
||||
} ByteaOutputType;
|
||||
|
||||
extern int bytea_output; /* ByteaOutputType, but int for GUC enum */
|
||||
|
||||
/* functions are in utils/adt/varlena.c */
|
||||
extern Datum byteain(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaout(PG_FUNCTION_ARGS);
|
||||
extern Datum bytearecv(PG_FUNCTION_ARGS);
|
||||
extern Datum byteasend(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaoctetlen(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaGetByte(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaGetBit(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaSetByte(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaSetBit(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaeq(PG_FUNCTION_ARGS);
|
||||
extern Datum byteane(PG_FUNCTION_ARGS);
|
||||
extern Datum bytealt(PG_FUNCTION_ARGS);
|
||||
extern Datum byteale(PG_FUNCTION_ARGS);
|
||||
extern Datum byteagt(PG_FUNCTION_ARGS);
|
||||
extern Datum byteage(PG_FUNCTION_ARGS);
|
||||
extern Datum byteacmp(PG_FUNCTION_ARGS);
|
||||
extern Datum byteacat(PG_FUNCTION_ARGS);
|
||||
extern Datum byteapos(PG_FUNCTION_ARGS);
|
||||
extern Datum bytea_substr(PG_FUNCTION_ARGS);
|
||||
extern Datum bytea_substr_no_len(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaoverlay(PG_FUNCTION_ARGS);
|
||||
extern Datum byteaoverlay_no_len(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* BYTEA_H */
|
73
deps/libpq/include/utils/cash.h
vendored
Normal file
73
deps/libpq/include/utils/cash.h
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* src/include/utils/cash.h
|
||||
*
|
||||
*
|
||||
* cash.h
|
||||
* Written by D'Arcy J.M. Cain
|
||||
*
|
||||
* Functions to allow input and output of money normally but store
|
||||
* and handle it as 64 bit integer.
|
||||
*/
|
||||
|
||||
#ifndef CASH_H
|
||||
#define CASH_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
typedef int64 Cash;
|
||||
|
||||
/* Cash is pass-by-reference if and only if int64 is */
|
||||
#define DatumGetCash(X) ((Cash) DatumGetInt64(X))
|
||||
#define CashGetDatum(X) Int64GetDatum(X)
|
||||
#define PG_GETARG_CASH(n) DatumGetCash(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_CASH(x) return CashGetDatum(x)
|
||||
|
||||
extern Datum cash_in(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_out(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_send(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_le(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_cmp(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_pl(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_mi(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_div_cash(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_mul_flt8(PG_FUNCTION_ARGS);
|
||||
extern Datum flt8_mul_cash(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_div_flt8(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_mul_flt4(PG_FUNCTION_ARGS);
|
||||
extern Datum flt4_mul_cash(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_div_flt4(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_mul_int8(PG_FUNCTION_ARGS);
|
||||
extern Datum int8_mul_cash(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_div_int8(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_mul_int4(PG_FUNCTION_ARGS);
|
||||
extern Datum int4_mul_cash(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_div_int4(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_mul_int2(PG_FUNCTION_ARGS);
|
||||
extern Datum int2_mul_cash(PG_FUNCTION_ARGS);
|
||||
extern Datum cash_div_int2(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cashlarger(PG_FUNCTION_ARGS);
|
||||
extern Datum cashsmaller(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_words(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum cash_numeric(PG_FUNCTION_ARGS);
|
||||
extern Datum numeric_cash(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int4_cash(PG_FUNCTION_ARGS);
|
||||
extern Datum int8_cash(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* CASH_H */
|
193
deps/libpq/include/utils/catcache.h
vendored
Normal file
193
deps/libpq/include/utils/catcache.h
vendored
Normal file
|
@ -0,0 +1,193 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* catcache.h
|
||||
* Low-level catalog cache definitions.
|
||||
*
|
||||
* NOTE: every catalog cache must have a corresponding unique index on
|
||||
* the system table that it caches --- ie, the index must match the keys
|
||||
* used to do lookups in this cache. All cache fetches are done with
|
||||
* indexscans (under normal conditions). The index should be unique to
|
||||
* guarantee that there can only be one matching row for a key combination.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/catcache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef CATCACHE_H
|
||||
#define CATCACHE_H
|
||||
|
||||
#include "access/htup.h"
|
||||
#include "access/skey.h"
|
||||
#include "lib/dllist.h"
|
||||
#include "utils/relcache.h"
|
||||
|
||||
/*
|
||||
* struct catctup: individual tuple in the cache.
|
||||
* struct catclist: list of tuples matching a partial key.
|
||||
* struct catcache: information for managing a cache.
|
||||
* struct catcacheheader: information for managing all the caches.
|
||||
*/
|
||||
|
||||
#define CATCACHE_MAXKEYS 4
|
||||
|
||||
typedef struct catcache
|
||||
{
|
||||
int id; /* cache identifier --- see syscache.h */
|
||||
struct catcache *cc_next; /* link to next catcache */
|
||||
const char *cc_relname; /* name of relation the tuples come from */
|
||||
Oid cc_reloid; /* OID of relation the tuples come from */
|
||||
Oid cc_indexoid; /* OID of index matching cache keys */
|
||||
bool cc_relisshared; /* is relation shared across databases? */
|
||||
TupleDesc cc_tupdesc; /* tuple descriptor (copied from reldesc) */
|
||||
int cc_ntup; /* # of tuples currently in this cache */
|
||||
int cc_nbuckets; /* # of hash buckets in this cache */
|
||||
int cc_nkeys; /* # of keys (1..CATCACHE_MAXKEYS) */
|
||||
int cc_key[CATCACHE_MAXKEYS]; /* AttrNumber of each key */
|
||||
PGFunction cc_hashfunc[CATCACHE_MAXKEYS]; /* hash function for each key */
|
||||
ScanKeyData cc_skey[CATCACHE_MAXKEYS]; /* precomputed key info for
|
||||
* heap scans */
|
||||
bool cc_isname[CATCACHE_MAXKEYS]; /* flag "name" key columns */
|
||||
Dllist cc_lists; /* list of CatCList structs */
|
||||
#ifdef CATCACHE_STATS
|
||||
long cc_searches; /* total # searches against this cache */
|
||||
long cc_hits; /* # of matches against existing entry */
|
||||
long cc_neg_hits; /* # of matches against negative entry */
|
||||
long cc_newloads; /* # of successful loads of new entry */
|
||||
|
||||
/*
|
||||
* cc_searches - (cc_hits + cc_neg_hits + cc_newloads) is number of failed
|
||||
* searches, each of which will result in loading a negative entry
|
||||
*/
|
||||
long cc_invals; /* # of entries invalidated from cache */
|
||||
long cc_lsearches; /* total # list-searches */
|
||||
long cc_lhits; /* # of matches against existing lists */
|
||||
#endif
|
||||
Dllist cc_bucket[1]; /* hash buckets --- VARIABLE LENGTH ARRAY */
|
||||
} CatCache; /* VARIABLE LENGTH STRUCT */
|
||||
|
||||
|
||||
typedef struct catctup
|
||||
{
|
||||
int ct_magic; /* for identifying CatCTup entries */
|
||||
#define CT_MAGIC 0x57261502
|
||||
CatCache *my_cache; /* link to owning catcache */
|
||||
|
||||
/*
|
||||
* Each tuple in a cache is a member of a Dllist that stores the elements
|
||||
* of its hash bucket. We keep each Dllist in LRU order to speed repeated
|
||||
* lookups.
|
||||
*/
|
||||
Dlelem cache_elem; /* list member of per-bucket list */
|
||||
|
||||
/*
|
||||
* The tuple may also be a member of at most one CatCList. (If a single
|
||||
* catcache is list-searched with varying numbers of keys, we may have to
|
||||
* make multiple entries for the same tuple because of this restriction.
|
||||
* Currently, that's not expected to be common, so we accept the potential
|
||||
* inefficiency.)
|
||||
*/
|
||||
struct catclist *c_list; /* containing CatCList, or NULL if none */
|
||||
|
||||
/*
|
||||
* A tuple marked "dead" must not be returned by subsequent searches.
|
||||
* However, it won't be physically deleted from the cache until its
|
||||
* refcount goes to zero. (If it's a member of a CatCList, the list's
|
||||
* refcount must go to zero, too; also, remember to mark the list dead at
|
||||
* the same time the tuple is marked.)
|
||||
*
|
||||
* A negative cache entry is an assertion that there is no tuple matching
|
||||
* a particular key. This is just as useful as a normal entry so far as
|
||||
* avoiding catalog searches is concerned. Management of positive and
|
||||
* negative entries is identical.
|
||||
*/
|
||||
int refcount; /* number of active references */
|
||||
bool dead; /* dead but not yet removed? */
|
||||
bool negative; /* negative cache entry? */
|
||||
uint32 hash_value; /* hash value for this tuple's keys */
|
||||
HeapTupleData tuple; /* tuple management header */
|
||||
} CatCTup;
|
||||
|
||||
|
||||
typedef struct catclist
|
||||
{
|
||||
int cl_magic; /* for identifying CatCList entries */
|
||||
#define CL_MAGIC 0x52765103
|
||||
CatCache *my_cache; /* link to owning catcache */
|
||||
|
||||
/*
|
||||
* A CatCList describes the result of a partial search, ie, a search using
|
||||
* only the first K key columns of an N-key cache. We form the keys used
|
||||
* into a tuple (with other attributes NULL) to represent the stored key
|
||||
* set. The CatCList object contains links to cache entries for all the
|
||||
* table rows satisfying the partial key. (Note: none of these will be
|
||||
* negative cache entries.)
|
||||
*
|
||||
* A CatCList is only a member of a per-cache list; we do not currently
|
||||
* divide them into hash buckets.
|
||||
*
|
||||
* A list marked "dead" must not be returned by subsequent searches.
|
||||
* However, it won't be physically deleted from the cache until its
|
||||
* refcount goes to zero. (A list should be marked dead if any of its
|
||||
* member entries are dead.)
|
||||
*
|
||||
* If "ordered" is true then the member tuples appear in the order of the
|
||||
* cache's underlying index. This will be true in normal operation, but
|
||||
* might not be true during bootstrap or recovery operations. (namespace.c
|
||||
* is able to save some cycles when it is true.)
|
||||
*/
|
||||
Dlelem cache_elem; /* list member of per-catcache list */
|
||||
int refcount; /* number of active references */
|
||||
bool dead; /* dead but not yet removed? */
|
||||
bool ordered; /* members listed in index order? */
|
||||
short nkeys; /* number of lookup keys specified */
|
||||
uint32 hash_value; /* hash value for lookup keys */
|
||||
HeapTupleData tuple; /* header for tuple holding keys */
|
||||
int n_members; /* number of member tuples */
|
||||
CatCTup *members[1]; /* members --- VARIABLE LENGTH ARRAY */
|
||||
} CatCList; /* VARIABLE LENGTH STRUCT */
|
||||
|
||||
|
||||
typedef struct catcacheheader
|
||||
{
|
||||
CatCache *ch_caches; /* head of list of CatCache structs */
|
||||
int ch_ntup; /* # of tuples in all caches */
|
||||
} CatCacheHeader;
|
||||
|
||||
|
||||
/* this extern duplicates utils/memutils.h... */
|
||||
extern PGDLLIMPORT MemoryContext CacheMemoryContext;
|
||||
|
||||
extern void CreateCacheMemoryContext(void);
|
||||
extern void AtEOXact_CatCache(bool isCommit);
|
||||
|
||||
extern CatCache *InitCatCache(int id, Oid reloid, Oid indexoid,
|
||||
int nkeys, const int *key,
|
||||
int nbuckets);
|
||||
extern void InitCatCachePhase2(CatCache *cache, bool touch_index);
|
||||
|
||||
extern HeapTuple SearchCatCache(CatCache *cache,
|
||||
Datum v1, Datum v2,
|
||||
Datum v3, Datum v4);
|
||||
extern void ReleaseCatCache(HeapTuple tuple);
|
||||
|
||||
extern CatCList *SearchCatCacheList(CatCache *cache, int nkeys,
|
||||
Datum v1, Datum v2,
|
||||
Datum v3, Datum v4);
|
||||
extern void ReleaseCatCacheList(CatCList *list);
|
||||
|
||||
extern void ResetCatalogCaches(void);
|
||||
extern void CatalogCacheFlushCatalog(Oid catId);
|
||||
extern void CatalogCacheIdInvalidate(int cacheId, uint32 hashValue,
|
||||
ItemPointer pointer);
|
||||
extern void PrepareToInvalidateCacheTuple(Relation relation,
|
||||
HeapTuple tuple,
|
||||
void (*function) (int, uint32, ItemPointer, Oid));
|
||||
|
||||
extern void PrintCatCacheLeakWarning(HeapTuple tuple);
|
||||
extern void PrintCatCacheListLeakWarning(CatCList *list);
|
||||
|
||||
#endif /* CATCACHE_H */
|
25
deps/libpq/include/utils/combocid.h
vendored
Normal file
25
deps/libpq/include/utils/combocid.h
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* combocid.h
|
||||
* Combo command ID support routines
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/combocid.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef COMBOCID_H
|
||||
#define COMBOCID_H
|
||||
|
||||
/*
|
||||
* HeapTupleHeaderGetCmin and HeapTupleHeaderGetCmax function prototypes
|
||||
* are in access/htup.h, because that's where the macro definitions that
|
||||
* those functions replaced used to be.
|
||||
*/
|
||||
|
||||
extern void AtEOXact_ComboCid(void);
|
||||
|
||||
#endif /* COMBOCID_H */
|
205
deps/libpq/include/utils/date.h
vendored
Normal file
205
deps/libpq/include/utils/date.h
vendored
Normal file
|
@ -0,0 +1,205 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* date.h
|
||||
* Definitions for the SQL92 "date" and "time" types.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/date.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef DATE_H
|
||||
#define DATE_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
|
||||
typedef int32 DateADT;
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
typedef int64 TimeADT;
|
||||
#else
|
||||
typedef float8 TimeADT;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TimeADT time; /* all time units other than months and years */
|
||||
int32 zone; /* numeric time zone, in seconds */
|
||||
} TimeTzADT;
|
||||
|
||||
/*
|
||||
* Infinity and minus infinity must be the max and min values of DateADT.
|
||||
* We could use INT_MIN and INT_MAX here, but seems better to not assume that
|
||||
* int32 == int.
|
||||
*/
|
||||
#define DATEVAL_NOBEGIN ((DateADT) (-0x7fffffff - 1))
|
||||
#define DATEVAL_NOEND ((DateADT) 0x7fffffff)
|
||||
|
||||
#define DATE_NOBEGIN(j) ((j) = DATEVAL_NOBEGIN)
|
||||
#define DATE_IS_NOBEGIN(j) ((j) == DATEVAL_NOBEGIN)
|
||||
#define DATE_NOEND(j) ((j) = DATEVAL_NOEND)
|
||||
#define DATE_IS_NOEND(j) ((j) == DATEVAL_NOEND)
|
||||
#define DATE_NOT_FINITE(j) (DATE_IS_NOBEGIN(j) || DATE_IS_NOEND(j))
|
||||
|
||||
/*
|
||||
* Macros for fmgr-callable functions.
|
||||
*
|
||||
* For TimeADT, we make use of the same support routines as for float8 or int64.
|
||||
* Therefore TimeADT is pass-by-reference if and only if float8 or int64 is!
|
||||
*/
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
|
||||
#define MAX_TIME_PRECISION 6
|
||||
|
||||
#define DatumGetDateADT(X) ((DateADT) DatumGetInt32(X))
|
||||
#define DatumGetTimeADT(X) ((TimeADT) DatumGetInt64(X))
|
||||
#define DatumGetTimeTzADTP(X) ((TimeTzADT *) DatumGetPointer(X))
|
||||
|
||||
#define DateADTGetDatum(X) Int32GetDatum(X)
|
||||
#define TimeADTGetDatum(X) Int64GetDatum(X)
|
||||
#define TimeTzADTPGetDatum(X) PointerGetDatum(X)
|
||||
#else /* !HAVE_INT64_TIMESTAMP */
|
||||
|
||||
#define MAX_TIME_PRECISION 10
|
||||
|
||||
/* round off to MAX_TIME_PRECISION decimal places */
|
||||
#define TIME_PREC_INV 10000000000.0
|
||||
#define TIMEROUND(j) (rint(((double) (j)) * TIME_PREC_INV) / TIME_PREC_INV)
|
||||
|
||||
#define DatumGetDateADT(X) ((DateADT) DatumGetInt32(X))
|
||||
#define DatumGetTimeADT(X) ((TimeADT) DatumGetFloat8(X))
|
||||
#define DatumGetTimeTzADTP(X) ((TimeTzADT *) DatumGetPointer(X))
|
||||
|
||||
#define DateADTGetDatum(X) Int32GetDatum(X)
|
||||
#define TimeADTGetDatum(X) Float8GetDatum(X)
|
||||
#define TimeTzADTPGetDatum(X) PointerGetDatum(X)
|
||||
#endif /* HAVE_INT64_TIMESTAMP */
|
||||
|
||||
#define PG_GETARG_DATEADT(n) DatumGetDateADT(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_TIMEADT(n) DatumGetTimeADT(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_TIMETZADT_P(n) DatumGetTimeTzADTP(PG_GETARG_DATUM(n))
|
||||
|
||||
#define PG_RETURN_DATEADT(x) return DateADTGetDatum(x)
|
||||
#define PG_RETURN_TIMEADT(x) return TimeADTGetDatum(x)
|
||||
#define PG_RETURN_TIMETZADT_P(x) return TimeTzADTPGetDatum(x)
|
||||
|
||||
|
||||
/* date.c */
|
||||
extern double date2timestamp_no_overflow(DateADT dateVal);
|
||||
|
||||
extern Datum date_in(PG_FUNCTION_ARGS);
|
||||
extern Datum date_out(PG_FUNCTION_ARGS);
|
||||
extern Datum date_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum date_send(PG_FUNCTION_ARGS);
|
||||
extern Datum date_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum date_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum date_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum date_le(PG_FUNCTION_ARGS);
|
||||
extern Datum date_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum date_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum date_cmp(PG_FUNCTION_ARGS);
|
||||
extern Datum date_finite(PG_FUNCTION_ARGS);
|
||||
extern Datum date_larger(PG_FUNCTION_ARGS);
|
||||
extern Datum date_smaller(PG_FUNCTION_ARGS);
|
||||
extern Datum date_mi(PG_FUNCTION_ARGS);
|
||||
extern Datum date_pli(PG_FUNCTION_ARGS);
|
||||
extern Datum date_mii(PG_FUNCTION_ARGS);
|
||||
extern Datum date_eq_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum date_ne_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum date_lt_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum date_le_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum date_gt_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum date_ge_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum date_cmp_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum date_eq_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum date_ne_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum date_lt_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum date_le_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum date_gt_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum date_ge_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum date_cmp_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_eq_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_ne_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_lt_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_le_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_gt_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_ge_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_cmp_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_eq_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_ne_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_lt_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_le_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_gt_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_ge_date(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_cmp_date(PG_FUNCTION_ARGS);
|
||||
extern Datum date_pl_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum date_mi_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum date_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_date(PG_FUNCTION_ARGS);
|
||||
extern Datum date_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_date(PG_FUNCTION_ARGS);
|
||||
extern Datum datetime_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum abstime_date(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum time_in(PG_FUNCTION_ARGS);
|
||||
extern Datum time_out(PG_FUNCTION_ARGS);
|
||||
extern Datum time_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum time_send(PG_FUNCTION_ARGS);
|
||||
extern Datum timetypmodin(PG_FUNCTION_ARGS);
|
||||
extern Datum timetypmodout(PG_FUNCTION_ARGS);
|
||||
extern Datum time_scale(PG_FUNCTION_ARGS);
|
||||
extern Datum time_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum time_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum time_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum time_le(PG_FUNCTION_ARGS);
|
||||
extern Datum time_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum time_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum time_cmp(PG_FUNCTION_ARGS);
|
||||
extern Datum time_hash(PG_FUNCTION_ARGS);
|
||||
extern Datum overlaps_time(PG_FUNCTION_ARGS);
|
||||
extern Datum time_larger(PG_FUNCTION_ARGS);
|
||||
extern Datum time_smaller(PG_FUNCTION_ARGS);
|
||||
extern Datum time_mi_time(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_time(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_time(PG_FUNCTION_ARGS);
|
||||
extern Datum time_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_time(PG_FUNCTION_ARGS);
|
||||
extern Datum time_pl_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum time_mi_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum time_part(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timetz_in(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_out(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_send(PG_FUNCTION_ARGS);
|
||||
extern Datum timetztypmodin(PG_FUNCTION_ARGS);
|
||||
extern Datum timetztypmodout(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_scale(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_le(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_cmp(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_hash(PG_FUNCTION_ARGS);
|
||||
extern Datum overlaps_timetz(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_larger(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_smaller(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_time(PG_FUNCTION_ARGS);
|
||||
extern Datum time_timetz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_timetz(PG_FUNCTION_ARGS);
|
||||
extern Datum datetimetz_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_part(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_zone(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_izone(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_pl_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum timetz_mi_interval(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* DATE_H */
|
337
deps/libpq/include/utils/datetime.h
vendored
Normal file
337
deps/libpq/include/utils/datetime.h
vendored
Normal file
|
@ -0,0 +1,337 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* datetime.h
|
||||
* Definitions for the date/time and other date/time support code.
|
||||
* The support code is shared with other date data types,
|
||||
* including abstime, reltime, date, and time.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/datetime.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef DATETIME_H
|
||||
#define DATETIME_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "utils/timestamp.h"
|
||||
|
||||
/* this struct is declared in utils/tzparser.h: */
|
||||
struct tzEntry;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* time types + support macros
|
||||
*
|
||||
* String definitions for standard time quantities.
|
||||
*
|
||||
* These strings are the defaults used to form output time strings.
|
||||
* Other alternative forms are hardcoded into token tables in datetime.c.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define DAGO "ago"
|
||||
#define DCURRENT "current"
|
||||
#define EPOCH "epoch"
|
||||
#define INVALID "invalid"
|
||||
#define EARLY "-infinity"
|
||||
#define LATE "infinity"
|
||||
#define NOW "now"
|
||||
#define TODAY "today"
|
||||
#define TOMORROW "tomorrow"
|
||||
#define YESTERDAY "yesterday"
|
||||
#define ZULU "zulu"
|
||||
|
||||
#define DMICROSEC "usecond"
|
||||
#define DMILLISEC "msecond"
|
||||
#define DSECOND "second"
|
||||
#define DMINUTE "minute"
|
||||
#define DHOUR "hour"
|
||||
#define DDAY "day"
|
||||
#define DWEEK "week"
|
||||
#define DMONTH "month"
|
||||
#define DQUARTER "quarter"
|
||||
#define DYEAR "year"
|
||||
#define DDECADE "decade"
|
||||
#define DCENTURY "century"
|
||||
#define DMILLENNIUM "millennium"
|
||||
#define DA_D "ad"
|
||||
#define DB_C "bc"
|
||||
#define DTIMEZONE "timezone"
|
||||
|
||||
/*
|
||||
* Fundamental time field definitions for parsing.
|
||||
*
|
||||
* Meridian: am, pm, or 24-hour style.
|
||||
* Millennium: ad, bc
|
||||
*/
|
||||
|
||||
#define AM 0
|
||||
#define PM 1
|
||||
#define HR24 2
|
||||
|
||||
#define AD 0
|
||||
#define BC 1
|
||||
|
||||
/*
|
||||
* Fields for time decoding.
|
||||
*
|
||||
* Can't have more of these than there are bits in an unsigned int
|
||||
* since these are turned into bit masks during parsing and decoding.
|
||||
*
|
||||
* Furthermore, the values for YEAR, MONTH, DAY, HOUR, MINUTE, SECOND
|
||||
* must be in the range 0..14 so that the associated bitmasks can fit
|
||||
* into the left half of an INTERVAL's typmod value. Since those bits
|
||||
* are stored in typmods, you can't change them without initdb!
|
||||
*/
|
||||
|
||||
#define RESERV 0
|
||||
#define MONTH 1
|
||||
#define YEAR 2
|
||||
#define DAY 3
|
||||
#define JULIAN 4
|
||||
#define TZ 5
|
||||
#define DTZ 6
|
||||
#define DTZMOD 7
|
||||
#define IGNORE_DTF 8
|
||||
#define AMPM 9
|
||||
#define HOUR 10
|
||||
#define MINUTE 11
|
||||
#define SECOND 12
|
||||
#define MILLISECOND 13
|
||||
#define MICROSECOND 14
|
||||
#define DOY 15
|
||||
#define DOW 16
|
||||
#define UNITS 17
|
||||
#define ADBC 18
|
||||
/* these are only for relative dates */
|
||||
#define AGO 19
|
||||
#define ABS_BEFORE 20
|
||||
#define ABS_AFTER 21
|
||||
/* generic fields to help with parsing */
|
||||
#define ISODATE 22
|
||||
#define ISOTIME 23
|
||||
/* these are only for parsing intervals */
|
||||
#define WEEK 24
|
||||
#define DECADE 25
|
||||
#define CENTURY 26
|
||||
#define MILLENNIUM 27
|
||||
/* reserved for unrecognized string values */
|
||||
#define UNKNOWN_FIELD 31
|
||||
|
||||
/*
|
||||
* Token field definitions for time parsing and decoding.
|
||||
* These need to fit into the datetkn table type.
|
||||
* At the moment, that means keep them within [-127,127].
|
||||
* These are also used for bit masks in DecodeDateDelta()
|
||||
* so actually restrict them to within [0,31] for now.
|
||||
* - thomas 97/06/19
|
||||
* Not all of these fields are used for masks in DecodeDateDelta
|
||||
* so allow some larger than 31. - thomas 1997-11-17
|
||||
*/
|
||||
|
||||
#define DTK_NUMBER 0
|
||||
#define DTK_STRING 1
|
||||
|
||||
#define DTK_DATE 2
|
||||
#define DTK_TIME 3
|
||||
#define DTK_TZ 4
|
||||
#define DTK_AGO 5
|
||||
|
||||
#define DTK_SPECIAL 6
|
||||
#define DTK_INVALID 7
|
||||
#define DTK_CURRENT 8
|
||||
#define DTK_EARLY 9
|
||||
#define DTK_LATE 10
|
||||
#define DTK_EPOCH 11
|
||||
#define DTK_NOW 12
|
||||
#define DTK_YESTERDAY 13
|
||||
#define DTK_TODAY 14
|
||||
#define DTK_TOMORROW 15
|
||||
#define DTK_ZULU 16
|
||||
|
||||
#define DTK_DELTA 17
|
||||
#define DTK_SECOND 18
|
||||
#define DTK_MINUTE 19
|
||||
#define DTK_HOUR 20
|
||||
#define DTK_DAY 21
|
||||
#define DTK_WEEK 22
|
||||
#define DTK_MONTH 23
|
||||
#define DTK_QUARTER 24
|
||||
#define DTK_YEAR 25
|
||||
#define DTK_DECADE 26
|
||||
#define DTK_CENTURY 27
|
||||
#define DTK_MILLENNIUM 28
|
||||
#define DTK_MILLISEC 29
|
||||
#define DTK_MICROSEC 30
|
||||
#define DTK_JULIAN 31
|
||||
|
||||
#define DTK_DOW 32
|
||||
#define DTK_DOY 33
|
||||
#define DTK_TZ_HOUR 34
|
||||
#define DTK_TZ_MINUTE 35
|
||||
#define DTK_ISOYEAR 36
|
||||
#define DTK_ISODOW 37
|
||||
|
||||
|
||||
/*
|
||||
* Bit mask definitions for time parsing.
|
||||
*/
|
||||
|
||||
#define DTK_M(t) (0x01 << (t))
|
||||
|
||||
/* Convenience: a second, plus any fractional component */
|
||||
#define DTK_ALL_SECS_M (DTK_M(SECOND) | DTK_M(MILLISECOND) | DTK_M(MICROSECOND))
|
||||
#define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
|
||||
#define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_ALL_SECS_M)
|
||||
|
||||
#define MAXDATELEN 63 /* maximum possible length of an input date
|
||||
* string (not counting tr. null) */
|
||||
#define MAXDATEFIELDS 25 /* maximum possible number of fields in a date
|
||||
* string */
|
||||
#define TOKMAXLEN 10 /* only this many chars are stored in
|
||||
* datetktbl */
|
||||
|
||||
/* keep this struct small; it gets used a lot */
|
||||
typedef struct
|
||||
{
|
||||
char token[TOKMAXLEN];
|
||||
char type;
|
||||
char value; /* this may be unsigned, alas */
|
||||
} datetkn;
|
||||
|
||||
/* one of its uses is in tables of time zone abbreviations */
|
||||
typedef struct TimeZoneAbbrevTable
|
||||
{
|
||||
int numabbrevs;
|
||||
datetkn abbrevs[1]; /* VARIABLE LENGTH ARRAY */
|
||||
} TimeZoneAbbrevTable;
|
||||
|
||||
|
||||
/* FMODULO()
|
||||
* Macro to replace modf(), which is broken on some platforms.
|
||||
* t = input and remainder
|
||||
* q = integer part
|
||||
* u = divisor
|
||||
*/
|
||||
#define FMODULO(t,q,u) \
|
||||
do { \
|
||||
(q) = (((t) < 0) ? ceil((t) / (u)) : floor((t) / (u))); \
|
||||
if ((q) != 0) (t) -= rint((q) * (u)); \
|
||||
} while(0)
|
||||
|
||||
/* TMODULO()
|
||||
* Like FMODULO(), but work on the timestamp datatype (either int64 or float8).
|
||||
* We assume that int64 follows the C99 semantics for division (negative
|
||||
* quotients truncate towards zero).
|
||||
*/
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
#define TMODULO(t,q,u) \
|
||||
do { \
|
||||
(q) = ((t) / (u)); \
|
||||
if ((q) != 0) (t) -= ((q) * (u)); \
|
||||
} while(0)
|
||||
#else
|
||||
#define TMODULO(t,q,u) \
|
||||
do { \
|
||||
(q) = (((t) < 0) ? ceil((t) / (u)) : floor((t) / (u))); \
|
||||
if ((q) != 0) (t) -= rint((q) * (u)); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Date/time validation
|
||||
* Include check for leap year.
|
||||
*/
|
||||
|
||||
extern const int day_tab[2][13];
|
||||
|
||||
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|
||||
|
||||
|
||||
/* Julian date support for date2j() and j2date()
|
||||
*
|
||||
* IS_VALID_JULIAN checks the minimum date exactly, but is a bit sloppy
|
||||
* about the maximum, since it's far enough out to not be especially
|
||||
* interesting.
|
||||
*/
|
||||
|
||||
#define JULIAN_MINYEAR (-4713)
|
||||
#define JULIAN_MINMONTH (11)
|
||||
#define JULIAN_MINDAY (24)
|
||||
#define JULIAN_MAXYEAR (5874898)
|
||||
|
||||
#define IS_VALID_JULIAN(y,m,d) ((((y) > JULIAN_MINYEAR) \
|
||||
|| (((y) == JULIAN_MINYEAR) && (((m) > JULIAN_MINMONTH) \
|
||||
|| (((m) == JULIAN_MINMONTH) && ((d) >= JULIAN_MINDAY))))) \
|
||||
&& ((y) < JULIAN_MAXYEAR))
|
||||
|
||||
#define JULIAN_MAX (2147483494) /* == date2j(JULIAN_MAXYEAR, 1 ,1) */
|
||||
|
||||
/* Julian-date equivalents of Day 0 in Unix and Postgres reckoning */
|
||||
#define UNIX_EPOCH_JDATE 2440588 /* == date2j(1970, 1, 1) */
|
||||
#define POSTGRES_EPOCH_JDATE 2451545 /* == date2j(2000, 1, 1) */
|
||||
|
||||
|
||||
/*
|
||||
* Datetime input parsing routines (ParseDateTime, DecodeDateTime, etc)
|
||||
* return zero or a positive value on success. On failure, they return
|
||||
* one of these negative code values. DateTimeParseError may be used to
|
||||
* produce a correct ereport.
|
||||
*/
|
||||
#define DTERR_BAD_FORMAT (-1)
|
||||
#define DTERR_FIELD_OVERFLOW (-2)
|
||||
#define DTERR_MD_FIELD_OVERFLOW (-3) /* triggers hint about DateStyle */
|
||||
#define DTERR_INTERVAL_OVERFLOW (-4)
|
||||
#define DTERR_TZDISP_OVERFLOW (-5)
|
||||
|
||||
|
||||
extern void GetCurrentDateTime(struct pg_tm * tm);
|
||||
extern void GetCurrentTimeUsec(struct pg_tm * tm, fsec_t *fsec, int *tzp);
|
||||
extern void j2date(int jd, int *year, int *month, int *day);
|
||||
extern int date2j(int year, int month, int day);
|
||||
|
||||
extern int ParseDateTime(const char *timestr, char *workbuf, size_t buflen,
|
||||
char **field, int *ftype,
|
||||
int maxfields, int *numfields);
|
||||
extern int DecodeDateTime(char **field, int *ftype,
|
||||
int nf, int *dtype,
|
||||
struct pg_tm * tm, fsec_t *fsec, int *tzp);
|
||||
extern int DecodeTimeOnly(char **field, int *ftype,
|
||||
int nf, int *dtype,
|
||||
struct pg_tm * tm, fsec_t *fsec, int *tzp);
|
||||
extern int DecodeInterval(char **field, int *ftype, int nf, int range,
|
||||
int *dtype, struct pg_tm * tm, fsec_t *fsec);
|
||||
extern int DecodeISO8601Interval(char *str,
|
||||
int *dtype, struct pg_tm * tm, fsec_t *fsec);
|
||||
|
||||
extern void DateTimeParseError(int dterr, const char *str,
|
||||
const char *datatype);
|
||||
|
||||
extern int DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp);
|
||||
|
||||
extern void EncodeDateOnly(struct pg_tm * tm, int style, char *str);
|
||||
extern void EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str);
|
||||
extern void EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str);
|
||||
extern void EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str);
|
||||
|
||||
extern int DecodeSpecial(int field, char *lowtoken, int *val);
|
||||
extern int DecodeUnits(int field, char *lowtoken, int *val);
|
||||
|
||||
extern int j2day(int jd);
|
||||
|
||||
extern bool CheckDateTokenTables(void);
|
||||
|
||||
extern void ConvertTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl,
|
||||
struct tzEntry *abbrevs, int n);
|
||||
extern void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl);
|
||||
|
||||
extern Datum pg_timezone_abbrevs(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_timezone_names(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* DATETIME_H */
|
49
deps/libpq/include/utils/datum.h
vendored
Normal file
49
deps/libpq/include/utils/datum.h
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* datum.h
|
||||
* POSTGRES Datum (abstract data type) manipulation routines.
|
||||
*
|
||||
* These routines are driven by the 'typbyval' and 'typlen' information,
|
||||
* which must previously have been obtained by the caller for the datatype
|
||||
* of the Datum. (We do it this way because in most situations the caller
|
||||
* can look up the info just once and use it for many per-datum operations.)
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/datum.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef DATUM_H
|
||||
#define DATUM_H
|
||||
|
||||
/*
|
||||
* datumGetSize - find the "real" length of a datum
|
||||
*/
|
||||
extern Size datumGetSize(Datum value, bool typByVal, int typLen);
|
||||
|
||||
/*
|
||||
* datumCopy - make a copy of a datum.
|
||||
*
|
||||
* If the datatype is pass-by-reference, memory is obtained with palloc().
|
||||
*/
|
||||
extern Datum datumCopy(Datum value, bool typByVal, int typLen);
|
||||
|
||||
/*
|
||||
* datumFree - free a datum previously allocated by datumCopy, if any.
|
||||
*
|
||||
* Does nothing if datatype is pass-by-value.
|
||||
*/
|
||||
extern void datumFree(Datum value, bool typByVal, int typLen);
|
||||
|
||||
/*
|
||||
* datumIsEqual
|
||||
* return true if two datums of the same type are equal, false otherwise.
|
||||
*
|
||||
* XXX : See comments in the code for restrictions!
|
||||
*/
|
||||
extern bool datumIsEqual(Datum value1, Datum value2,
|
||||
bool typByVal, int typLen);
|
||||
|
||||
#endif /* DATUM_H */
|
19
deps/libpq/include/utils/dynahash.h
vendored
Normal file
19
deps/libpq/include/utils/dynahash.h
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* dynahash
|
||||
* POSTGRES dynahash.h file definitions
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/dynahash.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef DYNAHASH_H
|
||||
#define DYNAHASH_H
|
||||
|
||||
extern int my_log2(long num);
|
||||
|
||||
#endif /* DYNAHASH_H */
|
25
deps/libpq/include/utils/dynamic_loader.h
vendored
Normal file
25
deps/libpq/include/utils/dynamic_loader.h
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* dynamic_loader.h
|
||||
*
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/dynamic_loader.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef DYNAMIC_LOADER_H
|
||||
#define DYNAMIC_LOADER_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
|
||||
extern void *pg_dlopen(char *filename);
|
||||
extern PGFunction pg_dlsym(void *handle, char *funcname);
|
||||
extern void pg_dlclose(void *handle);
|
||||
extern char *pg_dlerror(void);
|
||||
|
||||
#endif /* DYNAMIC_LOADER_H */
|
377
deps/libpq/include/utils/elog.h
vendored
Normal file
377
deps/libpq/include/utils/elog.h
vendored
Normal file
|
@ -0,0 +1,377 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* elog.h
|
||||
* POSTGRES error reporting/logging definitions.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/elog.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef ELOG_H
|
||||
#define ELOG_H
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
/* Error level codes */
|
||||
#define DEBUG5 10 /* Debugging messages, in categories of
|
||||
* decreasing detail. */
|
||||
#define DEBUG4 11
|
||||
#define DEBUG3 12
|
||||
#define DEBUG2 13
|
||||
#define DEBUG1 14 /* used by GUC debug_* variables */
|
||||
#define LOG 15 /* Server operational messages; sent only to
|
||||
* server log by default. */
|
||||
#define COMMERROR 16 /* Client communication problems; same as LOG
|
||||
* for server reporting, but never sent to
|
||||
* client. */
|
||||
#define INFO 17 /* Messages specifically requested by user (eg
|
||||
* VACUUM VERBOSE output); always sent to
|
||||
* client regardless of client_min_messages,
|
||||
* but by default not sent to server log. */
|
||||
#define NOTICE 18 /* Helpful messages to users about query
|
||||
* operation; sent to client and server log by
|
||||
* default. */
|
||||
#define WARNING 19 /* Warnings. NOTICE is for expected messages
|
||||
* like implicit sequence creation by SERIAL.
|
||||
* WARNING is for unexpected messages. */
|
||||
#define ERROR 20 /* user error - abort transaction; return to
|
||||
* known state */
|
||||
/* Save ERROR value in PGERROR so it can be restored when Win32 includes
|
||||
* modify it. We have to use a constant rather than ERROR because macros
|
||||
* are expanded only when referenced outside macros.
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#define PGERROR 20
|
||||
#endif
|
||||
#define FATAL 21 /* fatal error - abort process */
|
||||
#define PANIC 22 /* take down the other backends with me */
|
||||
|
||||
/* #define DEBUG DEBUG1 */ /* Backward compatibility with pre-7.3 */
|
||||
|
||||
|
||||
/* macros for representing SQLSTATE strings compactly */
|
||||
#define PGSIXBIT(ch) (((ch) - '0') & 0x3F)
|
||||
#define PGUNSIXBIT(val) (((val) & 0x3F) + '0')
|
||||
|
||||
#define MAKE_SQLSTATE(ch1,ch2,ch3,ch4,ch5) \
|
||||
(PGSIXBIT(ch1) + (PGSIXBIT(ch2) << 6) + (PGSIXBIT(ch3) << 12) + \
|
||||
(PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24))
|
||||
|
||||
/* These macros depend on the fact that '0' becomes a zero in SIXBIT */
|
||||
#define ERRCODE_TO_CATEGORY(ec) ((ec) & ((1 << 12) - 1))
|
||||
#define ERRCODE_IS_CATEGORY(ec) (((ec) & ~((1 << 12) - 1)) == 0)
|
||||
|
||||
/* SQLSTATE codes for errors are defined in a separate file */
|
||||
#include "utils/errcodes.h"
|
||||
|
||||
|
||||
/* Which __func__ symbol do we have, if any? */
|
||||
#ifdef HAVE_FUNCNAME__FUNC
|
||||
#define PG_FUNCNAME_MACRO __func__
|
||||
#else
|
||||
#ifdef HAVE_FUNCNAME__FUNCTION
|
||||
#define PG_FUNCNAME_MACRO __FUNCTION__
|
||||
#else
|
||||
#define PG_FUNCNAME_MACRO NULL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*----------
|
||||
* New-style error reporting API: to be used in this way:
|
||||
* ereport(ERROR,
|
||||
* (errcode(ERRCODE_UNDEFINED_CURSOR),
|
||||
* errmsg("portal \"%s\" not found", stmt->portalname),
|
||||
* ... other errxxx() fields as needed ...));
|
||||
*
|
||||
* The error level is required, and so is a primary error message (errmsg
|
||||
* or errmsg_internal). All else is optional. errcode() defaults to
|
||||
* ERRCODE_INTERNAL_ERROR if elevel is ERROR or more, ERRCODE_WARNING
|
||||
* if elevel is WARNING, or ERRCODE_SUCCESSFUL_COMPLETION if elevel is
|
||||
* NOTICE or below.
|
||||
*
|
||||
* ereport_domain() allows a message domain to be specified, for modules that
|
||||
* wish to use a different message catalog from the backend's. To avoid having
|
||||
* one copy of the default text domain per .o file, we define it as NULL here
|
||||
* and have errstart insert the default text domain. Modules can either use
|
||||
* ereport_domain() directly, or preferably they can override the TEXTDOMAIN
|
||||
* macro.
|
||||
*----------
|
||||
*/
|
||||
#define ereport_domain(elevel, domain, rest) \
|
||||
(errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain) ? \
|
||||
(errfinish rest) : (void) 0)
|
||||
|
||||
#define ereport(elevel, rest) \
|
||||
ereport_domain(elevel, TEXTDOMAIN, rest)
|
||||
|
||||
#define TEXTDOMAIN NULL
|
||||
|
||||
extern bool errstart(int elevel, const char *filename, int lineno,
|
||||
const char *funcname, const char *domain);
|
||||
extern void errfinish(int dummy,...);
|
||||
|
||||
extern int errcode(int sqlerrcode);
|
||||
|
||||
extern int errcode_for_file_access(void);
|
||||
extern int errcode_for_socket_access(void);
|
||||
|
||||
extern int
|
||||
errmsg(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errmsg_internal(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errmsg_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
unsigned long n,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4)))
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4)));
|
||||
|
||||
extern int
|
||||
errdetail(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errdetail_internal(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errdetail_log(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errdetail_plural(const char *fmt_singular, const char *fmt_plural,
|
||||
unsigned long n,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4)))
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4)));
|
||||
|
||||
extern int
|
||||
errhint(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int
|
||||
errcontext(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
extern int errhidestmt(bool hide_stmt);
|
||||
|
||||
extern int errfunction(const char *funcname);
|
||||
extern int errposition(int cursorpos);
|
||||
|
||||
extern int internalerrposition(int cursorpos);
|
||||
extern int internalerrquery(const char *query);
|
||||
|
||||
extern int geterrcode(void);
|
||||
extern int geterrposition(void);
|
||||
extern int getinternalerrposition(void);
|
||||
|
||||
|
||||
/*----------
|
||||
* Old-style error reporting API: to be used in this way:
|
||||
* elog(ERROR, "portal \"%s\" not found", stmt->portalname);
|
||||
*----------
|
||||
*/
|
||||
#define elog elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO), elog_finish
|
||||
|
||||
extern void elog_start(const char *filename, int lineno, const char *funcname);
|
||||
extern void
|
||||
elog_finish(int elevel, const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
|
||||
/* Support for constructing error strings separately from ereport() calls */
|
||||
|
||||
extern void pre_format_elog_string(int errnumber, const char *domain);
|
||||
extern char *
|
||||
format_elog_string(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
|
||||
/* Support for attaching context information to error reports */
|
||||
|
||||
typedef struct ErrorContextCallback
|
||||
{
|
||||
struct ErrorContextCallback *previous;
|
||||
void (*callback) (void *arg);
|
||||
void *arg;
|
||||
} ErrorContextCallback;
|
||||
|
||||
extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
|
||||
|
||||
|
||||
/*----------
|
||||
* API for catching ereport(ERROR) exits. Use these macros like so:
|
||||
*
|
||||
* PG_TRY();
|
||||
* {
|
||||
* ... code that might throw ereport(ERROR) ...
|
||||
* }
|
||||
* PG_CATCH();
|
||||
* {
|
||||
* ... error recovery code ...
|
||||
* }
|
||||
* PG_END_TRY();
|
||||
*
|
||||
* (The braces are not actually necessary, but are recommended so that
|
||||
* pg_indent will indent the construct nicely.) The error recovery code
|
||||
* can optionally do PG_RE_THROW() to propagate the same error outwards.
|
||||
*
|
||||
* Note: while the system will correctly propagate any new ereport(ERROR)
|
||||
* occurring in the recovery section, there is a small limit on the number
|
||||
* of levels this will work for. It's best to keep the error recovery
|
||||
* section simple enough that it can't generate any new errors, at least
|
||||
* not before popping the error stack.
|
||||
*
|
||||
* Note: an ereport(FATAL) will not be caught by this construct; control will
|
||||
* exit straight through proc_exit(). Therefore, do NOT put any cleanup
|
||||
* of non-process-local resources into the error recovery section, at least
|
||||
* not without taking thought for what will happen during ereport(FATAL).
|
||||
* The PG_ENSURE_ERROR_CLEANUP macros provided by storage/ipc.h may be
|
||||
* helpful in such cases.
|
||||
*----------
|
||||
*/
|
||||
#define PG_TRY() \
|
||||
do { \
|
||||
sigjmp_buf *save_exception_stack = PG_exception_stack; \
|
||||
ErrorContextCallback *save_context_stack = error_context_stack; \
|
||||
sigjmp_buf local_sigjmp_buf; \
|
||||
if (sigsetjmp(local_sigjmp_buf, 0) == 0) \
|
||||
{ \
|
||||
PG_exception_stack = &local_sigjmp_buf
|
||||
|
||||
#define PG_CATCH() \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
PG_exception_stack = save_exception_stack; \
|
||||
error_context_stack = save_context_stack
|
||||
|
||||
#define PG_END_TRY() \
|
||||
} \
|
||||
PG_exception_stack = save_exception_stack; \
|
||||
error_context_stack = save_context_stack; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* gcc understands __attribute__((noreturn)); for other compilers, insert
|
||||
* a useless exit() call so that the compiler gets the point.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define PG_RE_THROW() \
|
||||
pg_re_throw()
|
||||
#else
|
||||
#define PG_RE_THROW() \
|
||||
(pg_re_throw(), exit(1))
|
||||
#endif
|
||||
|
||||
extern PGDLLIMPORT sigjmp_buf *PG_exception_stack;
|
||||
|
||||
|
||||
/* Stuff that error handlers might want to use */
|
||||
|
||||
/*
|
||||
* ErrorData holds the data accumulated during any one ereport() cycle.
|
||||
* Any non-NULL pointers must point to palloc'd data.
|
||||
* (The const pointers are an exception; we assume they point at non-freeable
|
||||
* constant strings.)
|
||||
*/
|
||||
typedef struct ErrorData
|
||||
{
|
||||
int elevel; /* error level */
|
||||
bool output_to_server; /* will report to server log? */
|
||||
bool output_to_client; /* will report to client? */
|
||||
bool show_funcname; /* true to force funcname inclusion */
|
||||
bool hide_stmt; /* true to prevent STATEMENT: inclusion */
|
||||
const char *filename; /* __FILE__ of ereport() call */
|
||||
int lineno; /* __LINE__ of ereport() call */
|
||||
const char *funcname; /* __func__ of ereport() call */
|
||||
const char *domain; /* message domain */
|
||||
int sqlerrcode; /* encoded ERRSTATE */
|
||||
char *message; /* primary error message */
|
||||
char *detail; /* detail error message */
|
||||
char *detail_log; /* detail error message for server log only */
|
||||
char *hint; /* hint message */
|
||||
char *context; /* context message */
|
||||
int cursorpos; /* cursor index into query string */
|
||||
int internalpos; /* cursor index into internalquery */
|
||||
char *internalquery; /* text of internally-generated query */
|
||||
int saved_errno; /* errno at entry */
|
||||
} ErrorData;
|
||||
|
||||
extern void EmitErrorReport(void);
|
||||
extern ErrorData *CopyErrorData(void);
|
||||
extern void FreeErrorData(ErrorData *edata);
|
||||
extern void FlushErrorState(void);
|
||||
extern void ReThrowError(ErrorData *edata);
|
||||
extern void pg_re_throw(void) __attribute__((noreturn));
|
||||
|
||||
|
||||
/* GUC-configurable parameters */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PGERROR_TERSE, /* single-line error messages */
|
||||
PGERROR_DEFAULT, /* recommended style */
|
||||
PGERROR_VERBOSE /* all the facts, ma'am */
|
||||
} PGErrorVerbosity;
|
||||
|
||||
extern int Log_error_verbosity;
|
||||
extern char *Log_line_prefix;
|
||||
extern int Log_destination;
|
||||
|
||||
/* Log destination bitmap */
|
||||
#define LOG_DESTINATION_STDERR 1
|
||||
#define LOG_DESTINATION_SYSLOG 2
|
||||
#define LOG_DESTINATION_EVENTLOG 4
|
||||
#define LOG_DESTINATION_CSVLOG 8
|
||||
|
||||
/* Other exported functions */
|
||||
extern void DebugFileOpen(void);
|
||||
extern char *unpack_sql_state(int sql_state);
|
||||
extern bool in_error_recursion_trouble(void);
|
||||
|
||||
#ifdef HAVE_SYSLOG
|
||||
extern void set_syslog_parameters(const char *ident, int facility);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Write errors to stderr (or by equal means when stderr is
|
||||
* not available). Used before ereport/elog can be used
|
||||
* safely (memory context, GUC load etc)
|
||||
*/
|
||||
extern void
|
||||
write_stderr(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
|
||||
#endif /* ELOG_H */
|
39
deps/libpq/include/utils/fmgrtab.h
vendored
Normal file
39
deps/libpq/include/utils/fmgrtab.h
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* fmgrtab.h
|
||||
* The function manager's table of internal functions.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/fmgrtab.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef FMGRTAB_H
|
||||
#define FMGRTAB_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
|
||||
/*
|
||||
* This table stores info about all the built-in functions (ie, functions
|
||||
* that are compiled into the Postgres executable). The table entries are
|
||||
* required to appear in Oid order, so that binary search can be used.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Oid foid; /* OID of the function */
|
||||
const char *funcName; /* C name of the function */
|
||||
short nargs; /* 0..FUNC_MAX_ARGS, or -1 if variable count */
|
||||
bool strict; /* T if function is "strict" */
|
||||
bool retset; /* T if function returns a set */
|
||||
PGFunction func; /* pointer to compiled function */
|
||||
} FmgrBuiltin;
|
||||
|
||||
extern const FmgrBuiltin fmgr_builtins[];
|
||||
|
||||
extern const int fmgr_nbuiltins; /* number of entries in table */
|
||||
|
||||
#endif /* FMGRTAB_H */
|
39
deps/libpq/include/utils/formatting.h
vendored
Normal file
39
deps/libpq/include/utils/formatting.h
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* -----------------------------------------------------------------------
|
||||
* formatting.h
|
||||
*
|
||||
* src/include/utils/formatting.h
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1999-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
* The PostgreSQL routines for a DateTime/int/float/numeric formatting,
|
||||
* inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines.
|
||||
*
|
||||
* Karel Zak
|
||||
*
|
||||
* -----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _FORMATTING_H_
|
||||
#define _FORMATTING_H_
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
|
||||
extern char *str_tolower(const char *buff, size_t nbytes, Oid collid);
|
||||
extern char *str_toupper(const char *buff, size_t nbytes, Oid collid);
|
||||
extern char *str_initcap(const char *buff, size_t nbytes, Oid collid);
|
||||
|
||||
extern Datum timestamp_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum to_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum to_date(PG_FUNCTION_ARGS);
|
||||
extern Datum numeric_to_number(PG_FUNCTION_ARGS);
|
||||
extern Datum numeric_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum int4_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum int8_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum float4_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum float8_to_char(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif
|
437
deps/libpq/include/utils/geo_decls.h
vendored
Normal file
437
deps/libpq/include/utils/geo_decls.h
vendored
Normal file
|
@ -0,0 +1,437 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* geo_decls.h - Declarations for various 2D constructs.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/geo_decls.h
|
||||
*
|
||||
* NOTE
|
||||
* These routines do *not* use the float types from adt/.
|
||||
*
|
||||
* XXX These routines were not written by a numerical analyst.
|
||||
*
|
||||
* XXX I have made some attempt to flesh out the operators
|
||||
* and data types. There are still some more to do. - tgl 97/04/19
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef GEO_DECLS_H
|
||||
#define GEO_DECLS_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
* Useful floating point utilities and constants.
|
||||
*-------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define EPSILON 1.0E-06
|
||||
|
||||
#ifdef EPSILON
|
||||
#define FPzero(A) (fabs(A) <= EPSILON)
|
||||
#define FPeq(A,B) (fabs((A) - (B)) <= EPSILON)
|
||||
#define FPne(A,B) (fabs((A) - (B)) > EPSILON)
|
||||
#define FPlt(A,B) ((B) - (A) > EPSILON)
|
||||
#define FPle(A,B) ((A) - (B) <= EPSILON)
|
||||
#define FPgt(A,B) ((A) - (B) > EPSILON)
|
||||
#define FPge(A,B) ((B) - (A) <= EPSILON)
|
||||
#else
|
||||
#define FPzero(A) ((A) == 0)
|
||||
#define FPeq(A,B) ((A) == (B))
|
||||
#define FPne(A,B) ((A) != (B))
|
||||
#define FPlt(A,B) ((A) < (B))
|
||||
#define FPle(A,B) ((A) <= (B))
|
||||
#define FPgt(A,B) ((A) > (B))
|
||||
#define FPge(A,B) ((A) >= (B))
|
||||
#endif
|
||||
|
||||
#define HYPOT(A, B) pg_hypot(A, B)
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* Point - (x,y)
|
||||
*-------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
double x,
|
||||
y;
|
||||
} Point;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* LSEG - A straight line, specified by endpoints.
|
||||
*-------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
Point p[2];
|
||||
|
||||
double m; /* precomputed to save time, not in tuple */
|
||||
} LSEG;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* PATH - Specified by vertex points.
|
||||
*-------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
int32 npts;
|
||||
int32 closed; /* is this a closed polygon? */
|
||||
int32 dummy; /* padding to make it double align */
|
||||
Point p[1]; /* variable length array of POINTs */
|
||||
} PATH;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* LINE - Specified by its general equation (Ax+By+C=0).
|
||||
* If there is a y-intercept, it is C, which
|
||||
* incidentally gives a freebie point on the line
|
||||
* (if B=0, then C is the x-intercept).
|
||||
* Slope m is precalculated to save time; if
|
||||
* the line is not vertical, m == A.
|
||||
*-------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
double A,
|
||||
B,
|
||||
C;
|
||||
|
||||
double m;
|
||||
} LINE;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* BOX - Specified by two corner points, which are
|
||||
* sorted to save calculation time later.
|
||||
*-------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
Point high,
|
||||
low; /* corner POINTs */
|
||||
} BOX;
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* POLYGON - Specified by an array of doubles defining the points,
|
||||
* keeping the number of points and the bounding box for
|
||||
* speed purposes.
|
||||
*-------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
int32 npts;
|
||||
BOX boundbox;
|
||||
Point p[1]; /* variable length array of POINTs */
|
||||
} POLYGON;
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* CIRCLE - Specified by a center point and radius.
|
||||
*-------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
Point center;
|
||||
double radius;
|
||||
} CIRCLE;
|
||||
|
||||
/*
|
||||
* fmgr interface macros
|
||||
*
|
||||
* Path and Polygon are toastable varlena types, the others are just
|
||||
* fixed-size pass-by-reference types.
|
||||
*/
|
||||
|
||||
#define DatumGetPointP(X) ((Point *) DatumGetPointer(X))
|
||||
#define PointPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_POINT_P(n) DatumGetPointP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_POINT_P(x) return PointPGetDatum(x)
|
||||
|
||||
#define DatumGetLsegP(X) ((LSEG *) DatumGetPointer(X))
|
||||
#define LsegPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_LSEG_P(n) DatumGetLsegP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_LSEG_P(x) return LsegPGetDatum(x)
|
||||
|
||||
#define DatumGetPathP(X) ((PATH *) PG_DETOAST_DATUM(X))
|
||||
#define DatumGetPathPCopy(X) ((PATH *) PG_DETOAST_DATUM_COPY(X))
|
||||
#define PathPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_PATH_P(n) DatumGetPathP(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_PATH_P_COPY(n) DatumGetPathPCopy(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_PATH_P(x) return PathPGetDatum(x)
|
||||
|
||||
#define DatumGetLineP(X) ((LINE *) DatumGetPointer(X))
|
||||
#define LinePGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_LINE_P(n) DatumGetLineP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_LINE_P(x) return LinePGetDatum(x)
|
||||
|
||||
#define DatumGetBoxP(X) ((BOX *) DatumGetPointer(X))
|
||||
#define BoxPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_BOX_P(n) DatumGetBoxP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_BOX_P(x) return BoxPGetDatum(x)
|
||||
|
||||
#define DatumGetPolygonP(X) ((POLYGON *) PG_DETOAST_DATUM(X))
|
||||
#define DatumGetPolygonPCopy(X) ((POLYGON *) PG_DETOAST_DATUM_COPY(X))
|
||||
#define PolygonPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_POLYGON_P(n) DatumGetPolygonP(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_POLYGON_P_COPY(n) DatumGetPolygonPCopy(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_POLYGON_P(x) return PolygonPGetDatum(x)
|
||||
|
||||
#define DatumGetCircleP(X) ((CIRCLE *) DatumGetPointer(X))
|
||||
#define CirclePGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_CIRCLE_P(n) DatumGetCircleP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_CIRCLE_P(x) return CirclePGetDatum(x)
|
||||
|
||||
|
||||
/*
|
||||
* in geo_ops.h
|
||||
*/
|
||||
|
||||
/* public point routines */
|
||||
extern Datum point_in(PG_FUNCTION_ARGS);
|
||||
extern Datum point_out(PG_FUNCTION_ARGS);
|
||||
extern Datum point_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum point_send(PG_FUNCTION_ARGS);
|
||||
extern Datum construct_point(PG_FUNCTION_ARGS);
|
||||
extern Datum point_left(PG_FUNCTION_ARGS);
|
||||
extern Datum point_right(PG_FUNCTION_ARGS);
|
||||
extern Datum point_above(PG_FUNCTION_ARGS);
|
||||
extern Datum point_below(PG_FUNCTION_ARGS);
|
||||
extern Datum point_vert(PG_FUNCTION_ARGS);
|
||||
extern Datum point_horiz(PG_FUNCTION_ARGS);
|
||||
extern Datum point_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum point_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum point_distance(PG_FUNCTION_ARGS);
|
||||
extern Datum point_slope(PG_FUNCTION_ARGS);
|
||||
extern Datum point_add(PG_FUNCTION_ARGS);
|
||||
extern Datum point_sub(PG_FUNCTION_ARGS);
|
||||
extern Datum point_mul(PG_FUNCTION_ARGS);
|
||||
extern Datum point_div(PG_FUNCTION_ARGS);
|
||||
|
||||
/* private routines */
|
||||
extern double point_dt(Point *pt1, Point *pt2);
|
||||
extern double point_sl(Point *pt1, Point *pt2);
|
||||
extern double pg_hypot(double x, double y);
|
||||
|
||||
/* public lseg routines */
|
||||
extern Datum lseg_in(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_out(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_send(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_intersect(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_parallel(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_perp(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_vertical(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_horizontal(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_le(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_construct(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_length(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_distance(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_center(PG_FUNCTION_ARGS);
|
||||
extern Datum lseg_interpt(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_pl(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_ps(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_ppath(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_pb(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_sl(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_sb(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_lb(PG_FUNCTION_ARGS);
|
||||
extern Datum close_lseg(PG_FUNCTION_ARGS);
|
||||
extern Datum close_pl(PG_FUNCTION_ARGS);
|
||||
extern Datum close_ps(PG_FUNCTION_ARGS);
|
||||
extern Datum close_pb(PG_FUNCTION_ARGS);
|
||||
extern Datum close_sl(PG_FUNCTION_ARGS);
|
||||
extern Datum close_sb(PG_FUNCTION_ARGS);
|
||||
extern Datum close_ls(PG_FUNCTION_ARGS);
|
||||
extern Datum close_lb(PG_FUNCTION_ARGS);
|
||||
extern Datum on_pl(PG_FUNCTION_ARGS);
|
||||
extern Datum on_ps(PG_FUNCTION_ARGS);
|
||||
extern Datum on_pb(PG_FUNCTION_ARGS);
|
||||
extern Datum on_ppath(PG_FUNCTION_ARGS);
|
||||
extern Datum on_sl(PG_FUNCTION_ARGS);
|
||||
extern Datum on_sb(PG_FUNCTION_ARGS);
|
||||
extern Datum inter_sl(PG_FUNCTION_ARGS);
|
||||
extern Datum inter_sb(PG_FUNCTION_ARGS);
|
||||
extern Datum inter_lb(PG_FUNCTION_ARGS);
|
||||
|
||||
/* public line routines */
|
||||
extern Datum line_in(PG_FUNCTION_ARGS);
|
||||
extern Datum line_out(PG_FUNCTION_ARGS);
|
||||
extern Datum line_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum line_send(PG_FUNCTION_ARGS);
|
||||
extern Datum line_interpt(PG_FUNCTION_ARGS);
|
||||
extern Datum line_distance(PG_FUNCTION_ARGS);
|
||||
extern Datum line_construct_pp(PG_FUNCTION_ARGS);
|
||||
extern Datum line_intersect(PG_FUNCTION_ARGS);
|
||||
extern Datum line_parallel(PG_FUNCTION_ARGS);
|
||||
extern Datum line_perp(PG_FUNCTION_ARGS);
|
||||
extern Datum line_vertical(PG_FUNCTION_ARGS);
|
||||
extern Datum line_horizontal(PG_FUNCTION_ARGS);
|
||||
extern Datum line_eq(PG_FUNCTION_ARGS);
|
||||
|
||||
/* public box routines */
|
||||
extern Datum box_in(PG_FUNCTION_ARGS);
|
||||
extern Datum box_out(PG_FUNCTION_ARGS);
|
||||
extern Datum box_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum box_send(PG_FUNCTION_ARGS);
|
||||
extern Datum box_same(PG_FUNCTION_ARGS);
|
||||
extern Datum box_overlap(PG_FUNCTION_ARGS);
|
||||
extern Datum box_left(PG_FUNCTION_ARGS);
|
||||
extern Datum box_overleft(PG_FUNCTION_ARGS);
|
||||
extern Datum box_right(PG_FUNCTION_ARGS);
|
||||
extern Datum box_overright(PG_FUNCTION_ARGS);
|
||||
extern Datum box_below(PG_FUNCTION_ARGS);
|
||||
extern Datum box_overbelow(PG_FUNCTION_ARGS);
|
||||
extern Datum box_above(PG_FUNCTION_ARGS);
|
||||
extern Datum box_overabove(PG_FUNCTION_ARGS);
|
||||
extern Datum box_contained(PG_FUNCTION_ARGS);
|
||||
extern Datum box_contain(PG_FUNCTION_ARGS);
|
||||
extern Datum box_contain_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum box_below_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum box_above_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum box_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum box_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum box_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum box_le(PG_FUNCTION_ARGS);
|
||||
extern Datum box_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum box_area(PG_FUNCTION_ARGS);
|
||||
extern Datum box_width(PG_FUNCTION_ARGS);
|
||||
extern Datum box_height(PG_FUNCTION_ARGS);
|
||||
extern Datum box_distance(PG_FUNCTION_ARGS);
|
||||
extern Datum box_center(PG_FUNCTION_ARGS);
|
||||
extern Datum box_intersect(PG_FUNCTION_ARGS);
|
||||
extern Datum box_diagonal(PG_FUNCTION_ARGS);
|
||||
extern Datum points_box(PG_FUNCTION_ARGS);
|
||||
extern Datum box_add(PG_FUNCTION_ARGS);
|
||||
extern Datum box_sub(PG_FUNCTION_ARGS);
|
||||
extern Datum box_mul(PG_FUNCTION_ARGS);
|
||||
extern Datum box_div(PG_FUNCTION_ARGS);
|
||||
|
||||
/* public path routines */
|
||||
extern Datum path_area(PG_FUNCTION_ARGS);
|
||||
extern Datum path_in(PG_FUNCTION_ARGS);
|
||||
extern Datum path_out(PG_FUNCTION_ARGS);
|
||||
extern Datum path_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum path_send(PG_FUNCTION_ARGS);
|
||||
extern Datum path_n_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum path_n_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum path_n_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum path_n_le(PG_FUNCTION_ARGS);
|
||||
extern Datum path_n_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum path_inter(PG_FUNCTION_ARGS);
|
||||
extern Datum path_distance(PG_FUNCTION_ARGS);
|
||||
extern Datum path_length(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum path_isclosed(PG_FUNCTION_ARGS);
|
||||
extern Datum path_isopen(PG_FUNCTION_ARGS);
|
||||
extern Datum path_npoints(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum path_close(PG_FUNCTION_ARGS);
|
||||
extern Datum path_open(PG_FUNCTION_ARGS);
|
||||
extern Datum path_add(PG_FUNCTION_ARGS);
|
||||
extern Datum path_add_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum path_sub_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum path_mul_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum path_div_pt(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum path_center(PG_FUNCTION_ARGS);
|
||||
extern Datum path_poly(PG_FUNCTION_ARGS);
|
||||
|
||||
/* public polygon routines */
|
||||
extern Datum poly_in(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_out(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_send(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_left(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_overleft(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_right(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_overright(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_below(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_overbelow(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_above(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_overabove(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_same(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_overlap(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_contain(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_contained(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_contain_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum pt_contained_poly(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_distance(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_npoints(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_center(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_box(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_path(PG_FUNCTION_ARGS);
|
||||
extern Datum box_poly(PG_FUNCTION_ARGS);
|
||||
|
||||
/* public circle routines */
|
||||
extern Datum circle_in(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_out(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_send(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_same(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_overlap(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_overleft(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_left(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_right(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_overright(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_contained(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_contain(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_below(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_above(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_overbelow(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_overabove(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_le(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_contain_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum pt_contained_circle(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_add_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_sub_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_mul_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_div_pt(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_diameter(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_radius(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_distance(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_pc(PG_FUNCTION_ARGS);
|
||||
extern Datum dist_cpoly(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_center(PG_FUNCTION_ARGS);
|
||||
extern Datum cr_circle(PG_FUNCTION_ARGS);
|
||||
extern Datum box_circle(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_box(PG_FUNCTION_ARGS);
|
||||
extern Datum poly_circle(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_poly(PG_FUNCTION_ARGS);
|
||||
extern Datum circle_area(PG_FUNCTION_ARGS);
|
||||
|
||||
/* support routines for the GiST access method (access/gist/gistproc.c) */
|
||||
extern Datum gist_box_compress(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_box_decompress(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_box_union(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_box_picksplit(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_box_consistent(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_box_penalty(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_box_same(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_poly_compress(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_poly_consistent(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_circle_compress(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_circle_consistent(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_point_compress(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_point_consistent(PG_FUNCTION_ARGS);
|
||||
extern Datum gist_point_distance(PG_FUNCTION_ARGS);
|
||||
|
||||
/* geo_selfuncs.c */
|
||||
extern Datum areasel(PG_FUNCTION_ARGS);
|
||||
extern Datum areajoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum positionsel(PG_FUNCTION_ARGS);
|
||||
extern Datum positionjoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum contsel(PG_FUNCTION_ARGS);
|
||||
extern Datum contjoinsel(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* GEO_DECLS_H */
|
381
deps/libpq/include/utils/guc.h
vendored
Normal file
381
deps/libpq/include/utils/guc.h
vendored
Normal file
|
@ -0,0 +1,381 @@
|
|||
/*--------------------------------------------------------------------
|
||||
* guc.h
|
||||
*
|
||||
* External declarations pertaining to backend/utils/misc/guc.c and
|
||||
* backend/utils/misc/guc-file.l
|
||||
*
|
||||
* Copyright (c) 2000-2011, PostgreSQL Global Development Group
|
||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||
*
|
||||
* src/include/utils/guc.h
|
||||
*--------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef GUC_H
|
||||
#define GUC_H
|
||||
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "tcop/dest.h"
|
||||
#include "utils/array.h"
|
||||
|
||||
|
||||
/*
|
||||
* Certain options can only be set at certain times. The rules are
|
||||
* like this:
|
||||
*
|
||||
* INTERNAL options cannot be set by the user at all, but only through
|
||||
* internal processes ("server_version" is an example). These are GUC
|
||||
* variables only so they can be shown by SHOW, etc.
|
||||
*
|
||||
* POSTMASTER options can only be set when the postmaster starts,
|
||||
* either from the configuration file or the command line.
|
||||
*
|
||||
* SIGHUP options can only be set at postmaster startup or by changing
|
||||
* the configuration file and sending the HUP signal to the postmaster
|
||||
* or a backend process. (Notice that the signal receipt will not be
|
||||
* evaluated immediately. The postmaster and the backend check it at a
|
||||
* certain point in their main loop. It's safer to wait than to read a
|
||||
* file asynchronously.)
|
||||
*
|
||||
* BACKEND options can only be set at postmaster startup, from the
|
||||
* configuration file, or by client request in the connection startup
|
||||
* packet (e.g., from libpq's PGOPTIONS variable). Furthermore, an
|
||||
* already-started backend will ignore changes to such an option in the
|
||||
* configuration file. The idea is that these options are fixed for a
|
||||
* given backend once it's started, but they can vary across backends.
|
||||
*
|
||||
* SUSET options can be set at postmaster startup, with the SIGHUP
|
||||
* mechanism, or from SQL if you're a superuser.
|
||||
*
|
||||
* USERSET options can be set by anyone any time.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PGC_INTERNAL,
|
||||
PGC_POSTMASTER,
|
||||
PGC_SIGHUP,
|
||||
PGC_BACKEND,
|
||||
PGC_SUSET,
|
||||
PGC_USERSET
|
||||
} GucContext;
|
||||
|
||||
/*
|
||||
* The following type records the source of the current setting. A
|
||||
* new setting can only take effect if the previous setting had the
|
||||
* same or lower level. (E.g, changing the config file doesn't
|
||||
* override the postmaster command line.) Tracking the source allows us
|
||||
* to process sources in any convenient order without affecting results.
|
||||
* Sources <= PGC_S_OVERRIDE will set the default used by RESET, as well
|
||||
* as the current value. Note that source == PGC_S_OVERRIDE should be
|
||||
* used when setting a PGC_INTERNAL option.
|
||||
*
|
||||
* PGC_S_INTERACTIVE isn't actually a source value, but is the
|
||||
* dividing line between "interactive" and "non-interactive" sources for
|
||||
* error reporting purposes.
|
||||
*
|
||||
* PGC_S_TEST is used when testing values to be stored as per-database or
|
||||
* per-user defaults ("doit" will always be false, so this never gets stored
|
||||
* as the actual source of any value). This is an interactive case, but
|
||||
* it needs its own source value because some assign hooks need to make
|
||||
* different validity checks in this case.
|
||||
*
|
||||
* NB: see GucSource_Names in guc.c if you change this.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PGC_S_DEFAULT, /* hard-wired default ("boot_val") */
|
||||
PGC_S_DYNAMIC_DEFAULT, /* default computed during initialization */
|
||||
PGC_S_ENV_VAR, /* postmaster environment variable */
|
||||
PGC_S_FILE, /* postgresql.conf */
|
||||
PGC_S_ARGV, /* postmaster command line */
|
||||
PGC_S_DATABASE, /* per-database setting */
|
||||
PGC_S_USER, /* per-user setting */
|
||||
PGC_S_DATABASE_USER, /* per-user-and-database setting */
|
||||
PGC_S_CLIENT, /* from client connection request */
|
||||
PGC_S_OVERRIDE, /* special case to forcibly set default */
|
||||
PGC_S_INTERACTIVE, /* dividing line for error reporting */
|
||||
PGC_S_TEST, /* test per-database or per-user setting */
|
||||
PGC_S_SESSION /* SET command */
|
||||
} GucSource;
|
||||
|
||||
/*
|
||||
* Parsing the configuration file will return a list of name-value pairs
|
||||
* with source location info.
|
||||
*/
|
||||
typedef struct ConfigVariable
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
char *filename;
|
||||
int sourceline;
|
||||
struct ConfigVariable *next;
|
||||
} ConfigVariable;
|
||||
|
||||
extern bool ParseConfigFile(const char *config_file, const char *calling_file,
|
||||
int depth, int elevel,
|
||||
ConfigVariable **head_p, ConfigVariable **tail_p);
|
||||
extern bool ParseConfigFp(FILE *fp, const char *config_file,
|
||||
int depth, int elevel,
|
||||
ConfigVariable **head_p, ConfigVariable **tail_p);
|
||||
extern void FreeConfigVariables(ConfigVariable *list);
|
||||
|
||||
/*
|
||||
* The possible values of an enum variable are specified by an array of
|
||||
* name-value pairs. The "hidden" flag means the value is accepted but
|
||||
* won't be displayed when guc.c is asked for a list of acceptable values.
|
||||
*/
|
||||
struct config_enum_entry
|
||||
{
|
||||
const char *name;
|
||||
int val;
|
||||
bool hidden;
|
||||
};
|
||||
|
||||
/*
|
||||
* Signatures for per-variable check/assign/show hook functions
|
||||
*/
|
||||
typedef bool (*GucBoolCheckHook) (bool *newval, void **extra, GucSource source);
|
||||
typedef bool (*GucIntCheckHook) (int *newval, void **extra, GucSource source);
|
||||
typedef bool (*GucRealCheckHook) (double *newval, void **extra, GucSource source);
|
||||
typedef bool (*GucStringCheckHook) (char **newval, void **extra, GucSource source);
|
||||
typedef bool (*GucEnumCheckHook) (int *newval, void **extra, GucSource source);
|
||||
|
||||
typedef void (*GucBoolAssignHook) (bool newval, void *extra);
|
||||
typedef void (*GucIntAssignHook) (int newval, void *extra);
|
||||
typedef void (*GucRealAssignHook) (double newval, void *extra);
|
||||
typedef void (*GucStringAssignHook) (const char *newval, void *extra);
|
||||
typedef void (*GucEnumAssignHook) (int newval, void *extra);
|
||||
|
||||
typedef const char *(*GucShowHook) (void);
|
||||
|
||||
/*
|
||||
* Miscellaneous
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* Types of set_config_option actions */
|
||||
GUC_ACTION_SET, /* regular SET command */
|
||||
GUC_ACTION_LOCAL, /* SET LOCAL command */
|
||||
GUC_ACTION_SAVE /* function SET option, or temp assignment */
|
||||
} GucAction;
|
||||
|
||||
#define GUC_QUALIFIER_SEPARATOR '.'
|
||||
|
||||
/*
|
||||
* bit values in "flags" of a GUC variable
|
||||
*/
|
||||
#define GUC_LIST_INPUT 0x0001 /* input can be list format */
|
||||
#define GUC_LIST_QUOTE 0x0002 /* double-quote list elements */
|
||||
#define GUC_NO_SHOW_ALL 0x0004 /* exclude from SHOW ALL */
|
||||
#define GUC_NO_RESET_ALL 0x0008 /* exclude from RESET ALL */
|
||||
#define GUC_REPORT 0x0010 /* auto-report changes to client */
|
||||
#define GUC_NOT_IN_SAMPLE 0x0020 /* not in postgresql.conf.sample */
|
||||
#define GUC_DISALLOW_IN_FILE 0x0040 /* can't set in postgresql.conf */
|
||||
#define GUC_CUSTOM_PLACEHOLDER 0x0080 /* placeholder for custom variable */
|
||||
#define GUC_SUPERUSER_ONLY 0x0100 /* show only to superusers */
|
||||
#define GUC_IS_NAME 0x0200 /* limit string to NAMEDATALEN-1 */
|
||||
|
||||
#define GUC_UNIT_KB 0x0400 /* value is in kilobytes */
|
||||
#define GUC_UNIT_BLOCKS 0x0800 /* value is in blocks */
|
||||
#define GUC_UNIT_XBLOCKS 0x0C00 /* value is in xlog blocks */
|
||||
#define GUC_UNIT_MEMORY 0x0C00 /* mask for KB, BLOCKS, XBLOCKS */
|
||||
|
||||
#define GUC_UNIT_MS 0x1000 /* value is in milliseconds */
|
||||
#define GUC_UNIT_S 0x2000 /* value is in seconds */
|
||||
#define GUC_UNIT_MIN 0x4000 /* value is in minutes */
|
||||
#define GUC_UNIT_TIME 0x7000 /* mask for MS, S, MIN */
|
||||
|
||||
#define GUC_NOT_WHILE_SEC_REST 0x8000 /* can't set if security restricted */
|
||||
|
||||
/* GUC vars that are actually declared in guc.c, rather than elsewhere */
|
||||
extern bool log_duration;
|
||||
extern bool Debug_print_plan;
|
||||
extern bool Debug_print_parse;
|
||||
extern bool Debug_print_rewritten;
|
||||
extern bool Debug_pretty_print;
|
||||
|
||||
extern bool log_parser_stats;
|
||||
extern bool log_planner_stats;
|
||||
extern bool log_executor_stats;
|
||||
extern bool log_statement_stats;
|
||||
extern bool log_btree_build_stats;
|
||||
|
||||
extern PGDLLIMPORT bool check_function_bodies;
|
||||
extern bool default_with_oids;
|
||||
extern bool SQL_inheritance;
|
||||
|
||||
extern int log_min_error_statement;
|
||||
extern int log_min_messages;
|
||||
extern int client_min_messages;
|
||||
extern int log_min_duration_statement;
|
||||
extern int log_temp_files;
|
||||
|
||||
extern int num_temp_buffers;
|
||||
|
||||
extern char *data_directory;
|
||||
extern char *ConfigFileName;
|
||||
extern char *HbaFileName;
|
||||
extern char *IdentFileName;
|
||||
extern char *external_pid_file;
|
||||
|
||||
extern char *application_name;
|
||||
|
||||
extern int tcp_keepalives_idle;
|
||||
extern int tcp_keepalives_interval;
|
||||
extern int tcp_keepalives_count;
|
||||
|
||||
/*
|
||||
* Functions exported by guc.c
|
||||
*/
|
||||
extern void SetConfigOption(const char *name, const char *value,
|
||||
GucContext context, GucSource source);
|
||||
|
||||
extern void DefineCustomBoolVariable(
|
||||
const char *name,
|
||||
const char *short_desc,
|
||||
const char *long_desc,
|
||||
bool *valueAddr,
|
||||
bool bootValue,
|
||||
GucContext context,
|
||||
int flags,
|
||||
GucBoolCheckHook check_hook,
|
||||
GucBoolAssignHook assign_hook,
|
||||
GucShowHook show_hook);
|
||||
|
||||
extern void DefineCustomIntVariable(
|
||||
const char *name,
|
||||
const char *short_desc,
|
||||
const char *long_desc,
|
||||
int *valueAddr,
|
||||
int bootValue,
|
||||
int minValue,
|
||||
int maxValue,
|
||||
GucContext context,
|
||||
int flags,
|
||||
GucIntCheckHook check_hook,
|
||||
GucIntAssignHook assign_hook,
|
||||
GucShowHook show_hook);
|
||||
|
||||
extern void DefineCustomRealVariable(
|
||||
const char *name,
|
||||
const char *short_desc,
|
||||
const char *long_desc,
|
||||
double *valueAddr,
|
||||
double bootValue,
|
||||
double minValue,
|
||||
double maxValue,
|
||||
GucContext context,
|
||||
int flags,
|
||||
GucRealCheckHook check_hook,
|
||||
GucRealAssignHook assign_hook,
|
||||
GucShowHook show_hook);
|
||||
|
||||
extern void DefineCustomStringVariable(
|
||||
const char *name,
|
||||
const char *short_desc,
|
||||
const char *long_desc,
|
||||
char **valueAddr,
|
||||
const char *bootValue,
|
||||
GucContext context,
|
||||
int flags,
|
||||
GucStringCheckHook check_hook,
|
||||
GucStringAssignHook assign_hook,
|
||||
GucShowHook show_hook);
|
||||
|
||||
extern void DefineCustomEnumVariable(
|
||||
const char *name,
|
||||
const char *short_desc,
|
||||
const char *long_desc,
|
||||
int *valueAddr,
|
||||
int bootValue,
|
||||
const struct config_enum_entry * options,
|
||||
GucContext context,
|
||||
int flags,
|
||||
GucEnumCheckHook check_hook,
|
||||
GucEnumAssignHook assign_hook,
|
||||
GucShowHook show_hook);
|
||||
|
||||
extern void EmitWarningsOnPlaceholders(const char *className);
|
||||
|
||||
extern const char *GetConfigOption(const char *name, bool missing_ok,
|
||||
bool restrict_superuser);
|
||||
extern const char *GetConfigOptionResetString(const char *name);
|
||||
extern void ProcessConfigFile(GucContext context);
|
||||
extern void InitializeGUCOptions(void);
|
||||
extern bool SelectConfigFiles(const char *userDoption, const char *progname);
|
||||
extern void ResetAllOptions(void);
|
||||
extern void AtStart_GUC(void);
|
||||
extern int NewGUCNestLevel(void);
|
||||
extern void AtEOXact_GUC(bool isCommit, int nestLevel);
|
||||
extern void BeginReportingGUCOptions(void);
|
||||
extern void ParseLongOption(const char *string, char **name, char **value);
|
||||
extern bool parse_int(const char *value, int *result, int flags,
|
||||
const char **hintmsg);
|
||||
extern bool parse_real(const char *value, double *result);
|
||||
extern bool set_config_option(const char *name, const char *value,
|
||||
GucContext context, GucSource source,
|
||||
GucAction action, bool changeVal);
|
||||
extern char *GetConfigOptionByName(const char *name, const char **varname);
|
||||
extern void GetConfigOptionByNum(int varnum, const char **values, bool *noshow);
|
||||
extern int GetNumConfigOptions(void);
|
||||
|
||||
extern void SetPGVariable(const char *name, List *args, bool is_local);
|
||||
extern void GetPGVariable(const char *name, DestReceiver *dest);
|
||||
extern TupleDesc GetPGVariableResultDesc(const char *name);
|
||||
|
||||
extern void ExecSetVariableStmt(VariableSetStmt *stmt);
|
||||
extern char *ExtractSetVariableArgs(VariableSetStmt *stmt);
|
||||
|
||||
extern void ProcessGUCArray(ArrayType *array,
|
||||
GucContext context, GucSource source, GucAction action);
|
||||
extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
|
||||
extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
|
||||
extern ArrayType *GUCArrayReset(ArrayType *array);
|
||||
|
||||
extern void pg_timezone_abbrev_initialize(void);
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
extern void write_nondefault_variables(GucContext context);
|
||||
extern void read_nondefault_variables(void);
|
||||
#endif
|
||||
|
||||
/* Support for messages reported from GUC check hooks */
|
||||
|
||||
extern PGDLLIMPORT char *GUC_check_errmsg_string;
|
||||
extern PGDLLIMPORT char *GUC_check_errdetail_string;
|
||||
extern PGDLLIMPORT char *GUC_check_errhint_string;
|
||||
|
||||
extern void GUC_check_errcode(int sqlerrcode);
|
||||
|
||||
#define GUC_check_errmsg \
|
||||
pre_format_elog_string(errno, TEXTDOMAIN), \
|
||||
GUC_check_errmsg_string = format_elog_string
|
||||
|
||||
#define GUC_check_errdetail \
|
||||
pre_format_elog_string(errno, TEXTDOMAIN), \
|
||||
GUC_check_errdetail_string = format_elog_string
|
||||
|
||||
#define GUC_check_errhint \
|
||||
pre_format_elog_string(errno, TEXTDOMAIN), \
|
||||
GUC_check_errhint_string = format_elog_string
|
||||
|
||||
|
||||
/*
|
||||
* The following functions are not in guc.c, but are declared here to avoid
|
||||
* having to include guc.h in some widely used headers that it really doesn't
|
||||
* belong in.
|
||||
*/
|
||||
|
||||
/* in commands/tablespace.c */
|
||||
extern bool check_default_tablespace(char **newval, void **extra, GucSource source);
|
||||
extern bool check_temp_tablespaces(char **newval, void **extra, GucSource source);
|
||||
extern void assign_temp_tablespaces(const char *newval, void *extra);
|
||||
|
||||
/* in catalog/namespace.c */
|
||||
extern bool check_search_path(char **newval, void **extra, GucSource source);
|
||||
extern void assign_search_path(const char *newval, void *extra);
|
||||
|
||||
/* in access/transam/xlog.c */
|
||||
extern bool check_wal_buffers(int *newval, void **extra, GucSource source);
|
||||
extern void assign_xlog_sync_method(int new_sync_method, void *extra);
|
||||
|
||||
#endif /* GUC_H */
|
261
deps/libpq/include/utils/guc_tables.h
vendored
Normal file
261
deps/libpq/include/utils/guc_tables.h
vendored
Normal file
|
@ -0,0 +1,261 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* guc_tables.h
|
||||
* Declarations of tables used by GUC.
|
||||
*
|
||||
* See src/backend/utils/misc/README for design notes.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
* src/include/utils/guc_tables.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef GUC_TABLES_H
|
||||
#define GUC_TABLES_H 1
|
||||
|
||||
#include "utils/guc.h"
|
||||
|
||||
/*
|
||||
* GUC supports these types of variables:
|
||||
*/
|
||||
enum config_type
|
||||
{
|
||||
PGC_BOOL,
|
||||
PGC_INT,
|
||||
PGC_REAL,
|
||||
PGC_STRING,
|
||||
PGC_ENUM
|
||||
};
|
||||
|
||||
union config_var_val
|
||||
{
|
||||
bool boolval;
|
||||
int intval;
|
||||
double realval;
|
||||
char *stringval;
|
||||
int enumval;
|
||||
};
|
||||
|
||||
/*
|
||||
* The actual value of a GUC variable can include a malloc'd opaque struct
|
||||
* "extra", which is created by its check_hook and used by its assign_hook.
|
||||
*/
|
||||
typedef struct config_var_value
|
||||
{
|
||||
union config_var_val val;
|
||||
void *extra;
|
||||
} config_var_value;
|
||||
|
||||
/*
|
||||
* Groupings to help organize all the run-time options for display
|
||||
*/
|
||||
enum config_group
|
||||
{
|
||||
UNGROUPED,
|
||||
FILE_LOCATIONS,
|
||||
CONN_AUTH,
|
||||
CONN_AUTH_SETTINGS,
|
||||
CONN_AUTH_SECURITY,
|
||||
RESOURCES,
|
||||
RESOURCES_MEM,
|
||||
RESOURCES_KERNEL,
|
||||
RESOURCES_VACUUM_DELAY,
|
||||
RESOURCES_BGWRITER,
|
||||
RESOURCES_ASYNCHRONOUS,
|
||||
WAL,
|
||||
WAL_SETTINGS,
|
||||
WAL_CHECKPOINTS,
|
||||
WAL_ARCHIVING,
|
||||
REPLICATION,
|
||||
REPLICATION_MASTER,
|
||||
REPLICATION_STANDBY,
|
||||
QUERY_TUNING,
|
||||
QUERY_TUNING_METHOD,
|
||||
QUERY_TUNING_COST,
|
||||
QUERY_TUNING_GEQO,
|
||||
QUERY_TUNING_OTHER,
|
||||
LOGGING,
|
||||
LOGGING_WHERE,
|
||||
LOGGING_WHEN,
|
||||
LOGGING_WHAT,
|
||||
STATS,
|
||||
STATS_MONITORING,
|
||||
STATS_COLLECTOR,
|
||||
AUTOVACUUM,
|
||||
CLIENT_CONN,
|
||||
CLIENT_CONN_STATEMENT,
|
||||
CLIENT_CONN_LOCALE,
|
||||
CLIENT_CONN_OTHER,
|
||||
LOCK_MANAGEMENT,
|
||||
COMPAT_OPTIONS,
|
||||
COMPAT_OPTIONS_PREVIOUS,
|
||||
COMPAT_OPTIONS_CLIENT,
|
||||
ERROR_HANDLING_OPTIONS,
|
||||
PRESET_OPTIONS,
|
||||
CUSTOM_OPTIONS,
|
||||
DEVELOPER_OPTIONS
|
||||
};
|
||||
|
||||
/*
|
||||
* Stack entry for saving the state a variable had prior to an uncommitted
|
||||
* transactional change
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* This is almost GucAction, but we need a fourth state for SET+LOCAL */
|
||||
GUC_SAVE, /* entry caused by function SET option */
|
||||
GUC_SET, /* entry caused by plain SET command */
|
||||
GUC_LOCAL, /* entry caused by SET LOCAL command */
|
||||
GUC_SET_LOCAL /* entry caused by SET then SET LOCAL */
|
||||
} GucStackState;
|
||||
|
||||
typedef struct guc_stack
|
||||
{
|
||||
struct guc_stack *prev; /* previous stack item, if any */
|
||||
int nest_level; /* nesting depth at which we made entry */
|
||||
GucStackState state; /* see enum above */
|
||||
GucSource source; /* source of the prior value */
|
||||
config_var_value prior; /* previous value of variable */
|
||||
config_var_value masked; /* SET value in a GUC_SET_LOCAL entry */
|
||||
/* masked value's source must be PGC_S_SESSION, so no need to store it */
|
||||
} GucStack;
|
||||
|
||||
/*
|
||||
* Generic fields applicable to all types of variables
|
||||
*
|
||||
* The short description should be less than 80 chars in length. Some
|
||||
* applications may use the long description as well, and will append
|
||||
* it to the short description. (separated by a newline or '. ')
|
||||
*
|
||||
* Note that sourcefile/sourceline are kept here, and not pushed into stacked
|
||||
* values, although in principle they belong with some stacked value if the
|
||||
* active value is session- or transaction-local. This is to avoid bloating
|
||||
* stack entries. We know they are only relevant when source == PGC_S_FILE.
|
||||
*/
|
||||
struct config_generic
|
||||
{
|
||||
/* constant fields, must be set correctly in initial value: */
|
||||
const char *name; /* name of variable - MUST BE FIRST */
|
||||
GucContext context; /* context required to set the variable */
|
||||
enum config_group group; /* to help organize variables by function */
|
||||
const char *short_desc; /* short desc. of this variable's purpose */
|
||||
const char *long_desc; /* long desc. of this variable's purpose */
|
||||
int flags; /* flag bits, see below */
|
||||
/* variable fields, initialized at runtime: */
|
||||
enum config_type vartype; /* type of variable (set only at startup) */
|
||||
int status; /* status bits, see below */
|
||||
GucSource reset_source; /* source of the reset_value */
|
||||
GucSource source; /* source of the current actual value */
|
||||
GucStack *stack; /* stacked prior values */
|
||||
void *extra; /* "extra" pointer for current actual value */
|
||||
char *sourcefile; /* file current setting is from (NULL if not
|
||||
* file) */
|
||||
int sourceline; /* line in source file */
|
||||
};
|
||||
|
||||
/* bit values in flags field are defined in guc.h */
|
||||
|
||||
/* bit values in status field */
|
||||
#define GUC_IS_IN_FILE 0x0001 /* found it in config file */
|
||||
/*
|
||||
* Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
|
||||
* Do not assume that its value represents useful information elsewhere.
|
||||
*/
|
||||
|
||||
|
||||
/* GUC records for specific variable types */
|
||||
|
||||
struct config_bool
|
||||
{
|
||||
struct config_generic gen;
|
||||
/* constant fields, must be set correctly in initial value: */
|
||||
bool *variable;
|
||||
bool boot_val;
|
||||
GucBoolCheckHook check_hook;
|
||||
GucBoolAssignHook assign_hook;
|
||||
GucShowHook show_hook;
|
||||
/* variable fields, initialized at runtime: */
|
||||
bool reset_val;
|
||||
void *reset_extra;
|
||||
};
|
||||
|
||||
struct config_int
|
||||
{
|
||||
struct config_generic gen;
|
||||
/* constant fields, must be set correctly in initial value: */
|
||||
int *variable;
|
||||
int boot_val;
|
||||
int min;
|
||||
int max;
|
||||
GucIntCheckHook check_hook;
|
||||
GucIntAssignHook assign_hook;
|
||||
GucShowHook show_hook;
|
||||
/* variable fields, initialized at runtime: */
|
||||
int reset_val;
|
||||
void *reset_extra;
|
||||
};
|
||||
|
||||
struct config_real
|
||||
{
|
||||
struct config_generic gen;
|
||||
/* constant fields, must be set correctly in initial value: */
|
||||
double *variable;
|
||||
double boot_val;
|
||||
double min;
|
||||
double max;
|
||||
GucRealCheckHook check_hook;
|
||||
GucRealAssignHook assign_hook;
|
||||
GucShowHook show_hook;
|
||||
/* variable fields, initialized at runtime: */
|
||||
double reset_val;
|
||||
void *reset_extra;
|
||||
};
|
||||
|
||||
struct config_string
|
||||
{
|
||||
struct config_generic gen;
|
||||
/* constant fields, must be set correctly in initial value: */
|
||||
char **variable;
|
||||
const char *boot_val;
|
||||
GucStringCheckHook check_hook;
|
||||
GucStringAssignHook assign_hook;
|
||||
GucShowHook show_hook;
|
||||
/* variable fields, initialized at runtime: */
|
||||
char *reset_val;
|
||||
void *reset_extra;
|
||||
};
|
||||
|
||||
struct config_enum
|
||||
{
|
||||
struct config_generic gen;
|
||||
/* constant fields, must be set correctly in initial value: */
|
||||
int *variable;
|
||||
int boot_val;
|
||||
const struct config_enum_entry *options;
|
||||
GucEnumCheckHook check_hook;
|
||||
GucEnumAssignHook assign_hook;
|
||||
GucShowHook show_hook;
|
||||
/* variable fields, initialized at runtime: */
|
||||
int reset_val;
|
||||
void *reset_extra;
|
||||
};
|
||||
|
||||
/* constant tables corresponding to enums above and in guc.h */
|
||||
extern const char *const config_group_names[];
|
||||
extern const char *const config_type_names[];
|
||||
extern const char *const GucContext_Names[];
|
||||
extern const char *const GucSource_Names[];
|
||||
|
||||
/* get the current set of variables */
|
||||
extern struct config_generic **get_guc_variables(void);
|
||||
|
||||
extern void build_guc_variables(void);
|
||||
|
||||
/* search in enum options */
|
||||
extern const char *config_enum_lookup_by_value(struct config_enum * record, int val);
|
||||
extern bool config_enum_lookup_by_name(struct config_enum * record,
|
||||
const char *value, int *retval);
|
||||
|
||||
|
||||
#endif /* GUC_TABLES_H */
|
17
deps/libpq/include/utils/help_config.h
vendored
Normal file
17
deps/libpq/include/utils/help_config.h
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* help_config.h
|
||||
* Interface to the --help-config option of main.c
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
* src/include/utils/help_config.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef HELP_CONFIG_H
|
||||
#define HELP_CONFIG_H 1
|
||||
|
||||
extern int GucInfoMain(void);
|
||||
|
||||
#endif
|
151
deps/libpq/include/utils/hsearch.h
vendored
Normal file
151
deps/libpq/include/utils/hsearch.h
vendored
Normal file
|
@ -0,0 +1,151 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* hsearch.h
|
||||
* exported definitions for utils/hash/dynahash.c; see notes therein
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/hsearch.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef HSEARCH_H
|
||||
#define HSEARCH_H
|
||||
|
||||
|
||||
/*
|
||||
* Hash functions must have this signature.
|
||||
*/
|
||||
typedef uint32 (*HashValueFunc) (const void *key, Size keysize);
|
||||
|
||||
/*
|
||||
* Key comparison functions must have this signature. Comparison functions
|
||||
* return zero for match, nonzero for no match. (The comparison function
|
||||
* definition is designed to allow memcmp() and strncmp() to be used directly
|
||||
* as key comparison functions.)
|
||||
*/
|
||||
typedef int (*HashCompareFunc) (const void *key1, const void *key2,
|
||||
Size keysize);
|
||||
|
||||
/*
|
||||
* Key copying functions must have this signature. The return value is not
|
||||
* used. (The definition is set up to allow memcpy() and strncpy() to be
|
||||
* used directly.)
|
||||
*/
|
||||
typedef void *(*HashCopyFunc) (void *dest, const void *src, Size keysize);
|
||||
|
||||
/*
|
||||
* Space allocation function for a hashtable --- designed to match malloc().
|
||||
* Note: there is no free function API; can't destroy a hashtable unless you
|
||||
* use the default allocator.
|
||||
*/
|
||||
typedef void *(*HashAllocFunc) (Size request);
|
||||
|
||||
/*
|
||||
* HASHELEMENT is the private part of a hashtable entry. The caller's data
|
||||
* follows the HASHELEMENT structure (on a MAXALIGN'd boundary). The hash key
|
||||
* is expected to be at the start of the caller's hash entry data structure.
|
||||
*/
|
||||
typedef struct HASHELEMENT
|
||||
{
|
||||
struct HASHELEMENT *link; /* link to next entry in same bucket */
|
||||
uint32 hashvalue; /* hash function result for this entry */
|
||||
} HASHELEMENT;
|
||||
|
||||
/* Hash table header struct is an opaque type known only within dynahash.c */
|
||||
typedef struct HASHHDR HASHHDR;
|
||||
|
||||
/* Hash table control struct is an opaque type known only within dynahash.c */
|
||||
typedef struct HTAB HTAB;
|
||||
|
||||
/* Parameter data structure for hash_create */
|
||||
/* Only those fields indicated by hash_flags need be set */
|
||||
typedef struct HASHCTL
|
||||
{
|
||||
long num_partitions; /* # partitions (must be power of 2) */
|
||||
long ssize; /* segment size */
|
||||
long dsize; /* (initial) directory size */
|
||||
long max_dsize; /* limit to dsize if dir size is limited */
|
||||
long ffactor; /* fill factor */
|
||||
Size keysize; /* hash key length in bytes */
|
||||
Size entrysize; /* total user element size in bytes */
|
||||
HashValueFunc hash; /* hash function */
|
||||
HashCompareFunc match; /* key comparison function */
|
||||
HashCopyFunc keycopy; /* key copying function */
|
||||
HashAllocFunc alloc; /* memory allocator */
|
||||
MemoryContext hcxt; /* memory context to use for allocations */
|
||||
HASHHDR *hctl; /* location of header in shared mem */
|
||||
} HASHCTL;
|
||||
|
||||
/* Flags to indicate which parameters are supplied */
|
||||
#define HASH_PARTITION 0x001 /* Hashtable is used w/partitioned locking */
|
||||
#define HASH_SEGMENT 0x002 /* Set segment size */
|
||||
#define HASH_DIRSIZE 0x004 /* Set directory size (initial and max) */
|
||||
#define HASH_FFACTOR 0x008 /* Set fill factor */
|
||||
#define HASH_FUNCTION 0x010 /* Set user defined hash function */
|
||||
#define HASH_ELEM 0x020 /* Set keysize and entrysize */
|
||||
#define HASH_SHARED_MEM 0x040 /* Hashtable is in shared memory */
|
||||
#define HASH_ATTACH 0x080 /* Do not initialize hctl */
|
||||
#define HASH_ALLOC 0x100 /* Set memory allocator */
|
||||
#define HASH_CONTEXT 0x200 /* Set memory allocation context */
|
||||
#define HASH_COMPARE 0x400 /* Set user defined comparison function */
|
||||
#define HASH_KEYCOPY 0x800 /* Set user defined key-copying function */
|
||||
#define HASH_FIXED_SIZE 0x1000 /* Initial size is a hard limit */
|
||||
|
||||
|
||||
/* max_dsize value to indicate expansible directory */
|
||||
#define NO_MAX_DSIZE (-1)
|
||||
|
||||
/* hash_search operations */
|
||||
typedef enum
|
||||
{
|
||||
HASH_FIND,
|
||||
HASH_ENTER,
|
||||
HASH_REMOVE,
|
||||
HASH_ENTER_NULL
|
||||
} HASHACTION;
|
||||
|
||||
/* hash_seq status (should be considered an opaque type by callers) */
|
||||
typedef struct
|
||||
{
|
||||
HTAB *hashp;
|
||||
uint32 curBucket; /* index of current bucket */
|
||||
HASHELEMENT *curEntry; /* current entry in bucket */
|
||||
} HASH_SEQ_STATUS;
|
||||
|
||||
/*
|
||||
* prototypes for functions in dynahash.c
|
||||
*/
|
||||
extern HTAB *hash_create(const char *tabname, long nelem,
|
||||
HASHCTL *info, int flags);
|
||||
extern void hash_destroy(HTAB *hashp);
|
||||
extern void hash_stats(const char *where, HTAB *hashp);
|
||||
extern void *hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action,
|
||||
bool *foundPtr);
|
||||
extern uint32 get_hash_value(HTAB *hashp, const void *keyPtr);
|
||||
extern void *hash_search_with_hash_value(HTAB *hashp, const void *keyPtr,
|
||||
uint32 hashvalue, HASHACTION action,
|
||||
bool *foundPtr);
|
||||
extern long hash_get_num_entries(HTAB *hashp);
|
||||
extern void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp);
|
||||
extern void *hash_seq_search(HASH_SEQ_STATUS *status);
|
||||
extern void hash_seq_term(HASH_SEQ_STATUS *status);
|
||||
extern void hash_freeze(HTAB *hashp);
|
||||
extern Size hash_estimate_size(long num_entries, Size entrysize);
|
||||
extern long hash_select_dirsize(long num_entries);
|
||||
extern Size hash_get_shared_size(HASHCTL *info, int flags);
|
||||
extern void AtEOXact_HashTables(bool isCommit);
|
||||
extern void AtEOSubXact_HashTables(bool isCommit, int nestDepth);
|
||||
|
||||
/*
|
||||
* prototypes for functions in hashfn.c
|
||||
*/
|
||||
extern uint32 string_hash(const void *key, Size keysize);
|
||||
extern uint32 tag_hash(const void *key, Size keysize);
|
||||
extern uint32 oid_hash(const void *key, Size keysize);
|
||||
extern uint32 bitmap_hash(const void *key, Size keysize);
|
||||
extern int bitmap_match(const void *key1, const void *key2, Size keysize);
|
||||
|
||||
#endif /* HSEARCH_H */
|
85
deps/libpq/include/utils/inet.h
vendored
Normal file
85
deps/libpq/include/utils/inet.h
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* inet.h
|
||||
* Declarations for operations on INET datatypes.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/inet.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef INET_H
|
||||
#define INET_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
/*
|
||||
* This is the internal storage format for IP addresses
|
||||
* (both INET and CIDR datatypes):
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char family; /* PGSQL_AF_INET or PGSQL_AF_INET6 */
|
||||
unsigned char bits; /* number of bits in netmask */
|
||||
unsigned char ipaddr[16]; /* up to 128 bits of address */
|
||||
} inet_struct;
|
||||
|
||||
/*
|
||||
* Referencing all of the non-AF_INET types to AF_INET lets us work on
|
||||
* machines which may not have the appropriate address family (like
|
||||
* inet6 addresses when AF_INET6 isn't present) but doesn't cause a
|
||||
* dump/reload requirement. Existing databases used AF_INET for the family
|
||||
* type on disk.
|
||||
*/
|
||||
#define PGSQL_AF_INET (AF_INET + 0)
|
||||
#define PGSQL_AF_INET6 (AF_INET + 1)
|
||||
|
||||
/*
|
||||
* Both INET and CIDR addresses are represented within Postgres as varlena
|
||||
* objects, ie, there is a varlena header in front of the struct type
|
||||
* depicted above. This struct depicts what we actually have in memory
|
||||
* in "uncompressed" cases. Note that since the maximum data size is only
|
||||
* 18 bytes, INET/CIDR will invariably be stored into tuples using the
|
||||
* 1-byte-header varlena format. However, we have to be prepared to cope
|
||||
* with the 4-byte-header format too, because various code may helpfully
|
||||
* try to "decompress" 1-byte-header datums.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char vl_len_[4]; /* Do not touch this field directly! */
|
||||
inet_struct inet_data;
|
||||
} inet;
|
||||
|
||||
|
||||
/*
|
||||
* This is the internal storage format for MAC addresses:
|
||||
*/
|
||||
typedef struct macaddr
|
||||
{
|
||||
unsigned char a;
|
||||
unsigned char b;
|
||||
unsigned char c;
|
||||
unsigned char d;
|
||||
unsigned char e;
|
||||
unsigned char f;
|
||||
} macaddr;
|
||||
|
||||
/*
|
||||
* fmgr interface macros
|
||||
*/
|
||||
#define DatumGetInetP(X) ((inet *) PG_DETOAST_DATUM(X))
|
||||
#define DatumGetInetPP(X) ((inet *) PG_DETOAST_DATUM_PACKED(X))
|
||||
#define InetPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_INET_PP(n) DatumGetInetPP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_INET_P(x) return InetPGetDatum(x)
|
||||
/* macaddr is a fixed-length pass-by-reference datatype */
|
||||
#define DatumGetMacaddrP(X) ((macaddr *) DatumGetPointer(X))
|
||||
#define MacaddrPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_MACADDR_P(n) DatumGetMacaddrP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_MACADDR_P(x) return MacaddrPGetDatum(x)
|
||||
|
||||
#endif /* INET_H */
|
127
deps/libpq/include/utils/int8.h
vendored
Normal file
127
deps/libpq/include/utils/int8.h
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* int8.h
|
||||
* Declarations for operations on 64-bit integers.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/int8.h
|
||||
*
|
||||
* NOTES
|
||||
* These data types are supported on all 64-bit architectures, and may
|
||||
* be supported through libraries on some 32-bit machines. If your machine
|
||||
* is not currently supported, then please try to make it so, then post
|
||||
* patches to the postgresql.org hackers mailing list.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef INT8_H
|
||||
#define INT8_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
|
||||
extern bool scanint8(const char *str, bool errorOK, int64 *result);
|
||||
|
||||
extern Datum int8in(PG_FUNCTION_ARGS);
|
||||
extern Datum int8out(PG_FUNCTION_ARGS);
|
||||
extern Datum int8recv(PG_FUNCTION_ARGS);
|
||||
extern Datum int8send(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int8eq(PG_FUNCTION_ARGS);
|
||||
extern Datum int8ne(PG_FUNCTION_ARGS);
|
||||
extern Datum int8lt(PG_FUNCTION_ARGS);
|
||||
extern Datum int8gt(PG_FUNCTION_ARGS);
|
||||
extern Datum int8le(PG_FUNCTION_ARGS);
|
||||
extern Datum int8ge(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int84eq(PG_FUNCTION_ARGS);
|
||||
extern Datum int84ne(PG_FUNCTION_ARGS);
|
||||
extern Datum int84lt(PG_FUNCTION_ARGS);
|
||||
extern Datum int84gt(PG_FUNCTION_ARGS);
|
||||
extern Datum int84le(PG_FUNCTION_ARGS);
|
||||
extern Datum int84ge(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int48eq(PG_FUNCTION_ARGS);
|
||||
extern Datum int48ne(PG_FUNCTION_ARGS);
|
||||
extern Datum int48lt(PG_FUNCTION_ARGS);
|
||||
extern Datum int48gt(PG_FUNCTION_ARGS);
|
||||
extern Datum int48le(PG_FUNCTION_ARGS);
|
||||
extern Datum int48ge(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int82eq(PG_FUNCTION_ARGS);
|
||||
extern Datum int82ne(PG_FUNCTION_ARGS);
|
||||
extern Datum int82lt(PG_FUNCTION_ARGS);
|
||||
extern Datum int82gt(PG_FUNCTION_ARGS);
|
||||
extern Datum int82le(PG_FUNCTION_ARGS);
|
||||
extern Datum int82ge(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int28eq(PG_FUNCTION_ARGS);
|
||||
extern Datum int28ne(PG_FUNCTION_ARGS);
|
||||
extern Datum int28lt(PG_FUNCTION_ARGS);
|
||||
extern Datum int28gt(PG_FUNCTION_ARGS);
|
||||
extern Datum int28le(PG_FUNCTION_ARGS);
|
||||
extern Datum int28ge(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int8um(PG_FUNCTION_ARGS);
|
||||
extern Datum int8up(PG_FUNCTION_ARGS);
|
||||
extern Datum int8pl(PG_FUNCTION_ARGS);
|
||||
extern Datum int8mi(PG_FUNCTION_ARGS);
|
||||
extern Datum int8mul(PG_FUNCTION_ARGS);
|
||||
extern Datum int8div(PG_FUNCTION_ARGS);
|
||||
extern Datum int8abs(PG_FUNCTION_ARGS);
|
||||
extern Datum int8mod(PG_FUNCTION_ARGS);
|
||||
extern Datum int8inc(PG_FUNCTION_ARGS);
|
||||
extern Datum int8inc_any(PG_FUNCTION_ARGS);
|
||||
extern Datum int8inc_float8_float8(PG_FUNCTION_ARGS);
|
||||
extern Datum int8larger(PG_FUNCTION_ARGS);
|
||||
extern Datum int8smaller(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int8and(PG_FUNCTION_ARGS);
|
||||
extern Datum int8or(PG_FUNCTION_ARGS);
|
||||
extern Datum int8xor(PG_FUNCTION_ARGS);
|
||||
extern Datum int8not(PG_FUNCTION_ARGS);
|
||||
extern Datum int8shl(PG_FUNCTION_ARGS);
|
||||
extern Datum int8shr(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int84pl(PG_FUNCTION_ARGS);
|
||||
extern Datum int84mi(PG_FUNCTION_ARGS);
|
||||
extern Datum int84mul(PG_FUNCTION_ARGS);
|
||||
extern Datum int84div(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int48pl(PG_FUNCTION_ARGS);
|
||||
extern Datum int48mi(PG_FUNCTION_ARGS);
|
||||
extern Datum int48mul(PG_FUNCTION_ARGS);
|
||||
extern Datum int48div(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int82pl(PG_FUNCTION_ARGS);
|
||||
extern Datum int82mi(PG_FUNCTION_ARGS);
|
||||
extern Datum int82mul(PG_FUNCTION_ARGS);
|
||||
extern Datum int82div(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int28pl(PG_FUNCTION_ARGS);
|
||||
extern Datum int28mi(PG_FUNCTION_ARGS);
|
||||
extern Datum int28mul(PG_FUNCTION_ARGS);
|
||||
extern Datum int28div(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int48(PG_FUNCTION_ARGS);
|
||||
extern Datum int84(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum int28(PG_FUNCTION_ARGS);
|
||||
extern Datum int82(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum i8tod(PG_FUNCTION_ARGS);
|
||||
extern Datum dtoi8(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum i8tof(PG_FUNCTION_ARGS);
|
||||
extern Datum ftoi8(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum i8tooid(PG_FUNCTION_ARGS);
|
||||
extern Datum oidtoi8(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum generate_series_int8(PG_FUNCTION_ARGS);
|
||||
extern Datum generate_series_step_int8(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* INT8_H */
|
68
deps/libpq/include/utils/inval.h
vendored
Normal file
68
deps/libpq/include/utils/inval.h
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* inval.h
|
||||
* POSTGRES cache invalidation dispatcher definitions.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/inval.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef INVAL_H
|
||||
#define INVAL_H
|
||||
|
||||
#include "access/htup.h"
|
||||
#include "storage/relfilenode.h"
|
||||
#include "utils/relcache.h"
|
||||
|
||||
|
||||
typedef void (*SyscacheCallbackFunction) (Datum arg, int cacheid, ItemPointer tuplePtr);
|
||||
typedef void (*RelcacheCallbackFunction) (Datum arg, Oid relid);
|
||||
|
||||
|
||||
extern void AcceptInvalidationMessages(void);
|
||||
|
||||
extern void AtStart_Inval(void);
|
||||
|
||||
extern void AtSubStart_Inval(void);
|
||||
|
||||
extern void AtEOXact_Inval(bool isCommit);
|
||||
|
||||
extern void AtEOSubXact_Inval(bool isCommit);
|
||||
|
||||
extern void AtPrepare_Inval(void);
|
||||
|
||||
extern void PostPrepare_Inval(void);
|
||||
|
||||
extern void CommandEndInvalidationMessages(void);
|
||||
|
||||
extern void CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple);
|
||||
|
||||
extern void CacheInvalidateCatalog(Oid catalogId);
|
||||
|
||||
extern void CacheInvalidateRelcache(Relation relation);
|
||||
|
||||
extern void CacheInvalidateRelcacheByTuple(HeapTuple classTuple);
|
||||
|
||||
extern void CacheInvalidateRelcacheByRelid(Oid relid);
|
||||
|
||||
extern void CacheInvalidateSmgr(RelFileNodeBackend rnode);
|
||||
|
||||
extern void CacheInvalidateRelmap(Oid databaseId);
|
||||
|
||||
extern void CacheRegisterSyscacheCallback(int cacheid,
|
||||
SyscacheCallbackFunction func,
|
||||
Datum arg);
|
||||
|
||||
extern void CacheRegisterRelcacheCallback(RelcacheCallbackFunction func,
|
||||
Datum arg);
|
||||
|
||||
extern void CallSyscacheCallbacks(int cacheid, ItemPointer tuplePtr);
|
||||
|
||||
extern void inval_twophase_postcommit(TransactionId xid, uint16 info,
|
||||
void *recdata, uint32 len);
|
||||
|
||||
#endif /* INVAL_H */
|
44
deps/libpq/include/utils/logtape.h
vendored
Normal file
44
deps/libpq/include/utils/logtape.h
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* logtape.h
|
||||
* Management of "logical tapes" within temporary files.
|
||||
*
|
||||
* See logtape.c for explanations.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/logtape.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef LOGTAPE_H
|
||||
#define LOGTAPE_H
|
||||
|
||||
/* LogicalTapeSet is an opaque type whose details are not known outside logtape.c. */
|
||||
|
||||
typedef struct LogicalTapeSet LogicalTapeSet;
|
||||
|
||||
/*
|
||||
* prototypes for functions in logtape.c
|
||||
*/
|
||||
|
||||
extern LogicalTapeSet *LogicalTapeSetCreate(int ntapes);
|
||||
extern void LogicalTapeSetClose(LogicalTapeSet *lts);
|
||||
extern void LogicalTapeSetForgetFreeSpace(LogicalTapeSet *lts);
|
||||
extern size_t LogicalTapeRead(LogicalTapeSet *lts, int tapenum,
|
||||
void *ptr, size_t size);
|
||||
extern void LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
|
||||
void *ptr, size_t size);
|
||||
extern void LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite);
|
||||
extern void LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum);
|
||||
extern bool LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum,
|
||||
size_t size);
|
||||
extern bool LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
|
||||
long blocknum, int offset);
|
||||
extern void LogicalTapeTell(LogicalTapeSet *lts, int tapenum,
|
||||
long *blocknum, int *offset);
|
||||
extern long LogicalTapeSetBlocks(LogicalTapeSet *lts);
|
||||
|
||||
#endif /* LOGTAPE_H */
|
159
deps/libpq/include/utils/lsyscache.h
vendored
Normal file
159
deps/libpq/include/utils/lsyscache.h
vendored
Normal file
|
@ -0,0 +1,159 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* lsyscache.h
|
||||
* Convenience routines for common queries in the system catalog cache.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/lsyscache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef LSYSCACHE_H
|
||||
#define LSYSCACHE_H
|
||||
|
||||
#include "access/attnum.h"
|
||||
#include "access/htup.h"
|
||||
#include "nodes/pg_list.h"
|
||||
|
||||
/* Result list element for get_op_btree_interpretation */
|
||||
typedef struct OpBtreeInterpretation
|
||||
{
|
||||
Oid opfamily_id; /* btree opfamily containing operator */
|
||||
int strategy; /* its strategy number */
|
||||
Oid oplefttype; /* declared left input datatype */
|
||||
Oid oprighttype; /* declared right input datatype */
|
||||
} OpBtreeInterpretation;
|
||||
|
||||
/* I/O function selector for get_type_io_data */
|
||||
typedef enum IOFuncSelector
|
||||
{
|
||||
IOFunc_input,
|
||||
IOFunc_output,
|
||||
IOFunc_receive,
|
||||
IOFunc_send
|
||||
} IOFuncSelector;
|
||||
|
||||
/* Hook for plugins to get control in get_attavgwidth() */
|
||||
typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);
|
||||
extern PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook;
|
||||
|
||||
extern bool op_in_opfamily(Oid opno, Oid opfamily);
|
||||
extern int get_op_opfamily_strategy(Oid opno, Oid opfamily);
|
||||
extern Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily);
|
||||
extern void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
|
||||
int *strategy,
|
||||
Oid *lefttype,
|
||||
Oid *righttype);
|
||||
extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
|
||||
int16 strategy);
|
||||
extern bool get_ordering_op_properties(Oid opno,
|
||||
Oid *opfamily, Oid *opcintype, int16 *strategy);
|
||||
extern bool get_compare_function_for_ordering_op(Oid opno,
|
||||
Oid *cmpfunc, bool *reverse);
|
||||
extern Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse);
|
||||
extern Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type);
|
||||
extern List *get_mergejoin_opfamilies(Oid opno);
|
||||
extern bool get_compatible_hash_operators(Oid opno,
|
||||
Oid *lhs_opno, Oid *rhs_opno);
|
||||
extern bool get_op_hash_functions(Oid opno,
|
||||
RegProcedure *lhs_procno, RegProcedure *rhs_procno);
|
||||
extern List *get_op_btree_interpretation(Oid opno);
|
||||
extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);
|
||||
extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,
|
||||
int16 procnum);
|
||||
extern char *get_attname(Oid relid, AttrNumber attnum);
|
||||
extern char *get_relid_attribute_name(Oid relid, AttrNumber attnum);
|
||||
extern AttrNumber get_attnum(Oid relid, const char *attname);
|
||||
extern Oid get_atttype(Oid relid, AttrNumber attnum);
|
||||
extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
|
||||
extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
|
||||
Oid *typid, int32 *typmod, Oid *collid);
|
||||
extern char *get_collation_name(Oid colloid);
|
||||
extern char *get_constraint_name(Oid conoid);
|
||||
extern Oid get_opclass_family(Oid opclass);
|
||||
extern Oid get_opclass_input_type(Oid opclass);
|
||||
extern RegProcedure get_opcode(Oid opno);
|
||||
extern char *get_opname(Oid opno);
|
||||
extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype);
|
||||
extern bool op_mergejoinable(Oid opno, Oid inputtype);
|
||||
extern bool op_hashjoinable(Oid opno, Oid inputtype);
|
||||
extern bool op_strict(Oid opno);
|
||||
extern char op_volatile(Oid opno);
|
||||
extern Oid get_commutator(Oid opno);
|
||||
extern Oid get_negator(Oid opno);
|
||||
extern RegProcedure get_oprrest(Oid opno);
|
||||
extern RegProcedure get_oprjoin(Oid opno);
|
||||
extern char *get_func_name(Oid funcid);
|
||||
extern Oid get_func_namespace(Oid funcid);
|
||||
extern Oid get_func_rettype(Oid funcid);
|
||||
extern int get_func_nargs(Oid funcid);
|
||||
extern Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs);
|
||||
extern bool get_func_retset(Oid funcid);
|
||||
extern bool func_strict(Oid funcid);
|
||||
extern char func_volatile(Oid funcid);
|
||||
extern float4 get_func_cost(Oid funcid);
|
||||
extern float4 get_func_rows(Oid funcid);
|
||||
extern Oid get_relname_relid(const char *relname, Oid relnamespace);
|
||||
extern char *get_rel_name(Oid relid);
|
||||
extern Oid get_rel_namespace(Oid relid);
|
||||
extern Oid get_rel_type_id(Oid relid);
|
||||
extern char get_rel_relkind(Oid relid);
|
||||
extern Oid get_rel_tablespace(Oid relid);
|
||||
extern bool get_typisdefined(Oid typid);
|
||||
extern int16 get_typlen(Oid typid);
|
||||
extern bool get_typbyval(Oid typid);
|
||||
extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
|
||||
extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
|
||||
char *typalign);
|
||||
extern Oid getTypeIOParam(HeapTuple typeTuple);
|
||||
extern void get_type_io_data(Oid typid,
|
||||
IOFuncSelector which_func,
|
||||
int16 *typlen,
|
||||
bool *typbyval,
|
||||
char *typalign,
|
||||
char *typdelim,
|
||||
Oid *typioparam,
|
||||
Oid *func);
|
||||
extern char get_typstorage(Oid typid);
|
||||
extern Node *get_typdefault(Oid typid);
|
||||
extern char get_typtype(Oid typid);
|
||||
extern bool type_is_rowtype(Oid typid);
|
||||
extern bool type_is_enum(Oid typid);
|
||||
extern void get_type_category_preferred(Oid typid,
|
||||
char *typcategory,
|
||||
bool *typispreferred);
|
||||
extern Oid get_typ_typrelid(Oid typid);
|
||||
extern Oid get_element_type(Oid typid);
|
||||
extern Oid get_array_type(Oid typid);
|
||||
extern Oid get_base_element_type(Oid typid);
|
||||
extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
|
||||
extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);
|
||||
extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
|
||||
extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
|
||||
extern Oid get_typmodin(Oid typid);
|
||||
extern Oid get_typcollation(Oid typid);
|
||||
extern bool type_is_collatable(Oid typid);
|
||||
extern Oid getBaseType(Oid typid);
|
||||
extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod);
|
||||
extern int32 get_typavgwidth(Oid typid, int32 typmod);
|
||||
extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
|
||||
extern bool get_attstatsslot(HeapTuple statstuple,
|
||||
Oid atttype, int32 atttypmod,
|
||||
int reqkind, Oid reqop,
|
||||
Oid *actualop,
|
||||
Datum **values, int *nvalues,
|
||||
float4 **numbers, int *nnumbers);
|
||||
extern void free_attstatsslot(Oid atttype,
|
||||
Datum *values, int nvalues,
|
||||
float4 *numbers, int nnumbers);
|
||||
extern char *get_namespace_name(Oid nspid);
|
||||
|
||||
#define type_is_array(typid) (get_element_type(typid) != InvalidOid)
|
||||
/* type_is_array_domain accepts both plain arrays and domains over arrays */
|
||||
#define type_is_array_domain(typid) (get_base_element_type(typid) != InvalidOid)
|
||||
|
||||
#define TypeIsToastable(typid) (get_typstorage(typid) != 'p')
|
||||
|
||||
#endif /* LSYSCACHE_H */
|
141
deps/libpq/include/utils/memutils.h
vendored
Normal file
141
deps/libpq/include/utils/memutils.h
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* memutils.h
|
||||
* This file contains declarations for memory allocation utility
|
||||
* functions. These are functions that are not quite widely used
|
||||
* enough to justify going in utils/palloc.h, but are still part
|
||||
* of the API of the memory management subsystem.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/memutils.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef MEMUTILS_H
|
||||
#define MEMUTILS_H
|
||||
|
||||
#include "nodes/memnodes.h"
|
||||
|
||||
|
||||
/*
|
||||
* MaxAllocSize
|
||||
* Quasi-arbitrary limit on size of allocations.
|
||||
*
|
||||
* Note:
|
||||
* There is no guarantee that allocations smaller than MaxAllocSize
|
||||
* will succeed. Allocation requests larger than MaxAllocSize will
|
||||
* be summarily denied.
|
||||
*
|
||||
* XXX This is deliberately chosen to correspond to the limiting size
|
||||
* of varlena objects under TOAST. See VARSIZE_4B() and related macros
|
||||
* in postgres.h. Many datatypes assume that any allocatable size can
|
||||
* be represented in a varlena header.
|
||||
*
|
||||
* XXX Also, various places in aset.c assume they can compute twice an
|
||||
* allocation's size without overflow, so beware of raising this.
|
||||
*/
|
||||
#define MaxAllocSize ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
|
||||
|
||||
#define AllocSizeIsValid(size) ((Size) (size) <= MaxAllocSize)
|
||||
|
||||
/*
|
||||
* All chunks allocated by any memory context manager are required to be
|
||||
* preceded by a StandardChunkHeader at a spacing of STANDARDCHUNKHEADERSIZE.
|
||||
* A currently-allocated chunk must contain a backpointer to its owning
|
||||
* context as well as the allocated size of the chunk. The backpointer is
|
||||
* used by pfree() and repalloc() to find the context to call. The allocated
|
||||
* size is not absolutely essential, but it's expected to be needed by any
|
||||
* reasonable implementation.
|
||||
*/
|
||||
typedef struct StandardChunkHeader
|
||||
{
|
||||
MemoryContext context; /* owning context */
|
||||
Size size; /* size of data space allocated in chunk */
|
||||
#ifdef MEMORY_CONTEXT_CHECKING
|
||||
/* when debugging memory usage, also store actual requested size */
|
||||
Size requested_size;
|
||||
#endif
|
||||
} StandardChunkHeader;
|
||||
|
||||
#define STANDARDCHUNKHEADERSIZE MAXALIGN(sizeof(StandardChunkHeader))
|
||||
|
||||
|
||||
/*
|
||||
* Standard top-level memory contexts.
|
||||
*
|
||||
* Only TopMemoryContext and ErrorContext are initialized by
|
||||
* MemoryContextInit() itself.
|
||||
*/
|
||||
extern PGDLLIMPORT MemoryContext TopMemoryContext;
|
||||
extern PGDLLIMPORT MemoryContext ErrorContext;
|
||||
extern PGDLLIMPORT MemoryContext PostmasterContext;
|
||||
extern PGDLLIMPORT MemoryContext CacheMemoryContext;
|
||||
extern PGDLLIMPORT MemoryContext MessageContext;
|
||||
extern PGDLLIMPORT MemoryContext TopTransactionContext;
|
||||
extern PGDLLIMPORT MemoryContext CurTransactionContext;
|
||||
|
||||
/* This is a transient link to the active portal's memory context: */
|
||||
extern PGDLLIMPORT MemoryContext PortalContext;
|
||||
|
||||
|
||||
/*
|
||||
* Memory-context-type-independent functions in mcxt.c
|
||||
*/
|
||||
extern void MemoryContextInit(void);
|
||||
extern void MemoryContextReset(MemoryContext context);
|
||||
extern void MemoryContextDelete(MemoryContext context);
|
||||
extern void MemoryContextResetChildren(MemoryContext context);
|
||||
extern void MemoryContextDeleteChildren(MemoryContext context);
|
||||
extern void MemoryContextResetAndDeleteChildren(MemoryContext context);
|
||||
extern Size GetMemoryChunkSpace(void *pointer);
|
||||
extern MemoryContext GetMemoryChunkContext(void *pointer);
|
||||
extern bool MemoryContextIsEmpty(MemoryContext context);
|
||||
extern void MemoryContextStats(MemoryContext context);
|
||||
|
||||
#ifdef MEMORY_CONTEXT_CHECKING
|
||||
extern void MemoryContextCheck(MemoryContext context);
|
||||
#endif
|
||||
extern bool MemoryContextContains(MemoryContext context, void *pointer);
|
||||
|
||||
/*
|
||||
* This routine handles the context-type-independent part of memory
|
||||
* context creation. It's intended to be called from context-type-
|
||||
* specific creation routines, and noplace else.
|
||||
*/
|
||||
extern MemoryContext MemoryContextCreate(NodeTag tag, Size size,
|
||||
MemoryContextMethods *methods,
|
||||
MemoryContext parent,
|
||||
const char *name);
|
||||
|
||||
|
||||
/*
|
||||
* Memory-context-type-specific functions
|
||||
*/
|
||||
|
||||
/* aset.c */
|
||||
extern MemoryContext AllocSetContextCreate(MemoryContext parent,
|
||||
const char *name,
|
||||
Size minContextSize,
|
||||
Size initBlockSize,
|
||||
Size maxBlockSize);
|
||||
|
||||
/*
|
||||
* Recommended default alloc parameters, suitable for "ordinary" contexts
|
||||
* that might hold quite a lot of data.
|
||||
*/
|
||||
#define ALLOCSET_DEFAULT_MINSIZE 0
|
||||
#define ALLOCSET_DEFAULT_INITSIZE (8 * 1024)
|
||||
#define ALLOCSET_DEFAULT_MAXSIZE (8 * 1024 * 1024)
|
||||
|
||||
/*
|
||||
* Recommended alloc parameters for "small" contexts that are not expected
|
||||
* to contain much data (for example, a context to contain a query plan).
|
||||
*/
|
||||
#define ALLOCSET_SMALL_MINSIZE 0
|
||||
#define ALLOCSET_SMALL_INITSIZE (1 * 1024)
|
||||
#define ALLOCSET_SMALL_MAXSIZE (8 * 1024)
|
||||
|
||||
#endif /* MEMUTILS_H */
|
167
deps/libpq/include/utils/nabstime.h
vendored
Normal file
167
deps/libpq/include/utils/nabstime.h
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* nabstime.h
|
||||
* Definitions for the "new" abstime code.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/nabstime.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef NABSTIME_H
|
||||
#define NABSTIME_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "utils/timestamp.h"
|
||||
#include "utils/datetime.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
*
|
||||
* time types + support macros
|
||||
*
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Although time_t generally is a long int on 64 bit systems, these two
|
||||
* types must be 4 bytes, because that's what pg_type.h assumes. They
|
||||
* should be yanked (long) before 2038 and be replaced by timestamp and
|
||||
* interval.
|
||||
*/
|
||||
typedef int32 AbsoluteTime;
|
||||
typedef int32 RelativeTime;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32 status;
|
||||
AbsoluteTime data[2];
|
||||
} TimeIntervalData;
|
||||
|
||||
typedef TimeIntervalData *TimeInterval;
|
||||
|
||||
/*
|
||||
* Macros for fmgr-callable functions.
|
||||
*/
|
||||
#define DatumGetAbsoluteTime(X) ((AbsoluteTime) DatumGetInt32(X))
|
||||
#define DatumGetRelativeTime(X) ((RelativeTime) DatumGetInt32(X))
|
||||
#define DatumGetTimeInterval(X) ((TimeInterval) DatumGetPointer(X))
|
||||
|
||||
#define AbsoluteTimeGetDatum(X) Int32GetDatum(X)
|
||||
#define RelativeTimeGetDatum(X) Int32GetDatum(X)
|
||||
#define TimeIntervalGetDatum(X) PointerGetDatum(X)
|
||||
|
||||
#define PG_GETARG_ABSOLUTETIME(n) DatumGetAbsoluteTime(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_RELATIVETIME(n) DatumGetRelativeTime(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_TIMEINTERVAL(n) DatumGetTimeInterval(PG_GETARG_DATUM(n))
|
||||
|
||||
#define PG_RETURN_ABSOLUTETIME(x) return AbsoluteTimeGetDatum(x)
|
||||
#define PG_RETURN_RELATIVETIME(x) return RelativeTimeGetDatum(x)
|
||||
#define PG_RETURN_TIMEINTERVAL(x) return TimeIntervalGetDatum(x)
|
||||
|
||||
/*
|
||||
* Reserved values
|
||||
* Epoch is Unix system time zero, but needs to be kept as a reserved
|
||||
* value rather than converting to time since timezone calculations
|
||||
* might move it away from 1970-01-01 00:00:00Z - tgl 97/02/20
|
||||
*
|
||||
* Pre-v6.1 code had large decimal numbers for reserved values.
|
||||
* These were chosen as special 32-bit bit patterns,
|
||||
* so redefine them explicitly using these bit patterns. - tgl 97/02/24
|
||||
*/
|
||||
#define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE) /* 2147483647 (2^31 - 1) */
|
||||
#define NOEND_ABSTIME ((AbsoluteTime) 0x7FFFFFFC) /* 2147483645 (2^31 - 3) */
|
||||
#define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN) /* -2147483648 */
|
||||
|
||||
#define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE) /* 2147483647 (2^31 - 1) */
|
||||
|
||||
#define AbsoluteTimeIsValid(time) \
|
||||
((bool) ((time) != INVALID_ABSTIME))
|
||||
|
||||
/*
|
||||
* Because NOSTART_ABSTIME is defined as INT_MIN, there can't be any
|
||||
* AbsoluteTime values less than it. Therefore, we can code the test
|
||||
* "time > NOSTART_ABSTIME" as "time != NOSTART_ABSTIME", which avoids
|
||||
* compiler bugs on some platforms. --- tgl & az, 11/2000
|
||||
*/
|
||||
#define AbsoluteTimeIsReal(time) \
|
||||
((bool) (((AbsoluteTime) (time)) < NOEND_ABSTIME && \
|
||||
((AbsoluteTime) (time)) != NOSTART_ABSTIME))
|
||||
|
||||
#define RelativeTimeIsValid(time) \
|
||||
((bool) (((RelativeTime) (time)) != INVALID_RELTIME))
|
||||
|
||||
|
||||
/*
|
||||
* nabstime.c prototypes
|
||||
*/
|
||||
extern Datum abstimein(PG_FUNCTION_ARGS);
|
||||
extern Datum abstimeout(PG_FUNCTION_ARGS);
|
||||
extern Datum abstimerecv(PG_FUNCTION_ARGS);
|
||||
extern Datum abstimesend(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum abstimeeq(PG_FUNCTION_ARGS);
|
||||
extern Datum abstimene(PG_FUNCTION_ARGS);
|
||||
extern Datum abstimelt(PG_FUNCTION_ARGS);
|
||||
extern Datum abstimegt(PG_FUNCTION_ARGS);
|
||||
extern Datum abstimele(PG_FUNCTION_ARGS);
|
||||
extern Datum abstimege(PG_FUNCTION_ARGS);
|
||||
extern Datum abstime_finite(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timestamp_abstime(PG_FUNCTION_ARGS);
|
||||
extern Datum abstime_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_abstime(PG_FUNCTION_ARGS);
|
||||
extern Datum abstime_timestamptz(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum reltimein(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimeout(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimerecv(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimesend(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalin(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalout(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalrecv(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalsend(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_reltime(PG_FUNCTION_ARGS);
|
||||
extern Datum reltime_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum mktinterval(PG_FUNCTION_ARGS);
|
||||
extern Datum timepl(PG_FUNCTION_ARGS);
|
||||
extern Datum timemi(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum intinterval(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalrel(PG_FUNCTION_ARGS);
|
||||
extern Datum timenow(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimeeq(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimene(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimelt(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimegt(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimele(PG_FUNCTION_ARGS);
|
||||
extern Datum reltimege(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalsame(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervaleq(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalne(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervallt(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalgt(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalle(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalge(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalleneq(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervallenne(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervallenlt(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervallengt(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervallenle(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervallenge(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalct(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalov(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalstart(PG_FUNCTION_ARGS);
|
||||
extern Datum tintervalend(PG_FUNCTION_ARGS);
|
||||
extern Datum timeofday(PG_FUNCTION_ARGS);
|
||||
|
||||
/* non-fmgr-callable support routines */
|
||||
extern AbsoluteTime GetCurrentAbsoluteTime(void);
|
||||
extern void abstime2tm(AbsoluteTime time, int *tzp, struct pg_tm * tm, char **tzn);
|
||||
|
||||
#endif /* NABSTIME_H */
|
62
deps/libpq/include/utils/numeric.h
vendored
Normal file
62
deps/libpq/include/utils/numeric.h
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* numeric.h
|
||||
* Definitions for the exact numeric data type of Postgres
|
||||
*
|
||||
* Original coding 1998, Jan Wieck. Heavily revised 2003, Tom Lane.
|
||||
*
|
||||
* Copyright (c) 1998-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
* src/include/utils/numeric.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef _PG_NUMERIC_H_
|
||||
#define _PG_NUMERIC_H_
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
/*
|
||||
* Hardcoded precision limit - arbitrary, but must be small enough that
|
||||
* dscale values will fit in 14 bits.
|
||||
*/
|
||||
#define NUMERIC_MAX_PRECISION 1000
|
||||
|
||||
/*
|
||||
* Internal limits on the scales chosen for calculation results
|
||||
*/
|
||||
#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
|
||||
#define NUMERIC_MIN_DISPLAY_SCALE 0
|
||||
|
||||
#define NUMERIC_MAX_RESULT_SCALE (NUMERIC_MAX_PRECISION * 2)
|
||||
|
||||
/*
|
||||
* For inherently inexact calculations such as division and square root,
|
||||
* we try to get at least this many significant digits; the idea is to
|
||||
* deliver a result no worse than float8 would.
|
||||
*/
|
||||
#define NUMERIC_MIN_SIG_DIGITS 16
|
||||
|
||||
/* The actual contents of Numeric are private to numeric.c */
|
||||
struct NumericData;
|
||||
typedef struct NumericData *Numeric;
|
||||
|
||||
/*
|
||||
* fmgr interface macros
|
||||
*/
|
||||
|
||||
#define DatumGetNumeric(X) ((Numeric) PG_DETOAST_DATUM(X))
|
||||
#define DatumGetNumericCopy(X) ((Numeric) PG_DETOAST_DATUM_COPY(X))
|
||||
#define NumericGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_NUMERIC(n) DatumGetNumeric(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_NUMERIC_COPY(n) DatumGetNumericCopy(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_NUMERIC(x) return NumericGetDatum(x)
|
||||
|
||||
/*
|
||||
* Utility functions in numeric.c
|
||||
*/
|
||||
extern bool numeric_is_nan(Numeric num);
|
||||
int32 numeric_maximum_size(int32 typmod);
|
||||
extern char *numeric_out_sci(Numeric num, int scale);
|
||||
|
||||
#endif /* _PG_NUMERIC_H_ */
|
112
deps/libpq/include/utils/palloc.h
vendored
Normal file
112
deps/libpq/include/utils/palloc.h
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* palloc.h
|
||||
* POSTGRES memory allocator definitions.
|
||||
*
|
||||
* This file contains the basic memory allocation interface that is
|
||||
* needed by almost every backend module. It is included directly by
|
||||
* postgres.h, so the definitions here are automatically available
|
||||
* everywhere. Keep it lean!
|
||||
*
|
||||
* Memory allocation occurs within "contexts". Every chunk obtained from
|
||||
* palloc()/MemoryContextAlloc() is allocated within a specific context.
|
||||
* The entire contents of a context can be freed easily and quickly by
|
||||
* resetting or deleting the context --- this is both faster and less
|
||||
* prone to memory-leakage bugs than releasing chunks individually.
|
||||
* We organize contexts into context trees to allow fine-grain control
|
||||
* over chunk lifetime while preserving the certainty that we will free
|
||||
* everything that should be freed. See utils/mmgr/README for more info.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/palloc.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PALLOC_H
|
||||
#define PALLOC_H
|
||||
|
||||
/*
|
||||
* Type MemoryContextData is declared in nodes/memnodes.h. Most users
|
||||
* of memory allocation should just treat it as an abstract type, so we
|
||||
* do not provide the struct contents here.
|
||||
*/
|
||||
typedef struct MemoryContextData *MemoryContext;
|
||||
|
||||
/*
|
||||
* CurrentMemoryContext is the default allocation context for palloc().
|
||||
* We declare it here so that palloc() can be a macro. Avoid accessing it
|
||||
* directly! Instead, use MemoryContextSwitchTo() to change the setting.
|
||||
*/
|
||||
extern PGDLLIMPORT MemoryContext CurrentMemoryContext;
|
||||
|
||||
/*
|
||||
* Fundamental memory-allocation operations (more are in utils/memutils.h)
|
||||
*/
|
||||
extern void *MemoryContextAlloc(MemoryContext context, Size size);
|
||||
extern void *MemoryContextAllocZero(MemoryContext context, Size size);
|
||||
extern void *MemoryContextAllocZeroAligned(MemoryContext context, Size size);
|
||||
|
||||
#define palloc(sz) MemoryContextAlloc(CurrentMemoryContext, (sz))
|
||||
|
||||
#define palloc0(sz) MemoryContextAllocZero(CurrentMemoryContext, (sz))
|
||||
|
||||
/*
|
||||
* The result of palloc() is always word-aligned, so we can skip testing
|
||||
* alignment of the pointer when deciding which MemSet variant to use.
|
||||
* Note that this variant does not offer any advantage, and should not be
|
||||
* used, unless its "sz" argument is a compile-time constant; therefore, the
|
||||
* issue that it evaluates the argument multiple times isn't a problem in
|
||||
* practice.
|
||||
*/
|
||||
#define palloc0fast(sz) \
|
||||
( MemSetTest(0, sz) ? \
|
||||
MemoryContextAllocZeroAligned(CurrentMemoryContext, sz) : \
|
||||
MemoryContextAllocZero(CurrentMemoryContext, sz) )
|
||||
|
||||
extern void pfree(void *pointer);
|
||||
|
||||
extern void *repalloc(void *pointer, Size size);
|
||||
|
||||
/*
|
||||
* MemoryContextSwitchTo can't be a macro in standard C compilers.
|
||||
* But we can make it an inline function if the compiler supports it.
|
||||
*
|
||||
* This file has to be includable by some non-backend code such as
|
||||
* pg_resetxlog, so don't expose the CurrentMemoryContext reference
|
||||
* if FRONTEND is defined.
|
||||
*/
|
||||
#if defined(USE_INLINE) && !defined(FRONTEND)
|
||||
|
||||
static inline MemoryContext
|
||||
MemoryContextSwitchTo(MemoryContext context)
|
||||
{
|
||||
MemoryContext old = CurrentMemoryContext;
|
||||
|
||||
CurrentMemoryContext = context;
|
||||
return old;
|
||||
}
|
||||
#else
|
||||
|
||||
extern MemoryContext MemoryContextSwitchTo(MemoryContext context);
|
||||
#endif /* USE_INLINE && !FRONTEND */
|
||||
|
||||
/*
|
||||
* These are like standard strdup() except the copied string is
|
||||
* allocated in a context, not with malloc().
|
||||
*/
|
||||
extern char *MemoryContextStrdup(MemoryContext context, const char *string);
|
||||
|
||||
#define pstrdup(str) MemoryContextStrdup(CurrentMemoryContext, (str))
|
||||
|
||||
extern char *pnstrdup(const char *in, Size len);
|
||||
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
extern void *pgport_palloc(Size sz);
|
||||
extern char *pgport_pstrdup(const char *str);
|
||||
extern void pgport_pfree(void *pointer);
|
||||
#endif
|
||||
|
||||
#endif /* PALLOC_H */
|
152
deps/libpq/include/utils/pg_crc.h
vendored
Normal file
152
deps/libpq/include/utils/pg_crc.h
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* pg_crc.h
|
||||
*
|
||||
* PostgreSQL CRC support
|
||||
*
|
||||
* See Ross Williams' excellent introduction
|
||||
* A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from
|
||||
* http://www.ross.net/crc/ or several other net sites.
|
||||
*
|
||||
* We use a normal (not "reflected", in Williams' terms) CRC, using initial
|
||||
* all-ones register contents and a final bit inversion.
|
||||
*
|
||||
* The 64-bit variant is not used as of PostgreSQL 8.1, but we retain the
|
||||
* code for possible future use.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/pg_crc.h
|
||||
*/
|
||||
#ifndef PG_CRC_H
|
||||
#define PG_CRC_H
|
||||
|
||||
/* ugly hack to let this be used in frontend and backend code on Cygwin */
|
||||
#ifdef FRONTEND
|
||||
#define CRCDLLIMPORT
|
||||
#else
|
||||
#define CRCDLLIMPORT PGDLLIMPORT
|
||||
#endif
|
||||
|
||||
typedef uint32 pg_crc32;
|
||||
|
||||
/* Initialize a CRC accumulator */
|
||||
#define INIT_CRC32(crc) ((crc) = 0xFFFFFFFF)
|
||||
|
||||
/* Finish a CRC calculation */
|
||||
#define FIN_CRC32(crc) ((crc) ^= 0xFFFFFFFF)
|
||||
|
||||
/* Accumulate some (more) bytes into a CRC */
|
||||
#define COMP_CRC32(crc, data, len) \
|
||||
do { \
|
||||
unsigned char *__data = (unsigned char *) (data); \
|
||||
uint32 __len = (len); \
|
||||
\
|
||||
while (__len-- > 0) \
|
||||
{ \
|
||||
int __tab_index = ((int) ((crc) >> 24) ^ *__data++) & 0xFF; \
|
||||
(crc) = pg_crc32_table[__tab_index] ^ ((crc) << 8); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Check for equality of two CRCs */
|
||||
#define EQ_CRC32(c1,c2) ((c1) == (c2))
|
||||
|
||||
/* Constant table for CRC calculation */
|
||||
extern CRCDLLIMPORT const uint32 pg_crc32_table[];
|
||||
|
||||
|
||||
#ifdef PROVIDE_64BIT_CRC
|
||||
|
||||
/*
|
||||
* If we use a 64-bit integer type, then a 64-bit CRC looks just like the
|
||||
* usual sort of implementation. However, we can also fake it with two
|
||||
* 32-bit registers. Experience has shown that the two-32-bit-registers code
|
||||
* is as fast as, or even much faster than, the 64-bit code on all but true
|
||||
* 64-bit machines. We use SIZEOF_VOID_P to check the native word width.
|
||||
*/
|
||||
|
||||
#if SIZEOF_VOID_P < 8
|
||||
|
||||
/*
|
||||
* crc0 represents the LSBs of the 64-bit value, crc1 the MSBs. Note that
|
||||
* with crc0 placed first, the output of 32-bit and 64-bit implementations
|
||||
* will be bit-compatible only on little-endian architectures. If it were
|
||||
* important to make the two possible implementations bit-compatible on
|
||||
* all machines, we could do a configure test to decide how to order the
|
||||
* two fields, but it seems not worth the trouble.
|
||||
*/
|
||||
typedef struct pg_crc64
|
||||
{
|
||||
uint32 crc0;
|
||||
uint32 crc1;
|
||||
} pg_crc64;
|
||||
|
||||
/* Initialize a CRC accumulator */
|
||||
#define INIT_CRC64(crc) ((crc).crc0 = 0xffffffff, (crc).crc1 = 0xffffffff)
|
||||
|
||||
/* Finish a CRC calculation */
|
||||
#define FIN_CRC64(crc) ((crc).crc0 ^= 0xffffffff, (crc).crc1 ^= 0xffffffff)
|
||||
|
||||
/* Accumulate some (more) bytes into a CRC */
|
||||
#define COMP_CRC64(crc, data, len) \
|
||||
do { \
|
||||
uint32 __crc0 = (crc).crc0; \
|
||||
uint32 __crc1 = (crc).crc1; \
|
||||
unsigned char *__data = (unsigned char *) (data); \
|
||||
uint32 __len = (len); \
|
||||
\
|
||||
while (__len-- > 0) \
|
||||
{ \
|
||||
int __tab_index = ((int) (__crc1 >> 24) ^ *__data++) & 0xFF; \
|
||||
__crc1 = pg_crc64_table1[__tab_index] ^ ((__crc1 << 8) | (__crc0 >> 24)); \
|
||||
__crc0 = pg_crc64_table0[__tab_index] ^ (__crc0 << 8); \
|
||||
} \
|
||||
(crc).crc0 = __crc0; \
|
||||
(crc).crc1 = __crc1; \
|
||||
} while (0)
|
||||
|
||||
/* Check for equality of two CRCs */
|
||||
#define EQ_CRC64(c1,c2) ((c1).crc0 == (c2).crc0 && (c1).crc1 == (c2).crc1)
|
||||
|
||||
/* Constant table for CRC calculation */
|
||||
extern CRCDLLIMPORT const uint32 pg_crc64_table0[];
|
||||
extern CRCDLLIMPORT const uint32 pg_crc64_table1[];
|
||||
#else /* use int64 implementation */
|
||||
|
||||
typedef struct pg_crc64
|
||||
{
|
||||
uint64 crc0;
|
||||
} pg_crc64;
|
||||
|
||||
/* Initialize a CRC accumulator */
|
||||
#define INIT_CRC64(crc) ((crc).crc0 = UINT64CONST(0xffffffffffffffff))
|
||||
|
||||
/* Finish a CRC calculation */
|
||||
#define FIN_CRC64(crc) ((crc).crc0 ^= UINT64CONST(0xffffffffffffffff))
|
||||
|
||||
/* Accumulate some (more) bytes into a CRC */
|
||||
#define COMP_CRC64(crc, data, len) \
|
||||
do { \
|
||||
uint64 __crc0 = (crc).crc0; \
|
||||
unsigned char *__data = (unsigned char *) (data); \
|
||||
uint32 __len = (len); \
|
||||
\
|
||||
while (__len-- > 0) \
|
||||
{ \
|
||||
int __tab_index = ((int) (__crc0 >> 56) ^ *__data++) & 0xFF; \
|
||||
__crc0 = pg_crc64_table[__tab_index] ^ (__crc0 << 8); \
|
||||
} \
|
||||
(crc).crc0 = __crc0; \
|
||||
} while (0)
|
||||
|
||||
/* Check for equality of two CRCs */
|
||||
#define EQ_CRC64(c1,c2) ((c1).crc0 == (c2).crc0)
|
||||
|
||||
/* Constant table for CRC calculation */
|
||||
extern CRCDLLIMPORT const uint64 pg_crc64_table[];
|
||||
#endif /* SIZEOF_VOID_P < 8 */
|
||||
#endif /* PROVIDE_64BIT_CRC */
|
||||
|
||||
#endif /* PG_CRC_H */
|
83
deps/libpq/include/utils/pg_locale.h
vendored
Normal file
83
deps/libpq/include/utils/pg_locale.h
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*-----------------------------------------------------------------------
|
||||
*
|
||||
* PostgreSQL locale utilities
|
||||
*
|
||||
* src/include/utils/pg_locale.h
|
||||
*
|
||||
* Copyright (c) 2002-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _PG_LOCALE_
|
||||
#define _PG_LOCALE_
|
||||
|
||||
#include <locale.h>
|
||||
#ifdef LOCALE_T_IN_XLOCALE
|
||||
#include <xlocale.h>
|
||||
#endif
|
||||
|
||||
#include "utils/guc.h"
|
||||
|
||||
|
||||
/* GUC settings */
|
||||
extern char *locale_messages;
|
||||
extern char *locale_monetary;
|
||||
extern char *locale_numeric;
|
||||
extern char *locale_time;
|
||||
|
||||
/* lc_time localization cache */
|
||||
extern char *localized_abbrev_days[];
|
||||
extern char *localized_full_days[];
|
||||
extern char *localized_abbrev_months[];
|
||||
extern char *localized_full_months[];
|
||||
|
||||
|
||||
extern bool check_locale_messages(char **newval, void **extra, GucSource source);
|
||||
extern void assign_locale_messages(const char *newval, void *extra);
|
||||
extern bool check_locale_monetary(char **newval, void **extra, GucSource source);
|
||||
extern void assign_locale_monetary(const char *newval, void *extra);
|
||||
extern bool check_locale_numeric(char **newval, void **extra, GucSource source);
|
||||
extern void assign_locale_numeric(const char *newval, void *extra);
|
||||
extern bool check_locale_time(char **newval, void **extra, GucSource source);
|
||||
extern void assign_locale_time(const char *newval, void *extra);
|
||||
|
||||
extern bool check_locale(int category, const char *locale);
|
||||
extern char *pg_perm_setlocale(int category, const char *locale);
|
||||
|
||||
extern bool lc_collate_is_c(Oid collation);
|
||||
extern bool lc_ctype_is_c(Oid collation);
|
||||
|
||||
/*
|
||||
* Return the POSIX lconv struct (contains number/money formatting
|
||||
* information) with locale information for all categories.
|
||||
*/
|
||||
extern struct lconv *PGLC_localeconv(void);
|
||||
|
||||
extern void cache_locale_time(void);
|
||||
|
||||
|
||||
/*
|
||||
* We define our own wrapper around locale_t so we can keep the same
|
||||
* function signatures for all builds, while not having to create a
|
||||
* fake version of the standard type locale_t in the global namespace.
|
||||
* The fake version of pg_locale_t can be checked for truth; that's
|
||||
* about all it will be needed for.
|
||||
*/
|
||||
#ifdef HAVE_LOCALE_T
|
||||
typedef locale_t pg_locale_t;
|
||||
#else
|
||||
typedef int pg_locale_t;
|
||||
#endif
|
||||
|
||||
extern pg_locale_t pg_newlocale_from_collation(Oid collid);
|
||||
|
||||
/* These functions convert from/to libc's wchar_t, *not* pg_wchar_t */
|
||||
#ifdef USE_WIDE_UPPER_LOWER
|
||||
extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen,
|
||||
pg_locale_t locale);
|
||||
extern size_t char2wchar(wchar_t *to, size_t tolen,
|
||||
const char *from, size_t fromlen, pg_locale_t locale);
|
||||
#endif
|
||||
|
||||
#endif /* _PG_LOCALE_ */
|
112
deps/libpq/include/utils/pg_lzcompress.h
vendored
Normal file
112
deps/libpq/include/utils/pg_lzcompress.h
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
/* ----------
|
||||
* pg_lzcompress.h -
|
||||
*
|
||||
* Definitions for the builtin LZ compressor
|
||||
*
|
||||
* src/include/utils/pg_lzcompress.h
|
||||
* ----------
|
||||
*/
|
||||
|
||||
#ifndef _PG_LZCOMPRESS_H_
|
||||
#define _PG_LZCOMPRESS_H_
|
||||
|
||||
|
||||
/* ----------
|
||||
* PGLZ_Header -
|
||||
*
|
||||
* The information at the start of the compressed data.
|
||||
* ----------
|
||||
*/
|
||||
typedef struct PGLZ_Header
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
int32 rawsize;
|
||||
} PGLZ_Header;
|
||||
|
||||
|
||||
/* ----------
|
||||
* PGLZ_MAX_OUTPUT -
|
||||
*
|
||||
* Macro to compute the buffer size required by pglz_compress().
|
||||
* We allow 4 bytes for overrun before detecting compression failure.
|
||||
* ----------
|
||||
*/
|
||||
#define PGLZ_MAX_OUTPUT(_dlen) ((_dlen) + 4 + sizeof(PGLZ_Header))
|
||||
|
||||
/* ----------
|
||||
* PGLZ_RAW_SIZE -
|
||||
*
|
||||
* Macro to determine the uncompressed data size contained
|
||||
* in the entry.
|
||||
* ----------
|
||||
*/
|
||||
#define PGLZ_RAW_SIZE(_lzdata) ((_lzdata)->rawsize)
|
||||
|
||||
|
||||
/* ----------
|
||||
* PGLZ_Strategy -
|
||||
*
|
||||
* Some values that control the compression algorithm.
|
||||
*
|
||||
* min_input_size Minimum input data size to consider compression.
|
||||
*
|
||||
* max_input_size Maximum input data size to consider compression.
|
||||
*
|
||||
* min_comp_rate Minimum compression rate (0-99%) to require.
|
||||
* Regardless of min_comp_rate, the output must be
|
||||
* smaller than the input, else we don't store
|
||||
* compressed.
|
||||
*
|
||||
* first_success_by Abandon compression if we find no compressible
|
||||
* data within the first this-many bytes.
|
||||
*
|
||||
* match_size_good The initial GOOD match size when starting history
|
||||
* lookup. When looking up the history to find a
|
||||
* match that could be expressed as a tag, the
|
||||
* algorithm does not always walk back entirely.
|
||||
* A good match fast is usually better than the
|
||||
* best possible one very late. For each iteration
|
||||
* in the lookup, this value is lowered so the
|
||||
* longer the lookup takes, the smaller matches
|
||||
* are considered good.
|
||||
*
|
||||
* match_size_drop The percentage by which match_size_good is lowered
|
||||
* after each history check. Allowed values are
|
||||
* 0 (no change until end) to 100 (only check
|
||||
* latest history entry at all).
|
||||
* ----------
|
||||
*/
|
||||
typedef struct PGLZ_Strategy
|
||||
{
|
||||
int32 min_input_size;
|
||||
int32 max_input_size;
|
||||
int32 min_comp_rate;
|
||||
int32 first_success_by;
|
||||
int32 match_size_good;
|
||||
int32 match_size_drop;
|
||||
} PGLZ_Strategy;
|
||||
|
||||
|
||||
/* ----------
|
||||
* The standard strategies
|
||||
*
|
||||
* PGLZ_strategy_default Recommended default strategy for TOAST.
|
||||
*
|
||||
* PGLZ_strategy_always Try to compress inputs of any length.
|
||||
* Fallback to uncompressed storage only if
|
||||
* output would be larger than input.
|
||||
* ----------
|
||||
*/
|
||||
extern const PGLZ_Strategy *const PGLZ_strategy_default;
|
||||
extern const PGLZ_Strategy *const PGLZ_strategy_always;
|
||||
|
||||
|
||||
/* ----------
|
||||
* Global function declarations
|
||||
* ----------
|
||||
*/
|
||||
extern bool pglz_compress(const char *source, int32 slen, PGLZ_Header *dest,
|
||||
const PGLZ_Strategy *strategy);
|
||||
extern void pglz_decompress(const PGLZ_Header *source, char *dest);
|
||||
|
||||
#endif /* _PG_LZCOMPRESS_H_ */
|
37
deps/libpq/include/utils/pg_rusage.h
vendored
Normal file
37
deps/libpq/include/utils/pg_rusage.h
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* pg_rusage.h
|
||||
* header file for resource usage measurement support routines
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/pg_rusage.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PG_RUSAGE_H
|
||||
#define PG_RUSAGE_H
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#else
|
||||
#include "rusagestub.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* State structure for pg_rusage_init/pg_rusage_show */
|
||||
typedef struct PGRUsage
|
||||
{
|
||||
struct timeval tv;
|
||||
struct rusage ru;
|
||||
} PGRUsage;
|
||||
|
||||
|
||||
extern void pg_rusage_init(PGRUsage *ru0);
|
||||
extern const char *pg_rusage_show(const PGRUsage *ru0);
|
||||
|
||||
#endif /* PG_RUSAGE_H */
|
123
deps/libpq/include/utils/plancache.h
vendored
Normal file
123
deps/libpq/include/utils/plancache.h
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* plancache.h
|
||||
* Plan cache definitions.
|
||||
*
|
||||
* See plancache.c for comments.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/plancache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PLANCACHE_H
|
||||
#define PLANCACHE_H
|
||||
|
||||
#include "access/tupdesc.h"
|
||||
#include "nodes/params.h"
|
||||
|
||||
/*
|
||||
* CachedPlanSource represents the portion of a cached plan that persists
|
||||
* across invalidation/replan cycles. It stores a raw parse tree (required),
|
||||
* the original source text (also required, as of 8.4), and adjunct data.
|
||||
*
|
||||
* Normally, both the struct itself and the subsidiary data live in the
|
||||
* context denoted by the context field, while the linked-to CachedPlan, if
|
||||
* any, has its own context. Thus an invalidated CachedPlan can be dropped
|
||||
* when no longer needed, and conversely a CachedPlanSource can be dropped
|
||||
* without worrying whether any portals depend on particular instances of
|
||||
* its plan.
|
||||
*
|
||||
* But for entries created by FastCreateCachedPlan, the CachedPlanSource
|
||||
* and the initial version of the CachedPlan share the same memory context.
|
||||
* In this case, we treat the memory context as belonging to the CachedPlan.
|
||||
* The CachedPlanSource has an extra reference-counted link (orig_plan)
|
||||
* to the CachedPlan, and the memory context goes away when the CachedPlan's
|
||||
* reference count goes to zero. This arrangement saves overhead for plans
|
||||
* that aren't expected to live long enough to need replanning, while not
|
||||
* losing any flexibility if a replan turns out to be necessary.
|
||||
*
|
||||
* Note: the string referenced by commandTag is not subsidiary storage;
|
||||
* it is assumed to be a compile-time-constant string. As with portals,
|
||||
* commandTag shall be NULL if and only if the original query string (before
|
||||
* rewriting) was an empty string.
|
||||
*/
|
||||
typedef struct CachedPlanSource
|
||||
{
|
||||
Node *raw_parse_tree; /* output of raw_parser() */
|
||||
char *query_string; /* text of query (as of 8.4, never NULL) */
|
||||
const char *commandTag; /* command tag (a constant!), or NULL */
|
||||
Oid *param_types; /* array of parameter type OIDs, or NULL */
|
||||
int num_params; /* length of param_types array */
|
||||
ParserSetupHook parserSetup; /* alternative parameter spec method */
|
||||
void *parserSetupArg;
|
||||
int cursor_options; /* cursor options used for planning */
|
||||
bool fully_planned; /* do we cache planner or rewriter output? */
|
||||
bool fixed_result; /* disallow change in result tupdesc? */
|
||||
struct OverrideSearchPath *search_path; /* saved search_path */
|
||||
int generation; /* counter, starting at 1, for replans */
|
||||
TupleDesc resultDesc; /* result type; NULL = doesn't return tuples */
|
||||
struct CachedPlan *plan; /* link to plan, or NULL if not valid */
|
||||
MemoryContext context; /* context containing this CachedPlanSource */
|
||||
struct CachedPlan *orig_plan; /* link to plan owning my context */
|
||||
} CachedPlanSource;
|
||||
|
||||
/*
|
||||
* CachedPlan represents the portion of a cached plan that is discarded when
|
||||
* invalidation occurs. The reference count includes both the link(s) from the
|
||||
* parent CachedPlanSource, and any active plan executions, so the plan can be
|
||||
* discarded exactly when refcount goes to zero. Both the struct itself and
|
||||
* the subsidiary data live in the context denoted by the context field.
|
||||
* This makes it easy to free a no-longer-needed cached plan.
|
||||
*/
|
||||
typedef struct CachedPlan
|
||||
{
|
||||
List *stmt_list; /* list of statement or Query nodes */
|
||||
bool fully_planned; /* do we cache planner or rewriter output? */
|
||||
bool dead; /* if true, do not use */
|
||||
TransactionId saved_xmin; /* if valid, replan when TransactionXmin
|
||||
* changes from this value */
|
||||
int refcount; /* count of live references to this struct */
|
||||
int generation; /* counter, starting at 1, for replans */
|
||||
MemoryContext context; /* context containing this CachedPlan */
|
||||
/* These fields are used only in the not-fully-planned case: */
|
||||
List *relationOids; /* OIDs of relations the stmts depend on */
|
||||
List *invalItems; /* other dependencies, as PlanInvalItems */
|
||||
} CachedPlan;
|
||||
|
||||
|
||||
extern void InitPlanCache(void);
|
||||
extern CachedPlanSource *CreateCachedPlan(Node *raw_parse_tree,
|
||||
const char *query_string,
|
||||
const char *commandTag,
|
||||
Oid *param_types,
|
||||
int num_params,
|
||||
int cursor_options,
|
||||
List *stmt_list,
|
||||
bool fully_planned,
|
||||
bool fixed_result);
|
||||
extern CachedPlanSource *FastCreateCachedPlan(Node *raw_parse_tree,
|
||||
char *query_string,
|
||||
const char *commandTag,
|
||||
Oid *param_types,
|
||||
int num_params,
|
||||
int cursor_options,
|
||||
List *stmt_list,
|
||||
bool fully_planned,
|
||||
bool fixed_result,
|
||||
MemoryContext context);
|
||||
extern void CachedPlanSetParserHook(CachedPlanSource *plansource,
|
||||
ParserSetupHook parserSetup,
|
||||
void *parserSetupArg);
|
||||
extern void DropCachedPlan(CachedPlanSource *plansource);
|
||||
extern CachedPlan *RevalidateCachedPlan(CachedPlanSource *plansource,
|
||||
bool useResOwner);
|
||||
extern void ReleaseCachedPlan(CachedPlan *plan, bool useResOwner);
|
||||
extern bool CachedPlanIsValid(CachedPlanSource *plansource);
|
||||
extern TupleDesc PlanCacheComputeResultDesc(List *stmt_list);
|
||||
|
||||
extern void ResetPlanCache(void);
|
||||
|
||||
#endif /* PLANCACHE_H */
|
223
deps/libpq/include/utils/portal.h
vendored
Normal file
223
deps/libpq/include/utils/portal.h
vendored
Normal file
|
@ -0,0 +1,223 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* portal.h
|
||||
* POSTGRES portal definitions.
|
||||
*
|
||||
* A portal is an abstraction which represents the execution state of
|
||||
* a running or runnable query. Portals support both SQL-level CURSORs
|
||||
* and protocol-level portals.
|
||||
*
|
||||
* Scrolling (nonsequential access) and suspension of execution are allowed
|
||||
* only for portals that contain a single SELECT-type query. We do not want
|
||||
* to let the client suspend an update-type query partway through! Because
|
||||
* the query rewriter does not allow arbitrary ON SELECT rewrite rules,
|
||||
* only queries that were originally update-type could produce multiple
|
||||
* plan trees; so the restriction to a single query is not a problem
|
||||
* in practice.
|
||||
*
|
||||
* For SQL cursors, we support three kinds of scroll behavior:
|
||||
*
|
||||
* (1) Neither NO SCROLL nor SCROLL was specified: to remain backward
|
||||
* compatible, we allow backward fetches here, unless it would
|
||||
* impose additional runtime overhead to do so.
|
||||
*
|
||||
* (2) NO SCROLL was specified: don't allow any backward fetches.
|
||||
*
|
||||
* (3) SCROLL was specified: allow all kinds of backward fetches, even
|
||||
* if we need to take a performance hit to do so. (The planner sticks
|
||||
* a Materialize node atop the query plan if needed.)
|
||||
*
|
||||
* Case #1 is converted to #2 or #3 by looking at the query itself and
|
||||
* determining if scrollability can be supported without additional
|
||||
* overhead.
|
||||
*
|
||||
* Protocol-level portals have no nonsequential-fetch API and so the
|
||||
* distinction doesn't matter for them. They are always initialized
|
||||
* to look like NO SCROLL cursors.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/portal.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PORTAL_H
|
||||
#define PORTAL_H
|
||||
|
||||
#include "executor/execdesc.h"
|
||||
#include "utils/resowner.h"
|
||||
#include "utils/timestamp.h"
|
||||
|
||||
/*
|
||||
* We have several execution strategies for Portals, depending on what
|
||||
* query or queries are to be executed. (Note: in all cases, a Portal
|
||||
* executes just a single source-SQL query, and thus produces just a
|
||||
* single result from the user's viewpoint. However, the rule rewriter
|
||||
* may expand the single source query to zero or many actual queries.)
|
||||
*
|
||||
* PORTAL_ONE_SELECT: the portal contains one single SELECT query. We run
|
||||
* the Executor incrementally as results are demanded. This strategy also
|
||||
* supports holdable cursors (the Executor results can be dumped into a
|
||||
* tuplestore for access after transaction completion).
|
||||
*
|
||||
* PORTAL_ONE_RETURNING: the portal contains a single INSERT/UPDATE/DELETE
|
||||
* query with a RETURNING clause (plus possibly auxiliary queries added by
|
||||
* rule rewriting). On first execution, we run the portal to completion
|
||||
* and dump the primary query's results into the portal tuplestore; the
|
||||
* results are then returned to the client as demanded. (We can't support
|
||||
* suspension of the query partway through, because the AFTER TRIGGER code
|
||||
* can't cope, and also because we don't want to risk failing to execute
|
||||
* all the auxiliary queries.)
|
||||
*
|
||||
* PORTAL_ONE_MOD_WITH: the portal contains one single SELECT query, but
|
||||
* it has data-modifying CTEs. This is currently treated the same as the
|
||||
* PORTAL_ONE_RETURNING case because of the possibility of needing to fire
|
||||
* triggers. It may act more like PORTAL_ONE_SELECT in future.
|
||||
*
|
||||
* PORTAL_UTIL_SELECT: the portal contains a utility statement that returns
|
||||
* a SELECT-like result (for example, EXPLAIN or SHOW). On first execution,
|
||||
* we run the statement and dump its results into the portal tuplestore;
|
||||
* the results are then returned to the client as demanded.
|
||||
*
|
||||
* PORTAL_MULTI_QUERY: all other cases. Here, we do not support partial
|
||||
* execution: the portal's queries will be run to completion on first call.
|
||||
*/
|
||||
typedef enum PortalStrategy
|
||||
{
|
||||
PORTAL_ONE_SELECT,
|
||||
PORTAL_ONE_RETURNING,
|
||||
PORTAL_ONE_MOD_WITH,
|
||||
PORTAL_UTIL_SELECT,
|
||||
PORTAL_MULTI_QUERY
|
||||
} PortalStrategy;
|
||||
|
||||
/*
|
||||
* A portal is always in one of these states. It is possible to transit
|
||||
* from ACTIVE back to READY if the query is not run to completion;
|
||||
* otherwise we never back up in status.
|
||||
*/
|
||||
typedef enum PortalStatus
|
||||
{
|
||||
PORTAL_NEW, /* freshly created */
|
||||
PORTAL_DEFINED, /* PortalDefineQuery done */
|
||||
PORTAL_READY, /* PortalStart complete, can run it */
|
||||
PORTAL_ACTIVE, /* portal is running (can't delete it) */
|
||||
PORTAL_DONE, /* portal is finished (don't re-run it) */
|
||||
PORTAL_FAILED /* portal got error (can't re-run it) */
|
||||
} PortalStatus;
|
||||
|
||||
typedef struct PortalData *Portal;
|
||||
|
||||
typedef struct PortalData
|
||||
{
|
||||
/* Bookkeeping data */
|
||||
const char *name; /* portal's name */
|
||||
const char *prepStmtName; /* source prepared statement (NULL if none) */
|
||||
MemoryContext heap; /* subsidiary memory for portal */
|
||||
ResourceOwner resowner; /* resources owned by portal */
|
||||
void (*cleanup) (Portal portal); /* cleanup hook */
|
||||
SubTransactionId createSubid; /* the ID of the creating subxact */
|
||||
|
||||
/*
|
||||
* if createSubid is InvalidSubTransactionId, the portal is held over from
|
||||
* a previous transaction
|
||||
*/
|
||||
|
||||
/* The query or queries the portal will execute */
|
||||
const char *sourceText; /* text of query (as of 8.4, never NULL) */
|
||||
const char *commandTag; /* command tag for original query */
|
||||
List *stmts; /* PlannedStmts and/or utility statements */
|
||||
CachedPlan *cplan; /* CachedPlan, if stmts are from one */
|
||||
|
||||
ParamListInfo portalParams; /* params to pass to query */
|
||||
|
||||
/* Features/options */
|
||||
PortalStrategy strategy; /* see above */
|
||||
int cursorOptions; /* DECLARE CURSOR option bits */
|
||||
|
||||
/* Status data */
|
||||
PortalStatus status; /* see above */
|
||||
bool portalPinned; /* a pinned portal can't be dropped */
|
||||
|
||||
/* If not NULL, Executor is active; call ExecutorEnd eventually: */
|
||||
QueryDesc *queryDesc; /* info needed for executor invocation */
|
||||
|
||||
/* If portal returns tuples, this is their tupdesc: */
|
||||
TupleDesc tupDesc; /* descriptor for result tuples */
|
||||
/* and these are the format codes to use for the columns: */
|
||||
int16 *formats; /* a format code for each column */
|
||||
|
||||
/*
|
||||
* Where we store tuples for a held cursor or a PORTAL_ONE_RETURNING or
|
||||
* PORTAL_UTIL_SELECT query. (A cursor held past the end of its
|
||||
* transaction no longer has any active executor state.)
|
||||
*/
|
||||
Tuplestorestate *holdStore; /* store for holdable cursors */
|
||||
MemoryContext holdContext; /* memory containing holdStore */
|
||||
|
||||
/*
|
||||
* atStart, atEnd and portalPos indicate the current cursor position.
|
||||
* portalPos is zero before the first row, N after fetching N'th row of
|
||||
* query. After we run off the end, portalPos = # of rows in query, and
|
||||
* atEnd is true. If portalPos overflows, set posOverflow (this causes us
|
||||
* to stop relying on its value for navigation). Note that atStart
|
||||
* implies portalPos == 0, but not the reverse (portalPos could have
|
||||
* overflowed).
|
||||
*/
|
||||
bool atStart;
|
||||
bool atEnd;
|
||||
bool posOverflow;
|
||||
long portalPos;
|
||||
|
||||
/* Presentation data, primarily used by the pg_cursors system view */
|
||||
TimestampTz creation_time; /* time at which this portal was defined */
|
||||
bool visible; /* include this portal in pg_cursors? */
|
||||
} PortalData;
|
||||
|
||||
/*
|
||||
* PortalIsValid
|
||||
* True iff portal is valid.
|
||||
*/
|
||||
#define PortalIsValid(p) PointerIsValid(p)
|
||||
|
||||
/*
|
||||
* Access macros for Portal ... use these in preference to field access.
|
||||
*/
|
||||
#define PortalGetQueryDesc(portal) ((portal)->queryDesc)
|
||||
#define PortalGetHeapMemory(portal) ((portal)->heap)
|
||||
#define PortalGetPrimaryStmt(portal) PortalListGetPrimaryStmt((portal)->stmts)
|
||||
|
||||
|
||||
/* Prototypes for functions in utils/mmgr/portalmem.c */
|
||||
extern void EnablePortalManager(void);
|
||||
extern bool PreCommit_Portals(bool isPrepare);
|
||||
extern void AtAbort_Portals(void);
|
||||
extern void AtCleanup_Portals(void);
|
||||
extern void AtSubCommit_Portals(SubTransactionId mySubid,
|
||||
SubTransactionId parentSubid,
|
||||
ResourceOwner parentXactOwner);
|
||||
extern void AtSubAbort_Portals(SubTransactionId mySubid,
|
||||
SubTransactionId parentSubid,
|
||||
ResourceOwner parentXactOwner);
|
||||
extern void AtSubCleanup_Portals(SubTransactionId mySubid);
|
||||
extern Portal CreatePortal(const char *name, bool allowDup, bool dupSilent);
|
||||
extern Portal CreateNewPortal(void);
|
||||
extern void PinPortal(Portal portal);
|
||||
extern void UnpinPortal(Portal portal);
|
||||
extern void MarkPortalDone(Portal portal);
|
||||
extern void MarkPortalFailed(Portal portal);
|
||||
extern void PortalDrop(Portal portal, bool isTopCommit);
|
||||
extern Portal GetPortalByName(const char *name);
|
||||
extern void PortalDefineQuery(Portal portal,
|
||||
const char *prepStmtName,
|
||||
const char *sourceText,
|
||||
const char *commandTag,
|
||||
List *stmts,
|
||||
CachedPlan *cplan);
|
||||
extern Node *PortalListGetPrimaryStmt(List *stmts);
|
||||
extern void PortalCreateHoldStore(Portal portal);
|
||||
extern void PortalHashTableDeleteAll(void);
|
||||
|
||||
#endif /* PORTAL_H */
|
26
deps/libpq/include/utils/ps_status.h
vendored
Normal file
26
deps/libpq/include/utils/ps_status.h
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* ps_status.h
|
||||
*
|
||||
* Declarations for backend/utils/misc/ps_status.c
|
||||
*
|
||||
* src/include/utils/ps_status.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef PS_STATUS_H
|
||||
#define PS_STATUS_H
|
||||
|
||||
extern bool update_process_title;
|
||||
|
||||
extern char **save_ps_display_args(int argc, char **argv);
|
||||
|
||||
extern void init_ps_display(const char *username, const char *dbname,
|
||||
const char *host_info, const char *initial_str);
|
||||
|
||||
extern void set_ps_display(const char *activity, bool force);
|
||||
|
||||
extern const char *get_ps_display(int *displen);
|
||||
|
||||
#endif /* PS_STATUS_H */
|
66
deps/libpq/include/utils/rbtree.h
vendored
Normal file
66
deps/libpq/include/utils/rbtree.h
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* rbtree.h
|
||||
* interface for PostgreSQL generic Red-Black binary tree package
|
||||
*
|
||||
* Copyright (c) 2009-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* src/include/utils/rbtree.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef RBTREE_H
|
||||
#define RBTREE_H
|
||||
|
||||
/*
|
||||
* RBNode is intended to be used as the first field of a larger struct,
|
||||
* whose additional fields carry whatever payload data the caller needs
|
||||
* for a tree entry. (The total size of that larger struct is passed to
|
||||
* rb_create.) RBNode is declared here to support this usage, but
|
||||
* callers must treat it as an opaque struct.
|
||||
*/
|
||||
typedef struct RBNode
|
||||
{
|
||||
char iteratorState; /* workspace for iterating through tree */
|
||||
char color; /* node's current color, red or black */
|
||||
struct RBNode *left; /* left child, or RBNIL if none */
|
||||
struct RBNode *right; /* right child, or RBNIL if none */
|
||||
struct RBNode *parent; /* parent, or NULL (not RBNIL!) if none */
|
||||
} RBNode;
|
||||
|
||||
/* Opaque struct representing a whole tree */
|
||||
typedef struct RBTree RBTree;
|
||||
|
||||
/* Available tree iteration orderings */
|
||||
typedef enum RBOrderControl
|
||||
{
|
||||
LeftRightWalk, /* inorder: left child, node, right child */
|
||||
RightLeftWalk, /* reverse inorder: right, node, left */
|
||||
DirectWalk, /* preorder: node, left child, right child */
|
||||
InvertedWalk /* postorder: left child, right child, node */
|
||||
} RBOrderControl;
|
||||
|
||||
/* Support functions to be provided by caller */
|
||||
typedef int (*rb_comparator) (const RBNode *a, const RBNode *b, void *arg);
|
||||
typedef void (*rb_combiner) (RBNode *existing, const RBNode *newdata, void *arg);
|
||||
typedef RBNode *(*rb_allocfunc) (void *arg);
|
||||
typedef void (*rb_freefunc) (RBNode *x, void *arg);
|
||||
|
||||
extern RBTree *rb_create(Size node_size,
|
||||
rb_comparator comparator,
|
||||
rb_combiner combiner,
|
||||
rb_allocfunc allocfunc,
|
||||
rb_freefunc freefunc,
|
||||
void *arg);
|
||||
|
||||
extern RBNode *rb_find(RBTree *rb, const RBNode *data);
|
||||
extern RBNode *rb_leftmost(RBTree *rb);
|
||||
|
||||
extern RBNode *rb_insert(RBTree *rb, const RBNode *data, bool *isNew);
|
||||
extern void rb_delete(RBTree *rb, RBNode *node);
|
||||
|
||||
extern void rb_begin_iterate(RBTree *rb, RBOrderControl ctrl);
|
||||
extern RBNode *rb_iterate(RBTree *rb);
|
||||
|
||||
#endif /* RBTREE_H */
|
440
deps/libpq/include/utils/rel.h
vendored
Normal file
440
deps/libpq/include/utils/rel.h
vendored
Normal file
|
@ -0,0 +1,440 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* rel.h
|
||||
* POSTGRES relation descriptor (a/k/a relcache entry) definitions.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/rel.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef REL_H
|
||||
#define REL_H
|
||||
|
||||
#include "access/tupdesc.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "catalog/pg_class.h"
|
||||
#include "catalog/pg_index.h"
|
||||
#include "fmgr.h"
|
||||
#include "nodes/bitmapset.h"
|
||||
#include "rewrite/prs2lock.h"
|
||||
#include "storage/block.h"
|
||||
#include "storage/relfilenode.h"
|
||||
#include "utils/relcache.h"
|
||||
|
||||
|
||||
/*
|
||||
* LockRelId and LockInfo really belong to lmgr.h, but it's more convenient
|
||||
* to declare them here so we can have a LockInfoData field in a Relation.
|
||||
*/
|
||||
|
||||
typedef struct LockRelId
|
||||
{
|
||||
Oid relId; /* a relation identifier */
|
||||
Oid dbId; /* a database identifier */
|
||||
} LockRelId;
|
||||
|
||||
typedef struct LockInfoData
|
||||
{
|
||||
LockRelId lockRelId;
|
||||
} LockInfoData;
|
||||
|
||||
typedef LockInfoData *LockInfo;
|
||||
|
||||
/*
|
||||
* Likewise, this struct really belongs to trigger.h, but for convenience
|
||||
* we put it here.
|
||||
*/
|
||||
typedef struct Trigger
|
||||
{
|
||||
Oid tgoid; /* OID of trigger (pg_trigger row) */
|
||||
/* Remaining fields are copied from pg_trigger, see pg_trigger.h */
|
||||
char *tgname;
|
||||
Oid tgfoid;
|
||||
int16 tgtype;
|
||||
char tgenabled;
|
||||
bool tgisinternal;
|
||||
Oid tgconstrrelid;
|
||||
Oid tgconstrindid;
|
||||
Oid tgconstraint;
|
||||
bool tgdeferrable;
|
||||
bool tginitdeferred;
|
||||
int16 tgnargs;
|
||||
int16 tgnattr;
|
||||
int16 *tgattr;
|
||||
char **tgargs;
|
||||
char *tgqual;
|
||||
} Trigger;
|
||||
|
||||
typedef struct TriggerDesc
|
||||
{
|
||||
Trigger *triggers; /* array of Trigger structs */
|
||||
int numtriggers; /* number of array entries */
|
||||
|
||||
/*
|
||||
* These flags indicate whether the array contains at least one of each
|
||||
* type of trigger. We use these to skip searching the array if not.
|
||||
*/
|
||||
bool trig_insert_before_row;
|
||||
bool trig_insert_after_row;
|
||||
bool trig_insert_instead_row;
|
||||
bool trig_insert_before_statement;
|
||||
bool trig_insert_after_statement;
|
||||
bool trig_update_before_row;
|
||||
bool trig_update_after_row;
|
||||
bool trig_update_instead_row;
|
||||
bool trig_update_before_statement;
|
||||
bool trig_update_after_statement;
|
||||
bool trig_delete_before_row;
|
||||
bool trig_delete_after_row;
|
||||
bool trig_delete_instead_row;
|
||||
bool trig_delete_before_statement;
|
||||
bool trig_delete_after_statement;
|
||||
/* there are no row-level truncate triggers */
|
||||
bool trig_truncate_before_statement;
|
||||
bool trig_truncate_after_statement;
|
||||
} TriggerDesc;
|
||||
|
||||
|
||||
/*
|
||||
* Cached lookup information for the index access method functions defined
|
||||
* by the pg_am row associated with an index relation.
|
||||
*/
|
||||
typedef struct RelationAmInfo
|
||||
{
|
||||
FmgrInfo aminsert;
|
||||
FmgrInfo ambeginscan;
|
||||
FmgrInfo amgettuple;
|
||||
FmgrInfo amgetbitmap;
|
||||
FmgrInfo amrescan;
|
||||
FmgrInfo amendscan;
|
||||
FmgrInfo ammarkpos;
|
||||
FmgrInfo amrestrpos;
|
||||
FmgrInfo ambuild;
|
||||
FmgrInfo ambuildempty;
|
||||
FmgrInfo ambulkdelete;
|
||||
FmgrInfo amvacuumcleanup;
|
||||
FmgrInfo amcostestimate;
|
||||
FmgrInfo amoptions;
|
||||
} RelationAmInfo;
|
||||
|
||||
|
||||
/*
|
||||
* Here are the contents of a relation cache entry.
|
||||
*/
|
||||
|
||||
typedef struct RelationData
|
||||
{
|
||||
RelFileNode rd_node; /* relation physical identifier */
|
||||
/* use "struct" here to avoid needing to include smgr.h: */
|
||||
struct SMgrRelationData *rd_smgr; /* cached file handle, or NULL */
|
||||
int rd_refcnt; /* reference count */
|
||||
BackendId rd_backend; /* owning backend id, if temporary relation */
|
||||
bool rd_isnailed; /* rel is nailed in cache */
|
||||
bool rd_isvalid; /* relcache entry is valid */
|
||||
char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, 1 =
|
||||
* valid, 2 = temporarily forced */
|
||||
|
||||
/*
|
||||
* rd_createSubid is the ID of the highest subtransaction the rel has
|
||||
* survived into; or zero if the rel was not created in the current top
|
||||
* transaction. This should be relied on only for optimization purposes;
|
||||
* it is possible for new-ness to be "forgotten" (eg, after CLUSTER).
|
||||
* Likewise, rd_newRelfilenodeSubid is the ID of the highest
|
||||
* subtransaction the relfilenode change has survived into, or zero if not
|
||||
* changed in the current transaction (or we have forgotten changing it).
|
||||
*/
|
||||
SubTransactionId rd_createSubid; /* rel was created in current xact */
|
||||
SubTransactionId rd_newRelfilenodeSubid; /* new relfilenode assigned in
|
||||
* current xact */
|
||||
|
||||
Form_pg_class rd_rel; /* RELATION tuple */
|
||||
TupleDesc rd_att; /* tuple descriptor */
|
||||
Oid rd_id; /* relation's object id */
|
||||
List *rd_indexlist; /* list of OIDs of indexes on relation */
|
||||
Bitmapset *rd_indexattr; /* identifies columns used in indexes */
|
||||
Oid rd_oidindex; /* OID of unique index on OID, if any */
|
||||
LockInfoData rd_lockInfo; /* lock mgr's info for locking relation */
|
||||
RuleLock *rd_rules; /* rewrite rules */
|
||||
MemoryContext rd_rulescxt; /* private memory cxt for rd_rules, if any */
|
||||
TriggerDesc *trigdesc; /* Trigger info, or NULL if rel has none */
|
||||
|
||||
/*
|
||||
* rd_options is set whenever rd_rel is loaded into the relcache entry.
|
||||
* Note that you can NOT look into rd_rel for this data. NULL means "use
|
||||
* defaults".
|
||||
*/
|
||||
bytea *rd_options; /* parsed pg_class.reloptions */
|
||||
|
||||
/* These are non-NULL only for an index relation: */
|
||||
Form_pg_index rd_index; /* pg_index tuple describing this index */
|
||||
/* use "struct" here to avoid needing to include htup.h: */
|
||||
struct HeapTupleData *rd_indextuple; /* all of pg_index tuple */
|
||||
Form_pg_am rd_am; /* pg_am tuple for index's AM */
|
||||
|
||||
/*
|
||||
* index access support info (used only for an index relation)
|
||||
*
|
||||
* Note: only default support procs for each opclass are cached, namely
|
||||
* those with lefttype and righttype equal to the opclass's opcintype. The
|
||||
* arrays are indexed by support function number, which is a sufficient
|
||||
* identifier given that restriction.
|
||||
*
|
||||
* Note: rd_amcache is available for index AMs to cache private data about
|
||||
* an index. This must be just a cache since it may get reset at any time
|
||||
* (in particular, it will get reset by a relcache inval message for the
|
||||
* index). If used, it must point to a single memory chunk palloc'd in
|
||||
* rd_indexcxt. A relcache reset will include freeing that chunk and
|
||||
* setting rd_amcache = NULL.
|
||||
*/
|
||||
MemoryContext rd_indexcxt; /* private memory cxt for this stuff */
|
||||
RelationAmInfo *rd_aminfo; /* lookup info for funcs found in pg_am */
|
||||
Oid *rd_opfamily; /* OIDs of op families for each index col */
|
||||
Oid *rd_opcintype; /* OIDs of opclass declared input data types */
|
||||
RegProcedure *rd_support; /* OIDs of support procedures */
|
||||
FmgrInfo *rd_supportinfo; /* lookup info for support procedures */
|
||||
int16 *rd_indoption; /* per-column AM-specific flags */
|
||||
List *rd_indexprs; /* index expression trees, if any */
|
||||
List *rd_indpred; /* index predicate tree, if any */
|
||||
Oid *rd_exclops; /* OIDs of exclusion operators, if any */
|
||||
Oid *rd_exclprocs; /* OIDs of exclusion ops' procs, if any */
|
||||
uint16 *rd_exclstrats; /* exclusion ops' strategy numbers, if any */
|
||||
void *rd_amcache; /* available for use by index AM */
|
||||
Oid *rd_indcollation; /* OIDs of index collations */
|
||||
|
||||
/*
|
||||
* Hack for CLUSTER, rewriting ALTER TABLE, etc: when writing a new
|
||||
* version of a table, we need to make any toast pointers inserted into it
|
||||
* have the existing toast table's OID, not the OID of the transient toast
|
||||
* table. If rd_toastoid isn't InvalidOid, it is the OID to place in
|
||||
* toast pointers inserted into this rel. (Note it's set on the new
|
||||
* version of the main heap, not the toast table itself.) This also
|
||||
* causes toast_save_datum() to try to preserve toast value OIDs.
|
||||
*/
|
||||
Oid rd_toastoid; /* Real TOAST table's OID, or InvalidOid */
|
||||
|
||||
/* use "struct" here to avoid needing to include pgstat.h: */
|
||||
struct PgStat_TableStatus *pgstat_info; /* statistics collection area */
|
||||
} RelationData;
|
||||
|
||||
/*
|
||||
* StdRdOptions
|
||||
* Standard contents of rd_options for heaps and generic indexes.
|
||||
*
|
||||
* RelationGetFillFactor() and RelationGetTargetPageFreeSpace() can only
|
||||
* be applied to relations that use this format or a superset for
|
||||
* private options data.
|
||||
*/
|
||||
/* autovacuum-related reloptions. */
|
||||
typedef struct AutoVacOpts
|
||||
{
|
||||
bool enabled;
|
||||
int vacuum_threshold;
|
||||
int analyze_threshold;
|
||||
int vacuum_cost_delay;
|
||||
int vacuum_cost_limit;
|
||||
int freeze_min_age;
|
||||
int freeze_max_age;
|
||||
int freeze_table_age;
|
||||
float8 vacuum_scale_factor;
|
||||
float8 analyze_scale_factor;
|
||||
} AutoVacOpts;
|
||||
|
||||
typedef struct StdRdOptions
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
int fillfactor; /* page fill factor in percent (0..100) */
|
||||
AutoVacOpts autovacuum; /* autovacuum-related options */
|
||||
} StdRdOptions;
|
||||
|
||||
#define HEAP_MIN_FILLFACTOR 10
|
||||
#define HEAP_DEFAULT_FILLFACTOR 100
|
||||
|
||||
/*
|
||||
* RelationGetFillFactor
|
||||
* Returns the relation's fillfactor. Note multiple eval of argument!
|
||||
*/
|
||||
#define RelationGetFillFactor(relation, defaultff) \
|
||||
((relation)->rd_options ? \
|
||||
((StdRdOptions *) (relation)->rd_options)->fillfactor : (defaultff))
|
||||
|
||||
/*
|
||||
* RelationGetTargetPageUsage
|
||||
* Returns the relation's desired space usage per page in bytes.
|
||||
*/
|
||||
#define RelationGetTargetPageUsage(relation, defaultff) \
|
||||
(BLCKSZ * RelationGetFillFactor(relation, defaultff) / 100)
|
||||
|
||||
/*
|
||||
* RelationGetTargetPageFreeSpace
|
||||
* Returns the relation's desired freespace per page in bytes.
|
||||
*/
|
||||
#define RelationGetTargetPageFreeSpace(relation, defaultff) \
|
||||
(BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100)
|
||||
|
||||
/*
|
||||
* RelationIsValid
|
||||
* True iff relation descriptor is valid.
|
||||
*/
|
||||
#define RelationIsValid(relation) PointerIsValid(relation)
|
||||
|
||||
#define InvalidRelation ((Relation) NULL)
|
||||
|
||||
/*
|
||||
* RelationHasReferenceCountZero
|
||||
* True iff relation reference count is zero.
|
||||
*
|
||||
* Note:
|
||||
* Assumes relation descriptor is valid.
|
||||
*/
|
||||
#define RelationHasReferenceCountZero(relation) \
|
||||
((bool)((relation)->rd_refcnt == 0))
|
||||
|
||||
/*
|
||||
* RelationGetForm
|
||||
* Returns pg_class tuple for a relation.
|
||||
*
|
||||
* Note:
|
||||
* Assumes relation descriptor is valid.
|
||||
*/
|
||||
#define RelationGetForm(relation) ((relation)->rd_rel)
|
||||
|
||||
/*
|
||||
* RelationGetRelid
|
||||
* Returns the OID of the relation
|
||||
*/
|
||||
#define RelationGetRelid(relation) ((relation)->rd_id)
|
||||
|
||||
/*
|
||||
* RelationGetNumberOfAttributes
|
||||
* Returns the number of attributes in a relation.
|
||||
*/
|
||||
#define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts)
|
||||
|
||||
/*
|
||||
* RelationGetDescr
|
||||
* Returns tuple descriptor for a relation.
|
||||
*/
|
||||
#define RelationGetDescr(relation) ((relation)->rd_att)
|
||||
|
||||
/*
|
||||
* RelationGetRelationName
|
||||
* Returns the rel's name.
|
||||
*
|
||||
* Note that the name is only unique within the containing namespace.
|
||||
*/
|
||||
#define RelationGetRelationName(relation) \
|
||||
(NameStr((relation)->rd_rel->relname))
|
||||
|
||||
/*
|
||||
* RelationGetNamespace
|
||||
* Returns the rel's namespace OID.
|
||||
*/
|
||||
#define RelationGetNamespace(relation) \
|
||||
((relation)->rd_rel->relnamespace)
|
||||
|
||||
/*
|
||||
* RelationIsMapped
|
||||
* True if the relation uses the relfilenode map.
|
||||
*
|
||||
* NB: this is only meaningful for relkinds that have storage, else it
|
||||
* will misleadingly say "true".
|
||||
*/
|
||||
#define RelationIsMapped(relation) \
|
||||
((relation)->rd_rel->relfilenode == InvalidOid)
|
||||
|
||||
/*
|
||||
* RelationOpenSmgr
|
||||
* Open the relation at the smgr level, if not already done.
|
||||
*/
|
||||
#define RelationOpenSmgr(relation) \
|
||||
do { \
|
||||
if ((relation)->rd_smgr == NULL) \
|
||||
smgrsetowner(&((relation)->rd_smgr), smgropen((relation)->rd_node, (relation)->rd_backend)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* RelationCloseSmgr
|
||||
* Close the relation at the smgr level, if not already done.
|
||||
*
|
||||
* Note: smgrclose should unhook from owner pointer, hence the Assert.
|
||||
*/
|
||||
#define RelationCloseSmgr(relation) \
|
||||
do { \
|
||||
if ((relation)->rd_smgr != NULL) \
|
||||
{ \
|
||||
smgrclose((relation)->rd_smgr); \
|
||||
Assert((relation)->rd_smgr == NULL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* RelationGetTargetBlock
|
||||
* Fetch relation's current insertion target block.
|
||||
*
|
||||
* Returns InvalidBlockNumber if there is no current target block. Note
|
||||
* that the target block status is discarded on any smgr-level invalidation.
|
||||
*/
|
||||
#define RelationGetTargetBlock(relation) \
|
||||
( (relation)->rd_smgr != NULL ? (relation)->rd_smgr->smgr_targblock : InvalidBlockNumber )
|
||||
|
||||
/*
|
||||
* RelationSetTargetBlock
|
||||
* Set relation's current insertion target block.
|
||||
*/
|
||||
#define RelationSetTargetBlock(relation, targblock) \
|
||||
do { \
|
||||
RelationOpenSmgr(relation); \
|
||||
(relation)->rd_smgr->smgr_targblock = (targblock); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* RelationNeedsWAL
|
||||
* True if relation needs WAL.
|
||||
*/
|
||||
#define RelationNeedsWAL(relation) \
|
||||
((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
|
||||
|
||||
/*
|
||||
* RelationUsesLocalBuffers
|
||||
* True if relation's pages are stored in local buffers.
|
||||
*/
|
||||
#define RelationUsesLocalBuffers(relation) \
|
||||
((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
|
||||
|
||||
/*
|
||||
* RelationUsesTempNamespace
|
||||
* True if relation's catalog entries live in a private namespace.
|
||||
*/
|
||||
#define RelationUsesTempNamespace(relation) \
|
||||
((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
|
||||
|
||||
/*
|
||||
* RELATION_IS_LOCAL
|
||||
* If a rel is either temp or newly created in the current transaction,
|
||||
* it can be assumed to be visible only to the current backend.
|
||||
*
|
||||
* Beware of multiple eval of argument
|
||||
*/
|
||||
#define RELATION_IS_LOCAL(relation) \
|
||||
((relation)->rd_backend == MyBackendId || \
|
||||
(relation)->rd_createSubid != InvalidSubTransactionId)
|
||||
|
||||
/*
|
||||
* RELATION_IS_OTHER_TEMP
|
||||
* Test for a temporary relation that belongs to some other session.
|
||||
*
|
||||
* Beware of multiple eval of argument
|
||||
*/
|
||||
#define RELATION_IS_OTHER_TEMP(relation) \
|
||||
((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP \
|
||||
&& (relation)->rd_backend != MyBackendId)
|
||||
|
||||
/* routines in utils/cache/relcache.c */
|
||||
extern void RelationIncrementReferenceCount(Relation rel);
|
||||
extern void RelationDecrementReferenceCount(Relation rel);
|
||||
|
||||
#endif /* REL_H */
|
110
deps/libpq/include/utils/relcache.h
vendored
Normal file
110
deps/libpq/include/utils/relcache.h
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* relcache.h
|
||||
* Relation descriptor cache definitions.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/relcache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef RELCACHE_H
|
||||
#define RELCACHE_H
|
||||
|
||||
#include "access/tupdesc.h"
|
||||
#include "nodes/bitmapset.h"
|
||||
#include "nodes/pg_list.h"
|
||||
|
||||
|
||||
typedef struct RelationData *Relation;
|
||||
|
||||
/* ----------------
|
||||
* RelationPtr is used in the executor to support index scans
|
||||
* where we have to keep track of several index relations in an
|
||||
* array. -cim 9/10/89
|
||||
* ----------------
|
||||
*/
|
||||
typedef Relation *RelationPtr;
|
||||
|
||||
/*
|
||||
* Routines to open (lookup) and close a relcache entry
|
||||
*/
|
||||
extern Relation RelationIdGetRelation(Oid relationId);
|
||||
extern void RelationClose(Relation relation);
|
||||
|
||||
/*
|
||||
* Routines to compute/retrieve additional cached information
|
||||
*/
|
||||
extern List *RelationGetIndexList(Relation relation);
|
||||
extern Oid RelationGetOidIndex(Relation relation);
|
||||
extern List *RelationGetIndexExpressions(Relation relation);
|
||||
extern List *RelationGetIndexPredicate(Relation relation);
|
||||
extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation);
|
||||
extern void RelationGetExclusionInfo(Relation indexRelation,
|
||||
Oid **operators,
|
||||
Oid **procs,
|
||||
uint16 **strategies);
|
||||
|
||||
extern void RelationSetIndexList(Relation relation,
|
||||
List *indexIds, Oid oidIndex);
|
||||
|
||||
extern void RelationInitIndexAccessInfo(Relation relation);
|
||||
|
||||
/*
|
||||
* Routines for backend startup
|
||||
*/
|
||||
extern void RelationCacheInitialize(void);
|
||||
extern void RelationCacheInitializePhase2(void);
|
||||
extern void RelationCacheInitializePhase3(void);
|
||||
|
||||
/*
|
||||
* Routine to create a relcache entry for an about-to-be-created relation
|
||||
*/
|
||||
extern Relation RelationBuildLocalRelation(const char *relname,
|
||||
Oid relnamespace,
|
||||
TupleDesc tupDesc,
|
||||
Oid relid,
|
||||
Oid reltablespace,
|
||||
bool shared_relation,
|
||||
bool mapped_relation,
|
||||
char relpersistence);
|
||||
|
||||
/*
|
||||
* Routine to manage assignment of new relfilenode to a relation
|
||||
*/
|
||||
extern void RelationSetNewRelfilenode(Relation relation,
|
||||
TransactionId freezeXid);
|
||||
|
||||
/*
|
||||
* Routines for flushing/rebuilding relcache entries in various scenarios
|
||||
*/
|
||||
extern void RelationForgetRelation(Oid rid);
|
||||
|
||||
extern void RelationCacheInvalidateEntry(Oid relationId);
|
||||
|
||||
extern void RelationCacheInvalidate(void);
|
||||
|
||||
extern void RelationCloseSmgrByOid(Oid relationId);
|
||||
|
||||
extern void AtEOXact_RelationCache(bool isCommit);
|
||||
extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
|
||||
SubTransactionId parentSubid);
|
||||
|
||||
/*
|
||||
* Routines to help manage rebuilding of relcache init files
|
||||
*/
|
||||
extern bool RelationIdIsInInitFile(Oid relationId);
|
||||
extern void RelationCacheInitFilePreInvalidate(void);
|
||||
extern void RelationCacheInitFilePostInvalidate(void);
|
||||
extern void RelationCacheInitFileRemove(void);
|
||||
|
||||
/* should be used only by relcache.c and catcache.c */
|
||||
extern bool criticalRelcachesBuilt;
|
||||
|
||||
/* should be used only by relcache.c and postinit.c */
|
||||
extern bool criticalSharedRelcachesBuilt;
|
||||
|
||||
#endif /* RELCACHE_H */
|
62
deps/libpq/include/utils/relmapper.h
vendored
Normal file
62
deps/libpq/include/utils/relmapper.h
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* relmapper.h
|
||||
* Catalog-to-filenode mapping
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/relmapper.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef RELMAPPER_H
|
||||
#define RELMAPPER_H
|
||||
|
||||
#include "access/xlog.h"
|
||||
|
||||
/* ----------------
|
||||
* relmap-related XLOG entries
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
#define XLOG_RELMAP_UPDATE 0x00
|
||||
|
||||
typedef struct xl_relmap_update
|
||||
{
|
||||
Oid dbid; /* database ID, or 0 for shared map */
|
||||
Oid tsid; /* database's tablespace, or pg_global */
|
||||
int32 nbytes; /* size of relmap data */
|
||||
char data[1]; /* VARIABLE LENGTH ARRAY */
|
||||
} xl_relmap_update;
|
||||
|
||||
#define MinSizeOfRelmapUpdate offsetof(xl_relmap_update, data)
|
||||
|
||||
|
||||
extern Oid RelationMapOidToFilenode(Oid relationId, bool shared);
|
||||
|
||||
extern void RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared,
|
||||
bool immediate);
|
||||
|
||||
extern void RelationMapRemoveMapping(Oid relationId);
|
||||
|
||||
extern void RelationMapInvalidate(bool shared);
|
||||
extern void RelationMapInvalidateAll(void);
|
||||
|
||||
extern void AtCCI_RelationMap(void);
|
||||
extern void AtEOXact_RelationMap(bool isCommit);
|
||||
extern void AtPrepare_RelationMap(void);
|
||||
|
||||
extern void CheckPointRelationMap(void);
|
||||
|
||||
extern void RelationMapFinishBootstrap(void);
|
||||
|
||||
extern void RelationMapInitialize(void);
|
||||
extern void RelationMapInitializePhase2(void);
|
||||
extern void RelationMapInitializePhase3(void);
|
||||
|
||||
extern void relmap_redo(XLogRecPtr lsn, XLogRecord *record);
|
||||
extern void relmap_desc(StringInfo buf, uint8 xl_info, char *rec);
|
||||
|
||||
#endif /* RELMAPPER_H */
|
140
deps/libpq/include/utils/resowner.h
vendored
Normal file
140
deps/libpq/include/utils/resowner.h
vendored
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* resowner.h
|
||||
* POSTGRES resource owner definitions.
|
||||
*
|
||||
* Query-lifespan resources are tracked by associating them with
|
||||
* ResourceOwner objects. This provides a simple mechanism for ensuring
|
||||
* that such resources are freed at the right time.
|
||||
* See utils/resowner/README for more info.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/resowner.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef RESOWNER_H
|
||||
#define RESOWNER_H
|
||||
|
||||
#include "storage/buf.h"
|
||||
#include "storage/fd.h"
|
||||
#include "utils/catcache.h"
|
||||
#include "utils/plancache.h"
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
/*
|
||||
* ResourceOwner objects are an opaque data structure known only within
|
||||
* resowner.c.
|
||||
*/
|
||||
typedef struct ResourceOwnerData *ResourceOwner;
|
||||
|
||||
|
||||
/*
|
||||
* Globally known ResourceOwners
|
||||
*/
|
||||
extern PGDLLIMPORT ResourceOwner CurrentResourceOwner;
|
||||
extern PGDLLIMPORT ResourceOwner CurTransactionResourceOwner;
|
||||
extern PGDLLIMPORT ResourceOwner TopTransactionResourceOwner;
|
||||
|
||||
/*
|
||||
* Resource releasing is done in three phases: pre-locks, locks, and
|
||||
* post-locks. The pre-lock phase must release any resources that are
|
||||
* visible to other backends (such as pinned buffers); this ensures that
|
||||
* when we release a lock that another backend may be waiting on, it will
|
||||
* see us as being fully out of our transaction. The post-lock phase
|
||||
* should be used for backend-internal cleanup.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RESOURCE_RELEASE_BEFORE_LOCKS,
|
||||
RESOURCE_RELEASE_LOCKS,
|
||||
RESOURCE_RELEASE_AFTER_LOCKS
|
||||
} ResourceReleasePhase;
|
||||
|
||||
/*
|
||||
* Dynamically loaded modules can get control during ResourceOwnerRelease
|
||||
* by providing a callback of this form.
|
||||
*/
|
||||
typedef void (*ResourceReleaseCallback) (ResourceReleasePhase phase,
|
||||
bool isCommit,
|
||||
bool isTopLevel,
|
||||
void *arg);
|
||||
|
||||
|
||||
/*
|
||||
* Functions in resowner.c
|
||||
*/
|
||||
|
||||
/* generic routines */
|
||||
extern ResourceOwner ResourceOwnerCreate(ResourceOwner parent,
|
||||
const char *name);
|
||||
extern void ResourceOwnerRelease(ResourceOwner owner,
|
||||
ResourceReleasePhase phase,
|
||||
bool isCommit,
|
||||
bool isTopLevel);
|
||||
extern void ResourceOwnerDelete(ResourceOwner owner);
|
||||
extern ResourceOwner ResourceOwnerGetParent(ResourceOwner owner);
|
||||
extern void ResourceOwnerNewParent(ResourceOwner owner,
|
||||
ResourceOwner newparent);
|
||||
extern void RegisterResourceReleaseCallback(ResourceReleaseCallback callback,
|
||||
void *arg);
|
||||
extern void UnregisterResourceReleaseCallback(ResourceReleaseCallback callback,
|
||||
void *arg);
|
||||
|
||||
/* support for buffer refcount management */
|
||||
extern void ResourceOwnerEnlargeBuffers(ResourceOwner owner);
|
||||
extern void ResourceOwnerRememberBuffer(ResourceOwner owner, Buffer buffer);
|
||||
extern void ResourceOwnerForgetBuffer(ResourceOwner owner, Buffer buffer);
|
||||
|
||||
/* support for catcache refcount management */
|
||||
extern void ResourceOwnerEnlargeCatCacheRefs(ResourceOwner owner);
|
||||
extern void ResourceOwnerRememberCatCacheRef(ResourceOwner owner,
|
||||
HeapTuple tuple);
|
||||
extern void ResourceOwnerForgetCatCacheRef(ResourceOwner owner,
|
||||
HeapTuple tuple);
|
||||
extern void ResourceOwnerEnlargeCatCacheListRefs(ResourceOwner owner);
|
||||
extern void ResourceOwnerRememberCatCacheListRef(ResourceOwner owner,
|
||||
CatCList *list);
|
||||
extern void ResourceOwnerForgetCatCacheListRef(ResourceOwner owner,
|
||||
CatCList *list);
|
||||
|
||||
/* support for relcache refcount management */
|
||||
extern void ResourceOwnerEnlargeRelationRefs(ResourceOwner owner);
|
||||
extern void ResourceOwnerRememberRelationRef(ResourceOwner owner,
|
||||
Relation rel);
|
||||
extern void ResourceOwnerForgetRelationRef(ResourceOwner owner,
|
||||
Relation rel);
|
||||
|
||||
/* support for plancache refcount management */
|
||||
extern void ResourceOwnerEnlargePlanCacheRefs(ResourceOwner owner);
|
||||
extern void ResourceOwnerRememberPlanCacheRef(ResourceOwner owner,
|
||||
CachedPlan *plan);
|
||||
extern void ResourceOwnerForgetPlanCacheRef(ResourceOwner owner,
|
||||
CachedPlan *plan);
|
||||
|
||||
/* support for tupledesc refcount management */
|
||||
extern void ResourceOwnerEnlargeTupleDescs(ResourceOwner owner);
|
||||
extern void ResourceOwnerRememberTupleDesc(ResourceOwner owner,
|
||||
TupleDesc tupdesc);
|
||||
extern void ResourceOwnerForgetTupleDesc(ResourceOwner owner,
|
||||
TupleDesc tupdesc);
|
||||
|
||||
/* support for snapshot refcount management */
|
||||
extern void ResourceOwnerEnlargeSnapshots(ResourceOwner owner);
|
||||
extern void ResourceOwnerRememberSnapshot(ResourceOwner owner,
|
||||
Snapshot snapshot);
|
||||
extern void ResourceOwnerForgetSnapshot(ResourceOwner owner,
|
||||
Snapshot snapshot);
|
||||
|
||||
/* support for temporary file management */
|
||||
extern void ResourceOwnerEnlargeFiles(ResourceOwner owner);
|
||||
extern void ResourceOwnerRememberFile(ResourceOwner owner,
|
||||
File file);
|
||||
extern void ResourceOwnerForgetFile(ResourceOwner owner,
|
||||
File file);
|
||||
|
||||
#endif /* RESOWNER_H */
|
198
deps/libpq/include/utils/selfuncs.h
vendored
Normal file
198
deps/libpq/include/utils/selfuncs.h
vendored
Normal file
|
@ -0,0 +1,198 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* selfuncs.h
|
||||
* Selectivity functions and index cost estimation functions for
|
||||
* standard operators and index access methods.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/selfuncs.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SELFUNCS_H
|
||||
#define SELFUNCS_H
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "access/htup.h"
|
||||
#include "nodes/relation.h"
|
||||
|
||||
|
||||
/*
|
||||
* Note: the default selectivity estimates are not chosen entirely at random.
|
||||
* We want them to be small enough to ensure that indexscans will be used if
|
||||
* available, for typical table densities of ~100 tuples/page. Thus, for
|
||||
* example, 0.01 is not quite small enough, since that makes it appear that
|
||||
* nearly all pages will be hit anyway. Also, since we sometimes estimate
|
||||
* eqsel as 1/num_distinct, we probably want DEFAULT_NUM_DISTINCT to equal
|
||||
* 1/DEFAULT_EQ_SEL.
|
||||
*/
|
||||
|
||||
/* default selectivity estimate for equalities such as "A = b" */
|
||||
#define DEFAULT_EQ_SEL 0.005
|
||||
|
||||
/* default selectivity estimate for inequalities such as "A < b" */
|
||||
#define DEFAULT_INEQ_SEL 0.3333333333333333
|
||||
|
||||
/* default selectivity estimate for range inequalities "A > b AND A < c" */
|
||||
#define DEFAULT_RANGE_INEQ_SEL 0.005
|
||||
|
||||
/* default selectivity estimate for pattern-match operators such as LIKE */
|
||||
#define DEFAULT_MATCH_SEL 0.005
|
||||
|
||||
/* default number of distinct values in a table */
|
||||
#define DEFAULT_NUM_DISTINCT 200
|
||||
|
||||
/* default selectivity estimate for boolean and null test nodes */
|
||||
#define DEFAULT_UNK_SEL 0.005
|
||||
#define DEFAULT_NOT_UNK_SEL (1.0 - DEFAULT_UNK_SEL)
|
||||
|
||||
|
||||
/*
|
||||
* Clamp a computed probability estimate (which may suffer from roundoff or
|
||||
* estimation errors) to valid range. Argument must be a float variable.
|
||||
*/
|
||||
#define CLAMP_PROBABILITY(p) \
|
||||
do { \
|
||||
if (p < 0.0) \
|
||||
p = 0.0; \
|
||||
else if (p > 1.0) \
|
||||
p = 1.0; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Return data from examine_variable and friends */
|
||||
typedef struct VariableStatData
|
||||
{
|
||||
Node *var; /* the Var or expression tree */
|
||||
RelOptInfo *rel; /* Relation, or NULL if not identifiable */
|
||||
HeapTuple statsTuple; /* pg_statistic tuple, or NULL if none */
|
||||
/* NB: if statsTuple!=NULL, it must be freed when caller is done */
|
||||
void (*freefunc) (HeapTuple tuple); /* how to free statsTuple */
|
||||
Oid vartype; /* exposed type of expression */
|
||||
Oid atttype; /* type to pass to get_attstatsslot */
|
||||
int32 atttypmod; /* typmod to pass to get_attstatsslot */
|
||||
bool isunique; /* true if matched to a unique index */
|
||||
} VariableStatData;
|
||||
|
||||
#define ReleaseVariableStats(vardata) \
|
||||
do { \
|
||||
if (HeapTupleIsValid((vardata).statsTuple)) \
|
||||
(* (vardata).freefunc) ((vardata).statsTuple); \
|
||||
} while(0)
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Pattern_Type_Like, Pattern_Type_Like_IC,
|
||||
Pattern_Type_Regex, Pattern_Type_Regex_IC
|
||||
} Pattern_Type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Pattern_Prefix_None, Pattern_Prefix_Partial, Pattern_Prefix_Exact
|
||||
} Pattern_Prefix_Status;
|
||||
|
||||
|
||||
/* selfuncs.c */
|
||||
|
||||
/* Hooks for plugins to get control when we ask for stats */
|
||||
typedef bool (*get_relation_stats_hook_type) (PlannerInfo *root,
|
||||
RangeTblEntry *rte,
|
||||
AttrNumber attnum,
|
||||
VariableStatData *vardata);
|
||||
extern PGDLLIMPORT get_relation_stats_hook_type get_relation_stats_hook;
|
||||
typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
|
||||
Oid indexOid,
|
||||
AttrNumber indexattnum,
|
||||
VariableStatData *vardata);
|
||||
extern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;
|
||||
|
||||
extern void examine_variable(PlannerInfo *root, Node *node, int varRelid,
|
||||
VariableStatData *vardata);
|
||||
extern bool get_restriction_variable(PlannerInfo *root, List *args,
|
||||
int varRelid,
|
||||
VariableStatData *vardata, Node **other,
|
||||
bool *varonleft);
|
||||
extern void get_join_variables(PlannerInfo *root, List *args,
|
||||
SpecialJoinInfo *sjinfo,
|
||||
VariableStatData *vardata1,
|
||||
VariableStatData *vardata2,
|
||||
bool *join_is_reversed);
|
||||
extern double get_variable_numdistinct(VariableStatData *vardata);
|
||||
extern double mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc,
|
||||
Datum constval, bool varonleft,
|
||||
double *sumcommonp);
|
||||
extern double histogram_selectivity(VariableStatData *vardata, FmgrInfo *opproc,
|
||||
Datum constval, bool varonleft,
|
||||
int min_hist_size, int n_skip,
|
||||
int *hist_size);
|
||||
|
||||
extern Pattern_Prefix_Status pattern_fixed_prefix(Const *patt,
|
||||
Pattern_Type ptype,
|
||||
Oid collation,
|
||||
Const **prefix,
|
||||
Const **rest);
|
||||
extern Const *make_greater_string(const Const *str_const, FmgrInfo *ltproc,
|
||||
Oid collation);
|
||||
|
||||
extern Datum eqsel(PG_FUNCTION_ARGS);
|
||||
extern Datum neqsel(PG_FUNCTION_ARGS);
|
||||
extern Datum scalarltsel(PG_FUNCTION_ARGS);
|
||||
extern Datum scalargtsel(PG_FUNCTION_ARGS);
|
||||
extern Datum regexeqsel(PG_FUNCTION_ARGS);
|
||||
extern Datum icregexeqsel(PG_FUNCTION_ARGS);
|
||||
extern Datum likesel(PG_FUNCTION_ARGS);
|
||||
extern Datum iclikesel(PG_FUNCTION_ARGS);
|
||||
extern Datum regexnesel(PG_FUNCTION_ARGS);
|
||||
extern Datum icregexnesel(PG_FUNCTION_ARGS);
|
||||
extern Datum nlikesel(PG_FUNCTION_ARGS);
|
||||
extern Datum icnlikesel(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum eqjoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum neqjoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum scalarltjoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum scalargtjoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum regexeqjoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum icregexeqjoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum likejoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum iclikejoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum regexnejoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum icregexnejoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum nlikejoinsel(PG_FUNCTION_ARGS);
|
||||
extern Datum icnlikejoinsel(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Selectivity booltestsel(PlannerInfo *root, BoolTestType booltesttype,
|
||||
Node *arg, int varRelid,
|
||||
JoinType jointype, SpecialJoinInfo *sjinfo);
|
||||
extern Selectivity nulltestsel(PlannerInfo *root, NullTestType nulltesttype,
|
||||
Node *arg, int varRelid,
|
||||
JoinType jointype, SpecialJoinInfo *sjinfo);
|
||||
extern Selectivity scalararraysel(PlannerInfo *root,
|
||||
ScalarArrayOpExpr *clause,
|
||||
bool is_join_clause,
|
||||
int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo);
|
||||
extern int estimate_array_length(Node *arrayexpr);
|
||||
extern Selectivity rowcomparesel(PlannerInfo *root,
|
||||
RowCompareExpr *clause,
|
||||
int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo);
|
||||
|
||||
extern void mergejoinscansel(PlannerInfo *root, Node *clause,
|
||||
Oid opfamily, int strategy, bool nulls_first,
|
||||
Selectivity *leftstart, Selectivity *leftend,
|
||||
Selectivity *rightstart, Selectivity *rightend);
|
||||
|
||||
extern double estimate_num_groups(PlannerInfo *root, List *groupExprs,
|
||||
double input_rows);
|
||||
|
||||
extern Selectivity estimate_hash_bucketsize(PlannerInfo *root, Node *hashkey,
|
||||
double nbuckets);
|
||||
|
||||
extern Datum btcostestimate(PG_FUNCTION_ARGS);
|
||||
extern Datum hashcostestimate(PG_FUNCTION_ARGS);
|
||||
extern Datum gistcostestimate(PG_FUNCTION_ARGS);
|
||||
extern Datum gincostestimate(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* SELFUNCS_H */
|
47
deps/libpq/include/utils/snapmgr.h
vendored
Normal file
47
deps/libpq/include/utils/snapmgr.h
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* snapmgr.h
|
||||
* POSTGRES snapshot manager
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/snapmgr.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SNAPMGR_H
|
||||
#define SNAPMGR_H
|
||||
|
||||
#include "utils/resowner.h"
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
extern bool FirstSnapshotSet;
|
||||
|
||||
extern TransactionId TransactionXmin;
|
||||
extern TransactionId RecentXmin;
|
||||
extern TransactionId RecentGlobalXmin;
|
||||
|
||||
extern Snapshot GetTransactionSnapshot(void);
|
||||
extern Snapshot GetLatestSnapshot(void);
|
||||
extern void SnapshotSetCommandId(CommandId curcid);
|
||||
|
||||
extern void PushActiveSnapshot(Snapshot snapshot);
|
||||
extern void PushCopiedSnapshot(Snapshot snapshot);
|
||||
extern void UpdateActiveSnapshotCommandId(void);
|
||||
extern void PopActiveSnapshot(void);
|
||||
extern Snapshot GetActiveSnapshot(void);
|
||||
extern bool ActiveSnapshotSet(void);
|
||||
|
||||
extern Snapshot RegisterSnapshot(Snapshot snapshot);
|
||||
extern void UnregisterSnapshot(Snapshot snapshot);
|
||||
extern Snapshot RegisterSnapshotOnOwner(Snapshot snapshot, ResourceOwner owner);
|
||||
extern void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner);
|
||||
|
||||
extern void AtSubCommit_Snapshot(int level);
|
||||
extern void AtSubAbort_Snapshot(int level);
|
||||
extern void AtEarlyCommit_Snapshot(void);
|
||||
extern void AtEOXact_Snapshot(bool isCommit);
|
||||
|
||||
#endif /* SNAPMGR_H */
|
80
deps/libpq/include/utils/snapshot.h
vendored
Normal file
80
deps/libpq/include/utils/snapshot.h
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* snapshot.h
|
||||
* POSTGRES snapshot definition
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/snapshot.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SNAPSHOT_H
|
||||
#define SNAPSHOT_H
|
||||
|
||||
#include "access/htup.h"
|
||||
#include "storage/buf.h"
|
||||
|
||||
|
||||
typedef struct SnapshotData *Snapshot;
|
||||
|
||||
#define InvalidSnapshot ((Snapshot) NULL)
|
||||
|
||||
/*
|
||||
* We use SnapshotData structures to represent both "regular" (MVCC)
|
||||
* snapshots and "special" snapshots that have non-MVCC semantics.
|
||||
* The specific semantics of a snapshot are encoded by the "satisfies"
|
||||
* function.
|
||||
*/
|
||||
typedef bool (*SnapshotSatisfiesFunc) (HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
|
||||
typedef struct SnapshotData
|
||||
{
|
||||
SnapshotSatisfiesFunc satisfies; /* tuple test function */
|
||||
|
||||
/*
|
||||
* The remaining fields are used only for MVCC snapshots, and are normally
|
||||
* just zeroes in special snapshots. (But xmin and xmax are used
|
||||
* specially by HeapTupleSatisfiesDirty.)
|
||||
*
|
||||
* An MVCC snapshot can never see the effects of XIDs >= xmax. It can see
|
||||
* the effects of all older XIDs except those listed in the snapshot. xmin
|
||||
* is stored as an optimization to avoid needing to search the XID arrays
|
||||
* for most tuples.
|
||||
*/
|
||||
TransactionId xmin; /* all XID < xmin are visible to me */
|
||||
TransactionId xmax; /* all XID >= xmax are invisible to me */
|
||||
uint32 xcnt; /* # of xact ids in xip[] */
|
||||
TransactionId *xip; /* array of xact IDs in progress */
|
||||
/* note: all ids in xip[] satisfy xmin <= xip[i] < xmax */
|
||||
int32 subxcnt; /* # of xact ids in subxip[] */
|
||||
TransactionId *subxip; /* array of subxact IDs in progress */
|
||||
bool suboverflowed; /* has the subxip array overflowed? */
|
||||
bool takenDuringRecovery; /* recovery-shaped snapshot? */
|
||||
|
||||
/*
|
||||
* note: all ids in subxip[] are >= xmin, but we don't bother filtering
|
||||
* out any that are >= xmax
|
||||
*/
|
||||
CommandId curcid; /* in my xact, CID < curcid are visible */
|
||||
uint32 active_count; /* refcount on ActiveSnapshot stack */
|
||||
uint32 regd_count; /* refcount on RegisteredSnapshotList */
|
||||
bool copied; /* false if it's a static snapshot */
|
||||
} SnapshotData;
|
||||
|
||||
/*
|
||||
* Result codes for HeapTupleSatisfiesUpdate. This should really be in
|
||||
* tqual.h, but we want to avoid including that file elsewhere.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HeapTupleMayBeUpdated,
|
||||
HeapTupleInvisible,
|
||||
HeapTupleSelfUpdated,
|
||||
HeapTupleUpdated,
|
||||
HeapTupleBeingUpdated
|
||||
} HTSU_Result;
|
||||
|
||||
#endif /* SNAPSHOT_H */
|
19
deps/libpq/include/utils/spccache.h
vendored
Normal file
19
deps/libpq/include/utils/spccache.h
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* spccache.h
|
||||
* Tablespace cache.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/spccache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SPCCACHE_H
|
||||
#define SPCCACHE_H
|
||||
|
||||
void get_tablespace_page_costs(Oid spcid, float8 *spc_random_page_cost,
|
||||
float8 *spc_seq_page_cost);
|
||||
|
||||
#endif /* SPCCACHE_H */
|
171
deps/libpq/include/utils/syscache.h
vendored
Normal file
171
deps/libpq/include/utils/syscache.h
vendored
Normal file
|
@ -0,0 +1,171 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* syscache.h
|
||||
* System catalog cache definitions.
|
||||
*
|
||||
* See also lsyscache.h, which provides convenience routines for
|
||||
* common cache-lookup operations.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/syscache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SYSCACHE_H
|
||||
#define SYSCACHE_H
|
||||
|
||||
#include "utils/catcache.h"
|
||||
|
||||
/*
|
||||
* SysCache identifiers.
|
||||
*
|
||||
* The order of these identifiers must match the order
|
||||
* of the entries in the array cacheinfo[] in syscache.c.
|
||||
* Keep them in alphabetical order (renumbering only costs a
|
||||
* backend rebuild).
|
||||
*/
|
||||
|
||||
enum SysCacheIdentifier
|
||||
{
|
||||
AGGFNOID = 0,
|
||||
AMNAME,
|
||||
AMOID,
|
||||
AMOPOPID,
|
||||
AMOPSTRATEGY,
|
||||
AMPROCNUM,
|
||||
ATTNAME,
|
||||
ATTNUM,
|
||||
AUTHMEMMEMROLE,
|
||||
AUTHMEMROLEMEM,
|
||||
AUTHNAME,
|
||||
AUTHOID,
|
||||
CASTSOURCETARGET,
|
||||
CLAAMNAMENSP,
|
||||
CLAOID,
|
||||
COLLNAMEENCNSP,
|
||||
COLLOID,
|
||||
CONDEFAULT,
|
||||
CONNAMENSP,
|
||||
CONSTROID,
|
||||
CONVOID,
|
||||
DATABASEOID,
|
||||
DEFACLROLENSPOBJ,
|
||||
ENUMOID,
|
||||
ENUMTYPOIDNAME,
|
||||
FOREIGNDATAWRAPPERNAME,
|
||||
FOREIGNDATAWRAPPEROID,
|
||||
FOREIGNSERVERNAME,
|
||||
FOREIGNSERVEROID,
|
||||
FOREIGNTABLEREL,
|
||||
INDEXRELID,
|
||||
LANGNAME,
|
||||
LANGOID,
|
||||
NAMESPACENAME,
|
||||
NAMESPACEOID,
|
||||
OPERNAMENSP,
|
||||
OPEROID,
|
||||
OPFAMILYAMNAMENSP,
|
||||
OPFAMILYOID,
|
||||
PROCNAMEARGSNSP,
|
||||
PROCOID,
|
||||
RELNAMENSP,
|
||||
RELOID,
|
||||
RULERELNAME,
|
||||
STATRELATTINH,
|
||||
TABLESPACEOID,
|
||||
TSCONFIGMAP,
|
||||
TSCONFIGNAMENSP,
|
||||
TSCONFIGOID,
|
||||
TSDICTNAMENSP,
|
||||
TSDICTOID,
|
||||
TSPARSERNAMENSP,
|
||||
TSPARSEROID,
|
||||
TSTEMPLATENAMENSP,
|
||||
TSTEMPLATEOID,
|
||||
TYPENAMENSP,
|
||||
TYPEOID,
|
||||
USERMAPPINGOID,
|
||||
USERMAPPINGUSERSERVER
|
||||
};
|
||||
|
||||
extern void InitCatalogCache(void);
|
||||
extern void InitCatalogCachePhase2(void);
|
||||
|
||||
extern HeapTuple SearchSysCache(int cacheId,
|
||||
Datum key1, Datum key2, Datum key3, Datum key4);
|
||||
extern void ReleaseSysCache(HeapTuple tuple);
|
||||
|
||||
/* convenience routines */
|
||||
extern HeapTuple SearchSysCacheCopy(int cacheId,
|
||||
Datum key1, Datum key2, Datum key3, Datum key4);
|
||||
extern bool SearchSysCacheExists(int cacheId,
|
||||
Datum key1, Datum key2, Datum key3, Datum key4);
|
||||
extern Oid GetSysCacheOid(int cacheId,
|
||||
Datum key1, Datum key2, Datum key3, Datum key4);
|
||||
|
||||
extern HeapTuple SearchSysCacheAttName(Oid relid, const char *attname);
|
||||
extern HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname);
|
||||
extern bool SearchSysCacheExistsAttName(Oid relid, const char *attname);
|
||||
|
||||
extern Datum SysCacheGetAttr(int cacheId, HeapTuple tup,
|
||||
AttrNumber attributeNumber, bool *isNull);
|
||||
|
||||
/* list-search interface. Users of this must import catcache.h too */
|
||||
extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
|
||||
Datum key1, Datum key2, Datum key3, Datum key4);
|
||||
|
||||
/*
|
||||
* The use of the macros below rather than direct calls to the corresponding
|
||||
* functions is encouraged, as it insulates the caller from changes in the
|
||||
* maximum number of keys.
|
||||
*/
|
||||
#define SearchSysCache1(cacheId, key1) \
|
||||
SearchSysCache(cacheId, key1, 0, 0, 0)
|
||||
#define SearchSysCache2(cacheId, key1, key2) \
|
||||
SearchSysCache(cacheId, key1, key2, 0, 0)
|
||||
#define SearchSysCache3(cacheId, key1, key2, key3) \
|
||||
SearchSysCache(cacheId, key1, key2, key3, 0)
|
||||
#define SearchSysCache4(cacheId, key1, key2, key3, key4) \
|
||||
SearchSysCache(cacheId, key1, key2, key3, key4)
|
||||
|
||||
#define SearchSysCacheCopy1(cacheId, key1) \
|
||||
SearchSysCacheCopy(cacheId, key1, 0, 0, 0)
|
||||
#define SearchSysCacheCopy2(cacheId, key1, key2) \
|
||||
SearchSysCacheCopy(cacheId, key1, key2, 0, 0)
|
||||
#define SearchSysCacheCopy3(cacheId, key1, key2, key3) \
|
||||
SearchSysCacheCopy(cacheId, key1, key2, key3, 0)
|
||||
#define SearchSysCacheCopy4(cacheId, key1, key2, key3, key4) \
|
||||
SearchSysCacheCopy(cacheId, key1, key2, key3, key4)
|
||||
|
||||
#define SearchSysCacheExists1(cacheId, key1) \
|
||||
SearchSysCacheExists(cacheId, key1, 0, 0, 0)
|
||||
#define SearchSysCacheExists2(cacheId, key1, key2) \
|
||||
SearchSysCacheExists(cacheId, key1, key2, 0, 0)
|
||||
#define SearchSysCacheExists3(cacheId, key1, key2, key3) \
|
||||
SearchSysCacheExists(cacheId, key1, key2, key3, 0)
|
||||
#define SearchSysCacheExists4(cacheId, key1, key2, key3, key4) \
|
||||
SearchSysCacheExists(cacheId, key1, key2, key3, key4)
|
||||
|
||||
#define GetSysCacheOid1(cacheId, key1) \
|
||||
GetSysCacheOid(cacheId, key1, 0, 0, 0)
|
||||
#define GetSysCacheOid2(cacheId, key1, key2) \
|
||||
GetSysCacheOid(cacheId, key1, key2, 0, 0)
|
||||
#define GetSysCacheOid3(cacheId, key1, key2, key3) \
|
||||
GetSysCacheOid(cacheId, key1, key2, key3, 0)
|
||||
#define GetSysCacheOid4(cacheId, key1, key2, key3, key4) \
|
||||
GetSysCacheOid(cacheId, key1, key2, key3, key4)
|
||||
|
||||
#define SearchSysCacheList1(cacheId, key1) \
|
||||
SearchSysCacheList(cacheId, 1, key1, 0, 0, 0)
|
||||
#define SearchSysCacheList2(cacheId, key1, key2) \
|
||||
SearchSysCacheList(cacheId, 2, key1, key2, 0, 0)
|
||||
#define SearchSysCacheList3(cacheId, key1, key2, key3) \
|
||||
SearchSysCacheList(cacheId, 3, key1, key2, key3, 0)
|
||||
#define SearchSysCacheList4(cacheId, key1, key2, key3, key4) \
|
||||
SearchSysCacheList(cacheId, 4, key1, key2, key3, key4)
|
||||
|
||||
#define ReleaseSysCacheList(x) ReleaseCatCacheList(x)
|
||||
|
||||
#endif /* SYSCACHE_H */
|
361
deps/libpq/include/utils/timestamp.h
vendored
Normal file
361
deps/libpq/include/utils/timestamp.h
vendored
Normal file
|
@ -0,0 +1,361 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* timestamp.h
|
||||
* Definitions for the SQL92 "timestamp" and "interval" types.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/timestamp.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TIMESTAMP_H
|
||||
#define TIMESTAMP_H
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "pgtime.h"
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
#include "utils/int8.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Timestamp represents absolute time.
|
||||
*
|
||||
* Interval represents delta time. Keep track of months (and years), days,
|
||||
* and hours/minutes/seconds separately since the elapsed time spanned is
|
||||
* unknown until instantiated relative to an absolute time.
|
||||
*
|
||||
* Note that Postgres uses "time interval" to mean a bounded interval,
|
||||
* consisting of a beginning and ending time, not a time span - thomas 97/03/20
|
||||
*
|
||||
* We have two implementations, one that uses int64 values with units of
|
||||
* microseconds, and one that uses double values with units of seconds.
|
||||
*
|
||||
* TimeOffset and fsec_t are convenience typedefs for temporary variables
|
||||
* that are of different types in the two cases. Do not use fsec_t in values
|
||||
* stored on-disk, since it is not the same size in both implementations.
|
||||
* Also, fsec_t is only meant for *fractional* seconds; beware of overflow
|
||||
* if the value you need to store could be many seconds.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
|
||||
typedef int64 Timestamp;
|
||||
typedef int64 TimestampTz;
|
||||
typedef int64 TimeOffset;
|
||||
typedef int32 fsec_t; /* fractional seconds (in microseconds) */
|
||||
#else
|
||||
|
||||
typedef double Timestamp;
|
||||
typedef double TimestampTz;
|
||||
typedef double TimeOffset;
|
||||
typedef double fsec_t; /* fractional seconds (in seconds) */
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TimeOffset time; /* all time units other than days, months and
|
||||
* years */
|
||||
int32 day; /* days, after time for alignment */
|
||||
int32 month; /* months and years, after time for alignment */
|
||||
} Interval;
|
||||
|
||||
|
||||
#define MAX_TIMESTAMP_PRECISION 6
|
||||
#define MAX_INTERVAL_PRECISION 6
|
||||
|
||||
/* in both timestamp.h and ecpg/dt.h */
|
||||
#define DAYS_PER_YEAR 365.25 /* assumes leap year every four years */
|
||||
#define MONTHS_PER_YEAR 12
|
||||
/*
|
||||
* DAYS_PER_MONTH is very imprecise. The more accurate value is
|
||||
* 365.2425/12 = 30.436875, or '30 days 10:29:06'. Right now we only
|
||||
* return an integral number of days, but someday perhaps we should
|
||||
* also return a 'time' value to be used as well. ISO 8601 suggests
|
||||
* 30 days.
|
||||
*/
|
||||
#define DAYS_PER_MONTH 30 /* assumes exactly 30 days per month */
|
||||
#define HOURS_PER_DAY 24 /* assume no daylight savings time changes */
|
||||
|
||||
/*
|
||||
* This doesn't adjust for uneven daylight savings time intervals or leap
|
||||
* seconds, and it crudely estimates leap years. A more accurate value
|
||||
* for days per years is 365.2422.
|
||||
*/
|
||||
#define SECS_PER_YEAR (36525 * 864) /* avoid floating-point computation */
|
||||
#define SECS_PER_DAY 86400
|
||||
#define SECS_PER_HOUR 3600
|
||||
#define SECS_PER_MINUTE 60
|
||||
#define MINS_PER_HOUR 60
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
#define USECS_PER_DAY INT64CONST(86400000000)
|
||||
#define USECS_PER_HOUR INT64CONST(3600000000)
|
||||
#define USECS_PER_MINUTE INT64CONST(60000000)
|
||||
#define USECS_PER_SEC INT64CONST(1000000)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We allow numeric timezone offsets up to 15:59:59 either way from Greenwich.
|
||||
* Currently, the record holders for wackiest offsets in actual use are zones
|
||||
* Asia/Manila, at -15:56:00 until 1844, and America/Metlakatla, at +15:13:42
|
||||
* until 1867. If we were to reject such values we would fail to dump and
|
||||
* restore old timestamptz values with these zone settings.
|
||||
*/
|
||||
#define MAX_TZDISP_HOUR 15 /* maximum allowed hour part */
|
||||
#define TZDISP_LIMIT ((MAX_TZDISP_HOUR + 1) * SECS_PER_HOUR)
|
||||
|
||||
/*
|
||||
* Macros for fmgr-callable functions.
|
||||
*
|
||||
* For Timestamp, we make use of the same support routines as for int64
|
||||
* or float8. Therefore Timestamp is pass-by-reference if and only if
|
||||
* int64 or float8 is!
|
||||
*/
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
|
||||
#define DatumGetTimestamp(X) ((Timestamp) DatumGetInt64(X))
|
||||
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetInt64(X))
|
||||
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
|
||||
|
||||
#define TimestampGetDatum(X) Int64GetDatum(X)
|
||||
#define TimestampTzGetDatum(X) Int64GetDatum(X)
|
||||
#define IntervalPGetDatum(X) PointerGetDatum(X)
|
||||
|
||||
#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_TIMESTAMPTZ(n) DatumGetTimestampTz(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_INTERVAL_P(n) DatumGetIntervalP(PG_GETARG_DATUM(n))
|
||||
|
||||
#define PG_RETURN_TIMESTAMP(x) return TimestampGetDatum(x)
|
||||
#define PG_RETURN_TIMESTAMPTZ(x) return TimestampTzGetDatum(x)
|
||||
#define PG_RETURN_INTERVAL_P(x) return IntervalPGetDatum(x)
|
||||
|
||||
#define DT_NOBEGIN (-INT64CONST(0x7fffffffffffffff) - 1)
|
||||
#define DT_NOEND (INT64CONST(0x7fffffffffffffff))
|
||||
#else /* !HAVE_INT64_TIMESTAMP */
|
||||
|
||||
#define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X))
|
||||
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X))
|
||||
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
|
||||
|
||||
#define TimestampGetDatum(X) Float8GetDatum(X)
|
||||
#define TimestampTzGetDatum(X) Float8GetDatum(X)
|
||||
#define IntervalPGetDatum(X) PointerGetDatum(X)
|
||||
|
||||
#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_TIMESTAMPTZ(n) DatumGetTimestampTz(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_INTERVAL_P(n) DatumGetIntervalP(PG_GETARG_DATUM(n))
|
||||
|
||||
#define PG_RETURN_TIMESTAMP(x) return TimestampGetDatum(x)
|
||||
#define PG_RETURN_TIMESTAMPTZ(x) return TimestampTzGetDatum(x)
|
||||
#define PG_RETURN_INTERVAL_P(x) return IntervalPGetDatum(x)
|
||||
|
||||
#ifdef HUGE_VAL
|
||||
#define DT_NOBEGIN (-HUGE_VAL)
|
||||
#define DT_NOEND (HUGE_VAL)
|
||||
#else
|
||||
#define DT_NOBEGIN (-DBL_MAX)
|
||||
#define DT_NOEND (DBL_MAX)
|
||||
#endif
|
||||
#endif /* HAVE_INT64_TIMESTAMP */
|
||||
|
||||
|
||||
#define TIMESTAMP_NOBEGIN(j) \
|
||||
do {(j) = DT_NOBEGIN;} while (0)
|
||||
#define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN)
|
||||
|
||||
#define TIMESTAMP_NOEND(j) \
|
||||
do {(j) = DT_NOEND;} while (0)
|
||||
#define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND)
|
||||
|
||||
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
|
||||
|
||||
/*
|
||||
* Round off to MAX_TIMESTAMP_PRECISION decimal places.
|
||||
* Note: this is also used for rounding off intervals.
|
||||
*/
|
||||
#define TS_PREC_INV 1000000.0
|
||||
#define TSROUND(j) (rint(((double) (j)) * TS_PREC_INV) / TS_PREC_INV)
|
||||
|
||||
#define TIMESTAMP_MASK(b) (1 << (b))
|
||||
#define INTERVAL_MASK(b) (1 << (b))
|
||||
|
||||
/* Macros to handle packing and unpacking the typmod field for intervals */
|
||||
#define INTERVAL_FULL_RANGE (0x7FFF)
|
||||
#define INTERVAL_RANGE_MASK (0x7FFF)
|
||||
#define INTERVAL_FULL_PRECISION (0xFFFF)
|
||||
#define INTERVAL_PRECISION_MASK (0xFFFF)
|
||||
#define INTERVAL_TYPMOD(p,r) ((((r) & INTERVAL_RANGE_MASK) << 16) | ((p) & INTERVAL_PRECISION_MASK))
|
||||
#define INTERVAL_PRECISION(t) ((t) & INTERVAL_PRECISION_MASK)
|
||||
#define INTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK)
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) * (int64) 1000))
|
||||
#else
|
||||
#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) / 1000.0))
|
||||
#endif
|
||||
|
||||
|
||||
/* Set at postmaster start */
|
||||
extern TimestampTz PgStartTime;
|
||||
|
||||
/* Set at configuration reload */
|
||||
extern TimestampTz PgReloadTime;
|
||||
|
||||
|
||||
/*
|
||||
* timestamp.c prototypes
|
||||
*/
|
||||
|
||||
extern Datum timestamp_in(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_out(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_send(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptypmodin(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptypmodout(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_scale(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_le(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_finite(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_cmp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_hash(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_smaller(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_larger(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timestamp_eq_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_ne_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_lt_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_le_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_gt_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_ge_timestamptz(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_cmp_timestamptz(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timestamptz_eq_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_ne_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_lt_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_le_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_gt_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_ge_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_cmp_timestamp(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum interval_in(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_out(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_send(PG_FUNCTION_ARGS);
|
||||
extern Datum intervaltypmodin(PG_FUNCTION_ARGS);
|
||||
extern Datum intervaltypmodout(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_scale(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_eq(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_ne(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_lt(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_le(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_ge(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_gt(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_finite(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_cmp(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_hash(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_smaller(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_larger(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_justify_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_justify_hours(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_justify_days(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timestamp_trunc(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_trunc(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_part(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_part(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_zone(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_izone(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_timestamptz(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timestamptz_in(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_out(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_send(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptztypmodin(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptztypmodout(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_scale(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_zone(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_izone(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_timestamptz(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum interval_um(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_pl(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_mi(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_mul(PG_FUNCTION_ARGS);
|
||||
extern Datum mul_d_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_div(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_accum(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_avg(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timestamp_mi(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_pl_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_mi_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamp_age(PG_FUNCTION_ARGS);
|
||||
extern Datum overlaps_timestamp(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum timestamptz_pl_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_mi_interval(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_age(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_trunc(PG_FUNCTION_ARGS);
|
||||
extern Datum timestamptz_part(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum now(PG_FUNCTION_ARGS);
|
||||
extern Datum statement_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum clock_timestamp(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum pg_postmaster_start_time(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_conf_load_time(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum generate_series_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum generate_series_timestamptz(PG_FUNCTION_ARGS);
|
||||
|
||||
/* Internal routines (not fmgr-callable) */
|
||||
|
||||
extern TimestampTz GetCurrentTimestamp(void);
|
||||
|
||||
extern void TimestampDifference(TimestampTz start_time, TimestampTz stop_time,
|
||||
long *secs, int *microsecs);
|
||||
extern bool TimestampDifferenceExceeds(TimestampTz start_time,
|
||||
TimestampTz stop_time,
|
||||
int msec);
|
||||
|
||||
extern TimestampTz time_t_to_timestamptz(pg_time_t tm);
|
||||
extern pg_time_t timestamptz_to_time_t(TimestampTz t);
|
||||
|
||||
extern const char *timestamptz_to_str(TimestampTz t);
|
||||
|
||||
extern int tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);
|
||||
extern int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm,
|
||||
fsec_t *fsec, char **tzn, pg_tz *attimezone);
|
||||
extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec);
|
||||
|
||||
extern int interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec);
|
||||
extern int tm2interval(struct pg_tm * tm, fsec_t fsec, Interval *span);
|
||||
|
||||
extern Timestamp SetEpochTimestamp(void);
|
||||
extern void GetEpochTime(struct pg_tm * tm);
|
||||
|
||||
extern int timestamp_cmp_internal(Timestamp dt1, Timestamp dt2);
|
||||
|
||||
/* timestamp comparison works for timestamptz also */
|
||||
#define timestamptz_cmp_internal(dt1,dt2) timestamp_cmp_internal(dt1, dt2)
|
||||
|
||||
extern int isoweek2j(int year, int week);
|
||||
extern void isoweek2date(int woy, int *year, int *mon, int *mday);
|
||||
extern void isoweekdate2date(int isoweek, int isowday, int *year, int *mon, int *mday);
|
||||
extern int date2isoweek(int year, int mon, int mday);
|
||||
extern int date2isoyear(int year, int mon, int mday);
|
||||
extern int date2isoyearday(int year, int mon, int mday);
|
||||
|
||||
#endif /* TIMESTAMP_H */
|
90
deps/libpq/include/utils/tqual.h
vendored
Normal file
90
deps/libpq/include/utils/tqual.h
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* tqual.h
|
||||
* POSTGRES "time qualification" definitions, ie, tuple visibility rules.
|
||||
*
|
||||
* Should be moved/renamed... - vadim 07/28/98
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/tqual.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TQUAL_H
|
||||
#define TQUAL_H
|
||||
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
/* Static variables representing various special snapshot semantics */
|
||||
extern PGDLLIMPORT SnapshotData SnapshotNowData;
|
||||
extern PGDLLIMPORT SnapshotData SnapshotSelfData;
|
||||
extern PGDLLIMPORT SnapshotData SnapshotAnyData;
|
||||
extern PGDLLIMPORT SnapshotData SnapshotToastData;
|
||||
|
||||
#define SnapshotNow (&SnapshotNowData)
|
||||
#define SnapshotSelf (&SnapshotSelfData)
|
||||
#define SnapshotAny (&SnapshotAnyData)
|
||||
#define SnapshotToast (&SnapshotToastData)
|
||||
|
||||
/*
|
||||
* We don't provide a static SnapshotDirty variable because it would be
|
||||
* non-reentrant. Instead, users of that snapshot type should declare a
|
||||
* local variable of type SnapshotData, and initialize it with this macro.
|
||||
*/
|
||||
#define InitDirtySnapshot(snapshotdata) \
|
||||
((snapshotdata).satisfies = HeapTupleSatisfiesDirty)
|
||||
|
||||
/* This macro encodes the knowledge of which snapshots are MVCC-safe */
|
||||
#define IsMVCCSnapshot(snapshot) \
|
||||
((snapshot)->satisfies == HeapTupleSatisfiesMVCC)
|
||||
|
||||
/*
|
||||
* HeapTupleSatisfiesVisibility
|
||||
* True iff heap tuple satisfies a time qual.
|
||||
*
|
||||
* Notes:
|
||||
* Assumes heap tuple is valid.
|
||||
* Beware of multiple evaluations of snapshot argument.
|
||||
* Hint bits in the HeapTuple's t_infomask may be updated as a side effect;
|
||||
* if so, the indicated buffer is marked dirty.
|
||||
*/
|
||||
#define HeapTupleSatisfiesVisibility(tuple, snapshot, buffer) \
|
||||
((*(snapshot)->satisfies) ((tuple)->t_data, snapshot, buffer))
|
||||
|
||||
/* Result codes for HeapTupleSatisfiesVacuum */
|
||||
typedef enum
|
||||
{
|
||||
HEAPTUPLE_DEAD, /* tuple is dead and deletable */
|
||||
HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */
|
||||
HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */
|
||||
HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */
|
||||
HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still in progress */
|
||||
} HTSV_Result;
|
||||
|
||||
/* These are the "satisfies" test routines for the various snapshot types */
|
||||
extern bool HeapTupleSatisfiesMVCC(HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
extern bool HeapTupleSatisfiesSelf(HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
extern bool HeapTupleSatisfiesAny(HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
extern bool HeapTupleSatisfiesToast(HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
|
||||
/* Special "satisfies" routines with different APIs */
|
||||
extern HTSU_Result HeapTupleSatisfiesUpdate(HeapTupleHeader tuple,
|
||||
CommandId curcid, Buffer buffer);
|
||||
extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTupleHeader tuple,
|
||||
TransactionId OldestXmin, Buffer buffer);
|
||||
|
||||
extern void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
|
||||
uint16 infomask, TransactionId xid);
|
||||
|
||||
#endif /* TQUAL_H */
|
134
deps/libpq/include/utils/tuplesort.h
vendored
Normal file
134
deps/libpq/include/utils/tuplesort.h
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* tuplesort.h
|
||||
* Generalized tuple sorting routines.
|
||||
*
|
||||
* This module handles sorting of heap tuples, index tuples, or single
|
||||
* Datums (and could easily support other kinds of sortable objects,
|
||||
* if necessary). It works efficiently for both small and large amounts
|
||||
* of data. Small amounts are sorted in-memory using qsort(). Large
|
||||
* amounts are sorted using temporary files and a standard external sort
|
||||
* algorithm.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/tuplesort.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TUPLESORT_H
|
||||
#define TUPLESORT_H
|
||||
|
||||
#include "access/itup.h"
|
||||
#include "executor/tuptable.h"
|
||||
#include "fmgr.h"
|
||||
#include "utils/relcache.h"
|
||||
|
||||
|
||||
/* Tuplesortstate is an opaque type whose details are not known outside
|
||||
* tuplesort.c.
|
||||
*/
|
||||
typedef struct Tuplesortstate Tuplesortstate;
|
||||
|
||||
/*
|
||||
* We provide multiple interfaces to what is essentially the same code,
|
||||
* since different callers have different data to be sorted and want to
|
||||
* specify the sort key information differently. There are two APIs for
|
||||
* sorting HeapTuples and two more for sorting IndexTuples. Yet another
|
||||
* API supports sorting bare Datums.
|
||||
*
|
||||
* The "heap" API actually stores/sorts MinimalTuples, which means it doesn't
|
||||
* preserve the system columns (tuple identity and transaction visibility
|
||||
* info). The sort keys are specified by column numbers within the tuples
|
||||
* and sort operator OIDs. We save some cycles by passing and returning the
|
||||
* tuples in TupleTableSlots, rather than forming actual HeapTuples (which'd
|
||||
* have to be converted to MinimalTuples). This API works well for sorts
|
||||
* executed as parts of plan trees.
|
||||
*
|
||||
* The "cluster" API stores/sorts full HeapTuples including all visibility
|
||||
* info. The sort keys are specified by reference to a btree index that is
|
||||
* defined on the relation to be sorted. Note that putheaptuple/getheaptuple
|
||||
* go with this API, not the "begin_heap" one!
|
||||
*
|
||||
* The "index_btree" API stores/sorts IndexTuples (preserving all their
|
||||
* header fields). The sort keys are specified by a btree index definition.
|
||||
*
|
||||
* The "index_hash" API is similar to index_btree, but the tuples are
|
||||
* actually sorted by their hash codes not the raw data.
|
||||
*/
|
||||
|
||||
extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc,
|
||||
int nkeys, AttrNumber *attNums,
|
||||
Oid *sortOperators, Oid *sortCollations,
|
||||
bool *nullsFirstFlags,
|
||||
int workMem, bool randomAccess);
|
||||
extern Tuplesortstate *tuplesort_begin_cluster(TupleDesc tupDesc,
|
||||
Relation indexRel,
|
||||
int workMem, bool randomAccess);
|
||||
extern Tuplesortstate *tuplesort_begin_index_btree(Relation indexRel,
|
||||
bool enforceUnique,
|
||||
int workMem, bool randomAccess);
|
||||
extern Tuplesortstate *tuplesort_begin_index_hash(Relation indexRel,
|
||||
uint32 hash_mask,
|
||||
int workMem, bool randomAccess);
|
||||
extern Tuplesortstate *tuplesort_begin_datum(Oid datumType,
|
||||
Oid sortOperator, Oid sortCollation,
|
||||
bool nullsFirstFlag,
|
||||
int workMem, bool randomAccess);
|
||||
|
||||
extern void tuplesort_set_bound(Tuplesortstate *state, int64 bound);
|
||||
|
||||
extern void tuplesort_puttupleslot(Tuplesortstate *state,
|
||||
TupleTableSlot *slot);
|
||||
extern void tuplesort_putheaptuple(Tuplesortstate *state, HeapTuple tup);
|
||||
extern void tuplesort_putindextuple(Tuplesortstate *state, IndexTuple tuple);
|
||||
extern void tuplesort_putdatum(Tuplesortstate *state, Datum val,
|
||||
bool isNull);
|
||||
|
||||
extern void tuplesort_performsort(Tuplesortstate *state);
|
||||
|
||||
extern bool tuplesort_gettupleslot(Tuplesortstate *state, bool forward,
|
||||
TupleTableSlot *slot);
|
||||
extern HeapTuple tuplesort_getheaptuple(Tuplesortstate *state, bool forward,
|
||||
bool *should_free);
|
||||
extern IndexTuple tuplesort_getindextuple(Tuplesortstate *state, bool forward,
|
||||
bool *should_free);
|
||||
extern bool tuplesort_getdatum(Tuplesortstate *state, bool forward,
|
||||
Datum *val, bool *isNull);
|
||||
|
||||
extern void tuplesort_end(Tuplesortstate *state);
|
||||
|
||||
extern void tuplesort_get_stats(Tuplesortstate *state,
|
||||
const char **sortMethod,
|
||||
const char **spaceType,
|
||||
long *spaceUsed);
|
||||
|
||||
extern int tuplesort_merge_order(long allowedMem);
|
||||
|
||||
/*
|
||||
* These routines may only be called if randomAccess was specified 'true'.
|
||||
* Likewise, backwards scan in gettuple/getdatum is only allowed if
|
||||
* randomAccess was specified.
|
||||
*/
|
||||
|
||||
extern void tuplesort_rescan(Tuplesortstate *state);
|
||||
extern void tuplesort_markpos(Tuplesortstate *state);
|
||||
extern void tuplesort_restorepos(Tuplesortstate *state);
|
||||
|
||||
/* Setup for ApplySortFunction */
|
||||
extern void SelectSortFunction(Oid sortOperator, bool nulls_first,
|
||||
Oid *sortFunction,
|
||||
int *sortFlags);
|
||||
|
||||
/*
|
||||
* Apply a sort function (by now converted to fmgr lookup form)
|
||||
* and return a 3-way comparison result. This takes care of handling
|
||||
* reverse-sort and NULLs-ordering properly.
|
||||
*/
|
||||
extern int32 ApplySortFunction(FmgrInfo *sortFunction, int sortFlags,
|
||||
Oid collation,
|
||||
Datum datum1, bool isNull1,
|
||||
Datum datum2, bool isNull2);
|
||||
|
||||
#endif /* TUPLESORT_H */
|
85
deps/libpq/include/utils/tuplestore.h
vendored
Normal file
85
deps/libpq/include/utils/tuplestore.h
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* tuplestore.h
|
||||
* Generalized routines for temporary tuple storage.
|
||||
*
|
||||
* This module handles temporary storage of tuples for purposes such
|
||||
* as Materialize nodes, hashjoin batch files, etc. It is essentially
|
||||
* a dumbed-down version of tuplesort.c; it does no sorting of tuples
|
||||
* but can only store and regurgitate a sequence of tuples. However,
|
||||
* because no sort is required, it is allowed to start reading the sequence
|
||||
* before it has all been written. This is particularly useful for cursors,
|
||||
* because it allows random access within the already-scanned portion of
|
||||
* a query without having to process the underlying scan to completion.
|
||||
* Also, it is possible to support multiple independent read pointers.
|
||||
*
|
||||
* A temporary file is used to handle the data if it exceeds the
|
||||
* space limit specified by the caller.
|
||||
*
|
||||
* Beginning in Postgres 8.2, what is stored is just MinimalTuples;
|
||||
* callers cannot expect valid system columns in regurgitated tuples.
|
||||
* Also, we have changed the API to return tuples in TupleTableSlots,
|
||||
* so that there is a check to prevent attempted access to system columns.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/tuplestore.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TUPLESTORE_H
|
||||
#define TUPLESTORE_H
|
||||
|
||||
#include "executor/tuptable.h"
|
||||
|
||||
|
||||
/* Tuplestorestate is an opaque type whose details are not known outside
|
||||
* tuplestore.c.
|
||||
*/
|
||||
typedef struct Tuplestorestate Tuplestorestate;
|
||||
|
||||
/*
|
||||
* Currently we only need to store MinimalTuples, but it would be easy
|
||||
* to support the same behavior for IndexTuples and/or bare Datums.
|
||||
*/
|
||||
|
||||
extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
|
||||
bool interXact,
|
||||
int maxKBytes);
|
||||
|
||||
extern void tuplestore_set_eflags(Tuplestorestate *state, int eflags);
|
||||
|
||||
extern void tuplestore_puttupleslot(Tuplestorestate *state,
|
||||
TupleTableSlot *slot);
|
||||
extern void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple);
|
||||
extern void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc,
|
||||
Datum *values, bool *isnull);
|
||||
|
||||
/* tuplestore_donestoring() used to be required, but is no longer used */
|
||||
#define tuplestore_donestoring(state) ((void) 0)
|
||||
|
||||
extern int tuplestore_alloc_read_pointer(Tuplestorestate *state, int eflags);
|
||||
|
||||
extern void tuplestore_select_read_pointer(Tuplestorestate *state, int ptr);
|
||||
|
||||
extern void tuplestore_copy_read_pointer(Tuplestorestate *state,
|
||||
int srcptr, int destptr);
|
||||
|
||||
extern void tuplestore_trim(Tuplestorestate *state);
|
||||
|
||||
extern bool tuplestore_in_memory(Tuplestorestate *state);
|
||||
|
||||
extern bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward,
|
||||
bool copy, TupleTableSlot *slot);
|
||||
extern bool tuplestore_advance(Tuplestorestate *state, bool forward);
|
||||
|
||||
extern bool tuplestore_ateof(Tuplestorestate *state);
|
||||
|
||||
extern void tuplestore_rescan(Tuplestorestate *state);
|
||||
|
||||
extern void tuplestore_clear(Tuplestorestate *state);
|
||||
|
||||
extern void tuplestore_end(Tuplestorestate *state);
|
||||
|
||||
#endif /* TUPLESTORE_H */
|
110
deps/libpq/include/utils/typcache.h
vendored
Normal file
110
deps/libpq/include/utils/typcache.h
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* typcache.h
|
||||
* Type cache definitions.
|
||||
*
|
||||
* The type cache exists to speed lookup of certain information about data
|
||||
* types that is not directly available from a type's pg_type row.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/typcache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TYPCACHE_H
|
||||
#define TYPCACHE_H
|
||||
|
||||
#include "access/tupdesc.h"
|
||||
#include "fmgr.h"
|
||||
|
||||
|
||||
/* TypeCacheEnumData is an opaque struct known only within typcache.c */
|
||||
struct TypeCacheEnumData;
|
||||
|
||||
typedef struct TypeCacheEntry
|
||||
{
|
||||
/* typeId is the hash lookup key and MUST BE FIRST */
|
||||
Oid type_id; /* OID of the data type */
|
||||
|
||||
/* some subsidiary information copied from the pg_type row */
|
||||
int16 typlen;
|
||||
bool typbyval;
|
||||
char typalign;
|
||||
char typtype;
|
||||
Oid typrelid;
|
||||
|
||||
/*
|
||||
* Information obtained from opfamily entries
|
||||
*
|
||||
* These will be InvalidOid if no match could be found, or if the
|
||||
* information hasn't yet been requested. Also note that for array and
|
||||
* composite types, typcache.c checks that the contained types are
|
||||
* comparable or hashable before allowing eq_opr etc to become set.
|
||||
*/
|
||||
Oid btree_opf; /* the default btree opclass' family */
|
||||
Oid btree_opintype; /* the default btree opclass' opcintype */
|
||||
Oid hash_opf; /* the default hash opclass' family */
|
||||
Oid hash_opintype; /* the default hash opclass' opcintype */
|
||||
Oid eq_opr; /* the equality operator */
|
||||
Oid lt_opr; /* the less-than operator */
|
||||
Oid gt_opr; /* the greater-than operator */
|
||||
Oid cmp_proc; /* the btree comparison function */
|
||||
Oid hash_proc; /* the hash calculation function */
|
||||
|
||||
/*
|
||||
* Pre-set-up fmgr call info for the equality operator, the btree
|
||||
* comparison function, and the hash calculation function. These are kept
|
||||
* in the type cache to avoid problems with memory leaks in repeated calls
|
||||
* to functions such as array_eq, array_cmp, hash_array. There is not
|
||||
* currently a need to maintain call info for the lt_opr or gt_opr.
|
||||
*/
|
||||
FmgrInfo eq_opr_finfo;
|
||||
FmgrInfo cmp_proc_finfo;
|
||||
FmgrInfo hash_proc_finfo;
|
||||
|
||||
/*
|
||||
* Tuple descriptor if it's a composite type (row type). NULL if not
|
||||
* composite or information hasn't yet been requested. (NOTE: this is a
|
||||
* reference-counted tupledesc.)
|
||||
*/
|
||||
TupleDesc tupDesc;
|
||||
|
||||
/* Private data, for internal use of typcache.c only */
|
||||
int flags; /* flags about what we've computed */
|
||||
|
||||
/*
|
||||
* Private information about an enum type. NULL if not enum or
|
||||
* information hasn't been requested.
|
||||
*/
|
||||
struct TypeCacheEnumData *enumData;
|
||||
} TypeCacheEntry;
|
||||
|
||||
/* Bit flags to indicate which fields a given caller needs to have set */
|
||||
#define TYPECACHE_EQ_OPR 0x0001
|
||||
#define TYPECACHE_LT_OPR 0x0002
|
||||
#define TYPECACHE_GT_OPR 0x0004
|
||||
#define TYPECACHE_CMP_PROC 0x0008
|
||||
#define TYPECACHE_HASH_PROC 0x0010
|
||||
#define TYPECACHE_EQ_OPR_FINFO 0x0020
|
||||
#define TYPECACHE_CMP_PROC_FINFO 0x0040
|
||||
#define TYPECACHE_HASH_PROC_FINFO 0x0080
|
||||
#define TYPECACHE_TUPDESC 0x0100
|
||||
#define TYPECACHE_BTREE_OPFAMILY 0x0200
|
||||
#define TYPECACHE_HASH_OPFAMILY 0x0400
|
||||
|
||||
extern TypeCacheEntry *lookup_type_cache(Oid type_id, int flags);
|
||||
|
||||
extern TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod);
|
||||
|
||||
extern TupleDesc lookup_rowtype_tupdesc_noerror(Oid type_id, int32 typmod,
|
||||
bool noError);
|
||||
|
||||
extern TupleDesc lookup_rowtype_tupdesc_copy(Oid type_id, int32 typmod);
|
||||
|
||||
extern void assign_record_type_typmod(TupleDesc tupDesc);
|
||||
|
||||
extern int compare_values_of_enum(TypeCacheEntry *tcache, Oid arg1, Oid arg2);
|
||||
|
||||
#endif /* TYPCACHE_H */
|
37
deps/libpq/include/utils/tzparser.h
vendored
Normal file
37
deps/libpq/include/utils/tzparser.h
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* tzparser.h
|
||||
* Timezone offset file parsing definitions.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/tzparser.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TZPARSER_H
|
||||
#define TZPARSER_H
|
||||
|
||||
#include "utils/datetime.h"
|
||||
|
||||
/*
|
||||
* The result of parsing a timezone configuration file is an array of
|
||||
* these structs, in order by abbrev. We export this because datetime.c
|
||||
* needs it.
|
||||
*/
|
||||
typedef struct tzEntry
|
||||
{
|
||||
/* the actual data: TZ abbrev (downcased), offset, DST flag */
|
||||
char *abbrev;
|
||||
int offset; /* in seconds from UTC */
|
||||
bool is_dst;
|
||||
/* source information (for error messages) */
|
||||
int lineno;
|
||||
const char *filename;
|
||||
} tzEntry;
|
||||
|
||||
|
||||
extern TimeZoneAbbrevTable *load_tzoffsets(const char *filename);
|
||||
|
||||
#endif /* TZPARSER_H */
|
29
deps/libpq/include/utils/uuid.h
vendored
Normal file
29
deps/libpq/include/utils/uuid.h
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* uuid.h
|
||||
* Header file for the "uuid" ADT. In C, we use the name pg_uuid_t,
|
||||
* to avoid conflicts with any uuid_t type that might be defined by
|
||||
* the system headers.
|
||||
*
|
||||
* Copyright (c) 2007-2011, PostgreSQL Global Development Group
|
||||
*
|
||||
* src/include/utils/uuid.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef UUID_H
|
||||
#define UUID_H
|
||||
|
||||
/* guid size in bytes */
|
||||
#define UUID_LEN 16
|
||||
|
||||
/* opaque struct; defined in uuid.c */
|
||||
typedef struct pg_uuid_t pg_uuid_t;
|
||||
|
||||
/* fmgr interface macros */
|
||||
#define UUIDPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_RETURN_UUID_P(X) return UUIDPGetDatum(X)
|
||||
#define DatumGetUUIDP(X) ((pg_uuid_t *) DatumGetPointer(X))
|
||||
#define PG_GETARG_UUID_P(X) DatumGetUUIDP(PG_GETARG_DATUM(X))
|
||||
|
||||
#endif /* UUID_H */
|
106
deps/libpq/include/utils/varbit.h
vendored
Normal file
106
deps/libpq/include/utils/varbit.h
vendored
Normal file
|
@ -0,0 +1,106 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* varbit.h
|
||||
* Functions for the SQL datatypes BIT() and BIT VARYING().
|
||||
*
|
||||
* Code originally contributed by Adriaan Joubert.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/varbit.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef VARBIT_H
|
||||
#define VARBIT_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
/*
|
||||
* Modeled on struct varlena from postgres.h, but data type is bits8.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
int32 bit_len; /* number of valid bits */
|
||||
bits8 bit_dat[1]; /* bit string, most sig. byte first */
|
||||
} VarBit;
|
||||
|
||||
/*
|
||||
* fmgr interface macros
|
||||
*
|
||||
* BIT and BIT VARYING are toastable varlena types. They are the same
|
||||
* as far as representation goes, so we just have one set of macros.
|
||||
*/
|
||||
#define DatumGetVarBitP(X) ((VarBit *) PG_DETOAST_DATUM(X))
|
||||
#define DatumGetVarBitPCopy(X) ((VarBit *) PG_DETOAST_DATUM_COPY(X))
|
||||
#define VarBitPGetDatum(X) PointerGetDatum(X)
|
||||
#define PG_GETARG_VARBIT_P(n) DatumGetVarBitP(PG_GETARG_DATUM(n))
|
||||
#define PG_GETARG_VARBIT_P_COPY(n) DatumGetVarBitPCopy(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_VARBIT_P(x) return VarBitPGetDatum(x)
|
||||
|
||||
/* Header overhead *in addition to* VARHDRSZ */
|
||||
#define VARBITHDRSZ sizeof(int32)
|
||||
/* Number of bits in this bit string */
|
||||
#define VARBITLEN(PTR) (((VarBit *) (PTR))->bit_len)
|
||||
/* Pointer to the first byte containing bit string data */
|
||||
#define VARBITS(PTR) (((VarBit *) (PTR))->bit_dat)
|
||||
/* Number of bytes in the data section of a bit string */
|
||||
#define VARBITBYTES(PTR) (VARSIZE(PTR) - VARHDRSZ - VARBITHDRSZ)
|
||||
/* Padding of the bit string at the end (in bits) */
|
||||
#define VARBITPAD(PTR) (VARBITBYTES(PTR)*BITS_PER_BYTE - VARBITLEN(PTR))
|
||||
/* Number of bytes needed to store a bit string of a given length */
|
||||
#define VARBITTOTALLEN(BITLEN) (((BITLEN) + BITS_PER_BYTE-1)/BITS_PER_BYTE + \
|
||||
VARHDRSZ + VARBITHDRSZ)
|
||||
/* pointer beyond the end of the bit string (like end() in STL containers) */
|
||||
#define VARBITEND(PTR) (((bits8 *) (PTR)) + VARSIZE(PTR))
|
||||
/* Mask that will cover exactly one byte, i.e. BITS_PER_BYTE bits */
|
||||
#define BITMASK 0xFF
|
||||
|
||||
|
||||
extern Datum bit_in(PG_FUNCTION_ARGS);
|
||||
extern Datum bit_out(PG_FUNCTION_ARGS);
|
||||
extern Datum bit_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum bit_send(PG_FUNCTION_ARGS);
|
||||
extern Datum bittypmodin(PG_FUNCTION_ARGS);
|
||||
extern Datum bittypmodout(PG_FUNCTION_ARGS);
|
||||
extern Datum varbit_in(PG_FUNCTION_ARGS);
|
||||
extern Datum varbit_out(PG_FUNCTION_ARGS);
|
||||
extern Datum varbit_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum varbit_send(PG_FUNCTION_ARGS);
|
||||
extern Datum varbittypmodin(PG_FUNCTION_ARGS);
|
||||
extern Datum varbittypmodout(PG_FUNCTION_ARGS);
|
||||
extern Datum bit(PG_FUNCTION_ARGS);
|
||||
extern Datum varbit(PG_FUNCTION_ARGS);
|
||||
extern Datum biteq(PG_FUNCTION_ARGS);
|
||||
extern Datum bitne(PG_FUNCTION_ARGS);
|
||||
extern Datum bitlt(PG_FUNCTION_ARGS);
|
||||
extern Datum bitle(PG_FUNCTION_ARGS);
|
||||
extern Datum bitgt(PG_FUNCTION_ARGS);
|
||||
extern Datum bitge(PG_FUNCTION_ARGS);
|
||||
extern Datum bitcmp(PG_FUNCTION_ARGS);
|
||||
|
||||
/* avoid the names bitand and bitor, since they are C++ keywords */
|
||||
extern Datum bit_and(PG_FUNCTION_ARGS);
|
||||
extern Datum bit_or(PG_FUNCTION_ARGS);
|
||||
extern Datum bitxor(PG_FUNCTION_ARGS);
|
||||
extern Datum bitnot(PG_FUNCTION_ARGS);
|
||||
extern Datum bitshiftleft(PG_FUNCTION_ARGS);
|
||||
extern Datum bitshiftright(PG_FUNCTION_ARGS);
|
||||
extern Datum bitcat(PG_FUNCTION_ARGS);
|
||||
extern Datum bitsubstr(PG_FUNCTION_ARGS);
|
||||
extern Datum bitsubstr_no_len(PG_FUNCTION_ARGS);
|
||||
extern Datum bitoverlay(PG_FUNCTION_ARGS);
|
||||
extern Datum bitoverlay_no_len(PG_FUNCTION_ARGS);
|
||||
extern Datum bitlength(PG_FUNCTION_ARGS);
|
||||
extern Datum bitoctetlength(PG_FUNCTION_ARGS);
|
||||
extern Datum bitfromint4(PG_FUNCTION_ARGS);
|
||||
extern Datum bittoint4(PG_FUNCTION_ARGS);
|
||||
extern Datum bitfromint8(PG_FUNCTION_ARGS);
|
||||
extern Datum bittoint8(PG_FUNCTION_ARGS);
|
||||
extern Datum bitposition(PG_FUNCTION_ARGS);
|
||||
extern Datum bitsetbit(PG_FUNCTION_ARGS);
|
||||
extern Datum bitgetbit(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif
|
96
deps/libpq/include/utils/xml.h
vendored
Normal file
96
deps/libpq/include/utils/xml.h
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* xml.h
|
||||
* Declarations for XML data type support.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/utils/xml.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef XML_H
|
||||
#define XML_H
|
||||
|
||||
#include "fmgr.h"
|
||||
#include "nodes/execnodes.h"
|
||||
#include "nodes/primnodes.h"
|
||||
|
||||
typedef struct varlena xmltype;
|
||||
|
||||
#define DatumGetXmlP(X) ((xmltype *) PG_DETOAST_DATUM(X))
|
||||
#define XmlPGetDatum(X) PointerGetDatum(X)
|
||||
|
||||
#define PG_GETARG_XML_P(n) DatumGetXmlP(PG_GETARG_DATUM(n))
|
||||
#define PG_RETURN_XML_P(x) PG_RETURN_POINTER(x)
|
||||
|
||||
extern Datum xml_in(PG_FUNCTION_ARGS);
|
||||
extern Datum xml_out(PG_FUNCTION_ARGS);
|
||||
extern Datum xml_recv(PG_FUNCTION_ARGS);
|
||||
extern Datum xml_send(PG_FUNCTION_ARGS);
|
||||
extern Datum xmlcomment(PG_FUNCTION_ARGS);
|
||||
extern Datum xmlconcat2(PG_FUNCTION_ARGS);
|
||||
extern Datum texttoxml(PG_FUNCTION_ARGS);
|
||||
extern Datum xmltotext(PG_FUNCTION_ARGS);
|
||||
extern Datum xmlvalidate(PG_FUNCTION_ARGS);
|
||||
extern Datum xpath(PG_FUNCTION_ARGS);
|
||||
extern Datum xpath_exists(PG_FUNCTION_ARGS);
|
||||
extern Datum xmlexists(PG_FUNCTION_ARGS);
|
||||
extern Datum xml_is_well_formed(PG_FUNCTION_ARGS);
|
||||
extern Datum xml_is_well_formed_document(PG_FUNCTION_ARGS);
|
||||
extern Datum xml_is_well_formed_content(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum table_to_xml(PG_FUNCTION_ARGS);
|
||||
extern Datum query_to_xml(PG_FUNCTION_ARGS);
|
||||
extern Datum cursor_to_xml(PG_FUNCTION_ARGS);
|
||||
extern Datum table_to_xmlschema(PG_FUNCTION_ARGS);
|
||||
extern Datum query_to_xmlschema(PG_FUNCTION_ARGS);
|
||||
extern Datum cursor_to_xmlschema(PG_FUNCTION_ARGS);
|
||||
extern Datum table_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
|
||||
extern Datum query_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum schema_to_xml(PG_FUNCTION_ARGS);
|
||||
extern Datum schema_to_xmlschema(PG_FUNCTION_ARGS);
|
||||
extern Datum schema_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum database_to_xml(PG_FUNCTION_ARGS);
|
||||
extern Datum database_to_xmlschema(PG_FUNCTION_ARGS);
|
||||
extern Datum database_to_xml_and_xmlschema(PG_FUNCTION_ARGS);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XML_STANDALONE_YES,
|
||||
XML_STANDALONE_NO,
|
||||
XML_STANDALONE_NO_VALUE,
|
||||
XML_STANDALONE_OMITTED
|
||||
} XmlStandaloneType;
|
||||
|
||||
extern void pg_xml_init(void);
|
||||
extern void xml_ereport(int level, int sqlcode, const char *msg);
|
||||
extern xmltype *xmlconcat(List *args);
|
||||
extern xmltype *xmlelement(XmlExprState *xmlExpr, ExprContext *econtext);
|
||||
extern xmltype *xmlparse(text *data, XmlOptionType xmloption, bool preserve_whitespace);
|
||||
extern xmltype *xmlpi(char *target, text *arg, bool arg_is_null, bool *result_is_null);
|
||||
extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
|
||||
extern bool xml_is_document(xmltype *arg);
|
||||
extern text *xmltotext_with_xmloption(xmltype *data, XmlOptionType xmloption_arg);
|
||||
extern char *escape_xml(const char *str);
|
||||
|
||||
extern char *map_sql_identifier_to_xml_name(char *ident, bool fully_escaped, bool escape_period);
|
||||
extern char *map_xml_name_to_sql_identifier(char *name);
|
||||
extern char *map_sql_value_to_xml_value(Datum value, Oid type, bool xml_escape_strings);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XMLBINARY_BASE64,
|
||||
XMLBINARY_HEX
|
||||
} XmlBinaryType;
|
||||
|
||||
extern int xmlbinary; /* XmlBinaryType, but int for guc enum */
|
||||
|
||||
extern int xmloption; /* XmlOptionType, but int for guc enum */
|
||||
|
||||
#endif /* XML_H */
|
Loading…
Add table
Add a link
Reference in a new issue