PostgreSQL Source Code git master
Loading...
Searching...
No Matches
stringinfo.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  StringInfoData
 

Macros

#define STRINGINFO_DEFAULT_SIZE   1024 /* default initial allocation size */
 
#define appendStringInfoCharMacro(str, ch)
 

Typedefs

typedef struct StringInfoData StringInfoData
 
typedef StringInfoData * StringInfo
 

Functions

StringInfo makeStringInfo (void)
 
StringInfo makeStringInfoExt (int initsize)
 
void initStringInfo (StringInfo str)
 
void initStringInfoExt (StringInfo str, int initsize)
 
static void initReadOnlyStringInfo (StringInfo str, char *data, int len)
 
static void initStringInfoFromString (StringInfo str, char *data, int len)
 
void resetStringInfo (StringInfo str)
 
void appendStringInfo (StringInfo str, const char *fmt,...) pg_attribute_printf(2
 
void int appendStringInfoVA (StringInfo str, const char *fmt, va_list args) pg_attribute_printf(2
 
void int void appendStringInfoString (StringInfo str, const char *s)
 
void appendStringInfoChar (StringInfo str, char ch)
 
void appendStringInfoSpaces (StringInfo str, int count)
 
void appendBinaryStringInfo (StringInfo str, const void *data, int datalen)
 
void appendBinaryStringInfoNT (StringInfo str, const void *data, int datalen)
 
void enlargeStringInfo (StringInfo str, int needed)
 
void destroyStringInfo (StringInfo str)
 

Macro Definition Documentation

◆ appendStringInfoCharMacro

#define appendStringInfoCharMacro (   str,
  ch 
)
Value:
(((str)->len + 1 >= (str)->maxlen) ? \
(void)((str)->data[(str)->len] = (ch), (str)->data[++(str)->len] = '\0'))
const char * str
const void size_t len
const void * data
static int fb(int x)
void appendStringInfoChar(StringInfo str, char ch)
Definition stringinfo.c:242

Definition at line 231 of file stringinfo.h.

233 : \
234 (void)((str)->data[(str)->len] = (ch), (str)->data[++(str)->len] = '\0'))

◆ STRINGINFO_DEFAULT_SIZE

#define STRINGINFO_DEFAULT_SIZE   1024 /* default initial allocation size */

Definition at line 112 of file stringinfo.h.

Typedef Documentation

◆ StringInfo

Definition at line 54 of file stringinfo.h.

◆ StringInfoData

Function Documentation

◆ appendBinaryStringInfo()

void appendBinaryStringInfo ( StringInfo  str,
const void *  data,
int  datalen 
)
extern

Definition at line 281 of file stringinfo.c.

282{
283 Assert(str != NULL);
284
285 /* Make more room if needed */
286 enlargeStringInfo(str, datalen);
287
288 /* OK, append the data */
289 memcpy(str->data + str->len, data, datalen);
290 str->len += datalen;
291
292 /*
293 * Keep a trailing null in place, even though it's probably useless for
294 * binary data. (Some callers are dealing with text but call this because
295 * their input isn't null-terminated.)
296 */
297 str->data[str->len] = '\0';
298}
#define Assert(condition)
Definition c.h:1002
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
void enlargeStringInfo(StringInfo str, int needed)
Definition stringinfo.c:337

References Assert, data, enlargeStringInfo(), fb(), memcpy(), and str.

Referenced by addlit(), AppendIncrementalManifestData(), appendStringInfoRegexpSubstr(), appendStringInfoString(), appendStringInfoText(), astreamer_buffer_bytes(), astreamer_waldump_content(), buf_add_txid(), buf_init(), bytea_string_agg_transfn(), composite_to_json(), config_enum_get_options(), CopySendData(), CopySendString(), database_to_xml_internal(), datum_to_json_internal(), DeadLockReport(), deparseFromExprForRel(), escape_json_with_len(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), flattenJsonPathParseItem(), get_from_clause(), get_target_list(), hstore_to_json_loose(), hstore_to_jsonb_loose(), jsonb_put_escaped_value(), JsonbToCStringWorker(), log_status_format(), main(), map_sql_identifier_to_xml_name(), map_xml_name_to_sql_identifier(), multirange_recv(), parse_fcall_arguments(), pg_decode_message(), pg_decode_stream_message(), pg_get_functiondef(), pg_plan_advice_explain_text_multiline(), plpgsql_append_source_text(), pq_sendbytes(), pq_sendtext(), print_function_rettype(), process_pipe_input(), ProcessParallelApplyMessages(), ProcessParallelMessages(), ProcessRepackMessages(), range_recv(), rebuildInsertSql(), replace_text(), replace_text_regexp(), reserveSpaceForItemPointer(), RI_FKey_cascade_upd(), schema_to_xml_internal(), string_agg_combine(), string_agg_deserialize(), testcustomrmgrs_desc(), unaccent_lexize(), write_csvlog(), write_jsonlog(), XLogInsertRecord(), and xmlconcat().

◆ appendBinaryStringInfoNT()

void appendBinaryStringInfoNT ( StringInfo  str,
const void *  data,
int  datalen 
)
extern

Definition at line 307 of file stringinfo.c.

308{
309 Assert(str != NULL);
310
311 /* Make more room if needed */
312 enlargeStringInfo(str, datalen);
313
314 /* OK, append the data */
315 memcpy(str->data + str->len, data, datalen);
316 str->len += datalen;
317}

References Assert, data, enlargeStringInfo(), fb(), memcpy(), and str.

Referenced by appendStringInfoStringQuoted(), pq_sendcountedtext(), and pq_sendstring().

◆ appendStringInfo()

void appendStringInfo ( StringInfo  str,
const char *  fmt,
  ... 
)
extern

◆ appendStringInfoChar()

void appendStringInfoChar ( StringInfo  str,
char  ch 
)
extern

Definition at line 242 of file stringinfo.c.

243{
244 /* Make more room if needed */
245 if (str->len + 1 >= str->maxlen)
247
248 /* OK, append the character */
249 str->data[str->len] = ch;
250 str->len++;
251 str->data[str->len] = '\0';
252}

References enlargeStringInfo(), fb(), and str.

Referenced by _outList(), _outString(), add_file_to_manifest(), AddFileToBackupManifest(), addlitchar(), append_ddl_option(), appendConditions(), appendContextKeyword(), appendEscapedValue(), appendJSONKeyValue(), appendQuotedString(), appendQuotedString(), appendStringInfoRegexpSubstr(), appendTypeNameToBuffer(), array_desc(), array_dim_to_json(), brin_bloom_summary_out(), brin_minmax_multi_summary_out(), brin_page_items(), build_remattrmap(), BuildIndexValueDescription(), CheckSASLAuth(), ChooseIndexExpressionName_walker(), circle_out(), composite_to_json(), copy_table(), cube_out(), cursor_to_xml(), database_to_xml_internal(), datum_to_json_internal(), DeadLockReport(), delvacuum_desc(), deparseAggref(), deparseArrayExpr(), deparseBoolExpr(), deparseCaseExpr(), deparseColumnRef(), deparseDistinctExpr(), deparseFromExprForRel(), deparseFuncExpr(), deparseInsertSql(), deparseNullTest(), deparseOpExpr(), deparseRangeTblRef(), deparseScalarArrayOpExpr(), deparseSortGroupClause(), deparseStringLiteral(), deparseSubscriptingRef(), do_pg_backup_start(), errdetail_apply_conflict(), escape_param_str(), exec_stmt_raise(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExplainBeginOutput(), ExplainCloseGroup(), ExplainJSONLineEnding(), ExplainNode(), ExplainOpenGroup(), ExplainProperty(), ExplainPropertyList(), ExplainPropertyListNested(), ExplainSeparatePlans(), ExplainXMLTag(), ExplainYAMLLineStarting(), fetch_remote_slots(), flattenJsonPathParseItem(), format_procedure_extended(), FreePageManagerDumpBtree(), FreePageManagerDumpSpans(), funcname_signature_string(), generate_operator_name(), get_agg_expr_helper(), get_basic_select_query(), get_coercion_expr(), get_column_alias_list(), get_delete_query_def(), get_for_portion_of(), get_from_clause_coldeflist(), get_from_clause_item(), get_func_expr(), get_func_sql_syntax(), get_graph_label_expr(), get_insert_query_def(), get_json_constructor(), get_json_table(), get_json_table_columns(), get_json_table_nested_columns(), get_json_table_plan(), get_merge_query_def(), get_oper_expr(), get_parameter(), get_path_pattern_expr_def(), get_range_partbound_string(), get_returning_clause(), get_rule_expr(), get_rule_expr_paren(), get_rule_groupingset(), get_rule_sortgroupclause(), get_rule_windowspec(), get_select_query_def(), get_setop_query(), get_special_variable(), get_sql_insert(), get_sublink_expr(), get_tablesample_def(), get_update_query_def(), get_update_query_targetlist_def(), get_values_def(), get_variable(), get_windowfunc_expr_helper(), get_with_clause(), get_xmltable(), gist_page_items(), hstore_to_json(), hstore_to_json_loose(), incompatible_module_error(), infobits_desc(), InteractiveBackend(), json_agg_transfn_worker(), json_build_array_worker(), json_build_object_worker(), json_object(), json_object_two_arg(), log_status_format(), make_propgraphdef_elements(), make_propgraphdef_properties(), make_ruledef(), make_viewdef(), multirange_out(), mxid_to_string(), NameListToQuotedString(), NameListToString(), next_token(), oauth_get_mechanisms(), outBitmapset(), outDatum(), outNode(), outToken(), overexplain_alias(), overexplain_bitmapset_list(), path_encode(), pg_decode_change(), pg_dependencies_out(), pg_get_constraintdef_worker(), pg_get_database_ddl_internal(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_role_ddl_internal(), pg_get_statisticsobj_worker(), pg_get_tablespace_ddl_internal(), pg_get_triggerdef_worker(), pg_ndistinct_out(), pg_snapshot_out(), pg_split_opts(), pgp_armor_encode(), pgpa_cstring_trove_entry(), pgpa_format_advice_target(), pgpa_output_advice(), pgpa_output_do_not_scan(), pgpa_output_join_member(), pgpa_output_no_gather(), pgpa_output_query_feature(), pgpa_output_relation_name(), pgpa_output_scan_strategy(), pgpa_output_simple_strategy(), pgpa_output_unrolled_join(), pgpa_planner_feedback_warning(), pgsa_append_tsv_escaped_string(), pgsa_write_entries(), postgresExplainForeignScan(), postgresImportForeignSchema(), pq_send_ascii_string(), print_function_arguments(), print_function_rettype(), print_function_sqlbody(), print_function_trftypes(), print_literal(), printJsonPathItem(), printSubscripts(), process_pgfdw_appname(), process_queued_fetch_requests(), psql_add_command(), query_to_xml_internal(), range_bound_escape(), range_deparse(), range_parse_bound(), ReadArrayToken(), rebuildInsertSql(), record_in(), record_out(), replace_percent_placeholders(), reportDependentObjects(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_restrict(), schema_to_xml_internal(), scram_get_mechanisms(), send_message_to_frontend(), send_message_to_server_log(), sepgsql_proc_post_create(), serialize_deflist(), show_buffer_usage(), show_hashagg_info(), show_incremental_sort_info(), show_memory_counters(), show_modifytable_info(), show_tablesample(), show_tidbitmap_info(), show_wal_usage(), show_window_def(), simple_quote_literal(), SPI_sql_row_to_xmlelement(), storeObjectDescription(), stringlist_to_identifierstr(), test_status_failed(), tokenize_auth_file(), truncate_flags_desc(), tuple_to_stringinfo(), TypeNameListToString(), unistr(), verify_cb(), write_csvlog(), write_jsonlog(), writeNodeArray(), xlog_outdesc(), XLogRecGetBlockRefInfo(), and xmlpi().

◆ appendStringInfoSpaces()

void appendStringInfoSpaces ( StringInfo  str,
int  count 
)
extern

Definition at line 260 of file stringinfo.c.

261{
262 if (count > 0)
263 {
264 /* Make more room if needed */
265 enlargeStringInfo(str, count);
266
267 /* OK, append the spaces */
268 memset(&str->data[str->len], ' ', count);
269 str->len += count;
270 str->data[str->len] = '\0';
271 }
272}

References enlargeStringInfo(), fb(), and str.

Referenced by add_indent(), append_ddl_option(), appendContextKeyword(), ExplainCloseGroup(), ExplainDummyGroup(), ExplainIndentText(), ExplainOpenGroup(), ExplainProperty(), ExplainPropertyList(), ExplainPropertyListNested(), ExplainXMLTag(), ExplainYAMLLineStarting(), flattenJsonPathParseItem(), jsonPathFromCstring(), log_status_format(), show_hashagg_info(), show_incremental_sort_group_info(), and text_format_append_string().

◆ appendStringInfoString()

void int void appendStringInfoString ( StringInfo  str,
const char *  s 
)
extern

Definition at line 230 of file stringinfo.c.

231{
233}
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition stringinfo.c:281

References appendBinaryStringInfo(), fb(), and str.

Referenced by _outA_Const(), _outA_Expr(), _outBoolean(), _outBoolExpr(), _outConst(), _outFloat(), _outForeignKeyOptInfo(), add_file_to_manifest(), AddFileToBackupManifest(), append_guc_value(), append_num_word(), append_tuple_value_detail(), appendAggOrderBy(), appendConditions(), appendContextKeyword(), appendFunctionName(), appendGroupByClause(), appendJSONKeyValue(), appendLimitClause(), appendOrderByClause(), appendOrderBySuffix(), appendSCRAMKeysInfo(), appendTypeNameToBuffer(), appendWhereClause(), array_desc(), array_dim_to_json(), array_to_json_internal(), array_to_text_internal(), BackendInitialize(), begin_remote_xact(), brin_page_items(), build_backup_content(), build_remattrmap(), build_tuplestore_recursively(), BuildIndexValueDescription(), BuildParamLogString(), cash_words(), check_log_min_messages(), check_publications_origin_sequences(), check_publications_origin_tables(), ChooseIndexExpressionName_walker(), concat_internal(), config_enum_get_options(), copy_sequences(), copy_table(), CreateSchemaCommand(), cube_out(), database_to_xmlschema_internal(), datum_to_json_internal(), dbase_desc(), decompile_column_index_array(), delvacuum_desc(), deparseAggref(), deparseAnalyzeInfoSql(), deparseAnalyzeSizeSql(), deparseAnalyzeSql(), deparseArrayExpr(), deparseBoolExpr(), deparseCaseExpr(), deparseColumnRef(), deparseConst(), deparseDeleteSql(), deparseDirectDeleteSql(), deparseDirectUpdateSql(), deparseDistinctExpr(), deparseExplicitTargetList(), deparseFromExpr(), deparseFromExprForRel(), deparseFuncExpr(), deparseInsertSql(), deparseLockingClause(), deparseNullTest(), deparseOperatorName(), deparseRangeTblRef(), deparseSelectSql(), deparseSelectStmtForRel(), deparseSubqueryTargetList(), deparseTargetList(), deparseTruncateSql(), deparseUpdateSql(), ecpg_start_test(), errdetail_apply_conflict(), escape_json(), escape_json(), escape_json_char(), escape_xml(), estimate_path_cost_size(), exec_stmt_raise(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), execute_extension_script(), ExplainBeginOutput(), ExplainDummyGroup(), ExplainEndOutput(), ExplainFlushWorkersState(), ExplainIndexScanDetails(), ExplainNode(), ExplainOnePlan(), ExplainOneUtility(), ExplainOpenGroup(), ExplainPrintJIT(), ExplainPrintSettings(), ExplainProperty(), ExplainPropertyList(), ExplainPropertyListNested(), ExplainQuery(), ExplainTargetRel(), ExplainXMLTag(), ExportSnapshot(), fetch_attstats(), fetch_relation_list(), fetch_remote_slots(), fetch_remote_table_info(), finalize_manifest(), flatten_set_variable_args(), format_expr_params(), format_operator_extended(), format_preparedparamsdata(), format_procedure_extended(), FreePageManagerDump(), funcname_signature_string(), generate_error_response(), generate_operator_clause(), generate_operator_name(), get_agg_expr_helper(), get_basic_select_query(), get_column_alias_list(), get_const_expr(), get_for_portion_of(), get_from_clause(), get_from_clause_coldeflist(), get_from_clause_item(), get_func_expr(), get_func_sql_syntax(), get_graph_label_expr(), get_graph_pattern_def(), get_insert_query_def(), get_json_behavior(), get_json_constructor(), get_json_constructor_options(), get_json_expr_options(), get_json_format(), get_json_table(), get_json_table_columns(), get_json_table_plan(), get_merge_query_def(), get_parameter(), get_path_pattern_expr_def(), get_query_def(), get_range_partbound_string(), get_reloptions(), get_rule_expr(), get_rule_expr_funccall(), get_rule_groupingset(), get_rule_list_toplevel(), get_rule_orderby(), get_rule_windowclause(), get_rule_windowspec(), get_select_query_def(), get_sequences_string(), get_setop_query(), get_sql_delete(), get_sql_insert(), get_sql_update(), get_sublink_expr(), get_tablesample_def(), get_target_list(), get_tuple_of_interest(), get_update_query_def(), get_update_query_targetlist_def(), get_utility_query_def(), get_values_def(), get_variable(), get_window_frame_options(), get_windowfunc_expr_helper(), get_with_clause(), get_xmltable(), getConstraintTypeDescription(), getObjectIdentityParts(), getObjectTypeDescription(), getProcedureTypeDescription(), GetPublicationsStr(), getRelationIdentity(), getRelationTypeDescription(), gist_page_items(), heap2_desc(), heap_desc(), heap_vacuum_rel(), hstore_to_json(), hstore_to_json_loose(), incompatible_module_error(), infobits_desc(), json_agg_transfn_worker(), json_build_array_worker(), json_build_object_worker(), json_lex_string(), json_object(), json_object_agg_transfn_worker(), json_object_two_arg(), jsonb_put_escaped_value(), jsonPathToCstring(), libpqrcv_alter_slot(), log_status_format(), main(), make_propgraphdef_elements(), make_propgraphdef_labels(), make_propgraphdef_properties(), make_ruledef(), map_multipart_sql_identifier_to_xml_name(), map_sql_catalog_to_xmlschema_types(), map_sql_identifier_to_xml_name(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), map_sql_type_to_xmlschema_type(), map_sql_value_to_xml_value(), map_xml_name_to_sql_identifier(), multirange_out(), NameListToQuotedString(), NameListToString(), oauth_get_mechanisms(), op_signature_string(), out_member(), outChar(), outDatum(), outDouble(), outNode(), outToken(), overexplain_bitmapset_list(), overexplain_debug(), overexplain_intlist(), PerformWalRecovery(), pg_decode_change(), pg_decode_commit_txn(), pg_decode_stream_abort(), pg_decode_stream_change(), pg_decode_stream_commit(), pg_decode_stream_stop(), pg_decode_stream_truncate(), pg_decode_truncate(), pg_dependencies_out(), pg_extension_update_paths(), pg_get_constraintdef_worker(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_tablespace_ddl_internal(), pg_get_triggerdef_worker(), pg_ndistinct_out(), pg_output_begin(), pg_output_stream_start(), pg_plan_advice_explain_feedback(), pg_sync_replication_slots(), pgp_armor_encode(), pgpa_cstring_trove_entry(), pgpa_format_advice_target(), pgpa_format_index_target(), pgpa_output_advice(), pgpa_output_do_not_scan(), pgpa_output_no_gather(), pgpa_output_relation_name(), pgpa_output_relations(), pgpa_trove_append_flags(), pgsa_append_tsv_escaped_string(), plan_elem_desc(), PLy_traceback(), postgresExplainForeignScan(), postgresImportForeignSchema(), PostmasterMain(), print_function_arguments(), print_function_rettype(), print_function_sqlbody(), print_function_trftypes(), print_literal(), printJsonPathItem(), process_pgfdw_appname(), psql_add_command(), px_crypt_shacrypt(), quote_object_name(), quote_qualified_identifier(), range_deparse(), rebuildInsertSql(), refresh_by_match_merge(), regression_main(), replace_percent_placeholders(), ReplicationSlotDropAtPubNode(), ReplSlotSyncWorkerMain(), report_triggers(), ReportSlotInvalidation(), ri_Check_Pk_Match(), RI_FKey_check(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_ReportViolation(), ri_restrict(), schema_to_xmlschema_internal(), scram_get_mechanisms(), send_message_to_frontend(), send_message_to_server_log(), sepgsql_audit_log(), sepgsql_database_post_create(), sepgsql_proc_post_create(), sepgsql_schema_post_create(), serialize_deflist(), set_backtrace(), show_buffer_usage(), show_incremental_sort_group_info(), show_memoize_info(), show_modifytable_info(), show_result_replacement_info(), show_sort_group_keys(), show_sortorder_options(), show_tablesample(), show_tidbitmap_info(), show_wal_usage(), show_window_def(), show_window_keys(), ShowUsage(), single_encode(), smgr_desc(), sn_scalar(), spg_desc(), SPI_sql_row_to_xmlelement(), standby_desc_invalidations(), standby_desc_running_xacts(), text_format_append_string(), tokenize_auth_file(), transform_string_values_scalar(), transformJsonTableColumn(), truncate_flags_desc(), tuple_to_stringinfo(), unistr(), write_auto_conf_file(), write_csvlog(), writeNodeArray(), xact_desc_abort(), xact_desc_assignment(), xact_desc_commit(), xact_desc_prepare(), xact_desc_subxacts(), xlog2_desc(), xlog_block_info(), xlog_desc(), xlog_outdesc(), XLogInsertRecord(), XLogRecGetBlockRefInfo(), xml_out_internal(), xmlcomment(), xmlconcat(), xmldata_root_element_start(), xmlpi(), xmlroot(), xsd_schema_element_end(), and xsd_schema_element_start().

◆ appendStringInfoVA()

void int appendStringInfoVA ( StringInfo  str,
const char *  fmt,
va_list  args 
)
extern

◆ destroyStringInfo()

void destroyStringInfo ( StringInfo  str)
extern

Definition at line 409 of file stringinfo.c.

410{
411 /* don't allow destroys of read-only StringInfos */
412 Assert(str->maxlen != 0);
413
414 pfree(str->data);
415 pfree(str);
416}
void pfree(void *pointer)
Definition mcxt.c:1619

References Assert, pfree(), and str.

Referenced by check_backup_label_files(), fetch_remote_table_info(), free_archive_reader(), free_archive_wal_entry(), get_archive_wal_entry(), psql_end_command(), and px_crypt_shacrypt().

◆ enlargeStringInfo()

void enlargeStringInfo ( StringInfo  str,
int  needed 
)
extern

Definition at line 337 of file stringinfo.c.

338{
339 int newlen;
340
341 /* validate this is not a read-only StringInfo */
342 Assert(str->maxlen != 0);
343
344 /*
345 * Guard against out-of-range "needed" values. Without this, we can get
346 * an overflow or infinite loop in the following.
347 */
348 if (needed < 0) /* should not happen */
349 {
350#ifndef FRONTEND
351 elog(ERROR, "invalid string enlargement request size: %d", needed);
352#else
353 fprintf(stderr, "invalid string enlargement request size: %d\n", needed);
355#endif
356 }
357 if (((Size) needed) >= (MaxAllocSize - (Size) str->len))
358 {
359#ifndef FRONTEND
362 errmsg("string buffer exceeds maximum allowed length (%zu bytes)", MaxAllocSize),
363 errdetail("Cannot enlarge string buffer containing %d bytes by %d more bytes.",
364 str->len, needed)));
365#else
367 _("string buffer exceeds maximum allowed length (%zu bytes)\n\nCannot enlarge string buffer containing %d bytes by %d more bytes.\n"),
368 MaxAllocSize, str->len, needed);
370#endif
371 }
372
373 needed += str->len + 1; /* total space required now */
374
375 /* Because of the above test, we now have needed <= MaxAllocSize */
376
377 if (needed <= str->maxlen)
378 return; /* got enough space already */
379
380 /*
381 * We don't want to allocate just a little more space with each append;
382 * for efficiency, double the buffer size each time it overflows.
383 * Actually, we might need to more than double it if 'needed' is big...
384 */
385 newlen = 2 * str->maxlen;
386 while (needed > newlen)
387 newlen = 2 * newlen;
388
389 /*
390 * Clamp to MaxAllocSize in case we went past it. Note we are assuming
391 * here that MaxAllocSize <= INT_MAX/2, else the above loop could
392 * overflow. We will still have newlen >= needed.
393 */
394 if (newlen > (int) MaxAllocSize)
396
397 str->data = (char *) repalloc(str->data, newlen);
398
399 str->maxlen = newlen;
400}
size_t Size
Definition c.h:748
#define fprintf(file, fmt, msg)
Definition cubescan.l:21
int errcode(int sqlerrcode)
Definition elog.c:875
#define _(x)
Definition elog.c:96
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
#define ereport(elevel,...)
Definition elog.h:152
#define MaxAllocSize
Definition fe_memutils.h:22
void * repalloc(void *pointer, Size size)
Definition mcxt.c:1635
static char * errmsg
#define EXIT_FAILURE
Definition settings.h:197

References _, Assert, elog, ereport, errcode(), errdetail(), errmsg, ERROR, EXIT_FAILURE, fb(), fprintf, MaxAllocSize, repalloc(), and str.

Referenced by add_file_to_manifest(), AddFileToBackupManifest(), append_ddl_option(), appendBinaryStringInfo(), appendBinaryStringInfoNT(), appendStringInfo(), appendStringInfoChar(), appendStringInfoSpaces(), astreamer_gzip_decompressor_new(), astreamer_lz4_decompressor_new(), astreamer_zstd_compressor_new(), astreamer_zstd_decompressor_new(), CopyReadAttributesCSV(), CopyReadAttributesText(), CopyReadBinaryAttribute(), escape_json_with_len(), finalize_manifest(), JsonbToCStringWorker(), jsonPathFromCstring(), jsonPathToCstring(), manifest_report_error(), pg_get_line_append(), pgp_armor_decode(), pgp_armor_encode(), pgpa_maybe_linebreak(), PLy_elog_impl(), pq_getmessage(), pq_sendint16(), pq_sendint32(), pq_sendint64(), pq_sendint8(), psql_add_command(), read_binary_file(), ReportWalSummaryError(), reserveFromBuffer(), SendRowDescriptionMessage(), slurp_file(), and XLogSendPhysical().

◆ initReadOnlyStringInfo()

◆ initStringInfo()

void initStringInfo ( StringInfo  str)
extern

Definition at line 97 of file stringinfo.c.

98{
100}
static void initStringInfoInternal(StringInfo str, int initsize)
Definition stringinfo.c:41
#define STRINGINFO_DEFAULT_SIZE
Definition stringinfo.h:112

References initStringInfoInternal(), str, and STRINGINFO_DEFAULT_SIZE.

Referenced by AddFileToBackupManifest(), array_in_safe(), array_to_json(), array_to_json_pretty(), array_to_text_internal(), astreamer_gzip_decompressor_new(), astreamer_lz4_compressor_new(), astreamer_lz4_decompressor_new(), astreamer_tar_parser_new(), astreamer_zstd_compressor_new(), astreamer_zstd_decompressor_new(), ATExecAttachPartition(), BackendInitialize(), begin_remote_xact(), BeginCopyFrom(), bind_param_error_callback(), bmsToString(), bqarr_in(), brin_bloom_summary_out(), brin_minmax_multi_summary_out(), brin_page_items(), build_backup_content(), build_remattrmap(), build_tuplestore_recursively(), BuildIndexValueDescription(), BuildParamLogString(), cash_words(), check_publications_origin_sequences(), check_publications_origin_tables(), CheckAlterSubOption(), CheckSASLAuth(), checkSharedDependencies(), ChooseIndexExpressionName(), circle_out(), concat_internal(), config_enum_get_options(), convertToJsonb(), copy_sequences(), copy_table(), CopyFromTextLikeStart(), create_cursor(), create_manifest_writer(), CreateIncrementalBackupInfo(), CreateSchemaCommand(), cube_out(), cursor_to_xml(), datum_to_json(), dblink_close(), dblink_fetch(), dblink_open(), DeadLockReport(), dep_attnum_list(), deparse_expression_pretty(), deparseAnalyzeInfoSql(), deparseAnalyzeSizeSql(), deparseFromExprForRel(), DetermineRecoveryTargetType(), do_analyze_rel(), do_pg_backup_start(), ecpg_filter_source(), ecpg_filter_stderr(), ecpg_start_test(), errdetail_apply_conflict(), escape_param_str(), escape_xml(), estimate_path_cost_size(), exec_replication_command(), exec_stmt_raise(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExecEvalXmlExpr(), execute_extension_script(), execute_foreign_modify(), ExplainOpenWorker(), ExplainPrintSettings(), ExportSnapshot(), fetch_attstats(), fetch_relation_list(), fetch_relstats(), fetch_remote_slots(), fetch_remote_table_info(), filter_init(), flatten_reloptions(), flatten_set_variable_args(), format_expr_params(), format_node_dump(), format_operator_extended(), format_preparedparamsdata(), format_procedure_extended(), FreePageManagerDump(), fsm_page_contents(), funcname_signature_string(), generate_error_response(), generate_opclass_name(), generate_operator_name(), get_connect_string(), get_from_clause(), get_json_agg_constructor(), get_range_partbound_string(), get_sql_delete(), get_sql_insert(), get_sql_update(), get_target_list(), get_tuple_of_interest(), get_window_frame_options_for_explain(), getObjectDescription(), getObjectIdentityParts(), getObjectTypeDescription(), GetWALBlockInfo(), GetWALRecordInfo(), gist_page_items(), heap_vacuum_rel(), hstore_to_json(), hstore_to_json_loose(), hstore_to_jsonb_loose(), incompatible_module_error(), init_libpq_source(), initialize_worker_spi(), isolation_start_test(), item_attnum_list(), jbv_to_infunc_datum(), json_build_array_worker(), json_object(), json_object_two_arg(), json_strip_nulls(), json_unique_builder_get_throwawaybuf(), jsonb_pretty(), jsonb_send(), JsonbValueAsText(), jsonpath_send(), jsonPathFromCstring(), jsonPathToCstring(), KnownAssignedXidsDisplay(), libpqrcv_alter_slot(), LockAcquireExtended(), logicalrep_get_attrs_str(), LogicalRepSyncSequences(), LogRecoveryConflict(), main(), manifest_report_error(), map_multipart_sql_identifier_to_xml_name(), map_sql_catalog_to_xmlschema_types(), map_sql_identifier_to_xml_name(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), map_sql_type_to_xmlschema_type(), map_sql_typecoll_to_xmlschema_types(), map_sql_value_to_xml_value(), map_xml_name_to_sql_identifier(), multirange_out(), multirange_recv(), multirange_send(), mxid_to_string(), NameListToQuotedString(), NameListToString(), next_field_expand(), nodeToStringInternal(), op_signature_string(), overexplain_alias(), overexplain_bitmapset(), overexplain_bitmapset_list(), overexplain_debug(), overexplain_intlist(), parse_fcall_arguments(), path_encode(), perform_base_backup(), PerformAuthentication(), PerformWalRecovery(), pg_armor(), pg_dearmor(), pg_dependencies_out(), pg_extension_update_paths(), pg_get_constraintdef_worker(), pg_get_database_ddl_internal(), pg_get_function_arguments(), pg_get_function_identity_arguments(), pg_get_function_result(), pg_get_function_sqlbody(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_line(), pg_get_partkeydef_worker(), pg_get_propgraphdef(), pg_get_querydef(), pg_get_role_ddl_internal(), pg_get_ruledef_worker(), pg_get_statisticsobj_worker(), pg_get_tablespace_ddl_internal(), pg_get_triggerdef_worker(), pg_get_viewdef_worker(), pg_get_wait_events(), pg_ndistinct_out(), pg_plan_advice_explain_feedback(), pg_snapshot_out(), pg_split_opts(), pg_sync_replication_slots(), pgpa_bms_to_cstring(), pgpa_cstring_trove_entry(), pgpa_plan_walker(), pgpa_planner_feedback_warning(), pgpa_planner_shutdown(), pgpa_scanner_init(), pgsa_write_to_disk(), PLy_elog_impl(), PLy_traceback(), populate_array_report_expected_array(), populate_scalar(), postgres_fdw_connection(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresBeginForeignInsert(), postgresExecForeignTruncate(), postgresExplainForeignScan(), postgresGetAnalyzeInfoForForeignTable(), postgresGetForeignPlan(), postgresImportForeignSchema(), PostgresMain(), postgresPlanDirectModify(), postgresPlanForeignModify(), PostmasterMain(), pq_beginmessage(), pq_begintypsend(), pretty_format_node_dump(), print_function_rettype(), printtup_startup(), process_pgfdw_appname(), process_pipe_input(), ProcessParallelApplyMessages(), ProcessParallelMessages(), ProcessRepackMessages(), ProcSleep(), psql_add_command(), psql_start_test(), quote_object_name(), quote_qualified_identifier(), range_bound_escape(), range_deparse(), range_parse_bound(), range_recv(), range_send(), read_binary_file(), ReadArrayStr(), readfile(), record_in(), record_out(), recv_password_packet(), refresh_by_match_merge(), regression_main(), replace_percent_placeholders(), replace_text(), replace_text_regexp(), ReplicationSlotDropAtPubNode(), ReplSlotSyncWorkerMain(), report_sequence_errors(), ReportApplyConflict(), reportDependentObjects(), ReportSlotInvalidation(), ReportWalSummaryError(), ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_ReportViolation(), ri_restrict(), ri_set(), rm_redo_error_callback(), row_to_json(), row_to_json_pretty(), schema_get_xml_visible_tables(), send_message_to_frontend(), send_message_to_server_log(), sepgsql_attribute_post_create(), sepgsql_audit_log(), sepgsql_database_post_create(), sepgsql_proc_post_create(), sepgsql_relation_post_create(), sepgsql_schema_post_create(), serialize_deflist(), serializeAnalyzeStartup(), set_backtrace(), show_incremental_sort_group_info(), show_memoize_info(), show_result_replacement_info(), show_sort_group_keys(), show_window_def(), ShowTransactionStateRec(), ShowUsage(), SortTocFromFile(), startlit(), stringlist_to_identifierstr(), table_to_xml_internal(), test_inline_in_from_support_func(), text_format(), tokenize_auth_file(), transform_json_string_values(), transformJsonTableColumn(), triggered_change_notification(), tsearch_readline_begin(), TypeNameListToString(), TypeNameToString(), unaccent_lexize(), unistr(), validate_remote_info(), verify_cb(), waitonlock_error_callback(), WalReceiverMain(), worker_spi_main(), write_auto_conf_file(), write_csvlog(), write_jsonlog(), write_reconstructed_file(), XLogDumpDisplayRecord(), XLogInsertRecord(), xml_out_internal(), xmlcomment(), xmlconcat(), xmlpi(), xmlroot(), XmlTableGetValue(), and xpath_table().

◆ initStringInfoExt()

void initStringInfoExt ( StringInfo  str,
int  initsize 
)
extern

Definition at line 111 of file stringinfo.c.

References fb(), initStringInfoInternal(), and str.

Referenced by check_log_min_messages().

◆ initStringInfoFromString()

static void initStringInfoFromString ( StringInfo  str,
char *  data,
int  len 
)
inlinestatic

Definition at line 175 of file stringinfo.h.

176{
177 Assert(data[len] == '\0');
178
179 str->data = data;
180 str->len = len;
181 str->maxlen = len + 1;
182 str->cursor = 0;
183}

References Assert, data, len, and str.

Referenced by logicalrep_read_tuple().

◆ makeStringInfo()

◆ makeStringInfoExt()

StringInfo makeStringInfoExt ( int  initsize)
extern

Definition at line 85 of file stringinfo.c.

86{
88}

References fb(), and makeStringInfoInternal().

Referenced by px_crypt_shacrypt().

◆ resetStringInfo()

void resetStringInfo ( StringInfo  str)
extern

Definition at line 126 of file stringinfo.c.

127{
128 /* don't allow resets of read-only StringInfos */
129 Assert(str->maxlen != 0);
130
131 str->data[0] = '\0';
132 str->len = 0;
133 str->cursor = 0;
134}

References Assert, and str.

Referenced by build_tuplestore_recursively(), check_backup_label_files(), copy_sequences(), CopyReadAttributesCSV(), CopyReadAttributesText(), CopyReadBinaryAttribute(), CopyReadLine(), CopySendEndOfRow(), CopyToJsonOneRow(), DeadLockReport(), do_object_field_start(), do_scalar(), errdetail_apply_conflict(), fetch_remote_table_info(), flush_manifest(), get_sequences_string(), get_target_list(), hstore_to_jsonb_loose(), initialize_worker_spi(), initStringInfoInternal(), InteractiveBackend(), LogicalOutputPrepareWrite(), main(), multirange_recv(), next_token(), parse_fcall_arguments(), pg_get_database_ddl_internal(), pg_get_line_buf(), pg_get_role_ddl_internal(), pg_get_tablespace_ddl_internal(), pg_split_opts(), pgpa_planner_feedback_warning(), pgsa_write_entries(), pgsa_write_stashes(), postgresImportForeignSchema(), pq_beginmessage_reuse(), pq_getmessage(), print_function_rettype(), process_queued_fetch_requests(), ProcessRepliesIfAny(), ProcessStandbyPSRequestMessage(), ReadArrayToken(), record_in(), refresh_by_match_merge(), request_publisher_status(), send_feedback(), sepgsql_database_post_create(), sepgsql_relation_post_create(), show_sort_group_keys(), tokenize_auth_file(), WalSndKeepalive(), WalSndPrepareWrite(), WalSndWriteData(), write_auto_conf_file(), write_reconstructed_file(), XLogDumpDisplayRecord(), XLogSendPhysical(), XLogWalRcvSendHSFeedback(), and XLogWalRcvSendReply().