Search Postgresql Archives

Re: "timer" script from SAMS book or equivalent?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry...the first version was a bit rash and left out some features...particularly filtering by table. Here's the patch to correct:

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()


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux