On Wed, 2003-09-10 at 15:57, Bruce Momjian wrote: > I assume the attached patch is what you want done to fix this. Applied. > > It quotes table names for vacuum and analyze, and uppercases the > keywords for clarity.
Yeah, this is basically what I meant, sorry I didn't get to it quicker. However, I tested it out a little and the patch you made doesn't work because it produces commands like: VACUUM ANALYZE "public.FooBar" Which doesn't work, so I made my own patch that creates commands like: VACUUM ANALYZE "public"."FooBar" This allows for mixed case schema names as well as tables. Adam, can you please give this a test as you are the person who caught the bug in the first place. Thanks, Matthew T. O'Connor
*** pg_autovacuum.c.orig 2003-09-10 23:13:51.950728888 -0400 --- pg_autovacuum.c 2003-09-10 23:59:25.672571940 -0400 *************** *** 88,103 **** new_tbl->table_name = (char *) malloc(strlen(PQgetvalue(res, row, PQfnumber(res, "relname"))) + ! strlen(new_tbl->schema_name) + 2); if (!new_tbl->table_name) { log_entry("init_table_info: malloc failed on new_tbl->table_name"); fflush(LOGOUTPUT); return NULL; } ! strcpy(new_tbl->table_name, new_tbl->schema_name); ! strcat(new_tbl->table_name, "."); strcat(new_tbl->table_name, PQgetvalue(res, row, PQfnumber(res, "relname"))); new_tbl->CountAtLastAnalyze = (atol(PQgetvalue(res, row, PQfnumber(res, "n_tup_ins"))) + --- 88,108 ---- new_tbl->table_name = (char *) malloc(strlen(PQgetvalue(res, row, PQfnumber(res, "relname"))) + ! strlen(new_tbl->schema_name) + 6); if (!new_tbl->table_name) { log_entry("init_table_info: malloc failed on new_tbl->table_name"); fflush(LOGOUTPUT); return NULL; } ! ! /* Put both the schema and table name in quotes so that ! we can work with mixed case table names */ ! strcpy(new_tbl->table_name, "\""); ! strcat(new_tbl->table_name, new_tbl->schema_name); ! strcat(new_tbl->table_name, "\".\""); strcat(new_tbl->table_name, PQgetvalue(res, row, PQfnumber(res, "relname"))); + strcat(new_tbl->table_name, "\""); new_tbl->CountAtLastAnalyze = (atol(PQgetvalue(res, row, PQfnumber(res, "n_tup_ins"))) + *************** *** 581,587 **** { PGresult *res = NULL; ! res = send_query("vacuum", dbi); /* FIXME: Perhaps should add a check for PQ_COMMAND_OK */ PQclear(res); return 1; --- 586,592 ---- { PGresult *res = NULL; ! res = send_query("VACUUM", dbi); /* FIXME: Perhaps should add a check for PQ_COMMAND_OK */ PQclear(res); return 1; *************** *** 733,739 **** PGresult *res = NULL; int ret = 0; ! res = send_query("show stats_row_level", dbi); ret = strcmp("on", PQgetvalue(res, 0, PQfnumber(res, "stats_row_level"))); PQclear(res); --- 738,744 ---- PGresult *res = NULL; int ret = 0; ! res = send_query("SHOW stats_row_level", dbi); ret = strcmp("on", PQgetvalue(res, 0, PQfnumber(res, "stats_row_level"))); PQclear(res); *************** *** 1082,1088 **** */ if ((tbl->curr_vacuum_count - tbl->CountAtLastVacuum) >= tbl->vacuum_threshold) { ! snprintf(buf, sizeof(buf), "vacuum analyze %s", tbl->table_name); if (args->debug >= 1) { sprintf(logbuffer, "Performing: %s", buf); --- 1087,1093 ---- */ if ((tbl->curr_vacuum_count - tbl->CountAtLastVacuum) >= tbl->vacuum_threshold) { ! snprintf(buf, sizeof(buf), "VACUUM ANALYZE %s", tbl->table_name); if (args->debug >= 1) { sprintf(logbuffer, "Performing: %s", buf); *************** *** 1096,1102 **** } else if ((tbl->curr_analyze_count - tbl->CountAtLastAnalyze) >= tbl->analyze_threshold) { ! snprintf(buf, sizeof(buf), "analyze %s", tbl->table_name); if (args->debug >= 1) { sprintf(logbuffer, "Performing: %s", buf); --- 1101,1107 ---- } else if ((tbl->curr_analyze_count - tbl->CountAtLastAnalyze) >= tbl->analyze_threshold) { ! snprintf(buf, sizeof(buf), "ANALYZE %s", tbl->table_name); if (args->debug >= 1) { sprintf(logbuffer, "Performing: %s", buf);
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly