*** 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);
