pglite 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/pglite/connection.rb +50 -2
- data/lib/pglite/pg.rb +5 -0
- data/lib/pglite/result.rb +7 -0
- data/lib/pglite/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 609fd58663c3fe74ac615524bf32871d8f50d71eda095d4845cdaa54c7320d5d
|
|
4
|
+
data.tar.gz: 44bd42c1c7e83ba12ca9474b2ac45e0ba43e1530a3cdb6bdd8004bbdaa5288a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65a0e5e17832735317ebf54cc1c7bb93b815dff2bb9b8efc534c3cf281c139012ce1e43c2b152d49d5f1e12c2f191218023433583905c2ce8408c2bc06d424d0
|
|
7
|
+
data.tar.gz: b0365fdee8d300d6bc9c4446feb32a4ed70e66b4466ee56c1ac95773647406af899b9492ddc99ddfe3e6ef7446dcd46b8bd62693e9f649140648a16a2c4e61cc
|
data/CHANGELOG.md
CHANGED
data/lib/pglite/connection.rb
CHANGED
|
@@ -10,6 +10,7 @@ module PGlite
|
|
|
10
10
|
def initialize(conn_params = {})
|
|
11
11
|
@mount_path = conn_params[:mount_path] || File.join(Dir.pwd, "tmp", "pglite")
|
|
12
12
|
@prepared_statements_map = {}
|
|
13
|
+
@closed = false
|
|
13
14
|
PGlite.install!(mount_path)
|
|
14
15
|
rescue => e
|
|
15
16
|
raise PG::Error, e.message
|
|
@@ -19,13 +20,18 @@ module PGlite
|
|
|
19
20
|
# make no-op for now
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
def finished? =
|
|
23
|
+
def finished? = @closed
|
|
23
24
|
|
|
24
25
|
def transaction_status
|
|
25
26
|
PG::PQTRANS_IDLE
|
|
26
27
|
end
|
|
27
28
|
|
|
28
|
-
def parameter_status(
|
|
29
|
+
def parameter_status(name)
|
|
30
|
+
# Rails can query for the current time zone
|
|
31
|
+
return "UTC" if name.to_s.casecmp?("timezone")
|
|
32
|
+
|
|
33
|
+
nil
|
|
34
|
+
end
|
|
29
35
|
|
|
30
36
|
def escape(str) = str
|
|
31
37
|
|
|
@@ -67,6 +73,41 @@ module PGlite
|
|
|
67
73
|
@prepared_statements_map[name] = sql
|
|
68
74
|
end
|
|
69
75
|
|
|
76
|
+
# ==== Async interface for Active Record 8.2+ ===
|
|
77
|
+
def send_query(sql)
|
|
78
|
+
@pending_result = raw_query(sql, [])
|
|
79
|
+
nil
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def send_query_params(sql, params)
|
|
83
|
+
@pending_result = raw_query(sql, params)
|
|
84
|
+
nil
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def send_query_prepared(name, params)
|
|
88
|
+
@pending_result = exec_prepared(name, params)
|
|
89
|
+
nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def send_prepare(name, sql, param_types = nil)
|
|
93
|
+
prepare(name, sql, param_types)
|
|
94
|
+
@pending_result = nil
|
|
95
|
+
nil
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def get_result
|
|
99
|
+
result, @pending_result = @pending_result, nil
|
|
100
|
+
result
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def discard_results
|
|
104
|
+
@pending_result = nil
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def set_notice_receiver(&block)
|
|
108
|
+
nil
|
|
109
|
+
end
|
|
110
|
+
|
|
70
111
|
def get_last_result
|
|
71
112
|
@last_result
|
|
72
113
|
end
|
|
@@ -82,5 +123,12 @@ module PGlite
|
|
|
82
123
|
_1[1].to_i * 10_000 + _1[2].to_i
|
|
83
124
|
end
|
|
84
125
|
end
|
|
126
|
+
|
|
127
|
+
def close
|
|
128
|
+
@closed = true
|
|
129
|
+
nil
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def status = PG::CONNECTION_OK
|
|
85
133
|
end
|
|
86
134
|
end
|
data/lib/pglite/pg.rb
CHANGED
|
@@ -13,6 +13,11 @@ module PG
|
|
|
13
13
|
PQTRANS_INTRANS = 2 # (idle, within transaction block)
|
|
14
14
|
PQTRANS_INERROR = 3 # (idle, within failed transaction)
|
|
15
15
|
PQTRANS_UNKNOWN = 4 # (cannot determine status)
|
|
16
|
+
CONNECTION_OK = 0
|
|
17
|
+
|
|
18
|
+
PGRES_COMMAND_OK = 1 # (successful completion of a command returning no data)
|
|
19
|
+
PGRES_TUPLES_OK = 2 # (successful completion of a command returning data)
|
|
20
|
+
PGRES_FATAL_ERROR = 7 # (a fatal error occurred)
|
|
16
21
|
|
|
17
22
|
class Error < StandardError; end
|
|
18
23
|
class ConnectionBad < Error; end
|
data/lib/pglite/result.rb
CHANGED
|
@@ -25,6 +25,13 @@ module PGlite
|
|
|
25
25
|
|
|
26
26
|
def ntuples = res.row_count
|
|
27
27
|
|
|
28
|
+
# Rails' get_result loop compares against PG::PGRES_FATAL_ERROR; pglite
|
|
29
|
+
# raises PG::Error at query time, so any result reaching here is non-fatal.
|
|
30
|
+
def result_status = PG::PGRES_TUPLES_OK
|
|
31
|
+
|
|
32
|
+
# Rails calls result.check to raise on server errors; already handled upstream.
|
|
33
|
+
def check = self
|
|
34
|
+
|
|
28
35
|
def clear
|
|
29
36
|
end
|
|
30
37
|
|
data/lib/pglite/version.rb
CHANGED