In working through a pg_autovacuum problem with Joe Conway (which turned
out to be the same problem reported by Cott Lang which the previous
patch resolved) a new bug was uncovered when running with a debug level
of greater than 1.
This patch resolves this new found bug and fixes some of the other
debugging output to be more consistent.
Please apply to both HEAD and the 7.4 branch.
Matthew T. O'Connor
*** ./pg_autovacuum.c.orig 2004-03-16 23:30:18.372862648 -0500
--- ./pg_autovacuum.c 2004-03-16 23:17:41.187613298 -0500
***************
*** 359,377 ****
void
print_table_info(tbl_info * tbl)
{
! sprintf(logbuffer, " table name: %s.%s", tbl->dbi->dbname, tbl->table_name);
log_entry(logbuffer);
sprintf(logbuffer, " relid: %u; relisshared: %i", tbl->relid, tbl->relisshared);
log_entry(logbuffer);
sprintf(logbuffer, " reltuples: %f; relpages: %u", tbl->reltuples, tbl->relpages);
log_entry(logbuffer);
! sprintf(logbuffer, " curr_analyze_count: %li; cur_delete_count: %li",
tbl->curr_analyze_count, tbl->curr_vacuum_count);
log_entry(logbuffer);
! sprintf(logbuffer, " ins_at_last_analyze: %li; del_at_last_vacuum: %li",
tbl->CountAtLastAnalyze, tbl->CountAtLastVacuum);
log_entry(logbuffer);
! sprintf(logbuffer, " insert_threshold: %li; delete_threshold %li",
tbl->analyze_threshold, tbl->vacuum_threshold);
log_entry(logbuffer);
fflush(LOGOUTPUT);
--- 359,377 ----
void
print_table_info(tbl_info * tbl)
{
! sprintf(logbuffer, " table name: %s.%s", tbl->dbi->dbname, tbl->table_name);
log_entry(logbuffer);
sprintf(logbuffer, " relid: %u; relisshared: %i", tbl->relid, tbl->relisshared);
log_entry(logbuffer);
sprintf(logbuffer, " reltuples: %f; relpages: %u", tbl->reltuples, tbl->relpages);
log_entry(logbuffer);
! sprintf(logbuffer, " curr_analyze_count: %li; curr_vacuum_count: %li",
tbl->curr_analyze_count, tbl->curr_vacuum_count);
log_entry(logbuffer);
! sprintf(logbuffer, " last_analyze_count: %li; last_vacuum_count: %li",
tbl->CountAtLastAnalyze, tbl->CountAtLastVacuum);
log_entry(logbuffer);
! sprintf(logbuffer, " analyze_threshold: %li; vacuum_threshold: %li",
tbl->analyze_threshold, tbl->vacuum_threshold);
log_entry(logbuffer);
fflush(LOGOUTPUT);
***************
*** 678,694 ****
void
print_db_info(db_info * dbi, int print_tbl_list)
{
! sprintf(logbuffer, "dbname: %s Username %s Passwd %s", dbi->dbname,
! dbi->username, dbi->password);
log_entry(logbuffer);
! sprintf(logbuffer, " oid %u InsertThresh: %li DeleteThresh: %li", dbi->oid,
! dbi->analyze_threshold, dbi->vacuum_threshold);
log_entry(logbuffer);
if (dbi->conn != NULL)
! log_entry(" conn is valid, we are connected");
else
! log_entry(" conn is null, we are not connected.");
fflush(LOGOUTPUT);
if (print_tbl_list > 0)
print_table_list(dbi->table_list);
--- 678,706 ----
void
print_db_info(db_info * dbi, int print_tbl_list)
{
! sprintf(logbuffer, "dbname: %s", (dbi->dbname) ? dbi->dbname : "(null)");
log_entry(logbuffer);
!
! sprintf(logbuffer, " oid: %u", dbi->oid);
log_entry(logbuffer);
+
+ sprintf(logbuffer, " username: %s", (dbi->username) ? dbi->username : "(null)");
+ log_entry(logbuffer);
+
+ sprintf(logbuffer, " password: %s", (dbi->password) ? dbi->password : "(null)");
+ log_entry(logbuffer);
+
if (dbi->conn != NULL)
! log_entry(" conn is valid, (connected)");
else
! log_entry(" conn is null, (not connected)");
+ sprintf(logbuffer, " default_analyze_threshold: %li", dbi->analyze_threshold);
+ log_entry(logbuffer);
+
+ sprintf(logbuffer, " default_vacuum_threshold: %li", dbi->vacuum_threshold);
+ log_entry(logbuffer);
+
fflush(LOGOUTPUT);
if (print_tbl_list > 0)
print_table_list(dbi->table_list);
***************
*** 935,941 ****
log_entry(logbuffer);
sprintf(logbuffer, " args->port=%s", (args->port) ? args->port : "(null)");
log_entry(logbuffer);
! sprintf(logbuffer, " args->user=%s", (args->user) ? args->user : "(null)");
log_entry(logbuffer);
sprintf(logbuffer, " args->password=%s", (args->password) ? args->password : "(null)");
log_entry(logbuffer);
--- 947,953 ----
log_entry(logbuffer);
sprintf(logbuffer, " args->port=%s", (args->port) ? args->port : "(null)");
log_entry(logbuffer);
! sprintf(logbuffer, " args->username=%s", (args->user) ? args->user : "(null)");
log_entry(logbuffer);
sprintf(logbuffer, " args->password=%s", (args->password) ? args->password : "(null)");
log_entry(logbuffer);
***************
*** 1007,1013 ****
db_list = init_db_list();
if (db_list == NULL)
return 1;
!
if (check_stats_enabled(((db_info *) DLE_VAL(DLGetHead(db_list)))) != 0)
{
log_entry("Error: GUC variable stats_row_level must be enabled.");
--- 1019,1025 ----
db_list = init_db_list();
if (db_list == NULL)
return 1;
!
if (check_stats_enabled(((db_info *) DLE_VAL(DLGetHead(db_list)))) != 0)
{
log_entry("Error: GUC variable stats_row_level must be enabled.");
*** ./TODO.orig 2004-03-13 14:50:13.000000000 -0500
--- ./TODO 2004-03-13 14:51:27.000000000 -0500
***************
*** 1,6 ****
--- 1,8 ----
Todo Items for pg_autovacuum client
--------------------------------------------------------------------------
+ _Add Startup Message (with datetime stamp) to Logfile when starting and logging
+
_create a FSM export function and see if I can use it for pg_autovacuum
_look into possible benifits of pgstattuple contrib work