Re: vacuumlo patch

From: Tim <elatllat(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: vacuumlo patch
Date: 2011-07-25 13:37:07
Message-ID: CA+3zgmsBdZqXjRWNgZikbz-oObG_RhqGG2nRQ2hUBRwivgVd7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Updated the patch to also apply when the no-action flag is enabled.

git diff HEAD -- contrib/vacuumlo/vacuumlo.c
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index f6e2a28..8e9c342 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -48,6 +48,7 @@ struct _param
char *pg_host;
int verbose;
int dry_run;
+ int transaction_limit;
};

int vacuumlo(char *, struct _param *);
@@ -282,10 +283,18 @@ vacuumlo(char *database, struct _param * param)
fprintf(stderr, "%s", PQerrorMessage(conn));
}
else
+ {
deleted++;
+ if(param->transaction_limit!=0 &&
deleted>=param->transaction_limit)
+ break;
+ }
}
else
+ {
deleted++;
+ if(param->transaction_limit!=0 &&
deleted>=param->transaction_limit)
+ break;
+ }
}
PQclear(res);

@@ -313,6 +322,7 @@ usage(const char *progname)
printf(" -h HOSTNAME database server host or socket directory\n");
printf(" -n don't remove large objects, just show what would
be done\n");
printf(" -p PORT database server port\n");
+ printf(" -l LIMIT stop after removing LIMIT LOs\n");
printf(" -U USERNAME user name to connect as\n");
printf(" -w never prompt for password\n");
printf(" -W force password prompt\n");
@@ -342,6 +352,7 @@ main(int argc, char **argv)
param.pg_port = NULL;
param.verbose = 0;
param.dry_run = 0;
+ param.transaction_limit = 0;

if (argc > 1)
{
@@ -359,7 +370,7 @@ main(int argc, char **argv)

while (1)
{
- c = getopt(argc, argv, "h:U:p:vnwW");
+ c = getopt(argc, argv, "h:U:p:l:vnwW");
if (c == -1)
break;

@@ -395,6 +406,14 @@ main(int argc, char **argv)
}
param.pg_port = strdup(optarg);
break;
+ case 'l':
+ param.transaction_limit = strtol(optarg, NULL, 10);
+ if ((param.transaction_limit < 0) ||
(param.transaction_limit > 2147483647))
+ {
+ fprintf(stderr, "%s: invalid transaction limit number:
%s, valid range is form 0(disabled) to 2147483647.\n", progname, optarg);
+ exit(1);
+ }
+ break;
case 'h':
param.pg_host = strdup(optarg);
break;

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-07-25 13:39:02 Re: Questions and experiences writing a Foreign Data Wrapper
Previous Message Robert Haas 2011-07-25 13:23:01 Re: pgbench --unlogged-tables