Re: pgbench -f and vacuum - Mailing list pgsql-hackers

From Fabrízio de Royes Mello
Subject Re: pgbench -f and vacuum
Date
Msg-id CAFcNs+oZi9NBUgxbQ=-uvYQpjkoiEO5qY7x6xOZ+8MEYCbj1RA@mail.gmail.com
Whole thread Raw
In response to Re: pgbench -f and vacuum  (Tatsuo Ishii <ishii@postgresql.org>)
Responses Re: pgbench -f and vacuum
List pgsql-hackers


On Sun, Dec 21, 2014 at 12:58 PM, Tatsuo Ishii <ishii@postgresql.org> wrote:
>
> > On Sun, Dec 14, 2014 at 11:43 AM, Tatsuo Ishii <ishii@postgresql.org> wrote:
> >>> If we care enough about that case to attempt the vacuum anyway then we
> >>> need to do something about the error message; either squelch it or
> >>> check for the existence of the tables before attempting to
> >>> vacuum. Since there's no way to squelch in the server logfile, I think
> >>> checking for the table is the right answer.
> >>
> >> Fair enough. I will come up with "checking for table before vacuum"
> >> approach.
> >
> > +1 for this approach.
>
> Here is the patch I promised.
>

Some comments:

- Error to apply to the current master:

$ git apply /home/fabrizio/Downloads/pgbench-f-noexit-v2.patch
/home/fabrizio/Downloads/pgbench-f-noexit-v2.patch:9: trailing whitespace.
static void executeStatement2(PGconn *con, const char *sql, const char *table);
/home/fabrizio/Downloads/pgbench-f-noexit-v2.patch:10: trailing whitespace.
static bool is_table_exists(PGconn *con, const char *table);
/home/fabrizio/Downloads/pgbench-f-noexit-v2.patch:18: trailing whitespace.
/* call executeStatement() if table exists */
/home/fabrizio/Downloads/pgbench-f-noexit-v2.patch:19: trailing whitespace.
static void
/home/fabrizio/Downloads/pgbench-f-noexit-v2.patch:20: trailing whitespace.
executeStatement2(PGconn *con, const char *sql, const char *table)
error: patch failed: contrib/pgbench/pgbench.c:88
error: contrib/pgbench/pgbench.c: patch does not apply


+static void executeStatement2(PGconn *con, const char *sql, const char *table);

I think we can use a better name like "executeStatementIfTableExists".


+    if (result == NULL)
+    {
+        PQclear(res);
+        return false;
+    }
+
+    if (*result == 't')
+    {
+        PQclear(res);
+        return false;    /* table does not exist */
+    }

To simplify isn't better this way?

if (result == NULL || *result == 't')
{
    PQclear(res);
    return false; /* table does not exists */
}


Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog: http://fabriziomello.github.io
>> Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
>> Github: http://github.com/fabriziomello

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Add min and max execute statement time in pg_stat_statement
Next
From: Fabrízio de Royes Mello
Date:
Subject: Proposal "VACUUM SCHEMA"