Re: pg_autovacuum patch to display db name in log file is broken - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: pg_autovacuum patch to display db name in log file is broken
Date
Msg-id 200506151355.j5FDtgU01753@candle.pha.pa.us
Whole thread Raw
List pgsql-patches
Patch applied.  Thanks.

---------------------------------------------------------------------------

Cosimo Streppone wrote:
> Hi Bruce,
>
> it seems that the quick fix I submitted about pg_autovacuum to
> show "ANALYZE dbname.tablename" in logs is broken.
>
> In fact, looking at the cvs diff at:
>
> http://developer.postgresql.org/cvsweb.cgi/pgsql/contrib/pg_autovacuum/pg_autovacuum.c.diff?r1=1.33;r2=1.34
>
> shows that the `buf' string is being snprintf'ed to display log message but
> also to run query against backend, so clearly "ANALYZE mydb.mytable" is not
> going to work.
>
> I noticed that, I think it should be corrected with something like
> the following (diff from pg_autovacuum.c rev. 1.33)
>
> -------8<----------------
>
> --- pg_autovacuum.c.1.33    2005-06-08 13:07:11.744104013 +0200
> +++ pg_autovacuum.c 2005-06-08 13:27:02.258965845 +0200
> @@ -472,7 +472,7 @@
>
>      if (args->debug >= 1)
>      {
> -       sprintf(logbuffer, "Removing table: %s from list.", tbl->table_name);
> +       sprintf(logbuffer, "Removing table: %s.%s from list.", tbl->dbi->dbname,
> tbl->table_name);
>          log_entry(logbuffer, LVL_DEBUG);
>          fflush(LOGOUTPUT);
>      }
> @@ -1057,7 +1057,7 @@
>
>      if (args->debug >= 1)
>      {
> -       sprintf(logbuffer, "Performing: %s", buf);
> +       sprintf(logbuffer, "Performing: %s on database %s", buf, dbi->dbname);
>          log_entry(logbuffer, LVL_DEBUG);
>          fflush(LOGOUTPUT);
>      }
>
> ------8<-------------
>
> Sorry for the error.
> I should have reviewed better the patch before submitting.
>
> --
> Cosimo
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: contrib/pg_autovacuum/pg_autovacuum.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v
retrieving revision 1.34
diff -c -c -r1.34 pg_autovacuum.c
*** contrib/pg_autovacuum/pg_autovacuum.c    11 May 2005 18:07:14 -0000    1.34
--- contrib/pg_autovacuum/pg_autovacuum.c    15 Jun 2005 13:51:39 -0000
***************
*** 479,485 ****

      if (args->debug >= 1)
      {
!         sprintf(logbuffer, "Removing table: %s from list.", tbl->table_name);
          log_entry(logbuffer, LVL_DEBUG);
          fflush(LOGOUTPUT);
      }
--- 479,485 ----

      if (args->debug >= 1)
      {
!         sprintf(logbuffer, "Removing table: %s.%s from list.", tbl->dbi->dbname, tbl->table_name);
          log_entry(logbuffer, LVL_DEBUG);
          fflush(LOGOUTPUT);
      }
***************
*** 1064,1070 ****

      if (args->debug >= 1)
      {
!         sprintf(logbuffer, "Performing: %s", buf);
          log_entry(logbuffer, LVL_DEBUG);
          fflush(LOGOUTPUT);
      }
--- 1064,1070 ----

      if (args->debug >= 1)
      {
!         sprintf(logbuffer, "Performing: %s on database %s", buf, dbi->dbname);
          log_entry(logbuffer, LVL_DEBUG);
          fflush(LOGOUTPUT);
      }

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: uptime function to postmaster
Next
From: Tom Lane
Date:
Subject: Re: plpgsql raise - parameters can be expressions