1
- /* pg_autovacuum.hszCmdline
1
+ /* pg_autovacuum.h
2
2
* Header file for pg_autovacuum.c
3
3
* (c) 2003 Matthew T. O'Connor
4
+ *
5
+ * $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.h,v 1.12 2004/10/16 21:50:02 tgl Exp $
4
6
*/
5
7
6
- #define FRONTEND
8
+ #ifndef _PG_AUTOVACUUM_H
9
+ #define _PG_AUTOVACUUM_H
7
10
8
- #include "postgres_fe.h"
9
-
10
- #include <unistd.h>
11
- #ifdef HAVE_GETOPT_H
12
- #include <getopt.h>
13
- #endif
14
- #include <time.h>
15
- #include <sys/time.h>
16
-
17
- /* These next two lines are correct when pg_autovaccum is compiled
18
- from within the postgresql source tree */
19
11
#include "libpq-fe.h"
20
12
#include "lib/dllist.h"
21
- /* Had to change the last two lines to compile on
22
- Redhat outside of postgresql source tree */
23
- /*
24
- #include "/usr/include/libpq-fe.h"
25
- #include "/usr/include/pgsql/server/lib/dllist.h"
26
- */
27
13
28
14
#define AUTOVACUUM_DEBUG 0
29
15
#define VACBASETHRESHOLD 1000
43
29
#define FROZENOID_QUERY "select oid,age(datfrozenxid) from pg_database where datname = 'template1'"
44
30
#define FROZENOID_QUERY2 "select oid,datname,age(datfrozenxid) from pg_database where datname!='template0'"
45
31
46
- /* define atooid */
47
- #define atooid (x ) ((Oid) strtoul((x), NULL, 10))
48
-
49
32
/* Log levels */
50
33
enum
51
34
{
57
40
};
58
41
59
42
/* define cmd_args stucture */
60
- struct cmdargs
43
+ typedef struct cmdargs
61
44
{
62
45
int vacuum_base_threshold ,
63
46
analyze_base_threshold ,
@@ -81,16 +64,13 @@ struct cmdargs
81
64
* host ,
82
65
* logfile ,
83
66
* port ;
84
- };
85
- typedef struct cmdargs cmd_args ;
67
+ } cmd_args ;
86
68
87
-
88
- /* define cmd_args as global so we can get to them everywhere */
89
- cmd_args * args ;
90
-
91
- /* Might need to add a time value for last time the whold database was vacuumed.
92
- I think we need to guarantee this happens approx every 1Million TX's */
93
- struct dbinfo
69
+ /*
70
+ * Might need to add a time value for last time the whole database was
71
+ * vacuumed. We need to guarantee this happens approx every 1Billion TX's
72
+ */
73
+ typedef struct dbinfo
94
74
{
95
75
Oid oid ;
96
76
long age ;
@@ -102,10 +82,9 @@ struct dbinfo
102
82
* username ,
103
83
* password ;
104
84
Dllist * table_list ;
105
- };
106
- typedef struct dbinfo db_info ;
85
+ } db_info ;
107
86
108
- struct tableinfo
87
+ typedef struct tableinfo
109
88
{
110
89
char * schema_name ,
111
90
* table_name ;
@@ -125,53 +104,6 @@ struct tableinfo
125
104
curr_vacuum_count ; /* Latest values from stats system */
126
105
db_info * dbi ; /* pointer to the database that this table
127
106
* belongs to */
128
- };
129
- typedef struct tableinfo tbl_info ;
107
+ } tbl_info ;
130
108
131
- /* The main program loop function */
132
- static int VacuumLoop (int argc , char * * argv );
133
-
134
- /* Functions for dealing with command line arguements */
135
- static cmd_args * get_cmd_args (int argc , char * argv []);
136
- static void print_cmd_args (void );
137
- static void free_cmd_args (void );
138
- static void usage (void );
139
-
140
- /* Functions for managing database lists */
141
- static Dllist * init_db_list (void );
142
- static db_info * init_dbinfo (char * dbname , Oid oid , long age );
143
- static void update_db_list (Dllist * db_list );
144
- static void remove_db_from_list (Dlelem * db_to_remove );
145
- static void print_db_info (db_info * dbi , int print_table_list );
146
- static void print_db_list (Dllist * db_list , int print_table_lists );
147
- static int xid_wraparound_check (db_info * dbi );
148
- static void free_db_list (Dllist * db_list );
149
-
150
- /* Functions for managing table lists */
151
- static tbl_info * init_table_info (PGresult * conn , int row , db_info * dbi );
152
- static void update_table_list (db_info * dbi );
153
- static void remove_table_from_list (Dlelem * tbl_to_remove );
154
- static void print_table_list (Dllist * tbl_node );
155
- static void print_table_info (tbl_info * tbl );
156
- static void update_table_thresholds (db_info * dbi , tbl_info * tbl , int vacuum_type );
157
- static void free_tbl_list (Dllist * tbl_list );
158
-
159
- /* A few database helper functions */
160
- static int check_stats_enabled (db_info * dbi );
161
- static PGconn * db_connect (db_info * dbi );
162
- static void db_disconnect (db_info * dbi );
163
- static PGresult * send_query (const char * query , db_info * dbi );
164
-
165
- /* Other Generally needed Functions */
166
- #ifndef WIN32
167
- static void daemonize (void );
168
- #endif
169
- static void log_entry (const char * logentry , int level );
170
-
171
- #ifdef WIN32
172
- /* Windows Service related functions */
173
- static void ControlHandler (DWORD request );
174
- static int InstallService ();
175
- static int RemoveService ();
176
-
177
- #endif
109
+ #endif /* _PG_AUTOVACUUM_H */
0 commit comments