surus 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ # 0.3.2 (March 10, 2012)
2
+
3
+ * No changes. Had to bump version to get around partially failed upload to RubyGems.org.
4
+
5
+ # 0.3.1 (March 10, 2012)
6
+
7
+ * Added generator for hstore migration (Tad Thorley)
8
+
1
9
  # 0.3.0 (February 16, 2012)
2
10
 
3
11
  * Can now round-trip any value YAML can dump and load as an hstore key or value
data/README.md CHANGED
@@ -3,9 +3,11 @@ Surus
3
3
 
4
4
  # Description
5
5
 
6
- Surus extends ActiveRecord with PostgreSQL specific functionality. It includes
7
- hstore and array serializers and helper scopes. It also includes a helper to
8
- control PostgreSQL synchronous commit behavior.
6
+ Surus accelerates ActiveRecord with PostgreSQL specific types and
7
+ functionality. It enables indexed searching of serialized arrays and hashes.
8
+ It also can control PostgreSQL synchronous commit behavior. By relaxing
9
+ PostgreSQL's durability guarantee, transaction commit rate can be increased by
10
+ 50% or more.
9
11
 
10
12
  # Installation
11
13
 
@@ -45,6 +47,11 @@ Hstores can be searched with helper scopes.
45
47
  User.hstore_has_all_keys(:properties, "favorite_color", "gender")
46
48
  User.hstore_has_any_keys(:properties, "favorite_color", "favorite_artist")
47
49
 
50
+ Hstore is a PostgreSQL extension. You can generate a migration to install it.
51
+
52
+ rails g surus:hstore:install
53
+ rake db:migrate
54
+
48
55
 
49
56
  Read more in the [PostgreSQL hstore documentation](http://www.postgresql.org/docs/9.1/static/hstore.html).
50
57
 
@@ -0,0 +1,25 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Surus
5
+ module Hstore
6
+ class InstallGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+ source_root File.expand_path("../templates", __FILE__)
9
+
10
+ def self.next_migration_number(dirname)
11
+ if ActiveRecord::Base.timestamped_migrations
12
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
13
+ else
14
+ "%.3d" % (current_migration_number(dirname) + 1)
15
+ end
16
+ end
17
+
18
+ desc "creates a migration to install the hstore module"
19
+ def install
20
+ migration_template 'install_hstore.rb', 'db/migrate/install_hstore.rb'
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,304 @@
1
+ class InstallHstore < ActiveRecord::Migration
2
+ def self.up
3
+ version = ActiveRecord::Base.connection.send(:postgresql_version)
4
+ # check for newer versions
5
+ if version >= 90100
6
+ sql = "CREATE EXTENSION hstore"
7
+ # use the hstore.sql file on the system, if found
8
+ elsif(path = hstore_sql_path)
9
+ sql = File.read(path)
10
+ # run a default hstore.sql
11
+ else
12
+ sql = default_sql
13
+ end
14
+
15
+ execute sql
16
+ end
17
+
18
+ def self.down
19
+ version = ActiveRecord::Base.connection.send(:postgresql_version)
20
+ execute "DROP EXTENSION hstore" if version >= 90100
21
+ end
22
+
23
+
24
+ private
25
+ def hstore_sql_path
26
+ pg_share_dir = (`pg_config --sharedir`).strip
27
+ file_path = File.join(pg_share_dir, "contrib/hstore.sql")
28
+ File.exists?(file_path) ? file_path : nil
29
+ rescue Errno::ENOENT # if `pg_config` fails
30
+ nil
31
+ end
32
+
33
+ def default_sql
34
+ hstore_sql = <<-HSTORE_SQL
35
+ /* $PostgreSQL: pgsql/contrib/hstore/hstore.sql.in,v 1.11 2009/06/11 18:30:03 tgl Exp $ */
36
+
37
+ -- Adjust this setting to control where the objects get created.
38
+ SET search_path = public;
39
+
40
+ CREATE TYPE hstore;
41
+
42
+ CREATE OR REPLACE FUNCTION hstore_in(cstring)
43
+ RETURNS hstore
44
+ AS '$libdir/hstore'
45
+ LANGUAGE C STRICT;
46
+
47
+ CREATE OR REPLACE FUNCTION hstore_out(hstore)
48
+ RETURNS cstring
49
+ AS '$libdir/hstore'
50
+ LANGUAGE C STRICT;
51
+
52
+ CREATE TYPE hstore (
53
+ INTERNALLENGTH = -1,
54
+ INPUT = hstore_in,
55
+ OUTPUT = hstore_out,
56
+ STORAGE = extended
57
+ );
58
+
59
+ CREATE OR REPLACE FUNCTION fetchval(hstore,text)
60
+ RETURNS text
61
+ AS '$libdir/hstore'
62
+ LANGUAGE C STRICT IMMUTABLE;
63
+
64
+ CREATE OPERATOR -> (
65
+ LEFTARG = hstore,
66
+ RIGHTARG = text,
67
+ PROCEDURE = fetchval
68
+ );
69
+
70
+ CREATE OR REPLACE FUNCTION isexists(hstore,text)
71
+ RETURNS bool
72
+ AS '$libdir/hstore','exists'
73
+ LANGUAGE C STRICT IMMUTABLE;
74
+
75
+ CREATE OR REPLACE FUNCTION exist(hstore,text)
76
+ RETURNS bool
77
+ AS '$libdir/hstore','exists'
78
+ LANGUAGE C STRICT IMMUTABLE;
79
+
80
+ CREATE OPERATOR ? (
81
+ LEFTARG = hstore,
82
+ RIGHTARG = text,
83
+ PROCEDURE = exist,
84
+ RESTRICT = contsel,
85
+ JOIN = contjoinsel
86
+ );
87
+
88
+ CREATE OR REPLACE FUNCTION isdefined(hstore,text)
89
+ RETURNS bool
90
+ AS '$libdir/hstore','defined'
91
+ LANGUAGE C STRICT IMMUTABLE;
92
+
93
+ CREATE OR REPLACE FUNCTION defined(hstore,text)
94
+ RETURNS bool
95
+ AS '$libdir/hstore','defined'
96
+ LANGUAGE C STRICT IMMUTABLE;
97
+
98
+ CREATE OR REPLACE FUNCTION delete(hstore,text)
99
+ RETURNS hstore
100
+ AS '$libdir/hstore','delete'
101
+ LANGUAGE C STRICT IMMUTABLE;
102
+
103
+ CREATE OR REPLACE FUNCTION hs_concat(hstore,hstore)
104
+ RETURNS hstore
105
+ AS '$libdir/hstore'
106
+ LANGUAGE C STRICT IMMUTABLE;
107
+
108
+ CREATE OPERATOR || (
109
+ LEFTARG = hstore,
110
+ RIGHTARG = hstore,
111
+ PROCEDURE = hs_concat
112
+ );
113
+
114
+ CREATE OR REPLACE FUNCTION hs_contains(hstore,hstore)
115
+ RETURNS bool
116
+ AS '$libdir/hstore'
117
+ LANGUAGE C STRICT IMMUTABLE;
118
+
119
+ CREATE OR REPLACE FUNCTION hs_contained(hstore,hstore)
120
+ RETURNS bool
121
+ AS '$libdir/hstore'
122
+ LANGUAGE C STRICT IMMUTABLE;
123
+
124
+ CREATE OPERATOR @> (
125
+ LEFTARG = hstore,
126
+ RIGHTARG = hstore,
127
+ PROCEDURE = hs_contains,
128
+ COMMUTATOR = '<@',
129
+ RESTRICT = contsel,
130
+ JOIN = contjoinsel
131
+ );
132
+
133
+ CREATE OPERATOR <@ (
134
+ LEFTARG = hstore,
135
+ RIGHTARG = hstore,
136
+ PROCEDURE = hs_contained,
137
+ COMMUTATOR = '@>',
138
+ RESTRICT = contsel,
139
+ JOIN = contjoinsel
140
+ );
141
+
142
+ -- obsolete:
143
+ CREATE OPERATOR @ (
144
+ LEFTARG = hstore,
145
+ RIGHTARG = hstore,
146
+ PROCEDURE = hs_contains,
147
+ COMMUTATOR = '~',
148
+ RESTRICT = contsel,
149
+ JOIN = contjoinsel
150
+ );
151
+
152
+ CREATE OPERATOR ~ (
153
+ LEFTARG = hstore,
154
+ RIGHTARG = hstore,
155
+ PROCEDURE = hs_contained,
156
+ COMMUTATOR = '@',
157
+ RESTRICT = contsel,
158
+ JOIN = contjoinsel
159
+ );
160
+
161
+ CREATE OR REPLACE FUNCTION tconvert(text,text)
162
+ RETURNS hstore
163
+ AS '$libdir/hstore'
164
+ LANGUAGE C IMMUTABLE; -- not STRICT
165
+
166
+ CREATE OPERATOR => (
167
+ LEFTARG = text,
168
+ RIGHTARG = text,
169
+ PROCEDURE = tconvert
170
+ );
171
+
172
+ CREATE OR REPLACE FUNCTION akeys(hstore)
173
+ RETURNS _text
174
+ AS '$libdir/hstore'
175
+ LANGUAGE C STRICT IMMUTABLE;
176
+
177
+ CREATE OR REPLACE FUNCTION avals(hstore)
178
+ RETURNS _text
179
+ AS '$libdir/hstore'
180
+ LANGUAGE C STRICT IMMUTABLE;
181
+
182
+ CREATE OR REPLACE FUNCTION skeys(hstore)
183
+ RETURNS setof text
184
+ AS '$libdir/hstore'
185
+ LANGUAGE C STRICT IMMUTABLE;
186
+
187
+ CREATE OR REPLACE FUNCTION svals(hstore)
188
+ RETURNS setof text
189
+ AS '$libdir/hstore'
190
+ LANGUAGE C STRICT IMMUTABLE;
191
+
192
+ CREATE OR REPLACE FUNCTION each(IN hs hstore,
193
+ OUT key text,
194
+ OUT value text)
195
+ RETURNS SETOF record
196
+ AS '$libdir/hstore'
197
+ LANGUAGE C STRICT IMMUTABLE;
198
+
199
+
200
+
201
+ -- define the GiST support methods
202
+
203
+ CREATE TYPE ghstore;
204
+
205
+ CREATE OR REPLACE FUNCTION ghstore_in(cstring)
206
+ RETURNS ghstore
207
+ AS '$libdir/hstore'
208
+ LANGUAGE C STRICT;
209
+
210
+ CREATE OR REPLACE FUNCTION ghstore_out(ghstore)
211
+ RETURNS cstring
212
+ AS '$libdir/hstore'
213
+ LANGUAGE C STRICT;
214
+
215
+ CREATE TYPE ghstore (
216
+ INTERNALLENGTH = -1,
217
+ INPUT = ghstore_in,
218
+ OUTPUT = ghstore_out
219
+ );
220
+
221
+ CREATE OR REPLACE FUNCTION ghstore_compress(internal)
222
+ RETURNS internal
223
+ AS '$libdir/hstore'
224
+ LANGUAGE C IMMUTABLE STRICT;
225
+
226
+ CREATE OR REPLACE FUNCTION ghstore_decompress(internal)
227
+ RETURNS internal
228
+ AS '$libdir/hstore'
229
+ LANGUAGE C IMMUTABLE STRICT;
230
+
231
+ CREATE OR REPLACE FUNCTION ghstore_penalty(internal,internal,internal)
232
+ RETURNS internal
233
+ AS '$libdir/hstore'
234
+ LANGUAGE C IMMUTABLE STRICT;
235
+
236
+ CREATE OR REPLACE FUNCTION ghstore_picksplit(internal, internal)
237
+ RETURNS internal
238
+ AS '$libdir/hstore'
239
+ LANGUAGE C IMMUTABLE STRICT;
240
+
241
+ CREATE OR REPLACE FUNCTION ghstore_union(internal, internal)
242
+ RETURNS internal
243
+ AS '$libdir/hstore'
244
+ LANGUAGE C IMMUTABLE STRICT;
245
+
246
+ CREATE OR REPLACE FUNCTION ghstore_same(internal, internal, internal)
247
+ RETURNS internal
248
+ AS '$libdir/hstore'
249
+ LANGUAGE C IMMUTABLE STRICT;
250
+
251
+ CREATE OR REPLACE FUNCTION ghstore_consistent(internal,internal,int,oid,internal)
252
+ RETURNS bool
253
+ AS '$libdir/hstore'
254
+ LANGUAGE C IMMUTABLE STRICT;
255
+
256
+ -- register the opclass for indexing (not as default)
257
+ CREATE OPERATOR CLASS gist_hstore_ops
258
+ DEFAULT FOR TYPE hstore USING gist
259
+ AS
260
+ OPERATOR 7 @> ,
261
+ OPERATOR 9 ?(hstore,text) ,
262
+ --OPERATOR 8 <@ ,
263
+ OPERATOR 13 @ ,
264
+ --OPERATOR 14 ~ ,
265
+ FUNCTION 1 ghstore_consistent (internal, internal, int, oid, internal),
266
+ FUNCTION 2 ghstore_union (internal, internal),
267
+ FUNCTION 3 ghstore_compress (internal),
268
+ FUNCTION 4 ghstore_decompress (internal),
269
+ FUNCTION 5 ghstore_penalty (internal, internal, internal),
270
+ FUNCTION 6 ghstore_picksplit (internal, internal),
271
+ FUNCTION 7 ghstore_same (internal, internal, internal),
272
+ STORAGE ghstore;
273
+
274
+ -- define the GIN support methods
275
+
276
+ CREATE OR REPLACE FUNCTION gin_extract_hstore(internal, internal)
277
+ RETURNS internal
278
+ AS '$libdir/hstore'
279
+ LANGUAGE C IMMUTABLE STRICT;
280
+
281
+ CREATE OR REPLACE FUNCTION gin_extract_hstore_query(internal, internal, int2, internal, internal)
282
+ RETURNS internal
283
+ AS '$libdir/hstore'
284
+ LANGUAGE C IMMUTABLE STRICT;
285
+
286
+ CREATE OR REPLACE FUNCTION gin_consistent_hstore(internal, int2, internal, int4, internal, internal)
287
+ RETURNS bool
288
+ AS '$libdir/hstore'
289
+ LANGUAGE C IMMUTABLE STRICT;
290
+
291
+ CREATE OPERATOR CLASS gin_hstore_ops
292
+ DEFAULT FOR TYPE hstore USING gin
293
+ AS
294
+ OPERATOR 7 @> ,
295
+ OPERATOR 9 ?(hstore,text),
296
+ FUNCTION 1 bttextcmp(text,text),
297
+ FUNCTION 2 gin_extract_hstore(internal, internal),
298
+ FUNCTION 3 gin_extract_hstore_query(internal, internal, int2, internal, internal),
299
+ FUNCTION 4 gin_consistent_hstore(internal, int2, internal, int4, internal, internal),
300
+ STORAGE text;
301
+ HSTORE_SQL
302
+
303
+ end
304
+ end
@@ -1,3 +1,3 @@
1
1
  module Surus
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -8,8 +8,12 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Jack Christensen"]
9
9
  s.email = ["jack@jackchristensen.com"]
10
10
  s.homepage = "https://github.com/JackC/surus"
11
- s.summary = %q{PostgreSQL extensions for ActiveRecord}
12
- s.description = %q{Includes serializers and search scopes for hstore and array. Also includes control over synchronous_commit to boost insert and update speed.}
11
+ s.summary = %q{PostgreSQL Acceleration for ActiveRecord}
12
+ s.description = %q{Surus accelerates ActiveRecord with PostgreSQL specific types and
13
+ functionality. It enables indexed searching of serialized arrays and hashes.
14
+ It also can control PostgreSQL synchronous commit behavior. By relaxing
15
+ PostgreSQL's durability guarantee, transaction commit rate can be increased by
16
+ 50% or more. }
13
17
 
14
18
  s.rubyforge_project = ""
15
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: surus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-16 00:00:00.000000000 Z
12
+ date: 2012-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg
16
- requirement: &11662280 !ruby/object:Gem::Requirement
16
+ requirement: &9002920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *11662280
24
+ version_requirements: *9002920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &11661280 !ruby/object:Gem::Requirement
27
+ requirement: &9002400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *11661280
35
+ version_requirements: *9002400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &11660340 !ruby/object:Gem::Requirement
38
+ requirement: &9018280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.8.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *11660340
46
+ version_requirements: *9018280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard
49
- requirement: &11659560 !ruby/object:Gem::Requirement
49
+ requirement: &9017820 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.10.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *11659560
57
+ version_requirements: *9017820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-rspec
60
- requirement: &11624780 !ruby/object:Gem::Requirement
60
+ requirement: &9017360 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,9 +65,12 @@ dependencies:
65
65
  version: 0.6.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *11624780
69
- description: Includes serializers and search scopes for hstore and array. Also includes
70
- control over synchronous_commit to boost insert and update speed.
68
+ version_requirements: *9017360
69
+ description: ! "Surus accelerates ActiveRecord with PostgreSQL specific types and\n
70
+ \ functionality. It enables indexed searching of serialized arrays
71
+ and hashes.\n It also can control PostgreSQL synchronous commit
72
+ behavior. By relaxing\n PostgreSQL's durability guarantee, transaction
73
+ commit rate can be increased by\n 50% or more. "
71
74
  email:
72
75
  - jack@jackchristensen.com
73
76
  executables: []
@@ -92,6 +95,8 @@ files:
92
95
  - bench/hstore_find.rb
93
96
  - bench/hstore_serialize.rb
94
97
  - bench/synchronous_commit.rb
98
+ - lib/generators/surus/hstore/install_generator.rb
99
+ - lib/generators/surus/hstore/templates/install_hstore.rb
95
100
  - lib/surus.rb
96
101
  - lib/surus/array/decimal_serializer.rb
97
102
  - lib/surus/array/float_serializer.rb
@@ -136,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
141
  version: '0'
137
142
  requirements: []
138
143
  rubyforge_project: ''
139
- rubygems_version: 1.8.11
144
+ rubygems_version: 1.8.17
140
145
  signing_key:
141
146
  specification_version: 3
142
- summary: PostgreSQL extensions for ActiveRecord
147
+ summary: PostgreSQL Acceleration for ActiveRecord
143
148
  test_files: []