pg 0.7.9.2008.08.17 → 0.7.9.2008.10.05

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/ext/extconf.rb +2 -0
  2. data/ext/pg.c +34 -28
  3. data/spec/pgconn_spec.rb +3 -3
  4. metadata +3 -3
@@ -8,6 +8,8 @@ rescue
8
8
  exit 1
9
9
  end
10
10
 
11
+ $libs = IO.popen("pg_config --libs").readline.chomp
12
+
11
13
  # OS X compatibility
12
14
  if(RUBY_PLATFORM =~ /darwin/) then
13
15
  # test if postgresql is probably universal
data/ext/pg.c CHANGED
@@ -9,7 +9,7 @@
9
9
  modified at: Wed Jan 20 16:41:51 1999
10
10
 
11
11
  $Author: jdavis $
12
- $Date: 2008-08-17 13:43:21 -0700 (Sun, 17 Aug 2008) $
12
+ $Date: 2008-10-05 12:43:27 -0700 (Sun, 05 Oct 2008) $
13
13
  ************************************************/
14
14
 
15
15
  #include "pg.h"
@@ -137,27 +137,34 @@ pgresult_check(VALUE rb_pgconn, VALUE rb_pgresult)
137
137
  {
138
138
  VALUE error;
139
139
  PGconn *conn = get_pgconn(rb_pgconn);
140
- PGresult *result = get_pgresult(rb_pgresult);
140
+ PGresult *result;
141
+ Data_Get_Struct(rb_pgresult, PGresult, result);
141
142
 
142
143
  if(result == NULL)
144
+ {
143
145
  error = rb_exc_new2(rb_ePGError, PQerrorMessage(conn));
144
- switch (PQresultStatus(result)) {
145
- case PGRES_TUPLES_OK:
146
- case PGRES_COPY_OUT:
147
- case PGRES_COPY_IN:
148
- case PGRES_EMPTY_QUERY:
149
- case PGRES_COMMAND_OK:
150
- return;
151
- case PGRES_BAD_RESPONSE:
152
- case PGRES_FATAL_ERROR:
153
- case PGRES_NONFATAL_ERROR:
154
- error = rb_exc_new2(rb_ePGError, PQresultErrorMessage(result));
155
- break;
156
- default:
157
- error = rb_exc_new2(rb_ePGError,
158
- "internal error : unknown result status.");
159
146
  }
160
-
147
+ else
148
+ {
149
+ switch (PQresultStatus(result))
150
+ {
151
+ case PGRES_TUPLES_OK:
152
+ case PGRES_COPY_OUT:
153
+ case PGRES_COPY_IN:
154
+ case PGRES_EMPTY_QUERY:
155
+ case PGRES_COMMAND_OK:
156
+ return;
157
+ case PGRES_BAD_RESPONSE:
158
+ case PGRES_FATAL_ERROR:
159
+ case PGRES_NONFATAL_ERROR:
160
+ error = rb_exc_new2(rb_ePGError, PQresultErrorMessage(result));
161
+ break;
162
+ default:
163
+ error = rb_exc_new2(rb_ePGError,
164
+ "internal error : unknown result status.");
165
+ }
166
+ }
167
+
161
168
  rb_iv_set(error, "@connection", rb_pgconn);
162
169
  rb_iv_set(error, "@result", rb_pgresult);
163
170
  rb_exc_raise(error);
@@ -269,7 +276,7 @@ parse_connect_args(int argc, VALUE *argv, VALUE self)
269
276
  else if (RARRAY_LEN(args) == 7) {
270
277
  build_key_value_string(conninfo_rstr, "host", rb_ary_entry(args,0));
271
278
  build_key_value_string(conninfo_rstr, "port", rb_ary_entry(args,1));
272
- build_key_value_string(conninfo_rstr, "opt", rb_ary_entry(args,2));
279
+ build_key_value_string(conninfo_rstr, "options", rb_ary_entry(args,2));
273
280
  build_key_value_string(conninfo_rstr, "tty", rb_ary_entry(args,3));
274
281
  build_key_value_string(conninfo_rstr, "dbname", rb_ary_entry(args,4));
275
282
  build_key_value_string(conninfo_rstr, "user", rb_ary_entry(args,5));
@@ -1781,12 +1788,11 @@ pgconn_send_describe_portal(VALUE self, VALUE portal)
1781
1788
  * conn.get_result() -> PGresult
1782
1789
  *
1783
1790
  * Blocks waiting for the next result from a call to
1784
- * +PGconn#send_query+ (or another asynchronous command),
1785
- * and returns it. Returns +nil+ if no more results are
1786
- * available.
1791
+ * +PGconn#send_query+ (or another asynchronous command), and returns
1792
+ * it. Returns +nil+ if no more results are available.
1787
1793
  *
1788
- * Note: call this function repeatedly until it returns +nil+,
1789
- * or else you will not be able to issue further commands.
1794
+ * Note: call this function repeatedly until it returns +nil+, or else
1795
+ * you will not be able to issue further commands.
1790
1796
  */
1791
1797
  static VALUE
1792
1798
  pgconn_get_result(VALUE self)
@@ -1794,14 +1800,13 @@ pgconn_get_result(VALUE self)
1794
1800
  PGconn *conn = get_pgconn(self);
1795
1801
  PGresult *result;
1796
1802
  VALUE rb_pgresult;
1797
-
1803
+
1798
1804
  result = PQgetResult(conn);
1799
1805
  if(result == NULL)
1800
1806
  return Qnil;
1801
1807
  rb_pgresult = new_pgresult(result);
1802
- pgresult_check(self, rb_pgresult);
1803
1808
  if (rb_block_given_p()) {
1804
- return rb_ensure(yield_pgresult, rb_pgresult,
1809
+ return rb_ensure(yield_pgresult, rb_pgresult,
1805
1810
  pgresult_clear, rb_pgresult);
1806
1811
  }
1807
1812
  return rb_pgresult;
@@ -2461,8 +2466,9 @@ pgconn_get_last_result(VALUE self)
2461
2466
  while((result = pgconn_get_result(self)) != Qnil) {
2462
2467
  ret = result;
2463
2468
  }
2469
+ pgresult_check(self, ret);
2464
2470
  return ret;
2465
- }
2471
+ }
2466
2472
 
2467
2473
 
2468
2474
  /*
@@ -75,6 +75,7 @@ describe PGconn do
75
75
 
76
76
  it "should not leave stale server connections after finish" do
77
77
  PGconn.connect(@conninfo).finish
78
+ sleep 0.5
78
79
  res = @conn.exec(%[SELECT COUNT(*) AS n FROM pg_stat_activity
79
80
  WHERE usename IS NOT NULL])
80
81
  # there's still the global @conn, but should be no more
@@ -102,9 +103,8 @@ describe PGconn do
102
103
  error = false
103
104
  @conn.send_query("SELECT pg_sleep(1000)")
104
105
  @conn.cancel
105
- begin
106
- tmpres = @conn.get_result
107
- rescue PGError => e
106
+ tmpres = @conn.get_result
107
+ if(tmpres.result_status != PGresult::PGRES_TUPLES_OK)
108
108
  error = true
109
109
  end
110
110
  error.should == true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9.2008.08.17
4
+ version: 0.7.9.2008.10.05
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2008-08-17 00:00:00 -07:00
16
+ date: 2008-10-05 00:00:00 -07:00
17
17
  default_executable:
18
18
  dependencies: []
19
19
 
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - PostgreSQL libpq library and headers
69
69
  rubyforge_project: ruby-pg
70
- rubygems_version: 1.1.1
70
+ rubygems_version: 1.2.0
71
71
  signing_key:
72
72
  specification_version: 2
73
73
  summary: Ruby extension library providing an API to PostgreSQL