Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Typedefs | Functions

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

Defines

#define appendStringInfoCharMacro(str, ch)

Typedefs

typedef struct StringInfoData StringInfoData
typedef StringInfoDataStringInfo

Functions

StringInfo makeStringInfo (void)
void initStringInfo (StringInfo str)
void resetStringInfo (StringInfo str)
void appendStringInfo (StringInfo str, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE
void bool appendStringInfoVA (StringInfo str, const char *fmt, va_list args) __attribute__((format(PG_PRINTF_ATTRIBUTE
void bool void appendStringInfoString (StringInfo str, const char *s)
void appendStringInfoChar (StringInfo str, char ch)
void appendStringInfoSpaces (StringInfo str, int count)
void appendBinaryStringInfo (StringInfo str, const char *data, int datalen)
void enlargeStringInfo (StringInfo str, int needed)

Define Documentation

#define appendStringInfoCharMacro (   str,
  ch 
)
Value:
(((str)->len + 1 >= (str)->maxlen) ? \
     appendStringInfoChar(str, ch) : \
     (void)((str)->data[(str)->len] = (ch), (str)->data[++(str)->len] = '\0'))

Definition at line 131 of file stringinfo.h.

Referenced by append_with_tabs(), appendCSVLiteral(), CopySendChar(), errdetail_params(), escape_json(), escape_xml(), expand_fmt_string(), ExplainXMLTag(), pq_begintypsend(), pq_send_ascii_string(), pq_sendbyte(), record_out(), strcpy_quoted(), text_format(), and triggered_change_notification().


Typedef Documentation

Definition at line 43 of file stringinfo.h.


Function Documentation

void appendBinaryStringInfo ( StringInfo  str,
const char *  data,
int  datalen 
)
void appendStringInfo ( StringInfo  str,
const char *  fmt,
  ... 
)
void appendStringInfoChar ( StringInfo  str,
char  ch 
)

Definition at line 96 of file compat.c.

References appendStringInfo(), StringInfoData::data, enlargeStringInfo(), StringInfoData::len, and StringInfoData::maxlen.

Referenced by _outBitmapset(), _outList(), _outNode(), _outToken(), _outValue(), appendContextKeyword(), appendStringInfoRegexpSubstr(), appendTypeNameToBuffer(), appendWhereClause(), array_dim_to_json(), BuildIndexValueDescription(), composite_to_json(), ConvertTriggerToFK(), cube_out(), database_to_xml_internal(), DeadLockReport(), deparseArrayExpr(), deparseArrayRef(), deparseBoolExpr(), deparseDistinctExpr(), deparseFuncExpr(), deparseNullTest(), deparseOpExpr(), deparseScalarArrayOpExpr(), deparseStringLiteral(), escape_param_str(), exec_stmt_raise(), ExecBuildSlotValueDescription(), ExplainBeginOutput(), ExplainCloseGroup(), ExplainJSONLineEnding(), ExplainNode(), ExplainOpenGroup(), ExplainProperty(), ExplainPropertyList(), ExplainSeparatePlans(), ExplainYAMLLineStarting(), format_procedure_internal(), funcname_signature_string(), generate_operator_name(), get_agg_expr(), 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_insert_query_def(), get_oper_expr(), get_parameter(), get_rule_expr(), get_rule_expr_paren(), get_rule_windowspec(), get_setop_query(), get_sublink_expr(), get_update_query_def(), get_values_def(), get_variable(), get_windowfunc_expr(), get_with_clause(), heap_desc(), incompatible_module_error(), InteractiveBackend(), json_agg_finalfn(), json_agg_transfn(), json_lex_string(), log_line_prefix(), mxid_to_string(), NameListToQuotedString(), NameListToString(), pg_get_functiondef(), pg_get_indexdef_worker(), pq_send_ascii_string(), printSubscripts(), range_bound_escape(), range_deparse(), range_parse_bound(), record_in(), record_out(), reportDependentObjects(), schema_to_xml_internal(), send_message_to_frontend(), send_message_to_server_log(), sepgsql_proc_post_create(), serialize_deflist(), simple_quote_literal(), SPI_sql_row_to_xmlelement(), storeObjectDescription(), txid_snapshot_out(), TypeNameListToString(), uuid_out(), write_csvlog(), and xmlpi().

{
    appendStringInfo(str, "%c", ch);
}

void appendStringInfoSpaces ( StringInfo  str,
int  count 
)

Definition at line 195 of file stringinfo.c.

References StringInfoData::data, enlargeStringInfo(), and StringInfoData::len.

Referenced by appendContextKeyword(), ExplainCloseGroup(), ExplainDummyGroup(), ExplainNode(), ExplainOpenGroup(), ExplainProperty(), ExplainPropertyList(), ExplainXMLTag(), ExplainYAMLLineStarting(), get_setop_query(), show_hash_info(), show_sort_info(), and text_format_append_string().

{
    if (count > 0)
    {
        /* Make more room if needed */
        enlargeStringInfo(str, count);

        /* OK, append the spaces */
        while (--count >= 0)
            str->data[str->len++] = ' ';
        str->data[str->len] = '\0';
    }
}

void bool void appendStringInfoString ( StringInfo  str,
const char *  s 
)

Definition at line 90 of file compat.c.

References appendBinaryStringInfo(), and appendStringInfo().

Referenced by _outValue(), appendContextKeyword(), appendTypeNameToBuffer(), appendWhereClause(), array_dim_to_json(), array_to_json_internal(), array_to_text_internal(), BuildIndexValueDescription(), composite_to_json(), concat_internal(), config_enum_get_options(), ConvertTriggerToFK(), database_to_xml_internal(), database_to_xmlschema_internal(), datum_to_json(), DeadLockReport(), decompile_column_index_array(), deparseAnalyzeSql(), deparseArrayExpr(), deparseBoolExpr(), deparseColumnRef(), deparseConst(), deparseDeleteSql(), deparseDistinctExpr(), deparseFuncExpr(), deparseInsertSql(), deparseNullTest(), deparseReturningList(), deparseSelectSql(), deparseTargetList(), deparseUpdateSql(), errdetail_params(), escape_json(), escape_xml(), estimate_path_cost_size(), exec_stmt_raise(), ExecBuildSlotValueDescription(), execute_extension_script(), ExplainBeginOutput(), ExplainDummyGroup(), ExplainEndOutput(), ExplainIndexScanDetails(), ExplainNode(), ExplainOneUtility(), ExplainOpenGroup(), ExplainProperty(), ExplainPropertyList(), ExplainQuery(), ExplainTargetRel(), ExplainXMLTag(), ExportSnapshot(), flatten_set_variable_args(), format_procedure_internal(), funcname_signature_string(), generate_operator_name(), get_agg_expr(), get_basic_select_query(), get_column_alias_list(), get_const_expr(), get_from_clause(), get_from_clause_item(), get_func_expr(), get_insert_query_def(), get_rule_expr(), get_rule_orderby(), get_rule_windowclause(), get_rule_windowspec(), get_sql_delete(), get_sql_insert(), get_sql_update(), get_sublink_expr(), get_target_list(), get_tuple_of_interest(), get_update_query_def(), get_utility_query_def(), get_values_def(), get_variable(), get_windowfunc_expr(), get_with_clause(), getConstraintTypeDescription(), getObjectIdentity(), hstore_to_json(), hstore_to_json_loose(), json_agg_transfn(), json_lex_string(), log_line_prefix(), make_ruledef(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), map_sql_value_to_xml_value(), map_xml_name_to_sql_identifier(), NameListToQuotedString(), NameListToString(), op_signature_string(), out_member(), pg_extension_update_paths(), pg_get_constraintdef_worker(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_triggerdef_worker(), PLy_traceback(), print_function_arguments(), print_function_rettype(), query_to_xml_internal(), quote_qualified_identifier(), range_deparse(), report_triggers(), RI_FKey_cascade_upd(), RI_FKey_setdefault_del(), RI_FKey_setdefault_upd(), RI_FKey_setnull_del(), RI_FKey_setnull_upd(), ri_GenerateQual(), ri_ReportViolation(), schema_to_xml_internal(), schema_to_xmlschema_internal(), send_message_to_frontend(), send_message_to_server_log(), sepgsql_proc_post_create(), SPI_sql_row_to_xmlelement(), text_format_append_string(), write_csvlog(), xact_desc_abort(), xact_desc_commit(), xact_desc_commit_compact(), xml_out_internal(), xmlconcat(), xmldata_root_element_start(), xmlpi(), xmlroot(), xsd_schema_element_end(), and xsd_schema_element_start().

{
    appendStringInfo(str, "%s", string);
}

void bool appendStringInfoVA ( StringInfo  str,
const char *  fmt,
va_list  args 
)
void enlargeStringInfo ( StringInfo  str,
int  needed 
)

Definition at line 253 of file stringinfo.c.

References StringInfoData::data, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, StringInfoData::len, MaxAllocSize, StringInfoData::maxlen, and repalloc().

Referenced by appendBinaryStringInfo(), appendStringInfo(), appendStringInfoChar(), appendStringInfoSpaces(), CopyReadAttributesCSV(), CopyReadAttributesText(), CopyReadBinaryAttribute(), GetOldFunctionMessage(), PLy_elog(), pq_getmessage(), and XLogSend().

{
    int         newlen;

    /*
     * Guard against out-of-range "needed" values.  Without this, we can get
     * an overflow or infinite loop in the following.
     */
    if (needed < 0)             /* should not happen */
        elog(ERROR, "invalid string enlargement request size: %d", needed);
    if (((Size) needed) >= (MaxAllocSize - (Size) str->len))
        ereport(ERROR,
                (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
                 errmsg("out of memory"),
                 errdetail("Cannot enlarge string buffer containing %d bytes by %d more bytes.",
                           str->len, needed)));

    needed += str->len + 1;     /* total space required now */

    /* Because of the above test, we now have needed <= MaxAllocSize */

    if (needed <= str->maxlen)
        return;                 /* got enough space already */

    /*
     * We don't want to allocate just a little more space with each append;
     * for efficiency, double the buffer size each time it overflows.
     * Actually, we might need to more than double it if 'needed' is big...
     */
    newlen = 2 * str->maxlen;
    while (needed > newlen)
        newlen = 2 * newlen;

    /*
     * Clamp to MaxAllocSize in case we went past it.  Note we are assuming
     * here that MaxAllocSize <= INT_MAX/2, else the above loop could
     * overflow.  We will still have newlen >= needed.
     */
    if (newlen > (int) MaxAllocSize)
        newlen = (int) MaxAllocSize;

    str->data = (char *) repalloc(str->data, newlen);

    str->maxlen = newlen;
}

void initStringInfo ( StringInfo  str  ) 

Definition at line 46 of file stringinfo.c.

References StringInfoData::data, StringInfoData::maxlen, palloc(), and resetStringInfo().

Referenced by array_to_text_internal(), BeginCopyFrom(), bqarr_in(), build_tuplestore_recursively(), BuildIndexValueDescription(), checkSharedDependencies(), concat_internal(), config_enum_get_options(), ConvertTriggerToFK(), create_cursor(), cube_out(), cursor_to_xml(), dblink_close(), dblink_fdw_validator(), dblink_fetch(), dblink_open(), DeadLockReport(), deparse_expression_pretty(), deparseAnalyzeSizeSql(), do_pg_start_backup(), errdetail_params(), escape_xml(), estimate_path_cost_size(), exec_stmt_raise(), ExecBuildSlotValueDescription(), ExecEvalXml(), execute_extension_script(), expand_fmt_string(), ExportSnapshot(), file_fdw_validator(), flatten_set_variable_args(), format_node_dump(), format_operator_internal(), format_procedure_internal(), fsm_page_contents(), funcname_signature_string(), generate_operator_name(), get_from_clause(), get_sql_delete(), get_sql_insert(), get_sql_update(), get_target_list(), get_tuple_of_interest(), getObjectDescription(), getObjectIdentity(), getObjectTypeDescription(), incompatible_module_error(), initialize_worker_spi(), KnownAssignedXidsDisplay(), 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(), mxid_to_string(), NameListToQuotedString(), NameListToString(), nodeToString(), op_signature_string(), parse_fcall_arguments(), parse_fcall_arguments_20(), parseTypeString(), pg_extension_update_paths(), pg_get_constraintdef_worker(), pg_get_function_arguments(), pg_get_function_identity_arguments(), pg_get_function_result(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_ruledef_worker(), pg_get_triggerdef_worker(), pg_get_viewdef_worker(), PLy_elog(), PLy_traceback(), postgres_fdw_validator(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresGetForeignPlan(), PostgresMain(), postgresPlanForeignModify(), postgresql_fdw_validator(), pq_beginmessage(), pq_begintypsend(), pretty_format_node_dump(), print_function_rettype(), process_pipe_input(), ProcSleep(), quote_object_name(), quote_qualified_identifier(), range_bound_escape(), range_deparse(), range_parse_bound(), range_recv(), record_in(), record_out(), recv_password_packet(), replace_text(), replace_text_regexp(), reportDependentObjects(), ri_Check_Pk_Match(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), RI_FKey_check(), RI_FKey_setdefault_del(), RI_FKey_setdefault_upd(), RI_FKey_setnull_del(), RI_FKey_setnull_upd(), RI_Initial_Check(), ri_ReportViolation(), ri_restrict_del(), ri_restrict_upd(), 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(), ShowTransactionStateRec(), ShowUsage(), StartupXLOG(), table_to_xml_internal(), text_format(), txid_snapshot_out(), TypeNameListToString(), TypeNameToString(), uuid_out(), WalReceiverMain(), WalSndLoop(), worker_spi_main(), write_csvlog(), XLogInsert(), xml_out_internal(), xmlcomment(), xmlconcat(), xmlpi(), xmlroot(), and xpath_table().

{
    int         size = 1024;    /* initial default buffer size */

    str->data = (char *) palloc(size);
    str->maxlen = size;
    resetStringInfo(str);
}

StringInfo makeStringInfo ( void   ) 
void resetStringInfo ( StringInfo  str  )