jeremyevans-postgres-pr 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/postgres-pr/message.rb +3 -2
- data/lib/postgres-pr/version.rb +1 -1
- metadata +5 -7
- data/examples/client.rb +0 -34
- data/examples/og/test.rb +0 -50
- data/examples/server.rb +0 -12
- data/examples/test_connection.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e89ed8c39cf13736bfcdeaae252cc6ad3487bac0493ffb8d874346d16bc34980
|
4
|
+
data.tar.gz: d1d176aee597030bdf5c75c728b11afd443c1a88f91316820646099547549aed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eadccd63ee985186ae92055d8cff6cc0f977d43ea4135dde647d47f68b24841dec8adfdba73e8eef265efe0cff0414c038079e696002bbc7cb214db3e5f38bb
|
7
|
+
data.tar.gz: 397812627a82de80f6c97ef5211ecaca2ca7c2693377b15bd64e3e7165cfed05ed05e8ae5a54cebc160608428216a55c9cd84de9a24c28dea46cef22479f91ac
|
data/lib/postgres-pr/message.rb
CHANGED
@@ -491,12 +491,13 @@ class StartupMessage < Message
|
|
491
491
|
fields :proto_version, :params
|
492
492
|
|
493
493
|
def dump
|
494
|
-
|
494
|
+
params = @params.reject{|k,v| v.nil?}
|
495
|
+
sz = params.inject(4 + 4) {|sum, kv| sum + kv[0].size + 1 + kv[1].size + 1} + 1
|
495
496
|
|
496
497
|
buffer = Buffer.of_size(sz)
|
497
498
|
buffer.write_int32_network(sz)
|
498
499
|
buffer.write_int32_network(@proto_version)
|
499
|
-
|
500
|
+
params.each_pair {|key, value|
|
500
501
|
buffer.write_cstring(key)
|
501
502
|
buffer.write_cstring(value)
|
502
503
|
}
|
data/lib/postgres-pr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jeremyevans-postgres-pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
|
+
- Michael Neumann
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2018-
|
12
|
+
date: 2018-08-01 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description:
|
14
15
|
email: code@jeremyevans.net
|
@@ -16,10 +17,6 @@ executables: []
|
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
19
|
-
- examples/client.rb
|
20
|
-
- examples/og/test.rb
|
21
|
-
- examples/server.rb
|
22
|
-
- examples/test_connection.rb
|
23
20
|
- lib/binary_reader.rb
|
24
21
|
- lib/binary_writer.rb
|
25
22
|
- lib/buffer.rb
|
@@ -35,7 +32,8 @@ files:
|
|
35
32
|
- lib/postgres.rb
|
36
33
|
- test/TC_message.rb
|
37
34
|
homepage: https://github.com/jeremyevans/postgres-pr
|
38
|
-
licenses:
|
35
|
+
licenses:
|
36
|
+
- Ruby
|
39
37
|
metadata: {}
|
40
38
|
post_install_message:
|
41
39
|
rdoc_options: []
|
data/examples/client.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift "../lib"
|
2
|
-
require 'postgres-pr/message'
|
3
|
-
require 'socket'
|
4
|
-
include PostgresPR
|
5
|
-
|
6
|
-
s = UNIXSocket.new(ARGV.shift || "/tmp/.s.PGSQL.5432")
|
7
|
-
|
8
|
-
msg = StartupMessage.new(196608, "user" => "mneumann", "database" => "mneumann")
|
9
|
-
s << msg.dump
|
10
|
-
|
11
|
-
Thread.start(s) { |s|
|
12
|
-
sleep 2
|
13
|
-
s << Query.new("drop table test").dump
|
14
|
-
s << Query.new("create table test (i int, v varchar(100))").dump
|
15
|
-
s << Parse.new("insert into test (i, v) values ($1, $2)", "blah").dump
|
16
|
-
s << Query.new("EXECUTE blah(1, 'hallo')").dump
|
17
|
-
|
18
|
-
while not (line = gets.chomp).empty?
|
19
|
-
s << Query.new(line).dump
|
20
|
-
end
|
21
|
-
exit
|
22
|
-
}
|
23
|
-
|
24
|
-
loop do
|
25
|
-
msg = Message.read(s)
|
26
|
-
p msg
|
27
|
-
|
28
|
-
case msg
|
29
|
-
when AuthentificationOk
|
30
|
-
p "OK"
|
31
|
-
when ErrorResponse
|
32
|
-
p "FAILED"
|
33
|
-
end
|
34
|
-
end
|
data/examples/og/test.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift '../../lib'
|
2
|
-
require 'rubygems'
|
3
|
-
require 'og'
|
4
|
-
require 'glue/logger'
|
5
|
-
|
6
|
-
$DBG = true
|
7
|
-
|
8
|
-
class User
|
9
|
-
end
|
10
|
-
|
11
|
-
class Comment
|
12
|
-
prop_accessor :body, String
|
13
|
-
belongs_to :user, User
|
14
|
-
end
|
15
|
-
|
16
|
-
class User
|
17
|
-
prop_accessor :name, String
|
18
|
-
has_many :comments, Comment
|
19
|
-
end
|
20
|
-
|
21
|
-
if __FILE__ == $0
|
22
|
-
config = {
|
23
|
-
:address => "localhost",
|
24
|
-
:database => "mneumann",
|
25
|
-
:backend => "psql",
|
26
|
-
:user => "mneumann",
|
27
|
-
:password => "",
|
28
|
-
:connection_count => 1
|
29
|
-
}
|
30
|
-
$log = Logger.new(STDERR)
|
31
|
-
$og = Og::Database.new(config)
|
32
|
-
|
33
|
-
$og.get_connection
|
34
|
-
|
35
|
-
u1 = User.new
|
36
|
-
u1.name = "Michael Neumann"
|
37
|
-
u1.save!
|
38
|
-
|
39
|
-
u2 = User.new
|
40
|
-
u2.name = "John User"
|
41
|
-
u2.save!
|
42
|
-
|
43
|
-
c1 = Comment.new
|
44
|
-
c1.body = "og test"
|
45
|
-
c1.user = u1
|
46
|
-
c1.save!
|
47
|
-
|
48
|
-
p User.all
|
49
|
-
p Comment.all
|
50
|
-
end
|
data/examples/server.rb
DELETED
data/examples/test_connection.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift '../lib'
|
2
|
-
require 'postgres-pr/connection'
|
3
|
-
|
4
|
-
conn = PostgresPR::Connection.new('mneumann', 'mneumann', nil, 'unix:/var/run/postgresql/.s.PGSQL.5432')
|
5
|
-
p conn.query("DROP TABLE test") rescue nil
|
6
|
-
p conn.query("CREATE TABLE test (a VARCHAR(100))")
|
7
|
-
p conn.query("INSERT INTO test VALUES ('hallo')")
|
8
|
-
p conn.query("INSERT INTO test VALUES ('leute')")
|
9
|
-
conn.query("COMMIT")
|
10
|
-
|
11
|
-
conn.query("BEGIN")
|
12
|
-
10000.times do |i|
|
13
|
-
p i
|
14
|
-
conn.query("INSERT INTO test VALUES ('#{i}')")
|
15
|
-
end
|
16
|
-
conn.query("COMMIT")
|
17
|
-
|
18
|
-
p conn.query("SELECT * FROM test")
|