pghero 2.0.7 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pghero might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d81bff1e57b2e38bf36cb246e6795573084d07f9
4
- data.tar.gz: d86266d690d2e6fa0af14849909409c57fb465a4
3
+ metadata.gz: 553643782ed72cb0f44eb8e1f44efc239ace1075
4
+ data.tar.gz: 7defcc2212776fa9a45a45c206f8d7b5461a88c0
5
5
  SHA512:
6
- metadata.gz: be27a44e6c4707c4548d141c9f6d2d5ea5deabf1b08f662d14f03f6b9d4d03eff1a6d5a31112fa9055adfb6a92b75eb112b5c8779cafce7b0ea66e1dec0d63c2
7
- data.tar.gz: 3cf615d23ec3fa2868bf1b1c12866116bbbccfed0a8be8c77e9e260e788eb7b1c987e6dc1d6637fd4886d60df65a3871aa025a6679827e4ff633e36a36ca1fb6
6
+ metadata.gz: 826e25c291d209bb7abd7b5f07ba99576136c6fccdfd60c6ddb075df038779b219958ac31edc50fbd316179a1ef45fc6a98ac284b31d804d7bebae60c07e1128
7
+ data.tar.gz: '0885bb30490a0003edabc433638c6de367ae312c603ed35178da12e1ac8fa497ef4e6d46c19c9c8640b07bdf062a1f755fe297166d7c4d3395c6fca8d8eb94e9'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 2.0.8
2
+
3
+ - Added support for Postgres 10 replicas
4
+ - Added support for pg_query 1.0.0
5
+ - Show queries with insufficient privilege on live queries page
6
+ - Default to table schema for sequences
7
+
1
8
  ## 2.0.7
2
9
 
3
10
  - Fixed issue with sequences in different schema than table
@@ -111,7 +111,7 @@ module PgHero
111
111
 
112
112
  def live_queries
113
113
  @title = "Live Queries"
114
- @running_queries = @database.running_queries
114
+ @running_queries = @database.running_queries(all: true)
115
115
  end
116
116
 
117
117
  def queries
@@ -1,7 +1,7 @@
1
1
  module PgHero
2
2
  module Methods
3
3
  module Queries
4
- def running_queries(min_duration: nil)
4
+ def running_queries(min_duration: nil, all: false)
5
5
  select_all <<-SQL
6
6
  SELECT
7
7
  pid,
@@ -16,11 +16,11 @@ module PgHero
16
16
  FROM
17
17
  pg_stat_activity
18
18
  WHERE
19
- query <> '<insufficient privilege>'
20
- AND state <> 'idle'
19
+ state <> 'idle'
21
20
  AND pid <> pg_backend_pid()
22
21
  AND datname = current_database()
23
22
  #{min_duration ? "AND NOW() - COALESCE(query_start, xact_start) > interval '#{min_duration.to_i} seconds'" : nil}
23
+ #{all ? nil : "AND query <> '<insufficient privilege>'"}
24
24
  ORDER BY
25
25
  COALESCE(query_start, xact_start) DESC
26
26
  SQL
@@ -9,11 +9,18 @@ module PgHero
9
9
  end
10
10
 
11
11
  # http://www.postgresql.org/message-id/CADKbJJWz9M0swPT3oqe8f9+tfD4-F54uE6Xtkh4nERpVsQnjnw@mail.gmail.com
12
- def replication_lag
12
+ def replication_lag
13
+ lag_condition =
14
+ if server_version_num >= 100000
15
+ "pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn()"
16
+ else
17
+ "pg_last_xlog_receive_location() = pg_last_xlog_replay_location()"
18
+ end
19
+
13
20
  select_one <<-SQL
14
21
  SELECT
15
22
  CASE
16
- WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN 0
23
+ WHEN NOT pg_is_in_recovery() OR #{lag_condition} THEN 0
17
24
  ELSE EXTRACT (EPOCH FROM NOW() - pg_last_xact_replay_timestamp())
18
25
  END
19
26
  AS replication_lag
@@ -29,7 +29,7 @@ module PgHero
29
29
  # parse out sequence
30
30
  sequences.each do |column|
31
31
  m = /^nextval\('(.+)'\:\:regclass\)$/.match(column.delete(:default_value))
32
- column[:schema], column[:sequence] = unquote_ident(m[1])
32
+ column[:schema], column[:sequence] = unquote_ident(m[1], column[:table_schema])
33
33
  column[:max_value] = column[:column_type] == 'integer' ? 2147483647 : 9223372036854775807
34
34
  end
35
35
 
@@ -46,11 +46,11 @@ module PgHero
46
46
 
47
47
  private
48
48
 
49
- def unquote_ident(value)
49
+ def unquote_ident(value, default_schema)
50
50
  schema, seq = value.split(".")
51
51
  unless seq
52
52
  seq = schema
53
- schema = 'public'
53
+ schema = default_schema
54
54
  end
55
55
  [unquote(schema), unquote(seq)]
56
56
  end
@@ -188,6 +188,10 @@ module PgHero
188
188
  return {error: "Unknown structure"} unless tree.size == 1
189
189
 
190
190
  tree = tree.first
191
+
192
+ # pg_query 1.0.0
193
+ tree = tree["RawStmt"]["stmt"] if tree["RawStmt"]
194
+
191
195
  table = parse_table(tree) rescue nil
192
196
  unless table
193
197
  error =
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "2.0.7"
2
+ VERSION = "2.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pghero
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-28 00:00:00.000000000 Z
11
+ date: 2017-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord