pg 0.16.0 → 0.17.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 +2 -2
- data.tar.gz.sig +2 -1
- data/ChangeLog +195 -88
- data/History.rdoc +15 -0
- data/Rakefile +6 -2
- data/Rakefile.cross +1 -1
- data/ext/gvl_wrappers.h +45 -3
- data/ext/pg_connection.c +14 -9
- data/ext/pg_result.c +3 -3
- data/lib/pg.rb +4 -2
- data/lib/pg/connection.rb +85 -0
- data/spec/lib/helpers.rb +6 -0
- data/spec/pg/connection_spec.rb +95 -0
- metadata +23 -7
- 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: 82f24c3c723c5c426929fd7c14b784f8db43fccc
|
|
4
|
+
data.tar.gz: 3ce6e0d944af02a3283c2d51588e988df89da216
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb683af0ecf1711e19a5e497e63d7ca5fe08180db99b373fdbd9e0167d3930bfb55de6fe37f116a0e8d3c520741bef019ebcc15993da905eceb495c03ec23c31
|
|
7
|
+
data.tar.gz: e7255b4ce2802d0b97b4af8fe3a5715bfbffc2aee7d454b1c6bd6eec8b82aa711212467ca0b99a6614355b8ad1f101b9075f443b88d36e648aa0251848923b3f
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
q
|
|
1
|
+
�/p
|
|
2
|
+
_ˈ�jN���O��d�u��������w���=�B7���Gơ�ӥ=L�P���)#)�M�����^9⽳:L1�ad�nզr�?� &����ޜr�R\�<�s#*��Xlao@�ϝ{s�6�q��*].[�eКD�Q�{�B5�MY�H��Kx�7�{��T���$�Կ]�6�E4�{��ddΗ�V7;��I���h�
|
data.tar.gz.sig
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
�
|
|
1
|
+
2+��Ѣ���"����M�5��c&��X���A�I�9�\�7xhn�4G�1=(�0R�)#O���#z
S`|,�\$�\�\�K�ԓ�G
|
|
2
|
+
|7^`�^6�ui��&�ه^(K���E�;R�ZO1V�>�g�L4=�ZL���Zřw�[�\7h�B���)l/��J;F�X�V�"�+Py\�Ė&�g��b&<Qj8.Ū��SY
|
data/ChangeLog
CHANGED
|
@@ -1,8 +1,126 @@
|
|
|
1
|
+
2013-09-15 Michael Granger <ged@FaerieMUD.org>
|
|
2
|
+
|
|
3
|
+
* History.rdoc, lib/pg.rb:
|
|
4
|
+
Bump minor version
|
|
5
|
+
[7cdff0a462e5] [tip]
|
|
6
|
+
|
|
7
|
+
2013-09-14 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
8
|
+
|
|
9
|
+
* History.rdoc:
|
|
10
|
+
Add change of PG::Result#check to History.rdoc.
|
|
11
|
+
[2b4f876c54f6]
|
|
12
|
+
|
|
13
|
+
* spec/lib/helpers.rb:
|
|
14
|
+
verify_clean_exec_status itself should leave a clean status.
|
|
15
|
+
[933d0f788047]
|
|
16
|
+
|
|
17
|
+
2013-09-13 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
18
|
+
|
|
19
|
+
* lib/pg.rb, lib/pg/connection.rb, spec/lib/helpers.rb,
|
|
20
|
+
spec/pg/connection_spec.rb:
|
|
21
|
+
Improve Connection#copy_data:
|
|
22
|
+
- ensure and verify a clean exec status for each test case
|
|
23
|
+
- add error PG::NotAllCopyDataRetrieved and a spec for this case
|
|
24
|
+
- fix input/output naming in the specs
|
|
25
|
+
- use ArgumentError instead of PG::Error in case of non-COPY statement
|
|
26
|
+
[b0fd97e58a9a]
|
|
27
|
+
|
|
28
|
+
* History.rdoc, lib/pg.rb:
|
|
29
|
+
Bump VERSION to 0.16.1 and prepare History.rdoc for release.
|
|
30
|
+
[c2bbdcd4ef0f]
|
|
31
|
+
|
|
32
|
+
* lib/pg/connection.rb:
|
|
33
|
+
Fix examples of conn#copy_data and improve the documentation.
|
|
34
|
+
[53d027b0d064]
|
|
35
|
+
|
|
36
|
+
2013-09-07 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
37
|
+
|
|
38
|
+
* ext/gvl_wrappers.h, ext/pg_connection.c:
|
|
39
|
+
Wrap PQisBusy to be called without GVL. It could trigger the notice
|
|
40
|
+
callback.
|
|
41
|
+
[d93b3ddc69ff]
|
|
42
|
+
|
|
43
|
+
* ext/gvl_wrappers.h, ext/pg_connection.c:
|
|
44
|
+
Wrap all PQsend* functions to be called without GVL.
|
|
45
|
+
|
|
46
|
+
These functions could trigger the notice callback when some notice
|
|
47
|
+
is yet in the buffer. The notice callback needs to be called without
|
|
48
|
+
GVL since it always reaquires the GLV. This fixes issue #171.
|
|
49
|
+
[1fd77c0a4cea]
|
|
50
|
+
|
|
51
|
+
2013-08-19 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
52
|
+
|
|
53
|
+
* spec/pg/connection_spec.rb:
|
|
54
|
+
Add #copy_data case for non copy statement
|
|
55
|
+
[eea6da92b30a]
|
|
56
|
+
|
|
57
|
+
* ext/pg_connection.c:
|
|
58
|
+
Remove copy examples in favour of #copy_data
|
|
59
|
+
[c549f9878adf]
|
|
60
|
+
|
|
61
|
+
2013-08-18 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
62
|
+
|
|
63
|
+
* merge tip
|
|
64
|
+
[90252df3c5c8]
|
|
65
|
+
|
|
66
|
+
* lib/pg/connection.rb, spec/pg/connection_spec.rb:
|
|
67
|
+
Add PG::Connection#copy_data as a convenience method.
|
|
68
|
+
[5096385267ab]
|
|
69
|
+
|
|
70
|
+
* ext/pg_result.c:
|
|
71
|
+
Return self from PG::Result#check instead of nil. This allowes to
|
|
72
|
+
stack method calls.
|
|
73
|
+
[8255d4f73334]
|
|
74
|
+
|
|
75
|
+
2013-08-15 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
76
|
+
|
|
77
|
+
* Rakefile.cross:
|
|
78
|
+
Use RbConfig::CONFIG['CC'] instead of ['host'] for determining cross
|
|
79
|
+
compilation platform.
|
|
80
|
+
|
|
81
|
+
This is 'i586-mingw32msvc-gcc' versus 'i586-pc-mingw32msvc'.
|
|
82
|
+
[fbee9586e8f7] [github/master]
|
|
83
|
+
|
|
84
|
+
2013-08-14 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
85
|
+
|
|
86
|
+
* Gemfile, Rakefile:
|
|
87
|
+
Add Gemfile for compat with rake-compiler-dev-box.
|
|
88
|
+
|
|
89
|
+
Increase version of rake-compiler to 0.9. That is needed for the
|
|
90
|
+
x64-mingw32 build.
|
|
91
|
+
[355cce5c8566]
|
|
92
|
+
|
|
93
|
+
2013-08-13 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
94
|
+
|
|
95
|
+
* ext/pg_connection.c:
|
|
96
|
+
Add usage examples for put_copy_data and get_copy_data.
|
|
97
|
+
[9959003173b4]
|
|
98
|
+
|
|
99
|
+
2013-08-11 Lars Kanis <lars@greiz-reinsdorf.de>
|
|
100
|
+
|
|
101
|
+
* Rakefile:
|
|
102
|
+
Add Lars Kanis to the list of developers in the gemspec.
|
|
103
|
+
[6d3d18452d99]
|
|
104
|
+
|
|
105
|
+
2013-07-23 Michael Granger <ged@FaerieMUD.org>
|
|
106
|
+
|
|
107
|
+
* .hgtags:
|
|
108
|
+
Added tag v0.16.0 for changeset def8f41a7672
|
|
109
|
+
[315fa9728831]
|
|
110
|
+
|
|
111
|
+
* .hgsigs:
|
|
112
|
+
Added signature for changeset 4e0606f5f5aa
|
|
113
|
+
[def8f41a7672] [v0.16.0]
|
|
114
|
+
|
|
115
|
+
* History.rdoc, lib/pg.rb:
|
|
116
|
+
Bump the version, update history.
|
|
117
|
+
[4e0606f5f5aa]
|
|
118
|
+
|
|
1
119
|
2013-07-19 Lars Kanis <kanis@comcard.de>
|
|
2
120
|
|
|
3
121
|
* .travis.yml:
|
|
4
122
|
Travis: Allow failures on rbx.
|
|
5
|
-
[7be3b156c8fb]
|
|
123
|
+
[7be3b156c8fb]
|
|
6
124
|
|
|
7
125
|
2013-07-18 Lars Kanis <kanis@comcard.de>
|
|
8
126
|
|
|
@@ -45,7 +163,7 @@
|
|
|
45
163
|
Use ConnectionBad instead of PG::Error for connection related
|
|
46
164
|
|
|
47
165
|
Replace rb_bug() for PQsocket() failure with rb_raise().
|
|
48
|
-
[ddb55d4a44d3]
|
|
166
|
+
[ddb55d4a44d3]
|
|
49
167
|
|
|
50
168
|
2013-07-17 Michael Granger <ged@FaerieMUD.org>
|
|
51
169
|
|
|
@@ -69,8 +187,8 @@
|
|
|
69
187
|
Add new error class 'ConnectionBad' that is raised if the connection
|
|
70
188
|
|
|
71
189
|
From 9d0acad61a693b9042842883fa8195ba973bf813 Mon Sep 17 00:00:00
|
|
72
|
-
2001 could not be established. Use 'UnableToSend' error in case
|
|
73
|
-
|
|
190
|
+
2001 could not be established. Use 'UnableToSend' error in case that
|
|
191
|
+
sending fails with async methods.
|
|
74
192
|
[b09cf9da723e]
|
|
75
193
|
|
|
76
194
|
* ext/gvl_wrappers.h, ext/pg_connection.c, spec/pg/connection_spec.rb:
|
|
@@ -918,8 +1036,8 @@
|
|
|
918
1036
|
From 10cdc23ac4e3cfc91488f3f8a7a44f3275c9fe0a Mon Sep 17 00:00:00
|
|
919
1037
|
2001 This is used for the new single row mode introduced in
|
|
920
1038
|
9.2beta3, and indicates a successful result when using that mode.
|
|
921
|
-
--- ext/extconf.rb | 1 + ext/pg_result.c | 3 +++ 2 files
|
|
922
|
-
|
|
1039
|
+
--- ext/extconf.rb | 1 + ext/pg_result.c | 3 +++ 2 files changed, 4
|
|
1040
|
+
insertions(+), 0 deletions(-)
|
|
923
1041
|
[f92b6456c566]
|
|
924
1042
|
|
|
925
1043
|
2012-08-10 Michael Granger <ged@FaerieMUD.org>
|
|
@@ -1031,9 +1149,9 @@
|
|
|
1031
1149
|
2012-06-12 Mahlon E. Smith <mahlon@laika.com>
|
|
1032
1150
|
|
|
1033
1151
|
* sample/warehouse_partitions.rb:
|
|
1034
|
-
Move indexes across tablespaces along with their parents. Remove
|
|
1035
|
-
|
|
1036
|
-
|
|
1152
|
+
Move indexes across tablespaces along with their parents. Remove the
|
|
1153
|
+
'parent table' option, as we can derive that automatically from the
|
|
1154
|
+
pg_inherits table.
|
|
1037
1155
|
[be46f44349bf]
|
|
1038
1156
|
|
|
1039
1157
|
2012-05-07 Michael Granger <ged@FaerieMUD.org>
|
|
@@ -1070,31 +1188,28 @@
|
|
|
1070
1188
|
|
|
1071
1189
|
- disk_usage_report
|
|
1072
1190
|
|
|
1073
|
-
Quick reporting on the heaviest disk consumers for a
|
|
1074
|
-
|
|
1191
|
+
Quick reporting on the heaviest disk consumers for a database. Nice
|
|
1192
|
+
for cronned/email reporting.
|
|
1075
1193
|
|
|
1076
1194
|
- pg_statistics
|
|
1077
1195
|
|
|
1078
|
-
Continuous polled statistics for a database.
|
|
1079
|
-
|
|
1080
|
-
included.)
|
|
1196
|
+
Continuous polled statistics for a database. Suitable for graphing
|
|
1197
|
+
with gnuplot (example included.)
|
|
1081
1198
|
|
|
1082
1199
|
- replication_monitor
|
|
1083
1200
|
|
|
1084
|
-
A command-line monitor for slave replication lag.
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
plug into your preferred monitoring system.
|
|
1201
|
+
A command-line monitor for slave replication lag. Works for both
|
|
1202
|
+
streaming replication and WAL shipping. You should be able to use it
|
|
1203
|
+
as a base to plug into your preferred monitoring system.
|
|
1088
1204
|
|
|
1089
1205
|
- wal_shipper
|
|
1090
1206
|
|
|
1091
|
-
A smart WAL file transfer script, similar to
|
|
1092
|
-
PITRTools.
|
|
1207
|
+
A smart WAL file transfer script, similar to PITRTools.
|
|
1093
1208
|
|
|
1094
1209
|
- warehouse_partitions
|
|
1095
1210
|
|
|
1096
|
-
An automated tablespace migrator for older, date-
|
|
1097
|
-
|
|
1211
|
+
An automated tablespace migrator for older, date- based partitioned
|
|
1212
|
+
tables.
|
|
1098
1213
|
[36ca5b412583]
|
|
1099
1214
|
|
|
1100
1215
|
2012-04-02 Michael Granger <ged@FaerieMUD.org>
|
|
@@ -2237,10 +2352,9 @@
|
|
|
2237
2352
|
* Removed the type OID constants from PGresult; I was including them
|
|
2238
2353
|
so they could be used for comparison with PGresult#ftype return
|
|
2239
2354
|
values. RhodiumToad on #postgresql@freenode showed me the
|
|
2240
|
-
format_type() SQL function, so I added an example of how to get
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
changes.
|
|
2355
|
+
format_type() SQL function, so I added an example of how to get the
|
|
2356
|
+
same information via that function instead, which is guaranteed to
|
|
2357
|
+
be correct even if src/include/catalog/pg_type.h changes.
|
|
2244
2358
|
[739cec560448]
|
|
2245
2359
|
|
|
2246
2360
|
* README.windows, Rakefile.local, ext/extconf.rb:
|
|
@@ -2448,8 +2562,8 @@
|
|
|
2448
2562
|
* ext/pg.c, spec/m17n_spec.rb, spec/pgconn_spec.rb,
|
|
2449
2563
|
spec/pgresult_spec.rb:
|
|
2450
2564
|
* Use pg_ctl -w instead of sleep for specs
|
|
2451
|
-
* Fix up the specs to use #external_encoding, #internal_encoding,
|
|
2452
|
-
|
|
2565
|
+
* Fix up the specs to use #external_encoding, #internal_encoding, and
|
|
2566
|
+
#internal_encoding=
|
|
2453
2567
|
* Added a pending spec for Johab (I can't figure out how to return
|
|
2454
2568
|
JOHAB-encoded results from Postgres)
|
|
2455
2569
|
[d67c62945540] <i17n-19-patches>
|
|
@@ -2543,8 +2657,7 @@
|
|
|
2543
2657
|
[c33a73c14126]
|
|
2544
2658
|
|
|
2545
2659
|
* spec/pgconn_spec.rb:
|
|
2546
|
-
Ripple port change through text. Always full path to open spec
|
|
2547
|
-
file.
|
|
2660
|
+
Ripple port change through text. Always full path to open spec file.
|
|
2548
2661
|
[241d3410b875]
|
|
2549
2662
|
|
|
2550
2663
|
* spec/pgconn_spec.rb:
|
|
@@ -2601,27 +2714,26 @@
|
|
|
2601
2714
|
........ r169 | jdavis | 2008-08-20 19:48:10 -0700 (Wed, 20 Aug
|
|
2602
2715
|
2008) | 6 lines
|
|
2603
2716
|
|
|
2604
|
-
Fixed option connection argument in the case of using 7
|
|
2605
|
-
arguments.
|
|
2717
|
+
Fixed option connection argument in the case of using 7 arguments.
|
|
2606
2718
|
|
|
2607
|
-
Thanks Erik Hollensbe (erikh) for the bug report. ........ r170
|
|
2608
|
-
|
|
2719
|
+
Thanks Erik Hollensbe (erikh) for the bug report. ........ r170 |
|
|
2720
|
+
jdavis | 2008-10-05 11:01:40 -0700 (Sun, 05 Oct 2008) | 4 lines
|
|
2609
2721
|
|
|
2610
|
-
Throw correct exception when result is NULL. ........ r171 |
|
|
2611
|
-
|
|
2722
|
+
Throw correct exception when result is NULL. ........ r171 | jdavis
|
|
2723
|
+
| 2008-10-05 11:47:01 -0700 (Sun, 05 Oct 2008) | 12 lines
|
|
2612
2724
|
|
|
2613
2725
|
Fix PGconn#async_exec and PGconn#get_last_result to properly clear
|
|
2614
2726
|
all results when an exception is raised. Before, the connection
|
|
2615
2727
|
could be left in a state that is not ready for new commands.
|
|
2616
2728
|
|
|
2617
|
-
Also, change PGconn#get_result to not raise an exception
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2729
|
+
Also, change PGconn#get_result to not raise an exception when the
|
|
2730
|
+
result is in an error state. You can still check the result object
|
|
2731
|
+
for an error, but it's not appropriate to raise an exception,
|
|
2732
|
+
because that could prevent the caller from properly clearing all
|
|
2733
|
+
results.
|
|
2622
2734
|
|
|
2623
|
-
Thanks to Tarmo Tänav. ........ r172 | jdavis | 2008-10-05
|
|
2624
|
-
|
|
2735
|
+
Thanks to Tarmo Tänav. ........ r172 | jdavis | 2008-10-05 12:04:45
|
|
2736
|
+
-0700 (Sun, 05 Oct 2008) | 6 lines
|
|
2625
2737
|
|
|
2626
2738
|
Include all libraries listed in "pg_config --libs" in the build.
|
|
2627
2739
|
|
|
@@ -2696,24 +2808,23 @@
|
|
|
2696
2808
|
........ r149 | jdavis | 2008-03-19 14:17:20 -0700 (Wed, 19 Mar
|
|
2697
2809
|
2008) | 5 lines
|
|
2698
2810
|
|
|
2699
|
-
This commmit just cleans up indenting and coding
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
lines
|
|
2811
|
+
This commmit just cleans up indenting and coding conventions. It's
|
|
2812
|
+
a big patch, but does nothing meaningful. ........ r150 | jdavis |
|
|
2813
|
+
2008-03-19 14:19:53 -0700 (Wed, 19 Mar 2008) | 5 lines
|
|
2703
2814
|
|
|
2704
2815
|
|
|
2705
|
-
* forgot to add the expected output to the repository, so one
|
|
2706
|
-
|
|
2707
|
-
|
|
2816
|
+
* forgot to add the expected output to the repository, so one test was
|
|
2817
|
+
failing. Corrected now. ........ r151 | jdavis | 2008-03-20 11:20:25
|
|
2818
|
+
-0700 (Thu, 20 Mar 2008) | 12 lines
|
|
2708
2819
|
|
|
2709
2820
|
|
|
2710
2821
|
* added PGconn.connect_start(...) -> PGconn
|
|
2711
2822
|
* added test for PGconn.connect_start()
|
|
2712
2823
|
* refactored to separate the complexity of parsing the connection
|
|
2713
2824
|
arguments
|
|
2714
|
-
* Removed some superfluous code for old versions of Ruby that
|
|
2715
|
-
|
|
2716
|
-
|
|
2825
|
+
* Removed some superfluous code for old versions of Ruby that don't
|
|
2826
|
+
support rb_define_alloc_func(). Those versions of Ruby most likely
|
|
2827
|
+
don't work anyway, and I'm not testing them.
|
|
2717
2828
|
|
|
2718
2829
|
........ r152 | jdavis | 2008-03-20 12:16:06 -0700 (Thu, 20 Mar
|
|
2719
2830
|
2008) | 5 lines
|
|
@@ -2724,8 +2835,8 @@
|
|
|
2724
2835
|
10:13:39 -0700 (Mon, 21 Apr 2008) | 4 lines
|
|
2725
2836
|
|
|
2726
2837
|
|
|
2727
|
-
* added some tests for binary data ........ r154 | jdavis |
|
|
2728
|
-
|
|
2838
|
+
* added some tests for binary data ........ r154 | jdavis | 2008-04-21
|
|
2839
|
+
10:24:05 -0700 (Mon, 21 Apr 2008) | 5 lines
|
|
2729
2840
|
|
|
2730
2841
|
|
|
2731
2842
|
* applied patch from Louis Lavena to improve the build process
|
|
@@ -2733,20 +2844,19 @@
|
|
|
2733
2844
|
10:41:04 -0700 (Mon, 21 Apr 2008) | 6 lines
|
|
2734
2845
|
|
|
2735
2846
|
|
|
2736
|
-
* backtracked a small piece of the patch, to catch the condition
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
lines
|
|
2847
|
+
* backtracked a small piece of the patch, to catch the condition where
|
|
2848
|
+
pg_config is not in the PATH on posix platforms. ........ r156 |
|
|
2849
|
+
jdavis | 2008-07-07 23:21:07 -0700 (Mon, 07 Jul 2008) | 6 lines
|
|
2740
2850
|
|
|
2741
|
-
Fix oversight in connect arguments for options and
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2851
|
+
Fix oversight in connect arguments for options and connect_timeout
|
|
2852
|
+
when passed in a hash. (Thanks Rob Holland for the bug report).
|
|
2853
|
+
........ r157 | jdavis | 2008-07-23 22:33:26 -0700 (Wed, 23 Jul
|
|
2854
|
+
2008) | 10 lines
|
|
2745
2855
|
|
|
2746
|
-
Changed all temporary allocations to use ALLOC_N (heap
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2856
|
+
Changed all temporary allocations to use ALLOC_N (heap allocation)
|
|
2857
|
+
rather than ALLOCA_N (stack allocation). In particular, this allows
|
|
2858
|
+
PGconn#escape_string to accept larger input strings without fear of
|
|
2859
|
+
exceeding the stack size.
|
|
2750
2860
|
|
|
2751
2861
|
Thanks to Brett Neumeier. ........ r158 | jdavis | 2008-07-23
|
|
2752
2862
|
22:46:34 -0700 (Wed, 23 Jul 2008) | 6 lines
|
|
@@ -2756,8 +2866,8 @@
|
|
|
2756
2866
|
Thanks to Mohammad Ali (oldmoe) for the report. ........ r159 |
|
|
2757
2867
|
jdavis | 2008-08-17 11:19:09 -0700 (Sun, 17 Aug 2008) | 4 lines
|
|
2758
2868
|
|
|
2759
|
-
Applied build patch from Brett Neumeier. Thanks! ........ r160
|
|
2760
|
-
|
|
2869
|
+
Applied build patch from Brett Neumeier. Thanks! ........ r160 |
|
|
2870
|
+
jdavis | 2008-08-17 12:26:33 -0700 (Sun, 17 Aug 2008) | 7 lines
|
|
2761
2871
|
|
|
2762
2872
|
Properly protect variables from garbage collection, preventing
|
|
2763
2873
|
possible memory corruption.
|
|
@@ -2841,20 +2951,20 @@
|
|
|
2841
2951
|
* refactored to separate the complexity of parsing the connection
|
|
2842
2952
|
arguments
|
|
2843
2953
|
* Removed some superfluous code for old versions of Ruby that don't
|
|
2844
|
-
support rb_define_alloc_func(). Those versions of Ruby most
|
|
2845
|
-
|
|
2954
|
+
support rb_define_alloc_func(). Those versions of Ruby most likely
|
|
2955
|
+
don't work anyway, and I'm not testing them.
|
|
2846
2956
|
[778892302876]
|
|
2847
2957
|
|
|
2848
2958
|
2008-03-19 Jeff Davis <davis.jeffrey@gmail.com>
|
|
2849
2959
|
|
|
2850
2960
|
* spec/data/expected_trace.out:
|
|
2851
|
-
* forgot to add the expected output to the repository, so one
|
|
2852
|
-
|
|
2961
|
+
* forgot to add the expected output to the repository, so one test
|
|
2962
|
+
was failing. Corrected now.
|
|
2853
2963
|
[630cca5e74c1]
|
|
2854
2964
|
|
|
2855
2965
|
* ext/pg.c:
|
|
2856
|
-
This commmit just cleans up indenting and coding conventions. It's
|
|
2857
|
-
|
|
2966
|
+
This commmit just cleans up indenting and coding conventions. It's a
|
|
2967
|
+
big patch, but does nothing meaningful.
|
|
2858
2968
|
[661ed2fea9e2]
|
|
2859
2969
|
|
|
2860
2970
|
2008-03-18 Jeff Davis <davis.jeffrey@gmail.com>
|
|
@@ -2928,8 +3038,8 @@
|
|
|
2928
3038
|
[e94ce7f92a06]
|
|
2929
3039
|
|
|
2930
3040
|
* ext/pg.c:
|
|
2931
|
-
* make PGconn#trace accept any object that provides a writable
|
|
2932
|
-
|
|
3041
|
+
* make PGconn#trace accept any object that provides a writable file
|
|
3042
|
+
descriptor via the method "fileno".
|
|
2933
3043
|
[221e68f16f2d]
|
|
2934
3044
|
|
|
2935
3045
|
* ext/pg.c:
|
|
@@ -2939,9 +3049,8 @@
|
|
|
2939
3049
|
2008-03-07 Jeff Davis <davis.jeffrey@gmail.com>
|
|
2940
3050
|
|
|
2941
3051
|
* ext/extconf.rb, ext/mkrf_config.rb:
|
|
2942
|
-
* Added check to find pg_config. If not found, throw an error.
|
|
2943
|
-
|
|
2944
|
-
path.
|
|
3052
|
+
* Added check to find pg_config. If not found, throw an error. This
|
|
3053
|
+
should make it more obvious when pg_config is not in your path.
|
|
2945
3054
|
|
|
2946
3055
|
* Added proper check on MAC OS X so that it gives the correct
|
|
2947
3056
|
warning on ppc when ARCHFLAGS isn't set.
|
|
@@ -3152,13 +3261,12 @@
|
|
|
3152
3261
|
2008-01-23 Jeff Davis <davis.jeffrey@gmail.com>
|
|
3153
3262
|
|
|
3154
3263
|
* ext/compat.h, ext/pg.h:
|
|
3155
|
-
* had to include that file conditionally in compat.h for
|
|
3156
|
-
|
|
3264
|
+
* had to include that file conditionally in compat.h for postgresql
|
|
3265
|
+
7.3 compatibility
|
|
3157
3266
|
[12b2568a0ada]
|
|
3158
3267
|
|
|
3159
3268
|
* ext/pg.h:
|
|
3160
|
-
* included an additional file so that it works with PostgreSQL
|
|
3161
|
-
8.3
|
|
3269
|
+
* included an additional file so that it works with PostgreSQL 8.3
|
|
3162
3270
|
[34dd04d21a78]
|
|
3163
3271
|
|
|
3164
3272
|
* ext/extconf.rb, ext/pg.c:
|
|
@@ -3259,12 +3367,11 @@
|
|
|
3259
3367
|
[40270de77f48]
|
|
3260
3368
|
|
|
3261
3369
|
* ext/pg.c:
|
|
3262
|
-
Change conn.exec to use PQexec if no parameters are passed, and
|
|
3263
|
-
|
|
3370
|
+
Change conn.exec to use PQexec if no parameters are passed, and use
|
|
3371
|
+
PQexecParams if optional parameters are passed.
|
|
3264
3372
|
|
|
3265
3373
|
Change conn.send_query to use PQsendQuery if no parameters are
|
|
3266
|
-
passed, and use PQsendQueryParams if optional parameters are
|
|
3267
|
-
passed.
|
|
3374
|
+
passed, and use PQsendQueryParams if optional parameters are passed.
|
|
3268
3375
|
[d05d9f2042d7]
|
|
3269
3376
|
|
|
3270
3377
|
* compat-ruby-postgres/extconf.rb, compat-ruby-postgres/libpq-
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
== v0.17.0 [2013-09-15] Michael Granger <ged@FaerieMUD.org>
|
|
2
|
+
|
|
3
|
+
Bugfixes:
|
|
4
|
+
|
|
5
|
+
- Fix crash by calling PQsend* and PQisBusy without GVL (#171).
|
|
6
|
+
|
|
7
|
+
Enhancements:
|
|
8
|
+
|
|
9
|
+
- Add method PG::Connection#copy_data.
|
|
10
|
+
- Add a Gemfile to allow installation of dependencies with bundler.
|
|
11
|
+
- Add compatibility with rake-compiler-dev-box.
|
|
12
|
+
- Return self from PG::Result#check instead of nil. This allows
|
|
13
|
+
to stack method calls.
|
|
14
|
+
|
|
15
|
+
|
|
1
16
|
== v0.16.0 [2013-07-22] Michael Granger <ged@FaerieMUD.org>
|
|
2
17
|
|
|
3
18
|
Bugfixes:
|
data/Rakefile
CHANGED
|
@@ -38,6 +38,7 @@ CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
|
|
38
38
|
Hoe.plugin :mercurial
|
|
39
39
|
Hoe.plugin :signing
|
|
40
40
|
Hoe.plugin :deveiate
|
|
41
|
+
Hoe.plugin :bundler
|
|
41
42
|
|
|
42
43
|
Hoe.plugins.delete :rubyforge
|
|
43
44
|
Hoe.plugins.delete :compiler
|
|
@@ -54,9 +55,12 @@ $hoespec = Hoe.spec 'pg' do
|
|
|
54
55
|
self.extra_rdoc_files.include( 'ext/*.c' )
|
|
55
56
|
|
|
56
57
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
|
58
|
+
self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
|
|
57
59
|
|
|
58
|
-
self.dependency 'rake-compiler', '~> 0.
|
|
59
|
-
self.dependency
|
|
60
|
+
self.dependency 'rake-compiler', '~> 0.9', :developer
|
|
61
|
+
self.dependency 'hoe', '~> 3.5.1', :developer
|
|
62
|
+
self.dependency 'hoe-deveiate', '~> 0.2', :developer
|
|
63
|
+
self.dependency 'hoe-bundler', '~> 1.0', :developer
|
|
60
64
|
|
|
61
65
|
self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
|
|
62
66
|
self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
|
data/Rakefile.cross
CHANGED
|
@@ -72,7 +72,7 @@ class CrossLibrary < OpenStruct
|
|
|
72
72
|
self.host_platform = begin
|
|
73
73
|
config_file = YAML.load_file(File.expand_path("~/.rake-compiler/config.yml"))
|
|
74
74
|
_, rbfile = config_file.find{|key, fname| key.start_with?("rbconfig-#{for_platform}-") }
|
|
75
|
-
IO.read(rbfile).match(/CONFIG\["
|
|
75
|
+
IO.read(rbfile).match(/CONFIG\["CC"\] = "(.*)"/)[1].sub(/\-gcc/, '')
|
|
76
76
|
rescue
|
|
77
77
|
nil
|
|
78
78
|
end
|
data/ext/gvl_wrappers.h
CHANGED
|
@@ -168,7 +168,41 @@ void ubf_cancel_running_command(void *c);
|
|
|
168
168
|
|
|
169
169
|
#define FOR_EACH_PARAM_OF_PQnotifies(param)
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
#define FOR_EACH_PARAM_OF_PQsendQuery(param) \
|
|
172
|
+
param(PGconn *, conn)
|
|
173
|
+
|
|
174
|
+
#define FOR_EACH_PARAM_OF_PQsendQueryParams(param) \
|
|
175
|
+
param(PGconn *, conn) \
|
|
176
|
+
param(const char *, command) \
|
|
177
|
+
param(int, nParams) \
|
|
178
|
+
param(const Oid *, paramTypes) \
|
|
179
|
+
param(const char *const *, paramValues) \
|
|
180
|
+
param(const int *, paramLengths) \
|
|
181
|
+
param(const int *, paramFormats)
|
|
182
|
+
|
|
183
|
+
#define FOR_EACH_PARAM_OF_PQsendPrepare(param) \
|
|
184
|
+
param(PGconn *, conn) \
|
|
185
|
+
param(const char *, stmtName) \
|
|
186
|
+
param(const char *, query) \
|
|
187
|
+
param(int, nParams)
|
|
188
|
+
|
|
189
|
+
#define FOR_EACH_PARAM_OF_PQsendQueryPrepared(param) \
|
|
190
|
+
param(PGconn *, conn) \
|
|
191
|
+
param(const char *, stmtName) \
|
|
192
|
+
param(int, nParams) \
|
|
193
|
+
param(const char *const *, paramValues) \
|
|
194
|
+
param(const int *, paramLengths) \
|
|
195
|
+
param(const int *, paramFormats)
|
|
196
|
+
|
|
197
|
+
#define FOR_EACH_PARAM_OF_PQsendDescribePrepared(param) \
|
|
198
|
+
param(PGconn *, conn)
|
|
199
|
+
|
|
200
|
+
#define FOR_EACH_PARAM_OF_PQsendDescribePortal(param) \
|
|
201
|
+
param(PGconn *, conn)
|
|
202
|
+
|
|
203
|
+
#define FOR_EACH_PARAM_OF_PQisBusy(param)
|
|
204
|
+
|
|
205
|
+
/* function( name, cancel, void_or_nonvoid, returntype, lastparamtype, lastparamname ) */
|
|
172
206
|
#define FOR_EACH_BLOCKING_FUNCTION(function) \
|
|
173
207
|
function(PQconnectdb, GVL_NONCANCELABLE, GVL_TYPE_NONVOID, PGconn *, const char *, conninfo) \
|
|
174
208
|
function(PQconnectStart, GVL_NONCANCELABLE, GVL_TYPE_NONVOID, PGconn *, const char *, conninfo) \
|
|
@@ -186,7 +220,15 @@ void ubf_cancel_running_command(void *c);
|
|
|
186
220
|
function(PQputCopyData, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, int, nbytes) \
|
|
187
221
|
function(PQputCopyEnd, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, const char *, errormsg) \
|
|
188
222
|
function(PQgetCopyData, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, int, async) \
|
|
189
|
-
function(PQnotifies, GVL_CANCELABLE, GVL_TYPE_NONVOID, PGnotify *, PGconn *, conn)
|
|
223
|
+
function(PQnotifies, GVL_CANCELABLE, GVL_TYPE_NONVOID, PGnotify *, PGconn *, conn) \
|
|
224
|
+
function(PQsendQuery, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, const char *, query) \
|
|
225
|
+
function(PQsendQueryParams, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, int, resultFormat) \
|
|
226
|
+
function(PQsendPrepare, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, const Oid *, paramTypes) \
|
|
227
|
+
function(PQsendQueryPrepared, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, int, resultFormat) \
|
|
228
|
+
function(PQsendDescribePrepared, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, const char *, stmt) \
|
|
229
|
+
function(PQsendDescribePortal, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, const char *, portal) \
|
|
230
|
+
function(PQisBusy, GVL_CANCELABLE, GVL_TYPE_NONVOID, int, PGconn *, conn);
|
|
231
|
+
|
|
190
232
|
|
|
191
233
|
FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB_DECL );
|
|
192
234
|
|
|
@@ -201,7 +243,7 @@ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB_DECL );
|
|
|
201
243
|
#define FOR_EACH_PARAM_OF_notice_receiver_proxy(param) \
|
|
202
244
|
param(void *, arg)
|
|
203
245
|
|
|
204
|
-
/* function( name, void_or_nonvoid, returntype, lastparamtype, lastparamname ) */
|
|
246
|
+
/* function( name, cancel, void_or_nonvoid, returntype, lastparamtype, lastparamname ) */
|
|
205
247
|
#define FOR_EACH_CALLBACK_FUNCTION(function) \
|
|
206
248
|
function(notice_processor_proxy,, GVL_TYPE_VOID, void, const char *, message) \
|
|
207
249
|
function(notice_receiver_proxy,, GVL_TYPE_VOID, void, const PGresult *, result) \
|
data/ext/pg_connection.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* pg_connection.c - PG::Connection class extension
|
|
3
|
-
* $Id: pg_connection.c,v
|
|
3
|
+
* $Id: pg_connection.c,v d93b3ddc69ff 2013/09/07 21:12:59 lars $
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -1610,7 +1610,7 @@ pgconn_send_query(int argc, VALUE *argv, VALUE self)
|
|
|
1610
1610
|
|
|
1611
1611
|
/* If called with no parameters, use PQsendQuery */
|
|
1612
1612
|
if(NIL_P(params)) {
|
|
1613
|
-
if(
|
|
1613
|
+
if(gvl_PQsendQuery(conn,StringValuePtr(command)) == 0) {
|
|
1614
1614
|
error = rb_exc_new2(rb_eUnableToSend, PQerrorMessage(conn));
|
|
1615
1615
|
rb_iv_set(error, "@connection", self);
|
|
1616
1616
|
rb_exc_raise(error);
|
|
@@ -1683,7 +1683,7 @@ pgconn_send_query(int argc, VALUE *argv, VALUE self)
|
|
|
1683
1683
|
paramFormats[i] = NUM2INT(param_format);
|
|
1684
1684
|
}
|
|
1685
1685
|
|
|
1686
|
-
result =
|
|
1686
|
+
result = gvl_PQsendQueryParams(conn, StringValuePtr(command), nParams, paramTypes,
|
|
1687
1687
|
(const char * const *)paramValues, paramLengths, paramFormats, resultFormat);
|
|
1688
1688
|
|
|
1689
1689
|
rb_gc_unregister_address(&gc_array);
|
|
@@ -1750,7 +1750,7 @@ pgconn_send_prepare(int argc, VALUE *argv, VALUE self)
|
|
|
1750
1750
|
paramTypes[i] = NUM2INT(param);
|
|
1751
1751
|
}
|
|
1752
1752
|
}
|
|
1753
|
-
result =
|
|
1753
|
+
result = gvl_PQsendPrepare(conn, StringValuePtr(name), StringValuePtr(command),
|
|
1754
1754
|
nParams, paramTypes);
|
|
1755
1755
|
|
|
1756
1756
|
xfree(paramTypes);
|
|
@@ -1868,7 +1868,7 @@ pgconn_send_query_prepared(int argc, VALUE *argv, VALUE self)
|
|
|
1868
1868
|
paramFormats[i] = NUM2INT(param_format);
|
|
1869
1869
|
}
|
|
1870
1870
|
|
|
1871
|
-
result =
|
|
1871
|
+
result = gvl_PQsendQueryPrepared(conn, StringValuePtr(name), nParams,
|
|
1872
1872
|
(const char * const *)paramValues, paramLengths, paramFormats,
|
|
1873
1873
|
resultFormat);
|
|
1874
1874
|
|
|
@@ -1899,7 +1899,7 @@ pgconn_send_describe_prepared(VALUE self, VALUE stmt_name)
|
|
|
1899
1899
|
VALUE error;
|
|
1900
1900
|
PGconn *conn = pg_get_pgconn(self);
|
|
1901
1901
|
/* returns 0 on failure */
|
|
1902
|
-
if(
|
|
1902
|
+
if(gvl_PQsendDescribePrepared(conn,StringValuePtr(stmt_name)) == 0) {
|
|
1903
1903
|
error = rb_exc_new2(rb_eUnableToSend, PQerrorMessage(conn));
|
|
1904
1904
|
rb_iv_set(error, "@connection", self);
|
|
1905
1905
|
rb_exc_raise(error);
|
|
@@ -1921,7 +1921,7 @@ pgconn_send_describe_portal(VALUE self, VALUE portal)
|
|
|
1921
1921
|
VALUE error;
|
|
1922
1922
|
PGconn *conn = pg_get_pgconn(self);
|
|
1923
1923
|
/* returns 0 on failure */
|
|
1924
|
-
if(
|
|
1924
|
+
if(gvl_PQsendDescribePortal(conn,StringValuePtr(portal)) == 0) {
|
|
1925
1925
|
error = rb_exc_new2(rb_eUnableToSend, PQerrorMessage(conn));
|
|
1926
1926
|
rb_iv_set(error, "@connection", self);
|
|
1927
1927
|
rb_exc_raise(error);
|
|
@@ -1998,7 +1998,7 @@ static VALUE
|
|
|
1998
1998
|
pgconn_is_busy(self)
|
|
1999
1999
|
VALUE self;
|
|
2000
2000
|
{
|
|
2001
|
-
return
|
|
2001
|
+
return gvl_PQisBusy(pg_get_pgconn(self)) ? Qtrue : Qfalse;
|
|
2002
2002
|
}
|
|
2003
2003
|
|
|
2004
2004
|
/*
|
|
@@ -2449,6 +2449,9 @@ pgconn_wait_for_notify(int argc, VALUE *argv, VALUE self)
|
|
|
2449
2449
|
* is in nonblocking mode, and this command would block).
|
|
2450
2450
|
*
|
|
2451
2451
|
* Raises an exception if an error occurs.
|
|
2452
|
+
*
|
|
2453
|
+
* See also #copy_data.
|
|
2454
|
+
*
|
|
2452
2455
|
*/
|
|
2453
2456
|
static VALUE
|
|
2454
2457
|
pgconn_put_copy_data(self, buffer)
|
|
@@ -2513,6 +2516,8 @@ pgconn_put_copy_end(int argc, VALUE *argv, VALUE self)
|
|
|
2513
2516
|
* if the copy is done, or +false+ if the call would
|
|
2514
2517
|
* block (only possible if _async_ is true).
|
|
2515
2518
|
*
|
|
2519
|
+
* See also #copy_data.
|
|
2520
|
+
*
|
|
2516
2521
|
*/
|
|
2517
2522
|
static VALUE
|
|
2518
2523
|
pgconn_get_copy_data(int argc, VALUE *argv, VALUE self )
|
|
@@ -2916,7 +2921,7 @@ pgconn_s_quote_ident(VALUE self, VALUE in_str)
|
|
|
2916
2921
|
static void *
|
|
2917
2922
|
get_result_readable(PGconn *conn)
|
|
2918
2923
|
{
|
|
2919
|
-
return
|
|
2924
|
+
return gvl_PQisBusy(conn) ? NULL : (void*)1;
|
|
2920
2925
|
}
|
|
2921
2926
|
|
|
2922
2927
|
|
data/ext/pg_result.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* pg_result.c - PG::Result class extension
|
|
3
|
-
* $Id: pg_result.c,v
|
|
3
|
+
* $Id: pg_result.c,v 8255d4f73334 2013/08/18 20:40:08 lars $
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -74,7 +74,7 @@ pg_result_check( VALUE self )
|
|
|
74
74
|
#endif
|
|
75
75
|
case PGRES_EMPTY_QUERY:
|
|
76
76
|
case PGRES_COMMAND_OK:
|
|
77
|
-
return
|
|
77
|
+
return self;
|
|
78
78
|
case PGRES_BAD_RESPONSE:
|
|
79
79
|
case PGRES_FATAL_ERROR:
|
|
80
80
|
case PGRES_NONFATAL_ERROR:
|
|
@@ -97,7 +97,7 @@ pg_result_check( VALUE self )
|
|
|
97
97
|
rb_exc_raise( exception );
|
|
98
98
|
|
|
99
99
|
/* Not reached */
|
|
100
|
-
return
|
|
100
|
+
return self;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
|
data/lib/pg.rb
CHANGED
|
@@ -19,11 +19,13 @@ end
|
|
|
19
19
|
module PG
|
|
20
20
|
|
|
21
21
|
# Library version
|
|
22
|
-
VERSION = '0.
|
|
22
|
+
VERSION = '0.17.0'
|
|
23
23
|
|
|
24
24
|
# VCS revision
|
|
25
|
-
REVISION = %q$Revision:
|
|
25
|
+
REVISION = %q$Revision: 7cdff0a462e5 $
|
|
26
26
|
|
|
27
|
+
class NotAllCopyDataRetrieved < PG::Error
|
|
28
|
+
end
|
|
27
29
|
|
|
28
30
|
### Get the PG library version. If +include_buildnum+ is +true+, include the build ID.
|
|
29
31
|
def self::version_string( include_buildnum=false )
|
data/lib/pg/connection.rb
CHANGED
|
@@ -74,6 +74,91 @@ class PG::Connection
|
|
|
74
74
|
return connopts.join(' ')
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
# call-seq:
|
|
78
|
+
# conn.copy_data( sql ) {|sql_result| ... } -> PG::Result
|
|
79
|
+
#
|
|
80
|
+
# Execute a copy process for transfering data to or from the server.
|
|
81
|
+
#
|
|
82
|
+
# This issues the SQL COPY command via #exec. The response to this
|
|
83
|
+
# (if there is no error in the command) is a PG::Result object that
|
|
84
|
+
# is passed to the block, bearing a status code of PGRES_COPY_OUT or
|
|
85
|
+
# PGRES_COPY_IN (depending on the specified copy direction).
|
|
86
|
+
# The application should then use #put_copy_data or #get_copy_data
|
|
87
|
+
# to receive or transmit data rows and should return from the block
|
|
88
|
+
# when finished.
|
|
89
|
+
#
|
|
90
|
+
# #copy_data returns another PG::Result object when the data transfer
|
|
91
|
+
# is complete. An exception is raised if some problem was encountered,
|
|
92
|
+
# so it isn't required to make use of any of them.
|
|
93
|
+
# At this point further SQL commands can be issued via #exec.
|
|
94
|
+
# (It is not possible to execute other SQL commands using the same
|
|
95
|
+
# connection while the COPY operation is in progress.)
|
|
96
|
+
#
|
|
97
|
+
# This method ensures, that the copy process is properly terminated
|
|
98
|
+
# in case of client side or server side failures. Therefore, in case
|
|
99
|
+
# of blocking mode of operation, #copy_data is preferred to raw calls
|
|
100
|
+
# of #put_copy_data, #get_copy_data and #put_copy_end.
|
|
101
|
+
#
|
|
102
|
+
# Example with CSV input format:
|
|
103
|
+
# conn.exec "create table my_table (a text,b text,c text,d text,e text)"
|
|
104
|
+
# conn.copy_data "COPY my_table FROM STDOUT CSV" do
|
|
105
|
+
# conn.put_copy_data "some,csv,data,to,copy\n"
|
|
106
|
+
# conn.put_copy_data "more,csv,data,to,copy\n"
|
|
107
|
+
# end
|
|
108
|
+
# This creates +my_table+ and inserts two rows.
|
|
109
|
+
#
|
|
110
|
+
# Example with CSV output format:
|
|
111
|
+
# conn.copy_data "COPY my_table TO STDOUT CSV" do
|
|
112
|
+
# while row=conn.get_copy_data
|
|
113
|
+
# p row
|
|
114
|
+
# end
|
|
115
|
+
# end
|
|
116
|
+
# This prints all rows of +my_table+ to stdout:
|
|
117
|
+
# "some,csv,data,to,copy\n"
|
|
118
|
+
# "more,csv,data,to,copy\n"
|
|
119
|
+
def copy_data( sql )
|
|
120
|
+
res = exec( sql )
|
|
121
|
+
|
|
122
|
+
case res.result_status
|
|
123
|
+
when PGRES_COPY_IN
|
|
124
|
+
begin
|
|
125
|
+
yield res
|
|
126
|
+
rescue Exception => err
|
|
127
|
+
errmsg = "%s while copy data: %s" % [ err.class.name, err.message ]
|
|
128
|
+
put_copy_end( errmsg )
|
|
129
|
+
get_result
|
|
130
|
+
raise
|
|
131
|
+
else
|
|
132
|
+
put_copy_end
|
|
133
|
+
get_last_result
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
when PGRES_COPY_OUT
|
|
137
|
+
begin
|
|
138
|
+
yield res
|
|
139
|
+
rescue Exception => err
|
|
140
|
+
cancel
|
|
141
|
+
while get_copy_data
|
|
142
|
+
end
|
|
143
|
+
while get_result
|
|
144
|
+
end
|
|
145
|
+
raise
|
|
146
|
+
else
|
|
147
|
+
res = get_last_result
|
|
148
|
+
if res.result_status != PGRES_COMMAND_OK
|
|
149
|
+
while get_copy_data
|
|
150
|
+
end
|
|
151
|
+
while get_result
|
|
152
|
+
end
|
|
153
|
+
raise PG::NotAllCopyDataRetrieved, "Not all COPY data retrieved"
|
|
154
|
+
end
|
|
155
|
+
res
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
else
|
|
159
|
+
raise ArgumentError, "SQL command is no COPY statement: #{sql}"
|
|
160
|
+
end
|
|
161
|
+
end
|
|
77
162
|
|
|
78
163
|
# Backward-compatibility aliases for stuff that's moved into PG.
|
|
79
164
|
class << self
|
data/spec/lib/helpers.rb
CHANGED
|
@@ -254,6 +254,12 @@ module PG::TestingHelpers
|
|
|
254
254
|
conn_name.should include(app_name[-10..-1])
|
|
255
255
|
conn_name.length.should <= 64
|
|
256
256
|
end
|
|
257
|
+
|
|
258
|
+
# Ensure the connection is in a clean execution status.
|
|
259
|
+
def verify_clean_exec_status
|
|
260
|
+
@conn.send_query( "VALUES (1)" )
|
|
261
|
+
@conn.get_last_result.values.should == [["1"]]
|
|
262
|
+
end
|
|
257
263
|
end
|
|
258
264
|
|
|
259
265
|
|
data/spec/pg/connection_spec.rb
CHANGED
|
@@ -457,6 +457,101 @@ describe PG::Connection do
|
|
|
457
457
|
rval.should include( '5678', '1234' )
|
|
458
458
|
end
|
|
459
459
|
|
|
460
|
+
it "can process #copy_data output queries" do
|
|
461
|
+
rows = []
|
|
462
|
+
res2 = @conn.copy_data( "COPY (SELECT 1 UNION ALL SELECT 2) TO STDOUT" ) do |res|
|
|
463
|
+
res.result_status.should == PG::PGRES_COPY_OUT
|
|
464
|
+
res.nfields.should == 1
|
|
465
|
+
while row=@conn.get_copy_data
|
|
466
|
+
rows << row
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
rows.should == ["1\n", "2\n"]
|
|
470
|
+
res2.result_status.should == PG::PGRES_COMMAND_OK
|
|
471
|
+
verify_clean_exec_status
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
it "can handle incomplete #copy_data output queries" do
|
|
475
|
+
expect {
|
|
476
|
+
@conn.copy_data( "COPY (SELECT 1 UNION ALL SELECT 2) TO STDOUT" ) do |res|
|
|
477
|
+
@conn.get_copy_data
|
|
478
|
+
end
|
|
479
|
+
}.to raise_error(PG::NotAllCopyDataRetrieved, /Not all/)
|
|
480
|
+
verify_clean_exec_status
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
it "can handle client errors in #copy_data for output" do
|
|
484
|
+
expect {
|
|
485
|
+
@conn.copy_data( "COPY (SELECT 1 UNION ALL SELECT 2) TO STDOUT" ) do
|
|
486
|
+
raise "boom"
|
|
487
|
+
end
|
|
488
|
+
}.to raise_error(RuntimeError, "boom")
|
|
489
|
+
verify_clean_exec_status
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
it "can handle server errors in #copy_data for output" do
|
|
493
|
+
@conn.exec "ROLLBACK"
|
|
494
|
+
@conn.transaction do
|
|
495
|
+
@conn.exec( "CREATE FUNCTION errfunc() RETURNS int AS $$ BEGIN RAISE 'test-error'; END; $$ LANGUAGE plpgsql;" )
|
|
496
|
+
expect {
|
|
497
|
+
@conn.copy_data( "COPY (SELECT errfunc()) TO STDOUT" ) do |res|
|
|
498
|
+
while @conn.get_copy_data
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
}.to raise_error(PG::Error, /test-error/)
|
|
502
|
+
end
|
|
503
|
+
verify_clean_exec_status
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
it "can process #copy_data input queries" do
|
|
507
|
+
@conn.exec( "CREATE TEMP TABLE copytable (col1 TEXT)" )
|
|
508
|
+
res2 = @conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
|
|
509
|
+
res.result_status.should == PG::PGRES_COPY_IN
|
|
510
|
+
res.nfields.should == 1
|
|
511
|
+
@conn.put_copy_data "1\n"
|
|
512
|
+
@conn.put_copy_data "2\n"
|
|
513
|
+
end
|
|
514
|
+
res2.result_status.should == PG::PGRES_COMMAND_OK
|
|
515
|
+
|
|
516
|
+
verify_clean_exec_status
|
|
517
|
+
|
|
518
|
+
res = @conn.exec( "SELECT * FROM copytable ORDER BY col1" )
|
|
519
|
+
res.values.should == [["1"], ["2"]]
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
it "can handle client errors in #copy_data for input" do
|
|
523
|
+
@conn.exec "ROLLBACK"
|
|
524
|
+
@conn.transaction do
|
|
525
|
+
@conn.exec( "CREATE TEMP TABLE copytable (col1 TEXT)" )
|
|
526
|
+
expect {
|
|
527
|
+
@conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
|
|
528
|
+
raise "boom"
|
|
529
|
+
end
|
|
530
|
+
}.to raise_error(RuntimeError, "boom")
|
|
531
|
+
end
|
|
532
|
+
verify_clean_exec_status
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
it "can handle server errors in #copy_data for input" do
|
|
536
|
+
@conn.exec "ROLLBACK"
|
|
537
|
+
@conn.transaction do
|
|
538
|
+
@conn.exec( "CREATE TEMP TABLE copytable (col1 INT)" )
|
|
539
|
+
expect {
|
|
540
|
+
@conn.copy_data( "COPY copytable FROM STDOUT" ) do |res|
|
|
541
|
+
@conn.put_copy_data "xyz\n"
|
|
542
|
+
end
|
|
543
|
+
}.to raise_error(PG::Error, /invalid input syntax for integer/)
|
|
544
|
+
end
|
|
545
|
+
verify_clean_exec_status
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
it "should raise an error for non copy statements in #copy_data" do
|
|
549
|
+
expect {
|
|
550
|
+
@conn.copy_data( "SELECT 1" ){}
|
|
551
|
+
}.to raise_error(ArgumentError, /no COPY/)
|
|
552
|
+
|
|
553
|
+
verify_clean_exec_status
|
|
554
|
+
end
|
|
460
555
|
|
|
461
556
|
it "correctly finishes COPY queries passed to #async_exec" do
|
|
462
557
|
@conn.async_exec( "COPY (SELECT 1 UNION ALL SELECT 2) TO STDOUT" )
|
metadata
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.17.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Granger
|
|
8
|
+
- Lars Kanis
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain:
|
|
@@ -30,7 +31,7 @@ cert_chain:
|
|
|
30
31
|
6mKCwjpegytE0oifXfF8k75A9105cBnNiMZOe1tXiqYc/exCgWvbggurzDOcRkZu
|
|
31
32
|
/YSusaiDXHKU2O3Akc3htA==
|
|
32
33
|
-----END CERTIFICATE-----
|
|
33
|
-
date: 2013-
|
|
34
|
+
date: 2013-09-16 00:00:00.000000000 Z
|
|
34
35
|
dependencies:
|
|
35
36
|
- !ruby/object:Gem::Dependency
|
|
36
37
|
name: hoe-mercurial
|
|
@@ -80,14 +81,28 @@ dependencies:
|
|
|
80
81
|
requirements:
|
|
81
82
|
- - ~>
|
|
82
83
|
- !ruby/object:Gem::Version
|
|
83
|
-
version: '0.
|
|
84
|
+
version: '0.9'
|
|
84
85
|
type: :development
|
|
85
86
|
prerelease: false
|
|
86
87
|
version_requirements: !ruby/object:Gem::Requirement
|
|
87
88
|
requirements:
|
|
88
89
|
- - ~>
|
|
89
90
|
- !ruby/object:Gem::Version
|
|
90
|
-
version: '0.
|
|
91
|
+
version: '0.9'
|
|
92
|
+
- !ruby/object:Gem::Dependency
|
|
93
|
+
name: hoe
|
|
94
|
+
requirement: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ~>
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: 3.5.1
|
|
99
|
+
type: :development
|
|
100
|
+
prerelease: false
|
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
102
|
+
requirements:
|
|
103
|
+
- - ~>
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: 3.5.1
|
|
91
106
|
- !ruby/object:Gem::Dependency
|
|
92
107
|
name: hoe-deveiate
|
|
93
108
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -103,19 +118,19 @@ dependencies:
|
|
|
103
118
|
- !ruby/object:Gem::Version
|
|
104
119
|
version: '0.2'
|
|
105
120
|
- !ruby/object:Gem::Dependency
|
|
106
|
-
name: hoe
|
|
121
|
+
name: hoe-bundler
|
|
107
122
|
requirement: !ruby/object:Gem::Requirement
|
|
108
123
|
requirements:
|
|
109
124
|
- - ~>
|
|
110
125
|
- !ruby/object:Gem::Version
|
|
111
|
-
version: '
|
|
126
|
+
version: '1.0'
|
|
112
127
|
type: :development
|
|
113
128
|
prerelease: false
|
|
114
129
|
version_requirements: !ruby/object:Gem::Requirement
|
|
115
130
|
requirements:
|
|
116
131
|
- - ~>
|
|
117
132
|
- !ruby/object:Gem::Version
|
|
118
|
-
version: '
|
|
133
|
+
version: '1.0'
|
|
119
134
|
description: |-
|
|
120
135
|
Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
|
|
121
136
|
|
|
@@ -138,6 +153,7 @@ description: |-
|
|
|
138
153
|
end
|
|
139
154
|
email:
|
|
140
155
|
- ged@FaerieMUD.org
|
|
156
|
+
- lars@greiz-reinsdorf.de
|
|
141
157
|
executables: []
|
|
142
158
|
extensions:
|
|
143
159
|
- ext/extconf.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|