PostgreSQL Source Code git master
Loading...
Searching...
No Matches
builtins.h File Reference
#include "fmgr.h"
#include "nodes/nodes.h"
#include "utils/fmgrprotos.h"
Include dependency graph for builtins.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAXINT8LEN   20
 
#define CStringGetTextDatum(s)   PointerGetDatum(cstring_to_text(s))
 
#define TextDatumGetCString(d)   text_to_cstring((text *) DatumGetPointer(d))
 
#define FORMAT_TYPE_TYPEMOD_GIVEN   0x01 /* typemod defined by caller */
 
#define FORMAT_TYPE_ALLOW_INVALID   0x02 /* allow invalid types */
 
#define FORMAT_TYPE_FORCE_QUALIFY   0x04 /* force qualification of type */
 
#define FORMAT_TYPE_INVALID_AS_NULL   0x08 /* NULL if undefined */
 

Functions

bool parse_bool (const char *value, bool *result)
 
bool parse_bool_with_len (const char *value, size_t len, bool *result)
 
void domain_check (Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt)
 
bool domain_check_safe (Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt, Node *escontext)
 
int errdatatype (Oid datatypeOid)
 
int errdomainconstraint (Oid datatypeOid, const char *conname)
 
uint64 hex_encode (const char *src, size_t len, char *dst)
 
uint64 hex_decode (const char *src, size_t len, char *dst)
 
uint64 hex_decode_safe (const char *src, size_t len, char *dst, Node *escontext)
 
int2vectorbuildint2vector (const int16 *int2s, int n)
 
void namestrcpy (Name name, const char *str)
 
int namestrcmp (Name name, const char *str)
 
int16 pg_strtoint16 (const char *s)
 
int16 pg_strtoint16_safe (const char *s, Node *escontext)
 
int32 pg_strtoint32 (const char *s)
 
int32 pg_strtoint32_safe (const char *s, Node *escontext)
 
int64 pg_strtoint64 (const char *s)
 
int64 pg_strtoint64_safe (const char *s, Node *escontext)
 
uint32 uint32in_subr (const char *s, char **endloc, const char *typname, Node *escontext)
 
uint64 uint64in_subr (const char *s, char **endloc, const char *typname, Node *escontext)
 
int pg_itoa (int16 i, char *a)
 
int pg_ultoa_n (uint32 value, char *a)
 
int pg_ulltoa_n (uint64 value, char *a)
 
int pg_ltoa (int32 value, char *a)
 
int pg_lltoa (int64 value, char *a)
 
charpg_ultostr_zeropad (char *str, uint32 value, int32 minwidth)
 
charpg_ultostr (char *str, uint32 value)
 
oidvectorbuildoidvector (const Oid *oids, int n)
 
Oid oidparse (Node *node)
 
int oid_cmp (const void *p1, const void *p2)
 
charregexp_fixed_prefix (text *text_re, bool case_insensitive, Oid collation, bool *exact)
 
const charquote_identifier (const char *ident)
 
charquote_qualified_identifier (const char *qualifier, const char *ident)
 
void generate_operator_clause (StringInfo buf, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
 
int bpchartruelen (char *s, int len)
 
textcstring_to_text (const char *s)
 
textcstring_to_text_with_len (const char *s, int len)
 
chartext_to_cstring (const text *t)
 
void text_to_cstring_buffer (const text *src, char *dst, size_t dst_len)
 
int xidComparator (const void *arg1, const void *arg2)
 
int xidLogicalComparator (const void *arg1, const void *arg2)
 
charpg_inet_cidr_ntop (int af, const void *src, int bits, char *dst, size_t size)
 
int pg_inet_net_pton (int af, const char *src, void *dst, size_t size)
 
double convert_network_to_scalar (Datum value, Oid typid, bool *failure)
 
Datum network_scan_first (Datum in)
 
Datum network_scan_last (Datum in)
 
void clean_ipv6_addr (int addr_family, char *addr)
 
Datum numeric_float8_no_overflow (PG_FUNCTION_ARGS)
 
charformat_type_extended (Oid type_oid, int32 typemod, bits16 flags)
 
charformat_type_be (Oid type_oid)
 
charformat_type_be_qualified (Oid type_oid)
 
charformat_type_with_typemod (Oid type_oid, int32 typemod)
 
int32 type_maximum_size (Oid type_oid, int32 typemod)
 
charquote_literal_cstr (const char *rawstr)
 

Variables

PGDLLIMPORT bool quote_all_identifiers
 

Macro Definition Documentation

◆ CStringGetTextDatum

#define CStringGetTextDatum (   s)    PointerGetDatum(cstring_to_text(s))

Definition at line 97 of file builtins.h.

◆ FORMAT_TYPE_ALLOW_INVALID

#define FORMAT_TYPE_ALLOW_INVALID   0x02 /* allow invalid types */

Definition at line 125 of file builtins.h.

◆ FORMAT_TYPE_FORCE_QUALIFY

#define FORMAT_TYPE_FORCE_QUALIFY   0x04 /* force qualification of type */

Definition at line 126 of file builtins.h.

◆ FORMAT_TYPE_INVALID_AS_NULL

#define FORMAT_TYPE_INVALID_AS_NULL   0x08 /* NULL if undefined */

Definition at line 127 of file builtins.h.

◆ FORMAT_TYPE_TYPEMOD_GIVEN

#define FORMAT_TYPE_TYPEMOD_GIVEN   0x01 /* typemod defined by caller */

Definition at line 124 of file builtins.h.

◆ MAXINT8LEN

#define MAXINT8LEN   20

Definition at line 22 of file builtins.h.

◆ TextDatumGetCString

#define TextDatumGetCString (   d)    text_to_cstring((text *) DatumGetPointer(d))

Definition at line 98 of file builtins.h.

Function Documentation

◆ bpchartruelen()

int bpchartruelen ( char s,
int  len 
)
extern

Definition at line 676 of file varchar.c.

677{
678 int i;
679
680 /*
681 * Note that we rely on the assumption that ' ' is a singleton unit on
682 * every supported multibyte server encoding.
683 */
684 for (i = len - 1; i >= 0; i--)
685 {
686 if (s[i] != ' ')
687 break;
688 }
689 return i + 1;
690}
int i
Definition isn.c:77
const void size_t len

References i, and len.

Referenced by bcTruelen(), bpcharfastcmp_c(), varstr_abbrev_convert(), and varstrfastcmp_locale().

◆ buildint2vector()

int2vector * buildint2vector ( const int16 int2s,
int  n 
)
extern

Definition at line 114 of file int.c.

115{
116 int2vector *result;
117
118 result = (int2vector *) palloc0(Int2VectorSize(n));
119
120 if (n > 0 && int2s)
121 memcpy(result->values, int2s, n * sizeof(int16));
122
123 /*
124 * Attach standard array header. For historical reasons, we set the index
125 * lower bound to 0 not 1.
126 */
127 SET_VARSIZE(result, Int2VectorSize(n));
128 result->ndim = 1;
129 result->dataoffset = 0; /* never any nulls */
130 result->elemtype = INT2OID;
131 result->dim1 = n;
132 result->lbound1 = 0;
133
134 return result;
135}
int16_t int16
Definition c.h:541
#define Int2VectorSize(n)
Definition int.c:45
void * palloc0(Size size)
Definition mcxt.c:1417
static int fb(int x)
int ndim
Definition c.h:736
int dim1
Definition c.h:739
Oid elemtype
Definition c.h:738
int16 values[FLEXIBLE_ARRAY_MEMBER]
Definition c.h:741
int32 dataoffset
Definition c.h:737
int lbound1
Definition c.h:740
static void SET_VARSIZE(void *PTR, Size len)
Definition varatt.h:432

References int2vector::dataoffset, int2vector::dim1, int2vector::elemtype, fb(), Int2VectorSize, int2vector::lbound1, int2vector::ndim, palloc0(), SET_VARSIZE(), and int2vector::values.

Referenced by attnumstoint2vector(), CreateStatistics(), CreateTriggerFiringOn(), pg_get_publication_tables(), StorePartitionKey(), and UpdateIndexRelation().

◆ buildoidvector()

oidvector * buildoidvector ( const Oid oids,
int  n 
)
extern

Definition at line 87 of file oid.c.

88{
89 oidvector *result;
90
91 result = (oidvector *) palloc0(OidVectorSize(n));
92
93 if (n > 0 && oids)
94 memcpy(result->values, oids, n * sizeof(Oid));
95
96 /*
97 * Attach standard array header. For historical reasons, we set the index
98 * lower bound to 0 not 1.
99 */
100 SET_VARSIZE(result, OidVectorSize(n));
101 result->ndim = 1;
102 result->dataoffset = 0; /* never any nulls */
103 result->elemtype = OIDOID;
104 result->dim1 = n;
105 result->lbound1 = 0;
106
107 return result;
108}
#define OidVectorSize(n)
Definition oid.c:29
unsigned int Oid
Definition c.h:745
int dim1
Definition c.h:750
int32 dataoffset
Definition c.h:748
Oid elemtype
Definition c.h:749
int lbound1
Definition c.h:751
int ndim
Definition c.h:747
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition c.h:752

References oidvector::dataoffset, oidvector::dim1, oidvector::elemtype, fb(), oidvector::lbound1, oidvector::ndim, OidVectorSize, palloc0(), SET_VARSIZE(), and oidvector::values.

Referenced by DefineAggregate(), interpret_function_parameter_list(), makeMultirangeConstructors(), makeRangeConstructors(), StorePartitionKey(), and UpdateIndexRelation().

◆ clean_ipv6_addr()

void clean_ipv6_addr ( int  addr_family,
char addr 
)
extern

Definition at line 2028 of file network.c.

2029{
2030 if (addr_family == AF_INET6)
2031 {
2032 char *pct = strchr(addr, '%');
2033
2034 if (pct)
2035 *pct = '\0';
2036 }
2037}

References fb().

Referenced by fill_hba_line(), inet_client_addr(), inet_server_addr(), pg_stat_get_activity(), and pg_stat_get_backend_client_addr().

◆ convert_network_to_scalar()

double convert_network_to_scalar ( Datum  value,
Oid  typid,
bool failure 
)
extern

Definition at line 1435 of file network.c.

1436{
1437 switch (typid)
1438 {
1439 case INETOID:
1440 case CIDROID:
1441 {
1443 int len;
1444 double res;
1445 int i;
1446
1447 /*
1448 * Note that we don't use the full address for IPv6.
1449 */
1450 if (ip_family(ip) == PGSQL_AF_INET)
1451 len = 4;
1452 else
1453 len = 5;
1454
1455 res = ip_family(ip);
1456 for (i = 0; i < len; i++)
1457 {
1458 res *= 256;
1459 res += ip_addr(ip)[i];
1460 }
1461 return res;
1462 }
1463 case MACADDROID:
1464 {
1466 double res;
1467
1468 res = (mac->a << 16) | (mac->b << 8) | (mac->c);
1469 res *= 256 * 256 * 256;
1470 res += (mac->d << 16) | (mac->e << 8) | (mac->f);
1471 return res;
1472 }
1473 case MACADDR8OID:
1474 {
1476 double res;
1477
1478 res = (mac->a << 24) | (mac->b << 16) | (mac->c << 8) | (mac->d);
1479 res *= ((double) 256) * 256 * 256 * 256;
1480 res += (mac->e << 24) | (mac->f << 16) | (mac->g << 8) | (mac->h);
1481 return res;
1482 }
1483 }
1484
1485 *failure = true;
1486 return 0;
1487}
static struct @172 value
Definition inet.h:53
Definition inet.h:95
static macaddr8 * DatumGetMacaddr8P(Datum X)
Definition inet.h:163
static inet * DatumGetInetPP(Datum X)
Definition inet.h:123
#define ip_addr(inetptr)
Definition inet.h:77
#define ip_family(inetptr)
Definition inet.h:71
static macaddr * DatumGetMacaddrP(Datum X)
Definition inet.h:147
#define PGSQL_AF_INET
Definition inet.h:39

References DatumGetInetPP(), DatumGetMacaddr8P(), DatumGetMacaddrP(), fb(), i, ip_addr, ip_family, len, PGSQL_AF_INET, and value.

Referenced by convert_to_scalar(), gbt_inet_compress(), and gbt_inet_consistent().

◆ cstring_to_text()

text * cstring_to_text ( const char s)
extern

Definition at line 181 of file varlena.c.

182{
183 return cstring_to_text_with_len(s, strlen(s));
184}
text * cstring_to_text_with_len(const char *s, int len)
Definition varlena.c:193

References cstring_to_text_with_len(), and fb().

Referenced by array_dims(), ASN1_STRING_to_text(), booltext(), brin_minmax_multi_summary_out(), brin_page_type(), build_test_info_result(), build_test_match_result(), casefold(), cidr_abbrev(), convert_charset(), cstring_to_xmltype(), current_query(), cvt_name_text(), datetime_to_char_body(), dblink_build_sql_delete(), dblink_build_sql_insert(), dblink_build_sql_update(), dblink_cancel_query(), dblink_close(), dblink_connect(), dblink_disconnect(), dblink_error_message(), dblink_exec(), dblink_open(), dmetaphone(), dmetaphone_alt(), exec_assign_c_string(), executeDateTimeMethod(), filter_list_to_array(), format_type(), get_command_tag(), get_command_type(), get_scalar(), get_val_in_hash(), hash_page_type(), icu_unicode_version(), inet_abbrev(), initcap(), injection_points_list(), json_in(), json_typeof(), jsonb_get_element(), jsonb_typeof(), JsonbValueAsText(), lower(), md5_bytea(), md5_text(), metaphone(), name_bpchar(), name_text(), network_host(), network_show(), oidvectortypes(), ParameterAclCreate(), ParameterAclLookup(), pg_collation_actual_version(), pg_collation_for(), pg_column_compression(), pg_crypt(), pg_current_logfile(), pg_database_collation_actual_version(), pg_describe_object(), pg_export_snapshot(), pg_get_statisticsobjdef_expressions(), pg_get_wal_replay_pause_state(), pg_parameter_aclmask(), pg_relation_filepath(), pg_size_pretty(), pg_size_pretty_numeric(), pg_stat_get_backend_activity(), pg_stat_get_backend_wait_event(), pg_stat_get_backend_wait_event_type(), pg_stat_get_slru(), pg_stats_ext_mcvlist_items(), pg_tablespace_location(), pg_walfile_name(), pg_xact_status(), pgsql_version(), pgxml_result_to_text(), quote_ident(), quote_ident_cstr(), quote_nullable(), sepgsql_getcon(), sepgsql_mcstrans_in(), sepgsql_mcstrans_out(), set_config_by_name(), show_all_file_settings(), show_config_by_name(), show_config_by_name_missing_ok(), ShowAllGUCConfig(), soundex(), split_part(), ssl_cipher(), ssl_client_dn(), ssl_issuer_dn(), ssl_version(), string_to_text(), test_canonicalize_path(), test_custom_stats_var_report(), test_slru_page_read(), test_slru_page_readonly(), text_substring(), textin(), timeofday(), timetz_at_local(), tsquerytree(), unaccent_dict(), unicode_version(), upper(), xml_encode_special_chars(), xml_in(), and xml_recv().

◆ cstring_to_text_with_len()

text * cstring_to_text_with_len ( const char s,
int  len 
)
extern

Definition at line 193 of file varlena.c.

194{
195 text *result = (text *) palloc(len + VARHDRSZ);
196
197 SET_VARSIZE(result, len + VARHDRSZ);
198 memcpy(VARDATA(result), s, len);
199
200 return result;
201}
#define VARHDRSZ
Definition c.h:711
void * palloc(Size size)
Definition mcxt.c:1387
Definition c.h:706
static char * VARDATA(const void *PTR)
Definition varatt.h:305

References fb(), len, palloc(), SET_VARSIZE(), VARDATA(), and VARHDRSZ.

Referenced by array_to_json(), array_to_json_pretty(), array_to_text_internal(), brin_minmax_multi_summary_out(), build_regexp_match_result(), build_regexp_split_result(), build_test_match_result(), cash_words(), compute_tsvector_stats(), concat_internal(), convert_to_base(), cstring_to_text(), daitch_mokotoff_coding(), datum_to_json(), do_text_output_multiline(), dotrim(), each_object_field_end(), each_worker_jsonb(), elements_array_element_end(), ExecEvalMergeSupportFunc(), ExecEvalXmlExpr(), executeDateTimeMethod(), executeLikeRegex(), find_or_create_child_node(), fsm_page_contents(), get_array_element_end(), get_array_end(), get_object_end(), get_object_field_end(), get_scalar(), gin_extract_tsquery(), gin_extract_tsvector(), hstore_akeys(), hstore_avals(), hstore_each(), hstore_fetchval(), hstore_skeys(), hstore_slice_to_array(), hstore_subscript_fetch(), hstore_svals(), hstore_to_array_internal(), hstore_to_json(), hstore_to_json_loose(), json_build_array_noargs(), json_build_array_worker(), json_build_object_noargs(), json_build_object_worker(), json_object(), json_object_two_arg(), json_recv(), json_strip_nulls(), jsonb_pretty(), JsonbValueAsText(), leftmostvalue_text(), LogicalOutputWrite(), parse_ident(), pg_gen_salt(), pg_gen_salt_rounds(), pg_get_function_sqlbody(), replace_text(), replace_text_regexp(), row_to_json(), row_to_json_pretty(), serialize_deflist(), split_part(), split_text(), ssl_extension_info(), string_agg_finalfn(), stringinfo_to_xmltype(), text_format(), text_left(), text_right(), textrecv(), transform_json_string_values(), tsquerytree(), tsvector_to_array(), tsvector_unnest(), unistr(), varchar(), varchar_input(), xmltext(), xmltotext_with_options(), and xslt_process().

◆ domain_check()

void domain_check ( Datum  value,
bool  isnull,
Oid  domainType,
void **  extra,
MemoryContext  mcxt 
)
extern

Definition at line 346 of file domains.c.

348{
349 (void) domain_check_internal(value, isnull, domainType, extra, mcxt,
350 NULL);
351}
static bool domain_check_internal(Datum value, bool isnull, Oid domainType, void **extra, MemoryContext mcxt, Node *escontext)
Definition domains.c:371

References domain_check_internal(), fb(), and value.

Referenced by check_domain_for_new_field(), check_domain_for_new_tuple(), expanded_record_set_fields(), hstore_populate_record(), plperl_return_next_internal(), plperl_sv_to_datum(), plpgsql_exec_function(), pltcl_build_tuple_result(), and PLyObject_ToDomain().

◆ domain_check_safe()

bool domain_check_safe ( Datum  value,
bool  isnull,
Oid  domainType,
void **  extra,
MemoryContext  mcxt,
Node escontext 
)
extern

Definition at line 355 of file domains.c.

358{
359 return domain_check_internal(value, isnull, domainType, extra, mcxt,
360 escontext);
361}

References domain_check_internal(), fb(), and value.

Referenced by ExecEvalJsonCoercion(), populate_composite(), populate_domain(), and populate_recordset_record().

◆ errdatatype()

int errdatatype ( Oid  datatypeOid)
extern

Definition at line 407 of file domains.c.

408{
411
413 if (!HeapTupleIsValid(tup))
414 elog(ERROR, "cache lookup failed for type %u", datatypeOid);
416
418 get_namespace_name(typtup->typnamespace));
420
422
423 return 0; /* return value does not matter */
424}
#define NameStr(name)
Definition c.h:765
int err_generic_string(int field, const char *str)
Definition elog.c:1546
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
#define HeapTupleIsValid(tuple)
Definition htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
char * get_namespace_name(Oid nspid)
Definition lsyscache.c:3516
FormData_pg_type * Form_pg_type
Definition pg_type.h:261
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
#define PG_DIAG_SCHEMA_NAME
#define PG_DIAG_DATATYPE_NAME
void ReleaseSysCache(HeapTuple tuple)
Definition syscache.c:264
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition syscache.c:220

References elog, err_generic_string(), ERROR, fb(), get_namespace_name(), GETSTRUCT(), HeapTupleIsValid, NameStr, ObjectIdGetDatum(), PG_DIAG_DATATYPE_NAME, PG_DIAG_SCHEMA_NAME, ReleaseSysCache(), and SearchSysCache1().

Referenced by domain_check_input(), errdomainconstraint(), and ExecEvalConstraintNotNull().

◆ errdomainconstraint()

int errdomainconstraint ( Oid  datatypeOid,
const char conname 
)
extern

Definition at line 431 of file domains.c.

432{
435
436 return 0; /* return value does not matter */
437}
int errdatatype(Oid datatypeOid)
Definition domains.c:407
#define PG_DIAG_CONSTRAINT_NAME

References err_generic_string(), errdatatype(), fb(), and PG_DIAG_CONSTRAINT_NAME.

Referenced by domain_check_input(), and ExecEvalConstraintCheck().

◆ format_type_be()

char * format_type_be ( Oid  type_oid)
extern

Definition at line 343 of file format_type.c.

344{
345 return format_type_extended(type_oid, -1, 0);
346}
char * format_type_extended(Oid type_oid, int32 typemod, bits16 flags)

References fb(), and format_type_extended().

Referenced by aclcheck_error_type(), addFamilyMember(), addRangeTableEntryForFunction(), AggregateCreate(), AlterType(), AlterTypeNamespace(), AlterTypeNamespace_oid(), AlterTypeNamespaceInternal(), AlterTypeOwner(), AlterTypeOwnerInternal(), analyzeCTE(), appendTypeNameToBuffer(), array_cat(), array_cmp(), array_contain_compare(), array_eq(), array_position_common(), array_positions(), array_recv(), array_replace_internal(), array_send(), array_sort_internal(), assign_record_type_identifier(), ATAddForeignKeyConstraint(), ATExecAlterColumnType(), ATPrepAlterColumnType(), brinvalidate(), btvalidate(), build_attrmap_by_name(), build_column_default(), build_datatype(), build_subplan(), CastCreate(), check_object_ownership(), check_of_type(), check_safe_enum_use(), check_sql_stmt_retval(), check_valid_polymorphic_signature(), CheckAttributeType(), checkDomainOwner(), checkEnumOwner(), checkRuleResultList(), CheckVarSlotCompatibility(), coerce_record_to_complex(), coerce_to_boolean(), coerce_to_common_type(), coerce_to_specific_type_typmod(), coerce_type(), coerceJsonFuncExpr(), compare_values_of_enum(), compile_plperl_function(), compile_pltcl_function(), ComputeIndexAttrs(), ComputePartitionAttrs(), cookDefault(), create_ctas_nodata(), CreateCast(), CreateFunction(), CreateStatistics(), CreateTransform(), DefineAggregate(), DefineDomain(), DefineIndex(), DefineRange(), DefineType(), domain_check_input(), domain_state_setup(), dropOperators(), dropProcedures(), enforce_generic_type_consistency(), enum_first(), enum_in(), enum_last(), enum_recv(), EvaluateParams(), exec_stmt_foreach_a(), ExecAlterExtensionContentsRecurse(), ExecBuildUpdateProjection(), ExecCheckPlanOutput(), ExecEvalArrayExpr(), ExecEvalConstraintCheck(), ExecEvalConstraintNotNull(), ExecEvalFieldSelect(), ExecEvalParamExtern(), ExecEvalWholeRowVar(), ExecInitAgg(), ExecInitExprRec(), ExecInitSubscriptingRef(), exprType(), extract_date(), fetch_cursor_param_value(), findRangeSubOpclass(), findTypeInputFunction(), findTypeReceiveFunction(), fmgr_sql_validator(), format_operator_extended(), format_procedure_extended(), funcname_signature_string(), get_cached_rowtype(), get_cast_oid(), get_domain_constraint_oid(), get_expr_result_tupdesc(), get_multirange_io_data(), get_range_io_data(), get_rels_with_domain(), get_sort_group_operators(), get_transform_oid(), get_ts_parser_func(), get_ts_template_func(), GetAttributeCompression(), GetAttributeStorage(), GetColumnDefCollation(), GetDefaultOpClass(), getObjectDescription(), GetOperatorFromCompareType(), getTypeBinaryInputInfo(), getTypeBinaryOutputInfo(), getTypeInputInfo(), getTypeOutputInfo(), GinBufferInit(), hash_array(), hash_array_extended(), hash_multirange(), hash_multirange_extended(), hash_range(), hash_range_extended(), hash_record(), hash_record_extended(), hashvalidate(), init_params(), initArrayResultArr(), initGinState(), internal_get_result_type(), interval_part_common(), interval_trunc(), intorel_startup(), jsonb_subscript_transform(), JsonItemFromDatum(), load_enum_cache_data(), lookup_rowtype_tupdesc_domain(), lookup_rowtype_tupdesc_internal(), LookupTypeNameExtended(), make_expanded_record_from_tupdesc(), make_expanded_record_from_typeid(), make_row_comparison_op(), make_scalar_array_op(), NonFiniteIntervalPart(), NonFiniteTimestampTzPart(), op_signature_string(), ParseFuncOrColumn(), pg_collation_for(), plperl_array_to_datum(), plperl_sv_to_datum(), plperl_validator(), plpgsql_build_datatype_arrayof(), plpgsql_build_variable(), plpgsql_compile_callback(), plpgsql_param_eval_generic(), plpgsql_param_eval_generic_ro(), plpgsql_param_eval_recfield(), plpgsql_validator(), PLy_procedure_create(), prepare_sql_fn_parse_info(), print_function_arguments(), print_function_rettype(), print_function_trftypes(), processIndirection(), record_cmp(), record_eq(), record_image_cmp(), record_image_eq(), regtypeout(), RelationBuildPartitionKey(), RenameConstraintById(), RenameType(), resolve_anyarray_from_others(), resolve_anyelement_from_others(), resolve_anymultirange_from_others(), resolve_anyrange_from_others(), ResolveOpClass(), revalidate_rectypeid(), ri_HashCompareOp(), satisfies_hash_partition(), select_common_type(), select_common_type_from_oids(), spgvalidate(), sql_compile_callback(), stats_check_arg_type(), stats_fill_fcinfo_from_arg_pairs(), storeOperators(), storeProcedures(), time_part_common(), timestamp_part_common(), timestamp_trunc(), timestamptz_part_common(), timestamptz_trunc_internal(), timetz_part_common(), transformAggregateCall(), transformArrayExpr(), transformAssignedExpr(), transformAssignmentIndirection(), transformAssignmentSubscripts(), transformCollateClause(), transformColumnType(), transformContainerSubscripts(), transformFrameOffset(), transformJsonBehavior(), transformJsonFuncExpr(), transformJsonIsPredicate(), transformJsonReturning(), transformJsonSerializeExpr(), transformJsonValueExpr(), transformPartitionBoundValue(), transformPLAssignStmtTarget(), transformTypeCast(), transformXmlSerialize(), tuple_to_stringinfo(), tupledesc_match(), tuples_equal(), tuplesort_begin_index_gin(), unknown_attribute(), validateConnectbyTupleDesc(), variable_coerce_param_hook(), and width_bucket_array().

◆ format_type_be_qualified()

char * format_type_be_qualified ( Oid  type_oid)
extern

◆ format_type_extended()

char * format_type_extended ( Oid  type_oid,
int32  typemod,
bits16  flags 
)
extern

Definition at line 112 of file format_type.c.

113{
114 HeapTuple tuple;
117 bool is_array;
118 char *buf;
119 bool with_typemod;
120
121 if (type_oid == InvalidOid)
122 {
123 if ((flags & FORMAT_TYPE_INVALID_AS_NULL) != 0)
124 return NULL;
125 else if ((flags & FORMAT_TYPE_ALLOW_INVALID) != 0)
126 return pstrdup("-");
127 }
128
130 if (!HeapTupleIsValid(tuple))
131 {
132 if ((flags & FORMAT_TYPE_INVALID_AS_NULL) != 0)
133 return NULL;
134 else if ((flags & FORMAT_TYPE_ALLOW_INVALID) != 0)
135 return pstrdup("???");
136 else
137 elog(ERROR, "cache lookup failed for type %u", type_oid);
138 }
140
141 /*
142 * Check if it's a "true" array type. Pseudo-array types such as "name"
143 * shouldn't get deconstructed. Also check the toast property, and don't
144 * deconstruct "plain storage" array types --- this is because we don't
145 * want to show oidvector as oid[].
146 */
147 array_base_type = typeform->typelem;
148
150 typeform->typstorage != TYPSTORAGE_PLAIN)
151 {
152 /* Switch our attention to the array element type */
153 ReleaseSysCache(tuple);
155 if (!HeapTupleIsValid(tuple))
156 {
157 if ((flags & FORMAT_TYPE_INVALID_AS_NULL) != 0)
158 return NULL;
159 else if ((flags & FORMAT_TYPE_ALLOW_INVALID) != 0)
160 return pstrdup("???[]");
161 else
162 elog(ERROR, "cache lookup failed for type %u", type_oid);
163 }
166 is_array = true;
167 }
168 else
169 is_array = false;
170
171 with_typemod = (flags & FORMAT_TYPE_TYPEMOD_GIVEN) != 0 && (typemod >= 0);
172
173 /*
174 * See if we want to special-case the output for certain built-in types.
175 * Note that these special cases should all correspond to special
176 * productions in gram.y, to ensure that the type name will be taken as a
177 * system type, not a user type of the same name.
178 *
179 * If we do not provide a special-case output here, the type name will be
180 * handled the same way as a user type name --- in particular, it will be
181 * double-quoted if it matches any lexer keyword. This behavior is
182 * essential for some cases, such as types "bit" and "char".
183 */
184 buf = NULL; /* flag for no special case */
185
186 switch (type_oid)
187 {
188 case BITOID:
189 if (with_typemod)
190 buf = printTypmod("bit", typemod, typeform->typmodout);
191 else if ((flags & FORMAT_TYPE_TYPEMOD_GIVEN) != 0)
192 {
193 /*
194 * bit with typmod -1 is not the same as BIT, which means
195 * BIT(1) per SQL spec. Report it as the quoted typename so
196 * that parser will not assign a bogus typmod.
197 */
198 }
199 else
200 buf = pstrdup("bit");
201 break;
202
203 case BOOLOID:
204 buf = pstrdup("boolean");
205 break;
206
207 case BPCHAROID:
208 if (with_typemod)
209 buf = printTypmod("character", typemod, typeform->typmodout);
210 else if ((flags & FORMAT_TYPE_TYPEMOD_GIVEN) != 0)
211 {
212 /*
213 * bpchar with typmod -1 is not the same as CHARACTER, which
214 * means CHARACTER(1) per SQL spec. Report it as bpchar so
215 * that parser will not assign a bogus typmod.
216 */
217 }
218 else
219 buf = pstrdup("character");
220 break;
221
222 case FLOAT4OID:
223 buf = pstrdup("real");
224 break;
225
226 case FLOAT8OID:
227 buf = pstrdup("double precision");
228 break;
229
230 case INT2OID:
231 buf = pstrdup("smallint");
232 break;
233
234 case INT4OID:
235 buf = pstrdup("integer");
236 break;
237
238 case INT8OID:
239 buf = pstrdup("bigint");
240 break;
241
242 case NUMERICOID:
243 if (with_typemod)
244 buf = printTypmod("numeric", typemod, typeform->typmodout);
245 else
246 buf = pstrdup("numeric");
247 break;
248
249 case INTERVALOID:
250 if (with_typemod)
251 buf = printTypmod("interval", typemod, typeform->typmodout);
252 else
253 buf = pstrdup("interval");
254 break;
255
256 case TIMEOID:
257 if (with_typemod)
258 buf = printTypmod("time", typemod, typeform->typmodout);
259 else
260 buf = pstrdup("time without time zone");
261 break;
262
263 case TIMETZOID:
264 if (with_typemod)
265 buf = printTypmod("time", typemod, typeform->typmodout);
266 else
267 buf = pstrdup("time with time zone");
268 break;
269
270 case TIMESTAMPOID:
271 if (with_typemod)
272 buf = printTypmod("timestamp", typemod, typeform->typmodout);
273 else
274 buf = pstrdup("timestamp without time zone");
275 break;
276
277 case TIMESTAMPTZOID:
278 if (with_typemod)
279 buf = printTypmod("timestamp", typemod, typeform->typmodout);
280 else
281 buf = pstrdup("timestamp with time zone");
282 break;
283
284 case VARBITOID:
285 if (with_typemod)
286 buf = printTypmod("bit varying", typemod, typeform->typmodout);
287 else
288 buf = pstrdup("bit varying");
289 break;
290
291 case VARCHAROID:
292 if (with_typemod)
293 buf = printTypmod("character varying", typemod, typeform->typmodout);
294 else
295 buf = pstrdup("character varying");
296 break;
297
298 case JSONOID:
299 buf = pstrdup("json");
300 break;
301 }
302
303 if (buf == NULL)
304 {
305 /*
306 * Default handling: report the name as it appears in the catalog.
307 * Here, we must qualify the name if it is not visible in the search
308 * path or if caller requests it; and we must double-quote it if it's
309 * not a standard identifier or if it matches any keyword.
310 */
311 char *nspname;
312 char *typname;
313
314 if ((flags & FORMAT_TYPE_FORCE_QUALIFY) == 0 &&
316 nspname = NULL;
317 else
318 nspname = get_namespace_name_or_temp(typeform->typnamespace);
319
320 typname = NameStr(typeform->typname);
321
323
324 if (with_typemod)
325 buf = printTypmod(buf, typemod, typeform->typmodout);
326 }
327
328 if (is_array)
329 buf = psprintf("%s[]", buf);
330
331 ReleaseSysCache(tuple);
332
333 return buf;
334}
#define FORMAT_TYPE_ALLOW_INVALID
Definition builtins.h:125
#define FORMAT_TYPE_INVALID_AS_NULL
Definition builtins.h:127
#define FORMAT_TYPE_TYPEMOD_GIVEN
Definition builtins.h:124
static char * printTypmod(const char *typname, int32 typmod, Oid typmodout)
char * get_namespace_name_or_temp(Oid nspid)
Definition lsyscache.c:3540
char * pstrdup(const char *in)
Definition mcxt.c:1781
bool TypeIsVisible(Oid typid)
Definition namespace.c:1039
static char buf[DEFAULT_XLOG_SEG_SIZE]
NameData typname
Definition pg_type.h:41
#define InvalidOid
char * psprintf(const char *fmt,...)
Definition psprintf.c:43
char * quote_qualified_identifier(const char *qualifier, const char *ident)

References buf, elog, ERROR, fb(), FORMAT_TYPE_ALLOW_INVALID, FORMAT_TYPE_FORCE_QUALIFY, FORMAT_TYPE_INVALID_AS_NULL, FORMAT_TYPE_TYPEMOD_GIVEN, get_namespace_name_or_temp(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, NameStr, ObjectIdGetDatum(), printTypmod(), psprintf(), pstrdup(), quote_qualified_identifier(), ReleaseSysCache(), SearchSysCache1(), TypeIsVisible(), and typname.

Referenced by array_recv(), deparse_type_name(), format_type(), format_type_be(), format_type_be_qualified(), format_type_with_typemod(), gbtreekey_in(), getObjectDescription(), getObjectIdentityParts(), lookup_am_handler_func(), oidvectortypes(), and record_recv().

◆ format_type_with_typemod()

◆ generate_operator_clause()

void generate_operator_clause ( StringInfo  buf,
const char leftop,
Oid  leftoptype,
Oid  opoid,
const char rightop,
Oid  rightoptype 
)
extern

Definition at line 13472 of file ruleutils.c.

13476{
13479 char *oprname;
13480 char *nspname;
13481
13484 elog(ERROR, "cache lookup failed for operator %u", opoid);
13486 Assert(operform->oprkind == 'b');
13487 oprname = NameStr(operform->oprname);
13488
13489 nspname = get_namespace_name(operform->oprnamespace);
13490
13492 if (leftoptype != operform->oprleft)
13493 add_cast_to(buf, operform->oprleft);
13494 appendStringInfo(buf, " OPERATOR(%s.", quote_identifier(nspname));
13495 appendStringInfoString(buf, oprname);
13496 appendStringInfo(buf, ") %s", rightop);
13497 if (rightoptype != operform->oprright)
13498 add_cast_to(buf, operform->oprright);
13499
13501}
#define Assert(condition)
Definition c.h:873
FormData_pg_operator * Form_pg_operator
Definition pg_operator.h:83
static void add_cast_to(StringInfo buf, Oid typid)
const char * quote_identifier(const char *ident)
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition stringinfo.c:145
void appendStringInfoString(StringInfo str, const char *s)
Definition stringinfo.c:230

References add_cast_to(), appendStringInfo(), appendStringInfoString(), Assert, buf, elog, ERROR, fb(), get_namespace_name(), GETSTRUCT(), HeapTupleIsValid, NameStr, ObjectIdGetDatum(), quote_identifier(), ReleaseSysCache(), and SearchSysCache1().

Referenced by refresh_by_match_merge(), and ri_GenerateQual().

◆ hex_decode()

uint64 hex_decode ( const char src,
size_t  len,
char dst 
)
extern

Definition at line 265 of file encode.c.

266{
267 return hex_decode_safe(src, len, dst, NULL);
268}
uint64 hex_decode_safe(const char *src, size_t len, char *dst, Node *escontext)
Definition encode.c:351

References fb(), hex_decode_safe(), and len.

◆ hex_decode_safe()

uint64 hex_decode_safe ( const char src,
size_t  len,
char dst,
Node escontext 
)
extern

Definition at line 351 of file encode.c.

352{
353#ifdef USE_NO_SIMD
354 return hex_decode_safe_scalar(src, len, dst, escontext);
355#else
356 const uint64 tail_idx = len & ~(sizeof(Vector8) * 2 - 1);
357 uint64 i;
358 bool success = true;
359
360 /*
361 * We must process 2 vectors at a time since the output will be half the
362 * length of the input.
363 */
364 for (i = 0; i < tail_idx; i += sizeof(Vector8) * 2)
365 {
369
370 vector8_load(&srcv, (const uint8 *) &src[i]);
372
373 vector8_load(&srcv, (const uint8 *) &src[i + sizeof(Vector8)]);
375
377 }
378
379 /*
380 * If something didn't look right in the vector path, try again in the
381 * scalar path so that we can handle it correctly.
382 */
383 if (!success)
384 i = 0;
385
386 return i / 2 + hex_decode_safe_scalar(src + i, len - i, dst + i / 2, escontext);
387#endif
388}
uint8_t uint8
Definition c.h:544
uint64_t uint64
Definition c.h:547
static uint64 hex_decode_safe_scalar(const char *src, size_t len, char *dst, Node *escontext)
Definition encode.c:271
static bool success
Definition initdb.c:187
static void vector8_load(Vector8 *v, const uint8 *s)
Definition simd.h:94
uint64 Vector8
Definition simd.h:47

References fb(), hex_decode_safe_scalar(), i, len, success, and vector8_load().

Referenced by byteain(), and hex_decode().

◆ hex_encode()

uint64 hex_encode ( const char src,
size_t  len,
char dst 
)
extern

Definition at line 202 of file encode.c.

203{
204#ifdef USE_NO_SIMD
205 return hex_encode_scalar(src, len, dst);
206#else
207 const uint64 tail_idx = len & ~(sizeof(Vector8) - 1);
208 uint64 i;
209
210 /*
211 * This splits the high and low nibbles of each byte into separate
212 * vectors, adds the vectors to a mask that converts the nibbles to their
213 * equivalent ASCII bytes, and interleaves those bytes back together to
214 * form the final hex-encoded string.
215 */
216 for (i = 0; i < tail_idx; i += sizeof(Vector8))
217 {
219 Vector8 lo;
220 Vector8 hi;
221 Vector8 mask;
222
223 vector8_load(&srcv, (const uint8 *) &src[i]);
224
226 mask = vector8_gt(lo, vector8_broadcast(0x9));
227 mask = vector8_and(mask, vector8_broadcast('a' - '0' - 10));
228 mask = vector8_add(mask, vector8_broadcast('0'));
229 lo = vector8_add(lo, mask);
230
232 hi = vector8_shift_right(hi, 4);
233 mask = vector8_gt(hi, vector8_broadcast(0x9));
234 mask = vector8_and(mask, vector8_broadcast('a' - '0' - 10));
235 mask = vector8_add(mask, vector8_broadcast('0'));
236 hi = vector8_add(hi, mask);
237
238 vector8_store((uint8 *) &dst[i * 2],
239 vector8_interleave_low(hi, lo));
240 vector8_store((uint8 *) &dst[i * 2 + sizeof(Vector8)],
242 }
243
244 (void) hex_encode_scalar(src + i, len - i, dst + i * 2);
245
246 return (uint64) len * 2;
247#endif
248}
static uint64 hex_encode_scalar(const char *src, size_t len, char *dst)
Definition encode.c:186
static Vector8 vector8_broadcast(const uint8 c)
Definition simd.h:136

References fb(), hex_encode_scalar(), i, len, vector8_broadcast(), and vector8_load().

Referenced by AddFileToBackupManifest(), byteaout(), and SendBackupManifest().

◆ namestrcmp()

int namestrcmp ( Name  name,
const char str 
)
extern

Definition at line 247 of file name.c.

248{
249 if (!name && !str)
250 return 0;
251 if (!name)
252 return -1; /* NULL < anything */
253 if (!str)
254 return 1; /* NULL < anything */
255 return strncmp(NameStr(*name), str, NAMEDATALEN);
256}
const char * str
#define NAMEDATALEN
const char * name

References fb(), name, NAMEDATALEN, NameStr, and str.

Referenced by AlterEventTrigger(), attnameAttNum(), CopyGetAttnums(), expanded_record_lookup_field(), GetAttributeByName(), InitPostgres(), NextCopyFromRawFieldsInternal(), and SPI_fnumber().

◆ namestrcpy()

◆ network_scan_first()

Datum network_scan_first ( Datum  in)
extern

Definition at line 1623 of file network.c.

1624{
1626}
#define DirectFunctionCall1(func, arg1)
Definition fmgr.h:684
Datum network_network(PG_FUNCTION_ARGS)
Definition network.c:1263

References DirectFunctionCall1, and network_network().

Referenced by match_network_subset().

◆ network_scan_last()

Datum network_scan_last ( Datum  in)
extern

Definition at line 1637 of file network.c.

1638{
1641 Int32GetDatum(-1));
1642}
#define DirectFunctionCall2(func, arg1, arg2)
Definition fmgr.h:686
Datum network_broadcast(PG_FUNCTION_ARGS)
Definition network.c:1218
Datum inet_set_masklen(PG_FUNCTION_ARGS)
Definition network.c:320
static Datum Int32GetDatum(int32 X)
Definition postgres.h:222

References DirectFunctionCall1, DirectFunctionCall2, inet_set_masklen(), Int32GetDatum(), and network_broadcast().

Referenced by match_network_subset().

◆ numeric_float8_no_overflow()

Datum numeric_float8_no_overflow ( PG_FUNCTION_ARGS  )
extern

Definition at line 4589 of file numeric.c.

4590{
4591 Numeric num = PG_GETARG_NUMERIC(0);
4592 double val;
4593
4594 if (NUMERIC_IS_SPECIAL(num))
4595 {
4596 if (NUMERIC_IS_PINF(num))
4597 val = HUGE_VAL;
4598 else if (NUMERIC_IS_NINF(num))
4599 val = -HUGE_VAL;
4600 else
4601 val = get_float8_nan();
4602 }
4603 else
4604 {
4605 NumericVar x;
4606
4607 init_var_from_num(num, &x);
4609 }
4610
4612}
#define NUMERIC_IS_SPECIAL(n)
Definition numeric.c:176
static void init_var_from_num(Numeric num, NumericVar *dest)
Definition numeric.c:7181
#define NUMERIC_IS_PINF(n)
Definition numeric.c:208
#define NUMERIC_IS_NINF(n)
Definition numeric.c:209
static double numericvar_to_double_no_overflow(const NumericVar *var)
Definition numeric.c:7971
static float8 get_float8_nan(void)
Definition float.h:84
#define PG_RETURN_FLOAT8(x)
Definition fmgr.h:369
long val
Definition informix.c:689
int x
Definition isn.c:75
#define PG_GETARG_NUMERIC(n)
Definition numeric.h:81

References fb(), get_float8_nan(), init_var_from_num(), NUMERIC_IS_NINF, NUMERIC_IS_PINF, NUMERIC_IS_SPECIAL, numericvar_to_double_no_overflow(), PG_GETARG_NUMERIC, PG_RETURN_FLOAT8, val, and x.

Referenced by convert_numeric_to_scalar(), and gbt_numeric_penalty().

◆ oid_cmp()

int oid_cmp ( const void p1,
const void p2 
)
extern

Definition at line 258 of file oid.c.

259{
260 Oid v1 = *((const Oid *) p1);
261 Oid v2 = *((const Oid *) p2);
262
263 return pg_cmp_u32(v1, v2);
264}
static int pg_cmp_u32(uint32 a, uint32 b)
Definition int.h:719

References fb(), and pg_cmp_u32().

Referenced by aclmembers(), AlterSubscription_refresh(), EnumValuesCreate(), and find_inheritance_children_extended().

◆ oidparse()

Oid oidparse ( Node node)
extern

Definition at line 235 of file oid.c.

236{
237 switch (nodeTag(node))
238 {
239 case T_Integer:
240 return intVal(node);
241 case T_Float:
242
243 /*
244 * Values too large for int4 will be represented as Float
245 * constants by the lexer. Accept these if they are valid OID
246 * strings.
247 */
248 return uint32in_subr(castNode(Float, node)->fval, NULL,
249 "oid", NULL);
250 default:
251 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
252 }
253 return InvalidOid; /* keep compiler quiet */
254}
#define nodeTag(nodeptr)
Definition nodes.h:139
#define castNode(_type_, nodeptr)
Definition nodes.h:182
uint32 uint32in_subr(const char *s, char **endloc, const char *typname, Node *escontext)
Definition numutils.c:897
Definition value.h:48
#define intVal(v)
Definition value.h:79

References castNode, elog, ERROR, fb(), intVal, InvalidOid, nodeTag, and uint32in_subr().

Referenced by get_object_address().

◆ parse_bool()

bool parse_bool ( const char value,
bool result 
)
extern

Definition at line 31 of file bool.c.

32{
33 return parse_bool_with_len(value, strlen(value), result);
34}
bool parse_bool_with_len(const char *value, size_t len, bool *result)
Definition bool.c:37

References fb(), parse_bool_with_len(), and value.

Referenced by executeItemOptUnwrapTarget(), GrantRole(), parse_and_validate_value(), parse_basebackup_options(), parse_extension_control_file(), parse_one_reloption(), pg_decode_startup(), and ProcessStartupPacket().

◆ parse_bool_with_len()

bool parse_bool_with_len ( const char value,
size_t  len,
bool result 
)
extern

Definition at line 37 of file bool.c.

38{
39 /* Check the most-used possibilities first. */
40 switch (*value)
41 {
42 case 't':
43 case 'T':
44 if (pg_strncasecmp(value, "true", len) == 0)
45 {
46 if (result)
47 *result = true;
48 return true;
49 }
50 break;
51 case 'f':
52 case 'F':
53 if (pg_strncasecmp(value, "false", len) == 0)
54 {
55 if (result)
56 *result = false;
57 return true;
58 }
59 break;
60 case 'y':
61 case 'Y':
62 if (pg_strncasecmp(value, "yes", len) == 0)
63 {
64 if (result)
65 *result = true;
66 return true;
67 }
68 break;
69 case 'n':
70 case 'N':
71 if (pg_strncasecmp(value, "no", len) == 0)
72 {
73 if (result)
74 *result = false;
75 return true;
76 }
77 break;
78 case 'o':
79 case 'O':
80 /* 'o' is not unique enough */
81 if (pg_strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
82 {
83 if (result)
84 *result = true;
85 return true;
86 }
87 else if (pg_strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
88 {
89 if (result)
90 *result = false;
91 return true;
92 }
93 break;
94 case '1':
95 if (len == 1)
96 {
97 if (result)
98 *result = true;
99 return true;
100 }
101 break;
102 case '0':
103 if (len == 1)
104 {
105 if (result)
106 *result = false;
107 return true;
108 }
109 break;
110 default:
111 break;
112 }
113
114 if (result)
115 *result = false; /* suppress compiler warning */
116 return false;
117}
int pg_strncasecmp(const char *s1, const char *s2, size_t n)

References len, pg_strncasecmp(), and value.

Referenced by boolin(), and parse_bool().

◆ pg_inet_cidr_ntop()

char * pg_inet_cidr_ntop ( int  af,
const void src,
int  bits,
char dst,
size_t  size 
)
extern

Definition at line 56 of file inet_cidr_ntop.c.

57{
58 switch (af)
59 {
60 case PGSQL_AF_INET:
61 return inet_cidr_ntop_ipv4(src, bits, dst, size);
62 case PGSQL_AF_INET6:
63 return inet_cidr_ntop_ipv6(src, bits, dst, size);
64 default:
66 return NULL;
67 }
68}
static char * inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size)
static char * inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size)
#define PGSQL_AF_INET6
Definition inet.h:40
#define EAFNOSUPPORT
Definition win32_port.h:365

References EAFNOSUPPORT, fb(), inet_cidr_ntop_ipv4(), inet_cidr_ntop_ipv6(), PGSQL_AF_INET, and PGSQL_AF_INET6.

Referenced by cidr_abbrev().

◆ pg_inet_net_pton()

int pg_inet_net_pton ( int  af,
const char src,
void dst,
size_t  size 
)
extern

Definition at line 61 of file inet_net_pton.c.

62{
63 switch (af)
64 {
65 case PGSQL_AF_INET:
66 return size == -1 ?
68 inet_cidr_pton_ipv4(src, dst, size);
69 case PGSQL_AF_INET6:
70 return size == -1 ?
72 inet_cidr_pton_ipv6(src, dst, size);
73 default:
75 return -1;
76 }
77}
static int inet_net_pton_ipv6(const char *src, u_char *dst)
static int inet_net_pton_ipv4(const char *src, u_char *dst)
static int inet_cidr_pton_ipv6(const char *src, u_char *dst, size_t size)
static int inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size)

References EAFNOSUPPORT, fb(), inet_cidr_pton_ipv4(), inet_cidr_pton_ipv6(), inet_net_pton_ipv4(), inet_net_pton_ipv6(), PGSQL_AF_INET, and PGSQL_AF_INET6.

Referenced by network_in().

◆ pg_itoa()

int pg_itoa ( int16  i,
char a 
)
extern

Definition at line 1041 of file numutils.c.

1042{
1043 return pg_ltoa((int32) i, a);
1044}
int32_t int32
Definition c.h:542
int a
Definition isn.c:73
int pg_ltoa(int32 value, char *a)
Definition numutils.c:1119

References a, i, and pg_ltoa().

Referenced by int2out(), int2vectorout(), LogicalTapeImport(), and LogicalTapeSetCreate().

◆ pg_lltoa()

int pg_lltoa ( int64  value,
char a 
)
extern

Definition at line 1226 of file numutils.c.

1227{
1229 int len = 0;
1230
1231 if (value < 0)
1232 {
1233 uvalue = (uint64) 0 - uvalue;
1234 a[len++] = '-';
1235 }
1236
1237 len += pg_ulltoa_n(uvalue, a + len);
1238 a[len] = '\0';
1239 return len;
1240}
int pg_ulltoa_n(uint64 value, char *a)
Definition numutils.c:1139

References a, fb(), len, pg_ulltoa_n(), and value.

Referenced by int8out(), and printsimple().

◆ pg_ltoa()

int pg_ltoa ( int32  value,
char a 
)
extern

Definition at line 1119 of file numutils.c.

1120{
1122 int len = 0;
1123
1124 if (value < 0)
1125 {
1126 uvalue = (uint32) 0 - uvalue;
1127 a[len++] = '-';
1128 }
1129 len += pg_ultoa_n(uvalue, a + len);
1130 a[len] = '\0';
1131 return len;
1132}
uint32_t uint32
Definition c.h:546
int pg_ultoa_n(uint32 value, char *a)
Definition numutils.c:1054

References a, fb(), len, pg_ultoa_n(), and value.

Referenced by executeItemOptUnwrapTarget(), int4out(), pg_itoa(), and printsimple().

◆ pg_strtoint16()

int16 pg_strtoint16 ( const char s)
extern

Definition at line 121 of file numutils.c.

122{
123 return pg_strtoint16_safe(s, NULL);
124}
int16 pg_strtoint16_safe(const char *s, Node *escontext)
Definition numutils.c:127

References fb(), and pg_strtoint16_safe().

◆ pg_strtoint16_safe()

int16 pg_strtoint16_safe ( const char s,
Node escontext 
)
extern

Definition at line 127 of file numutils.c.

128{
129 const char *ptr = s;
130 const char *firstdigit;
131 uint16 tmp = 0;
132 bool neg = false;
133 unsigned char digit;
134 int16 result;
135
136 /*
137 * The majority of cases are likely to be base-10 digits without any
138 * underscore separator characters. We'll first try to parse the string
139 * with the assumption that's the case and only fallback on a slower
140 * implementation which handles hex, octal and binary strings and
141 * underscores if the fastpath version cannot parse the string.
142 */
143
144 /* leave it up to the slow path to look for leading spaces */
145
146 if (*ptr == '-')
147 {
148 ptr++;
149 neg = true;
150 }
151
152 /* a leading '+' is uncommon so leave that for the slow path */
153
154 /* process the first digit */
155 digit = (*ptr - '0');
156
157 /*
158 * Exploit unsigned arithmetic to save having to check both the upper and
159 * lower bounds of the digit.
160 */
161 if (likely(digit < 10))
162 {
163 ptr++;
164 tmp = digit;
165 }
166 else
167 {
168 /* we need at least one digit */
169 goto slow;
170 }
171
172 /* process remaining digits */
173 for (;;)
174 {
175 digit = (*ptr - '0');
176
177 if (digit >= 10)
178 break;
179
180 ptr++;
181
182 if (unlikely(tmp > -(PG_INT16_MIN / 10)))
183 goto out_of_range;
184
185 tmp = tmp * 10 + digit;
186 }
187
188 /* when the string does not end in a digit, let the slow path handle it */
189 if (unlikely(*ptr != '\0'))
190 goto slow;
191
192 if (neg)
193 {
194 if (unlikely(pg_neg_u16_overflow(tmp, &result)))
195 goto out_of_range;
196 return result;
197 }
198
199 if (unlikely(tmp > PG_INT16_MAX))
200 goto out_of_range;
201
202 return (int16) tmp;
203
204slow:
205 tmp = 0;
206 ptr = s;
207 /* no need to reset neg */
208
209 /* skip leading spaces */
210 while (isspace((unsigned char) *ptr))
211 ptr++;
212
213 /* handle sign */
214 if (*ptr == '-')
215 {
216 ptr++;
217 neg = true;
218 }
219 else if (*ptr == '+')
220 ptr++;
221
222 /* process digits */
223 if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
224 {
225 firstdigit = ptr += 2;
226
227 for (;;)
228 {
229 if (isxdigit((unsigned char) *ptr))
230 {
231 if (unlikely(tmp > -(PG_INT16_MIN / 16)))
232 goto out_of_range;
233
234 tmp = tmp * 16 + hexlookup[(unsigned char) *ptr++];
235 }
236 else if (*ptr == '_')
237 {
238 /* underscore must be followed by more digits */
239 ptr++;
240 if (*ptr == '\0' || !isxdigit((unsigned char) *ptr))
241 goto invalid_syntax;
242 }
243 else
244 break;
245 }
246 }
247 else if (ptr[0] == '0' && (ptr[1] == 'o' || ptr[1] == 'O'))
248 {
249 firstdigit = ptr += 2;
250
251 for (;;)
252 {
253 if (*ptr >= '0' && *ptr <= '7')
254 {
255 if (unlikely(tmp > -(PG_INT16_MIN / 8)))
256 goto out_of_range;
257
258 tmp = tmp * 8 + (*ptr++ - '0');
259 }
260 else if (*ptr == '_')
261 {
262 /* underscore must be followed by more digits */
263 ptr++;
264 if (*ptr == '\0' || *ptr < '0' || *ptr > '7')
265 goto invalid_syntax;
266 }
267 else
268 break;
269 }
270 }
271 else if (ptr[0] == '0' && (ptr[1] == 'b' || ptr[1] == 'B'))
272 {
273 firstdigit = ptr += 2;
274
275 for (;;)
276 {
277 if (*ptr >= '0' && *ptr <= '1')
278 {
279 if (unlikely(tmp > -(PG_INT16_MIN / 2)))
280 goto out_of_range;
281
282 tmp = tmp * 2 + (*ptr++ - '0');
283 }
284 else if (*ptr == '_')
285 {
286 /* underscore must be followed by more digits */
287 ptr++;
288 if (*ptr == '\0' || *ptr < '0' || *ptr > '1')
289 goto invalid_syntax;
290 }
291 else
292 break;
293 }
294 }
295 else
296 {
297 firstdigit = ptr;
298
299 for (;;)
300 {
301 if (*ptr >= '0' && *ptr <= '9')
302 {
303 if (unlikely(tmp > -(PG_INT16_MIN / 10)))
304 goto out_of_range;
305
306 tmp = tmp * 10 + (*ptr++ - '0');
307 }
308 else if (*ptr == '_')
309 {
310 /* underscore may not be first */
311 if (unlikely(ptr == firstdigit))
312 goto invalid_syntax;
313 /* and it must be followed by more digits */
314 ptr++;
315 if (*ptr == '\0' || !isdigit((unsigned char) *ptr))
316 goto invalid_syntax;
317 }
318 else
319 break;
320 }
321 }
322
323 /* require at least one digit */
324 if (unlikely(ptr == firstdigit))
325 goto invalid_syntax;
326
327 /* allow trailing whitespace, but not other trailing chars */
328 while (isspace((unsigned char) *ptr))
329 ptr++;
330
331 if (unlikely(*ptr != '\0'))
332 goto invalid_syntax;
333
334 if (neg)
335 {
336 if (unlikely(pg_neg_u16_overflow(tmp, &result)))
337 goto out_of_range;
338 return result;
339 }
340
341 if (tmp > PG_INT16_MAX)
342 goto out_of_range;
343
344 return (int16) tmp;
345
347 ereturn(escontext, 0,
349 errmsg("value \"%s\" is out of range for type %s",
350 s, "smallint")));
351
353 ereturn(escontext, 0,
355 errmsg("invalid input syntax for type %s: \"%s\"",
356 "smallint", s)));
357}
#define likely(x)
Definition c.h:411
#define PG_INT16_MIN
Definition c.h:599
uint16_t uint16
Definition c.h:545
#define unlikely(x)
Definition c.h:412
#define PG_INT16_MAX
Definition c.h:600
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define ereturn(context, dummy_value,...)
Definition elog.h:278
static bool pg_neg_u16_overflow(uint16 a, int16 *result)
Definition int.h:420
static const int8 hexlookup[128]
Definition numutils.c:87

References ereturn, errcode(), errmsg(), fb(), hexlookup, likely, PG_INT16_MAX, PG_INT16_MIN, pg_neg_u16_overflow(), and unlikely.

Referenced by dependencies_scalar(), int2in(), ndistinct_scalar(), and pg_strtoint16().

◆ pg_strtoint32()

int32 pg_strtoint32 ( const char s)
extern

Definition at line 382 of file numutils.c.

383{
384 return pg_strtoint32_safe(s, NULL);
385}
int32 pg_strtoint32_safe(const char *s, Node *escontext)
Definition numutils.c:388

References fb(), and pg_strtoint32_safe().

Referenced by ArrayGetIntegerTypmods(), check_foreign_key(), libpqrcv_endstreaming(), libpqrcv_identify_system(), pq_parse_errornotice(), prsd_headline(), and text_format().

◆ pg_strtoint32_safe()

int32 pg_strtoint32_safe ( const char s,
Node escontext 
)
extern

Definition at line 388 of file numutils.c.

389{
390 const char *ptr = s;
391 const char *firstdigit;
392 uint32 tmp = 0;
393 bool neg = false;
394 unsigned char digit;
395 int32 result;
396
397 /*
398 * The majority of cases are likely to be base-10 digits without any
399 * underscore separator characters. We'll first try to parse the string
400 * with the assumption that's the case and only fallback on a slower
401 * implementation which handles hex, octal and binary strings and
402 * underscores if the fastpath version cannot parse the string.
403 */
404
405 /* leave it up to the slow path to look for leading spaces */
406
407 if (*ptr == '-')
408 {
409 ptr++;
410 neg = true;
411 }
412
413 /* a leading '+' is uncommon so leave that for the slow path */
414
415 /* process the first digit */
416 digit = (*ptr - '0');
417
418 /*
419 * Exploit unsigned arithmetic to save having to check both the upper and
420 * lower bounds of the digit.
421 */
422 if (likely(digit < 10))
423 {
424 ptr++;
425 tmp = digit;
426 }
427 else
428 {
429 /* we need at least one digit */
430 goto slow;
431 }
432
433 /* process remaining digits */
434 for (;;)
435 {
436 digit = (*ptr - '0');
437
438 if (digit >= 10)
439 break;
440
441 ptr++;
442
443 if (unlikely(tmp > -(PG_INT32_MIN / 10)))
444 goto out_of_range;
445
446 tmp = tmp * 10 + digit;
447 }
448
449 /* when the string does not end in a digit, let the slow path handle it */
450 if (unlikely(*ptr != '\0'))
451 goto slow;
452
453 if (neg)
454 {
455 if (unlikely(pg_neg_u32_overflow(tmp, &result)))
456 goto out_of_range;
457 return result;
458 }
459
460 if (unlikely(tmp > PG_INT32_MAX))
461 goto out_of_range;
462
463 return (int32) tmp;
464
465slow:
466 tmp = 0;
467 ptr = s;
468 /* no need to reset neg */
469
470 /* skip leading spaces */
471 while (isspace((unsigned char) *ptr))
472 ptr++;
473
474 /* handle sign */
475 if (*ptr == '-')
476 {
477 ptr++;
478 neg = true;
479 }
480 else if (*ptr == '+')
481 ptr++;
482
483 /* process digits */
484 if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
485 {
486 firstdigit = ptr += 2;
487
488 for (;;)
489 {
490 if (isxdigit((unsigned char) *ptr))
491 {
492 if (unlikely(tmp > -(PG_INT32_MIN / 16)))
493 goto out_of_range;
494
495 tmp = tmp * 16 + hexlookup[(unsigned char) *ptr++];
496 }
497 else if (*ptr == '_')
498 {
499 /* underscore must be followed by more digits */
500 ptr++;
501 if (*ptr == '\0' || !isxdigit((unsigned char) *ptr))
502 goto invalid_syntax;
503 }
504 else
505 break;
506 }
507 }
508 else if (ptr[0] == '0' && (ptr[1] == 'o' || ptr[1] == 'O'))
509 {
510 firstdigit = ptr += 2;
511
512 for (;;)
513 {
514 if (*ptr >= '0' && *ptr <= '7')
515 {
516 if (unlikely(tmp > -(PG_INT32_MIN / 8)))
517 goto out_of_range;
518
519 tmp = tmp * 8 + (*ptr++ - '0');
520 }
521 else if (*ptr == '_')
522 {
523 /* underscore must be followed by more digits */
524 ptr++;
525 if (*ptr == '\0' || *ptr < '0' || *ptr > '7')
526 goto invalid_syntax;
527 }
528 else
529 break;
530 }
531 }
532 else if (ptr[0] == '0' && (ptr[1] == 'b' || ptr[1] == 'B'))
533 {
534 firstdigit = ptr += 2;
535
536 for (;;)
537 {
538 if (*ptr >= '0' && *ptr <= '1')
539 {
540 if (unlikely(tmp > -(PG_INT32_MIN / 2)))
541 goto out_of_range;
542
543 tmp = tmp * 2 + (*ptr++ - '0');
544 }
545 else if (*ptr == '_')
546 {
547 /* underscore must be followed by more digits */
548 ptr++;
549 if (*ptr == '\0' || *ptr < '0' || *ptr > '1')
550 goto invalid_syntax;
551 }
552 else
553 break;
554 }
555 }
556 else
557 {
558 firstdigit = ptr;
559
560 for (;;)
561 {
562 if (*ptr >= '0' && *ptr <= '9')
563 {
564 if (unlikely(tmp > -(PG_INT32_MIN / 10)))
565 goto out_of_range;
566
567 tmp = tmp * 10 + (*ptr++ - '0');
568 }
569 else if (*ptr == '_')
570 {
571 /* underscore may not be first */
572 if (unlikely(ptr == firstdigit))
573 goto invalid_syntax;
574 /* and it must be followed by more digits */
575 ptr++;
576 if (*ptr == '\0' || !isdigit((unsigned char) *ptr))
577 goto invalid_syntax;
578 }
579 else
580 break;
581 }
582 }
583
584 /* require at least one digit */
585 if (unlikely(ptr == firstdigit))
586 goto invalid_syntax;
587
588 /* allow trailing whitespace, but not other trailing chars */
589 while (isspace((unsigned char) *ptr))
590 ptr++;
591
592 if (unlikely(*ptr != '\0'))
593 goto invalid_syntax;
594
595 if (neg)
596 {
597 if (unlikely(pg_neg_u32_overflow(tmp, &result)))
598 goto out_of_range;
599 return result;
600 }
601
602 if (tmp > PG_INT32_MAX)
603 goto out_of_range;
604
605 return (int32) tmp;
606
608 ereturn(escontext, 0,
610 errmsg("value \"%s\" is out of range for type %s",
611 s, "integer")));
612
614 ereturn(escontext, 0,
616 errmsg("invalid input syntax for type %s: \"%s\"",
617 "integer", s)));
618}
#define PG_INT32_MAX
Definition c.h:603
#define PG_INT32_MIN
Definition c.h:602
static bool pg_neg_u32_overflow(uint32 a, int32 *result)
Definition int.h:493

References ereturn, errcode(), errmsg(), fb(), hexlookup, likely, PG_INT32_MAX, PG_INT32_MIN, pg_neg_u32_overflow(), and unlikely.

Referenced by defGetCopyHeaderOption(), int4in(), ndistinct_scalar(), pg_strtoint32(), and process_integer_literal().

◆ pg_strtoint64()

int64 pg_strtoint64 ( const char s)
extern

Definition at line 643 of file numutils.c.

644{
645 return pg_strtoint64_safe(s, NULL);
646}
int64 pg_strtoint64_safe(const char *s, Node *escontext)
Definition numutils.c:649

References fb(), and pg_strtoint64_safe().

Referenced by defGetCopyRejectLimitOption().

◆ pg_strtoint64_safe()

int64 pg_strtoint64_safe ( const char s,
Node escontext 
)
extern

Definition at line 649 of file numutils.c.

650{
651 const char *ptr = s;
652 const char *firstdigit;
653 uint64 tmp = 0;
654 bool neg = false;
655 unsigned char digit;
656 int64 result;
657
658 /*
659 * The majority of cases are likely to be base-10 digits without any
660 * underscore separator characters. We'll first try to parse the string
661 * with the assumption that's the case and only fallback on a slower
662 * implementation which handles hex, octal and binary strings and
663 * underscores if the fastpath version cannot parse the string.
664 */
665
666 /* leave it up to the slow path to look for leading spaces */
667
668 if (*ptr == '-')
669 {
670 ptr++;
671 neg = true;
672 }
673
674 /* a leading '+' is uncommon so leave that for the slow path */
675
676 /* process the first digit */
677 digit = (*ptr - '0');
678
679 /*
680 * Exploit unsigned arithmetic to save having to check both the upper and
681 * lower bounds of the digit.
682 */
683 if (likely(digit < 10))
684 {
685 ptr++;
686 tmp = digit;
687 }
688 else
689 {
690 /* we need at least one digit */
691 goto slow;
692 }
693
694 /* process remaining digits */
695 for (;;)
696 {
697 digit = (*ptr - '0');
698
699 if (digit >= 10)
700 break;
701
702 ptr++;
703
704 if (unlikely(tmp > -(PG_INT64_MIN / 10)))
705 goto out_of_range;
706
707 tmp = tmp * 10 + digit;
708 }
709
710 /* when the string does not end in a digit, let the slow path handle it */
711 if (unlikely(*ptr != '\0'))
712 goto slow;
713
714 if (neg)
715 {
716 if (unlikely(pg_neg_u64_overflow(tmp, &result)))
717 goto out_of_range;
718 return result;
719 }
720
721 if (unlikely(tmp > PG_INT64_MAX))
722 goto out_of_range;
723
724 return (int64) tmp;
725
726slow:
727 tmp = 0;
728 ptr = s;
729 /* no need to reset neg */
730
731 /* skip leading spaces */
732 while (isspace((unsigned char) *ptr))
733 ptr++;
734
735 /* handle sign */
736 if (*ptr == '-')
737 {
738 ptr++;
739 neg = true;
740 }
741 else if (*ptr == '+')
742 ptr++;
743
744 /* process digits */
745 if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
746 {
747 firstdigit = ptr += 2;
748
749 for (;;)
750 {
751 if (isxdigit((unsigned char) *ptr))
752 {
753 if (unlikely(tmp > -(PG_INT64_MIN / 16)))
754 goto out_of_range;
755
756 tmp = tmp * 16 + hexlookup[(unsigned char) *ptr++];
757 }
758 else if (*ptr == '_')
759 {
760 /* underscore must be followed by more digits */
761 ptr++;
762 if (*ptr == '\0' || !isxdigit((unsigned char) *ptr))
763 goto invalid_syntax;
764 }
765 else
766 break;
767 }
768 }
769 else if (ptr[0] == '0' && (ptr[1] == 'o' || ptr[1] == 'O'))
770 {
771 firstdigit = ptr += 2;
772
773 for (;;)
774 {
775 if (*ptr >= '0' && *ptr <= '7')
776 {
777 if (unlikely(tmp > -(PG_INT64_MIN / 8)))
778 goto out_of_range;
779
780 tmp = tmp * 8 + (*ptr++ - '0');
781 }
782 else if (*ptr == '_')
783 {
784 /* underscore must be followed by more digits */
785 ptr++;
786 if (*ptr == '\0' || *ptr < '0' || *ptr > '7')
787 goto invalid_syntax;
788 }
789 else
790 break;
791 }
792 }
793 else if (ptr[0] == '0' && (ptr[1] == 'b' || ptr[1] == 'B'))
794 {
795 firstdigit = ptr += 2;
796
797 for (;;)
798 {
799 if (*ptr >= '0' && *ptr <= '1')
800 {
801 if (unlikely(tmp > -(PG_INT64_MIN / 2)))
802 goto out_of_range;
803
804 tmp = tmp * 2 + (*ptr++ - '0');
805 }
806 else if (*ptr == '_')
807 {
808 /* underscore must be followed by more digits */
809 ptr++;
810 if (*ptr == '\0' || *ptr < '0' || *ptr > '1')
811 goto invalid_syntax;
812 }
813 else
814 break;
815 }
816 }
817 else
818 {
819 firstdigit = ptr;
820
821 for (;;)
822 {
823 if (*ptr >= '0' && *ptr <= '9')
824 {
825 if (unlikely(tmp > -(PG_INT64_MIN / 10)))
826 goto out_of_range;
827
828 tmp = tmp * 10 + (*ptr++ - '0');
829 }
830 else if (*ptr == '_')
831 {
832 /* underscore may not be first */
833 if (unlikely(ptr == firstdigit))
834 goto invalid_syntax;
835 /* and it must be followed by more digits */
836 ptr++;
837 if (*ptr == '\0' || !isdigit((unsigned char) *ptr))
838 goto invalid_syntax;
839 }
840 else
841 break;
842 }
843 }
844
845 /* require at least one digit */
846 if (unlikely(ptr == firstdigit))
847 goto invalid_syntax;
848
849 /* allow trailing whitespace, but not other trailing chars */
850 while (isspace((unsigned char) *ptr))
851 ptr++;
852
853 if (unlikely(*ptr != '\0'))
854 goto invalid_syntax;
855
856 if (neg)
857 {
858 if (unlikely(pg_neg_u64_overflow(tmp, &result)))
859 goto out_of_range;
860 return result;
861 }
862
863 if (tmp > PG_INT64_MAX)
864 goto out_of_range;
865
866 return (int64) tmp;
867
869 ereturn(escontext, 0,
871 errmsg("value \"%s\" is out of range for type %s",
872 s, "bigint")));
873
875 ereturn(escontext, 0,
877 errmsg("invalid input syntax for type %s: \"%s\"",
878 "bigint", s)));
879}
int64_t int64
Definition c.h:543
#define PG_INT64_MAX
Definition c.h:606
#define PG_INT64_MIN
Definition c.h:605
static bool pg_neg_u64_overflow(uint64 a, int64 *result)
Definition int.h:576

References ereturn, errcode(), errmsg(), fb(), hexlookup, likely, PG_INT64_MAX, PG_INT64_MIN, pg_neg_u64_overflow(), and unlikely.

Referenced by int8in(), make_const(), and pg_strtoint64().

◆ pg_ulltoa_n()

int pg_ulltoa_n ( uint64  value,
char a 
)
extern

Definition at line 1139 of file numutils.c.

1140{
1141 int olength,
1142 i = 0;
1143 uint32 value2;
1144
1145 /* Degenerate case */
1146 if (value == 0)
1147 {
1148 *a = '0';
1149 return 1;
1150 }
1151
1153
1154 /* Compute the result string. */
1155 while (value >= 100000000)
1156 {
1157 const uint64 q = value / 100000000;
1158 uint32 value3 = (uint32) (value - 100000000 * q);
1159
1160 const uint32 c = value3 % 10000;
1161 const uint32 d = value3 / 10000;
1162 const uint32 c0 = (c % 100) << 1;
1163 const uint32 c1 = (c / 100) << 1;
1164 const uint32 d0 = (d % 100) << 1;
1165 const uint32 d1 = (d / 100) << 1;
1166
1167 char *pos = a + olength - i;
1168
1169 value = q;
1170
1171 memcpy(pos - 2, DIGIT_TABLE + c0, 2);
1172 memcpy(pos - 4, DIGIT_TABLE + c1, 2);
1173 memcpy(pos - 6, DIGIT_TABLE + d0, 2);
1174 memcpy(pos - 8, DIGIT_TABLE + d1, 2);
1175 i += 8;
1176 }
1177
1178 /* Switch to 32-bit for speed */
1179 value2 = (uint32) value;
1180
1181 if (value2 >= 10000)
1182 {
1183 const uint32 c = value2 - 10000 * (value2 / 10000);
1184 const uint32 c0 = (c % 100) << 1;
1185 const uint32 c1 = (c / 100) << 1;
1186
1187 char *pos = a + olength - i;
1188
1189 value2 /= 10000;
1190
1191 memcpy(pos - 2, DIGIT_TABLE + c0, 2);
1192 memcpy(pos - 4, DIGIT_TABLE + c1, 2);
1193 i += 4;
1194 }
1195 if (value2 >= 100)
1196 {
1197 const uint32 c = (value2 % 100) << 1;
1198 char *pos = a + olength - i;
1199
1200 value2 /= 100;
1201
1202 memcpy(pos - 2, DIGIT_TABLE + c, 2);
1203 i += 2;
1204 }
1205 if (value2 >= 10)
1206 {
1207 const uint32 c = value2 << 1;
1208 char *pos = a + olength - i;
1209
1210 memcpy(pos - 2, DIGIT_TABLE + c, 2);
1211 }
1212 else
1213 *a = (char) ('0' + value2);
1214
1215 return olength;
1216}
static const char DIGIT_TABLE[200]
Definition numutils.c:28
static int decimalLength64(const uint64 v)
Definition numutils.c:63
char * c

References a, decimalLength64(), DIGIT_TABLE, fb(), i, and value.

Referenced by BuildQueryCompletionString(), oid8out(), and pg_lltoa().

◆ pg_ultoa_n()

int pg_ultoa_n ( uint32  value,
char a 
)
extern

Definition at line 1054 of file numutils.c.

1055{
1056 int olength,
1057 i = 0;
1058
1059 /* Degenerate case */
1060 if (value == 0)
1061 {
1062 *a = '0';
1063 return 1;
1064 }
1065
1067
1068 /* Compute the result string. */
1069 while (value >= 10000)
1070 {
1071 const uint32 c = value - 10000 * (value / 10000);
1072 const uint32 c0 = (c % 100) << 1;
1073 const uint32 c1 = (c / 100) << 1;
1074
1075 char *pos = a + olength - i;
1076
1077 value /= 10000;
1078
1079 memcpy(pos - 2, DIGIT_TABLE + c0, 2);
1080 memcpy(pos - 4, DIGIT_TABLE + c1, 2);
1081 i += 4;
1082 }
1083 if (value >= 100)
1084 {
1085 const uint32 c = (value % 100) << 1;
1086
1087 char *pos = a + olength - i;
1088
1089 value /= 100;
1090
1091 memcpy(pos - 2, DIGIT_TABLE + c, 2);
1092 i += 2;
1093 }
1094 if (value >= 10)
1095 {
1096 const uint32 c = value << 1;
1097
1098 char *pos = a + olength - i;
1099
1100 memcpy(pos - 2, DIGIT_TABLE + c, 2);
1101 }
1102 else
1103 {
1104 *a = (char) ('0' + value);
1105 }
1106
1107 return olength;
1108}
static int decimalLength32(const uint32 v)
Definition numutils.c:44

References a, decimalLength32(), DIGIT_TABLE, fb(), i, and value.

Referenced by pg_ltoa(), pg_ultostr(), pg_ultostr_zeropad(), and printsimple().

◆ pg_ultostr()

char * pg_ultostr ( char str,
uint32  value 
)
extern

Definition at line 1306 of file numutils.c.

1307{
1308 int len = pg_ultoa_n(value, str);
1309
1310 return str + len;
1311}

References len, pg_ultoa_n(), str, and value.

Referenced by AppendSeconds().

◆ pg_ultostr_zeropad()

char * pg_ultostr_zeropad ( char str,
uint32  value,
int32  minwidth 
)
extern

Definition at line 1266 of file numutils.c.

1267{
1268 int len;
1269
1270 Assert(minwidth > 0);
1271
1272 if (value < 100 && minwidth == 2) /* Short cut for common case */
1273 {
1274 memcpy(str, DIGIT_TABLE + value * 2, 2);
1275 return str + 2;
1276 }
1277
1278 len = pg_ultoa_n(value, str);
1279 if (len >= minwidth)
1280 return str + len;
1281
1282 memmove(str + minwidth - len, str, len);
1283 memset(str, '0', minwidth - len);
1284 return str + minwidth;
1285}

References Assert, DIGIT_TABLE, fb(), len, pg_ultoa_n(), str, and value.

Referenced by AppendSeconds(), EncodeDateOnly(), EncodeDateTime(), EncodeTimeOnly(), and EncodeTimezone().

◆ quote_identifier()

const char * quote_identifier ( const char ident)
extern

Definition at line 13060 of file ruleutils.c.

13061{
13062 /*
13063 * Can avoid quoting if ident starts with a lowercase letter or underscore
13064 * and contains only lowercase letters, digits, and underscores, *and* is
13065 * not any SQL keyword. Otherwise, supply quotes.
13066 */
13067 int nquotes = 0;
13068 bool safe;
13069 const char *ptr;
13070 char *result;
13071 char *optr;
13072
13073 /*
13074 * would like to use <ctype.h> macros here, but they might yield unwanted
13075 * locale-specific results...
13076 */
13077 safe = ((ident[0] >= 'a' && ident[0] <= 'z') || ident[0] == '_');
13078
13079 for (ptr = ident; *ptr; ptr++)
13080 {
13081 char ch = *ptr;
13082
13083 if ((ch >= 'a' && ch <= 'z') ||
13084 (ch >= '0' && ch <= '9') ||
13085 (ch == '_'))
13086 {
13087 /* okay */
13088 }
13089 else
13090 {
13091 safe = false;
13092 if (ch == '"')
13093 nquotes++;
13094 }
13095 }
13096
13098 safe = false;
13099
13100 if (safe)
13101 {
13102 /*
13103 * Check for keyword. We quote keywords except for unreserved ones.
13104 * (In some cases we could avoid quoting a col_name or type_func_name
13105 * keyword, but it seems much harder than it's worth to tell that.)
13106 *
13107 * Note: ScanKeywordLookup() does case-insensitive comparison, but
13108 * that's fine, since we already know we have all-lower-case.
13109 */
13111
13113 safe = false;
13114 }
13115
13116 if (safe)
13117 return ident; /* no change needed */
13118
13119 result = (char *) palloc(strlen(ident) + nquotes + 2 + 1);
13120
13121 optr = result;
13122 *optr++ = '"';
13123 for (ptr = ident; *ptr; ptr++)
13124 {
13125 char ch = *ptr;
13126
13127 if (ch == '"')
13128 *optr++ = '"';
13129 *optr++ = ch;
13130 }
13131 *optr++ = '"';
13132 *optr = '\0';
13133
13134 return result;
13135}
const uint8 ScanKeywordCategories[SCANKEYWORDS_NUM_KEYWORDS]
Definition keywords.c:29
#define ident
PGDLLIMPORT const ScanKeywordList ScanKeywords
#define UNRESERVED_KEYWORD
Definition keywords.h:20
int ScanKeywordLookup(const char *str, const ScanKeywordList *keywords)
Definition kwlookup.c:38
bool quote_all_identifiers
Definition ruleutils.c:339

References fb(), ident, palloc(), pg_malloc(), quote_all_identifiers, ScanKeywordCategories, ScanKeywordLookup(), ScanKeywords, and UNRESERVED_KEYWORD.

Referenced by add_cast_to(), appendFunctionName(), ATPrepAlterColumnType(), CheckMyDatabase(), copy_table(), createdb(), CreateSchemaCommand(), decompile_column_index_array(), deparseAnalyzeSql(), deparseColumnRef(), deparseOperatorName(), deparseRelation(), execute_extension_script(), ExplainIndexScanDetails(), ExplainNode(), ExplainTargetRel(), extended_statistics_update(), flatten_set_variable_args(), format_operator_extended(), generate_operator_clause(), generate_operator_name(), get_column_alias_list(), get_from_clause_coldeflist(), get_from_clause_item(), get_insert_query_def(), get_json_table(), get_json_table_columns(), get_json_table_nested_columns(), get_merge_query_def(), get_opclass_name(), get_parameter(), get_reloptions(), get_returning_clause(), get_rte_alias(), get_rule_expr(), get_rule_windowclause(), get_rule_windowspec(), get_select_query_def(), get_target_list(), get_update_query_targetlist_def(), get_utility_query_def(), get_variable(), get_windowfunc_expr_helper(), get_with_clause(), get_xmltable(), getObjectIdentityParts(), libpqrcv_alter_slot(), make_ruledef(), NameListToQuotedString(), old_9_6_invalidate_hash_indexes(), overexplain_alias(), overexplain_range_table(), pg_get_constraintdef_worker(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), pg_identify_object(), PLy_quote_ident(), postgresExplainForeignScan(), postgresImportForeignSchema(), print_function_arguments(), process_extension_updates(), processIndirection(), quote_ident(), quote_object_name(), quote_qualified_identifier(), regdatabaseout(), regnamespaceout(), regoperout(), regroleout(), ReplicationSlotDropAtPubNode(), sepgsql_attribute_post_create(), sepgsql_database_post_create(), sepgsql_relation_post_create(), sepgsql_schema_post_create(), serialize_deflist(), set_frozenxids(), show_sortorder_options(), show_window_def(), test_inline_in_from_support_func(), text_format_string_conversion(), tuple_to_stringinfo(), and worker_spi_main().

◆ quote_literal_cstr()

char * quote_literal_cstr ( const char rawstr)
extern

Definition at line 101 of file quote.c.

102{
103 char *result;
104 int len;
105 int newlen;
106
107 len = strlen(rawstr);
108 /* We make a worst-case result area; wasting a little space is OK */
109 result = palloc(
110 (len * 2) /* doubling for every character if each one is
111 * a quote */
112 + 3 /* two outer quotes + possibly 'E' if needed */
113 + 1 /* null terminator */
114 );
115
117 result[newlen] = '\0';
118
119 return result;
120}
static size_t quote_literal_internal(char *dst, const char *src, size_t len)
Definition quote.c:45

References fb(), len, palloc(), and quote_literal_internal().

Referenced by build_tuplestore_recursively(), copy_sequences(), fetch_remote_slots(), fetch_remote_table_info(), get_sql_delete(), get_sql_insert(), get_sql_update(), get_tuple_of_interest(), GetPublicationsStr(), pg_decode_commit_prepared_txn(), pg_decode_prepare_txn(), pg_decode_rollback_prepared_txn(), pg_decode_stream_prepare(), PLy_quote_literal(), PLy_quote_nullable(), text_format_string_conversion(), and validate_remote_info().

◆ quote_qualified_identifier()

◆ regexp_fixed_prefix()

char * regexp_fixed_prefix ( text text_re,
bool  case_insensitive,
Oid  collation,
bool exact 
)
extern

Definition at line 2022 of file regexp.c.

2024{
2025 char *result;
2026 regex_t *re;
2027 int cflags;
2028 int re_result;
2029 pg_wchar *str;
2030 size_t slen;
2031 size_t maxlen;
2032 char errMsg[100];
2033
2034 *exact = false; /* default result */
2035
2036 /* Compile RE */
2037 cflags = REG_ADVANCED;
2038 if (case_insensitive)
2039 cflags |= REG_ICASE;
2040
2041 re = RE_compile_and_cache(text_re, cflags | REG_NOSUB, collation);
2042
2043 /* Examine it to see if there's a fixed prefix */
2044 re_result = pg_regprefix(re, &str, &slen);
2045
2046 switch (re_result)
2047 {
2048 case REG_NOMATCH:
2049 return NULL;
2050
2051 case REG_PREFIX:
2052 /* continue with wchar conversion */
2053 break;
2054
2055 case REG_EXACT:
2056 *exact = true;
2057 /* continue with wchar conversion */
2058 break;
2059
2060 default:
2061 /* re failed??? */
2062 pg_regerror(re_result, re, errMsg, sizeof(errMsg));
2063 ereport(ERROR,
2065 errmsg("regular expression failed: %s", errMsg)));
2066 break;
2067 }
2068
2069 /* Convert pg_wchar result back to database encoding */
2070 maxlen = pg_database_encoding_max_length() * slen + 1;
2071 result = (char *) palloc(maxlen);
2072 slen = pg_wchar2mb_with_len(str, result, slen);
2073 Assert(slen < maxlen);
2074
2075 pfree(str);
2076
2077 return result;
2078}
#define ereport(elevel,...)
Definition elog.h:150
unsigned int pg_wchar
Definition mbprint.c:31
int pg_wchar2mb_with_len(const pg_wchar *from, char *to, int len)
Definition mbutils.c:1011
int pg_database_encoding_max_length(void)
Definition mbutils.c:1549
void pfree(void *pointer)
Definition mcxt.c:1616
size_t pg_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
Definition regerror.c:60
#define REG_ICASE
Definition regex.h:184
#define REG_NOMATCH
Definition regex.h:216
#define REG_EXACT
Definition regex.h:240
#define REG_PREFIX
Definition regex.h:239
#define REG_ADVANCED
Definition regex.h:181
#define REG_NOSUB
Definition regex.h:185
#define regex_t
Definition regex.h:245
regex_t * RE_compile_and_cache(text *text_re, int cflags, Oid collation)
Definition regexp.c:141
int pg_regprefix(regex_t *re, chr **string, size_t *slength)
Definition regprefix.c:46

References Assert, ereport, errcode(), errmsg(), ERROR, fb(), palloc(), pfree(), pg_database_encoding_max_length(), pg_regerror(), pg_regprefix(), pg_wchar2mb_with_len(), RE_compile_and_cache(), REG_ADVANCED, REG_EXACT, REG_ICASE, REG_NOMATCH, REG_NOSUB, REG_PREFIX, regex_t, and str.

Referenced by regex_fixed_prefix().

◆ text_to_cstring()

char * text_to_cstring ( const text t)
extern

Definition at line 214 of file varlena.c.

215{
216 /* must cast away the const, unfortunately */
219 char *result;
220
221 result = (char *) palloc(len + 1);
222 memcpy(result, VARDATA_ANY(tunpacked), len);
223 result[len] = '\0';
224
225 if (tunpacked != t)
227
228 return result;
229}
#define unconstify(underlying_type, expr)
Definition c.h:1240
struct varlena * pg_detoast_datum_packed(struct varlena *datum)
Definition fmgr.c:1829
static Size VARSIZE_ANY_EXHDR(const void *PTR)
Definition varatt.h:472
static char * VARDATA_ANY(const void *PTR)
Definition varatt.h:486

References fb(), len, palloc(), pfree(), pg_detoast_datum_packed(), unconstify, VARDATA_ANY(), and VARSIZE_ANY_EXHDR().

Referenced by array_to_text(), array_to_text_null(), binary_upgrade_add_sub_rel_state(), binary_upgrade_create_empty_extension(), binary_upgrade_replorigin_advance(), binary_upgrade_set_missing_value(), connectby_text(), connectby_text_serial(), convert_and_check_filename(), convert_any_priv_string(), convert_column_name(), convert_database_name(), convert_foreign_data_wrapper_name(), convert_function_name(), convert_language_name(), convert_schema_name(), convert_server_name(), convert_tablespace_name(), convert_type_name(), crosstab(), crosstab_hash(), cursor_to_xml(), cursor_to_xmlschema(), daitch_mokotoff(), database_to_xml(), database_to_xml_and_xmlschema(), database_to_xmlschema(), datetime_to_char_body(), dblink_cancel_query(), dblink_close(), dblink_connect(), dblink_disconnect(), dblink_error_message(), dblink_exec(), dblink_fetch(), dblink_get_notify(), dblink_is_busy(), dblink_open(), dblink_record_internal(), dblink_send_query(), deserialize_deflist(), difference(), dmetaphone(), dmetaphone_alt(), do_to_timestamp(), errno_from_string(), ExecAlterExtensionStmt(), execute_extension_script(), executeDateTimeMethod(), get_raw_page_fork(), get_raw_page_fork_1_9(), has_param_priv_byname(), has_sequence_privilege_id_name(), has_sequence_privilege_name(), has_sequence_privilege_name_name(), injection_points_attach(), injection_points_attach_func(), injection_points_cached(), injection_points_detach(), injection_points_load(), injection_points_run(), injection_points_wakeup(), json_object_field(), json_object_field_text(), jsonb_set_lax(), JsonItemFromDatum(), ltree_addtext(), ltree_textadd(), NUM_cache(), parse_datetime(), parse_ident(), pg_backup_start(), pg_create_restore_point(), pg_crypt(), pg_current_logfile(), pg_get_expr_worker(), pg_get_logical_snapshot_info(), pg_get_logical_snapshot_meta(), pg_get_publication_sequences(), pg_get_serial_sequence(), pg_index_column_has_property(), pg_index_has_property(), pg_indexam_has_property(), pg_input_is_valid_common(), pg_logical_emit_message_bytea(), pg_ls_replslotdir(), pg_notify(), pg_prewarm(), pg_relation_size(), pg_replication_origin_advance(), pg_replication_origin_create(), pg_replication_origin_drop(), pg_replication_origin_oid(), pg_replication_origin_progress(), pg_replication_origin_session_setup(), pg_size_bytes(), pg_split_walfile_name(), pg_stat_get_progress_info(), pg_stat_get_replication_slot(), pg_stat_have_stats(), pg_stat_reset_replication_slot(), pg_stat_reset_shared(), pg_stat_reset_slru(), pgxml_texttoxmlchar(), phraseto_tsquery_byid(), plainto_tsquery_byid(), postgres_fdw_disconnect(), query_to_xml(), query_to_xml_and_xmlschema(), query_to_xmlschema(), quote_ident(), quote_ident_cstr(), range_constructor3(), regress_setenv(), replorigin_by_oid(), schema_to_xml(), schema_to_xml_and_xmlschema(), schema_to_xmlschema(), sepgsql_mcstrans_in(), sepgsql_mcstrans_out(), soundex(), table_to_xml(), table_to_xml_and_xmlschema(), table_to_xmlschema(), test_canonicalize_path(), test_custom_stats_var_create(), test_custom_stats_var_drop(), test_custom_stats_var_report(), test_custom_stats_var_update(), test_predtest(), test_slru_page_write(), text2ltree(), text_concat_ws(), textToQualifiedNameList(), to_date(), to_regclass(), to_regcollation(), to_regdatabase(), to_regnamespace(), to_regoper(), to_regoperator(), to_regproc(), to_regprocedure(), to_regrole(), to_regtype(), to_regtypemod(), to_tsquery_byid(), ts_stat_sql(), tsquery_rewrite_query(), tuple_data_split(), unicode_is_normalized(), unicode_normalize_func(), verify_heapam(), websearch_to_tsquery_byid(), X509_NAME_field_to_text(), xml_out_internal(), xmlconcat(), xmlpi(), xmlroot(), and xpath_table().

◆ text_to_cstring_buffer()

void text_to_cstring_buffer ( const text src,
char dst,
size_t  dst_len 
)
extern

Definition at line 245 of file varlena.c.

246{
247 /* must cast away the const, unfortunately */
250
251 if (dst_len > 0)
252 {
253 dst_len--;
254 if (dst_len >= src_len)
256 else /* ensure truncation is encoding-safe */
259 dst[dst_len] = '\0';
260 }
261
262 if (srcunpacked != src)
264}
int pg_mbcliplen(const char *mbstr, int len, int limit)
Definition mbutils.c:1086

References fb(), pfree(), pg_detoast_datum_packed(), pg_mbcliplen(), unconstify, VARDATA_ANY(), and VARSIZE_ANY_EXHDR().

Referenced by be_lo_export(), lo_import_internal(), lookup_timezone(), parse_sane_timezone(), pg_gen_salt(), pg_gen_salt_rounds(), timestamp_zone(), timestamptz_zone(), and timetz_zone().

◆ type_maximum_size()

int32 type_maximum_size ( Oid  type_oid,
int32  typemod 
)
extern

Definition at line 412 of file format_type.c.

413{
414 if (typemod < 0)
415 return -1;
416
417 switch (type_oid)
418 {
419 case BPCHAROID:
420 case VARCHAROID:
421 /* typemod includes varlena header */
422
423 /* typemod is in characters not bytes */
424 return (typemod - VARHDRSZ) *
426 + VARHDRSZ;
427
428 case NUMERICOID:
429 return numeric_maximum_size(typemod);
430
431 case VARBITOID:
432 case BITOID:
433 /* typemod is the (max) number of bits */
434 return (typemod + (BITS_PER_BYTE - 1)) / BITS_PER_BYTE
435 + 2 * sizeof(int32);
436 }
437
438 /* Unknown type, or unlimited-width type such as 'text' */
439 return -1;
440}
int32 numeric_maximum_size(int32 typmod)
Definition numeric.c:936
int GetDatabaseEncoding(void)
Definition mbutils.c:1264
#define BITS_PER_BYTE
int pg_encoding_max_length(int encoding)
Definition wchar.c:2213

References BITS_PER_BYTE, fb(), GetDatabaseEncoding(), numeric_maximum_size(), pg_encoding_max_length(), and VARHDRSZ.

Referenced by get_typavgwidth(), and heapam_relation_needs_toast_table().

◆ uint32in_subr()

uint32 uint32in_subr ( const char s,
char **  endloc,
const char typname,
Node escontext 
)
extern

Definition at line 897 of file numutils.c.

899{
900 uint32 result;
901 unsigned long cvt;
902 char *endptr;
903
904 errno = 0;
905 cvt = strtoul(s, &endptr, 0);
906
907 /*
908 * strtoul() normally only sets ERANGE. On some systems it may also set
909 * EINVAL, which simply means it couldn't parse the input string. Be sure
910 * to report that the same way as the standard error indication (that
911 * endptr == s).
912 */
913 if ((errno && errno != ERANGE) || endptr == s)
914 ereturn(escontext, 0,
916 errmsg("invalid input syntax for type %s: \"%s\"",
917 typname, s)));
918
919 if (errno == ERANGE)
920 ereturn(escontext, 0,
922 errmsg("value \"%s\" is out of range for type %s",
923 s, typname)));
924
925 if (endloc)
926 {
927 /* caller wants to deal with rest of string */
928 *endloc = endptr;
929 }
930 else
931 {
932 /* allow only whitespace after number */
933 while (*endptr && isspace((unsigned char) *endptr))
934 endptr++;
935 if (*endptr)
936 ereturn(escontext, 0,
938 errmsg("invalid input syntax for type %s: \"%s\"",
939 typname, s)));
940 }
941
942 result = (uint32) cvt;
943
944 /*
945 * Cope with possibility that unsigned long is wider than uint32, in which
946 * case strtoul will not raise an error for some values that are out of
947 * the range of uint32.
948 *
949 * For backwards compatibility, we want to accept inputs that are given
950 * with a minus sign, so allow the input value if it matches after either
951 * signed or unsigned extension to long.
952 *
953 * To ensure consistent results on 32-bit and 64-bit platforms, make sure
954 * the error message is the same as if strtoul() had returned ERANGE.
955 */
956#if PG_UINT32_MAX != ULONG_MAX
957 if (cvt != (unsigned long) result &&
958 cvt != (unsigned long) ((int) result))
959 ereturn(escontext, 0,
961 errmsg("value \"%s\" is out of range for type %s",
962 s, typname)));
963#endif
964
965 return result;
966}

References ereturn, errcode(), errmsg(), fb(), and typname.

Referenced by cidin(), oidin(), oidparse(), oidvectorin(), and xidin().

◆ uint64in_subr()

uint64 uint64in_subr ( const char s,
char **  endloc,
const char typname,
Node escontext 
)
extern

Definition at line 984 of file numutils.c.

986{
987 uint64 result;
988 char *endptr;
989
990 errno = 0;
991 result = strtou64(s, &endptr, 0);
992
993 /*
994 * strtoul[l] normally only sets ERANGE. On some systems it may also set
995 * EINVAL, which simply means it couldn't parse the input string. Be sure
996 * to report that the same way as the standard error indication (that
997 * endptr == s).
998 */
999 if ((errno && errno != ERANGE) || endptr == s)
1000 ereturn(escontext, 0,
1002 errmsg("invalid input syntax for type %s: \"%s\"",
1003 typname, s)));
1004
1005 if (errno == ERANGE)
1006 ereturn(escontext, 0,
1008 errmsg("value \"%s\" is out of range for type %s",
1009 s, typname)));
1010
1011 if (endloc)
1012 {
1013 /* caller wants to deal with rest of string */
1014 *endloc = endptr;
1015 }
1016 else
1017 {
1018 /* allow only whitespace after number */
1019 while (*endptr && isspace((unsigned char) *endptr))
1020 endptr++;
1021 if (*endptr)
1022 ereturn(escontext, 0,
1024 errmsg("invalid input syntax for type %s: \"%s\"",
1025 typname, s)));
1026 }
1027
1028 return result;
1029}

References ereturn, errcode(), errmsg(), fb(), and typname.

Referenced by oid8in(), and xid8in().

◆ xidComparator()

int xidComparator ( const void arg1,
const void arg2 
)
extern

◆ xidLogicalComparator()

int xidLogicalComparator ( const void arg1,
const void arg2 
)
extern

Definition at line 169 of file xid.c.

170{
173
176
178 return -1;
179
181 return 1;
182
183 return 0;
184}
#define TransactionIdIsNormal(xid)
Definition transam.h:42
static bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition transam.h:263

References Assert, fb(), TransactionIdIsNormal, and TransactionIdPrecedes().

Referenced by ProcArrayApplyRecoveryInfo().

Variable Documentation

◆ quote_all_identifiers

PGDLLIMPORT bool quote_all_identifiers
extern

Definition at line 339 of file ruleutils.c.

Referenced by fmtIdEnc(), main(), main(), quote_identifier(), and setup_connection().