Re: "timer" script from SAMS book or equivalent? - Mailing list pgsql-general

From John Wells
Subject Re: "timer" script from SAMS book or equivalent?
Date
Msg-id 14252509.4211192051431489.JavaMail.root@cayman.devsea.com
Whole thread Raw
In response to Re: "timer" script from SAMS book or equivalent?  (John Wells <jb@sourceillustrated.com>)
Responses Re: "timer" script from SAMS book or equivalent?  (John Wells <jb@sourceillustrated.com>)
List pgsql-general
Sorry...the first version was a bit rash and left out some features...particularly filtering by table. Here's the patch
tocorrect: 

If anyone wants the corrected version, email me off list.

Thanks,
John


# diff -w pg_timer_old.rb pg_timer.rb
18a19
>   app = File.basename $0
20,21c21,25
<     #{$0} <query>
<     Example: #{$0} "select * from users"
---
>     #{app} <query> [tablename]
>       or
>     #{app} /path/to/file/containing/query.sql [tablename]
>
>     Example: #{app} "select * from users" "users"
54a59
>
78c83
< if !table_name.nil?
---
>       if table_name.nil?
86c91
< if !table_name.nil?
---
>       if table_name.nil?
194c199,211
<   arg = args[0]
---
>   first = args[0]
>   query = nil
>   if !first.nil? and File.exists?(first)
>     File.open(first, "r") do |f|
>       query = f.read
>     end
>   else
>     query = first
>   end
>
>   table = args[1]
>
>   usage() if args.size < 1
196d212
<   usage() if arg.nil?
201a218
>
204,206c221,223
<   begTupleValues = getTupleValues(tran1, arg)
<   begBlockValues = getBlockValues(tran1, arg)
<   ignore = tran1.exec(args[0])
---
>   begTupleValues = getTupleValues(tran1, table)
>   begBlockValues = getBlockValues(tran1, table)
>   ignore = tran1.exec(query)
212,213c229,232
<   endTupleValues = getTupleValues(tran2, arg)
<   endBlockValues = getBlockValues(tran2, arg)
---
>   tran2.start_tran()
>   endTupleValues = getTupleValues(tran2, table)
>   endBlockValues = getBlockValues(tran2, table)
>   tran2.commit()


pgsql-general by date:

Previous
From: John Wells
Date:
Subject: Re: "timer" script from SAMS book or equivalent?
Next
From: "Selena Deckelmann"
Date:
Subject: PostgreSQL Conference Fall 2007, Registration closing soon!