PostgreSQL Source Code  git master
stringinfo.c File Reference
#include "postgres.h"
#include "utils/memutils.h"
#include "lib/stringinfo.h"
Include dependency graph for stringinfo.c:

Go to the source code of this file.

Functions

StringInfo makeStringInfo (void)
 
void initStringInfo (StringInfo str)
 
void resetStringInfo (StringInfo str)
 
void appendStringInfo (StringInfo str, const char *fmt,...)
 
int appendStringInfoVA (StringInfo str, const char *fmt, va_list args)
 
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)
 

Function Documentation

◆ appendBinaryStringInfo()

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

Definition at line 227 of file stringinfo.c.

228 {
229  Assert(str != NULL);
230 
231  /* Make more room if needed */
232  enlargeStringInfo(str, datalen);
233 
234  /* OK, append the data */
235  memcpy(str->data + str->len, data, datalen);
236  str->len += datalen;
237 
238  /*
239  * Keep a trailing null in place, even though it's probably useless for
240  * binary data. (Some callers are dealing with text but call this because
241  * their input isn't null-terminated.)
242  */
243  str->data[str->len] = '\0';
244 }
Assert(fmt[strlen(fmt) - 1] !='\n')
const void * data
void enlargeStringInfo(StringInfo str, int needed)
Definition: stringinfo.c:283

References Assert(), data, enlargeStringInfo(), and generate_unaccent_rules::str.

Referenced by appendStringInfoRegexpSubstr(), appendStringInfoString(), appendStringInfoText(), apply_spooled_messages(), array_agg_array_deserialize(), array_agg_deserialize(), bbstreamer_buffer_bytes(), buf_add_txid(), buf_init(), bytea_string_agg_transfn(), config_enum_get_options(), CopyReadLineText(), CopySendData(), CopySendString(), database_to_xml_internal(), DeadLockReport(), deparseFromExprForRel(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), flattenJsonPathParseItem(), get_from_clause(), get_target_list(), HandleParallelApplyMessages(), HandleParallelMessages(), hstore_to_json(), hstore_to_json_loose(), hstore_to_jsonb_loose(), int8_avg_deserialize(), json_lex_string(), jsonb_put_escaped_value(), JsonbToCStringWorker(), log_status_format(), map_sql_identifier_to_xml_name(), map_xml_name_to_sql_identifier(), multirange_recv(), numeric_avg_deserialize(), numeric_deserialize(), numeric_poly_deserialize(), parse_fcall_arguments(), pg_decode_message(), pg_decode_stream_message(), pg_get_functiondef(), plpgsql_append_source_text(), pq_sendbytes(), pq_sendtext(), print_function_rettype(), process_pipe_input(), 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(), XLogWalRcvProcessMsg(), and xmlconcat().

◆ appendBinaryStringInfoNT()

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

Definition at line 253 of file stringinfo.c.

254 {
255  Assert(str != NULL);
256 
257  /* Make more room if needed */
258  enlargeStringInfo(str, datalen);
259 
260  /* OK, append the data */
261  memcpy(str->data + str->len, data, datalen);
262  str->len += datalen;
263 }

References Assert(), data, enlargeStringInfo(), and generate_unaccent_rules::str.

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

◆ appendStringInfo()

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

Definition at line 91 of file stringinfo.c.

92 {
93  int save_errno = errno;
94 
95  for (;;)
96  {
97  va_list args;
98  int needed;
99 
100  /* Try to format the data. */
101  errno = save_errno;
102  va_start(args, fmt);
103  needed = appendStringInfoVA(str, fmt, args);
104  va_end(args);
105 
106  if (needed == 0)
107  break; /* success */
108 
109  /* Increase the buffer size and try again. */
110  enlargeStringInfo(str, needed);
111  }
112 }
static void const char * fmt
va_end(args)
va_start(args, fmt)
int appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
Definition: stringinfo.c:133

References appendStringInfoVA(), generate_unaccent_rules::args, enlargeStringInfo(), fmt, generate_unaccent_rules::str, va_end(), and va_start().

Referenced by _outForeignKeyOptInfo(), _outInteger(), _outList(), add_cast_to(), AddFileToBackupManifest(), appendFunctionName(), appendStringInfoStringQuoted(), array_to_text_internal(), BackendInitialize(), bqarr_in(), brin_bloom_summary_out(), brin_desc(), brin_minmax_multi_summary_out(), btree_desc(), build_backup_content(), build_tuplestore_recursively(), BuildIndexValueDescription(), BuildParamLogString(), check_publications_origin(), checkSharedDependencies(), clog_desc(), commit_ts_desc(), copy_table(), create_cursor(), CreateSchemaCommand(), database_to_xml_internal(), datum_to_json_internal(), dbase_desc(), dblink_close(), dblink_fetch(), dblink_open(), DeadLockReport(), decompile_column_index_array(), default_desc(), delvacuum_desc(), deparseAnalyzeSizeSql(), deparseAnalyzeSql(), deparseArrayExpr(), deparseBoolExpr(), deparseColumnRef(), deparseConst(), deparseDirectDeleteSql(), deparseDirectUpdateSql(), deparseFromExprForRel(), deparseFuncExpr(), deparseInsertSql(), deparseLockingClause(), deparseOperatorName(), deparseRangeTblRef(), deparseRelabelType(), deparseRelation(), deparseScalarArrayOpExpr(), deparseSortGroupClause(), deparseTruncateSql(), deparseUpdateSql(), deparseVar(), desc_recompress_leaf(), DescribeLockTag(), do_analyze_rel(), do_pg_backup_start(), escape_json(), ExecBuildSlotPartitionKeyDescription(), ExecEvalXmlExpr(), execute_extension_script(), ExplainIndexScanDetails(), ExplainNode(), ExplainOpenGroup(), ExplainOpenWorker(), ExplainPrintJIT(), ExplainPrintSettings(), ExplainProperty(), ExplainPropertyList(), ExplainTargetRel(), ExportSnapshot(), fetch_remote_table_info(), fetch_table_list(), flatten_set_variable_args(), format_expr_params(), format_node_dump(), format_operator_extended(), format_preparedparamsdata(), format_procedure_extended(), FreePageManagerDump(), FreePageManagerDumpBtree(), FreePageManagerDumpSpans(), fsm_page_contents(), funcname_signature_string(), generate_operator_clause(), generate_operator_name(), generic_desc(), get_agg_expr_helper(), get_coercion_expr(), get_connect_string(), get_const_collation(), get_const_expr(), get_delete_query_def(), get_from_clause_coldeflist(), get_from_clause_item(), get_func_expr(), get_func_sql_syntax(), get_insert_query_def(), get_json_constructor(), get_json_format(), get_json_returning(), get_merge_query_def(), get_opclass_name(), get_oper_expr(), get_parameter(), get_reloptions(), get_rte_alias(), get_rule_expr(), get_rule_expr_funccall(), get_rule_orderby(), get_rule_sortgroupclause(), get_rule_windowclause(), get_select_query_def(), get_sql_delete(), get_sql_insert(), get_sql_update(), get_sublink_expr(), get_tablefunc(), get_tablesample_def(), get_target_list(), get_tuple_of_interest(), get_update_query_def(), get_utility_query_def(), get_variable(), get_windowfunc_expr_helper(), get_with_clause(), getObjectDescription(), getObjectIdentityParts(), getOpFamilyDescription(), getOpFamilyIdentity(), getRelationDescription(), gin_desc(), gist_page_items(), hash_desc(), heap2_desc(), heap_desc(), heap_vacuum_rel(), incompatible_module_error(), infobits_desc(), initialize_worker_spi(), KnownAssignedXidsDisplay(), libpqrcv_create_slot(), libpqrcv_startstreaming(), log_status_format(), logicalmsg_desc(), logicalrep_report_missing_attrs(), LogRecoveryConflict(), make_ruledef(), make_temptable_name_n(), 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(), multixact_desc(), mxid_to_string(), offset_elem_desc(), oid_elem_desc(), op_signature_string(), out_gistxlogDelete(), out_gistxlogPageDelete(), out_gistxlogPageReuse(), out_gistxlogPageSplit(), out_member(), outBitmapset(), outDatum(), pair_encode(), PerformAuthentication(), PerformWalRecovery(), pg_decode_commit_prepared_txn(), pg_decode_commit_txn(), pg_decode_message(), pg_decode_prepare_txn(), pg_decode_rollback_prepared_txn(), pg_decode_stream_abort(), pg_decode_stream_change(), pg_decode_stream_commit(), pg_decode_stream_message(), pg_decode_stream_prepare(), pg_decode_stream_stop(), pg_decode_stream_truncate(), pg_dependencies_out(), pg_get_constraintdef_worker(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), pg_get_wait_events(), pg_ndistinct_out(), pg_output_begin(), pg_output_stream_start(), pg_snapshot_out(), pgp_armor_encode(), plan_elem_desc(), PLy_traceback(), populate_array_report_expected_array(), postgresAcquireSampleRowsFunc(), postgresExplainForeignScan(), postgresImportForeignSchema(), pretty_format_node_dump(), print_function_arguments(), print_function_trftypes(), print_literal(), printJsonPathItem(), printRemoteParam(), printRemotePlaceholder(), process_pgfdw_appname(), process_queued_fetch_requests(), processIndirection(), ProcSleep(), psql_end_command(), psql_start_command(), query_to_xml_internal(), quote_object_name(), quote_qualified_identifier(), rebuildInsertSql(), redirect_elem_desc(), refresh_by_match_merge(), regression_main(), relmap_desc(), ReplicationSlotDropAtPubNode(), replorigin_desc(), report_triggers(), reportDependentObjects(), ReportSlotInvalidation(), ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), ri_GenerateQual(), ri_GenerateQualCollation(), RI_Initial_Check(), RI_PartitionRemove_Check(), ri_restrict(), ri_set(), schema_get_xml_visible_tables(), schema_to_xml_internal(), send_message_to_frontend(), send_message_to_server_log(), sepgsql_attribute_post_create(), sepgsql_audit_log(), sepgsql_proc_post_create(), sepgsql_relation_post_create(), seq_desc(), serialize_deflist(), set_backtrace(), show_buffer_usage(), show_hash_info(), show_hashagg_info(), show_incremental_sort_group_info(), show_memoize_info(), show_modifytable_info(), show_sort_info(), show_sortorder_options(), show_tablesample(), show_tidbitmap_info(), show_wal_usage(), ShowTransactionStateRec(), ShowUsage(), smgr_desc(), spg_desc(), SPI_sql_row_to_xmlelement(), standby_desc(), standby_desc_invalidations(), standby_desc_running_xacts(), storeObjectDescription(), table_to_xml_internal(), tblspc_desc(), test_status_failed(), testcustomrmgrs_desc(), verify_cb(), worker_spi_main(), write_csvlog(), xact_desc(), xact_desc_abort(), xact_desc_assignment(), xact_desc_commit(), xact_desc_prepare(), xact_desc_relations(), xact_desc_stats(), xact_desc_subxacts(), xlog_block_info(), xlog_desc(), xlog_outdesc(), XLogInsertRecord(), XLogRecGetBlockRefInfo(), xmldata_root_element_end(), xmldata_root_element_start(), xmlpi(), xpath_table(), and xsd_schema_element_start().

◆ appendStringInfoChar()

void appendStringInfoChar ( StringInfo  str,
char  ch 
)

Definition at line 188 of file stringinfo.c.

189 {
190  /* Make more room if needed */
191  if (str->len + 1 >= str->maxlen)
193 
194  /* OK, append the character */
195  str->data[str->len] = ch;
196  str->len++;
197  str->data[str->len] = '\0';
198 }

References enlargeStringInfo(), and generate_unaccent_rules::str.

Referenced by _outList(), _outString(), AddFileToBackupManifest(), appendConditions(), appendContextKeyword(), appendJSONKeyValue(), appendStringInfoRegexpSubstr(), appendTypeNameToBuffer(), array_dim_to_json(), brin_bloom_summary_out(), brin_minmax_multi_summary_out(), brin_page_items(), BuildIndexValueDescription(), check_publications(), CheckSASLAuth(), circle_out(), composite_to_json(), cube_out(), cursor_to_xml(), database_to_xml_internal(), DeadLockReport(), deparseAggref(), deparseArrayExpr(), deparseBoolExpr(), deparseCaseExpr(), deparseColumnRef(), deparseDistinctExpr(), deparseFromExprForRel(), deparseFuncExpr(), deparseInsertSql(), deparseNullTest(), deparseOpExpr(), deparseRangeTblRef(), deparseScalarArrayOpExpr(), deparseSortGroupClause(), deparseStringLiteral(), deparseSubscriptingRef(), do_pg_backup_start(), escape_param_str(), exec_stmt_raise(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExplainBeginOutput(), ExplainCloseGroup(), ExplainJSONLineEnding(), ExplainNode(), ExplainOpenGroup(), ExplainProperty(), ExplainPropertyList(), ExplainPropertyListNested(), ExplainSeparatePlans(), ExplainXMLTag(), ExplainYAMLLineStarting(), fetch_table_list(), 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_from_clause_coldeflist(), get_from_clause_item(), get_func_expr(), get_func_sql_syntax(), get_insert_query_def(), get_merge_query_def(), get_oper_expr(), get_parameter(), get_publications_str(), get_range_partbound_string(), get_rule_expr(), get_rule_expr_paren(), get_rule_groupingset(), get_rule_sortgroupclause(), get_rule_windowspec(), get_setop_query(), get_special_variable(), get_sql_insert(), get_sublink_expr(), get_tablefunc(), get_tablesample_def(), get_update_query_def(), get_update_query_targetlist_def(), get_values_def(), get_variable(), get_windowfunc_expr_helper(), get_with_clause(), gist_page_items(), hstore_to_json(), hstore_to_json_loose(), incompatible_module_error(), InteractiveBackend(), json_agg_transfn_worker(), json_build_array_worker(), json_build_object_worker(), json_lex_string(), json_object(), json_object_two_arg(), libpqrcv_create_slot(), libpqrcv_startstreaming(), log_status_format(), make_ruledef(), make_viewdef(), multirange_out(), mxid_to_string(), NameListToQuotedString(), NameListToString(), next_token(), outBitmapset(), outDatum(), outNode(), outToken(), path_encode(), pg_decode_change(), pg_dependencies_out(), pg_get_constraintdef_worker(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), pg_ndistinct_out(), pg_snapshot_out(), pg_split_opts(), pgp_armor_encode(), 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(), rebuildInsertSql(), record_in(), record_out(), replace_percent_placeholders(), reportDependentObjects(), RI_Initial_Check(), RI_PartitionRemove_Check(), 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_modifytable_info(), show_tablesample(), show_tidbitmap_info(), show_wal_usage(), simple_quote_literal(), SPI_sql_row_to_xmlelement(), storeObjectDescription(), stringlist_to_identifierstr(), test_status_failed(), tokenize_auth_file(), tuple_to_stringinfo(), TypeNameListToString(), unistr(), uuid_out(), verify_cb(), write_csvlog(), write_jsonlog(), writeNodeArray(), xlog_outdesc(), XLogRecGetBlockRefInfo(), and xmlpi().

◆ appendStringInfoSpaces()

void appendStringInfoSpaces ( StringInfo  str,
int  count 
)

Definition at line 206 of file stringinfo.c.

207 {
208  if (count > 0)
209  {
210  /* Make more room if needed */
211  enlargeStringInfo(str, count);
212 
213  /* OK, append the spaces */
214  memset(&str->data[str->len], ' ', count);
215  str->len += count;
216  str->data[str->len] = '\0';
217  }
218 }

References enlargeStringInfo(), and generate_unaccent_rules::str.

Referenced by add_indent(), 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 appendStringInfoString ( StringInfo  str,
const char *  s 
)

Definition at line 176 of file stringinfo.c.

177 {
178  appendBinaryStringInfo(str, s, strlen(s));
179 }
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:227

References appendBinaryStringInfo(), and generate_unaccent_rules::str.

Referenced by _outA_Const(), _outA_Expr(), _outBitString(), _outBoolean(), _outBoolExpr(), _outConst(), _outConstraint(), _outFloat(), _outForeignKeyOptInfo(), AddFileToBackupManifest(), appendAggOrderBy(), appendConditions(), appendContextKeyword(), appendFunctionName(), appendGroupByClause(), appendJSONKeyValue(), appendLimitClause(), appendOrderByClause(), appendOrderBySuffix(), appendTypeNameToBuffer(), array_desc(), array_dim_to_json(), array_to_json_internal(), array_to_text_internal(), BackendInitialize(), brin_page_items(), build_tuplestore_recursively(), BuildIndexValueDescription(), BuildParamLogString(), check_publications(), check_publications_origin(), composite_to_json(), concat_internal(), config_enum_get_options(), 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(), escape_json(), escape_xml(), estimate_path_cost_size(), exec_stmt_raise(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), execute_extension_script(), ExplainBeginOutput(), ExplainDummyGroup(), ExplainEndOutput(), ExplainFlushWorkersState(), ExplainIndexScanDetails(), ExplainNode(), ExplainOneUtility(), ExplainOpenGroup(), ExplainPrintJIT(), ExplainPrintSettings(), ExplainProperty(), ExplainPropertyList(), ExplainPropertyListNested(), ExplainQuery(), ExplainTargetRel(), ExplainXMLTag(), ExportSnapshot(), fetch_remote_table_info(), fetch_table_list(), flatten_set_variable_args(), format_expr_params(), format_operator_extended(), format_preparedparamsdata(), format_procedure_extended(), FreePageManagerDump(), funcname_signature_string(), generate_operator_clause(), generate_operator_name(), get_agg_expr_helper(), get_basic_select_query(), get_column_alias_list(), get_const_expr(), get_from_clause(), get_from_clause_coldeflist(), get_from_clause_item(), get_func_expr(), get_func_sql_syntax(), get_insert_query_def(), get_json_constructor(), get_json_constructor_options(), get_json_format(), get_merge_query_def(), get_parameter(), get_publications_str(), 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_setop_query(), get_sql_delete(), get_sql_insert(), get_sql_update(), get_sublink_expr(), get_tablefunc(), 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_windowfunc_expr_helper(), get_with_clause(), getConstraintTypeDescription(), getObjectIdentityParts(), getObjectTypeDescription(), getProcedureTypeDescription(), getRelationIdentity(), getRelationTypeDescription(), gin_desc(), 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_create_slot(), libpqrcv_startstreaming(), log_status_format(), make_ruledef(), make_temptable_name_n(), 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(), op_signature_string(), out_member(), outChar(), outDatum(), outDouble(), outNode(), outToken(), 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_triggerdef_worker(), pg_ndistinct_out(), pg_output_begin(), pg_output_stream_start(), pgp_armor_encode(), plan_elem_desc(), PLy_traceback(), postgresExplainForeignScan(), postgresImportForeignSchema(), print_function_arguments(), print_function_rettype(), print_function_sqlbody(), print_function_trftypes(), print_literal(), printJsonPathItem(), process_pgfdw_appname(), psql_add_command(), quote_object_name(), quote_qualified_identifier(), range_deparse(), rebuildInsertSql(), refresh_by_match_merge(), replace_percent_placeholders(), report_triggers(), 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_sort_group_keys(), show_sortorder_options(), show_tablesample(), show_tidbitmap_info(), show_wal_usage(), ShowUsage(), single_encode(), smgr_desc(), sn_scalar(), spg_desc(), SPI_sql_row_to_xmlelement(), standby_desc_invalidations(), standby_desc_running_xacts(), stringlist_to_identifierstr(), text_format_append_string(), tokenize_auth_file(), transform_string_values_scalar(), 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(), 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()

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

Definition at line 133 of file stringinfo.c.

134 {
135  int avail;
136  size_t nprinted;
137 
138  Assert(str != NULL);
139 
140  /*
141  * If there's hardly any space, don't bother trying, just fail to make the
142  * caller enlarge the buffer first. We have to guess at how much to
143  * enlarge, since we're skipping the formatting work.
144  */
145  avail = str->maxlen - str->len;
146  if (avail < 16)
147  return 32;
148 
149  nprinted = pvsnprintf(str->data + str->len, (size_t) avail, fmt, args);
150 
151  if (nprinted < (size_t) avail)
152  {
153  /* Success. Note nprinted does not include trailing null. */
154  str->len += (int) nprinted;
155  return 0;
156  }
157 
158  /* Restore the trailing null so that str is unmodified. */
159  str->data[str->len] = '\0';
160 
161  /*
162  * Return pvsnprintf's estimate of the space needed. (Although this is
163  * given as a size_t, we know it will fit in int because it's not more
164  * than MaxAllocSize.)
165  */
166  return (int) nprinted;
167 }
size_t pvsnprintf(char *buf, size_t len, const char *fmt, va_list args)
Definition: psprintf.c:106

References generate_unaccent_rules::args, Assert(), fmt, pvsnprintf(), and generate_unaccent_rules::str.

Referenced by appendStringInfo(), PLy_elog_impl(), and psql_add_command().

◆ enlargeStringInfo()

void enlargeStringInfo ( StringInfo  str,
int  needed 
)

Definition at line 283 of file stringinfo.c.

284 {
285  int newlen;
286 
287  /*
288  * Guard against out-of-range "needed" values. Without this, we can get
289  * an overflow or infinite loop in the following.
290  */
291  if (needed < 0) /* should not happen */
292  {
293 #ifndef FRONTEND
294  elog(ERROR, "invalid string enlargement request size: %d", needed);
295 #else
296  fprintf(stderr, "invalid string enlargement request size: %d\n", needed);
298 #endif
299  }
300  if (((Size) needed) >= (MaxAllocSize - (Size) str->len))
301  {
302 #ifndef FRONTEND
303  ereport(ERROR,
304  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
305  errmsg("out of memory"),
306  errdetail("Cannot enlarge string buffer containing %d bytes by %d more bytes.",
307  str->len, needed)));
308 #else
309  fprintf(stderr,
310  _("out of memory\n\nCannot enlarge string buffer containing %d bytes by %d more bytes.\n"),
311  str->len, needed);
313 #endif
314  }
315 
316  needed += str->len + 1; /* total space required now */
317 
318  /* Because of the above test, we now have needed <= MaxAllocSize */
319 
320  if (needed <= str->maxlen)
321  return; /* got enough space already */
322 
323  /*
324  * We don't want to allocate just a little more space with each append;
325  * for efficiency, double the buffer size each time it overflows.
326  * Actually, we might need to more than double it if 'needed' is big...
327  */
328  newlen = 2 * str->maxlen;
329  while (needed > newlen)
330  newlen = 2 * newlen;
331 
332  /*
333  * Clamp to MaxAllocSize in case we went past it. Note we are assuming
334  * here that MaxAllocSize <= INT_MAX/2, else the above loop could
335  * overflow. We will still have newlen >= needed.
336  */
337  if (newlen > (int) MaxAllocSize)
338  newlen = (int) MaxAllocSize;
339 
340  str->data = (char *) repalloc(str->data, newlen);
341 
342  str->maxlen = newlen;
343 }
size_t Size
Definition: c.h:594
int errdetail(const char *fmt,...)
Definition: elog.c:1202
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define _(x)
Definition: elog.c:91
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
exit(1)
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1476
#define MaxAllocSize
Definition: memutils.h:40
#define fprintf
Definition: port.h:242
#define EXIT_FAILURE
Definition: settings.h:167

References _, elog(), ereport, errcode(), errdetail(), errmsg(), ERROR, exit(), EXIT_FAILURE, fprintf, MaxAllocSize, repalloc(), and generate_unaccent_rules::str.

Referenced by AddFileToBackupManifest(), appendBinaryStringInfo(), appendBinaryStringInfoNT(), appendStringInfo(), appendStringInfoChar(), appendStringInfoSpaces(), bbstreamer_zstd_compressor_new(), bbstreamer_zstd_decompressor_new(), CopyReadAttributesCSV(), CopyReadAttributesText(), CopyReadBinaryAttribute(), JsonbToCStringWorker(), jsonPathFromCstring(), jsonPathToCstring(), pg_get_line_append(), pgp_armor_decode(), pgp_armor_encode(), PLy_elog_impl(), pq_getmessage(), pq_sendint16(), pq_sendint32(), pq_sendint64(), pq_sendint8(), psql_add_command(), read_binary_file(), reserveFromBuffer(), SendRowDescriptionMessage(), and XLogSendPhysical().

◆ initStringInfo()

void initStringInfo ( StringInfo  str)

Definition at line 59 of file stringinfo.c.

60 {
61  int size = 1024; /* initial default buffer size */
62 
63  str->data = (char *) palloc(size);
64  str->maxlen = size;
66 }
void * palloc(Size size)
Definition: mcxt.c:1226
void resetStringInfo(StringInfo str)
Definition: stringinfo.c:75

References palloc(), resetStringInfo(), and generate_unaccent_rules::str.

Referenced by AddFileToBackupManifest(), apply_spooled_messages(), array_agg_array_deserialize(), array_agg_deserialize(), array_to_text_internal(), BackendInitialize(), bbstreamer_gzip_decompressor_new(), bbstreamer_lz4_compressor_new(), bbstreamer_lz4_decompressor_new(), bbstreamer_tar_parser_new(), bbstreamer_zstd_compressor_new(), bbstreamer_zstd_decompressor_new(), BeginCopyFrom(), bind_param_error_callback(), bmsToString(), bqarr_in(), brin_bloom_summary_out(), brin_minmax_multi_summary_out(), brin_page_items(), build_tuplestore_recursively(), BuildIndexValueDescription(), BuildParamLogString(), check_publications_origin(), CheckSASLAuth(), checkSharedDependencies(), circle_out(), concat_internal(), config_enum_get_options(), convertToJsonb(), copy_table(), create_cursor(), CreateSchemaCommand(), cube_out(), cursor_to_xml(), dblink_close(), dblink_fetch(), dblink_open(), DeadLockReport(), deparse_expression_pretty(), deparseAnalyzeInfoSql(), deparseAnalyzeSizeSql(), deparseFromExprForRel(), do_analyze_rel(), do_pg_backup_start(), ecpg_filter_source(), ecpg_filter_stderr(), ecpg_start_test(), 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_remote_table_info(), fetch_table_list(), 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_opclass_name(), generate_operator_name(), get_connect_string(), get_from_clause(), get_json_agg_constructor(), get_sql_delete(), get_sql_insert(), get_sql_update(), get_target_list(), get_tuple_of_interest(), getObjectDescription(), getObjectIdentityParts(), getObjectTypeDescription(), GetWALBlockInfo(), GetWALRecordInfo(), gist_page_items(), HandleParallelApplyMessages(), HandleParallelMessages(), heap_vacuum_rel(), hstore_to_json(), hstore_to_json_loose(), hstore_to_jsonb_loose(), incompatible_module_error(), init_libpq_source(), initialize_worker_spi(), int8_avg_deserialize(), json_object(), json_object_two_arg(), json_unique_builder_get_throwawaybuf(), JsonbValueAsText(), jsonpath_send(), jsonPathFromCstring(), jsonPathToCstring(), KnownAssignedXidsDisplay(), libpqrcv_create_slot(), libpqrcv_startstreaming(), logicalrep_report_missing_attrs(), LogRecoveryConflict(), make_temptable_name_n(), makeStringInfo(), 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(), mxid_to_string(), NameListToQuotedString(), NameListToString(), next_field_expand(), nodeToString(), numeric_avg_deserialize(), numeric_deserialize(), numeric_poly_deserialize(), op_signature_string(), parse_fcall_arguments(), path_encode(), PerformAuthentication(), PerformWalRecovery(), pg_armor(), pg_dearmor(), pg_dependencies_out(), pg_extension_update_paths(), pg_get_constraintdef_worker(), 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_querydef(), pg_get_ruledef_worker(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), pg_get_viewdef_worker(), pg_get_wait_events(), pg_ndistinct_out(), pg_snapshot_out(), pg_split_opts(), pgstat_progress_parallel_incr_param(), PLy_elog_impl(), PLy_traceback(), populate_array_report_expected_array(), populate_scalar(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresBeginForeignInsert(), postgresExecForeignTruncate(), postgresGetAnalyzeInfoForForeignTable(), postgresGetForeignPlan(), postgresImportForeignSchema(), PostgresMain(), postgresPlanDirectModify(), postgresPlanForeignModify(), pq_beginmessage(), pq_begintypsend(), pretty_format_node_dump(), print_function_rettype(), printtup_startup(), process_pgfdw_appname(), process_pipe_input(), ProcSleep(), psql_add_command(), quote_object_name(), quote_qualified_identifier(), range_bound_escape(), range_deparse(), range_parse_bound(), range_recv(), read_binary_file(), readfile(), record_in(), record_out(), recv_password_packet(), refresh_by_match_merge(), regression_main(), replace_percent_placeholders(), replace_text(), replace_text_regexp(), ReplicationSlotDropAtPubNode(), reportDependentObjects(), ReportSlotInvalidation(), 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(), 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(), set_backtrace(), show_incremental_sort_group_info(), show_memoize_info(), show_sort_group_keys(), ShowTransactionStateRec(), ShowUsage(), SortTocFromFile(), string_agg_deserialize(), stringlist_to_identifierstr(), table_to_xml_internal(), text_format(), tokenize_auth_file(), tsearch_readline_begin(), TypeNameListToString(), TypeNameToString(), unaccent_lexize(), unistr(), uuid_out(), verify_cb(), WalReceiverMain(), worker_spi_main(), write_auto_conf_file(), write_csvlog(), write_jsonlog(), XLogDumpDisplayRecord(), XLogInsertRecord(), xml_out_internal(), xmlcomment(), xmlconcat(), xmlpi(), xmlroot(), XmlTableGetValue(), and xpath_table().

◆ makeStringInfo()

◆ resetStringInfo()