PostgreSQL Source Code git master
Loading...
Searching...
No Matches
vacuuming.h File Reference
#include "common.h"
#include "fe_utils/connect_utils.h"
#include "fe_utils/simple_list.h"
Include dependency graph for vacuuming.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vacuumingOptions
 

Macros

#define ANALYZE_NO_STAGE   -1
 
#define ANALYZE_NUM_STAGES   3
 
#define OBJFILTER_ALL_DBS   0x01 /* --all */
 
#define OBJFILTER_DATABASE   0x02 /* --dbname */
 
#define OBJFILTER_TABLE   0x04 /* --table */
 
#define OBJFILTER_SCHEMA   0x08 /* --schema */
 
#define OBJFILTER_SCHEMA_EXCLUDE   0x10 /* --exclude-schema */
 

Typedefs

typedef struct vacuumingOptions vacuumingOptions
 

Enumerations

enum  RunMode { MODE_VACUUM , MODE_ANALYZE , MODE_ANALYZE_IN_STAGES }
 

Functions

int vacuuming_main (ConnParams *cparams, const char *dbname, const char *maintenance_db, vacuumingOptions *vacopts, SimpleStringList *objects, unsigned int tbl_count, int concurrentCons, const char *progname)
 
charescape_quotes (const char *src)
 

Macro Definition Documentation

◆ ANALYZE_NO_STAGE

#define ANALYZE_NO_STAGE   -1

Definition at line 28 of file vacuuming.h.

◆ ANALYZE_NUM_STAGES

#define ANALYZE_NUM_STAGES   3

Definition at line 29 of file vacuuming.h.

◆ OBJFILTER_ALL_DBS

#define OBJFILTER_ALL_DBS   0x01 /* --all */

Definition at line 60 of file vacuuming.h.

◆ OBJFILTER_DATABASE

#define OBJFILTER_DATABASE   0x02 /* --dbname */

Definition at line 61 of file vacuuming.h.

◆ OBJFILTER_SCHEMA

#define OBJFILTER_SCHEMA   0x08 /* --schema */

Definition at line 63 of file vacuuming.h.

◆ OBJFILTER_SCHEMA_EXCLUDE

#define OBJFILTER_SCHEMA_EXCLUDE   0x10 /* --exclude-schema */

Definition at line 64 of file vacuuming.h.

◆ OBJFILTER_TABLE

#define OBJFILTER_TABLE   0x04 /* --table */

Definition at line 62 of file vacuuming.h.

Typedef Documentation

◆ vacuumingOptions

Enumeration Type Documentation

◆ RunMode

Enumerator
MODE_VACUUM 
MODE_ANALYZE 
MODE_ANALYZE_IN_STAGES 

Definition at line 20 of file vacuuming.h.

21{
25} RunMode;
RunMode
Definition vacuuming.h:21
@ MODE_ANALYZE
Definition vacuuming.h:23
@ MODE_VACUUM
Definition vacuuming.h:22
@ MODE_ANALYZE_IN_STAGES
Definition vacuuming.h:24

Function Documentation

◆ escape_quotes()

char * escape_quotes ( const char src)
extern

Definition at line 1043 of file vacuuming.c.

1044{
1045 char *result = escape_single_quotes_ascii(src);
1046
1047 if (!result)
1048 pg_fatal("out of memory");
1049 return result;
1050}
#define pg_fatal(...)
char * escape_single_quotes_ascii(const char *src)
Definition quotes.c:33

References escape_single_quotes_ascii(), and pg_fatal.

◆ vacuuming_main()

int vacuuming_main ( ConnParams cparams,
const char dbname,
const char maintenance_db,
vacuumingOptions vacopts,
SimpleStringList objects,
unsigned int  tbl_count,
int  concurrentCons,
const char progname 
)
extern

Definition at line 55 of file vacuuming.c.

60{
62
63 /* Avoid opening extra connections. */
64 if (tbl_count > 0 && (concurrentCons > tbl_count))
66
67 if (vacopts->objfilter & OBJFILTER_ALL_DBS)
68 {
69 cparams->dbname = maintenance_db;
70
71 return vacuum_all_databases(cparams, vacopts,
72 objects,
74 progname);
75 }
76 else
77 {
78 if (dbname == NULL)
79 {
80 if (getenv("PGDATABASE"))
81 dbname = getenv("PGDATABASE");
82 else if (getenv("PGUSER"))
83 dbname = getenv("PGUSER");
84 else
86 }
87
88 cparams->dbname = dbname;
89
91 {
93
94 for (int stage = 0; stage < ANALYZE_NUM_STAGES; stage++)
95 {
96 int ret;
97
98 ret = vacuum_one_database(cparams, vacopts,
99 stage,
100 objects,
101 vacopts->missing_stats_only ? &found_objs : NULL,
103 progname);
104 if (ret != 0)
105 {
107 return ret;
108 }
109 }
110
112 return EXIT_SUCCESS;
113 }
114 else
115 return vacuum_one_database(cparams, vacopts,
117 objects, NULL,
119 progname);
120 }
121}
void setup_cancel_handler(void(*query_cancel_callback)(void))
Definition cancel.c:183
const char * progname
Definition main.c:44
static int fb(int x)
#define EXIT_SUCCESS
Definition settings.h:193
char * dbname
Definition streamutil.c:49
char * dbname
Definition pg_backup.h:87
const char * get_user_name_or_exit(const char *progname)
Definition username.c:74
static int vacuum_all_databases(ConnParams *cparams, vacuumingOptions *vacopts, SimpleStringList *objects, int concurrentCons, const char *progname)
Definition vacuuming.c:439
static int vacuum_one_database(ConnParams *cparams, vacuumingOptions *vacopts, int stage, SimpleStringList *objects, SimpleStringList **found_objs, int concurrentCons, const char *progname)
Definition vacuuming.c:164
static void free_retrieved_objects(SimpleStringList *list)
Definition vacuuming.c:819
#define OBJFILTER_ALL_DBS
Definition vacuuming.h:60
#define ANALYZE_NUM_STAGES
Definition vacuuming.h:29
#define ANALYZE_NO_STAGE
Definition vacuuming.h:28

References ANALYZE_NO_STAGE, ANALYZE_NUM_STAGES, dbname, _connParams::dbname, EXIT_SUCCESS, fb(), free_retrieved_objects(), get_user_name_or_exit(), MODE_ANALYZE_IN_STAGES, OBJFILTER_ALL_DBS, progname, setup_cancel_handler(), vacuum_all_databases(), and vacuum_one_database().

Referenced by main().