viewy 0.1.1 → 0.1.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eff5c5e346be1ca5ab408f4b37431d8af0b102a
|
4
|
+
data.tar.gz: 4699cfb5e13e4331e455f6e970afceb566050e30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 763d4f573e981231058164708e19507e82e904093a7f095cde7aabf27e3dd335e381dba3a2d7e6701bc31ddf4d5362e0dedd10c59cb8bfe145ae0cc6d6e2401a
|
7
|
+
data.tar.gz: 673a0b105715622bc7a8966a777f7855073ce9d5a42daab3ca4780757a6ccec6636e64c9fd482c0a9b07361df2390c5f82e755cced92eeecb08c86cc2b44916e
|
@@ -72,12 +72,16 @@ class AddIndexRecreation < ActiveRecord::Migration
|
|
72
72
|
FOREACH current_statement IN ARRAY create_statements LOOP
|
73
73
|
EXECUTE current_statement;
|
74
74
|
END LOOP;
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
IF index_statements IS NOT NULL THEN
|
76
|
+
FOREACH current_index_statement IN ARRAY index_statements LOOP
|
77
|
+
EXECUTE current_index_statement;
|
78
|
+
END LOOP;
|
79
|
+
END IF;
|
80
|
+
IF current_index_statements IS NOT NULL THEN
|
81
|
+
FOREACH current_index_statement IN ARRAY current_index_statements LOOP
|
82
|
+
EXECUTE current_index_statement;
|
83
|
+
END LOOP;
|
84
|
+
END IF;
|
81
85
|
ALTER EVENT TRIGGER view_dependencies_update ENABLE ALWAYS;
|
82
86
|
END;
|
83
87
|
$$ LANGUAGE plpgsql;
|
@@ -42,7 +42,29 @@ module Viewy
|
|
42
42
|
end
|
43
43
|
|
44
44
|
private def refresh_single_view(view_name, concurrently:)
|
45
|
-
|
45
|
+
begin
|
46
|
+
connection.execute(refresh_sql(view_name, concurrently))
|
47
|
+
rescue ActiveRecord::StatementInvalid => ex
|
48
|
+
if attempt_non_concurrent_refresh?(ex, concurrently)
|
49
|
+
connection.execute(refresh_sql(view_name, false))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param ex [ActiveRecord::StatementInvalid] an exception raised during the view refresh
|
55
|
+
# @param concurrently [Boolean] whether or not the refresh that raised the exception was concurrent
|
56
|
+
#
|
57
|
+
# @raise [ActiveRecord::StatementInvalid] re-raised if the original exception is not a FeatureNotSupported exception
|
58
|
+
#
|
59
|
+
# @return [Boolean] true if the system should attempt to refresh the view non-concurrently after a concurrent
|
60
|
+
# refresh has failed. Since Postgres raises an error when an unpopulated view is refreshed concurrently, this
|
61
|
+
# allows the system to populated such views if needed
|
62
|
+
private def attempt_non_concurrent_refresh?(ex, concurrently)
|
63
|
+
if ex.original_exception.instance_of?(PG::FeatureNotSupported)
|
64
|
+
concurrently
|
65
|
+
else
|
66
|
+
raise ex
|
67
|
+
end
|
46
68
|
end
|
47
69
|
|
48
70
|
# @param name [String] the name of a materialized view
|
data/lib/viewy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emerson Huitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|