File: pg-test.rb

package info (click to toggle)
ruby-pg 1.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,316 kB
  • sloc: ansic: 9,403; ruby: 3,160; makefile: 10
file content (45 lines) | stat: -rw-r--r-- 915 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'pg'

conn = PG.connect(
  host: 'yb',
  port: 5433,
  user: 'yugabyte',
  dbname: 'yugabyte',
  sslmode: 'require',
  sslrootcert: 'app/generated_certs/127.0.0.1/ca.crt',
  sslcert: 'app/generated_certs/127.0.0.1/node.127.0.0.1.crt',
  sslkey: 'app/generated_certs/127.0.0.1/node.127.0.0.1.key'
)

$stdout.sync = true
# fd = File.open("pg_trace.log", "a+")
# conn.trace(fd)

begin
  # Validate connection is working
  res = conn.exec("SELECT version();")
  res.each_row do |row|
    puts "You are connected to: #{row[0]}"
  end
# 53*511
# 53*767
# 53*1023
# 53*1279
# 7*1817
# 11*1487
# 13*1363
# 16*1211
# 18*1128
# 22*1984
# 27*1723

  (22..53).each do |m|
    (1..2048).each do |l|
      hanging_query = "SELECT lpad(''::text, #{m}, '0') FROM generate_series(1, #{l});"
      puts "Executing hanging query: #{hanging_query}"
      conn.exec(hanging_query)
    end
  end
ensure
  conn.close if conn
end