PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pg_backup_utils.c File Reference
#include "postgres_fe.h"
#include "parallel.h"
#include "pg_backup_utils.h"
Include dependency graph for pg_backup_utils.c:

Go to the source code of this file.

Macros

#define MAX_ON_EXIT_NICELY   20
 

Functions

void set_dump_section (const char *arg, int *dumpSections)
 
void write_msg (const char *modulename, const char *fmt,...)
 
void vwrite_msg (const char *modulename, const char *fmt, va_list ap)
 
void exit_horribly (const char *modulename, const char *fmt,...)
 
void on_exit_nicely (on_exit_nicely_callback function, void *arg)
 
void exit_nicely (int code)
 

Variables

const char * progname = NULL
 
struct {
   on_exit_nicely_callback   function
 
   void *   arg
 
on_exit_nicely_list [MAX_ON_EXIT_NICELY]
 
static int on_exit_nicely_index
 

Macro Definition Documentation

#define MAX_ON_EXIT_NICELY   20

Definition at line 22 of file pg_backup_utils.c.

Referenced by on_exit_nicely().

Function Documentation

void exit_horribly ( const char *  modulename,
const char *  fmt,
  ... 
)

Definition at line 102 of file pg_backup_utils.c.

References exit_nicely(), and vwrite_msg().

Referenced by _allocAH(), _check_database_version(), _Clone(), _CloseArchive(), _connectDB(), _discoverArchiveFormat(), _doSetSessionAuth(), _EndBlob(), _getFilePos(), _LoadBlobs(), _PrintFileData(), _PrintTocData(), _ReadBuf(), _ReadByte(), _ReopenArchive(), _skipData(), _StartBlob(), _StartBlobs(), _StartData(), _tarAddFile(), _tarGetHeader(), _tarPositionTo(), _tarReadRaw(), AllocateCompressor(), binary_upgrade_extension_member(), buildTocEntryArrays(), cfgetc(), cfopen(), cfopen_write(), cfread(), CloseArchive(), ConnectDatabase(), createViewAsClause(), die_on_query_failure(), dump_lo_buf(), dumpACL(), dumpAgg(), dumpBlobs(), dumpCast(), dumpCollation(), dumpConstraint(), dumpDefaultACL(), dumpFunc(), dumpSequence(), dumpTransform(), EndDBCopyMode(), ExecuteSqlCommandBuf(), ExecuteSqlQueryForSingleRow(), expand_schema_name_patterns(), expand_table_name_patterns(), findDependencyLoops(), findNamespace(), getAttrName(), getMessageFromWorker(), getOwnedSeqs(), getRules(), getTableAttrs(), getTriggers(), InitArchiveFmt_Custom(), InitArchiveFmt_Directory(), InitArchiveFmt_Null(), InitArchiveFmt_Tar(), ListenToWorkers(), lockTableForWorker(), main(), mark_dump_job_done(), mark_restore_job_done(), on_exit_nicely(), ParallelBackupStart(), parseArchiveFormat(), ParseCompressionOption(), parseWorkerCommand(), parseWorkerResponse(), ProcessArchiveRestoreOptions(), processEncodingEntry(), processStdStringsEntry(), ReadDataFromArchive(), ReadHead(), ReadOffset(), ReadToc(), RestoreArchive(), RestoreOutput(), sendMessageToMaster(), sendMessageToWorker(), setFilePath(), SetOutput(), setup_connection(), SortTocFromFile(), StartBlob(), StartRestoreBlob(), StrictNamesCheck(), tarClose(), tarOpen(), TopoSort(), WriteData(), and WriteDataToArchive().

103 {
104  va_list ap;
105 
106  va_start(ap, fmt);
107  vwrite_msg(modulename, fmt, ap);
108  va_end(ap);
109 
110  exit_nicely(1);
111 }
static const char * modulename
Definition: compress_io.c:78
void exit_nicely(int code)
void vwrite_msg(const char *modulename, const char *fmt, va_list ap)
void exit_nicely ( int  code)

Definition at line 142 of file pg_backup_utils.c.

References i, on_exit_nicely_index, and on_exit_nicely_list.

Referenced by exit_horribly(), and set_dump_section().

143 {
144  int i;
145 
146  for (i = on_exit_nicely_index - 1; i >= 0; i--)
147  (*on_exit_nicely_list[i].function) (code,
148  on_exit_nicely_list[i].arg);
149 
150 #ifdef WIN32
151  if (parallel_init_done && GetCurrentThreadId() != mainThreadId)
152  _endthreadex(code);
153 #endif
154 
155  exit(code);
156 }
static struct @38 on_exit_nicely_list[MAX_ON_EXIT_NICELY]
int i
static int on_exit_nicely_index
void on_exit_nicely ( on_exit_nicely_callback  function,
void *  arg 
)

Definition at line 115 of file pg_backup_utils.c.

References arg, exit_horribly(), MAX_ON_EXIT_NICELY, NULL, on_exit_nicely_index, and on_exit_nicely_list.

Referenced by init_parallel_dump_utils(), and on_exit_close_archive().

116 {
118  exit_horribly(NULL, "out of on_exit_nicely slots\n");
119  on_exit_nicely_list[on_exit_nicely_index].function = function;
122 }
#define MAX_ON_EXIT_NICELY
static struct @38 on_exit_nicely_list[MAX_ON_EXIT_NICELY]
#define NULL
Definition: c.h:229
void exit_horribly(const char *modulename, const char *fmt,...)
static int on_exit_nicely_index
void * arg
void set_dump_section ( const char *  arg,
int *  dumpSections 
)

Definition at line 40 of file pg_backup_utils.c.

References _, DUMP_DATA, DUMP_POST_DATA, DUMP_PRE_DATA, DUMP_UNSECTIONED, exit_nicely(), and progname.

Referenced by main().

41 {
42  /* if this is the first call, clear all the bits */
43  if (*dumpSections == DUMP_UNSECTIONED)
44  *dumpSections = 0;
45 
46  if (strcmp(arg, "pre-data") == 0)
47  *dumpSections |= DUMP_PRE_DATA;
48  else if (strcmp(arg, "data") == 0)
49  *dumpSections |= DUMP_DATA;
50  else if (strcmp(arg, "post-data") == 0)
51  *dumpSections |= DUMP_POST_DATA;
52  else
53  {
54  fprintf(stderr, _("%s: unrecognized section name: \"%s\"\n"),
55  progname, arg);
56  fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
57  progname);
58  exit_nicely(1);
59  }
60 }
void exit_nicely(int code)
const char * progname
void * arg
#define _(x)
Definition: elog.c:84
void vwrite_msg ( const char *  modulename,
const char *  fmt,
va_list  ap 
)

Definition at line 84 of file pg_backup_utils.c.

References _, and progname.

Referenced by ahlog(), exit_horribly(), warn_or_exit_horribly(), and write_msg().

85 {
86  if (progname)
87  {
88  if (modulename)
89  fprintf(stderr, "%s: [%s] ", progname, _(modulename));
90  else
91  fprintf(stderr, "%s: ", progname);
92  }
93  vfprintf(stderr, _(fmt), ap);
94 }
static const char * modulename
Definition: compress_io.c:78
const char * progname
#define _(x)
Definition: elog.c:84
void write_msg ( const char *  modulename,
const char *  fmt,
  ... 
)

Variable Documentation

void* arg

Definition at line 27 of file pg_backup_utils.c.

Referenced by _bt_mkscankey(), _copyA_Indirection(), _copyArrayCoerceExpr(), _copyBooleanTest(), _copyCaseExpr(), _copyCoerceToDomain(), _copyCoerceViaIO(), _copyCollateClause(), _copyCollateExpr(), _copyConvertRowtypeExpr(), _copyDefElem(), _copyFieldSelect(), _copyFieldStore(), _copyNamedArgExpr(), _copyNullTest(), _copyRelabelType(), _copyTypeCast(), _equalA_Indirection(), _equalArrayCoerceExpr(), _equalBooleanTest(), _equalCaseExpr(), _equalCoerceToDomain(), _equalCoerceViaIO(), _equalCollateClause(), _equalCollateExpr(), _equalConvertRowtypeExpr(), _equalDefElem(), _equalFieldSelect(), _equalFieldStore(), _equalNamedArgExpr(), _equalNullTest(), _equalRelabelType(), _equalTypeCast(), _outA_Indirection(), _outArrayCoerceExpr(), _outBooleanTest(), _outCaseExpr(), _outCoerceToDomain(), _outCoerceViaIO(), _outCollateClause(), _outCollateExpr(), _outConvertRowtypeExpr(), _outDefElem(), _outFieldSelect(), _outFieldStore(), _outNamedArgExpr(), _outNullTest(), _outRelabelType(), _outTypeCast(), _readArrayCoerceExpr(), _readBooleanTest(), _readCaseExpr(), _readCoerceToDomain(), _readCoerceViaIO(), _readCollateExpr(), _readConvertRowtypeExpr(), _readDefElem(), _readFieldSelect(), _readFieldStore(), _readNamedArgExpr(), _readNullTest(), _readRelabelType(), accumArrayResultArr(), add_one(), add_one_float8(), advance_windowaggregate(), advance_windowaggregate_base(), ATColumnChangeRequiresRewrite(), before_shmem_exit(), binaryheap_allocate(), bit(), bitlength(), bitnot(), bitoctetlength(), bitshiftleft(), bitshiftright(), bittoint4(), bittoint8(), bpcharlen(), bpcharoctetlen(), build_subplan(), CacheRegisterRelcacheCallback(), CacheRegisterSyscacheCallback(), canonicalize_ec_expression(), clause_selectivity(), coerce_record_to_complex(), coerce_to_domain(), coerce_to_target_type(), ComputeIndexAttrs(), ComputePartitionAttrs(), ConvertTriggerToFK(), deconstruct_indexquals(), decrypt_init(), deparseAggref(), deparseFuncExpr(), deparseOpExpr(), dmetaphone(), dmetaphone_alt(), dsm_detach(), dtoi8(), eval_const_expressions_mutator(), evaluate_function(), examine_variable(), exec_check_rw_parameter(), exec_simple_check_node(), ExecEvalFuncArgs(), ExecEvalXmlExpr(), ExecIndexBuildScanKeys(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecuteDoStmt(), expand_boolean_index_clause(), expand_function_arguments(), exprCollation(), expression_tree_walker(), exprLocation(), exprSetCollation(), exprType(), exprTypmod(), FigureColnameInternal(), find_duplicate_ors(), find_ec_member_for_tle(), find_enumitem(), find_param_referent(), fix_indexqual_operand(), flatten_set_variable_args(), float4up(), float8up(), ftoi8(), get_agg_expr(), get_call_expr_arg_stable(), get_call_expr_argtype(), get_cast_hashentry(), get_func_expr(), get_oper_expr(), get_rule_expr(), get_windowfunc_expr(), gincost_opexpr(), gincost_scalararrayopexpr(), ginExtractEntries(), HandleSlashCmds(), i8tod(), i8tof(), i8tooid(), ignore_slash_filepipe(), ignore_slash_options(), ignore_slash_whole_line(), inline_function(), int28(), int2um(), int2up(), int48(), int4inc(), int4um(), int4up(), int82(), int84(), int8dec(), int8inc(), int8um(), int8up(), isSimpleNode(), json_build_array(), json_build_object(), json_object_agg_transfn(), jsonb_agg_finalfn(), jsonb_build_array(), jsonb_build_object(), jsonb_object_agg_finalfn(), list_member_strip(), makeDefElem(), makeDefElemExtended(), makeRelabelType(), match_eclass_clauses_to_index(), match_index_to_operand(), mdc_init(), mdcbuf_init(), numeric_exp(), numeric_inc(), numeric_ln(), numeric_round(), numeric_sqrt(), numeric_trunc(), oidtoi8(), on_dsm_detach(), on_exit_nicely(), on_proc_exit(), on_shmem_exit(), pairingheap_allocate(), ParseFuncOrColumn(), pg_digest(), pg_hmac(), pg_size_bytes(), pgp_pub_decrypt_bytea(), pgp_pub_decrypt_text(), pgp_pub_encrypt_bytea(), pgp_pub_encrypt_text(), pgp_sym_decrypt_bytea(), pgp_sym_decrypt_text(), pgp_sym_encrypt_bytea(), pgp_sym_encrypt_text(), PLy_function_build_args(), postgresGetForeignPaths(), PQsetNoticeProcessor(), PQsetNoticeReceiver(), predicate_refuted_by_simple_clause(), prefix_init(), proc_exit_prepare(), pull_ands(), pull_from_mbuf(), pull_ors(), push_into_mbuf(), quote_postgres(), raw_expression_tree_walker(), rb_create(), RegisterExprContextCallback(), RegisterResourceReleaseCallback(), RegisterSubXactCallback(), RegisterXactCallback(), relabel_to_typmod(), reorder_function_arguments(), runShellCommand(), sepgsql_object_access(), shmem_exit(), show_tablesample(), simplify_and_arguments(), simplify_or_arguments(), soundex(), strip_array_coercion(), tablesample_init(), text_format(), tlist_member_ignore_relabel(), transformAggregateCall(), transformBoolExpr(), transformCaseExpr(), transformFuncCall(), transformRangeFunction(), transformRangeTableSample(), transformTypeCast(), txid_snapshot_xip(), varbit(), xmlcomment(), and xmlelement().

int on_exit_nicely_index
static

Definition at line 30 of file pg_backup_utils.c.

Referenced by exit_nicely(), and on_exit_nicely().

struct { ... } on_exit_nicely_list[MAX_ON_EXIT_NICELY]

Referenced by exit_nicely(), and on_exit_nicely().

const char* progname = NULL

Definition at line 20 of file pg_backup_utils.c.

Referenced by set_dump_section(), and vwrite_msg().