debloater 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/debloater/index.rb +18 -8
- data/lib/debloater/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d071b8c2e619cc724f84453444f600241088c6ac
|
4
|
+
data.tar.gz: 54f8a1a4b93b2ec4dee3ea3730c2874ff030e9d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9de264341cffe510b287d4013448ba5fecf2b9cba86519aa05a224f14bf95c1757908102f5dee8f8c07f088833c1bf0b826be9917795d9be7db5bee56d33bcd2
|
7
|
+
data.tar.gz: 4b4e430e2d7978ce58ce627d83cbed6572a2546780a2320bdb55c4a3c2210102d4654b46a34403b735d533c5e7f4800929399154e0daea8bd38e663c5aecfcc3
|
data/lib/debloater/index.rb
CHANGED
@@ -56,21 +56,31 @@ module Debloater
|
|
56
56
|
|
57
57
|
|
58
58
|
def debloat!
|
59
|
+
_log "Old index definition:"
|
60
|
+
_log @sql
|
61
|
+
|
59
62
|
[
|
60
|
-
|
63
|
+
'DROP INDEX IF EXISTS idx_debloat_new',
|
61
64
|
@sql.
|
62
65
|
sub(/CONCURRENTLY/i, '').
|
63
|
-
sub(/CREATE
|
66
|
+
sub(/CREATE\s+(UNIQUE\s+)?INDEX/i, 'CREATE \1INDEX CONCURRENTLY').
|
64
67
|
sub(@name, 'idx_debloat_new'),
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
%{
|
69
|
+
BEGIN;
|
70
|
+
ALTER INDEX #{@name} RENAME TO idx_debloat_old;
|
71
|
+
ALTER INDEX idx_debloat_new RENAME TO #{@name};
|
72
|
+
DROP INDEX idx_debloat_old;
|
73
|
+
COMMIT;
|
74
|
+
},
|
70
75
|
].each do |sql|
|
71
|
-
_log "\t#{sql}"
|
72
76
|
begin
|
77
|
+
_log "\t#{sql}"
|
73
78
|
@conn.exec sql
|
79
|
+
rescue PG::TRDeadlockDetected => e
|
80
|
+
_log "Deadlock encountered. Press enter to retry, ^C to abort."
|
81
|
+
IO.console.gets
|
82
|
+
@conn.exec 'ROLLBACK;'
|
83
|
+
retry
|
74
84
|
rescue PG::DependentObjectsStillExist => e
|
75
85
|
_log "Could not debloat '#{@name}', skipping. Details:"
|
76
86
|
_log e.message
|
data/lib/debloater/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debloater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Letessier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|