Project

General

Profile

Bug #3174 ยป reproduce_crash.rb

ingo (Ingo M), 04/19/2010 08:49 PM

 
1
#!/usr/bin/env ruby
2
# encoding: utf-8
3

    
4
require "rubygems"
5
require "pg"
6

    
7
$old = PGconn.new( :dbname => 'tsm', :host => 'gzptsm01', :user => 'xglogs', :password => 'xglogs' )
8
$new = PGconn.new( :dbname => 'tsm', :host => 'localhost' )
9

    
10
puts "create table "
11
$old.exec("drop table crash_table")
12
$old.exec("create table crash_table ( id int8 , server_a float, server_b float, server_c float, server_d float, server_e float ) ")
13
$new.exec("drop table crash_table")
14
$new.exec("create table crash_table ( id int8 , name varchar(8), value float ) ")
15

    
16
puts "fill table "
17
$old.exec("BEGIN")
18
250000.times {|i| $old.exec("insert into crash_table values ( #{i}, #{rand},  #{rand}, #{rand}, #{rand}, #{rand} ) ") }
19
$old.exec("COMMIT")
20

    
21
puts "queries"
22
['server_a','server_b','server_c','server_d','server_e',].each do |server|
23
	print server," : Session : "
24
	t = $old.exec("select id, #{server} from crash_table ").to_a
25
	print t.size,"\n"
26
	t.each {|i|
27
		$new.exec("insert into crash_table values ( #{i["id"]}, '#{server}', #{i[server]} )")
28
	}
29
end