PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "access/stratnum.h"
#include "catalog/pg_opfamily.h"
#include "catalog/pg_type.h"
#include "common/hashfn.h"
#include "common/ip.h"
#include "lib/hyperloglog.h"
#include "libpq/libpq-be.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/supportnodes.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/inet.h"
#include "utils/lsyscache.h"
#include "utils/sortsupport.h"
Go to the source code of this file.
Data Structures | |
struct | network_sortsupport_state |
Macros | |
#define | ABBREV_BITS_INET4_NETMASK_SIZE 6 |
#define | ABBREV_BITS_INET4_SUBNET 25 |
|
static |
Definition at line 1635 of file network.c.
References a, Assert, and PGSQL_AF_INET.
Referenced by network_in(), and network_recv().
int bitncmp | ( | const unsigned char * | l, |
const unsigned char * | r, | ||
int | n | ||
) |
Definition at line 1563 of file network.c.
References b, IS_HIGHBIT_SET, and x.
Referenced by inet_gist_consistent(), inet_inclusion_cmp(), inet_spg_choose(), inet_spg_consistent_bitmap(), network_cmp_internal(), network_overlap(), network_sub(), network_subeq(), network_sup(), and network_supeq().
int bitncommon | ( | const unsigned char * | l, |
const unsigned char * | r, | ||
int | n | ||
) |
Definition at line 1597 of file network.c.
Referenced by calc_inet_union_params(), calc_inet_union_params_indexed(), inet_gist_penalty(), inet_hist_match_divider(), inet_merge(), inet_spg_choose(), and inet_spg_picksplit().
Datum cidr_abbrev | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1234 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, pg_inet_cidr_ntop(), and PG_RETURN_TEXT_P.
Datum cidr_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 129 of file network.c.
References network_in(), PG_GETARG_CSTRING, and PG_RETURN_INET_P.
Datum cidr_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 173 of file network.c.
References network_out(), PG_GETARG_INET_PP, and PG_RETURN_CSTRING.
Datum cidr_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 258 of file network.c.
References buf, network_recv(), PG_GETARG_POINTER, and PG_RETURN_INET_P.
Datum cidr_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 300 of file network.c.
References network_send(), PG_GETARG_INET_PP, and PG_RETURN_BYTEA_P.
Datum cidr_set_masklen | ( | PG_FUNCTION_ARGS | ) |
Definition at line 348 of file network.c.
References cidr_set_masklen_internal(), ereport, errcode(), errmsg(), ERROR, ip_maxbits, PG_GETARG_INET_PP, PG_GETARG_INT32, and PG_RETURN_INET_P.
Definition at line 368 of file network.c.
References Assert, ip_addr, ip_bits, ip_family, ip_maxbits, palloc0(), and SET_INET_VARSIZE.
Referenced by cidr_set_masklen(), inet_merge(), inet_spg_choose(), inet_spg_picksplit(), and inet_to_cidr().
void clean_ipv6_addr | ( | int | addr_family, |
char * | addr | ||
) |
Definition at line 2089 of file network.c.
Referenced by fill_hba_line(), inet_client_addr(), inet_server_addr(), pg_stat_get_activity(), and pg_stat_get_backend_client_addr().
Definition at line 1496 of file network.c.
References macaddr::a, macaddr8::a, macaddr::b, macaddr8::b, macaddr::c, macaddr8::c, macaddr::d, macaddr8::d, DatumGetInetPP(), DatumGetMacaddr8P(), DatumGetMacaddrP(), macaddr::e, macaddr8::e, macaddr::f, macaddr8::f, macaddr8::g, macaddr8::h, i, ip_addr, ip_family, len, PGSQL_AF_INET, res, and value.
Referenced by convert_to_scalar(), gbt_inet_compress(), and gbt_inet_consistent().
Datum hashinet | ( | PG_FUNCTION_ARGS | ) |
Definition at line 874 of file network.c.
References hash_any(), ip_addrsize, PG_GETARG_INET_PP, and VARDATA_ANY.
Datum hashinetextended | ( | PG_FUNCTION_ARGS | ) |
Definition at line 884 of file network.c.
References hash_any_extended(), ip_addrsize, PG_GETARG_INET_PP, PG_GETARG_INT64, and VARDATA_ANY.
Datum inet_abbrev | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1216 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, pg_inet_net_ntop(), and PG_RETURN_TEXT_P.
Datum inet_client_addr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1710 of file network.c.
References clean_ipv6_addr(), MyProcPort, network_in(), pg_getnameinfo_all(), PG_RETURN_INET_P, PG_RETURN_NULL, and port.
Datum inet_client_port | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1747 of file network.c.
References CStringGetDatum(), DirectFunctionCall1, int4in(), MyProcPort, pg_getnameinfo_all(), PG_RETURN_DATUM, PG_RETURN_NULL, and port.
Datum inet_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 121 of file network.c.
References network_in(), PG_GETARG_CSTRING, and PG_RETURN_INET_P.
Referenced by leftmostvalue_inet(), pg_stat_get_activity(), and pg_stat_get_backend_client_addr().
Datum inet_merge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1470 of file network.c.
References a1, a2, bitncommon(), cidr_set_masklen_internal(), ereport, errcode(), errmsg(), ERROR, ip_addr, ip_bits, ip_family, Min, PG_GETARG_INET_PP, and PG_RETURN_INET_P.
Datum inet_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 165 of file network.c.
References network_out(), PG_GETARG_INET_PP, and PG_RETURN_CSTRING.
Datum inet_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 250 of file network.c.
References buf, network_recv(), PG_GETARG_POINTER, and PG_RETURN_INET_P.
Datum inet_same_family | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1458 of file network.c.
References a1, a2, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum inet_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 292 of file network.c.
References network_send(), PG_GETARG_INET_PP, and PG_RETURN_BYTEA_P.
Datum inet_server_addr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1782 of file network.c.
References clean_ipv6_addr(), MyProcPort, network_in(), pg_getnameinfo_all(), PG_RETURN_INET_P, PG_RETURN_NULL, and port.
Datum inet_server_port | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1819 of file network.c.
References CStringGetDatum(), DirectFunctionCall1, int4in(), MyProcPort, pg_getnameinfo_all(), PG_RETURN_DATUM, PG_RETURN_NULL, and port.
Datum inet_set_masklen | ( | PG_FUNCTION_ARGS | ) |
Definition at line 324 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_bits, ip_maxbits, palloc(), PG_GETARG_INET_PP, PG_GETARG_INT32, PG_RETURN_INET_P, and VARSIZE_ANY.
Referenced by network_scan_last().
Datum inet_to_cidr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 309 of file network.c.
References cidr_set_masklen_internal(), elog, ERROR, ip_bits, ip_maxbits, PG_GETARG_INET_PP, and PG_RETURN_INET_P.
Datum inetand | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1876 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize, ip_bits, ip_family, Max, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Datum inetmi | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2012 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize, ip_family, PG_GETARG_INET_PP, PG_RETURN_INT64, and res.
Datum inetmi_int8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2002 of file network.c.
References internal_inetpl(), PG_GETARG_INET_PP, PG_GETARG_INT64, and PG_RETURN_INET_P.
Datum inetnot | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1851 of file network.c.
References ip_addr, ip_addrsize, ip_bits, ip_family, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Datum inetor | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1908 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize, ip_bits, ip_family, Max, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Datum inetpl | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1992 of file network.c.
References internal_inetpl(), PG_GETARG_INET_PP, PG_GETARG_INT64, and PG_RETURN_INET_P.
Definition at line 1940 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize, ip_bits, ip_family, palloc0(), and SET_INET_VARSIZE.
Referenced by inetmi_int8(), and inetpl().
|
static |
Definition at line 1022 of file network.c.
References match_network_subset(), and NIL.
Referenced by network_subset_support().
|
static |
Definition at line 1070 of file network.c.
References BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, elog, ERROR, get_opfamily_member(), InvalidOid, IsA, lappend(), list_make1, make_opclause(), makeConst(), network_scan_first(), network_scan_last(), and NIL.
Referenced by match_network_function().
|
static |
Definition at line 488 of file network.c.
References network_sortsupport_state::abbr_card, elog, estimateHyperLogLog(), network_sortsupport_state::estimating, network_sortsupport_state::input_count, INT64_FORMAT, LOG, SortSupportData::ssup_extra, and trace_sort.
Referenced by network_sortsupport().
|
static |
Definition at line 619 of file network.c.
References network_sortsupport_state::abbr_card, ABBREV_BITS_INET4_NETMASK_SIZE, ABBREV_BITS_INET4_SUBNET, addHyperLogLog(), Assert, BITS_PER_BYTE, DatumGetInetPP(), DatumGetUInt32(), network_sortsupport_state::estimating, hash_uint32(), network_sortsupport_state::input_count, ip_addr, ip_bits, ip_family, ip_maxbits, pg_bswap32(), PGSQL_AF_INET, PGSQL_AF_INET6, res, SIZEOF_DATUM, and SortSupportData::ssup_extra.
Referenced by network_sortsupport().
Datum network_broadcast | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1279 of file network.c.
References a, b, ip_addr, ip_addrsize, ip_bits, ip_family, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Referenced by network_scan_last().
Datum network_cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 425 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_INT32.
Definition at line 405 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, ip_maxbits, and Min.
Referenced by network_cmp(), network_eq(), network_fast_cmp(), network_ge(), network_gt(), network_larger(), network_le(), network_lt(), network_ne(), and network_smaller().
Datum network_eq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 808 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_family | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1260 of file network.c.
References ip_family, PG_GETARG_INET_PP, PG_RETURN_INT32, PGSQL_AF_INET, and PGSQL_AF_INET6.
|
static |
Definition at line 473 of file network.c.
References DatumGetInetPP(), network_cmp_internal(), x, and y.
Referenced by network_sortsupport().
Datum network_ge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 817 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_gt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 826 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_host | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1167 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, ip_addr, ip_family, ip_maxbits, PG_GETARG_INET_PP, pg_inet_net_ntop(), and PG_RETURN_TEXT_P.
Datum network_hostmask | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1410 of file network.c.
References b, ip_addr, ip_addrsize, ip_bits, ip_family, ip_maxbits, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Definition at line 75 of file network.c.
References addressOK(), ereturn, errcode(), errdetail(), errmsg(), ip_addr, ip_addrsize, ip_bits, ip_family, ip_maxbits, palloc0(), pg_inet_net_pton(), PGSQL_AF_INET, PGSQL_AF_INET6, and SET_INET_VARSIZE.
Referenced by cidr_in(), inet_client_addr(), inet_in(), and inet_server_addr().
Datum network_larger | ( | PG_FUNCTION_ARGS | ) |
Definition at line 859 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_INET_P.
Datum network_le | ( | PG_FUNCTION_ARGS | ) |
Definition at line 799 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_lt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 790 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_masklen | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1252 of file network.c.
References ip_bits, PG_GETARG_INET_PP, and PG_RETURN_INT32.
Datum network_ne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 835 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_netmask | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1368 of file network.c.
References b, ip_addr, ip_bits, ip_family, ip_maxbits, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Datum network_network | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1324 of file network.c.
References a, b, ip_addr, ip_bits, ip_family, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Referenced by network_scan_first().
Definition at line 141 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_bits, ip_family, len, pg_inet_net_ntop(), pstrdup(), and snprintf.
Referenced by cidr_out(), and inet_out().
Datum network_overlap | ( | PG_FUNCTION_ARGS | ) |
|
static |
Definition at line 192 of file network.c.
References addressOK(), buf, ereport, errcode(), errdetail(), errmsg(), ERROR, i, ip_addr, ip_addrsize, ip_bits, ip_family, ip_maxbits, palloc0(), PGSQL_AF_INET, PGSQL_AF_INET6, pq_getmsgbyte(), and SET_INET_VARSIZE.
Referenced by cidr_recv(), and inet_recv().
Definition at line 1684 of file network.c.
References DirectFunctionCall1, and network_network().
Referenced by match_network_subset().
Definition at line 1698 of file network.c.
References DirectFunctionCall1, DirectFunctionCall2, inet_set_masklen(), Int32GetDatum(), and network_broadcast().
Referenced by match_network_subset().
Definition at line 270 of file network.c.
References buf, i, ip_addr, ip_addrsize, ip_bits, ip_family, pq_begintypsend(), pq_endtypsend(), and pq_sendbyte().
Referenced by cidr_send(), and inet_send().
Datum network_show | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1193 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, ip_addr, ip_bits, ip_family, ip_maxbits, len, PG_GETARG_INET_PP, pg_inet_net_ntop(), PG_RETURN_TEXT_P, and snprintf.
Datum network_smaller | ( | PG_FUNCTION_ARGS | ) |
Definition at line 847 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_INET_P.
Datum network_sortsupport | ( | PG_FUNCTION_ARGS | ) |
Definition at line 437 of file network.c.
References network_sortsupport_state::abbr_card, SortSupportData::abbrev_abort, SortSupportData::abbrev_converter, SortSupportData::abbrev_full_comparator, SortSupportData::abbreviate, SortSupportData::comparator, network_sortsupport_state::estimating, initHyperLogLog(), network_sortsupport_state::input_count, MemoryContextSwitchTo(), network_abbrev_abort(), network_abbrev_convert(), network_fast_cmp(), palloc(), PG_GETARG_POINTER, PG_RETURN_VOID, SortSupportData::ssup_cxt, ssup_datum_unsigned_cmp(), and SortSupportData::ssup_extra.
Datum network_sub | ( | PG_FUNCTION_ARGS | ) |
Definition at line 897 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_subeq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 912 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_subset_support | ( | PG_FUNCTION_ARGS | ) |
Definition at line 975 of file network.c.
References FuncExpr::args, OpExpr::args, Assert, SupportRequestIndexCondition::funcid, SupportRequestIndexCondition::indexarg, is_funcclause(), is_opclause(), IsA, linitial, list_length(), lsecond, match_network_function(), SupportRequestIndexCondition::node, SupportRequestIndexCondition::opfamily, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum network_sup | ( | PG_FUNCTION_ARGS | ) |
Definition at line 927 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum network_supeq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 942 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.