Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3d48045

Browse files
committed
> 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
1 parent 188eda0 commit 3d48045

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

contrib/pg_autovacuum/pg_autovacuum.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,21 @@ init_table_info(PGresult *res, int row, db_info * dbi)
8888

8989
new_tbl->table_name = (char *)
9090
malloc(strlen(PQgetvalue(res, row, PQfnumber(res, "relname"))) +
91-
strlen(new_tbl->schema_name) + 2);
91+
strlen(new_tbl->schema_name) + 6);
9292
if (!new_tbl->table_name)
9393
{
9494
log_entry("init_table_info: malloc failed on new_tbl->table_name");
9595
fflush(LOGOUTPUT);
9696
return NULL;
9797
}
98-
strcpy(new_tbl->table_name, new_tbl->schema_name);
99-
strcat(new_tbl->table_name, ".");
98+
99+
/* Put both the schema and table name in quotes so that
100+
we can work with mixed case table names */
101+
strcpy(new_tbl->table_name, "\"");
102+
strcat(new_tbl->table_name, new_tbl->schema_name);
103+
strcat(new_tbl->table_name, "\".\"");
100104
strcat(new_tbl->table_name, PQgetvalue(res, row, PQfnumber(res, "relname")));
105+
strcat(new_tbl->table_name, "\"");
101106

102107
new_tbl->CountAtLastAnalyze =
103108
(atol(PQgetvalue(res, row, PQfnumber(res, "n_tup_ins"))) +

0 commit comments

Comments
 (0)