PostgreSQL Source Code git master
|
#include "postgres.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.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 1574 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 1502 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 1536 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 1173 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 127 of file network.c.
References network_in(), PG_GETARG_CSTRING, and PG_RETURN_INET_P.
Datum cidr_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 171 of file network.c.
References network_out(), PG_GETARG_INET_PP, and PG_RETURN_CSTRING.
Datum cidr_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 256 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 296 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 344 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 364 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 2028 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 1435 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, and value.
Referenced by convert_to_scalar(), gbt_inet_compress(), and gbt_inet_consistent().
Datum hashinet | ( | PG_FUNCTION_ARGS | ) |
Definition at line 840 of file network.c.
References hash_any(), ip_addrsize, PG_GETARG_INET_PP, and VARDATA_ANY().
Datum hashinetextended | ( | PG_FUNCTION_ARGS | ) |
Definition at line 850 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 1155 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 1649 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 1686 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 119 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 1409 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 163 of file network.c.
References network_out(), PG_GETARG_INET_PP, and PG_RETURN_CSTRING.
Datum inet_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 248 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 1397 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 288 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 1721 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 1758 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 320 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 305 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 1815 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 1951 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize, ip_family, PG_GETARG_INET_PP, and PG_RETURN_INT64.
Datum inetmi_int8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1941 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 1790 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 1847 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 1931 of file network.c.
References internal_inetpl(), PG_GETARG_INET_PP, PG_GETARG_INT64, and PG_RETURN_INET_P.
Definition at line 1879 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 988 of file network.c.
References match_network_subset(), and NIL.
Referenced by network_subset_support().
|
static |
Definition at line 1036 of file network.c.
References COMPARE_GE, COMPARE_GT, COMPARE_LE, get_opfamily_member_for_cmptype(), 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 484 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 593 of file network.c.
References network_sortsupport_state::abbr_card, ABBREV_BITS_INET4_NETMASK_SIZE, ABBREV_BITS_INET4_SUBNET, addHyperLogLog(), Assert(), BITS_PER_BYTE, DatumBigEndianToNative, DatumGetInetPP(), DatumGetUInt32(), DatumGetUInt64(), 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, and SortSupportData::ssup_extra.
Referenced by network_sortsupport().
Datum network_broadcast | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1218 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 421 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_INT32.
Definition at line 401 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 774 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 1199 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 469 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 783 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 792 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 1106 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 1349 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 73 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 825 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 765 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 756 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 1191 of file network.c.
References ip_bits, PG_GETARG_INET_PP, and PG_RETURN_INT32.
Datum network_ne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 801 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 1307 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 1263 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().
|
static |
Definition at line 139 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 190 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 1623 of file network.c.
References DirectFunctionCall1, and network_network().
Referenced by match_network_subset().
Definition at line 1637 of file network.c.
References DirectFunctionCall1, DirectFunctionCall2, inet_set_masklen(), Int32GetDatum(), and network_broadcast().
Referenced by match_network_subset().
Definition at line 268 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 1132 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 813 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 433 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 863 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 878 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 941 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 893 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 908 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.