pg_conn 0.26.1 → 0.26.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dc75936f3c9bd5db772a2f8a80aa8e8bb25cbd1ae2181492766a7ed6ab9104a
4
- data.tar.gz: 8ac094777a20c074f4a018b4bb0ea53efff219eb2401e18bf9c5887721fbb1fe
3
+ metadata.gz: 419e3bd17f4343be6860d172864ad0eeaaed032ab72cc659a02afa14914cdf65
4
+ data.tar.gz: 00d673f75424491bd322cf1321cc8afbb67eba1d955a9545b4f7a0df334bc0b8
5
5
  SHA512:
6
- metadata.gz: 8651be5de05b08d991cc257dab9cc060c4dfe22f8c22b2489f7e9ecc3654d51c55ad8494287b1cb829dc92a50cf60eb777b8814bcc23b348143caf9339729a8c
7
- data.tar.gz: 8c11d1e8cb3ceb859438e9ccb98fe38de9ed9126c449c58972cef97d9fb3108c87ea2a18899aea9d500eaa249625d0a1a783176e3fd4e8bc7ebe035cec31f67b
6
+ metadata.gz: 9e732a7523af59a16052603766aeea731d3d54a4f36fbd250f2dea33b85d1bc890af2fb7de4f8efb96d816eed2ecce390fb4510224715f78bd75a693c4243062
7
+ data.tar.gz: f1b0b073a7231a68a5e0e3b255523c50000db9d50e24596a7545d9228b84bc69056a70b4c8111f899ad6852990ac6b84dc646f2e369c7cb4fbe77f77615d65e7
@@ -16,14 +16,14 @@ module PgConn
16
16
  else
17
17
  conn.tuples %(
18
18
  select datname, usename
19
- from pg_stat_activity
19
+ from pg_stat_activity
20
20
  where datname is not null and usename is not null
21
21
  )
22
22
  end
23
23
  end
24
24
 
25
25
  # Return true if the given database accepts connections
26
- def enabled?(database)
26
+ def enabled?(database)
27
27
  !database.nil? or raise ArgumentError
28
28
  conn.value "select datallowconn from pg_catalog.pg_database where datname = '#{database}'"
29
29
  end
@@ -50,19 +50,21 @@ module PgConn
50
50
  # multiple sessions (is this ever relevant?)
51
51
  #
52
52
  def terminate(database, *users)
53
+ users = Array(users).flatten
53
54
  !database.nil? or raise ArgumentError
54
55
  enabled = self.enabled?(database)
55
56
 
56
57
  case users
57
- when [];
58
+ when [];
58
59
  return
59
60
  when [nil]
60
61
  self.disable(database) if enabled
61
62
  users = self.list(database)
62
- else
63
+ else
63
64
  users = Array(users).flatten
64
65
  end
65
66
  pids = self.pids(database, users)
67
+
66
68
  if !pids.empty?
67
69
  pids_sql = pids.map { |pid| "(#{pid})" }.join(", ")
68
70
  conn.execute "select pg_terminate_backend(pid) from ( values #{pids_sql} ) as x(pid)"
@@ -71,7 +73,7 @@ module PgConn
71
73
  end
72
74
 
73
75
  # Run block without any connected users. Existing sessions are terminated
74
- def exclusive(database, &block)
76
+ def exclusive(database, &block)
75
77
  !database.nil? or raise ArgumentError
76
78
  begin
77
79
  disable(database)
@@ -85,7 +87,7 @@ module PgConn
85
87
  # Return true if session triggers are enabled. Triggers are enabled by
86
88
  # default by Postgres
87
89
  def triggers?() conn.value "select current_setting('session_replication_role') <> 'replica'" end
88
-
90
+
89
91
  # Enable session triggers
90
92
  def enable_triggers()
91
93
  conn.execute "set session session_replication_role = DEFAULT"
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.26.1"
2
+ VERSION = "0.26.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.1
4
+ version: 0.26.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen