pg 0.18.0.pre20141117110243 → 0.18.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ChangeLog +100 -15
- data/History.rdoc +2 -1
- data/Manifest.txt +3 -1
- data/Rakefile +17 -0
- data/ext/pg.c +2 -1
- data/ext/pg.h +1 -0
- data/ext/pg_binary_decoder.c +1 -1
- data/ext/pg_binary_encoder.c +1 -1
- data/ext/pg_connection.c +5 -5
- data/ext/pg_copy_coder.c +24 -4
- data/ext/pg_result.c +1 -1
- data/ext/pg_text_decoder.c +3 -5
- data/ext/pg_text_encoder.c +28 -39
- data/ext/pg_type_map.c +1 -26
- data/ext/pg_type_map_all_strings.c +2 -2
- data/ext/pg_type_map_by_class.c +1 -1
- data/ext/pg_type_map_by_column.c +1 -1
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +8 -26
- data/ext/pg_type_map_in_ruby.c +302 -0
- data/ext/util.c +1 -1
- data/lib/pg.rb +2 -2
- data/lib/pg/basic_type_mapping.rb +25 -3
- data/lib/pg/connection.rb +1 -1
- data/sample/disk_usage_report.rb +1 -1
- data/sample/pg_statistics.rb +1 -1
- data/sample/replication_monitor.rb +1 -1
- data/spec/pg/basic_type_mapping_spec.rb +3 -3
- data/spec/pg/type_map_by_class_spec.rb +1 -1
- data/spec/pg/type_map_by_oid_spec.rb +1 -6
- data/spec/pg/type_map_in_ruby_spec.rb +164 -0
- data/spec/pg/type_map_spec.rb +0 -17
- data/spec/pg/type_spec.rb +5 -9
- metadata +27 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e975ac4cb7b86a878bbc8d5a92a106c2096e4edb
|
|
4
|
+
data.tar.gz: 9a4406e5063886d701248da53c759704b7c9f474
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 642968ad5ff9e3b9cae890b553c78c8ca8bd068fa9398e4248b3dc3e93553fed92e21ee73dda6cae477a2531b129c87b45d41af61630b002b4d55c829bac493d
|
|
7
|
+
data.tar.gz: 379f3e798b2d974d115478bbb5cf1f2bc067f1361150055a107054332de4d0238de6f0027ee0071b378cb738835a22e4d6c44f92da4d7f00f8f5cfd28fc31850
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/ChangeLog
CHANGED
|
@@ -1,8 +1,93 @@
|
|
|
1
|
+
2014-12-26 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
2
|
+
|
|
3
|
+
* lib/pg/basic_type_mapping.rb:
|
|
4
|
+
Add a warning about Type OIDs without decoder in
|
|
5
|
+
PG::BasicTypeMapForResults.
|
|
6
|
+
[592e29cdf2e9] [tip]
|
|
7
|
+
|
|
8
|
+
2014-12-13 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
9
|
+
|
|
10
|
+
* ext/pg_type_map_in_ruby.c:
|
|
11
|
+
Fix TypeMapInRuby for Rubinius.
|
|
12
|
+
[a38cf53a96f1]
|
|
13
|
+
|
|
14
|
+
2014-12-12 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
15
|
+
|
|
16
|
+
* ext/pg_type_map_all_strings.c:
|
|
17
|
+
Fix documentation to TypeMapAllStrings.
|
|
18
|
+
[c53f993a4254]
|
|
19
|
+
|
|
20
|
+
* Manifest.txt, ext/pg.c, ext/pg.h, ext/pg_type_map_in_ruby.c,
|
|
21
|
+
spec/pg/type_map_in_ruby_spec.rb:
|
|
22
|
+
Add TypeMapInRuby as a way to combine fast but static C-based type
|
|
23
|
+
maps with flexible ruby based type maps.
|
|
24
|
+
[a9724aef9116]
|
|
25
|
+
|
|
26
|
+
* ext/pg_type_map.c, ext/pg_type_map_by_oid.c,
|
|
27
|
+
lib/pg/basic_type_mapping.rb, spec/pg/basic_type_mapping_spec.rb,
|
|
28
|
+
spec/pg/type_map_by_oid_spec.rb, spec/pg/type_map_spec.rb:
|
|
29
|
+
Remove TypeMap#fit_to_result and #fit_to_query.
|
|
30
|
+
|
|
31
|
+
The only use case so far is building a TypeMapByColumn out of a
|
|
32
|
+
TypeMapByOid, which is now named more explicitly as
|
|
33
|
+
#build_column_map .
|
|
34
|
+
[c99d26015e3c]
|
|
35
|
+
|
|
36
|
+
* ext/pg_text_encoder.c:
|
|
37
|
+
Remove unused variable.
|
|
38
|
+
[1a13e7eafeb7]
|
|
39
|
+
|
|
40
|
+
* ext/pg_connection.c, ext/pg_copy_coder.c, lib/pg/connection.rb:
|
|
41
|
+
Several documentation fixes to COPY coders.
|
|
42
|
+
[a7befacdef4e]
|
|
43
|
+
|
|
44
|
+
2014-11-26 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
45
|
+
|
|
46
|
+
* ext/pg_text_encoder.c, spec/pg/type_spec.rb:
|
|
47
|
+
PG::TextDecoder::Boolean: encode only true, false, 0 and 1 and pass
|
|
48
|
+
all other values as strings to the server.
|
|
49
|
+
[6b86a5543567]
|
|
50
|
+
|
|
51
|
+
2014-11-24 Lars Kanis <kanis@comcard.de>
|
|
52
|
+
|
|
53
|
+
* spec/pg/type_map_by_class_spec.rb:
|
|
54
|
+
Fix test case for rbx. The error message is somewhat different than
|
|
55
|
+
in MRI.
|
|
56
|
+
[99638547f8b4]
|
|
57
|
+
|
|
58
|
+
2014-11-21 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
59
|
+
|
|
60
|
+
* ext/pg_text_decoder.c:
|
|
61
|
+
Stack memory can be used for Identifier decoding, since they are
|
|
62
|
+
limited in size.
|
|
63
|
+
[b7f9daeeba29]
|
|
64
|
+
|
|
65
|
+
2014-11-17 Lars Kanis <kanis@comcard.de>
|
|
66
|
+
|
|
67
|
+
* .travis.yml:
|
|
68
|
+
Revert "Remove Rubinius from the allowed failure list - failing
|
|
69
|
+
specs are now marked as pending."
|
|
70
|
+
|
|
71
|
+
This reverts commit 524c84ccd17f3caeed13a16084206f14225bbdd6 because
|
|
72
|
+
of ongoing issues with gem installation on rbx.
|
|
73
|
+
[b8debfea4331]
|
|
74
|
+
|
|
75
|
+
* ext/pg.h, ext/pg_errors.c, ext/pg_result.c, spec/pg/result_spec.rb:
|
|
76
|
+
Use dedicated error classes for stream exceptions.
|
|
77
|
+
[f23dd01bcb52]
|
|
78
|
+
|
|
79
|
+
* History.rdoc, ext/pg.c, spec/pg_spec.rb:
|
|
80
|
+
Add PG.init_openssl and PG.init_ssl methods.
|
|
81
|
+
|
|
82
|
+
This will hopefully help to solve issue #190:
|
|
83
|
+
https://bitbucket.org/ged/ruby-pg/issue/190
|
|
84
|
+
[45610159a246]
|
|
85
|
+
|
|
1
86
|
2014-11-10 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
2
87
|
|
|
3
88
|
* ext/pg_type_map_by_class.c:
|
|
4
89
|
Fix typo.
|
|
5
|
-
[eeb8a82c5328]
|
|
90
|
+
[eeb8a82c5328]
|
|
6
91
|
|
|
7
92
|
* spec/pg/type_map_by_class_spec.rb:
|
|
8
93
|
TypeMapByClass: Add test for invlid coder object.
|
|
@@ -200,7 +285,7 @@
|
|
|
200
285
|
|
|
201
286
|
* ext/pg_text_encoder.c, spec/pg/type_spec.rb:
|
|
202
287
|
Allow non Array values as input for TextEncoder::Array.
|
|
203
|
-
[a4725dfca9e4]
|
|
288
|
+
[a4725dfca9e4] [github/master]
|
|
204
289
|
|
|
205
290
|
* ext/pg_coder.c, spec/pg/type_spec.rb:
|
|
206
291
|
Clarify handling of nil/NULL values by PG::Coders.
|
|
@@ -1655,12 +1740,6 @@
|
|
|
1655
1740
|
Merged with 4cc778c5ead7
|
|
1656
1741
|
[67bb0f34ca05]
|
|
1657
1742
|
|
|
1658
|
-
2014-08-20 Michael Granger <ged@FaerieMUD.org>
|
|
1659
|
-
|
|
1660
|
-
* spec/helpers.rb, spec/pg/connection_spec.rb:
|
|
1661
|
-
Check connection status with a matcher in specs
|
|
1662
|
-
[b32840b98e4b]
|
|
1663
|
-
|
|
1664
1743
|
2014-10-09 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
1665
1744
|
|
|
1666
1745
|
* Rakefile, Rakefile.cross, ext/extconf.rb:
|
|
@@ -1736,6 +1815,10 @@
|
|
|
1736
1815
|
|
|
1737
1816
|
2014-08-20 Michael Granger <ged@FaerieMUD.org>
|
|
1738
1817
|
|
|
1818
|
+
* spec/helpers.rb, spec/pg/connection_spec.rb:
|
|
1819
|
+
Check connection status with a matcher in specs
|
|
1820
|
+
[b32840b98e4b]
|
|
1821
|
+
|
|
1739
1822
|
* ext/pg_connection.c, lib/pg/connection.rb,
|
|
1740
1823
|
spec/pg/connection_spec.rb:
|
|
1741
1824
|
Implement PG::Connection#conninfo and use it to test #188
|
|
@@ -1760,17 +1843,19 @@
|
|
|
1760
1843
|
* Merge with 6c2444dc63e1
|
|
1761
1844
|
[d7160a9fb5dc]
|
|
1762
1845
|
|
|
1763
|
-
* .rvm.gems, Rakefile, spec/helpers.rb, spec/lib/helpers.rb,
|
|
1764
|
-
spec/pg/connection_spec.rb, spec/pg/result_spec.rb, spec/pg_spec.rb:
|
|
1765
|
-
Convert specs to expect syntax for RSpec 3
|
|
1766
|
-
[c9108c846ab2]
|
|
1767
|
-
|
|
1768
1846
|
2013-12-30 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
1769
1847
|
|
|
1770
1848
|
* ext/pg_connection.c:
|
|
1771
1849
|
Fix typo in documentation.
|
|
1772
1850
|
[6c2444dc63e1]
|
|
1773
1851
|
|
|
1852
|
+
2014-06-05 Michael Granger <ged@FaerieMUD.org>
|
|
1853
|
+
|
|
1854
|
+
* .rvm.gems, Rakefile, spec/helpers.rb, spec/lib/helpers.rb,
|
|
1855
|
+
spec/pg/connection_spec.rb, spec/pg/result_spec.rb, spec/pg_spec.rb:
|
|
1856
|
+
Convert specs to expect syntax for RSpec 3
|
|
1857
|
+
[c9108c846ab2]
|
|
1858
|
+
|
|
1774
1859
|
2013-12-18 Michael Granger <ged@FaerieMUD.org>
|
|
1775
1860
|
|
|
1776
1861
|
* .hgtags:
|
|
@@ -2505,13 +2590,13 @@
|
|
|
2505
2590
|
PQexecParams() itself.
|
|
2506
2591
|
|
|
2507
2592
|
Thanks to Aaron Patterson for the idea.
|
|
2508
|
-
[7c313c2355b7]
|
|
2593
|
+
[7c313c2355b7] [github/exec_params]
|
|
2509
2594
|
|
|
2510
2595
|
2013-01-31 Michael Granger <ged@FaerieMUD.org>
|
|
2511
2596
|
|
|
2512
2597
|
* ext/extconf.rb:
|
|
2513
2598
|
Add experimental -rpath to the LDFLAGS
|
|
2514
|
-
[8496c624dffd]
|
|
2599
|
+
[8496c624dffd] [github/rpath_ldflag]
|
|
2515
2600
|
|
|
2516
2601
|
2013-01-30 Michael Granger <ged@FaerieMUD.org>
|
|
2517
2602
|
|
data/History.rdoc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
== v0.18.0 [
|
|
1
|
+
== v0.18.0 [2015-01-01] Michael Granger <ged@FaerieMUD.org>
|
|
2
2
|
|
|
3
3
|
Bugfixes:
|
|
4
4
|
- Fix OID to Integer mapping (it is unsigned now). #187
|
|
@@ -19,6 +19,7 @@ Enhancements:
|
|
|
19
19
|
- Update Windows cross build to PostgreSQL 9.3.
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
|
|
22
23
|
== v0.17.1 [2013-12-18] Michael Granger <ged@FaerieMUD.org>
|
|
23
24
|
|
|
24
25
|
Bugfixes:
|
data/Manifest.txt
CHANGED
|
@@ -29,12 +29,13 @@ ext/pg_errors.c
|
|
|
29
29
|
ext/pg_result.c
|
|
30
30
|
ext/pg_text_decoder.c
|
|
31
31
|
ext/pg_text_encoder.c
|
|
32
|
+
ext/pg_type_map.c
|
|
32
33
|
ext/pg_type_map_all_strings.c
|
|
33
34
|
ext/pg_type_map_by_class.c
|
|
34
35
|
ext/pg_type_map_by_column.c
|
|
35
36
|
ext/pg_type_map_by_mri_type.c
|
|
36
37
|
ext/pg_type_map_by_oid.c
|
|
37
|
-
ext/
|
|
38
|
+
ext/pg_type_map_in_ruby.c
|
|
38
39
|
ext/util.c
|
|
39
40
|
ext/util.h
|
|
40
41
|
ext/vc/pg.sln
|
|
@@ -78,6 +79,7 @@ spec/pg/type_map_by_class_spec.rb
|
|
|
78
79
|
spec/pg/type_map_by_column_spec.rb
|
|
79
80
|
spec/pg/type_map_by_mri_type_spec.rb
|
|
80
81
|
spec/pg/type_map_by_oid_spec.rb
|
|
82
|
+
spec/pg/type_map_in_ruby_spec.rb
|
|
81
83
|
spec/pg/type_map_spec.rb
|
|
82
84
|
spec/pg/type_spec.rb
|
|
83
85
|
spec/pg_spec.rb
|
data/Rakefile
CHANGED
|
@@ -29,6 +29,8 @@ TMPDIR = BASEDIR + 'tmp'
|
|
|
29
29
|
DLEXT = RbConfig::CONFIG['DLEXT']
|
|
30
30
|
EXT = LIBDIR + "pg_ext.#{DLEXT}"
|
|
31
31
|
|
|
32
|
+
GEMSPEC = 'pg.gemspec'
|
|
33
|
+
|
|
32
34
|
TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
|
|
33
35
|
|
|
34
36
|
CLOBBER.include( TEST_DIRECTORY.to_s )
|
|
@@ -187,3 +189,18 @@ file 'ext/pg_errors.c' => ['ext/errorcodes.def'] do
|
|
|
187
189
|
# trigger compilation of changed errorcodes.def
|
|
188
190
|
touch 'ext/pg_errors.c'
|
|
189
191
|
end
|
|
192
|
+
|
|
193
|
+
task :gemspec => GEMSPEC
|
|
194
|
+
file GEMSPEC => __FILE__
|
|
195
|
+
task GEMSPEC do |task|
|
|
196
|
+
spec = $hoespec.spec
|
|
197
|
+
spec.files.delete( '.gemtest' )
|
|
198
|
+
spec.version = "#{spec.version}.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
|
|
199
|
+
File.open( task.name, 'w' ) do |fh|
|
|
200
|
+
fh.write( spec.to_ruby )
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
CLOBBER.include( GEMSPEC.to_s )
|
|
205
|
+
task :default => :gemspec
|
|
206
|
+
|
data/ext/pg.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* pg.c - Toplevel extension
|
|
3
|
-
* $Id$
|
|
3
|
+
* $Id: pg.c,v a9724aef9116 2014/12/12 21:03:27 lars $
|
|
4
4
|
*
|
|
5
5
|
* Author/s:
|
|
6
6
|
*
|
|
@@ -655,6 +655,7 @@ Init_pg_ext()
|
|
|
655
655
|
init_pg_type_map_by_column();
|
|
656
656
|
init_pg_type_map_by_mri_type();
|
|
657
657
|
init_pg_type_map_by_oid();
|
|
658
|
+
init_pg_type_map_in_ruby();
|
|
658
659
|
init_pg_coder();
|
|
659
660
|
init_pg_text_encoder();
|
|
660
661
|
init_pg_text_decoder();
|
data/ext/pg.h
CHANGED
|
@@ -302,6 +302,7 @@ void init_pg_type_map_by_class _(( void ));
|
|
|
302
302
|
void init_pg_type_map_by_column _(( void ));
|
|
303
303
|
void init_pg_type_map_by_mri_type _(( void ));
|
|
304
304
|
void init_pg_type_map_by_oid _(( void ));
|
|
305
|
+
void init_pg_type_map_in_ruby _(( void ));
|
|
305
306
|
void init_pg_coder _(( void ));
|
|
306
307
|
void init_pg_copycoder _(( void ));
|
|
307
308
|
void init_pg_text_encoder _(( void ));
|
data/ext/pg_binary_decoder.c
CHANGED
data/ext/pg_binary_encoder.c
CHANGED
data/ext/pg_connection.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* pg_connection.c - PG::Connection class extension
|
|
3
|
-
* $Id$
|
|
3
|
+
* $Id: pg_connection.c,v a7befacdef4e 2014/12/12 20:57:14 lars $
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -2542,10 +2542,10 @@ pgconn_wait_for_notify(int argc, VALUE *argv, VALUE self)
|
|
|
2542
2542
|
* not sent (false is only possible if the connection
|
|
2543
2543
|
* is in nonblocking mode, and this command would block).
|
|
2544
2544
|
*
|
|
2545
|
-
* encoder can be a PG::Coder derivation (typically PG::
|
|
2545
|
+
* encoder can be a PG::Coder derivation (typically PG::TextEncoder::CopyRow).
|
|
2546
2546
|
* This encodes the received data fields from an Array of Strings. Optionally
|
|
2547
2547
|
* the encoder can type cast the fields form various Ruby types in one step,
|
|
2548
|
-
* if PG::
|
|
2548
|
+
* if PG::TextEncoder::CopyRow#type_map is set accordingly.
|
|
2549
2549
|
*
|
|
2550
2550
|
* Raises an exception if an error occurs.
|
|
2551
2551
|
*
|
|
@@ -2654,10 +2654,10 @@ pgconn_put_copy_end(int argc, VALUE *argv, VALUE self)
|
|
|
2654
2654
|
* if the copy is done, or +false+ if the call would
|
|
2655
2655
|
* block (only possible if _async_ is true).
|
|
2656
2656
|
*
|
|
2657
|
-
* decoder can be a PG::Coder derivation (typically PG::
|
|
2657
|
+
* decoder can be a PG::Coder derivation (typically PG::TextDecoder::CopyRow).
|
|
2658
2658
|
* This decodes the received data fields as Array of Strings. Optionally
|
|
2659
2659
|
* the decoder can type cast the fields to various Ruby types in one step,
|
|
2660
|
-
* if PG::
|
|
2660
|
+
* if PG::TextDecoder::CopyRow#type_map is set accordingly.
|
|
2661
2661
|
*
|
|
2662
2662
|
* See also #copy_data.
|
|
2663
2663
|
*
|
data/ext/pg_copy_coder.c
CHANGED
|
@@ -153,12 +153,20 @@ pg_copycoder_type_map_get(VALUE self)
|
|
|
153
153
|
* See the {COPY command}[http://www.postgresql.org/docs/current/static/sql-copy.html]
|
|
154
154
|
* for description of the format.
|
|
155
155
|
*
|
|
156
|
-
* It is intended to be used in conjunction with PG::Connection#
|
|
156
|
+
* It is intended to be used in conjunction with PG::Connection#put_copy_data .
|
|
157
157
|
*
|
|
158
158
|
* The columns are expected as Array of values. The single values are encoded as defined
|
|
159
159
|
* in the assigned #type_map. If no type_map was assigned, all values are converted to
|
|
160
|
-
*
|
|
160
|
+
* strings by PG::TextEncoder::String.
|
|
161
161
|
*
|
|
162
|
+
* Example with default type map ( TypeMapAllStrings ):
|
|
163
|
+
* conn.exec "create table my_table (a text,b int,c bool)"
|
|
164
|
+
* enco = PG::TextEncoder::CopyRow.new
|
|
165
|
+
* conn.copy_data "COPY my_table FROM STDIN", enco do
|
|
166
|
+
* conn.put_copy_data ["astring", 7, false]
|
|
167
|
+
* conn.put_copy_data ["string2", 42, true]
|
|
168
|
+
* end
|
|
169
|
+
* This creates +my_table+ and inserts two rows.
|
|
162
170
|
*/
|
|
163
171
|
static int
|
|
164
172
|
pg_text_enc_copy_row(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate)
|
|
@@ -286,12 +294,22 @@ GetDecimalFromHex(char hex)
|
|
|
286
294
|
* See the {COPY command}[http://www.postgresql.org/docs/current/static/sql-copy.html]
|
|
287
295
|
* for description of the format.
|
|
288
296
|
*
|
|
289
|
-
* It is intended to be used in conjunction with PG::Connection#
|
|
297
|
+
* It is intended to be used in conjunction with PG::Connection#get_copy_data .
|
|
290
298
|
*
|
|
291
299
|
* The columns are retrieved as Array of values. The single values are decoded as defined
|
|
292
300
|
* in the assigned #type_map. If no type_map was assigned, all values are converted to
|
|
293
|
-
*
|
|
301
|
+
* strings by PG::TextDecoder::String.
|
|
294
302
|
*
|
|
303
|
+
* Example with default type map ( TypeMapAllStrings ):
|
|
304
|
+
* deco = PG::TextDecoder::CopyRow.new
|
|
305
|
+
* conn.copy_data "COPY my_table TO STDOUT", deco do
|
|
306
|
+
* while row=conn.get_copy_data
|
|
307
|
+
* p row
|
|
308
|
+
* end
|
|
309
|
+
* end
|
|
310
|
+
* This prints all rows of +my_table+ to stdout:
|
|
311
|
+
* ["astring", "7", "f"]
|
|
312
|
+
* ["string2", "42", "t"]
|
|
295
313
|
*/
|
|
296
314
|
/*
|
|
297
315
|
* Parse the current line into separate attributes (fields),
|
|
@@ -534,8 +552,10 @@ init_pg_copycoder()
|
|
|
534
552
|
rb_define_alloc_func( rb_cPG_CopyDecoder, pg_copycoder_decoder_allocate );
|
|
535
553
|
|
|
536
554
|
/* Make RDoc aware of the encoder classes... */
|
|
555
|
+
/* rb_mPG_TextEncoder = rb_define_module_under( rb_mPG, "TextEncoder" ); */
|
|
537
556
|
/* dummy = rb_define_class_under( rb_mPG_TextEncoder, "CopyRow", rb_cPG_CopyEncoder ); */
|
|
538
557
|
pg_define_coder( "CopyRow", pg_text_enc_copy_row, rb_cPG_CopyEncoder, rb_mPG_TextEncoder );
|
|
558
|
+
/* rb_mPG_TextDecoder = rb_define_module_under( rb_mPG, "TextDecoder" ); */
|
|
539
559
|
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "CopyRow", rb_cPG_CopyDecoder ); */
|
|
540
560
|
pg_define_coder( "CopyRow", pg_text_dec_copy_row, rb_cPG_CopyDecoder, rb_mPG_TextDecoder );
|
|
541
561
|
}
|
data/ext/pg_result.c
CHANGED
data/ext/pg_text_decoder.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* pg_text_decoder.c - PG::TextDecoder module
|
|
3
|
-
* $Id$
|
|
3
|
+
* $Id: pg_text_decoder.c,v b7f9daeeba29 2014/11/21 19:53:47 lars $
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -313,8 +313,8 @@ pg_text_dec_identifier(t_pg_coder *conv, char *val, int len, int tuple, int fiel
|
|
|
313
313
|
VALUE elem;
|
|
314
314
|
int word_index = 0;
|
|
315
315
|
int index;
|
|
316
|
-
/*
|
|
317
|
-
char
|
|
316
|
+
/* Use a buffer of the same length, as that will be the worst case */
|
|
317
|
+
char word[len + 1];
|
|
318
318
|
|
|
319
319
|
/* The current character in the input string. */
|
|
320
320
|
char c;
|
|
@@ -356,8 +356,6 @@ pg_text_dec_identifier(t_pg_coder *conv, char *val, int len, int tuple, int fiel
|
|
|
356
356
|
elem = dec_func(conv, word, word_index, tuple, field, enc_idx);
|
|
357
357
|
rb_ary_push(array, elem);
|
|
358
358
|
|
|
359
|
-
free(word);
|
|
360
|
-
|
|
361
359
|
return array;
|
|
362
360
|
}
|
|
363
361
|
|
data/ext/pg_text_encoder.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* pg_text_encoder.c - PG::TextEncoder module
|
|
3
|
-
* $Id$
|
|
3
|
+
* $Id: pg_text_encoder.c,v 1a13e7eafeb7 2014/12/12 20:57:39 lars $
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
VALUE rb_mPG_TextEncoder;
|
|
48
48
|
static ID s_id_encode;
|
|
49
49
|
static ID s_id_to_i;
|
|
50
|
-
static VALUE hash_false_values;
|
|
51
50
|
|
|
51
|
+
static int pg_text_enc_integer(t_pg_coder *this, VALUE value, char *out, VALUE *intermediate);
|
|
52
52
|
|
|
53
53
|
VALUE
|
|
54
54
|
pg_obj_to_i( VALUE value )
|
|
@@ -68,38 +68,37 @@ pg_obj_to_i( VALUE value )
|
|
|
68
68
|
*
|
|
69
69
|
* This is the encoder class for the PostgreSQL bool type.
|
|
70
70
|
*
|
|
71
|
-
* Ruby
|
|
72
|
-
*
|
|
73
|
-
* Any other
|
|
71
|
+
* Ruby value false is encoded as SQL +FALSE+ value.
|
|
72
|
+
* Ruby value true is encoded as SQL +TRUE+ value.
|
|
73
|
+
* Any other value is sent as it's string representation.
|
|
74
74
|
*
|
|
75
75
|
*/
|
|
76
76
|
static int
|
|
77
|
-
pg_text_enc_boolean(t_pg_coder *
|
|
77
|
+
pg_text_enc_boolean(t_pg_coder *this, VALUE value, char *out, VALUE *intermediate)
|
|
78
78
|
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*out = 't';
|
|
100
|
-
}
|
|
79
|
+
switch( TYPE(value) ){
|
|
80
|
+
case T_FALSE:
|
|
81
|
+
if(out) *out = 'f';
|
|
82
|
+
return 1;
|
|
83
|
+
case T_TRUE:
|
|
84
|
+
if(out) *out = 't';
|
|
85
|
+
return 1;
|
|
86
|
+
case T_FIXNUM:
|
|
87
|
+
case T_BIGNUM:
|
|
88
|
+
if( NUM2LONG(value) == 0 ){
|
|
89
|
+
if(out) *out = '0';
|
|
90
|
+
return 1;
|
|
91
|
+
} else if( NUM2LONG(value) == 1 ){
|
|
92
|
+
if(out) *out = '1';
|
|
93
|
+
return 1;
|
|
94
|
+
} else {
|
|
95
|
+
return pg_text_enc_integer(this, value, out, intermediate);
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
return pg_coder_enc_to_s(this, value, out, intermediate);
|
|
101
99
|
}
|
|
102
|
-
|
|
100
|
+
/* never reached */
|
|
101
|
+
return 0;
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
|
|
@@ -638,16 +637,6 @@ init_pg_text_encoder()
|
|
|
638
637
|
s_id_encode = rb_intern("encode");
|
|
639
638
|
s_id_to_i = rb_intern("to_i");
|
|
640
639
|
|
|
641
|
-
hash_false_values = rb_hash_new();
|
|
642
|
-
rb_gc_register_address( &hash_false_values );
|
|
643
|
-
rb_hash_aset( hash_false_values, rb_str_new2( "0" ), Qtrue );
|
|
644
|
-
rb_hash_aset( hash_false_values, rb_str_new2( "f" ), Qtrue );
|
|
645
|
-
rb_hash_aset( hash_false_values, rb_str_new2( "F" ), Qtrue );
|
|
646
|
-
rb_hash_aset( hash_false_values, rb_str_new2( "false" ), Qtrue );
|
|
647
|
-
rb_hash_aset( hash_false_values, rb_str_new2( "FALSE" ), Qtrue );
|
|
648
|
-
rb_hash_aset( hash_false_values, rb_str_new2( "off" ), Qtrue );
|
|
649
|
-
rb_hash_aset( hash_false_values, rb_str_new2( "OFF" ), Qtrue );
|
|
650
|
-
|
|
651
640
|
/* This module encapsulates all encoder classes with text output format */
|
|
652
641
|
rb_mPG_TextEncoder = rb_define_module_under( rb_mPG, "TextEncoder" );
|
|
653
642
|
|