diff options
| author | Pavan Deolasee | 2017-06-14 05:42:18 +0000 |
|---|---|---|
| committer | Pavan Deolasee | 2017-06-14 05:42:18 +0000 |
| commit | 15dd5274c323fb93e4e3ea9ad2185aaaec10f79c (patch) | |
| tree | 9dafb4c7f735d9429ea461dc792933af87493c33 /src/include/utils | |
| parent | dfbb88e3bbb526dcb204b456b9e5cfd9d10d0d0a (diff) | |
| parent | d5cb3bab564e0927ffac7c8729eacf181a12dd40 (diff) | |
Merge from PG master upto d5cb3bab564e0927ffac7c8729eacf181a12dd40
This is the result of the "git merge remotes/PGSQL/master" upto the said commit
point. We have done some basic analysis, fixed compilation problems etc, but
bulk of the logical problems in conflict resolution etc will be handled by
subsequent commits.
Diffstat (limited to 'src/include/utils')
81 files changed, 1023 insertions, 2660 deletions
diff --git a/src/include/utils/.gitignore b/src/include/utils/.gitignore index 808826d147..25db658da5 100644 --- a/src/include/utils/.gitignore +++ b/src/include/utils/.gitignore @@ -1,3 +1,4 @@ /fmgroids.h +/fmgrprotos.h /probes.h /errcodes.h diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index 4cc49f0c0c..2487020ec1 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -4,7 +4,7 @@ * Definition of (and support for) access control list data structures. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/acl.h @@ -26,6 +26,7 @@ #include "access/htup.h" #include "nodes/parsenodes.h" +#include "parser/parse_node.h" #include "utils/array.h" #include "utils/snapshot.h" @@ -191,6 +192,7 @@ typedef enum AclObjectKind ACL_KIND_OPFAMILY, /* pg_opfamily */ ACL_KIND_COLLATION, /* pg_collation */ ACL_KIND_CONVERSION, /* pg_conversion */ + ACL_KIND_STATISTICS, /* pg_statistic_ext */ ACL_KIND_TABLESPACE, /* pg_tablespace */ ACL_KIND_TSDICTIONARY, /* pg_ts_dict */ ACL_KIND_TSCONFIGURATION, /* pg_ts_config */ @@ -198,6 +200,8 @@ typedef enum AclObjectKind ACL_KIND_FOREIGN_SERVER, /* pg_foreign_server */ ACL_KIND_EVENT_TRIGGER, /* pg_event_trigger */ ACL_KIND_EXTENSION, /* pg_extension */ + ACL_KIND_PUBLICATION, /* pg_publication */ + ACL_KIND_SUBSCRIPTION, /* pg_subscription */ MAX_ACL_KIND /* MUST BE LAST */ } AclObjectKind; @@ -230,10 +234,10 @@ 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 *rolename, bool missing_ok); extern Oid get_role_oid_or_public(const char *rolename); -extern Oid get_rolespec_oid(const Node *node, bool missing_ok); -extern void check_rolespec_name(const Node *node, const char *detail_msg); -extern HeapTuple get_rolespec_tuple(const Node *node); -extern char *get_rolespec_name(const Node *node); +extern Oid get_rolespec_oid(const RoleSpec *role, bool missing_ok); +extern void check_rolespec_name(const RoleSpec *role, const char *detail_msg); +extern HeapTuple get_rolespec_tuple(const RoleSpec *role); +extern char *get_rolespec_name(const RoleSpec *role); extern void select_best_grantor(Oid roleId, AclMode privileges, const Acl *acl, Oid ownerId, @@ -242,24 +246,10 @@ extern void select_best_grantor(Oid roleId, AclMode privileges, 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 acldefault_sql(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 ExecAlterDefaultPrivilegesStmt(ParseState *pstate, AlterDefaultPrivilegesStmt *stmt); extern void RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid); extern void RemoveDefaultACLById(Oid defaclOid); @@ -311,6 +301,10 @@ extern void aclcheck_error_col(AclResult aclerr, AclObjectKind objectkind, extern void aclcheck_error_type(AclResult aclerr, Oid typeOid); +extern void recordExtObjInitPriv(Oid objoid, Oid classoid); +extern void removeExtObjInitPriv(Oid objoid, Oid classoid); + + /* 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); @@ -331,6 +325,9 @@ 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_event_trigger_ownercheck(Oid et_oid, Oid roleid); extern bool pg_extension_ownercheck(Oid ext_oid, Oid roleid); +extern bool pg_publication_ownercheck(Oid pub_oid, Oid roleid); +extern bool pg_subscription_ownercheck(Oid sub_oid, Oid roleid); +extern bool pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid); extern bool has_createrole_privilege(Oid roleid); extern bool has_bypassrls_privilege(Oid roleid); diff --git a/src/include/utils/aclchk_internal.h b/src/include/utils/aclchk_internal.h index 319a391246..0e50f73aab 100644 --- a/src/include/utils/aclchk_internal.h +++ b/src/include/utils/aclchk_internal.h @@ -2,7 +2,7 @@ * * aclchk_internal.h * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/aclchk_internal.h diff --git a/src/include/utils/array.h b/src/include/utils/array.h index b62b08c482..552c08f0d5 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -36,7 +36,7 @@ * * 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). + * nulls (and no null bitmap). They don't support being toasted, either. * * 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 @@ -51,7 +51,7 @@ * arrays holding the elements. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/array.h @@ -328,38 +328,6 @@ 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_cardinality(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_remove(PG_FUNCTION_ARGS); -extern Datum array_replace(PG_FUNCTION_ARGS); -extern Datum width_bucket_array(PG_FUNCTION_ARGS); - extern void CopyArrayEls(ArrayType *array, Datum *values, bool *nulls, @@ -475,31 +443,4 @@ extern ExpandedArrayHeader *DatumGetExpandedArrayX(Datum d, extern AnyArrayType *DatumGetAnyArray(Datum d); extern void deconstruct_expanded_array(ExpandedArrayHeader *eah); -/* - * prototypes for functions defined in array_userfuncs.c - */ -extern Datum array_append(PG_FUNCTION_ARGS); -extern Datum array_prepend(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); -extern Datum array_agg_array_transfn(PG_FUNCTION_ARGS); -extern Datum array_agg_array_finalfn(PG_FUNCTION_ARGS); - -extern Datum array_position(PG_FUNCTION_ARGS); -extern Datum array_position_start(PG_FUNCTION_ARGS); -extern Datum array_positions(PG_FUNCTION_ARGS); - -/* - * prototypes for functions defined in array_typanalyze.c - */ -extern Datum array_typanalyze(PG_FUNCTION_ARGS); - #endif /* ARRAY_H */ diff --git a/src/include/utils/arrayaccess.h b/src/include/utils/arrayaccess.h index 3ff49f12bc..6148bdf834 100644 --- a/src/include/utils/arrayaccess.h +++ b/src/include/utils/arrayaccess.h @@ -4,7 +4,7 @@ * Declarations for element-by-element access to Postgres arrays. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/arrayaccess.h diff --git a/src/include/utils/ascii.h b/src/include/utils/ascii.h index 1006d0d63e..3771e1acab 100644 --- a/src/include/utils/ascii.h +++ b/src/include/utils/ascii.h @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------- * ascii.h * - * Portions Copyright (c) 1999-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1999-2017, PostgreSQL Global Development Group * * src/include/utils/ascii.h * @@ -11,12 +11,6 @@ #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); - extern void ascii_safe_strlcpy(char *dest, const char *src, size_t destsiz); #endif /* _ASCII_H_ */ diff --git a/src/include/utils/attoptcache.h b/src/include/utils/attoptcache.h index cf8ead006d..7f2334b4cd 100644 --- a/src/include/utils/attoptcache.h +++ b/src/include/utils/attoptcache.h @@ -3,7 +3,7 @@ * attoptcache.h * Attribute options cache. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/attoptcache.h diff --git a/src/include/utils/backend_random.h b/src/include/utils/backend_random.h new file mode 100644 index 0000000000..31602f250d --- /dev/null +++ b/src/include/utils/backend_random.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * backend_random.h + * Declarations for backend random number generation + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * + * src/include/utils/backend_random.h + * + *------------------------------------------------------------------------- + */ +#ifndef BACKEND_RANDOM_H +#define BACKEND_RANDOM_H + +extern Size BackendRandomShmemSize(void); +extern void BackendRandomShmemInit(void); +extern bool pg_backend_random(char *dst, int len); + +#endif /* BACKEND_RANDOM_H */ diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index fa7b940659..ea93c922f1 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -5,7 +5,7 @@ * * * Portions Copyright (c) 2012-2014, TransLattice, Inc. - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/builtins.h @@ -16,283 +16,34 @@ #define BUILTINS_H #include "fmgr.h" -#include "lib/stringinfo.h" #include "nodes/parsenodes.h" #ifdef PGXC #include "lib/stringinfo.h" #endif -#include "utils/sortsupport.h" -/* - * Defined in adt/ - */ - -/* acl.c */ -extern Datum has_any_column_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_any_column_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_any_column_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_any_column_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_any_column_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_any_column_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_name_name_name(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_name_name_attnum(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_name_id_name(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_name_id_attnum(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_id_name_name(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_id_name_attnum(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_id_id_name(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_id_id_attnum(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_name_attnum(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_column_privilege_id_attnum(PG_FUNCTION_ARGS); -extern Datum has_table_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_table_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_table_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_table_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_table_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_table_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_sequence_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_sequence_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_sequence_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_sequence_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_sequence_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_sequence_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_database_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_database_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_database_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_database_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_database_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_database_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_foreign_data_wrapper_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_foreign_data_wrapper_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_foreign_data_wrapper_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_foreign_data_wrapper_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_foreign_data_wrapper_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_foreign_data_wrapper_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_function_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_function_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_function_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_function_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_function_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_function_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_language_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_language_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_language_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_language_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_language_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_language_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_schema_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_schema_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_schema_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_schema_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_schema_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_schema_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_server_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_server_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_server_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_server_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_server_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_server_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_tablespace_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_tablespace_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_tablespace_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_tablespace_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_tablespace_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_tablespace_privilege_id(PG_FUNCTION_ARGS); -extern Datum has_type_privilege_name_name(PG_FUNCTION_ARGS); -extern Datum has_type_privilege_name_id(PG_FUNCTION_ARGS); -extern Datum has_type_privilege_id_name(PG_FUNCTION_ARGS); -extern Datum has_type_privilege_id_id(PG_FUNCTION_ARGS); -extern Datum has_type_privilege_name(PG_FUNCTION_ARGS); -extern Datum has_type_privilege_id(PG_FUNCTION_ARGS); -extern Datum pg_has_role_name_name(PG_FUNCTION_ARGS); -extern Datum pg_has_role_name_id(PG_FUNCTION_ARGS); -extern Datum pg_has_role_id_name(PG_FUNCTION_ARGS); -extern Datum pg_has_role_id_id(PG_FUNCTION_ARGS); -extern Datum pg_has_role_name(PG_FUNCTION_ARGS); -extern Datum pg_has_role_id(PG_FUNCTION_ARGS); - -/* amutils.c */ -extern Datum pg_indexam_has_property(PG_FUNCTION_ARGS); -extern Datum pg_index_has_property(PG_FUNCTION_ARGS); -extern Datum pg_index_column_has_property(PG_FUNCTION_ARGS); +#include "nodes/nodes.h" +#include "utils/fmgrprotos.h" /* bool.c */ -extern Datum boolin(PG_FUNCTION_ARGS); -extern Datum boolout(PG_FUNCTION_ARGS); -extern Datum boolrecv(PG_FUNCTION_ARGS); -extern Datum boolsend(PG_FUNCTION_ARGS); -extern Datum booltext(PG_FUNCTION_ARGS); -extern Datum booleq(PG_FUNCTION_ARGS); -extern Datum boolne(PG_FUNCTION_ARGS); -extern Datum boollt(PG_FUNCTION_ARGS); -extern Datum boolgt(PG_FUNCTION_ARGS); -extern Datum boolle(PG_FUNCTION_ARGS); -extern Datum boolge(PG_FUNCTION_ARGS); -extern Datum booland_statefunc(PG_FUNCTION_ARGS); -extern Datum boolor_statefunc(PG_FUNCTION_ARGS); -extern Datum bool_accum(PG_FUNCTION_ARGS); -extern Datum bool_accum_inv(PG_FUNCTION_ARGS); -extern Datum bool_alltrue(PG_FUNCTION_ARGS); -extern Datum bool_anytrue(PG_FUNCTION_ARGS); extern bool parse_bool(const char *value, bool *result); extern bool parse_bool_with_len(const char *value, size_t len, bool *result); -/* char.c */ -extern Datum charin(PG_FUNCTION_ARGS); -extern Datum charout(PG_FUNCTION_ARGS); -extern Datum charrecv(PG_FUNCTION_ARGS); -extern Datum charsend(PG_FUNCTION_ARGS); -extern Datum chareq(PG_FUNCTION_ARGS); -extern Datum charne(PG_FUNCTION_ARGS); -extern Datum charlt(PG_FUNCTION_ARGS); -extern Datum charle(PG_FUNCTION_ARGS); -extern Datum chargt(PG_FUNCTION_ARGS); -extern Datum charge(PG_FUNCTION_ARGS); -extern Datum chartoi4(PG_FUNCTION_ARGS); -extern Datum i4tochar(PG_FUNCTION_ARGS); -extern Datum text_char(PG_FUNCTION_ARGS); -extern Datum char_text(PG_FUNCTION_ARGS); - /* domains.c */ -extern Datum domain_in(PG_FUNCTION_ARGS); -extern Datum domain_recv(PG_FUNCTION_ARGS); extern void domain_check(Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt); extern int errdatatype(Oid datatypeOid); extern int errdomainconstraint(Oid datatypeOid, const char *conname); /* encode.c */ -extern Datum binary_encode(PG_FUNCTION_ARGS); -extern Datum binary_decode(PG_FUNCTION_ARGS); extern unsigned hex_encode(const char *src, unsigned len, char *dst); extern unsigned hex_decode(const char *src, unsigned len, char *dst); -/* enum.c */ -extern Datum enum_in(PG_FUNCTION_ARGS); -extern Datum enum_out(PG_FUNCTION_ARGS); -extern Datum enum_recv(PG_FUNCTION_ARGS); -extern Datum enum_send(PG_FUNCTION_ARGS); -extern Datum enum_lt(PG_FUNCTION_ARGS); -extern Datum enum_le(PG_FUNCTION_ARGS); -extern Datum enum_eq(PG_FUNCTION_ARGS); -extern Datum enum_ne(PG_FUNCTION_ARGS); -extern Datum enum_ge(PG_FUNCTION_ARGS); -extern Datum enum_gt(PG_FUNCTION_ARGS); -extern Datum enum_cmp(PG_FUNCTION_ARGS); -extern Datum enum_smaller(PG_FUNCTION_ARGS); -extern Datum enum_larger(PG_FUNCTION_ARGS); -extern Datum enum_first(PG_FUNCTION_ARGS); -extern Datum enum_last(PG_FUNCTION_ARGS); -extern Datum enum_range_bounds(PG_FUNCTION_ARGS); -extern Datum enum_range_all(PG_FUNCTION_ARGS); - /* int.c */ -extern Datum int2in(PG_FUNCTION_ARGS); -extern Datum int2out(PG_FUNCTION_ARGS); -extern Datum int2recv(PG_FUNCTION_ARGS); -extern Datum int2send(PG_FUNCTION_ARGS); -extern Datum int2vectorin(PG_FUNCTION_ARGS); -extern Datum int2vectorout(PG_FUNCTION_ARGS); -extern Datum int2vectorrecv(PG_FUNCTION_ARGS); -extern Datum int2vectorsend(PG_FUNCTION_ARGS); -extern Datum int2vectoreq(PG_FUNCTION_ARGS); -extern Datum int4in(PG_FUNCTION_ARGS); -extern Datum int4out(PG_FUNCTION_ARGS); -extern Datum int4recv(PG_FUNCTION_ARGS); -extern Datum int4send(PG_FUNCTION_ARGS); -extern Datum i2toi4(PG_FUNCTION_ARGS); -extern Datum i4toi2(PG_FUNCTION_ARGS); -extern Datum int4_bool(PG_FUNCTION_ARGS); -extern Datum bool_int4(PG_FUNCTION_ARGS); -extern Datum int4eq(PG_FUNCTION_ARGS); -extern Datum int4ne(PG_FUNCTION_ARGS); -extern Datum int4lt(PG_FUNCTION_ARGS); -extern Datum int4le(PG_FUNCTION_ARGS); -extern Datum int4gt(PG_FUNCTION_ARGS); -extern Datum int4ge(PG_FUNCTION_ARGS); -extern Datum int2eq(PG_FUNCTION_ARGS); -extern Datum int2ne(PG_FUNCTION_ARGS); -extern Datum int2lt(PG_FUNCTION_ARGS); -extern Datum int2le(PG_FUNCTION_ARGS); -extern Datum int2gt(PG_FUNCTION_ARGS); -extern Datum int2ge(PG_FUNCTION_ARGS); -extern Datum int24eq(PG_FUNCTION_ARGS); -extern Datum int24ne(PG_FUNCTION_ARGS); -extern Datum int24lt(PG_FUNCTION_ARGS); -extern Datum int24le(PG_FUNCTION_ARGS); -extern Datum int24gt(PG_FUNCTION_ARGS); -extern Datum int24ge(PG_FUNCTION_ARGS); -extern Datum int42eq(PG_FUNCTION_ARGS); -extern Datum int42ne(PG_FUNCTION_ARGS); -extern Datum int42lt(PG_FUNCTION_ARGS); -extern Datum int42le(PG_FUNCTION_ARGS); -extern Datum int42gt(PG_FUNCTION_ARGS); -extern Datum int42ge(PG_FUNCTION_ARGS); -extern Datum int4um(PG_FUNCTION_ARGS); -extern Datum int4up(PG_FUNCTION_ARGS); -extern Datum int4pl(PG_FUNCTION_ARGS); -extern Datum int4mi(PG_FUNCTION_ARGS); -extern Datum int4mul(PG_FUNCTION_ARGS); -extern Datum int4div(PG_FUNCTION_ARGS); -extern Datum int4abs(PG_FUNCTION_ARGS); -extern Datum int4inc(PG_FUNCTION_ARGS); -extern Datum int2um(PG_FUNCTION_ARGS); -extern Datum int2up(PG_FUNCTION_ARGS); -extern Datum int2pl(PG_FUNCTION_ARGS); -extern Datum int2mi(PG_FUNCTION_ARGS); -extern Datum int2mul(PG_FUNCTION_ARGS); -extern Datum int2div(PG_FUNCTION_ARGS); -extern Datum int2abs(PG_FUNCTION_ARGS); -extern Datum int24pl(PG_FUNCTION_ARGS); -extern Datum int24mi(PG_FUNCTION_ARGS); -extern Datum int24mul(PG_FUNCTION_ARGS); -extern Datum int24div(PG_FUNCTION_ARGS); -extern Datum int42pl(PG_FUNCTION_ARGS); -extern Datum int42mi(PG_FUNCTION_ARGS); -extern Datum int42mul(PG_FUNCTION_ARGS); -extern Datum int42div(PG_FUNCTION_ARGS); -extern Datum int4mod(PG_FUNCTION_ARGS); -extern Datum int2mod(PG_FUNCTION_ARGS); -extern Datum int2larger(PG_FUNCTION_ARGS); -extern Datum int2smaller(PG_FUNCTION_ARGS); -extern Datum int4larger(PG_FUNCTION_ARGS); -extern Datum int4smaller(PG_FUNCTION_ARGS); - -extern Datum int4and(PG_FUNCTION_ARGS); -extern Datum int4or(PG_FUNCTION_ARGS); -extern Datum int4xor(PG_FUNCTION_ARGS); -extern Datum int4not(PG_FUNCTION_ARGS); -extern Datum int4shl(PG_FUNCTION_ARGS); -extern Datum int4shr(PG_FUNCTION_ARGS); -extern Datum int2and(PG_FUNCTION_ARGS); -extern Datum int2or(PG_FUNCTION_ARGS); -extern Datum int2xor(PG_FUNCTION_ARGS); -extern Datum int2not(PG_FUNCTION_ARGS); -extern Datum int2shl(PG_FUNCTION_ARGS); -extern Datum int2shr(PG_FUNCTION_ARGS); -extern Datum generate_series_int4(PG_FUNCTION_ARGS); -extern Datum generate_series_step_int4(PG_FUNCTION_ARGS); extern int2vector *buildint2vector(const int16 *int2s, int n); /* name.c */ -extern Datum namein(PG_FUNCTION_ARGS); -extern Datum nameout(PG_FUNCTION_ARGS); -extern Datum namerecv(PG_FUNCTION_ARGS); -extern Datum namesend(PG_FUNCTION_ARGS); -extern Datum nameeq(PG_FUNCTION_ARGS); -extern Datum namene(PG_FUNCTION_ARGS); -extern Datum namelt(PG_FUNCTION_ARGS); -extern Datum namele(PG_FUNCTION_ARGS); -extern Datum namegt(PG_FUNCTION_ARGS); -extern Datum namege(PG_FUNCTION_ARGS); extern int namecpy(Name n1, Name n2); extern int namestrcpy(Name name, const char *str); extern int namestrcmp(Name name, const char *str); -extern Datum current_user(PG_FUNCTION_ARGS); -extern Datum session_user(PG_FUNCTION_ARGS); -extern Datum current_schema(PG_FUNCTION_ARGS); -extern Datum current_schemas(PG_FUNCTION_ARGS); /* numutils.c */ extern int32 pg_atoi(const char *s, int size, int c); @@ -303,47 +54,6 @@ extern char *pg_ltostr_zeropad(char *str, int32 value, int32 minwidth); extern char *pg_ltostr(char *str, int32 value); extern uint64 pg_strtouint64(const char *str, char **endptr, int base); -/* - * Per-opclass comparison functions for new btrees. These are - * stored in pg_amproc; most are defined in access/nbtree/nbtcompare.c - */ -extern Datum btboolcmp(PG_FUNCTION_ARGS); -extern Datum btint2cmp(PG_FUNCTION_ARGS); -extern Datum btint4cmp(PG_FUNCTION_ARGS); -extern Datum btint8cmp(PG_FUNCTION_ARGS); -extern Datum btfloat4cmp(PG_FUNCTION_ARGS); -extern Datum btfloat8cmp(PG_FUNCTION_ARGS); -extern Datum btint48cmp(PG_FUNCTION_ARGS); -extern Datum btint84cmp(PG_FUNCTION_ARGS); -extern Datum btint24cmp(PG_FUNCTION_ARGS); -extern Datum btint42cmp(PG_FUNCTION_ARGS); -extern Datum btint28cmp(PG_FUNCTION_ARGS); -extern Datum btint82cmp(PG_FUNCTION_ARGS); -extern Datum btfloat48cmp(PG_FUNCTION_ARGS); -extern Datum btfloat84cmp(PG_FUNCTION_ARGS); -extern Datum btoidcmp(PG_FUNCTION_ARGS); -extern Datum btoidvectorcmp(PG_FUNCTION_ARGS); -extern Datum btabstimecmp(PG_FUNCTION_ARGS); -extern Datum btreltimecmp(PG_FUNCTION_ARGS); -extern Datum bttintervalcmp(PG_FUNCTION_ARGS); -extern Datum btcharcmp(PG_FUNCTION_ARGS); -extern Datum btnamecmp(PG_FUNCTION_ARGS); -extern Datum bttextcmp(PG_FUNCTION_ARGS); -extern Datum bttextsortsupport(PG_FUNCTION_ARGS); - -/* - * Per-opclass sort support functions for new btrees. Like the - * functions above, these are stored in pg_amproc; most are defined in - * access/nbtree/nbtcompare.c - */ -extern Datum btint2sortsupport(PG_FUNCTION_ARGS); -extern Datum btint4sortsupport(PG_FUNCTION_ARGS); -extern Datum btint8sortsupport(PG_FUNCTION_ARGS); -extern Datum btfloat4sortsupport(PG_FUNCTION_ARGS); -extern Datum btfloat8sortsupport(PG_FUNCTION_ARGS); -extern Datum btoidsortsupport(PG_FUNCTION_ARGS); -extern Datum btnamesortsupport(PG_FUNCTION_ARGS); - /* float.c */ extern PGDLLIMPORT int extra_float_digits; @@ -358,397 +68,21 @@ extern char *float8out_internal(double num); extern int float4_cmp_internal(float4 a, float4 b); extern int float8_cmp_internal(float8 a, float8 b); -extern Datum float4in(PG_FUNCTION_ARGS); -extern Datum float4out(PG_FUNCTION_ARGS); -extern Datum float4recv(PG_FUNCTION_ARGS); -extern Datum float4send(PG_FUNCTION_ARGS); -extern Datum float8in(PG_FUNCTION_ARGS); -extern Datum float8out(PG_FUNCTION_ARGS); -extern Datum float8recv(PG_FUNCTION_ARGS); -extern Datum float8send(PG_FUNCTION_ARGS); -extern Datum float4abs(PG_FUNCTION_ARGS); -extern Datum float4um(PG_FUNCTION_ARGS); -extern Datum float4up(PG_FUNCTION_ARGS); -extern Datum float4larger(PG_FUNCTION_ARGS); -extern Datum float4smaller(PG_FUNCTION_ARGS); -extern Datum float8abs(PG_FUNCTION_ARGS); -extern Datum float8um(PG_FUNCTION_ARGS); -extern Datum float8up(PG_FUNCTION_ARGS); -extern Datum float8larger(PG_FUNCTION_ARGS); -extern Datum float8smaller(PG_FUNCTION_ARGS); -extern Datum float4pl(PG_FUNCTION_ARGS); -extern Datum float4mi(PG_FUNCTION_ARGS); -extern Datum float4mul(PG_FUNCTION_ARGS); -extern Datum float4div(PG_FUNCTION_ARGS); -extern Datum float8pl(PG_FUNCTION_ARGS); -extern Datum float8mi(PG_FUNCTION_ARGS); -extern Datum float8mul(PG_FUNCTION_ARGS); -extern Datum float8div(PG_FUNCTION_ARGS); -extern Datum float4eq(PG_FUNCTION_ARGS); -extern Datum float4ne(PG_FUNCTION_ARGS); -extern Datum float4lt(PG_FUNCTION_ARGS); -extern Datum float4le(PG_FUNCTION_ARGS); -extern Datum float4gt(PG_FUNCTION_ARGS); -extern Datum float4ge(PG_FUNCTION_ARGS); -extern Datum float8eq(PG_FUNCTION_ARGS); -extern Datum float8ne(PG_FUNCTION_ARGS); -extern Datum float8lt(PG_FUNCTION_ARGS); -extern Datum float8le(PG_FUNCTION_ARGS); -extern Datum float8gt(PG_FUNCTION_ARGS); -extern Datum float8ge(PG_FUNCTION_ARGS); -extern Datum ftod(PG_FUNCTION_ARGS); -extern Datum i4tod(PG_FUNCTION_ARGS); -extern Datum i2tod(PG_FUNCTION_ARGS); -extern Datum dtof(PG_FUNCTION_ARGS); -extern Datum dtoi4(PG_FUNCTION_ARGS); -extern Datum dtoi2(PG_FUNCTION_ARGS); -extern Datum i4tof(PG_FUNCTION_ARGS); -extern Datum i2tof(PG_FUNCTION_ARGS); -extern Datum ftoi4(PG_FUNCTION_ARGS); -extern Datum ftoi2(PG_FUNCTION_ARGS); -extern Datum dround(PG_FUNCTION_ARGS); -extern Datum dceil(PG_FUNCTION_ARGS); -extern Datum dfloor(PG_FUNCTION_ARGS); -extern Datum dsign(PG_FUNCTION_ARGS); -extern Datum dtrunc(PG_FUNCTION_ARGS); -extern Datum dsqrt(PG_FUNCTION_ARGS); -extern Datum dcbrt(PG_FUNCTION_ARGS); -extern Datum dpow(PG_FUNCTION_ARGS); -extern Datum dexp(PG_FUNCTION_ARGS); -extern Datum dlog1(PG_FUNCTION_ARGS); -extern Datum dlog10(PG_FUNCTION_ARGS); -extern Datum dacos(PG_FUNCTION_ARGS); -extern Datum dasin(PG_FUNCTION_ARGS); -extern Datum datan(PG_FUNCTION_ARGS); -extern Datum datan2(PG_FUNCTION_ARGS); -extern Datum dcos(PG_FUNCTION_ARGS); -extern Datum dcot(PG_FUNCTION_ARGS); -extern Datum dsin(PG_FUNCTION_ARGS); -extern Datum dtan(PG_FUNCTION_ARGS); -extern Datum dacosd(PG_FUNCTION_ARGS); -extern Datum dasind(PG_FUNCTION_ARGS); -extern Datum datand(PG_FUNCTION_ARGS); -extern Datum datan2d(PG_FUNCTION_ARGS); -extern Datum dcosd(PG_FUNCTION_ARGS); -extern Datum dcotd(PG_FUNCTION_ARGS); -extern Datum dsind(PG_FUNCTION_ARGS); -extern Datum dtand(PG_FUNCTION_ARGS); -extern Datum degrees(PG_FUNCTION_ARGS); -extern Datum dpi(PG_FUNCTION_ARGS); -extern Datum radians(PG_FUNCTION_ARGS); -extern Datum drandom(PG_FUNCTION_ARGS); -extern Datum setseed(PG_FUNCTION_ARGS); -extern Datum float8_combine(PG_FUNCTION_ARGS); -extern Datum float8_accum(PG_FUNCTION_ARGS); -extern Datum float4_accum(PG_FUNCTION_ARGS); -extern Datum float8_avg(PG_FUNCTION_ARGS); -extern Datum float8_var_pop(PG_FUNCTION_ARGS); -extern Datum float8_var_samp(PG_FUNCTION_ARGS); -extern Datum float8_stddev_pop(PG_FUNCTION_ARGS); -extern Datum float8_stddev_samp(PG_FUNCTION_ARGS); -extern Datum float8_regr_accum(PG_FUNCTION_ARGS); -extern Datum float8_regr_combine(PG_FUNCTION_ARGS); -extern Datum float8_regr_sxx(PG_FUNCTION_ARGS); -extern Datum float8_regr_syy(PG_FUNCTION_ARGS); -extern Datum float8_regr_sxy(PG_FUNCTION_ARGS); -extern Datum float8_regr_avgx(PG_FUNCTION_ARGS); -extern Datum float8_regr_avgy(PG_FUNCTION_ARGS); -extern Datum float8_covar_pop(PG_FUNCTION_ARGS); -extern Datum float8_covar_samp(PG_FUNCTION_ARGS); -extern Datum float8_corr(PG_FUNCTION_ARGS); -extern Datum float8_regr_r2(PG_FUNCTION_ARGS); -extern Datum float8_regr_slope(PG_FUNCTION_ARGS); -extern Datum float8_regr_intercept(PG_FUNCTION_ARGS); -extern Datum float48pl(PG_FUNCTION_ARGS); -extern Datum float48mi(PG_FUNCTION_ARGS); -extern Datum float48mul(PG_FUNCTION_ARGS); -extern Datum float48div(PG_FUNCTION_ARGS); -extern Datum float84pl(PG_FUNCTION_ARGS); -extern Datum float84mi(PG_FUNCTION_ARGS); -extern Datum float84mul(PG_FUNCTION_ARGS); -extern Datum float84div(PG_FUNCTION_ARGS); -extern Datum float48eq(PG_FUNCTION_ARGS); -extern Datum float48ne(PG_FUNCTION_ARGS); -extern Datum float48lt(PG_FUNCTION_ARGS); -extern Datum float48le(PG_FUNCTION_ARGS); -extern Datum float48gt(PG_FUNCTION_ARGS); -extern Datum float48ge(PG_FUNCTION_ARGS); -extern Datum float84eq(PG_FUNCTION_ARGS); -extern Datum float84ne(PG_FUNCTION_ARGS); -extern Datum float84lt(PG_FUNCTION_ARGS); -extern Datum float84le(PG_FUNCTION_ARGS); -extern Datum float84gt(PG_FUNCTION_ARGS); -extern Datum float84ge(PG_FUNCTION_ARGS); -extern Datum width_bucket_float8(PG_FUNCTION_ARGS); - -/* dbsize.c */ -extern Datum pg_tablespace_size_oid(PG_FUNCTION_ARGS); -extern Datum pg_tablespace_size_name(PG_FUNCTION_ARGS); -extern Datum pg_database_size_oid(PG_FUNCTION_ARGS); -extern Datum pg_database_size_name(PG_FUNCTION_ARGS); -extern Datum pg_relation_size(PG_FUNCTION_ARGS); -extern Datum pg_total_relation_size(PG_FUNCTION_ARGS); -extern Datum pg_size_pretty(PG_FUNCTION_ARGS); -extern Datum pg_size_pretty_numeric(PG_FUNCTION_ARGS); -extern Datum pg_size_bytes(PG_FUNCTION_ARGS); -extern Datum pg_table_size(PG_FUNCTION_ARGS); -extern Datum pg_indexes_size(PG_FUNCTION_ARGS); -extern Datum pg_relation_filenode(PG_FUNCTION_ARGS); -extern Datum pg_filenode_relation(PG_FUNCTION_ARGS); -extern Datum pg_relation_filepath(PG_FUNCTION_ARGS); - -/* genfile.c */ -extern Datum pg_stat_file(PG_FUNCTION_ARGS); -extern Datum pg_stat_file_1arg(PG_FUNCTION_ARGS); -extern Datum pg_read_file(PG_FUNCTION_ARGS); -extern Datum pg_read_file_off_len(PG_FUNCTION_ARGS); -extern Datum pg_read_file_all(PG_FUNCTION_ARGS); -extern Datum pg_read_binary_file(PG_FUNCTION_ARGS); -extern Datum pg_read_binary_file_off_len(PG_FUNCTION_ARGS); -extern Datum pg_read_binary_file_all(PG_FUNCTION_ARGS); -extern Datum pg_ls_dir(PG_FUNCTION_ARGS); -extern Datum pg_ls_dir_1arg(PG_FUNCTION_ARGS); - -/* misc.c */ -extern Datum pg_num_nulls(PG_FUNCTION_ARGS); -extern Datum pg_num_nonnulls(PG_FUNCTION_ARGS); -extern Datum current_database(PG_FUNCTION_ARGS); -extern Datum current_query(PG_FUNCTION_ARGS); -extern Datum pg_cancel_backend(PG_FUNCTION_ARGS); -extern Datum pg_terminate_backend(PG_FUNCTION_ARGS); -extern Datum pg_reload_conf(PG_FUNCTION_ARGS); -extern Datum pg_tablespace_databases(PG_FUNCTION_ARGS); -extern Datum pg_tablespace_location(PG_FUNCTION_ARGS); -extern Datum pg_rotate_logfile(PG_FUNCTION_ARGS); -extern Datum pg_sleep(PG_FUNCTION_ARGS); -extern Datum pg_get_keywords(PG_FUNCTION_ARGS); -extern Datum pg_typeof(PG_FUNCTION_ARGS); -extern Datum pg_collation_for(PG_FUNCTION_ARGS); -extern Datum pg_relation_is_updatable(PG_FUNCTION_ARGS); -extern Datum pg_column_is_updatable(PG_FUNCTION_ARGS); -extern Datum parse_ident(PG_FUNCTION_ARGS); - /* oid.c */ -extern Datum oidin(PG_FUNCTION_ARGS); -extern Datum oidout(PG_FUNCTION_ARGS); -extern Datum oidrecv(PG_FUNCTION_ARGS); -extern Datum oidsend(PG_FUNCTION_ARGS); -extern Datum oideq(PG_FUNCTION_ARGS); -extern Datum oidne(PG_FUNCTION_ARGS); -extern Datum oidlt(PG_FUNCTION_ARGS); -extern Datum oidle(PG_FUNCTION_ARGS); -extern Datum oidge(PG_FUNCTION_ARGS); -extern Datum oidgt(PG_FUNCTION_ARGS); -extern Datum oidlarger(PG_FUNCTION_ARGS); -extern Datum oidsmaller(PG_FUNCTION_ARGS); -extern Datum oidvectorin(PG_FUNCTION_ARGS); -extern Datum oidvectorout(PG_FUNCTION_ARGS); -extern Datum oidvectorrecv(PG_FUNCTION_ARGS); -extern Datum oidvectorsend(PG_FUNCTION_ARGS); -extern Datum oidvectoreq(PG_FUNCTION_ARGS); -extern Datum oidvectorne(PG_FUNCTION_ARGS); -extern Datum oidvectorlt(PG_FUNCTION_ARGS); -extern Datum oidvectorle(PG_FUNCTION_ARGS); -extern Datum oidvectorge(PG_FUNCTION_ARGS); -extern Datum oidvectorgt(PG_FUNCTION_ARGS); extern oidvector *buildoidvector(const Oid *oids, int n); extern Oid oidparse(Node *node); - -/* orderedsetaggs.c */ -extern Datum ordered_set_transition(PG_FUNCTION_ARGS); -extern Datum ordered_set_transition_multi(PG_FUNCTION_ARGS); -extern Datum percentile_disc_final(PG_FUNCTION_ARGS); -extern Datum percentile_cont_float8_final(PG_FUNCTION_ARGS); -extern Datum percentile_cont_interval_final(PG_FUNCTION_ARGS); -extern Datum percentile_disc_multi_final(PG_FUNCTION_ARGS); -extern Datum percentile_cont_float8_multi_final(PG_FUNCTION_ARGS); -extern Datum percentile_cont_interval_multi_final(PG_FUNCTION_ARGS); -extern Datum mode_final(PG_FUNCTION_ARGS); -extern Datum hypothetical_rank_final(PG_FUNCTION_ARGS); -extern Datum hypothetical_percent_rank_final(PG_FUNCTION_ARGS); -extern Datum hypothetical_cume_dist_final(PG_FUNCTION_ARGS); -extern Datum hypothetical_dense_rank_final(PG_FUNCTION_ARGS); - -/* pseudotypes.c */ -extern Datum cstring_in(PG_FUNCTION_ARGS); -extern Datum cstring_out(PG_FUNCTION_ARGS); -extern Datum cstring_recv(PG_FUNCTION_ARGS); -extern Datum cstring_send(PG_FUNCTION_ARGS); -extern Datum any_in(PG_FUNCTION_ARGS); -extern Datum any_out(PG_FUNCTION_ARGS); -extern Datum anyarray_in(PG_FUNCTION_ARGS); -extern Datum anyarray_out(PG_FUNCTION_ARGS); -extern Datum anyarray_recv(PG_FUNCTION_ARGS); -extern Datum anyarray_send(PG_FUNCTION_ARGS); -extern Datum anynonarray_in(PG_FUNCTION_ARGS); -extern Datum anynonarray_out(PG_FUNCTION_ARGS); -extern Datum anyenum_in(PG_FUNCTION_ARGS); -extern Datum anyenum_out(PG_FUNCTION_ARGS); -extern Datum anyrange_in(PG_FUNCTION_ARGS); -extern Datum anyrange_out(PG_FUNCTION_ARGS); -extern Datum void_in(PG_FUNCTION_ARGS); -extern Datum void_out(PG_FUNCTION_ARGS); -extern Datum void_recv(PG_FUNCTION_ARGS); -extern Datum void_send(PG_FUNCTION_ARGS); #ifdef PGXC extern Datum pgxc_node_str (PG_FUNCTION_ARGS); extern Datum pgxc_lock_for_backup (PG_FUNCTION_ARGS); #endif -extern Datum trigger_in(PG_FUNCTION_ARGS); -extern Datum trigger_out(PG_FUNCTION_ARGS); -extern Datum event_trigger_in(PG_FUNCTION_ARGS); -extern Datum event_trigger_out(PG_FUNCTION_ARGS); -extern Datum language_handler_in(PG_FUNCTION_ARGS); -extern Datum language_handler_out(PG_FUNCTION_ARGS); -extern Datum fdw_handler_in(PG_FUNCTION_ARGS); -extern Datum fdw_handler_out(PG_FUNCTION_ARGS); -extern Datum index_am_handler_in(PG_FUNCTION_ARGS); -extern Datum index_am_handler_out(PG_FUNCTION_ARGS); -extern Datum tsm_handler_in(PG_FUNCTION_ARGS); -extern Datum tsm_handler_out(PG_FUNCTION_ARGS); -extern Datum internal_in(PG_FUNCTION_ARGS); -extern Datum internal_out(PG_FUNCTION_ARGS); -extern Datum opaque_in(PG_FUNCTION_ARGS); -extern Datum opaque_out(PG_FUNCTION_ARGS); -extern Datum anyelement_in(PG_FUNCTION_ARGS); -extern Datum anyelement_out(PG_FUNCTION_ARGS); -extern Datum shell_in(PG_FUNCTION_ARGS); -extern Datum shell_out(PG_FUNCTION_ARGS); -extern Datum pg_node_tree_in(PG_FUNCTION_ARGS); -extern Datum pg_node_tree_out(PG_FUNCTION_ARGS); -extern Datum pg_node_tree_recv(PG_FUNCTION_ARGS); -extern Datum pg_node_tree_send(PG_FUNCTION_ARGS); -extern Datum pg_ddl_command_in(PG_FUNCTION_ARGS); -extern Datum pg_ddl_command_out(PG_FUNCTION_ARGS); -extern Datum pg_ddl_command_recv(PG_FUNCTION_ARGS); -extern Datum pg_ddl_command_send(PG_FUNCTION_ARGS); +extern int oid_cmp(const void *p1, const void *p2); /* regexp.c */ -extern Datum nameregexeq(PG_FUNCTION_ARGS); -extern Datum nameregexne(PG_FUNCTION_ARGS); -extern Datum textregexeq(PG_FUNCTION_ARGS); -extern Datum textregexne(PG_FUNCTION_ARGS); -extern Datum nameicregexeq(PG_FUNCTION_ARGS); -extern Datum nameicregexne(PG_FUNCTION_ARGS); -extern Datum texticregexeq(PG_FUNCTION_ARGS); -extern Datum texticregexne(PG_FUNCTION_ARGS); -extern Datum textregexsubstr(PG_FUNCTION_ARGS); -extern Datum textregexreplace_noopt(PG_FUNCTION_ARGS); -extern Datum textregexreplace(PG_FUNCTION_ARGS); -extern Datum similar_escape(PG_FUNCTION_ARGS); -extern Datum regexp_matches(PG_FUNCTION_ARGS); -extern Datum regexp_matches_no_flags(PG_FUNCTION_ARGS); -extern Datum regexp_split_to_table(PG_FUNCTION_ARGS); -extern Datum regexp_split_to_table_no_flags(PG_FUNCTION_ARGS); -extern Datum regexp_split_to_array(PG_FUNCTION_ARGS); -extern Datum regexp_split_to_array_no_flags(PG_FUNCTION_ARGS); extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive, Oid collation, bool *exact); -/* regproc.c */ -extern Datum regprocin(PG_FUNCTION_ARGS); -extern Datum regprocout(PG_FUNCTION_ARGS); -extern Datum to_regproc(PG_FUNCTION_ARGS); -extern Datum to_regprocedure(PG_FUNCTION_ARGS); -extern Datum regprocrecv(PG_FUNCTION_ARGS); -extern Datum regprocsend(PG_FUNCTION_ARGS); -extern Datum regprocedurein(PG_FUNCTION_ARGS); -extern Datum regprocedureout(PG_FUNCTION_ARGS); -extern Datum regprocedurerecv(PG_FUNCTION_ARGS); -extern Datum regproceduresend(PG_FUNCTION_ARGS); -extern Datum regoperin(PG_FUNCTION_ARGS); -extern Datum regoperout(PG_FUNCTION_ARGS); -extern Datum regoperrecv(PG_FUNCTION_ARGS); -extern Datum regopersend(PG_FUNCTION_ARGS); -extern Datum to_regoper(PG_FUNCTION_ARGS); -extern Datum to_regoperator(PG_FUNCTION_ARGS); -extern Datum regoperatorin(PG_FUNCTION_ARGS); -extern Datum regoperatorout(PG_FUNCTION_ARGS); -extern Datum regoperatorrecv(PG_FUNCTION_ARGS); -extern Datum regoperatorsend(PG_FUNCTION_ARGS); -extern Datum regclassin(PG_FUNCTION_ARGS); -extern Datum regclassout(PG_FUNCTION_ARGS); -extern Datum regclassrecv(PG_FUNCTION_ARGS); -extern Datum regclasssend(PG_FUNCTION_ARGS); -extern Datum to_regclass(PG_FUNCTION_ARGS); -extern Datum regtypein(PG_FUNCTION_ARGS); -extern Datum regtypeout(PG_FUNCTION_ARGS); -extern Datum regtyperecv(PG_FUNCTION_ARGS); -extern Datum regtypesend(PG_FUNCTION_ARGS); -extern Datum to_regtype(PG_FUNCTION_ARGS); -extern Datum regrolein(PG_FUNCTION_ARGS); -extern Datum regroleout(PG_FUNCTION_ARGS); -extern Datum regrolerecv(PG_FUNCTION_ARGS); -extern Datum regrolesend(PG_FUNCTION_ARGS); -extern Datum to_regrole(PG_FUNCTION_ARGS); -extern Datum regnamespacein(PG_FUNCTION_ARGS); -extern Datum regnamespaceout(PG_FUNCTION_ARGS); -extern Datum regnamespacerecv(PG_FUNCTION_ARGS); -extern Datum regnamespacesend(PG_FUNCTION_ARGS); -extern Datum to_regnamespace(PG_FUNCTION_ARGS); -extern Datum regconfigin(PG_FUNCTION_ARGS); -extern Datum regconfigout(PG_FUNCTION_ARGS); -extern Datum regconfigrecv(PG_FUNCTION_ARGS); -extern Datum regconfigsend(PG_FUNCTION_ARGS); -extern Datum regdictionaryin(PG_FUNCTION_ARGS); -extern Datum regdictionaryout(PG_FUNCTION_ARGS); -extern Datum regdictionaryrecv(PG_FUNCTION_ARGS); -extern Datum regdictionarysend(PG_FUNCTION_ARGS); -extern Datum text_regclass(PG_FUNCTION_ARGS); -extern List *stringToQualifiedNameList(const char *string); -extern char *format_procedure(Oid procedure_oid); -extern char *format_procedure_qualified(Oid procedure_oid); -extern void format_procedure_parts(Oid operator_oid, List **objnames, - List **objargs); -extern char *format_operator(Oid operator_oid); -extern char *format_operator_qualified(Oid operator_oid); -extern void format_operator_parts(Oid operator_oid, List **objnames, - List **objargs); - -/* rowtypes.c */ -extern Datum record_in(PG_FUNCTION_ARGS); -extern Datum record_out(PG_FUNCTION_ARGS); -extern Datum record_recv(PG_FUNCTION_ARGS); -extern Datum record_send(PG_FUNCTION_ARGS); -extern Datum record_eq(PG_FUNCTION_ARGS); -extern Datum record_ne(PG_FUNCTION_ARGS); -extern Datum record_lt(PG_FUNCTION_ARGS); -extern Datum record_gt(PG_FUNCTION_ARGS); -extern Datum record_le(PG_FUNCTION_ARGS); -extern Datum record_ge(PG_FUNCTION_ARGS); -extern Datum btrecordcmp(PG_FUNCTION_ARGS); -extern Datum record_image_eq(PG_FUNCTION_ARGS); -extern Datum record_image_ne(PG_FUNCTION_ARGS); -extern Datum record_image_lt(PG_FUNCTION_ARGS); -extern Datum record_image_gt(PG_FUNCTION_ARGS); -extern Datum record_image_le(PG_FUNCTION_ARGS); -extern Datum record_image_ge(PG_FUNCTION_ARGS); -extern Datum btrecordimagecmp(PG_FUNCTION_ARGS); - /* ruleutils.c */ extern bool quote_all_identifiers; -extern Datum pg_get_ruledef(PG_FUNCTION_ARGS); -extern Datum pg_get_ruledef_ext(PG_FUNCTION_ARGS); -extern Datum pg_get_viewdef(PG_FUNCTION_ARGS); -extern Datum pg_get_viewdef_ext(PG_FUNCTION_ARGS); -extern Datum pg_get_viewdef_wrap(PG_FUNCTION_ARGS); -extern Datum pg_get_viewdef_name(PG_FUNCTION_ARGS); -extern Datum pg_get_viewdef_name_ext(PG_FUNCTION_ARGS); -extern Datum pg_get_indexdef(PG_FUNCTION_ARGS); -extern Datum pg_get_indexdef_ext(PG_FUNCTION_ARGS); -extern Datum pg_get_triggerdef(PG_FUNCTION_ARGS); -extern Datum pg_get_triggerdef_ext(PG_FUNCTION_ARGS); -extern Datum pg_get_constraintdef(PG_FUNCTION_ARGS); -extern Datum pg_get_constraintdef_ext(PG_FUNCTION_ARGS); -extern Datum pg_get_expr(PG_FUNCTION_ARGS); -extern Datum pg_get_expr_ext(PG_FUNCTION_ARGS); -extern Datum pg_get_userbyid(PG_FUNCTION_ARGS); -extern Datum pg_get_serial_sequence(PG_FUNCTION_ARGS); -extern Datum pg_get_functiondef(PG_FUNCTION_ARGS); -extern Datum pg_get_function_arguments(PG_FUNCTION_ARGS); -extern Datum pg_get_function_identity_arguments(PG_FUNCTION_ARGS); -extern Datum pg_get_function_result(PG_FUNCTION_ARGS); -extern Datum pg_get_function_arg_default(PG_FUNCTION_ARGS); #ifdef PGXC extern void get_query_def_from_valuesList(Query *query, StringInfo buf); extern void deparse_query(Query *query, StringInfo buf, List *parentnamespace, @@ -762,66 +96,10 @@ extern const char *quote_identifier(const char *ident); extern char *quote_qualified_identifier(const char *qualifier, const char *ident); - -/* tid.c */ -extern Datum tidin(PG_FUNCTION_ARGS); -extern Datum tidout(PG_FUNCTION_ARGS); -extern Datum tidrecv(PG_FUNCTION_ARGS); -extern Datum tidsend(PG_FUNCTION_ARGS); -extern Datum tideq(PG_FUNCTION_ARGS); -extern Datum tidne(PG_FUNCTION_ARGS); -extern Datum tidlt(PG_FUNCTION_ARGS); -extern Datum tidle(PG_FUNCTION_ARGS); -extern Datum tidgt(PG_FUNCTION_ARGS); -extern Datum tidge(PG_FUNCTION_ARGS); -extern Datum bttidcmp(PG_FUNCTION_ARGS); -extern Datum tidlarger(PG_FUNCTION_ARGS); -extern Datum tidsmaller(PG_FUNCTION_ARGS); -extern Datum currtid_byreloid(PG_FUNCTION_ARGS); -extern Datum currtid_byrelname(PG_FUNCTION_ARGS); - /* varchar.c */ -extern Datum bpcharin(PG_FUNCTION_ARGS); -extern Datum bpcharout(PG_FUNCTION_ARGS); -extern Datum bpcharrecv(PG_FUNCTION_ARGS); -extern Datum bpcharsend(PG_FUNCTION_ARGS); -extern Datum bpchartypmodin(PG_FUNCTION_ARGS); -extern Datum bpchartypmodout(PG_FUNCTION_ARGS); -extern Datum bpchar(PG_FUNCTION_ARGS); -extern Datum char_bpchar(PG_FUNCTION_ARGS); -extern Datum name_bpchar(PG_FUNCTION_ARGS); -extern Datum bpchar_name(PG_FUNCTION_ARGS); -extern Datum bpchareq(PG_FUNCTION_ARGS); -extern Datum bpcharne(PG_FUNCTION_ARGS); -extern Datum bpcharlt(PG_FUNCTION_ARGS); -extern Datum bpcharle(PG_FUNCTION_ARGS); -extern Datum bpchargt(PG_FUNCTION_ARGS); -extern Datum bpcharge(PG_FUNCTION_ARGS); -extern Datum bpcharcmp(PG_FUNCTION_ARGS); -extern Datum bpchar_sortsupport(PG_FUNCTION_ARGS); -extern Datum bpchar_larger(PG_FUNCTION_ARGS); -extern Datum bpchar_smaller(PG_FUNCTION_ARGS); extern int bpchartruelen(char *s, int len); -extern Datum bpcharlen(PG_FUNCTION_ARGS); -extern Datum bpcharoctetlen(PG_FUNCTION_ARGS); -extern Datum hashbpchar(PG_FUNCTION_ARGS); -extern Datum bpchar_pattern_lt(PG_FUNCTION_ARGS); -extern Datum bpchar_pattern_le(PG_FUNCTION_ARGS); -extern Datum bpchar_pattern_gt(PG_FUNCTION_ARGS); -extern Datum bpchar_pattern_ge(PG_FUNCTION_ARGS); -extern Datum btbpchar_pattern_cmp(PG_FUNCTION_ARGS); -extern Datum btbpchar_pattern_sortsupport(PG_FUNCTION_ARGS); - -extern Datum varcharin(PG_FUNCTION_ARGS); -extern Datum varcharout(PG_FUNCTION_ARGS); -extern Datum varcharrecv(PG_FUNCTION_ARGS); -extern Datum varcharsend(PG_FUNCTION_ARGS); -extern Datum varchartypmodin(PG_FUNCTION_ARGS); -extern Datum varchartypmodout(PG_FUNCTION_ARGS); -extern Datum varchar_transform(PG_FUNCTION_ARGS); -extern Datum varchar(PG_FUNCTION_ARGS); -/* varlena.c */ +/* popular functions from varlena.c */ extern text *cstring_to_text(const char *s); extern text *cstring_to_text_with_len(const char *s, int len); extern char *text_to_cstring(const text *t); @@ -830,132 +108,8 @@ extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len); #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s)) #define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d)) -extern Datum textin(PG_FUNCTION_ARGS); -extern Datum textout(PG_FUNCTION_ARGS); -extern Datum textrecv(PG_FUNCTION_ARGS); -extern Datum textsend(PG_FUNCTION_ARGS); -extern Datum textcat(PG_FUNCTION_ARGS); -extern Datum texteq(PG_FUNCTION_ARGS); -extern Datum textne(PG_FUNCTION_ARGS); -extern Datum text_lt(PG_FUNCTION_ARGS); -extern Datum text_le(PG_FUNCTION_ARGS); -extern Datum text_gt(PG_FUNCTION_ARGS); -extern Datum text_ge(PG_FUNCTION_ARGS); -extern Datum text_larger(PG_FUNCTION_ARGS); -extern Datum text_smaller(PG_FUNCTION_ARGS); -extern Datum text_pattern_lt(PG_FUNCTION_ARGS); -extern Datum text_pattern_le(PG_FUNCTION_ARGS); -extern Datum text_pattern_gt(PG_FUNCTION_ARGS); -extern Datum text_pattern_ge(PG_FUNCTION_ARGS); -extern Datum bttext_pattern_cmp(PG_FUNCTION_ARGS); -extern Datum bttext_pattern_sortsupport(PG_FUNCTION_ARGS); -extern Datum textlen(PG_FUNCTION_ARGS); -extern Datum textoctetlen(PG_FUNCTION_ARGS); -extern Datum textpos(PG_FUNCTION_ARGS); -extern Datum text_substr(PG_FUNCTION_ARGS); -extern Datum text_substr_no_len(PG_FUNCTION_ARGS); -extern Datum textoverlay(PG_FUNCTION_ARGS); -extern Datum textoverlay_no_len(PG_FUNCTION_ARGS); -extern Datum name_text(PG_FUNCTION_ARGS); -extern Datum text_name(PG_FUNCTION_ARGS); -extern int varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid); -extern void varstr_sortsupport(SortSupport ssup, Oid collid, bool bpchar); -extern int varstr_levenshtein(const char *source, int slen, - const char *target, int tlen, - int ins_c, int del_c, int sub_c, - bool trusted); -extern int varstr_levenshtein_less_equal(const char *source, int slen, - const char *target, int tlen, - int ins_c, int del_c, int sub_c, - int max_d, bool trusted); -extern List *textToQualifiedNameList(text *textval); -extern bool SplitIdentifierString(char *rawstring, char separator, - List **namelist); -extern bool SplitDirectoriesString(char *rawstring, char separator, - List **namelist); -extern Datum replace_text(PG_FUNCTION_ARGS); -extern text *replace_text_regexp(text *src_text, void *regexp, - text *replace_text, bool glob); -extern Datum split_text(PG_FUNCTION_ARGS); -extern Datum text_to_array(PG_FUNCTION_ARGS); -extern Datum array_to_text(PG_FUNCTION_ARGS); -extern Datum text_to_array_null(PG_FUNCTION_ARGS); -extern Datum array_to_text_null(PG_FUNCTION_ARGS); -extern Datum to_hex32(PG_FUNCTION_ARGS); -extern Datum to_hex64(PG_FUNCTION_ARGS); -extern Datum md5_text(PG_FUNCTION_ARGS); -extern Datum md5_bytea(PG_FUNCTION_ARGS); - -extern Datum unknownin(PG_FUNCTION_ARGS); -extern Datum unknownout(PG_FUNCTION_ARGS); -extern Datum unknownrecv(PG_FUNCTION_ARGS); -extern Datum unknownsend(PG_FUNCTION_ARGS); - -extern Datum pg_column_size(PG_FUNCTION_ARGS); - -extern Datum bytea_string_agg_transfn(PG_FUNCTION_ARGS); -extern Datum bytea_string_agg_finalfn(PG_FUNCTION_ARGS); -extern Datum string_agg_transfn(PG_FUNCTION_ARGS); -extern Datum string_agg_finalfn(PG_FUNCTION_ARGS); - -extern Datum text_concat(PG_FUNCTION_ARGS); -extern Datum text_concat_ws(PG_FUNCTION_ARGS); -extern Datum text_left(PG_FUNCTION_ARGS); -extern Datum text_right(PG_FUNCTION_ARGS); -extern Datum text_reverse(PG_FUNCTION_ARGS); -extern Datum text_format(PG_FUNCTION_ARGS); -extern Datum text_format_nv(PG_FUNCTION_ARGS); - -/* version.c */ -extern Datum pgsql_version(PG_FUNCTION_ARGS); - /* xid.c */ -extern Datum xidin(PG_FUNCTION_ARGS); -extern Datum xidout(PG_FUNCTION_ARGS); -extern Datum xidrecv(PG_FUNCTION_ARGS); -extern Datum xidsend(PG_FUNCTION_ARGS); -extern Datum xideq(PG_FUNCTION_ARGS); -extern Datum xidneq(PG_FUNCTION_ARGS); -extern Datum xid_age(PG_FUNCTION_ARGS); -extern Datum mxid_age(PG_FUNCTION_ARGS); extern int xidComparator(const void *arg1, const void *arg2); -extern Datum cidin(PG_FUNCTION_ARGS); -extern Datum cidout(PG_FUNCTION_ARGS); -extern Datum cidrecv(PG_FUNCTION_ARGS); -extern Datum cidsend(PG_FUNCTION_ARGS); -extern Datum cideq(PG_FUNCTION_ARGS); - -/* like.c */ -extern Datum namelike(PG_FUNCTION_ARGS); -extern Datum namenlike(PG_FUNCTION_ARGS); -extern Datum nameiclike(PG_FUNCTION_ARGS); -extern Datum nameicnlike(PG_FUNCTION_ARGS); -extern Datum textlike(PG_FUNCTION_ARGS); -extern Datum textnlike(PG_FUNCTION_ARGS); -extern Datum texticlike(PG_FUNCTION_ARGS); -extern Datum texticnlike(PG_FUNCTION_ARGS); -extern Datum bytealike(PG_FUNCTION_ARGS); -extern Datum byteanlike(PG_FUNCTION_ARGS); -extern Datum like_escape(PG_FUNCTION_ARGS); -extern Datum like_escape_bytea(PG_FUNCTION_ARGS); - -/* oracle_compat.c */ -extern Datum lower(PG_FUNCTION_ARGS); -extern Datum upper(PG_FUNCTION_ARGS); -extern Datum initcap(PG_FUNCTION_ARGS); -extern Datum lpad(PG_FUNCTION_ARGS); -extern Datum rpad(PG_FUNCTION_ARGS); -extern Datum btrim(PG_FUNCTION_ARGS); -extern Datum btrim1(PG_FUNCTION_ARGS); -extern Datum byteatrim(PG_FUNCTION_ARGS); -extern Datum ltrim(PG_FUNCTION_ARGS); -extern Datum ltrim1(PG_FUNCTION_ARGS); -extern Datum rtrim(PG_FUNCTION_ARGS); -extern Datum rtrim1(PG_FUNCTION_ARGS); -extern Datum translate(PG_FUNCTION_ARGS); -extern Datum chr (PG_FUNCTION_ARGS); -extern Datum repeat(PG_FUNCTION_ARGS); -extern Datum ascii(PG_FUNCTION_ARGS); /* inet_cidr_ntop.c */ extern char *inet_cidr_ntop(int af, const void *src, int bits, @@ -966,385 +120,23 @@ extern int inet_net_pton(int af, const char *src, void *dst, size_t size); /* network.c */ -extern Datum inet_in(PG_FUNCTION_ARGS); -extern Datum inet_out(PG_FUNCTION_ARGS); -extern Datum inet_recv(PG_FUNCTION_ARGS); -extern Datum inet_send(PG_FUNCTION_ARGS); -extern Datum cidr_in(PG_FUNCTION_ARGS); -extern Datum cidr_out(PG_FUNCTION_ARGS); -extern Datum cidr_recv(PG_FUNCTION_ARGS); -extern Datum cidr_send(PG_FUNCTION_ARGS); -extern Datum network_cmp(PG_FUNCTION_ARGS); -extern Datum network_lt(PG_FUNCTION_ARGS); -extern Datum network_le(PG_FUNCTION_ARGS); -extern Datum network_eq(PG_FUNCTION_ARGS); -extern Datum network_ge(PG_FUNCTION_ARGS); -extern Datum network_gt(PG_FUNCTION_ARGS); -extern Datum network_ne(PG_FUNCTION_ARGS); -extern Datum network_smaller(PG_FUNCTION_ARGS); -extern Datum network_larger(PG_FUNCTION_ARGS); -extern Datum hashinet(PG_FUNCTION_ARGS); -extern Datum network_sub(PG_FUNCTION_ARGS); -extern Datum network_subeq(PG_FUNCTION_ARGS); -extern Datum network_sup(PG_FUNCTION_ARGS); -extern Datum network_supeq(PG_FUNCTION_ARGS); -extern Datum network_overlap(PG_FUNCTION_ARGS); -extern Datum network_network(PG_FUNCTION_ARGS); -extern Datum network_netmask(PG_FUNCTION_ARGS); -extern Datum network_hostmask(PG_FUNCTION_ARGS); -extern Datum network_masklen(PG_FUNCTION_ARGS); -extern Datum network_family(PG_FUNCTION_ARGS); -extern Datum network_broadcast(PG_FUNCTION_ARGS); -extern Datum network_host(PG_FUNCTION_ARGS); -extern Datum network_show(PG_FUNCTION_ARGS); -extern Datum inet_abbrev(PG_FUNCTION_ARGS); -extern Datum cidr_abbrev(PG_FUNCTION_ARGS); extern double convert_network_to_scalar(Datum value, Oid typid); -extern Datum inet_to_cidr(PG_FUNCTION_ARGS); -extern Datum inet_set_masklen(PG_FUNCTION_ARGS); -extern Datum cidr_set_masklen(PG_FUNCTION_ARGS); extern Datum network_scan_first(Datum in); extern Datum network_scan_last(Datum in); -extern Datum inet_client_addr(PG_FUNCTION_ARGS); -extern Datum inet_client_port(PG_FUNCTION_ARGS); -extern Datum inet_server_addr(PG_FUNCTION_ARGS); -extern Datum inet_server_port(PG_FUNCTION_ARGS); -extern Datum inetnot(PG_FUNCTION_ARGS); -extern Datum inetand(PG_FUNCTION_ARGS); -extern Datum inetor(PG_FUNCTION_ARGS); -extern Datum inetpl(PG_FUNCTION_ARGS); -extern Datum inetmi_int8(PG_FUNCTION_ARGS); -extern Datum inetmi(PG_FUNCTION_ARGS); extern void clean_ipv6_addr(int addr_family, char *addr); -extern Datum inet_same_family(PG_FUNCTION_ARGS); -extern Datum inet_merge(PG_FUNCTION_ARGS); - -/* mac.c */ -extern Datum macaddr_in(PG_FUNCTION_ARGS); -extern Datum macaddr_out(PG_FUNCTION_ARGS); -extern Datum macaddr_recv(PG_FUNCTION_ARGS); -extern Datum macaddr_send(PG_FUNCTION_ARGS); -extern Datum macaddr_cmp(PG_FUNCTION_ARGS); -extern Datum macaddr_lt(PG_FUNCTION_ARGS); -extern Datum macaddr_le(PG_FUNCTION_ARGS); -extern Datum macaddr_eq(PG_FUNCTION_ARGS); -extern Datum macaddr_ge(PG_FUNCTION_ARGS); -extern Datum macaddr_gt(PG_FUNCTION_ARGS); -extern Datum macaddr_ne(PG_FUNCTION_ARGS); -extern Datum macaddr_not(PG_FUNCTION_ARGS); -extern Datum macaddr_and(PG_FUNCTION_ARGS); -extern Datum macaddr_or(PG_FUNCTION_ARGS); -extern Datum macaddr_trunc(PG_FUNCTION_ARGS); -extern Datum hashmacaddr(PG_FUNCTION_ARGS); /* numeric.c */ -extern Datum numeric_in(PG_FUNCTION_ARGS); -extern Datum numeric_out(PG_FUNCTION_ARGS); -extern Datum numeric_recv(PG_FUNCTION_ARGS); -extern Datum numeric_send(PG_FUNCTION_ARGS); -extern Datum numerictypmodin(PG_FUNCTION_ARGS); -extern Datum numerictypmodout(PG_FUNCTION_ARGS); -extern Datum numeric_transform(PG_FUNCTION_ARGS); -extern Datum numeric (PG_FUNCTION_ARGS); -extern Datum numeric_abs(PG_FUNCTION_ARGS); -extern Datum numeric_uminus(PG_FUNCTION_ARGS); -extern Datum numeric_uplus(PG_FUNCTION_ARGS); -extern Datum numeric_sign(PG_FUNCTION_ARGS); -extern Datum numeric_round(PG_FUNCTION_ARGS); -extern Datum numeric_trunc(PG_FUNCTION_ARGS); -extern Datum numeric_ceil(PG_FUNCTION_ARGS); -extern Datum numeric_floor(PG_FUNCTION_ARGS); -extern Datum numeric_sortsupport(PG_FUNCTION_ARGS); -extern Datum numeric_cmp(PG_FUNCTION_ARGS); -extern Datum numeric_eq(PG_FUNCTION_ARGS); -extern Datum numeric_ne(PG_FUNCTION_ARGS); -extern Datum numeric_gt(PG_FUNCTION_ARGS); -extern Datum numeric_ge(PG_FUNCTION_ARGS); -extern Datum numeric_lt(PG_FUNCTION_ARGS); -extern Datum numeric_le(PG_FUNCTION_ARGS); -extern Datum numeric_add(PG_FUNCTION_ARGS); -extern Datum numeric_sub(PG_FUNCTION_ARGS); -extern Datum numeric_mul(PG_FUNCTION_ARGS); -extern Datum numeric_div(PG_FUNCTION_ARGS); -extern Datum numeric_div_trunc(PG_FUNCTION_ARGS); -extern Datum numeric_mod(PG_FUNCTION_ARGS); -extern Datum numeric_inc(PG_FUNCTION_ARGS); -extern Datum numeric_smaller(PG_FUNCTION_ARGS); -extern Datum numeric_larger(PG_FUNCTION_ARGS); -extern Datum numeric_fac(PG_FUNCTION_ARGS); -extern Datum numeric_sqrt(PG_FUNCTION_ARGS); -extern Datum numeric_exp(PG_FUNCTION_ARGS); -extern Datum numeric_ln(PG_FUNCTION_ARGS); -extern Datum numeric_log(PG_FUNCTION_ARGS); -extern Datum numeric_power(PG_FUNCTION_ARGS); -extern Datum numeric_scale(PG_FUNCTION_ARGS); -extern Datum int4_numeric(PG_FUNCTION_ARGS); -extern Datum numeric_int4(PG_FUNCTION_ARGS); -extern Datum int8_numeric(PG_FUNCTION_ARGS); -extern Datum numeric_int8(PG_FUNCTION_ARGS); -extern Datum int2_numeric(PG_FUNCTION_ARGS); -extern Datum numeric_int2(PG_FUNCTION_ARGS); -extern Datum float8_numeric(PG_FUNCTION_ARGS); -extern Datum numeric_float8(PG_FUNCTION_ARGS); extern Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS); -extern Datum float4_numeric(PG_FUNCTION_ARGS); -extern Datum numeric_float4(PG_FUNCTION_ARGS); -extern Datum numeric_accum(PG_FUNCTION_ARGS); -extern Datum numeric_combine(PG_FUNCTION_ARGS); -extern Datum numeric_avg_accum(PG_FUNCTION_ARGS); -extern Datum numeric_avg_combine(PG_FUNCTION_ARGS); -extern Datum numeric_avg_serialize(PG_FUNCTION_ARGS); -extern Datum numeric_avg_deserialize(PG_FUNCTION_ARGS); -extern Datum numeric_serialize(PG_FUNCTION_ARGS); -extern Datum numeric_deserialize(PG_FUNCTION_ARGS); -extern Datum numeric_accum_inv(PG_FUNCTION_ARGS); -extern Datum int2_accum(PG_FUNCTION_ARGS); -extern Datum int4_accum(PG_FUNCTION_ARGS); -extern Datum int8_accum(PG_FUNCTION_ARGS); -extern Datum numeric_poly_combine(PG_FUNCTION_ARGS); -extern Datum numeric_poly_serialize(PG_FUNCTION_ARGS); -extern Datum numeric_poly_deserialize(PG_FUNCTION_ARGS); -extern Datum int2_accum_inv(PG_FUNCTION_ARGS); -extern Datum int4_accum_inv(PG_FUNCTION_ARGS); -extern Datum int8_accum_inv(PG_FUNCTION_ARGS); -extern Datum int8_avg_accum(PG_FUNCTION_ARGS); -extern Datum int8_avg_combine(PG_FUNCTION_ARGS); -extern Datum int8_avg_serialize(PG_FUNCTION_ARGS); -extern Datum int8_avg_deserialize(PG_FUNCTION_ARGS); -extern Datum numeric_avg(PG_FUNCTION_ARGS); -extern Datum numeric_sum(PG_FUNCTION_ARGS); -extern Datum numeric_var_pop(PG_FUNCTION_ARGS); -extern Datum numeric_var_samp(PG_FUNCTION_ARGS); -extern Datum numeric_stddev_pop(PG_FUNCTION_ARGS); -extern Datum numeric_stddev_samp(PG_FUNCTION_ARGS); -extern Datum numeric_poly_sum(PG_FUNCTION_ARGS); -extern Datum numeric_poly_avg(PG_FUNCTION_ARGS); -extern Datum numeric_poly_var_pop(PG_FUNCTION_ARGS); -extern Datum numeric_poly_var_samp(PG_FUNCTION_ARGS); -extern Datum numeric_poly_stddev_pop(PG_FUNCTION_ARGS); -extern Datum numeric_poly_stddev_samp(PG_FUNCTION_ARGS); -extern Datum int2_sum(PG_FUNCTION_ARGS); -extern Datum int4_sum(PG_FUNCTION_ARGS); -extern Datum int8_sum(PG_FUNCTION_ARGS); -extern Datum int2_avg_accum(PG_FUNCTION_ARGS); -extern Datum int4_avg_accum(PG_FUNCTION_ARGS); -extern Datum int4_avg_combine(PG_FUNCTION_ARGS); -extern Datum int2_avg_accum_inv(PG_FUNCTION_ARGS); -extern Datum int4_avg_accum_inv(PG_FUNCTION_ARGS); -extern Datum int8_avg_accum_inv(PG_FUNCTION_ARGS); -extern Datum int8_avg(PG_FUNCTION_ARGS); -extern Datum int2int4_sum(PG_FUNCTION_ARGS); -extern Datum width_bucket_numeric(PG_FUNCTION_ARGS); -extern Datum hash_numeric(PG_FUNCTION_ARGS); -extern Datum generate_series_numeric(PG_FUNCTION_ARGS); -extern Datum generate_series_step_numeric(PG_FUNCTION_ARGS); - -/* ri_triggers.c */ -extern Datum RI_FKey_check_ins(PG_FUNCTION_ARGS); -extern Datum RI_FKey_check_upd(PG_FUNCTION_ARGS); -extern Datum RI_FKey_noaction_del(PG_FUNCTION_ARGS); -extern Datum RI_FKey_noaction_upd(PG_FUNCTION_ARGS); -extern Datum RI_FKey_cascade_del(PG_FUNCTION_ARGS); -extern Datum RI_FKey_cascade_upd(PG_FUNCTION_ARGS); -extern Datum RI_FKey_restrict_del(PG_FUNCTION_ARGS); -extern Datum RI_FKey_restrict_upd(PG_FUNCTION_ARGS); -extern Datum RI_FKey_setnull_del(PG_FUNCTION_ARGS); -extern Datum RI_FKey_setnull_upd(PG_FUNCTION_ARGS); -extern Datum RI_FKey_setdefault_del(PG_FUNCTION_ARGS); -extern Datum RI_FKey_setdefault_upd(PG_FUNCTION_ARGS); - -/* trigfuncs.c */ -extern Datum suppress_redundant_updates_trigger(PG_FUNCTION_ARGS); - -/* encoding support functions */ -extern Datum getdatabaseencoding(PG_FUNCTION_ARGS); -extern Datum database_character_set(PG_FUNCTION_ARGS); -extern Datum pg_client_encoding(PG_FUNCTION_ARGS); -extern Datum PG_encoding_to_char(PG_FUNCTION_ARGS); -extern Datum PG_char_to_encoding(PG_FUNCTION_ARGS); -extern Datum PG_character_set_name(PG_FUNCTION_ARGS); -extern Datum PG_character_set_id(PG_FUNCTION_ARGS); -extern Datum pg_convert(PG_FUNCTION_ARGS); -extern Datum pg_convert_to(PG_FUNCTION_ARGS); -extern Datum pg_convert_from(PG_FUNCTION_ARGS); -extern Datum length_in_encoding(PG_FUNCTION_ARGS); -extern Datum pg_encoding_max_length_sql(PG_FUNCTION_ARGS); /* format_type.c */ -extern Datum format_type(PG_FUNCTION_ARGS); extern char *format_type_be(Oid type_oid); extern char *format_type_be_qualified(Oid type_oid); extern char *format_type_with_typemod(Oid type_oid, int32 typemod); extern char *format_type_with_typemod_qualified(Oid type_oid, int32 typemod); -extern Datum oidvectortypes(PG_FUNCTION_ARGS); extern int32 type_maximum_size(Oid type_oid, int32 typemod); /* quote.c */ -extern Datum quote_ident(PG_FUNCTION_ARGS); -extern Datum quote_literal(PG_FUNCTION_ARGS); extern char *quote_literal_cstr(const char *rawstr); -extern Datum quote_nullable(PG_FUNCTION_ARGS); - -/* guc.c */ -extern Datum show_config_by_name(PG_FUNCTION_ARGS); -extern Datum show_config_by_name_missing_ok(PG_FUNCTION_ARGS); -extern Datum set_config_by_name(PG_FUNCTION_ARGS); -extern Datum show_all_settings(PG_FUNCTION_ARGS); -extern Datum show_all_file_settings(PG_FUNCTION_ARGS); - -/* pg_config.c */ -extern Datum pg_config(PG_FUNCTION_ARGS); - -/* pg_controldata.c */ -extern Datum pg_control_checkpoint(PG_FUNCTION_ARGS); -extern Datum pg_control_system(PG_FUNCTION_ARGS); -extern Datum pg_control_init(PG_FUNCTION_ARGS); -extern Datum pg_control_recovery(PG_FUNCTION_ARGS); - -/* rls.c */ -extern Datum row_security_active(PG_FUNCTION_ARGS); -extern Datum row_security_active_name(PG_FUNCTION_ARGS); - -/* lockfuncs.c */ -extern Datum pg_lock_status(PG_FUNCTION_ARGS); -extern Datum pg_blocking_pids(PG_FUNCTION_ARGS); -extern Datum pg_advisory_lock_int8(PG_FUNCTION_ARGS); -extern Datum pg_advisory_xact_lock_int8(PG_FUNCTION_ARGS); -extern Datum pg_advisory_lock_shared_int8(PG_FUNCTION_ARGS); -extern Datum pg_advisory_xact_lock_shared_int8(PG_FUNCTION_ARGS); -extern Datum pg_try_advisory_lock_int8(PG_FUNCTION_ARGS); -extern Datum pg_try_advisory_xact_lock_int8(PG_FUNCTION_ARGS); -extern Datum pg_try_advisory_lock_shared_int8(PG_FUNCTION_ARGS); -extern Datum pg_try_advisory_xact_lock_shared_int8(PG_FUNCTION_ARGS); -extern Datum pg_advisory_unlock_int8(PG_FUNCTION_ARGS); -extern Datum pg_advisory_unlock_shared_int8(PG_FUNCTION_ARGS); -extern Datum pg_advisory_lock_int4(PG_FUNCTION_ARGS); -extern Datum pg_advisory_xact_lock_int4(PG_FUNCTION_ARGS); -extern Datum pg_advisory_lock_shared_int4(PG_FUNCTION_ARGS); -extern Datum pg_advisory_xact_lock_shared_int4(PG_FUNCTION_ARGS); -extern Datum pg_try_advisory_lock_int4(PG_FUNCTION_ARGS); -extern Datum pg_try_advisory_xact_lock_int4(PG_FUNCTION_ARGS); -extern Datum pg_try_advisory_lock_shared_int4(PG_FUNCTION_ARGS); -extern Datum pg_try_advisory_xact_lock_shared_int4(PG_FUNCTION_ARGS); -extern Datum pg_advisory_unlock_int4(PG_FUNCTION_ARGS); -extern Datum pg_advisory_unlock_shared_int4(PG_FUNCTION_ARGS); -extern Datum pg_advisory_unlock_all(PG_FUNCTION_ARGS); - -/* txid.c */ -extern Datum txid_snapshot_in(PG_FUNCTION_ARGS); -extern Datum txid_snapshot_out(PG_FUNCTION_ARGS); -extern Datum txid_snapshot_recv(PG_FUNCTION_ARGS); -extern Datum txid_snapshot_send(PG_FUNCTION_ARGS); -extern Datum txid_current(PG_FUNCTION_ARGS); -extern Datum txid_current_snapshot(PG_FUNCTION_ARGS); -extern Datum txid_snapshot_xmin(PG_FUNCTION_ARGS); -extern Datum txid_snapshot_xmax(PG_FUNCTION_ARGS); -extern Datum txid_snapshot_xip(PG_FUNCTION_ARGS); -extern Datum txid_visible_in_snapshot(PG_FUNCTION_ARGS); - -/* uuid.c */ -extern Datum uuid_in(PG_FUNCTION_ARGS); -extern Datum uuid_out(PG_FUNCTION_ARGS); -extern Datum uuid_send(PG_FUNCTION_ARGS); -extern Datum uuid_recv(PG_FUNCTION_ARGS); -extern Datum uuid_lt(PG_FUNCTION_ARGS); -extern Datum uuid_le(PG_FUNCTION_ARGS); -extern Datum uuid_eq(PG_FUNCTION_ARGS); -extern Datum uuid_ge(PG_FUNCTION_ARGS); -extern Datum uuid_gt(PG_FUNCTION_ARGS); -extern Datum uuid_ne(PG_FUNCTION_ARGS); -extern Datum uuid_cmp(PG_FUNCTION_ARGS); -extern Datum uuid_sortsupport(PG_FUNCTION_ARGS); -extern Datum uuid_hash(PG_FUNCTION_ARGS); - -/* windowfuncs.c */ -extern Datum window_row_number(PG_FUNCTION_ARGS); -extern Datum window_rank(PG_FUNCTION_ARGS); -extern Datum window_dense_rank(PG_FUNCTION_ARGS); -extern Datum window_percent_rank(PG_FUNCTION_ARGS); -extern Datum window_cume_dist(PG_FUNCTION_ARGS); -extern Datum window_ntile(PG_FUNCTION_ARGS); -extern Datum window_lag(PG_FUNCTION_ARGS); -extern Datum window_lag_with_offset(PG_FUNCTION_ARGS); -extern Datum window_lag_with_offset_and_default(PG_FUNCTION_ARGS); -extern Datum window_lead(PG_FUNCTION_ARGS); -extern Datum window_lead_with_offset(PG_FUNCTION_ARGS); -extern Datum window_lead_with_offset_and_default(PG_FUNCTION_ARGS); -extern Datum window_first_value(PG_FUNCTION_ARGS); -extern Datum window_last_value(PG_FUNCTION_ARGS); -extern Datum window_nth_value(PG_FUNCTION_ARGS); - -/* access/spgist/spgquadtreeproc.c */ -extern Datum spg_quad_config(PG_FUNCTION_ARGS); -extern Datum spg_quad_choose(PG_FUNCTION_ARGS); -extern Datum spg_quad_picksplit(PG_FUNCTION_ARGS); -extern Datum spg_quad_inner_consistent(PG_FUNCTION_ARGS); -extern Datum spg_quad_leaf_consistent(PG_FUNCTION_ARGS); - -/* access/spgist/spgkdtreeproc.c */ -extern Datum spg_kd_config(PG_FUNCTION_ARGS); -extern Datum spg_kd_choose(PG_FUNCTION_ARGS); -extern Datum spg_kd_picksplit(PG_FUNCTION_ARGS); -extern Datum spg_kd_inner_consistent(PG_FUNCTION_ARGS); - -/* access/spgist/spgtextproc.c */ -extern Datum spg_text_config(PG_FUNCTION_ARGS); -extern Datum spg_text_choose(PG_FUNCTION_ARGS); -extern Datum spg_text_picksplit(PG_FUNCTION_ARGS); -extern Datum spg_text_inner_consistent(PG_FUNCTION_ARGS); -extern Datum spg_text_leaf_consistent(PG_FUNCTION_ARGS); - -/* access/gin/ginarrayproc.c */ -extern Datum ginarrayextract(PG_FUNCTION_ARGS); -extern Datum ginarrayextract_2args(PG_FUNCTION_ARGS); -extern Datum ginqueryarrayextract(PG_FUNCTION_ARGS); -extern Datum ginarrayconsistent(PG_FUNCTION_ARGS); -extern Datum ginarraytriconsistent(PG_FUNCTION_ARGS); - -/* access/tablesample/bernoulli.c */ -extern Datum tsm_bernoulli_handler(PG_FUNCTION_ARGS); - -/* access/tablesample/system.c */ -extern Datum tsm_system_handler(PG_FUNCTION_ARGS); - -/* access/transam/twophase.c */ -extern Datum pg_prepared_xact(PG_FUNCTION_ARGS); - -/* access/transam/multixact.c */ -extern Datum pg_get_multixact_members(PG_FUNCTION_ARGS); - -/* access/transam/committs.c */ -extern Datum pg_xact_commit_timestamp(PG_FUNCTION_ARGS); -extern Datum pg_last_committed_xact(PG_FUNCTION_ARGS); - -/* catalogs/dependency.c */ -extern Datum pg_describe_object(PG_FUNCTION_ARGS); -extern Datum pg_identify_object(PG_FUNCTION_ARGS); -extern Datum pg_identify_object_as_address(PG_FUNCTION_ARGS); - -/* catalog/objectaddress.c */ -extern Datum pg_get_object_address(PG_FUNCTION_ARGS); - -/* commands/constraint.c */ -extern Datum unique_key_recheck(PG_FUNCTION_ARGS); - -/* commands/event_trigger.c */ -extern Datum pg_event_trigger_dropped_objects(PG_FUNCTION_ARGS); -extern Datum pg_event_trigger_table_rewrite_oid(PG_FUNCTION_ARGS); -extern Datum pg_event_trigger_table_rewrite_reason(PG_FUNCTION_ARGS); -extern Datum pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS); - -/* commands/extension.c */ -extern Datum pg_available_extensions(PG_FUNCTION_ARGS); -extern Datum pg_available_extension_versions(PG_FUNCTION_ARGS); -extern Datum pg_extension_update_paths(PG_FUNCTION_ARGS); -extern Datum pg_extension_config_dump(PG_FUNCTION_ARGS); - -/* commands/prepare.c */ -extern Datum pg_prepared_statement(PG_FUNCTION_ARGS); - -/* utils/mmgr/portalmem.c */ -extern Datum pg_cursor(PG_FUNCTION_ARGS); #ifdef PGXC /* backend/pgxc/pool/poolutils.c */ diff --git a/src/include/utils/bytea.h b/src/include/utils/bytea.h index c41e6b4b7a..818e65707f 100644 --- a/src/include/utils/bytea.h +++ b/src/include/utils/bytea.h @@ -4,7 +4,7 @@ * Declarations for BYTEA data type support. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/bytea.h @@ -25,29 +25,4 @@ typedef enum 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 bytea_sortsupport(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 */ diff --git a/src/include/utils/cash.h b/src/include/utils/cash.h index 3a491f9231..84083677e1 100644 --- a/src/include/utils/cash.h +++ b/src/include/utils/cash.h @@ -22,52 +22,4 @@ typedef int64 Cash; #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 */ diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index 253c7b53ed..5add424e5e 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -10,7 +10,7 @@ * guarantee that there can only be one matching row for a key combination. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/catcache.h @@ -52,6 +52,12 @@ typedef struct catcache * heap scans */ bool cc_isname[CATCACHE_MAXKEYS]; /* flag "name" key columns */ dlist_head cc_lists; /* list of CatCList structs */ + dlist_head *cc_bucket; /* hash buckets */ + + /* + * Keep these at the end, so that compiling catcache.c with CATCACHE_STATS + * doesn't break ABI for other modules + */ #ifdef CATCACHE_STATS long cc_searches; /* total # searches against this cache */ long cc_hits; /* # of matches against existing entry */ @@ -66,7 +72,6 @@ typedef struct catcache long cc_lsearches; /* total # list-searches */ long cc_lhits; /* # of matches against existing lists */ #endif - dlist_head *cc_bucket; /* hash buckets */ } CatCache; @@ -185,7 +190,7 @@ extern void ReleaseCatCacheList(CatCList *list); extern void ResetCatalogCaches(void); extern void CatalogCacheFlushCatalog(Oid catId); -extern void CatalogCacheIdInvalidate(int cacheId, uint32 hashValue); +extern void CatCacheInvalidate(CatCache *cache, uint32 hashValue); extern void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, HeapTuple newtuple, diff --git a/src/include/utils/combocid.h b/src/include/utils/combocid.h index 299b2edbfc..1cb0e74275 100644 --- a/src/include/utils/combocid.h +++ b/src/include/utils/combocid.h @@ -4,7 +4,7 @@ * Combo command ID support routines * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/combocid.h diff --git a/src/include/utils/date.h b/src/include/utils/date.h index 1b962af7d8..309a581853 100644 --- a/src/include/utils/date.h +++ b/src/include/utils/date.h @@ -4,7 +4,7 @@ * Definitions for the SQL "date" and "time" types. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/date.h @@ -21,11 +21,7 @@ typedef int32 DateADT; -#ifdef HAVE_INT64_TIMESTAMP typedef int64 TimeADT; -#else -typedef float8 TimeADT; -#endif typedef struct { @@ -48,11 +44,9 @@ typedef struct /* * 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! + * For TimeADT, we make use of the same support routines as for int64. + * Therefore TimeADT is pass-by-reference if and only if int64 is! */ -#ifdef HAVE_INT64_TIMESTAMP - #define MAX_TIME_PRECISION 6 #define DatumGetDateADT(X) ((DateADT) DatumGetInt32(X)) @@ -62,22 +56,6 @@ typedef struct #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)) @@ -89,120 +67,11 @@ typedef struct /* date.c */ +extern int32 anytime_typmod_check(bool istz, int32 typmod); extern double date2timestamp_no_overflow(DateADT dateVal); extern void EncodeSpecialDate(DateADT dt, char *str); - -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 make_date(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_sortsupport(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 make_time(PG_FUNCTION_ARGS); -extern Datum time_transform(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); +extern DateADT GetSQLCurrentDate(void); +extern TimeTzADT *GetSQLCurrentTime(int32 typmod); +extern TimeADT GetSQLLocalTime(int32 typmod); #endif /* DATE_H */ diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index c57dc05ff8..fb7885bf34 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -6,7 +6,7 @@ * including abstime, reltime, date, and time. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/datetime.h @@ -244,23 +244,15 @@ do { \ } while(0) /* TMODULO() - * Like FMODULO(), but work on the timestamp datatype (either int64 or float8). + * Like FMODULO(), but work on the timestamp datatype (now always int64). * 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 @@ -346,7 +338,4 @@ extern TimeZoneAbbrevTable *ConvertTimeZoneAbbrevs(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 */ diff --git a/src/include/utils/datum.h b/src/include/utils/datum.h index 73ec689d3c..a8a9ea6d19 100644 --- a/src/include/utils/datum.h +++ b/src/include/utils/datum.h @@ -8,7 +8,7 @@ * 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-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/datum.h diff --git a/src/include/utils/dsa.h b/src/include/utils/dsa.h new file mode 100644 index 0000000000..f084443409 --- /dev/null +++ b/src/include/utils/dsa.h @@ -0,0 +1,125 @@ +/*------------------------------------------------------------------------- + * + * dsa.h + * Dynamic shared memory areas. + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * src/include/utils/dsa.h + * + *------------------------------------------------------------------------- + */ +#ifndef DSA_H +#define DSA_H + +#include "port/atomics.h" +#include "storage/dsm.h" + +/* The opaque type used for an area. */ +struct dsa_area; +typedef struct dsa_area dsa_area; + +/* + * If this system only uses a 32-bit value for Size, then use the 32-bit + * implementation of DSA. This limits the amount of DSA that can be created + * to something significantly less than the entire 4GB address space because + * the DSA pointer must encode both a segment identifier and an offset, but + * that shouldn't be a significant limitation in practice. + * + * If this system doesn't support atomic operations on 64-bit values, then + * we fall back to 32-bit dsa_pointer for lack of other options. + * + * For testing purposes, USE_SMALL_DSA_POINTER can be defined to force the use + * of 32-bit dsa_pointer even on systems capable of supporting a 64-bit + * dsa_pointer. + */ +#if SIZEOF_SIZE_T == 4 || !defined(PG_HAVE_ATOMIC_U64_SUPPORT) || \ + defined(USE_SMALL_DSA_POINTER) +#define SIZEOF_DSA_POINTER 4 +#else +#define SIZEOF_DSA_POINTER 8 +#endif + +/* + * The type of 'relative pointers' to memory allocated by a dynamic shared + * area. dsa_pointer values can be shared with other processes, but must be + * converted to backend-local pointers before they can be dereferenced. See + * dsa_get_address. Also, an atomic version and appropriately sized atomic + * operations. + */ +#if SIZEOF_DSA_POINTER == 4 +typedef uint32 dsa_pointer; +typedef pg_atomic_uint32 dsa_pointer_atomic; +#define dsa_pointer_atomic_init pg_atomic_init_u32 +#define dsa_pointer_atomic_read pg_atomic_read_u32 +#define dsa_pointer_atomic_write pg_atomic_write_u32 +#define dsa_pointer_atomic_fetch_add pg_atomic_fetch_add_u32 +#define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u32 +#define DSA_POINTER_FORMAT "%08x" +#else +typedef uint64 dsa_pointer; +typedef pg_atomic_uint64 dsa_pointer_atomic; +#define dsa_pointer_atomic_init pg_atomic_init_u64 +#define dsa_pointer_atomic_read pg_atomic_read_u64 +#define dsa_pointer_atomic_write pg_atomic_write_u64 +#define dsa_pointer_atomic_fetch_add pg_atomic_fetch_add_u64 +#define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u64 +#define DSA_POINTER_FORMAT "%016" INT64_MODIFIER "x" +#endif + +/* Flags for dsa_allocate_extended. */ +#define DSA_ALLOC_HUGE 0x01 /* allow huge allocation (> 1 GB) */ +#define DSA_ALLOC_NO_OOM 0x02 /* no failure if out-of-memory */ +#define DSA_ALLOC_ZERO 0x04 /* zero allocated memory */ + +/* A sentinel value for dsa_pointer used to indicate failure to allocate. */ +#define InvalidDsaPointer ((dsa_pointer) 0) + +/* Check if a dsa_pointer value is valid. */ +#define DsaPointerIsValid(x) ((x) != InvalidDsaPointer) + +/* Allocate uninitialized memory with error on out-of-memory. */ +#define dsa_allocate(area, size) \ + dsa_allocate_extended(area, size, 0) + +/* Allocate zero-initialized memory with error on out-of-memory. */ +#define dsa_allocate0(area, size) \ + dsa_allocate_extended(area, size, DSA_ALLOC_ZERO) + +/* + * The type used for dsa_area handles. dsa_handle values can be shared with + * other processes, so that they can attach to them. This provides a way to + * share allocated storage with other processes. + * + * The handle for a dsa_area is currently implemented as the dsm_handle + * for the first DSM segment backing this dynamic storage area, but client + * code shouldn't assume that is true. + */ +typedef dsm_handle dsa_handle; + +extern void dsa_startup(void); + +extern dsa_area *dsa_create(int tranche_id); +extern dsa_area *dsa_create_in_place(void *place, Size size, + int tranche_id, dsm_segment *segment); +extern dsa_area *dsa_attach(dsa_handle handle); +extern dsa_area *dsa_attach_in_place(void *place, dsm_segment *segment); +extern void dsa_release_in_place(void *place); +extern void dsa_on_dsm_detach_release_in_place(dsm_segment *, Datum); +extern void dsa_on_shmem_exit_release_in_place(int, Datum); +extern void dsa_pin_mapping(dsa_area *area); +extern void dsa_detach(dsa_area *area); +extern void dsa_pin(dsa_area *area); +extern void dsa_unpin(dsa_area *area); +extern void dsa_set_size_limit(dsa_area *area, Size limit); +extern Size dsa_minimum_size(void); +extern dsa_handle dsa_get_handle(dsa_area *area); +extern dsa_pointer dsa_allocate_extended(dsa_area *area, Size size, int flags); +extern void dsa_free(dsa_area *area, dsa_pointer dp); +extern void *dsa_get_address(dsa_area *area, dsa_pointer dp); +extern void dsa_trim(dsa_area *area); +extern void dsa_dump(dsa_area *area); + +#endif /* DSA_H */ diff --git a/src/include/utils/dynahash.h b/src/include/utils/dynahash.h index a0352eb7a7..eee5cce928 100644 --- a/src/include/utils/dynahash.h +++ b/src/include/utils/dynahash.h @@ -4,7 +4,7 @@ * POSTGRES dynahash.h file definitions * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/dynahash.h diff --git a/src/include/utils/dynamic_loader.h b/src/include/utils/dynamic_loader.h index 89c24b789a..987f21a362 100644 --- a/src/include/utils/dynamic_loader.h +++ b/src/include/utils/dynamic_loader.h @@ -4,7 +4,7 @@ * * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/dynamic_loader.h diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index d2ad6bae2c..b56e444b5e 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -4,7 +4,7 @@ * POSTGRES error reporting/logging definitions. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/elog.h @@ -260,12 +260,13 @@ extern int getinternalerrposition(void); #else /* !HAVE__BUILTIN_CONSTANT_P */ #define elog(elevel, ...) \ do { \ - int elevel_; \ elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO); \ - elevel_ = (elevel); \ - elog_finish(elevel_, __VA_ARGS__); \ - if (elevel_ >= ERROR) \ - pg_unreachable(); \ + { \ + const int elevel_ = (elevel); \ + elog_finish(elevel_, __VA_ARGS__); \ + if (elevel_ >= ERROR) \ + pg_unreachable(); \ + } \ } while(0) #endif /* HAVE__BUILTIN_CONSTANT_P */ #else /* !HAVE__VA_ARGS */ diff --git a/src/include/utils/evtcache.h b/src/include/utils/evtcache.h index 7c8da746fd..f6ea163df3 100644 --- a/src/include/utils/evtcache.h +++ b/src/include/utils/evtcache.h @@ -3,7 +3,7 @@ * evtcache.c * Special-purpose cache for event trigger data. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION diff --git a/src/include/utils/expandeddatum.h b/src/include/utils/expandeddatum.h index 47989a8cf2..f853a13e6e 100644 --- a/src/include/utils/expandeddatum.h +++ b/src/include/utils/expandeddatum.h @@ -34,7 +34,7 @@ * value if they fail partway through. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/expandeddatum.h diff --git a/src/include/utils/fmgrtab.h b/src/include/utils/fmgrtab.h index 81e844c392..414cd03952 100644 --- a/src/include/utils/fmgrtab.h +++ b/src/include/utils/fmgrtab.h @@ -3,7 +3,7 @@ * fmgrtab.h * The function manager's table of internal functions. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/fmgrtab.h diff --git a/src/include/utils/formatting.h b/src/include/utils/formatting.h index 1f40f97d8e..8eaf2c3052 100644 --- a/src/include/utils/formatting.h +++ b/src/include/utils/formatting.h @@ -4,7 +4,7 @@ * src/include/utils/formatting.h * * - * Portions Copyright (c) 1999-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1999-2017, PostgreSQL Global Development Group * * The PostgreSQL routines for a DateTime/int/float/numeric formatting, * inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines. @@ -28,16 +28,4 @@ extern char *asc_tolower(const char *buff, size_t nbytes); extern char *asc_toupper(const char *buff, size_t nbytes); extern char *asc_initcap(const char *buff, size_t nbytes); -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 diff --git a/src/include/utils/freepage.h b/src/include/utils/freepage.h new file mode 100644 index 0000000000..78caa5369b --- /dev/null +++ b/src/include/utils/freepage.h @@ -0,0 +1,99 @@ +/*------------------------------------------------------------------------- + * + * freepage.h + * Management of page-organized free memory. + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/utils/freepage.h + * + *------------------------------------------------------------------------- + */ + +#ifndef FREEPAGE_H +#define FREEPAGE_H + +#include "storage/lwlock.h" +#include "utils/relptr.h" + +/* Forward declarations. */ +typedef struct FreePageSpanLeader FreePageSpanLeader; +typedef struct FreePageBtree FreePageBtree; +typedef struct FreePageManager FreePageManager; + +/* + * PostgreSQL normally uses 8kB pages for most things, but many common + * architecture/operating system pairings use a 4kB page size for memory + * allocation, so we do that here also. + */ +#define FPM_PAGE_SIZE 4096 + +/* + * Each freelist except for the last contains only spans of one particular + * size. Everything larger goes on the last one. In some sense this seems + * like a waste since most allocations are in a few common sizes, but it + * means that small allocations can simply pop the head of the relevant list + * without needing to worry about whether the object we find there is of + * precisely the correct size (because we know it must be). + */ +#define FPM_NUM_FREELISTS 129 + +/* Define relative pointer types. */ +relptr_declare(FreePageBtree, RelptrFreePageBtree); +relptr_declare(FreePageManager, RelptrFreePageManager); +relptr_declare(FreePageSpanLeader, RelptrFreePageSpanLeader); + +/* Everything we need in order to manage free pages (see freepage.c) */ +struct FreePageManager +{ + RelptrFreePageManager self; + RelptrFreePageBtree btree_root; + RelptrFreePageSpanLeader btree_recycle; + unsigned btree_depth; + unsigned btree_recycle_count; + Size singleton_first_page; + Size singleton_npages; + Size contiguous_pages; + bool contiguous_pages_dirty; + RelptrFreePageSpanLeader freelist[FPM_NUM_FREELISTS]; +#ifdef FPM_EXTRA_ASSERTS + /* For debugging only, pages put minus pages gotten. */ + Size free_pages; +#endif +}; + +/* Macros to convert between page numbers (expressed as Size) and pointers. */ +#define fpm_page_to_pointer(base, page) \ + (AssertVariableIsOfTypeMacro(page, Size), \ + (base) + FPM_PAGE_SIZE * (page)) +#define fpm_pointer_to_page(base, ptr) \ + (((Size) (((char *) (ptr)) - (base))) / FPM_PAGE_SIZE) + +/* Macro to convert an allocation size to a number of pages. */ +#define fpm_size_to_pages(sz) \ + (((sz) + FPM_PAGE_SIZE - 1) / FPM_PAGE_SIZE) + +/* Macros to check alignment of absolute and relative pointers. */ +#define fpm_pointer_is_page_aligned(base, ptr) \ + (((Size) (((char *) (ptr)) - (base))) % FPM_PAGE_SIZE == 0) +#define fpm_relptr_is_page_aligned(base, relptr) \ + ((relptr).relptr_off % FPM_PAGE_SIZE == 0) + +/* Macro to find base address of the segment containing a FreePageManager. */ +#define fpm_segment_base(fpm) \ + (((char *) fpm) - fpm->self.relptr_off) + +/* Macro to access a FreePageManager's largest consecutive run of pages. */ +#define fpm_largest(fpm) \ + (fpm->contiguous_pages) + +/* Functions to manipulate the free page map. */ +extern void FreePageManagerInitialize(FreePageManager *fpm, char *base); +extern bool FreePageManagerGet(FreePageManager *fpm, Size npages, + Size *first_page); +extern void FreePageManagerPut(FreePageManager *fpm, Size first_page, + Size npages); +extern char *FreePageManagerDump(FreePageManager *fpm); + +#endif /* FREEPAGE_H */ diff --git a/src/include/utils/geo_decls.h b/src/include/utils/geo_decls.h index fe9bc60782..9b530dbe3d 100644 --- a/src/include/utils/geo_decls.h +++ b/src/include/utils/geo_decls.h @@ -3,7 +3,7 @@ * geo_decls.h - Declarations for various 2D constructs. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/geo_decls.h @@ -175,270 +175,12 @@ typedef struct /* - * in geo_ops.h + * in geo_ops.c */ -/* 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 */ +/* private point 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); -extern Datum point_box(PG_FUNCTION_ARGS); -extern Datum boxes_bound_box(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_cpoint(PG_FUNCTION_ARGS); -extern Datum dist_cpoly(PG_FUNCTION_ARGS); -extern Datum dist_ppoly(PG_FUNCTION_ARGS); -extern Datum dist_polyp(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_box_fetch(PG_FUNCTION_ARGS); -extern Datum gist_poly_compress(PG_FUNCTION_ARGS); -extern Datum gist_poly_consistent(PG_FUNCTION_ARGS); -extern Datum gist_poly_distance(PG_FUNCTION_ARGS); -extern Datum gist_circle_compress(PG_FUNCTION_ARGS); -extern Datum gist_circle_consistent(PG_FUNCTION_ARGS); -extern Datum gist_circle_distance(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); -extern Datum gist_point_fetch(PG_FUNCTION_ARGS); - -/* utils/adt/geo_spgist.c */ -Datum spg_box_quad_config(PG_FUNCTION_ARGS); -Datum spg_box_quad_choose(PG_FUNCTION_ARGS); -Datum spg_box_quad_picksplit(PG_FUNCTION_ARGS); -Datum spg_box_quad_inner_consistent(PG_FUNCTION_ARGS); -Datum spg_box_quad_leaf_consistent(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 */ diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 23288d9806..144281aa24 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -5,7 +5,7 @@ * backend/utils/misc/guc-file.l * * Portions Copyright (c) 2012-2014, TransLattice, Inc. - * Copyright (c) 2000-2016, PostgreSQL Global Development Group + * Copyright (c) 2000-2017, PostgreSQL Global Development Group * Written by Peter Eisentraut <peter_e@gmx.net>. * * src/include/utils/guc.h @@ -219,13 +219,13 @@ typedef enum #define GUC_UNIT_KB 0x1000 /* value is in kilobytes */ #define GUC_UNIT_BLOCKS 0x2000 /* value is in blocks */ #define GUC_UNIT_XBLOCKS 0x3000 /* value is in xlog blocks */ -#define GUC_UNIT_XSEGS 0x4000 /* value is in xlog segments */ -#define GUC_UNIT_MEMORY 0xF000 /* mask for KB, BLOCKS, XBLOCKS */ +#define GUC_UNIT_MB 0x4000 /* value is in megabytes */ +#define GUC_UNIT_MEMORY 0xF000 /* mask for size-related units */ #define GUC_UNIT_MS 0x10000 /* value is in milliseconds */ #define GUC_UNIT_S 0x20000 /* value is in seconds */ #define GUC_UNIT_MIN 0x30000 /* value is in minutes */ -#define GUC_UNIT_TIME 0xF0000 /* mask for MS, S, MIN */ +#define GUC_UNIT_TIME 0xF0000 /* mask for time-related units */ #define GUC_UNIT (GUC_UNIT_MEMORY | GUC_UNIT_TIME) @@ -250,7 +250,6 @@ extern bool log_remotesubplan_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; diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index 329fc5f90c..1057e55f76 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -5,7 +5,7 @@ * * See src/backend/utils/misc/README for design notes. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * * src/include/utils/guc_tables.h * @@ -72,6 +72,7 @@ enum config_group REPLICATION_SENDING, REPLICATION_MASTER, REPLICATION_STANDBY, + REPLICATION_SUBSCRIBERS, QUERY_TUNING, QUERY_TUNING_METHOD, QUERY_TUNING_COST, diff --git a/src/include/utils/help_config.h b/src/include/utils/help_config.h index 565fdd96fc..3f433d10d7 100644 --- a/src/include/utils/help_config.h +++ b/src/include/utils/help_config.h @@ -3,7 +3,7 @@ * help_config.h * Interface to the --help-config option of main.c * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * * src/include/utils/help_config.h * diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 007ba2c69b..7964087161 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -4,7 +4,7 @@ * exported definitions for utils/hash/dynahash.c; see notes therein * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/hsearch.h diff --git a/src/include/utils/index_selfuncs.h b/src/include/utils/index_selfuncs.h index a03e12f518..17d165ca65 100644 --- a/src/include/utils/index_selfuncs.h +++ b/src/include/utils/index_selfuncs.h @@ -9,7 +9,7 @@ * If you make it depend on anything besides access/amapi.h, that's likely * a mistake. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/index_selfuncs.h @@ -28,41 +28,47 @@ extern void brincostestimate(struct PlannerInfo *root, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, - double *indexCorrelation); + double *indexCorrelation, + double *indexPages); extern void btcostestimate(struct PlannerInfo *root, struct IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, - double *indexCorrelation); + double *indexCorrelation, + double *indexPages); extern void hashcostestimate(struct PlannerInfo *root, struct IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, - double *indexCorrelation); + double *indexCorrelation, + double *indexPages); extern void gistcostestimate(struct PlannerInfo *root, struct IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, - double *indexCorrelation); + double *indexCorrelation, + double *indexPages); extern void spgcostestimate(struct PlannerInfo *root, struct IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, - double *indexCorrelation); + double *indexCorrelation, + double *indexPages); extern void gincostestimate(struct PlannerInfo *root, struct IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, - double *indexCorrelation); + double *indexCorrelation, + double *indexPages); #endif /* INDEX_SELFUNCS_H */ diff --git a/src/include/utils/inet.h b/src/include/utils/inet.h index 2fe3ca8c3c..7dc179e255 100644 --- a/src/include/utils/inet.h +++ b/src/include/utils/inet.h @@ -4,7 +4,7 @@ * Declarations for operations on INET datatypes. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/inet.h @@ -28,10 +28,12 @@ typedef struct } inet_struct; /* + * We use these values for the "family" field. + * * 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 + * dump/reload requirement. Pre-7.4 databases used AF_INET for the family * type on disk. */ #define PGSQL_AF_INET (AF_INET + 0) @@ -100,42 +102,48 @@ typedef struct macaddr } macaddr; /* + * This is the internal storage format for MAC8 addresses: + */ +typedef struct macaddr8 +{ + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; + unsigned char e; + unsigned char f; + unsigned char g; + unsigned char h; +} macaddr8; + +/* * 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) +/* obsolescent variants */ +#define DatumGetInetP(X) ((inet *) PG_DETOAST_DATUM(X)) +#define PG_GETARG_INET_P(n) DatumGetInetP(PG_GETARG_DATUM(n)) + /* 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) +/* macaddr8 is a fixed-length pass-by-reference datatype */ +#define DatumGetMacaddr8P(X) ((macaddr8 *) DatumGetPointer(X)) +#define Macaddr8PGetDatum(X) PointerGetDatum(X) +#define PG_GETARG_MACADDR8_P(n) DatumGetMacaddr8P(PG_GETARG_DATUM(n)) +#define PG_RETURN_MACADDR8_P(x) return Macaddr8PGetDatum(x) + /* * Support functions in network.c */ +extern inet *cidr_set_masklen_internal(const inet *src, int bits); extern int bitncmp(const unsigned char *l, const unsigned char *r, int n); extern int bitncommon(const unsigned char *l, const unsigned char *r, int n); -/* - * GiST support functions in network_gist.c - */ -extern Datum inet_gist_fetch(PG_FUNCTION_ARGS); -extern Datum inet_gist_consistent(PG_FUNCTION_ARGS); -extern Datum inet_gist_union(PG_FUNCTION_ARGS); -extern Datum inet_gist_compress(PG_FUNCTION_ARGS); -extern Datum inet_gist_decompress(PG_FUNCTION_ARGS); -extern Datum inet_gist_penalty(PG_FUNCTION_ARGS); -extern Datum inet_gist_picksplit(PG_FUNCTION_ARGS); -extern Datum inet_gist_same(PG_FUNCTION_ARGS); - -/* - * Estimation functions in network_selfuncs.c - */ -extern Datum networksel(PG_FUNCTION_ARGS); -extern Datum networkjoinsel(PG_FUNCTION_ARGS); - #endif /* INET_H */ diff --git a/src/include/utils/int8.h b/src/include/utils/int8.h index 2bafa2dc2d..c58ee048cf 100644 --- a/src/include/utils/int8.h +++ b/src/include/utils/int8.h @@ -4,7 +4,7 @@ * Declarations for operations on 64-bit integers. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/int8.h @@ -20,110 +20,6 @@ #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 int8dec(PG_FUNCTION_ARGS); -extern Datum int8inc_any(PG_FUNCTION_ARGS); -extern Datum int8inc_float8_float8(PG_FUNCTION_ARGS); -extern Datum int8dec_any(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 */ diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h index 122fef29c8..afbe354b4d 100644 --- a/src/include/utils/inval.h +++ b/src/include/utils/inval.h @@ -4,7 +4,7 @@ * POSTGRES cache invalidation dispatcher definitions. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/inval.h @@ -43,6 +43,8 @@ extern void CacheInvalidateCatalog(Oid catalogId); extern void CacheInvalidateRelcache(Relation relation); +extern void CacheInvalidateRelcacheAll(void); + extern void CacheInvalidateRelcacheByTuple(HeapTuple classTuple); extern void CacheInvalidateRelcacheByRelid(Oid relid); diff --git a/src/include/utils/json.h b/src/include/utils/json.h index 9dd9dff2f6..0a749b90c8 100644 --- a/src/include/utils/json.h +++ b/src/include/utils/json.h @@ -3,7 +3,7 @@ * json.h * Declarations for JSON data type support. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/json.h @@ -14,73 +14,9 @@ #ifndef JSON_H #define JSON_H -#include "fmgr.h" #include "lib/stringinfo.h" /* functions in json.c */ -extern Datum json_in(PG_FUNCTION_ARGS); -extern Datum json_out(PG_FUNCTION_ARGS); -extern Datum json_recv(PG_FUNCTION_ARGS); -extern Datum json_send(PG_FUNCTION_ARGS); -extern Datum array_to_json(PG_FUNCTION_ARGS); -extern Datum array_to_json_pretty(PG_FUNCTION_ARGS); -extern Datum row_to_json(PG_FUNCTION_ARGS); -extern Datum row_to_json_pretty(PG_FUNCTION_ARGS); -extern Datum to_json(PG_FUNCTION_ARGS); - -extern Datum json_agg_transfn(PG_FUNCTION_ARGS); -extern Datum json_agg_finalfn(PG_FUNCTION_ARGS); - -extern Datum json_object_agg_finalfn(PG_FUNCTION_ARGS); -extern Datum json_object_agg_transfn(PG_FUNCTION_ARGS); - -extern Datum json_build_object(PG_FUNCTION_ARGS); -extern Datum json_build_object_noargs(PG_FUNCTION_ARGS); -extern Datum json_build_array(PG_FUNCTION_ARGS); -extern Datum json_build_array_noargs(PG_FUNCTION_ARGS); - -extern Datum json_object(PG_FUNCTION_ARGS); -extern Datum json_object_two_arg(PG_FUNCTION_ARGS); - extern void escape_json(StringInfo buf, const char *str); -extern Datum json_typeof(PG_FUNCTION_ARGS); - -/* functions in jsonfuncs.c */ -extern Datum json_object_field(PG_FUNCTION_ARGS); -extern Datum json_object_field_text(PG_FUNCTION_ARGS); -extern Datum json_array_element(PG_FUNCTION_ARGS); -extern Datum json_array_element_text(PG_FUNCTION_ARGS); -extern Datum json_extract_path(PG_FUNCTION_ARGS); -extern Datum json_extract_path_text(PG_FUNCTION_ARGS); -extern Datum json_object_keys(PG_FUNCTION_ARGS); -extern Datum json_array_length(PG_FUNCTION_ARGS); -extern Datum json_each(PG_FUNCTION_ARGS); -extern Datum json_each_text(PG_FUNCTION_ARGS); -extern Datum json_array_elements(PG_FUNCTION_ARGS); -extern Datum json_array_elements_text(PG_FUNCTION_ARGS); -extern Datum json_populate_record(PG_FUNCTION_ARGS); -extern Datum json_populate_recordset(PG_FUNCTION_ARGS); -extern Datum json_to_record(PG_FUNCTION_ARGS); -extern Datum json_to_recordset(PG_FUNCTION_ARGS); -extern Datum json_strip_nulls(PG_FUNCTION_ARGS); - -extern Datum jsonb_object_field(PG_FUNCTION_ARGS); -extern Datum jsonb_object_field_text(PG_FUNCTION_ARGS); -extern Datum jsonb_array_element(PG_FUNCTION_ARGS); -extern Datum jsonb_array_element_text(PG_FUNCTION_ARGS); -extern Datum jsonb_extract_path(PG_FUNCTION_ARGS); -extern Datum jsonb_extract_path_text(PG_FUNCTION_ARGS); -extern Datum jsonb_object_keys(PG_FUNCTION_ARGS); -extern Datum jsonb_array_length(PG_FUNCTION_ARGS); -extern Datum jsonb_each(PG_FUNCTION_ARGS); -extern Datum jsonb_each_text(PG_FUNCTION_ARGS); -extern Datum jsonb_array_elements_text(PG_FUNCTION_ARGS); -extern Datum jsonb_array_elements(PG_FUNCTION_ARGS); -extern Datum jsonb_populate_record(PG_FUNCTION_ARGS); -extern Datum jsonb_populate_recordset(PG_FUNCTION_ARGS); -extern Datum jsonb_to_record(PG_FUNCTION_ARGS); -extern Datum jsonb_to_recordset(PG_FUNCTION_ARGS); -extern Datum jsonb_strip_nulls(PG_FUNCTION_ARGS); - #endif /* JSON_H */ diff --git a/src/include/utils/jsonapi.h b/src/include/utils/jsonapi.h index b041fa4ed3..44ee36931e 100644 --- a/src/include/utils/jsonapi.h +++ b/src/include/utils/jsonapi.h @@ -3,7 +3,7 @@ * jsonapi.h * Declarations for JSON API support. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/jsonapi.h @@ -14,6 +14,7 @@ #ifndef JSONAPI_H #define JSONAPI_H +#include "jsonb.h" #include "lib/stringinfo.h" typedef enum @@ -127,8 +128,23 @@ extern JsonLexContext *makeJsonLexContextCstringLen(char *json, /* * Utility function to check if a string is a valid JSON number. * - * str agrument does not need to be nul-terminated. + * str argument does not need to be nul-terminated. */ extern bool IsValidJsonNumber(const char *str, int len); +/* an action that will be applied to each value in iterate_json(b)_string_vaues functions */ +typedef void (*JsonIterateStringValuesAction) (void *state, char *elem_value, int elem_len); + +/* an action that will be applied to each value in transform_json(b)_string_values functions */ +typedef text *(*JsonTransformStringValuesAction) (void *state, char *elem_value, int elem_len); + +extern void iterate_jsonb_string_values(Jsonb *jb, void *state, + JsonIterateStringValuesAction action); +extern void iterate_json_string_values(text *json, void *action_state, + JsonIterateStringValuesAction action); +extern Jsonb *transform_jsonb_string_values(Jsonb *jsonb, void *action_state, + JsonTransformStringValuesAction transform_action); +extern text *transform_json_string_values(text *json, void *action_state, + JsonTransformStringValuesAction transform_action); + #endif /* JSONAPI_H */ diff --git a/src/include/utils/jsonb.h b/src/include/utils/jsonb.h index fa52afcb5c..411e158d6c 100644 --- a/src/include/utils/jsonb.h +++ b/src/include/utils/jsonb.h @@ -3,7 +3,7 @@ * jsonb.h * Declarations for jsonb data type support. * - * Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Copyright (c) 1996-2017, PostgreSQL Global Development Group * * src/include/utils/jsonb.h * @@ -205,6 +205,12 @@ typedef struct JsonbContainer #define JB_FOBJECT 0x20000000 #define JB_FARRAY 0x40000000 +/* convenience macros for accessing a JsonbContainer struct */ +#define JsonContainerSize(jc) ((jc)->header & JB_CMASK) +#define JsonContainerIsScalar(jc) (((jc)->header & JB_FSCALAR) != 0) +#define JsonContainerIsObject(jc) (((jc)->header & JB_FOBJECT) != 0) +#define JsonContainerIsArray(jc) (((jc)->header & JB_FARRAY) != 0) + /* The top-level on-disk format for a jsonb datum. */ typedef struct { @@ -213,12 +219,26 @@ typedef struct } Jsonb; /* convenience macros for accessing the root container in a Jsonb datum */ -#define JB_ROOT_COUNT(jbp_) ( *(uint32*) VARDATA(jbp_) & JB_CMASK) -#define JB_ROOT_IS_SCALAR(jbp_) ( *(uint32*) VARDATA(jbp_) & JB_FSCALAR) -#define JB_ROOT_IS_OBJECT(jbp_) ( *(uint32*) VARDATA(jbp_) & JB_FOBJECT) -#define JB_ROOT_IS_ARRAY(jbp_) ( *(uint32*) VARDATA(jbp_) & JB_FARRAY) +#define JB_ROOT_COUNT(jbp_) (*(uint32 *) VARDATA(jbp_) & JB_CMASK) +#define JB_ROOT_IS_SCALAR(jbp_) ((*(uint32 *) VARDATA(jbp_) & JB_FSCALAR) != 0) +#define JB_ROOT_IS_OBJECT(jbp_) ((*(uint32 *) VARDATA(jbp_) & JB_FOBJECT) != 0) +#define JB_ROOT_IS_ARRAY(jbp_) ((*(uint32 *) VARDATA(jbp_) & JB_FARRAY) != 0) +enum jbvType +{ + /* Scalar types */ + jbvNull = 0x0, + jbvString, + jbvNumeric, + jbvBool, + /* Composite types */ + jbvArray = 0x10, + jbvObject, + /* Binary (i.e. struct Jsonb) jbvArray/jbvObject */ + jbvBinary +}; + /* * JsonbValue: In-memory representation of Jsonb. This is a convenient * deserialized representation, that can easily support using the "val" @@ -227,19 +247,7 @@ typedef struct */ struct JsonbValue { - enum - { - /* Scalar types */ - jbvNull = 0x0, - jbvString, - jbvNumeric, - jbvBool, - /* Composite types */ - jbvArray = 0x10, - jbvObject, - /* Binary (i.e. struct Jsonb) jbvArray/jbvObject */ - jbvBinary - } type; /* Influences sort order */ + enum jbvType type; /* Influences sort order */ union { @@ -343,73 +351,6 @@ typedef struct JsonbIterator struct JsonbIterator *parent; } JsonbIterator; -/* I/O routines */ -extern Datum jsonb_in(PG_FUNCTION_ARGS); -extern Datum jsonb_out(PG_FUNCTION_ARGS); -extern Datum jsonb_recv(PG_FUNCTION_ARGS); -extern Datum jsonb_send(PG_FUNCTION_ARGS); -extern Datum jsonb_typeof(PG_FUNCTION_ARGS); - -/* generator routines */ -extern Datum to_jsonb(PG_FUNCTION_ARGS); - -extern Datum jsonb_build_object(PG_FUNCTION_ARGS); -extern Datum jsonb_build_object_noargs(PG_FUNCTION_ARGS); -extern Datum jsonb_build_array(PG_FUNCTION_ARGS); -extern Datum jsonb_build_array_noargs(PG_FUNCTION_ARGS); -extern Datum jsonb_object(PG_FUNCTION_ARGS); -extern Datum jsonb_object_two_arg(PG_FUNCTION_ARGS); - -/* jsonb_agg, json_object_agg functions */ -extern Datum jsonb_agg_transfn(PG_FUNCTION_ARGS); -extern Datum jsonb_agg_finalfn(PG_FUNCTION_ARGS); -extern Datum jsonb_object_agg_transfn(PG_FUNCTION_ARGS); -extern Datum jsonb_object_agg_finalfn(PG_FUNCTION_ARGS); - -/* Indexing-related ops */ -extern Datum jsonb_exists(PG_FUNCTION_ARGS); -extern Datum jsonb_exists_any(PG_FUNCTION_ARGS); -extern Datum jsonb_exists_all(PG_FUNCTION_ARGS); -extern Datum jsonb_contains(PG_FUNCTION_ARGS); -extern Datum jsonb_contained(PG_FUNCTION_ARGS); -extern Datum jsonb_ne(PG_FUNCTION_ARGS); -extern Datum jsonb_lt(PG_FUNCTION_ARGS); -extern Datum jsonb_gt(PG_FUNCTION_ARGS); -extern Datum jsonb_le(PG_FUNCTION_ARGS); -extern Datum jsonb_ge(PG_FUNCTION_ARGS); -extern Datum jsonb_eq(PG_FUNCTION_ARGS); -extern Datum jsonb_cmp(PG_FUNCTION_ARGS); -extern Datum jsonb_hash(PG_FUNCTION_ARGS); - -/* GIN support functions for jsonb_ops */ -extern Datum gin_compare_jsonb(PG_FUNCTION_ARGS); -extern Datum gin_extract_jsonb(PG_FUNCTION_ARGS); -extern Datum gin_extract_jsonb_query(PG_FUNCTION_ARGS); -extern Datum gin_consistent_jsonb(PG_FUNCTION_ARGS); -extern Datum gin_triconsistent_jsonb(PG_FUNCTION_ARGS); - -/* GIN support functions for jsonb_path_ops */ -extern Datum gin_extract_jsonb_path(PG_FUNCTION_ARGS); -extern Datum gin_extract_jsonb_query_path(PG_FUNCTION_ARGS); -extern Datum gin_consistent_jsonb_path(PG_FUNCTION_ARGS); -extern Datum gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS); - -/* pretty printer, returns text */ -extern Datum jsonb_pretty(PG_FUNCTION_ARGS); - -/* concatenation */ -extern Datum jsonb_concat(PG_FUNCTION_ARGS); - -/* deletion */ -extern Datum jsonb_delete(PG_FUNCTION_ARGS); -extern Datum jsonb_delete_idx(PG_FUNCTION_ARGS); -extern Datum jsonb_delete_path(PG_FUNCTION_ARGS); - -/* replacement */ -extern Datum jsonb_set(PG_FUNCTION_ARGS); - -/* insert after or before (for arrays) */ -extern Datum jsonb_insert(PG_FUNCTION_ARGS); /* Support functions */ extern uint32 getJsonbOffset(const JsonbContainer *jc, int index); diff --git a/src/include/utils/logtape.h b/src/include/utils/logtape.h index fa1e992082..e802c4b213 100644 --- a/src/include/utils/logtape.h +++ b/src/include/utils/logtape.h @@ -5,7 +5,7 @@ * * See logtape.c for explanations. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/logtape.h @@ -31,11 +31,13 @@ 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 LogicalTapeRewindForRead(LogicalTapeSet *lts, int tapenum, + size_t buffer_size); +extern void LogicalTapeRewindForWrite(LogicalTapeSet *lts, int tapenum); extern void LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum); -extern bool LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum, +extern size_t LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum, size_t size); -extern bool LogicalTapeSeek(LogicalTapeSet *lts, int tapenum, +extern void LogicalTapeSeek(LogicalTapeSet *lts, int tapenum, long blocknum, int offset); extern void LogicalTapeTell(LogicalTapeSet *lts, int tapenum, long *blocknum, int *offset); diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index f72233c335..8da59bbf3e 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -4,7 +4,7 @@ * Convenience routines for common queries in the system catalog cache. * * Portions Copyright (c) 2012-2014, TransLattice, Inc. - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/lsyscache.h @@ -36,6 +36,28 @@ typedef enum IOFuncSelector IOFunc_send } IOFuncSelector; +/* Flag bits for get_attstatsslot */ +#define ATTSTATSSLOT_VALUES 0x01 +#define ATTSTATSSLOT_NUMBERS 0x02 + +/* Result struct for get_attstatsslot */ +typedef struct AttStatsSlot +{ + /* Always filled: */ + Oid staop; /* Actual staop for the found slot */ + /* Filled if ATTSTATSSLOT_VALUES is specified: */ + Oid valuetype; /* Actual datatype of the values */ + Datum *values; /* slot's "values" array, or NULL if none */ + int nvalues; /* length of values[], or 0 */ + /* Filled if ATTSTATSSLOT_NUMBERS is specified: */ + float4 *numbers; /* slot's "numbers" array, or NULL if none */ + int nnumbers; /* length of numbers[], or 0 */ + + /* Remaining fields are private to get_attstatsslot/free_attstatsslot */ + void *values_arr; /* palloc'd values array, if any */ + void *numbers_arr; /* palloc'd numbers array, if any */ +} AttStatsSlot; + /* 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; @@ -65,6 +87,7 @@ extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, 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 char get_attidentity(Oid relid, AttrNumber attnum); extern Oid get_atttype(Oid relid, AttrNumber attnum); extern int32 get_atttypmod(Oid relid, AttrNumber attnum); extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum, @@ -167,18 +190,13 @@ extern bool is_pgxc_nodeprimary(Oid nodeid); extern Oid get_pgxc_groupoid(const char *groupname); extern int get_pgxc_groupmembers(Oid groupid, Oid **members); extern int get_pgxc_classnodes(Oid tableid, Oid **nodes); +extern char * get_pgxc_groupname(Oid groupid); #endif 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 bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple, + int reqkind, Oid reqop, int flags); +extern void free_attstatsslot(AttStatsSlot *sslot); extern char *get_namespace_name(Oid nspid); #ifdef XCP extern Oid get_namespaceid(const char *nspname); diff --git a/src/include/utils/memdebug.h b/src/include/utils/memdebug.h index 96b5baf5a0..206e6ce002 100644 --- a/src/include/utils/memdebug.h +++ b/src/include/utils/memdebug.h @@ -7,7 +7,7 @@ * empty definitions for Valgrind client request macros we use. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/memdebug.h @@ -31,4 +31,52 @@ #define VALGRIND_MEMPOOL_CHANGE(context, optr, nptr, size) do {} while (0) #endif + +#ifdef CLOBBER_FREED_MEMORY + +/* Wipe freed memory for debugging purposes */ +static inline void +wipe_mem(void *ptr, size_t size) +{ + VALGRIND_MAKE_MEM_UNDEFINED(ptr, size); + memset(ptr, 0x7F, size); + VALGRIND_MAKE_MEM_NOACCESS(ptr, size); +} + +#endif /* CLOBBER_FREED_MEMORY */ + +#ifdef MEMORY_CONTEXT_CHECKING + +static inline void +set_sentinel(void *base, Size offset) +{ + char *ptr = (char *) base + offset; + + VALGRIND_MAKE_MEM_UNDEFINED(ptr, 1); + *ptr = 0x7E; + VALGRIND_MAKE_MEM_NOACCESS(ptr, 1); +} + +static inline bool +sentinel_ok(const void *base, Size offset) +{ + const char *ptr = (const char *) base + offset; + bool ret; + + VALGRIND_MAKE_MEM_DEFINED(ptr, 1); + ret = *ptr == 0x7E; + VALGRIND_MAKE_MEM_NOACCESS(ptr, 1); + + return ret; +} + +#endif /* MEMORY_CONTEXT_CHECKING */ + +#ifdef RANDOMIZE_ALLOCATED_MEMORY + +void randomize_mem(char *ptr, size_t size); + +#endif /* RANDOMIZE_ALLOCATED_MEMORY */ + + #endif /* MEMDEBUG_H */ diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index ae07705b6b..58e816d8e9 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -7,7 +7,7 @@ * of the API of the memory management subsystem. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/memutils.h @@ -45,27 +45,6 @@ #define AllocHugeSizeIsValid(size) ((Size) (size) <= MaxAllocHugeSize) -/* - * 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. @@ -100,7 +79,6 @@ extern void MemoryContextDeleteChildren(MemoryContext context); extern void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent); extern Size GetMemoryChunkSpace(void *pointer); -extern MemoryContext GetMemoryChunkContext(void *pointer); extern MemoryContext MemoryContextGetParent(MemoryContext context); extern bool MemoryContextIsEmpty(MemoryContext context); extern void MemoryContextStats(MemoryContext context); @@ -114,6 +92,42 @@ extern void MemoryContextCheck(MemoryContext context); extern bool MemoryContextContains(MemoryContext context, void *pointer); /* + * GetMemoryChunkContext + * Given a currently-allocated chunk, determine the context + * it belongs to. + * + * All chunks allocated by any memory context manager are required to be + * preceded by the corresponding MemoryContext stored, without padding, in the + * preceding sizeof(void*) bytes. A currently-allocated chunk must contain a + * backpointer to its owning context. The backpointer is used by pfree() and + * repalloc() to find the context to call. + */ +#ifndef FRONTEND +static inline MemoryContext +GetMemoryChunkContext(void *pointer) +{ + MemoryContext context; + + /* + * Try to detect bogus pointers handed to us, poorly though we can. + * Presumably, a pointer that isn't MAXALIGNED isn't pointing at an + * allocated chunk. + */ + Assert(pointer != NULL); + Assert(pointer == (void *) MAXALIGN(pointer)); + + /* + * OK, it's probably safe to look at the context. + */ + context = *(MemoryContext *) (((char *) pointer) - sizeof(void *)); + + AssertArg(MemoryContextIsValid(context)); + + return context; +} +#endif + +/* * 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. @@ -135,6 +149,12 @@ extern MemoryContext AllocSetContextCreate(MemoryContext parent, Size initBlockSize, Size maxBlockSize); +/* slab.c */ +extern MemoryContext SlabContextCreate(MemoryContext parent, + const char *name, + Size blockSize, + Size chunkSize); + /* * Recommended default alloc parameters, suitable for "ordinary" contexts * that might hold quite a lot of data. @@ -142,14 +162,26 @@ extern MemoryContext AllocSetContextCreate(MemoryContext parent, #define ALLOCSET_DEFAULT_MINSIZE 0 #define ALLOCSET_DEFAULT_INITSIZE (8 * 1024) #define ALLOCSET_DEFAULT_MAXSIZE (8 * 1024 * 1024) +#define ALLOCSET_DEFAULT_SIZES \ + ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE /* - * Recommended alloc parameters for "small" contexts that are not expected + * Recommended alloc parameters for "small" contexts that are never 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) +#define ALLOCSET_SMALL_SIZES \ + ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_SMALL_MAXSIZE + +/* + * Recommended alloc parameters for contexts that should start out small, + * but might sometimes grow big. + */ +#define ALLOCSET_START_SMALL_SIZES \ + ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE + /* * Threshold above which a request in an AllocSet context is certain to be @@ -159,4 +191,7 @@ extern MemoryContext AllocSetContextCreate(MemoryContext parent, */ #define ALLOCSET_SEPARATE_THRESHOLD 8192 +#define SLAB_DEFAULT_BLOCK_SIZE (8 * 1024) +#define SLAB_LARGE_BLOCK_SIZE (8 * 1024 * 1024) + #endif /* MEMUTILS_H */ diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h index d06f6f82e7..4b0706a316 100644 --- a/src/include/utils/nabstime.h +++ b/src/include/utils/nabstime.h @@ -4,7 +4,7 @@ * Definitions for the "new" abstime code. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/nabstime.h @@ -96,69 +96,6 @@ typedef TimeIntervalData *TimeInterval; ((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); diff --git a/src/include/utils/numeric.h b/src/include/utils/numeric.h index 6c1808ec71..0ab57d7025 100644 --- a/src/include/utils/numeric.h +++ b/src/include/utils/numeric.h @@ -5,7 +5,7 @@ * * Original coding 1998, Jan Wieck. Heavily revised 2003, Tom Lane. * - * Copyright (c) 1998-2016, PostgreSQL Global Development Group + * Copyright (c) 1998-2017, PostgreSQL Global Development Group * * src/include/utils/numeric.h * diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h index 9be59d1055..2e07bd57ad 100644 --- a/src/include/utils/palloc.h +++ b/src/include/utils/palloc.h @@ -18,7 +18,7 @@ * everything that should be freed. See utils/mmgr/README for more info. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/palloc.h @@ -127,6 +127,8 @@ extern char *MemoryContextStrdup(MemoryContext context, const char *string); extern char *pstrdup(const char *in); extern char *pnstrdup(const char *in, Size len); +extern char *pchomp(const char *in); + /* sprintf into a palloc'd buffer --- these are in psprintf.c */ extern char *psprintf(const char *fmt,...) pg_attribute_printf(1, 2); extern size_t pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) pg_attribute_printf(3, 0); diff --git a/src/include/utils/pg_crc.h b/src/include/utils/pg_crc.h index a9401f9bd7..2fe083850a 100644 --- a/src/include/utils/pg_crc.h +++ b/src/include/utils/pg_crc.h @@ -26,7 +26,7 @@ * * The CRC-32C variant is in port/pg_crc32c.h. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/pg_crc.h diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h index 0a4b9f7bd2..f0acc86b88 100644 --- a/src/include/utils/pg_locale.h +++ b/src/include/utils/pg_locale.h @@ -4,7 +4,7 @@ * * src/include/utils/pg_locale.h * - * Copyright (c) 2002-2016, PostgreSQL Global Development Group + * Copyright (c) 2002-2017, PostgreSQL Global Development Group * *----------------------------------------------------------------------- */ @@ -12,10 +12,12 @@ #ifndef _PG_LOCALE_ #define _PG_LOCALE_ -#include <locale.h> #if defined(LOCALE_T_IN_XLOCALE) || defined(WCSTOMBS_L_IN_XLOCALE) #include <xlocale.h> #endif +#ifdef USE_ICU +#include <unicode/ucol.h> +#endif #include "utils/guc.h" @@ -62,17 +64,38 @@ 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. + * pg_locale_t is occasionally checked for truth, so make it a pointer. */ +struct pg_locale_struct +{ + char provider; + union + { #ifdef HAVE_LOCALE_T -typedef locale_t pg_locale_t; -#else -typedef int pg_locale_t; + locale_t lt; +#endif +#ifdef USE_ICU + struct + { + const char *locale; + UCollator *ucol; + } icu; #endif + int dummy; /* in case we have neither LOCALE_T nor ICU */ + } info; +}; + +typedef struct pg_locale_struct *pg_locale_t; extern pg_locale_t pg_newlocale_from_collation(Oid collid); +extern char *get_collation_actual_version(char collprovider, const char *collcollate); + +#ifdef USE_ICU +extern int32_t icu_to_uchar(UChar **buff_uchar, const char *buff, size_t nbytes); +extern int32_t icu_from_uchar(char **result, UChar *buff_uchar, int32_t len_uchar); +#endif + /* 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, diff --git a/src/include/utils/pg_lsn.h b/src/include/utils/pg_lsn.h index 772fd6adf5..6f038e9e14 100644 --- a/src/include/utils/pg_lsn.h +++ b/src/include/utils/pg_lsn.h @@ -5,7 +5,7 @@ * PostgreSQL. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/pg_lsn.h @@ -18,22 +18,6 @@ #include "fmgr.h" #include "access/xlogdefs.h" -extern Datum pg_lsn_in(PG_FUNCTION_ARGS); -extern Datum pg_lsn_out(PG_FUNCTION_ARGS); -extern Datum pg_lsn_recv(PG_FUNCTION_ARGS); -extern Datum pg_lsn_send(PG_FUNCTION_ARGS); - -extern Datum pg_lsn_eq(PG_FUNCTION_ARGS); -extern Datum pg_lsn_ne(PG_FUNCTION_ARGS); -extern Datum pg_lsn_lt(PG_FUNCTION_ARGS); -extern Datum pg_lsn_gt(PG_FUNCTION_ARGS); -extern Datum pg_lsn_le(PG_FUNCTION_ARGS); -extern Datum pg_lsn_ge(PG_FUNCTION_ARGS); -extern Datum pg_lsn_cmp(PG_FUNCTION_ARGS); -extern Datum pg_lsn_hash(PG_FUNCTION_ARGS); - -extern Datum pg_lsn_mi(PG_FUNCTION_ARGS); - #define DatumGetLSN(X) ((XLogRecPtr) DatumGetInt64(X)) #define LSNGetDatum(X) (Int64GetDatum((int64) (X))) diff --git a/src/include/utils/pg_rusage.h b/src/include/utils/pg_rusage.h index 7c264eb6b1..48a74e90ba 100644 --- a/src/include/utils/pg_rusage.h +++ b/src/include/utils/pg_rusage.h @@ -4,7 +4,7 @@ * header file for resource usage measurement support routines * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/pg_rusage.h diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h index 41b10ab372..fbb271ed1c 100644 --- a/src/include/utils/plancache.h +++ b/src/include/utils/plancache.h @@ -6,7 +6,7 @@ * See plancache.c for comments. * * Portions Copyright (c) 2012-2014, TransLattice, Inc. - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/plancache.h @@ -18,6 +18,10 @@ #include "access/tupdesc.h" #include "nodes/params.h" +#include "utils/queryenvironment.h" + +/* Forward declaration, to avoid including parsenodes.h here */ +struct RawStmt; #define CACHEDPLANSOURCE_MAGIC 195726186 #define CACHEDPLAN_MAGIC 953717834 @@ -77,7 +81,7 @@ typedef struct CachedPlanSource { int magic; /* should equal CACHEDPLANSOURCE_MAGIC */ - Node *raw_parse_tree; /* output of raw_parser(), or NULL */ + struct RawStmt *raw_parse_tree; /* output of raw_parser(), or NULL */ const char *query_string; /* source text of query */ const char *commandTag; /* command tag (a constant!), or NULL */ Oid *param_types; /* array of parameter type OIDs, or NULL */ @@ -130,8 +134,7 @@ typedef struct CachedPlanSource typedef struct CachedPlan { int magic; /* should equal CACHEDPLAN_MAGIC */ - List *stmt_list; /* list of statement nodes (PlannedStmts and - * bare utility statements) */ + List *stmt_list; /* list of PlannedStmts */ bool is_oneshot; /* is it a "oneshot" plan? */ bool is_saved; /* is CachedPlan in a long-lived context? */ bool is_valid; /* is the stmt_list currently valid? */ @@ -148,13 +151,13 @@ typedef struct CachedPlan extern void InitPlanCache(void); extern void ResetPlanCache(void); -extern CachedPlanSource *CreateCachedPlan(Node *raw_parse_tree, +extern CachedPlanSource *CreateCachedPlan(struct RawStmt *raw_parse_tree, const char *query_string, #ifdef PGXC const char *stmt_name, #endif const char *commandTag); -extern CachedPlanSource *CreateOneShotCachedPlan(Node *raw_parse_tree, +extern CachedPlanSource *CreateOneShotCachedPlan(struct RawStmt *raw_parse_tree, const char *query_string, const char *commandTag); extern void CompleteCachedPlan(CachedPlanSource *plansource, @@ -177,11 +180,13 @@ extern CachedPlanSource *CopyCachedPlan(CachedPlanSource *plansource); extern bool CachedPlanIsValid(CachedPlanSource *plansource); -extern List *CachedPlanGetTargetList(CachedPlanSource *plansource); +extern List *CachedPlanGetTargetList(CachedPlanSource *plansource, + QueryEnvironment *queryEnv); extern CachedPlan *GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams, - bool useResOwner); + bool useResOwner, + QueryEnvironment *queryEnv); extern void ReleaseCachedPlan(CachedPlan *plan, bool useResOwner); #ifdef XCP extern void SetRemoteSubplan(CachedPlanSource *plansource, diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index ba11a5cf5f..c9ce886483 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -37,7 +37,7 @@ * * * Portions Copyright (c) 2012-2014, TransLattice, Inc. - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/portal.h @@ -138,14 +138,16 @@ typedef struct PortalData /* 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 */ + List *stmts; /* list of PlannedStmts */ CachedPlan *cplan; /* CachedPlan, if stmts are from one */ ParamListInfo portalParams; /* params to pass to query */ + QueryEnvironment *queryEnv; /* environment for query */ /* Features/options */ PortalStrategy strategy; /* see above */ int cursorOptions; /* DECLARE CURSOR option bits */ + bool run_once; /* portal will only be run once */ /* Status data */ PortalStatus status; /* see above */ @@ -209,7 +211,6 @@ typedef struct PortalData */ #define PortalGetQueryDesc(portal) ((portal)->queryDesc) #define PortalGetHeapMemory(portal) ((portal)->heap) -#define PortalGetPrimaryStmt(portal) PortalListGetPrimaryStmt((portal)->stmts) /* Prototypes for functions in utils/mmgr/portalmem.c */ @@ -240,7 +241,7 @@ extern void PortalDefineQuery(Portal portal, const char *commandTag, List *stmts, CachedPlan *cplan); -extern Node *PortalListGetPrimaryStmt(List *stmts); +extern PlannedStmt *PortalGetPrimaryStmt(Portal portal); extern void PortalCreateHoldStore(Portal portal); extern void PortalHashTableDeleteAll(void); #ifdef XCP diff --git a/src/include/utils/queryenvironment.h b/src/include/utils/queryenvironment.h new file mode 100644 index 0000000000..291b6fdbc2 --- /dev/null +++ b/src/include/utils/queryenvironment.h @@ -0,0 +1,74 @@ +/*------------------------------------------------------------------------- + * + * queryenvironment.h + * Access to functions to mutate the query environment and retrieve the + * actual data related to entries (if any). + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/utils/queryenvironment.h + * + *------------------------------------------------------------------------- + */ +#ifndef QUERYENVIRONMENT_H +#define QUERYENVIRONMENT_H + +#include "access/tupdesc.h" + + +typedef enum EphemeralNameRelationType +{ + ENR_NAMED_TUPLESTORE /* named tuplestore relation; e.g., deltas */ +} EphemeralNameRelationType; + +/* + * Some ephemeral named relations must match some relation (e.g., trigger + * transition tables), so to properly handle cached plans and DDL, we should + * carry the OID of that relation. In other cases an ENR might be independent + * of any relation which is stored in the system catalogs, so we need to be + * able to directly store the TupleDesc. We never need both. + */ +typedef struct EphemeralNamedRelationMetadataData +{ + char *name; /* name used to identify the relation */ + + /* only one of the next two fields should be used */ + Oid reliddesc; /* oid of relation to get tupdesc */ + TupleDesc tupdesc; /* description of result rows */ + + EphemeralNameRelationType enrtype; /* to identify type of relation */ + double enrtuples; /* estimated number of tuples */ +} EphemeralNamedRelationMetadataData; + +typedef EphemeralNamedRelationMetadataData *EphemeralNamedRelationMetadata; + +/* + * Ephemeral Named Relation data; used for parsing named relations not in the + * catalog, like transition tables in AFTER triggers. + */ +typedef struct EphemeralNamedRelationData +{ + EphemeralNamedRelationMetadataData md; + void *reldata; /* structure for execution-time access to data */ +} EphemeralNamedRelationData; + +typedef EphemeralNamedRelationData *EphemeralNamedRelation; + +/* + * This is an opaque structure outside of queryenvironment.c itself. The + * intention is to be able to change the implementation or add new context + * features without needing to change existing code for use of existing + * features. + */ +typedef struct QueryEnvironment QueryEnvironment; + + +extern QueryEnvironment *create_queryEnv(void); +extern EphemeralNamedRelationMetadata get_visible_ENR_metadata(QueryEnvironment *queryEnv, const char *refname); +extern void register_ENR(QueryEnvironment *queryEnv, EphemeralNamedRelation enr); +extern void unregister_ENR(QueryEnvironment *queryEnv, const char *name); +extern EphemeralNamedRelation get_ENR(QueryEnvironment *queryEnv, const char *name); +extern TupleDesc ENRMetadataGetTupDesc(EphemeralNamedRelationMetadata enrmd); + +#endif /* QUERYENVIRONMENT_H */ diff --git a/src/include/utils/rangetypes.h b/src/include/utils/rangetypes.h index a774ca0e80..abb2223ec5 100644 --- a/src/include/utils/rangetypes.h +++ b/src/include/utils/rangetypes.h @@ -4,7 +4,7 @@ * Declarations for Postgres range types. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/rangetypes.h @@ -92,45 +92,8 @@ typedef struct * prototypes for functions defined in rangetypes.c */ -/* I/O */ -extern Datum range_in(PG_FUNCTION_ARGS); -extern Datum range_out(PG_FUNCTION_ARGS); -extern Datum range_recv(PG_FUNCTION_ARGS); -extern Datum range_send(PG_FUNCTION_ARGS); - -/* constructors */ -extern Datum range_constructor2(PG_FUNCTION_ARGS); -extern Datum range_constructor3(PG_FUNCTION_ARGS); - -/* range -> subtype */ -extern Datum range_lower(PG_FUNCTION_ARGS); -extern Datum range_upper(PG_FUNCTION_ARGS); - -/* range -> bool */ -extern Datum range_empty(PG_FUNCTION_ARGS); -extern Datum range_lower_inc(PG_FUNCTION_ARGS); -extern Datum range_upper_inc(PG_FUNCTION_ARGS); -extern Datum range_lower_inf(PG_FUNCTION_ARGS); -extern Datum range_upper_inf(PG_FUNCTION_ARGS); - -/* range, element -> bool */ -extern Datum range_contains_elem(PG_FUNCTION_ARGS); -extern Datum elem_contained_by_range(PG_FUNCTION_ARGS); - extern bool range_contains_elem_internal(TypeCacheEntry *typcache, RangeType *r, Datum val); -/* range, range -> bool */ -extern Datum range_eq(PG_FUNCTION_ARGS); -extern Datum range_ne(PG_FUNCTION_ARGS); -extern Datum range_contains(PG_FUNCTION_ARGS); -extern Datum range_contained_by(PG_FUNCTION_ARGS); -extern Datum range_before(PG_FUNCTION_ARGS); -extern Datum range_after(PG_FUNCTION_ARGS); -extern Datum range_adjacent(PG_FUNCTION_ARGS); -extern Datum range_overlaps(PG_FUNCTION_ARGS); -extern Datum range_overleft(PG_FUNCTION_ARGS); -extern Datum range_overright(PG_FUNCTION_ARGS); - /* internal versions of the above */ extern bool range_eq_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2); @@ -153,38 +116,6 @@ extern bool range_overleft_internal(TypeCacheEntry *typcache, RangeType *r1, extern bool range_overright_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2); -/* range, range -> range */ -extern Datum range_minus(PG_FUNCTION_ARGS); -extern Datum range_union(PG_FUNCTION_ARGS); -extern Datum range_intersect(PG_FUNCTION_ARGS); - -/* BTree support */ -extern Datum range_cmp(PG_FUNCTION_ARGS); -extern Datum range_lt(PG_FUNCTION_ARGS); -extern Datum range_le(PG_FUNCTION_ARGS); -extern Datum range_ge(PG_FUNCTION_ARGS); -extern Datum range_gt(PG_FUNCTION_ARGS); - -/* Hash support */ -extern Datum hash_range(PG_FUNCTION_ARGS); - -/* ANALYZE support */ -extern Datum range_typanalyze(PG_FUNCTION_ARGS); -extern Datum rangesel(PG_FUNCTION_ARGS); - -/* Canonical functions */ -extern Datum int4range_canonical(PG_FUNCTION_ARGS); -extern Datum int8range_canonical(PG_FUNCTION_ARGS); -extern Datum daterange_canonical(PG_FUNCTION_ARGS); - -/* Subtype Difference functions */ -extern Datum int4range_subdiff(PG_FUNCTION_ARGS); -extern Datum int8range_subdiff(PG_FUNCTION_ARGS); -extern Datum numrange_subdiff(PG_FUNCTION_ARGS); -extern Datum daterange_subdiff(PG_FUNCTION_ARGS); -extern Datum tsrange_subdiff(PG_FUNCTION_ARGS); -extern Datum tstzrange_subdiff(PG_FUNCTION_ARGS); - /* assorted support functions */ extern TypeCacheEntry *range_get_typcache(FunctionCallInfo fcinfo, Oid rngtypid); @@ -205,15 +136,4 @@ extern bool bounds_adjacent(TypeCacheEntry *typcache, RangeBound bound1, RangeBound bound2); extern RangeType *make_empty_range(TypeCacheEntry *typcache); -/* GiST support (in rangetypes_gist.c) */ -extern Datum range_gist_consistent(PG_FUNCTION_ARGS); -extern Datum range_gist_compress(PG_FUNCTION_ARGS); -extern Datum range_gist_decompress(PG_FUNCTION_ARGS); -extern Datum range_gist_fetch(PG_FUNCTION_ARGS); -extern Datum range_gist_union(PG_FUNCTION_ARGS); -extern Datum range_merge(PG_FUNCTION_ARGS); -extern Datum range_gist_penalty(PG_FUNCTION_ARGS); -extern Datum range_gist_picksplit(PG_FUNCTION_ARGS); -extern Datum range_gist_same(PG_FUNCTION_ARGS); - #endif /* RANGETYPES_H */ diff --git a/src/include/utils/regproc.h b/src/include/utils/regproc.h new file mode 100644 index 0000000000..ba46bd7d58 --- /dev/null +++ b/src/include/utils/regproc.h @@ -0,0 +1,28 @@ +/*------------------------------------------------------------------------- + * + * regproc.h + * Functions for the built-in types regproc, regclass, regtype, etc. + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/utils/regproc.h + * + *------------------------------------------------------------------------- + */ +#ifndef REGPROC_H +#define REGPROC_H + +#include "nodes/pg_list.h" + +extern List *stringToQualifiedNameList(const char *string); +extern char *format_procedure(Oid procedure_oid); +extern char *format_procedure_qualified(Oid procedure_oid); +extern void format_procedure_parts(Oid operator_oid, List **objnames, + List **objargs); +extern char *format_operator(Oid operator_oid); +extern char *format_operator_qualified(Oid operator_oid); +extern void format_operator_parts(Oid operator_oid, List **objnames, + List **objargs); + +#endif diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 6145b0ecc1..dd5de58fef 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -5,7 +5,7 @@ * * * Portions Copyright (c) 2012-2014, TransLattice, Inc. - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 2010-2012 Postgres-XC Development Group * @@ -20,6 +20,7 @@ #include "access/xlog.h" #include "catalog/pg_class.h" #include "catalog/pg_index.h" +#include "catalog/pg_publication.h" #include "fmgr.h" #include "nodes/bitmapset.h" #include "pgxc/locator.h" @@ -47,6 +48,35 @@ typedef struct LockInfoData typedef LockInfoData *LockInfo; +/* + * Information about the partition key of a relation + */ +typedef struct PartitionKeyData +{ + char strategy; /* partitioning strategy */ + int16 partnatts; /* number of columns in the partition key */ + AttrNumber *partattrs; /* attribute numbers of columns in the + * partition key */ + List *partexprs; /* list of expressions in the partitioning + * key, or NIL */ + + Oid *partopfamily; /* OIDs of operator families */ + Oid *partopcintype; /* OIDs of opclass declared input data types */ + FmgrInfo *partsupfunc; /* lookup info for support funcs */ + + /* Partitioning collation per attribute */ + Oid *partcollation; + + /* Type information per attribute */ + Oid *parttypid; + int32 *parttypmod; + int16 *parttyplen; + bool *parttypbyval; + char *parttypalign; + Oid *parttypcoll; +} PartitionKeyData; + +typedef struct PartitionKeyData *PartitionKey; /* * Here are the contents of a relation cache entry. @@ -64,6 +94,7 @@ typedef struct RelationData bool rd_isvalid; /* relcache entry is valid */ char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, 1 = * valid, 2 = temporarily forced */ + bool rd_statvalid; /* is rd_statlist valid? */ /* * rd_createSubid is the ID of the highest subtransaction the rel has @@ -96,16 +127,29 @@ typedef struct RelationData List *rd_fkeylist; /* list of ForeignKeyCacheInfo (see below) */ bool rd_fkeyvalid; /* true if list has been computed */ + MemoryContext rd_partkeycxt; /* private memory cxt for the below */ + struct PartitionKeyData *rd_partkey; /* partition key, or NULL */ + MemoryContext rd_pdcxt; /* private context for partdesc */ + struct PartitionDescData *rd_partdesc; /* partitions, or NULL */ + List *rd_partcheck; /* partition CHECK quals */ + /* data managed by RelationGetIndexList: */ List *rd_indexlist; /* list of OIDs of indexes on relation */ Oid rd_oidindex; /* OID of unique index on OID, if any */ + Oid rd_pkindex; /* OID of primary key, if any */ Oid rd_replidindex; /* OID of replica identity index, if any */ + /* data managed by RelationGetStatExtList: */ + List *rd_statlist; /* list of OIDs of extended stats */ + /* data managed by RelationGetIndexAttrBitmap: */ Bitmapset *rd_indexattr; /* identifies columns used in indexes */ Bitmapset *rd_keyattr; /* cols that can be ref'd by foreign keys */ + Bitmapset *rd_pkattr; /* cols included in primary key */ Bitmapset *rd_idattr; /* included in replica identity index */ + PublicationActions *rd_pubactions; /* publication actions */ + /* * 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 @@ -275,7 +319,9 @@ typedef struct StdRdOptions * from the pov of logical decoding. Note multiple eval of argument! */ #define RelationIsUsedAsCatalogTable(relation) \ - ((relation)->rd_options ? \ + ((relation)->rd_options && \ + ((relation)->rd_rel->relkind == RELKIND_RELATION || \ + (relation)->rd_rel->relkind == RELKIND_MATVIEW) ? \ ((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false) /* @@ -585,9 +631,64 @@ typedef struct ViewOptions RelationNeedsWAL(relation) && \ !IsCatalogRelation(relation)) +/* + * RelationGetPartitionKey + * Returns the PartitionKey of a relation + */ +#define RelationGetPartitionKey(relation) ((relation)->rd_partkey) + +/* + * PartitionKey inquiry functions + */ +static inline int +get_partition_strategy(PartitionKey key) +{ + return key->strategy; +} + +static inline int +get_partition_natts(PartitionKey key) +{ + return key->partnatts; +} + +static inline List * +get_partition_exprs(PartitionKey key) +{ + return key->partexprs; +} + +/* + * PartitionKey inquiry functions - one column + */ +static inline int16 +get_partition_col_attnum(PartitionKey key, int col) +{ + return key->partattrs[col]; +} + +static inline Oid +get_partition_col_typid(PartitionKey key, int col) +{ + return key->parttypid[col]; +} + +static inline int32 +get_partition_col_typmod(PartitionKey key, int col) +{ + return key->parttypmod[col]; +} + +/* + * RelationGetPartitionDesc + * Returns partition descriptor for a relation. + */ +#define RelationGetPartitionDesc(relation) ((relation)->rd_partdesc) + /* routines in utils/cache/relcache.c */ extern void RelationIncrementReferenceCount(Relation rel); extern void RelationDecrementReferenceCount(Relation rel); extern bool RelationHasUnloggedIndex(Relation rel); +extern List *RelationGetRepsetList(Relation rel); #endif /* REL_H */ diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index 6ea7dd2510..81af3aebb8 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -4,7 +4,7 @@ * Relation descriptor cache definitions. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/relcache.h @@ -39,7 +39,9 @@ extern void RelationClose(Relation relation); */ extern List *RelationGetFKeyList(Relation relation); extern List *RelationGetIndexList(Relation relation); +extern List *RelationGetStatExtList(Relation relation); extern Oid RelationGetOidIndex(Relation relation); +extern Oid RelationGetPrimaryKeyIndex(Relation relation); extern Oid RelationGetReplicaIndex(Relation relation); extern List *RelationGetIndexExpressions(Relation relation); extern List *RelationGetIndexPredicate(Relation relation); @@ -48,6 +50,7 @@ typedef enum IndexAttrBitmapKind { INDEX_ATTR_BITMAP_ALL, INDEX_ATTR_BITMAP_KEY, + INDEX_ATTR_BITMAP_PRIMARY_KEY, INDEX_ATTR_BITMAP_IDENTITY_KEY } IndexAttrBitmapKind; @@ -64,6 +67,10 @@ extern void RelationSetIndexList(Relation relation, extern void RelationInitIndexAccessInfo(Relation relation); +/* caller must include pg_publication.h */ +struct PublicationActions; +extern struct PublicationActions *GetRelationPublicationActions(Relation relation); + /* * Routines to support ereport() reports of relation-related errors */ diff --git a/src/include/utils/relfilenodemap.h b/src/include/utils/relfilenodemap.h index e3e14feea5..0827ff3db8 100644 --- a/src/include/utils/relfilenodemap.h +++ b/src/include/utils/relfilenodemap.h @@ -3,7 +3,7 @@ * relfilenodemap.h * relfilenode to oid mapping cache. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/relfilenodemap.h diff --git a/src/include/utils/relmapper.h b/src/include/utils/relmapper.h index 22c5118ded..8fb2879ff9 100644 --- a/src/include/utils/relmapper.h +++ b/src/include/utils/relmapper.h @@ -4,7 +4,7 @@ * Catalog-to-filenode mapping * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/relmapper.h diff --git a/src/include/utils/relptr.h b/src/include/utils/relptr.h new file mode 100644 index 0000000000..1e5e622150 --- /dev/null +++ b/src/include/utils/relptr.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + * + * relptr.h + * This file contains basic declarations for relative pointers. + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/utils/relptr.h + * + *------------------------------------------------------------------------- + */ + +#ifndef RELPTR_H +#define RELPTR_H + +/* + * Relative pointers are intended to be used when storing an address that may + * be relative either to the base of the process's address space or some + * dynamic shared memory segment mapped therein. + * + * The idea here is that you declare a relative pointer as relptr(type) + * and then use relptr_access to dereference it and relptr_store to change + * it. The use of a union here is a hack, because what's stored in the + * relptr is always a Size, never an actual pointer. But including a pointer + * in the union allows us to use stupid macro tricks to provide some measure + * of type-safety. + */ +#define relptr(type) union { type *relptr_type; Size relptr_off; } + +/* + * pgindent gets confused by declarations that use "relptr(type)" directly, + * so preferred style is to write + * typedef struct ... SomeStruct; + * relptr_declare(SomeStruct, RelptrSomeStruct); + * and then declare pointer variables as "RelptrSomeStruct someptr". + */ +#define relptr_declare(type, relptrtype) \ + typedef relptr(type) relptrtype + +#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P +#define relptr_access(base, rp) \ + (AssertVariableIsOfTypeMacro(base, char *), \ + (__typeof__((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \ + (base + (rp).relptr_off))) +#else +/* + * If we don't have __builtin_types_compatible_p, assume we might not have + * __typeof__ either. + */ +#define relptr_access(base, rp) \ + (AssertVariableIsOfTypeMacro(base, char *), \ + (void *) ((rp).relptr_off == 0 ? NULL : (base + (rp).relptr_off))) +#endif + +#define relptr_is_null(rp) \ + ((rp).relptr_off == 0) + +#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P +#define relptr_store(base, rp, val) \ + (AssertVariableIsOfTypeMacro(base, char *), \ + AssertVariableIsOfTypeMacro(val, __typeof__((rp).relptr_type)), \ + (rp).relptr_off = ((val) == NULL ? 0 : ((char *) (val)) - (base))) +#else +/* + * If we don't have __builtin_types_compatible_p, assume we might not have + * __typeof__ either. + */ +#define relptr_store(base, rp, val) \ + (AssertVariableIsOfTypeMacro(base, char *), \ + (rp).relptr_off = ((val) == NULL ? 0 : ((char *) (val)) - (base))) +#endif + +#define relptr_copy(rp1, rp2) \ + ((rp1).relptr_off = (rp2).relptr_off) + +#endif /* RELPTR_H */ diff --git a/src/include/utils/reltrigger.h b/src/include/utils/reltrigger.h index e87f2283ec..65d6ecb30a 100644 --- a/src/include/utils/reltrigger.h +++ b/src/include/utils/reltrigger.h @@ -4,7 +4,7 @@ * POSTGRES relation trigger definitions. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/reltrigger.h @@ -39,6 +39,8 @@ typedef struct Trigger int16 *tgattr; char **tgargs; char *tgqual; + char *tgoldtable; + char *tgnewtable; } Trigger; typedef struct TriggerDesc @@ -68,6 +70,11 @@ typedef struct TriggerDesc /* there are no row-level truncate triggers */ bool trig_truncate_before_statement; bool trig_truncate_after_statement; + /* Is there at least one trigger specifying each transition relation? */ + bool trig_insert_new_table; + bool trig_update_old_table; + bool trig_update_new_table; + bool trig_delete_old_table; } TriggerDesc; #endif /* RELTRIGGER_H */ diff --git a/src/include/utils/resowner.h b/src/include/utils/resowner.h index c5abac23a7..ff785e3a3e 100644 --- a/src/include/utils/resowner.h +++ b/src/include/utils/resowner.h @@ -9,7 +9,7 @@ * See utils/resowner/README for more info. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/resowner.h diff --git a/src/include/utils/resowner_private.h b/src/include/utils/resowner_private.h index 1fffec520c..2f763d7539 100644 --- a/src/include/utils/resowner_private.h +++ b/src/include/utils/resowner_private.h @@ -6,7 +6,7 @@ * See utils/resowner/README for more info. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/resowner_private.h diff --git a/src/include/utils/rls.h b/src/include/utils/rls.h index 29d17a4bf5..fa2c44e160 100644 --- a/src/include/utils/rls.h +++ b/src/include/utils/rls.h @@ -4,7 +4,7 @@ * Header file for Row Level Security (RLS) utility commands to be used * with the rowsecurity feature. * - * Copyright (c) 2007-2016, PostgreSQL Global Development Group + * Copyright (c) 2007-2017, PostgreSQL Global Development Group * * src/include/utils/rls.h * diff --git a/src/include/utils/ruleutils.h b/src/include/utils/ruleutils.h index cec24184b0..42fc872c4a 100644 --- a/src/include/utils/ruleutils.h +++ b/src/include/utils/ruleutils.h @@ -3,7 +3,7 @@ * ruleutils.h * Declarations for ruleutils.c * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/ruleutils.h @@ -21,6 +21,8 @@ extern char *pg_get_indexdef_string(Oid indexrelid); extern char *pg_get_indexdef_columns(Oid indexrelid, bool pretty); +extern char *pg_get_partkeydef_columns(Oid relid, bool pretty); + extern char *pg_get_constraintdef_command(Oid constraintId); extern char *deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit); diff --git a/src/include/utils/sampling.h b/src/include/utils/sampling.h index 2b914ebc3e..7edfc4a44d 100644 --- a/src/include/utils/sampling.h +++ b/src/include/utils/sampling.h @@ -3,7 +3,7 @@ * sampling.h * definitions for sampling functions * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/sampling.h diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h index 8e0d317468..958bdba455 100644 --- a/src/include/utils/selfuncs.h +++ b/src/include/utils/selfuncs.h @@ -5,7 +5,7 @@ * infrastructure for selectivity and cost estimation. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/selfuncs.h @@ -72,9 +72,10 @@ typedef struct VariableStatData /* 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 */ + Oid atttype; /* actual type (after stripping relabel) */ + int32 atttypmod; /* actual typmod (after stripping relabel) */ bool isunique; /* matches unique index or DISTINCT clause */ + bool acl_ok; /* result of ACL check on table or column */ } VariableStatData; #define ReleaseVariableStats(vardata) \ @@ -153,6 +154,7 @@ 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 statistic_proc_security_check(VariableStatData *vardata, Oid func_oid); extern bool get_restriction_variable(PlannerInfo *root, List *args, int varRelid, VariableStatData *vardata, Node **other, @@ -180,32 +182,6 @@ extern Pattern_Prefix_Status pattern_fixed_prefix(Const *patt, 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 boolvarsel(PlannerInfo *root, Node *arg, int varRelid); extern Selectivity booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, int varRelid, @@ -245,7 +221,5 @@ extern Selectivity scalararraysel_containment(PlannerInfo *root, Node *leftop, Node *rightop, Oid elemtype, bool isEquality, bool useOr, int varRelid); -extern Datum arraycontsel(PG_FUNCTION_ARGS); -extern Datum arraycontjoinsel(PG_FUNCTION_ARGS); #endif /* SELFUNCS_H */ diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h index 9e3827249e..2a3f8eca34 100644 --- a/src/include/utils/snapmgr.h +++ b/src/include/utils/snapmgr.h @@ -3,7 +3,7 @@ * snapmgr.h * POSTGRES snapshot manager * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/snapmgr.h @@ -51,14 +51,14 @@ extern PGDLLIMPORT int old_snapshot_threshold; extern Size SnapMgrShmemSize(void); extern void SnapMgrInit(void); -extern int64 GetSnapshotCurrentTimestamp(void); -extern int64 GetOldSnapshotThresholdTimestamp(void); +extern TimestampTz GetSnapshotCurrentTimestamp(void); +extern TimestampTz GetOldSnapshotThresholdTimestamp(void); extern bool FirstSnapshotSet; extern TransactionId TransactionXmin; extern TransactionId RecentXmin; -extern TransactionId RecentGlobalXmin; +extern PGDLLIMPORT TransactionId RecentGlobalXmin; extern TransactionId RecentGlobalDataXmin; extern Snapshot GetTransactionSnapshot(void); @@ -69,6 +69,7 @@ extern Snapshot GetOldestSnapshot(void); extern Snapshot GetCatalogSnapshot(Oid relid); extern Snapshot GetNonHistoricCatalogSnapshot(Oid relid); extern void InvalidateCatalogSnapshot(void); +extern void InvalidateCatalogSnapshotConditionally(void); extern void PushActiveSnapshot(Snapshot snapshot); extern void PushCopiedSnapshot(Snapshot snapshot); @@ -84,16 +85,16 @@ extern void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner); extern void AtSubCommit_Snapshot(int level); extern void AtSubAbort_Snapshot(int level); -extern void AtEOXact_Snapshot(bool isCommit); +extern void AtEOXact_Snapshot(bool isCommit, bool resetXmin); -extern Datum pg_export_snapshot(PG_FUNCTION_ARGS); extern void ImportSnapshot(const char *idstr); extern bool XactHasExportedSnapshots(void); extern void DeleteAllExportedSnapshotFiles(void); extern bool ThereAreNoPriorRegisteredSnapshots(void); extern TransactionId TransactionIdLimitedForOldSnapshots(TransactionId recentXmin, Relation relation); -extern void MaintainOldSnapshotTimeMapping(int64 whenTaken, TransactionId xmin); +extern void MaintainOldSnapshotTimeMapping(TimestampTz whenTaken, + TransactionId xmin); extern char *ExportSnapshot(Snapshot snapshot); diff --git a/src/include/utils/snapshot.h b/src/include/utils/snapshot.h index 7cc6f3894d..a981d90616 100644 --- a/src/include/utils/snapshot.h +++ b/src/include/utils/snapshot.h @@ -3,7 +3,7 @@ * snapshot.h * POSTGRES snapshot definition * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 2010-2012 Postgres-XC Development Group * @@ -16,6 +16,7 @@ #include "access/htup.h" #include "access/xlogdefs.h" +#include "datatype/timestamp.h" #include "lib/pairingheap.h" #include "storage/buf.h" @@ -111,7 +112,7 @@ typedef struct SnapshotData uint32 regd_count; /* refcount on RegisteredSnapshots */ pairingheap_node ph_node; /* link in the RegisteredSnapshots heap */ - int64 whenTaken; /* timestamp when snapshot was taken */ + TimestampTz whenTaken; /* timestamp when snapshot was taken */ XLogRecPtr lsn; /* position in the WAL stream when taken */ } SnapshotData; diff --git a/src/include/utils/sortsupport.h b/src/include/utils/sortsupport.h index 0ef76c8ccf..9ca8fe86ae 100644 --- a/src/include/utils/sortsupport.h +++ b/src/include/utils/sortsupport.h @@ -42,7 +42,7 @@ * function for such cases, but probably not any other acceleration method. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/sortsupport.h diff --git a/src/include/utils/spccache.h b/src/include/utils/spccache.h index e0e42e99c8..26f88da0b2 100644 --- a/src/include/utils/spccache.h +++ b/src/include/utils/spccache.h @@ -3,7 +3,7 @@ * spccache.h * Tablespace cache. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/spccache.h diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index 5a16368f12..2bbc93a975 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -6,7 +6,7 @@ * See also lsyscache.h, which provides convenience routines for * common cache-lookup operations. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 2010-2012 Postgres-XC Development Group * @@ -81,6 +81,7 @@ enum SysCacheIdentifier PGXCNODEOID, PGXCNODEIDENTIFIER, #endif + PARTRELID, PROCNAMEARGSNSP, PROCOID, RANGETYPE, @@ -88,8 +89,18 @@ enum SysCacheIdentifier RELOID, REPLORIGIDENT, REPLORIGNAME, + PUBLICATIONOID, + PUBLICATIONNAME, + PUBLICATIONREL, + PUBLICATIONRELMAP, RULERELNAME, + SEQRELID, + STATEXTNAMENSP, + STATEXTOID, STATRELATTINH, + SUBSCRIPTIONOID, + SUBSCRIPTIONNAME, + SUBSCRIPTIONRELMAP, TABLESPACEOID, TRFOID, TRFTYPELANG, @@ -106,6 +117,8 @@ enum SysCacheIdentifier TYPEOID, USERMAPPINGOID, USERMAPPINGUSERSERVER + +#define SysCacheSize (USERMAPPINGUSERSERVER + 1) }; extern void InitCatalogCache(void); @@ -138,6 +151,8 @@ struct catclist; extern struct catclist *SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3, Datum key4); +extern void SysCacheInvalidate(int cacheId, uint32 hashValue); + extern bool RelationInvalidatesSnapshotsOnly(Oid relid); extern bool RelationHasSysCache(Oid relid); extern bool RelationSupportsSysCache(Oid relid); diff --git a/src/include/utils/timeout.h b/src/include/utils/timeout.h index 260c013960..aa816334c0 100644 --- a/src/include/utils/timeout.h +++ b/src/include/utils/timeout.h @@ -4,7 +4,7 @@ * Routines to multiplex SIGALRM interrupts for multiple timeout reasons. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/timeout.h diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h index 3e8f4855d0..5e7e353b73 100644 --- a/src/include/utils/timestamp.h +++ b/src/include/utils/timestamp.h @@ -3,7 +3,7 @@ * timestamp.h * Definitions for the SQL "timestamp" and "interval" types. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/timestamp.h @@ -20,12 +20,9 @@ /* * 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! + * For Timestamp, we make use of the same support routines as for int64. + * Therefore Timestamp is pass-by-reference if and only if int64 is! */ -#ifdef HAVE_INT64_TIMESTAMP - #define DatumGetTimestamp(X) ((Timestamp) DatumGetInt64(X)) #define DatumGetTimestampTz(X) ((TimestampTz) DatumGetInt64(X)) #define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X)) @@ -41,24 +38,6 @@ #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) -#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) -#endif /* HAVE_INT64_TIMESTAMP */ #define TIMESTAMP_MASK(b) (1 << (b)) @@ -73,11 +52,7 @@ #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 #ifdef PGXC #define InvalidGlobalTimestamp ((TimestampTz) 0) @@ -91,155 +66,19 @@ extern TimestampTz PgStartTime; 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_transform(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_sortsupport(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 make_timestamp(PG_FUNCTION_ARGS); -extern Datum make_timestamptz(PG_FUNCTION_ARGS); -extern Datum make_timestamptz_at_timezone(PG_FUNCTION_ARGS); -extern Datum float8_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_transform(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 make_interval(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_transform(PG_FUNCTION_ARGS); -extern Datum timestamp_zone(PG_FUNCTION_ARGS); -extern Datum timestamp_izone_transform(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); -#ifdef PGXC -extern Datum interval_collect(PG_FUNCTION_ARGS); -#endif -extern Datum interval_combine(PG_FUNCTION_ARGS); -extern Datum interval_accum_inv(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 int32 anytimestamp_typmod_check(bool istz, int32 typmod); + extern TimestampTz GetCurrentTimestamp(void); +extern TimestampTz GetSQLCurrentTimestamp(int32 typmod); +extern Timestamp GetSQLLocalTimestamp(int32 typmod); extern void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs); extern bool TimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time, int msec); -/* - * Prototypes for functions to deal with integer timestamps, when the native - * format is float timestamps. - */ -#ifndef HAVE_INT64_TIMESTAMP -extern int64 GetCurrentIntegerTimestamp(void); -extern TimestampTz IntegerTimestampToTimestampTz(int64 timestamp); -#else -#define GetCurrentIntegerTimestamp() GetCurrentTimestamp() -#define IntegerTimestampToTimestampTz(timestamp) (timestamp) -#endif - extern TimestampTz time_t_to_timestamptz(pg_time_t tm); extern pg_time_t timestamptz_to_time_t(TimestampTz t); diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h index fafe1bd862..f39f21bb64 100644 --- a/src/include/utils/tqual.h +++ b/src/include/utils/tqual.h @@ -5,7 +5,7 @@ * * Should be moved/renamed... - vadim 07/28/98 * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/tqual.h diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h index ac46f90c4a..d6be7fe826 100644 --- a/src/include/utils/tuplesort.h +++ b/src/include/utils/tuplesort.h @@ -11,7 +11,7 @@ * algorithm. * * Portions Copyright (c) 2012-2014, TransLattice, Inc. - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/tuplesort.h @@ -76,7 +76,9 @@ extern Tuplesortstate *tuplesort_begin_index_btree(Relation heapRel, int workMem, bool randomAccess); extern Tuplesortstate *tuplesort_begin_index_hash(Relation heapRel, Relation indexRel, - uint32 hash_mask, + uint32 high_mask, + uint32 low_mask, + uint32 max_buckets, int workMem, bool randomAccess); extern Tuplesortstate *tuplesort_begin_datum(Oid datumType, Oid sortOperator, Oid sortCollation, @@ -104,11 +106,9 @@ extern void tuplesort_putdatum(Tuplesortstate *state, Datum val, extern void tuplesort_performsort(Tuplesortstate *state); extern bool tuplesort_gettupleslot(Tuplesortstate *state, bool forward, - TupleTableSlot *slot, Datum *abbrev); -extern HeapTuple tuplesort_getheaptuple(Tuplesortstate *state, bool forward, - bool *should_free); -extern IndexTuple tuplesort_getindextuple(Tuplesortstate *state, bool forward, - bool *should_free); + bool copy, TupleTableSlot *slot, Datum *abbrev); +extern HeapTuple tuplesort_getheaptuple(Tuplesortstate *state, bool forward); +extern IndexTuple tuplesort_getindextuple(Tuplesortstate *state, bool forward); extern bool tuplesort_getdatum(Tuplesortstate *state, bool forward, Datum *val, bool *isNull, Datum *abbrev); diff --git a/src/include/utils/tuplestore.h b/src/include/utils/tuplestore.h index 1eecc89bcf..aef4fc9840 100644 --- a/src/include/utils/tuplestore.h +++ b/src/include/utils/tuplestore.h @@ -22,7 +22,7 @@ * so that there is a check to prevent attempted access to system columns. * * Portions Copyright (c) 2012-2014, TransLattice, Inc. - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/tuplestore.h @@ -79,6 +79,8 @@ extern bool tuplestore_advance(Tuplestorestate *state, bool forward); extern bool tuplestore_skiptuples(Tuplestorestate *state, int64 ntuples, bool forward); +extern int64 tuplestore_tuple_count(Tuplestorestate *state); + extern bool tuplestore_ateof(Tuplestorestate *state); extern void tuplestore_rescan(Tuplestorestate *state); diff --git a/src/include/utils/typcache.h b/src/include/utils/typcache.h index c72efcccb1..1bf94e2548 100644 --- a/src/include/utils/typcache.h +++ b/src/include/utils/typcache.h @@ -6,7 +6,7 @@ * 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-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/typcache.h @@ -131,9 +131,10 @@ typedef struct DomainConstraintRef { List *constraints; /* list of DomainConstraintState nodes */ MemoryContext refctx; /* context holding DomainConstraintRef */ + TypeCacheEntry *tcache; /* typcache entry for domain type */ + bool need_exprstate; /* does caller need check_exprstate? */ /* Management data --- treat these fields as private to typcache.c */ - TypeCacheEntry *tcache; /* owning typcache entry */ DomainConstraintCache *dcc; /* current constraints, or NULL if none */ MemoryContextCallback callback; /* used to release refcount when done */ } DomainConstraintRef; @@ -142,7 +143,7 @@ typedef struct DomainConstraintRef extern TypeCacheEntry *lookup_type_cache(Oid type_id, int flags); extern void InitDomainConstraintRef(Oid type_id, DomainConstraintRef *ref, - MemoryContext refctx); + MemoryContext refctx, bool need_exprstate); extern void UpdateDomainConstraintRef(DomainConstraintRef *ref); diff --git a/src/include/utils/tzparser.h b/src/include/utils/tzparser.h index eea8ffcfa4..c22467de1a 100644 --- a/src/include/utils/tzparser.h +++ b/src/include/utils/tzparser.h @@ -3,7 +3,7 @@ * tzparser.h * Timezone offset file parsing definitions. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/tzparser.h diff --git a/src/include/utils/uuid.h b/src/include/utils/uuid.h index 897382f2e5..9e62d81c3d 100644 --- a/src/include/utils/uuid.h +++ b/src/include/utils/uuid.h @@ -5,7 +5,7 @@ * to avoid conflicts with any uuid_t type that might be defined by * the system headers. * - * Copyright (c) 2007-2016, PostgreSQL Global Development Group + * Copyright (c) 2007-2017, PostgreSQL Global Development Group * * src/include/utils/uuid.h * @@ -14,11 +14,13 @@ #ifndef UUID_H #define UUID_H -/* guid size in bytes */ +/* uuid size in bytes */ #define UUID_LEN 16 -/* opaque struct; defined in uuid.c */ -typedef struct pg_uuid_t pg_uuid_t; +typedef struct pg_uuid_t +{ + unsigned char data[UUID_LEN]; +} pg_uuid_t; /* fmgr interface macros */ #define UUIDPGetDatum(X) PointerGetDatum(X) diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h index 5d5c9f38fa..2a4ec67698 100644 --- a/src/include/utils/varbit.h +++ b/src/include/utils/varbit.h @@ -5,7 +5,7 @@ * * Code originally contributed by Adriaan Joubert. * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/varbit.h @@ -66,50 +66,4 @@ typedef struct /* 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_transform(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 diff --git a/src/include/utils/varlena.h b/src/include/utils/varlena.h new file mode 100644 index 0000000000..cab82ee888 --- /dev/null +++ b/src/include/utils/varlena.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + * + * varlena.h + * Functions for the variable-length built-in types. + * + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/utils/varlena.h + * + *------------------------------------------------------------------------- + */ +#ifndef VARLENA_H +#define VARLENA_H + +#include "nodes/pg_list.h" +#include "utils/sortsupport.h" + +extern int varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid); +extern void varstr_sortsupport(SortSupport ssup, Oid collid, bool bpchar); +extern int varstr_levenshtein(const char *source, int slen, + const char *target, int tlen, + int ins_c, int del_c, int sub_c, + bool trusted); +extern int varstr_levenshtein_less_equal(const char *source, int slen, + const char *target, int tlen, + int ins_c, int del_c, int sub_c, + int max_d, bool trusted); +extern List *textToQualifiedNameList(text *textval); +extern bool SplitIdentifierString(char *rawstring, char separator, + List **namelist); +extern bool SplitDirectoriesString(char *rawstring, char separator, + List **namelist); +extern text *replace_text_regexp(text *src_text, void *regexp, + text *replace_text, bool glob); + +#endif diff --git a/src/include/utils/xml.h b/src/include/utils/xml.h index 2eab8a5c2d..195b9b3a97 100644 --- a/src/include/utils/xml.h +++ b/src/include/utils/xml.h @@ -4,7 +4,7 @@ * Declarations for XML data type support. * * - * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/utils/xml.h @@ -18,6 +18,7 @@ #include "fmgr.h" #include "nodes/execnodes.h" #include "nodes/primnodes.h" +#include "executor/tablefunc.h" typedef struct varlena xmltype; @@ -52,39 +53,6 @@ typedef struct PgXmlErrorContext PgXmlErrorContext; #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); - extern void pg_xml_init_library(void); extern PgXmlErrorContext *pg_xml_init(PgXmlStrictness strictness); extern void pg_xml_done(PgXmlErrorContext *errcxt, bool isError); @@ -93,7 +61,9 @@ extern void xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode, const char *msg); extern xmltype *xmlconcat(List *args); -extern xmltype *xmlelement(XmlExprState *xmlExpr, ExprContext *econtext); +extern xmltype *xmlelement(XmlExpr *xexpr, + Datum *named_argvalue, bool *named_argnull, + Datum *argvalue, bool *argnull); 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); @@ -109,4 +79,6 @@ extern int xmlbinary; /* XmlBinaryType, but int for guc enum */ extern int xmloption; /* XmlOptionType, but int for guc enum */ +extern const TableFuncRoutine XmlTableRoutine; + #endif /* XML_H */ |
