diff options
author | Bruce Momjian <bruce@momjian.us> | 2003-09-11 19:01:18 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2003-09-11 19:01:18 +0000 |
commit | 3d48045ae12dd3d5364dcaf1c12386e5936fb277 (patch) | |
tree | 9e3697d0e7d0dd0a06ac03e5ad939a9cac229dcd | |
parent | 188eda0df2ab280d0f5ed43cb1de0512e350a51e (diff) | |
download | postgresql-3d48045ae12dd3d5364dcaf1c12386e5936fb277.tar.gz postgresql-3d48045ae12dd3d5364dcaf1c12386e5936fb277.zip |
> 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
-rw-r--r-- | contrib/pg_autovacuum/pg_autovacuum.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/contrib/pg_autovacuum/pg_autovacuum.c b/contrib/pg_autovacuum/pg_autovacuum.c index afa6561a20c..1b1c2a21686 100644 --- a/contrib/pg_autovacuum/pg_autovacuum.c +++ b/contrib/pg_autovacuum/pg_autovacuum.c @@ -88,16 +88,21 @@ init_table_info(PGresult *res, int row, db_info * dbi) new_tbl->table_name = (char *) malloc(strlen(PQgetvalue(res, row, PQfnumber(res, "relname"))) + - strlen(new_tbl->schema_name) + 2); + 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; } - strcpy(new_tbl->table_name, new_tbl->schema_name); - strcat(new_tbl->table_name, "."); + + /* 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"))) + |