ovirt_metrics 2.0.0 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/lib/active_record/connection_adapters/ovirt_postgresql_adapter.rb +31 -0
  4. data/lib/ovirt_metrics/version.rb +1 -1
  5. data/lib/ovirt_metrics.rb +4 -8
  6. metadata +32 -57
  7. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/column.rb +0 -15
  8. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/database_statements.rb +0 -170
  9. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/explain_pretty_printer.rb +0 -42
  10. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/array.rb +0 -70
  11. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bit.rb +0 -52
  12. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bit_varying.rb +0 -13
  13. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bytea.rb +0 -15
  14. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/cidr.rb +0 -48
  15. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/date_time.rb +0 -21
  16. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/decimal.rb +0 -13
  17. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/enum.rb +0 -19
  18. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/hstore.rb +0 -59
  19. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/inet.rb +0 -13
  20. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/json.rb +0 -10
  21. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/jsonb.rb +0 -23
  22. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/money.rb +0 -39
  23. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/point.rb +0 -43
  24. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/rails_5_1_point.rb +0 -50
  25. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/range.rb +0 -93
  26. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/specialized_string.rb +0 -15
  27. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/type_map_initializer.rb +0 -109
  28. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/uuid.rb +0 -21
  29. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/vector.rb +0 -26
  30. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/xml.rb +0 -28
  31. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid.rb +0 -31
  32. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/quoting.rb +0 -116
  33. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/referential_integrity.rb +0 -49
  34. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_definitions.rb +0 -180
  35. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_dumper.rb +0 -47
  36. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_statements.rb +0 -682
  37. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/type_metadata.rb +0 -35
  38. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/utils.rb +0 -77
  39. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql_adapter.rb +0 -856
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44450df0a7e97dcfb4ce4130086d6f9bffae58357cc9b0b86c64449c38a7294b
4
- data.tar.gz: b41dd6c590ce4c99bf0a3892c9dd941bb56df5b0477b2f7982c4b26fa6558873
3
+ metadata.gz: 833cc61457e356f5205dc435fd697fe9a699ba2a656c807b76ecfa91909922a8
4
+ data.tar.gz: 341fe95c2e871e104c965941a95ff6ec4c324b94cb70683b8bf60806200a65e8
5
5
  SHA512:
6
- metadata.gz: 051223d519ad682d3e5d91115de76d25d3cbbbf87ca81a686a287ad92199da2535fea4e2842aeb0fe582ca29e5f139c87e2cca713cce1ffa498a0a948945a3e0
7
- data.tar.gz: 6c4fd514f05daf23892844ca0a162eb2753aa2f2cd104b01c22b41644fd0e631e222efbb65ab4f4f11949594c765ece5f1a8c0bcd719b8bf541e3823230bf2e4
6
+ metadata.gz: 7d0c603f7046af77f7c2aac5c665ea5c070c59adacee17d6efd6c264b88b8aa2c3d217b19f071996ef8fe463a26406824bd3143641affe5e1a42a8b78883d19c
7
+ data.tar.gz: d88f6a5ed0d917d1ea1c7b8892bf78a252e545fafedf709b582242f9091d3a2e33cfb5b33e123fe0c9e196d6b6e62270de6fbab23a42f93975be0a08216879e6
data/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
  [![Build Status](https://travis-ci.org/ManageIQ/ovirt_metrics.svg?branch=master)](https://travis-ci.org/ManageIQ/ovirt_metrics)
5
5
  [![Code Climate](http://img.shields.io/codeclimate/github/ManageIQ/ovirt_metrics.svg)](https://codeclimate.com/github/ManageIQ/ovirt_metrics)
6
6
  [![Coverage Status](http://img.shields.io/coveralls/ManageIQ/ovirt_metrics.svg)](https://coveralls.io/r/ManageIQ/ovirt_metrics)
7
- [![Dependency Status](https://gemnasium.com/ManageIQ/ovirt_metrics.svg)](https://gemnasium.com/ManageIQ/ovirt_metrics)
8
7
 
9
8
  OvirtMetrics is an ActiveRecord-based gem for reading the oVirt History database.
10
9
 
@@ -0,0 +1,31 @@
1
+ module ActiveRecord
2
+ module ConnectionHandling # :nodoc:
3
+ def ovirt_postgresql_connection(config)
4
+ conn_params = config.symbolize_keys
5
+
6
+ conn_params.delete_if { |_, v| v.nil? }
7
+
8
+ conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
9
+ conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]
10
+
11
+ valid_conn_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl]
12
+ conn_params.slice!(*valid_conn_param_keys)
13
+
14
+ conn = PG.connect(conn_params) if ActiveRecord::VERSION::MAJOR >= 6
15
+ ConnectionAdapters::OvirtPostgreSQLAdapter.new(conn, logger, conn_params, config)
16
+ end
17
+ end
18
+
19
+ module ConnectionAdapters
20
+ class OvirtPostgreSQLAdapter < PostgreSQLAdapter
21
+ ADAPTER_NAME = "OvirtPostgreSQL"
22
+
23
+ def check_version
24
+ msg = "The version of PostgreSQL (#{postgresql_version}) is too old (9.2+ required)"
25
+ if postgresql_version < 90200
26
+ raise msg
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module OvirtMetrics
2
- VERSION = "2.0.0"
2
+ VERSION = "3.0.3"
3
3
  end
data/lib/ovirt_metrics.rb CHANGED
@@ -27,14 +27,10 @@ module OvirtMetrics
27
27
  opts ||= {}
28
28
  opts[:port] ||= 5432
29
29
  opts[:database] ||= DEFAULT_HISTORY_DATABASE_NAME
30
- opts[:adapter] = begin
31
- if ActiveRecord::VERSION::MAJOR > 4
32
- require "active_record/connection_adapters/ovirt_legacy_postgresql_adapter"
33
- 'ovirt_legacy_postgresql'
34
- else
35
- 'postgresql'
36
- end
37
- end
30
+ opts[:adapter] = begin
31
+ require "active_record/connection_adapters/ovirt_postgresql_adapter"
32
+ 'ovirt_postgresql'
33
+ end
38
34
 
39
35
  # Don't allow accidental connections to localhost. A blank host will
40
36
  # connect to localhost, so don't allow that at all.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ovirt_metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Barenboim
@@ -9,24 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-05 00:00:00.000000000 Z
12
+ date: 2021-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '1.3'
20
+ version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '1.3'
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake
29
+ name: coveralls
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
@@ -40,7 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: pry
43
+ name: manageiq-style
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
@@ -54,21 +54,21 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: rspec
57
+ name: pry
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '3.0'
62
+ version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '3.0'
69
+ version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: sqlite3
71
+ name: rake
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
@@ -82,7 +82,21 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: coveralls
85
+ name: rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '3.0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '3.0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: sqlite3
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - ">="
@@ -99,22 +113,16 @@ dependencies:
99
113
  name: activerecord
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: 4.2.3
105
116
  - - "<"
106
117
  - !ruby/object:Gem::Version
107
- version: '5.2'
118
+ version: '6.1'
108
119
  type: :runtime
109
120
  prerelease: false
110
121
  version_requirements: !ruby/object:Gem::Requirement
111
122
  requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: 4.2.3
115
123
  - - "<"
116
124
  - !ruby/object:Gem::Version
117
- version: '5.2'
125
+ version: '6.1'
118
126
  - !ruby/object:Gem::Dependency
119
127
  name: pg
120
128
  requirement: !ruby/object:Gem::Requirement
@@ -141,39 +149,7 @@ files:
141
149
  - ".rspec"
142
150
  - LICENSE.txt
143
151
  - README.md
144
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/column.rb
145
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/database_statements.rb
146
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/explain_pretty_printer.rb
147
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid.rb
148
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/array.rb
149
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bit.rb
150
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bit_varying.rb
151
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bytea.rb
152
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/cidr.rb
153
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/date_time.rb
154
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/decimal.rb
155
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/enum.rb
156
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/hstore.rb
157
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/inet.rb
158
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/json.rb
159
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/jsonb.rb
160
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/money.rb
161
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/point.rb
162
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/rails_5_1_point.rb
163
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/range.rb
164
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/specialized_string.rb
165
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/type_map_initializer.rb
166
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/uuid.rb
167
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/vector.rb
168
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/xml.rb
169
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/quoting.rb
170
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/referential_integrity.rb
171
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_definitions.rb
172
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_dumper.rb
173
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_statements.rb
174
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/type_metadata.rb
175
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql/utils.rb
176
- - lib/active_record/connection_adapters/ovirt_legacy_postgresql_adapter.rb
152
+ - lib/active_record/connection_adapters/ovirt_postgresql_adapter.rb
177
153
  - lib/ovirt_metrics.rb
178
154
  - lib/ovirt_metrics/column_definitions.rb
179
155
  - lib/ovirt_metrics/configurator.rb
@@ -242,15 +218,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
242
218
  requirements:
243
219
  - - ">="
244
220
  - !ruby/object:Gem::Version
245
- version: '2.1'
221
+ version: 2.5.8
246
222
  required_rubygems_version: !ruby/object:Gem::Requirement
247
223
  requirements:
248
224
  - - ">="
249
225
  - !ruby/object:Gem::Version
250
226
  version: '0'
251
227
  requirements: []
252
- rubyforge_project:
253
- rubygems_version: 2.7.2
228
+ rubygems_version: 3.2.27
254
229
  signing_key:
255
230
  specification_version: 4
256
231
  summary: OvirtMetrics is an ActiveRecord-based gem for reading the oVirt History database.
@@ -1,15 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- # PostgreSQL-specific extensions to column definitions in a table.
4
- class OvirtLegacyPostgreSQLColumn < Column #:nodoc:
5
- delegate :array, :oid, :fmod, to: :sql_type_metadata
6
- alias :array? :array
7
-
8
- def serial?
9
- return unless default_function
10
-
11
- %r{\Anextval\('"?#{table_name}_#{name}_seq"?'::regclass\)\z} === default_function
12
- end
13
- end
14
- end
15
- end
@@ -1,170 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module DatabaseStatements
5
- def explain(arel, binds = [])
6
- sql = "EXPLAIN #{to_sql(arel, binds)}"
7
- OvirtLegacyPostgreSQL::ExplainPrettyPrinter.new.pp(exec_query(sql, 'EXPLAIN', binds))
8
- end
9
-
10
- def select_value(arel, name = nil, binds = [])
11
- arel, binds = binds_from_relation arel, binds
12
- sql = to_sql(arel, binds)
13
- execute_and_clear(sql, name, binds) do |result|
14
- result.getvalue(0, 0) if result.ntuples > 0 && result.nfields > 0
15
- end
16
- end
17
-
18
- def select_values(arel, name = nil, binds = [])
19
- arel, binds = binds_from_relation arel, binds
20
- sql = to_sql(arel, binds)
21
- execute_and_clear(sql, name, binds) do |result|
22
- if result.nfields > 0
23
- result.column_values(0)
24
- else
25
- []
26
- end
27
- end
28
- end
29
-
30
- # Executes a SELECT query and returns an array of rows. Each row is an
31
- # array of field values.
32
- def select_rows(sql, name = nil, binds = [])
33
- execute_and_clear(sql, name, binds) do |result|
34
- result.values
35
- end
36
- end
37
-
38
- # The internal PostgreSQL identifier of the money data type.
39
- MONEY_COLUMN_TYPE_OID = 790 #:nodoc:
40
- # The internal PostgreSQL identifier of the BYTEA data type.
41
- BYTEA_COLUMN_TYPE_OID = 17 #:nodoc:
42
-
43
- # create a 2D array representing the result set
44
- def result_as_array(res) #:nodoc:
45
- # check if we have any binary column and if they need escaping
46
- ftypes = Array.new(res.nfields) do |i|
47
- [i, res.ftype(i)]
48
- end
49
-
50
- rows = res.values
51
- return rows unless ftypes.any? { |_, x|
52
- x == BYTEA_COLUMN_TYPE_OID || x == MONEY_COLUMN_TYPE_OID
53
- }
54
-
55
- typehash = ftypes.group_by { |_, type| type }
56
- binaries = typehash[BYTEA_COLUMN_TYPE_OID] || []
57
- monies = typehash[MONEY_COLUMN_TYPE_OID] || []
58
-
59
- rows.each do |row|
60
- # unescape string passed BYTEA field (OID == 17)
61
- binaries.each do |index, _|
62
- row[index] = unescape_bytea(row[index])
63
- end
64
-
65
- # If this is a money type column and there are any currency symbols,
66
- # then strip them off. Indeed it would be prettier to do this in
67
- # OvirtLegacyPostgreSQLColumn.string_to_decimal but would break form input
68
- # fields that call value_before_type_cast.
69
- monies.each do |index, _|
70
- data = row[index]
71
- # Because money output is formatted according to the locale, there are two
72
- # cases to consider (note the decimal separators):
73
- # (1) $12,345,678.12
74
- # (2) $12.345.678,12
75
- case data
76
- when /^-?\D+[\d,]+\.\d{2}$/ # (1)
77
- data.gsub!(/[^-\d.]/, '')
78
- when /^-?\D+[\d.]+,\d{2}$/ # (2)
79
- data.gsub!(/[^-\d,]/, '').sub!(/,/, '.')
80
- end
81
- end
82
- end
83
- end
84
-
85
- # Queries the database and returns the results in an Array-like object
86
- def query(sql, name = nil) #:nodoc:
87
- log(sql, name) do
88
- result_as_array @connection.async_exec(sql)
89
- end
90
- end
91
-
92
- # Executes an SQL statement, returning a PGresult object on success
93
- # or raising a PGError exception otherwise.
94
- # Note: the PGresult object is manually memory managed; if you don't
95
- # need it specifically, you many want consider the exec_query wrapper.
96
- def execute(sql, name = nil)
97
- log(sql, name) do
98
- @connection.async_exec(sql)
99
- end
100
- end
101
-
102
- def exec_query(sql, name = 'SQL', binds = [], prepare: false)
103
- execute_and_clear(sql, name, binds, prepare: prepare) do |result|
104
- types = {}
105
- fields = result.fields
106
- fields.each_with_index do |fname, i|
107
- ftype = result.ftype i
108
- fmod = result.fmod i
109
- types[fname] = get_oid_type(ftype, fmod, fname)
110
- end
111
- ActiveRecord::Result.new(fields, result.values, types)
112
- end
113
- end
114
-
115
- def exec_delete(sql, name = 'SQL', binds = [])
116
- execute_and_clear(sql, name, binds) {|result| result.cmd_tuples }
117
- end
118
- alias :exec_update :exec_delete
119
-
120
- def sql_for_insert(sql, pk, id_value, sequence_name, binds) # :nodoc:
121
- if pk.nil?
122
- # Extract the table from the insert sql. Yuck.
123
- table_ref = extract_table_ref_from_insert_sql(sql)
124
- pk = primary_key(table_ref) if table_ref
125
- end
126
-
127
- if pk && use_insert_returning?
128
- sql = "#{sql} RETURNING #{quote_column_name(pk)}"
129
- end
130
-
131
- super
132
- end
133
-
134
- def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
135
- val = exec_query(sql, name, binds)
136
- if !use_insert_returning? && pk
137
- unless sequence_name
138
- table_ref = extract_table_ref_from_insert_sql(sql)
139
- sequence_name = default_sequence_name(table_ref, pk)
140
- return val unless sequence_name
141
- end
142
- last_insert_id_result(sequence_name)
143
- else
144
- val
145
- end
146
- end
147
-
148
- # Begins a transaction.
149
- def begin_db_transaction
150
- execute "BEGIN"
151
- end
152
-
153
- def begin_isolated_db_transaction(isolation)
154
- begin_db_transaction
155
- execute "SET TRANSACTION ISOLATION LEVEL #{transaction_isolation_levels.fetch(isolation)}"
156
- end
157
-
158
- # Commits a transaction.
159
- def commit_db_transaction
160
- execute "COMMIT"
161
- end
162
-
163
- # Aborts a transaction.
164
- def exec_rollback_db_transaction
165
- execute "ROLLBACK"
166
- end
167
- end
168
- end
169
- end
170
- end
@@ -1,42 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- class ExplainPrettyPrinter # :nodoc:
5
- # Pretty prints the result of an EXPLAIN in a way that resembles the output of the
6
- # PostgreSQL shell:
7
- #
8
- # QUERY PLAN
9
- # ------------------------------------------------------------------------------
10
- # Nested Loop Left Join (cost=0.00..37.24 rows=8 width=0)
11
- # Join Filter: (posts.user_id = users.id)
12
- # -> Index Scan using users_pkey on users (cost=0.00..8.27 rows=1 width=4)
13
- # Index Cond: (id = 1)
14
- # -> Seq Scan on posts (cost=0.00..28.88 rows=8 width=4)
15
- # Filter: (posts.user_id = 1)
16
- # (6 rows)
17
- #
18
- def pp(result)
19
- header = result.columns.first
20
- lines = result.rows.map(&:first)
21
-
22
- # We add 2 because there's one char of padding at both sides, note
23
- # the extra hyphens in the example above.
24
- width = [header, *lines].map(&:length).max + 2
25
-
26
- pp = []
27
-
28
- pp << header.center(width).rstrip
29
- pp << '-' * width
30
-
31
- pp += lines.map {|line| " #{line}"}
32
-
33
- nrows = result.rows.length
34
- rows_label = nrows == 1 ? 'row' : 'rows'
35
- pp << "(#{nrows} #{rows_label})"
36
-
37
- pp.join("\n") + "\n"
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,70 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Array < Type::Value # :nodoc:
6
- include Type::Helpers::Mutable
7
-
8
- attr_reader :subtype, :delimiter
9
- delegate :type, :user_input_in_time_zone, :limit, to: :subtype
10
-
11
- def initialize(subtype, delimiter = ',')
12
- @subtype = subtype
13
- @delimiter = delimiter
14
-
15
- @pg_encoder = PG::TextEncoder::Array.new name: "#{type}[]", delimiter: delimiter
16
- @pg_decoder = PG::TextDecoder::Array.new name: "#{type}[]", delimiter: delimiter
17
- end
18
-
19
- def deserialize(value)
20
- if value.is_a?(::String)
21
- type_cast_array(@pg_decoder.decode(value), :deserialize)
22
- else
23
- super
24
- end
25
- end
26
-
27
- def cast(value)
28
- if value.is_a?(::String)
29
- value = @pg_decoder.decode(value)
30
- end
31
- type_cast_array(value, :cast)
32
- end
33
-
34
- def serialize(value)
35
- if value.is_a?(::Array)
36
- @pg_encoder.encode(type_cast_array(value, :serialize))
37
- else
38
- super
39
- end
40
- end
41
-
42
- def ==(other)
43
- other.is_a?(Array) &&
44
- subtype == other.subtype &&
45
- delimiter == other.delimiter
46
- end
47
-
48
- def type_cast_for_schema(value)
49
- return super unless value.is_a?(::Array)
50
- "[" + value.map { |v| subtype.type_cast_for_schema(v) }.join(", ") + "]"
51
- end
52
-
53
- def map(value, &block)
54
- value.map(&block)
55
- end
56
-
57
- private
58
-
59
- def type_cast_array(value, method)
60
- if value.is_a?(::Array)
61
- value.map { |item| type_cast_array(item, method) }
62
- else
63
- @subtype.public_send(method, value)
64
- end
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,52 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Bit < Type::Value # :nodoc:
6
- def type
7
- :bit
8
- end
9
-
10
- def cast(value)
11
- if ::String === value
12
- case value
13
- when /^0x/i
14
- value[2..-1].hex.to_s(2) # Hexadecimal notation
15
- else
16
- value # Bit-string notation
17
- end
18
- else
19
- value
20
- end
21
- end
22
-
23
- def serialize(value)
24
- Data.new(super) if value
25
- end
26
-
27
- class Data
28
- def initialize(value)
29
- @value = value
30
- end
31
-
32
- def to_s
33
- value
34
- end
35
-
36
- def binary?
37
- /\A[01]*\Z/ === value
38
- end
39
-
40
- def hex?
41
- /\A[0-9A-F]*\Z/i === value
42
- end
43
-
44
- protected
45
-
46
- attr_reader :value
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,13 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class BitVarying < OID::Bit # :nodoc:
6
- def type
7
- :bit_varying
8
- end
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Bytea < Type::Binary # :nodoc:
6
- def deserialize(value)
7
- return if value.nil?
8
- return value.to_s if value.is_a?(Type::Binary::Data)
9
- PGconn.unescape_bytea(super)
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end