Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3d58ea

Browse files
committed
Include dllist.c directly instead of assuming that libpq will provide it.
Whack some semblance of project-conventions-conformance into pg_autovacuum.h.
1 parentdc19aaa commitb3d58ea

File tree

3 files changed

+92
-89
lines changed

3 files changed

+92
-89
lines changed

‎contrib/pg_autovacuum/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
PROGRAM = pg_autovacuum
2-
OBJS= pg_autovacuum.o
2+
OBJS= pg_autovacuum.o dllist.o
33

4-
PG_CPPFLAGS = -I$(libpq_srcdir)
4+
PG_CPPFLAGS = -I$(libpq_srcdir) -DFRONTEND
55
PG_LIBS =$(libpq)
66

77
DOCS = README.pg_autovacuum
88

9+
EXTRA_CLEAN = dllist.c
10+
911
ifdefUSE_PGXS
1012
PGXS =$(shell pg_config --pgxs)
1113
include$(PGXS)
@@ -15,3 +17,6 @@ top_builddir = ../..
1517
include$(top_builddir)/src/Makefile.global
1618
include$(top_srcdir)/contrib/contrib-global.mk
1719
endif
20+
21+
dllist.c:$(top_srcdir)/src/backend/lib/dllist.c
22+
rm -f$@&&$(LN_S)$<.

‎contrib/pg_autovacuum/pg_autovacuum.c

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,88 @@
33
* (c) 2003 Matthew T. O'Connor
44
* Revisions by Christopher B. Browne, Liberty RMS
55
* Win32 Service code added by Dave Page
6+
*
7+
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.22 2004/10/16 21:50:02 tgl Exp $
68
*/
79

8-
#include"pg_autovacuum.h"
10+
#include"postgres_fe.h"
911

12+
#include<unistd.h>
13+
#ifdefHAVE_GETOPT_H
14+
#include<getopt.h>
15+
#endif
16+
#include<time.h>
17+
#include<sys/time.h>
1018
#ifdefWIN32
1119
#include<windows.h>
20+
#endif
1221

22+
#include"pg_autovacuum.h"
23+
24+
#ifdefWIN32
1325
unsignedintsleep();
1426

1527
SERVICE_STATUSServiceStatus;
1628
SERVICE_STATUS_HANDLEhStatus;
1729
intappMode=0;
1830
#endif
1931

20-
FILE*LOGOUTPUT;
21-
charlogbuffer[4096];
32+
/* define atooid */
33+
#defineatooid(x) ((Oid) strtoul((x), NULL, 10))
34+
35+
36+
staticcmd_args*args;
37+
staticFILE*LOGOUTPUT;
38+
staticcharlogbuffer[4096];
39+
40+
41+
/* The main program loop function */
42+
staticintVacuumLoop(intargc,char**argv);
43+
44+
/* Functions for dealing with command line arguements */
45+
staticcmd_args*get_cmd_args(intargc,char*argv[]);
46+
staticvoidprint_cmd_args(void);
47+
staticvoidfree_cmd_args(void);
48+
staticvoidusage(void);
49+
50+
/* Functions for managing database lists */
51+
staticDllist*init_db_list(void);
52+
staticdb_info*init_dbinfo(char*dbname,Oidoid,longage);
53+
staticvoidupdate_db_list(Dllist*db_list);
54+
staticvoidremove_db_from_list(Dlelem*db_to_remove);
55+
staticvoidprint_db_info(db_info*dbi,intprint_table_list);
56+
staticvoidprint_db_list(Dllist*db_list,intprint_table_lists);
57+
staticintxid_wraparound_check(db_info*dbi);
58+
staticvoidfree_db_list(Dllist*db_list);
59+
60+
/* Functions for managing table lists */
61+
statictbl_info*init_table_info(PGresult*conn,introw,db_info*dbi);
62+
staticvoidupdate_table_list(db_info*dbi);
63+
staticvoidremove_table_from_list(Dlelem*tbl_to_remove);
64+
staticvoidprint_table_list(Dllist*tbl_node);
65+
staticvoidprint_table_info(tbl_info*tbl);
66+
staticvoidupdate_table_thresholds(db_info*dbi,tbl_info*tbl,intvacuum_type);
67+
staticvoidfree_tbl_list(Dllist*tbl_list);
68+
69+
/* A few database helper functions */
70+
staticintcheck_stats_enabled(db_info*dbi);
71+
staticPGconn*db_connect(db_info*dbi);
72+
staticvoiddb_disconnect(db_info*dbi);
73+
staticPGresult*send_query(constchar*query,db_info*dbi);
74+
75+
/* Other Generally needed Functions */
76+
#ifndefWIN32
77+
staticvoiddaemonize(void);
78+
#endif
79+
staticvoidlog_entry(constchar*logentry,intlevel);
80+
81+
#ifdefWIN32
82+
/* Windows Service related functions */
83+
staticvoidControlHandler(DWORDrequest);
84+
staticintInstallService();
85+
staticintRemoveService();
86+
#endif
87+
2288

2389
staticvoid
2490
log_entry(constchar*logentry,intlevel)

‎contrib/pg_autovacuum/pg_autovacuum.h

Lines changed: 16 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
1-
/* pg_autovacuum.hszCmdline
1+
/* pg_autovacuum.h
22
* Header file for pg_autovacuum.c
33
* (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 $
46
*/
57

6-
#defineFRONTEND
8+
#ifndef_PG_AUTOVACUUM_H
9+
#define_PG_AUTOVACUUM_H
710

8-
#include"postgres_fe.h"
9-
10-
#include<unistd.h>
11-
#ifdefHAVE_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 */
1911
#include"libpq-fe.h"
2012
#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-
*/
2713

2814
#defineAUTOVACUUM_DEBUG0
2915
#defineVACBASETHRESHOLD1000
@@ -43,9 +29,6 @@
4329
#defineFROZENOID_QUERY "select oid,age(datfrozenxid) from pg_database where datname = 'template1'"
4430
#defineFROZENOID_QUERY2 "select oid,datname,age(datfrozenxid) from pg_database where datname!='template0'"
4531

46-
/* define atooid */
47-
#defineatooid(x) ((Oid) strtoul((x), NULL, 10))
48-
4932
/* Log levels */
5033
enum
5134
{
@@ -57,7 +40,7 @@ enum
5740
};
5841

5942
/* define cmd_args stucture */
60-
structcmdargs
43+
typedefstructcmdargs
6144
{
6245
intvacuum_base_threshold,
6346
analyze_base_threshold,
@@ -81,16 +64,13 @@ struct cmdargs
8164
*host,
8265
*logfile,
8366
*port;
84-
};
85-
typedefstructcmdargscmd_args;
67+
}cmd_args;
8668

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-
structdbinfo
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+
typedefstructdbinfo
9474
{
9575
Oidoid;
9676
longage;
@@ -102,10 +82,9 @@ struct dbinfo
10282
*username,
10383
*password;
10484
Dllist*table_list;
105-
};
106-
typedefstructdbinfodb_info;
85+
}db_info;
10786

108-
structtableinfo
87+
typedefstructtableinfo
10988
{
11089
char*schema_name,
11190
*table_name;
@@ -125,53 +104,6 @@ struct tableinfo
125104
curr_vacuum_count;/* Latest values from stats system */
126105
db_info*dbi;/* pointer to the database that this table
127106
* belongs to */
128-
};
129-
typedefstructtableinfotbl_info;
107+
}tbl_info;
130108

131-
/* The main program loop function */
132-
staticintVacuumLoop(intargc,char**argv);
133-
134-
/* Functions for dealing with command line arguements */
135-
staticcmd_args*get_cmd_args(intargc,char*argv[]);
136-
staticvoidprint_cmd_args(void);
137-
staticvoidfree_cmd_args(void);
138-
staticvoidusage(void);
139-
140-
/* Functions for managing database lists */
141-
staticDllist*init_db_list(void);
142-
staticdb_info*init_dbinfo(char*dbname,Oidoid,longage);
143-
staticvoidupdate_db_list(Dllist*db_list);
144-
staticvoidremove_db_from_list(Dlelem*db_to_remove);
145-
staticvoidprint_db_info(db_info*dbi,intprint_table_list);
146-
staticvoidprint_db_list(Dllist*db_list,intprint_table_lists);
147-
staticintxid_wraparound_check(db_info*dbi);
148-
staticvoidfree_db_list(Dllist*db_list);
149-
150-
/* Functions for managing table lists */
151-
statictbl_info*init_table_info(PGresult*conn,introw,db_info*dbi);
152-
staticvoidupdate_table_list(db_info*dbi);
153-
staticvoidremove_table_from_list(Dlelem*tbl_to_remove);
154-
staticvoidprint_table_list(Dllist*tbl_node);
155-
staticvoidprint_table_info(tbl_info*tbl);
156-
staticvoidupdate_table_thresholds(db_info*dbi,tbl_info*tbl,intvacuum_type);
157-
staticvoidfree_tbl_list(Dllist*tbl_list);
158-
159-
/* A few database helper functions */
160-
staticintcheck_stats_enabled(db_info*dbi);
161-
staticPGconn*db_connect(db_info*dbi);
162-
staticvoiddb_disconnect(db_info*dbi);
163-
staticPGresult*send_query(constchar*query,db_info*dbi);
164-
165-
/* Other Generally needed Functions */
166-
#ifndefWIN32
167-
staticvoiddaemonize(void);
168-
#endif
169-
staticvoidlog_entry(constchar*logentry,intlevel);
170-
171-
#ifdefWIN32
172-
/* Windows Service related functions */
173-
staticvoidControlHandler(DWORDrequest);
174-
staticintInstallService();
175-
staticintRemoveService();
176-
177-
#endif
109+
#endif/* _PG_AUTOVACUUM_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp