swift-db-postgres 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.1.1 (2012-07-26)
2
+
3
+ * Updated compile flags.
4
+
1
5
  == 0.1.0 (2012-07-20)
2
6
 
3
7
  * Initial version.
data/README.md CHANGED
@@ -21,6 +21,7 @@ MRI adapter for PostgreSQL
21
21
  #commit(savepoint = nil)
22
22
  #rollback(savepoint = nil)
23
23
  #transaction(savepoint = nil, &block)
24
+ #ping
24
25
  #close
25
26
  #closed?
26
27
  #escape(text)
@@ -114,6 +115,10 @@ Don't read too much into it. Each library has its advantages and disadvantages.
114
115
  * pg uses the pg_typecast extension
115
116
 
116
117
  ```
118
+ $ ruby -v
119
+
120
+ ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
121
+
117
122
  $ ruby check.rb
118
123
  user system total real
119
124
  do_postgres insert 0.190000 0.080000 0.270000 ( 0.587877)
@@ -40,8 +40,7 @@ VALUE db_postgres_adapter_deallocate(Adapter *a) {
40
40
  VALUE db_postgres_adapter_allocate(VALUE klass) {
41
41
  Adapter *a = (Adapter*)malloc(sizeof(Adapter));
42
42
 
43
- a->connection = 0;
44
- a->t_nesting = 0;
43
+ memset(a, 0, sizeof(Adapter));
45
44
  return Data_Wrap_Struct(klass, 0, db_postgres_adapter_deallocate, a);
46
45
  }
47
46
 
@@ -319,6 +318,11 @@ VALUE db_postgres_adapter_closed_q(VALUE self) {
319
318
  return a->connection ? Qfalse : Qtrue;
320
319
  }
321
320
 
321
+ VALUE db_postgres_adapter_ping(VALUE self) {
322
+ Adapter *a = db_postgres_adapter_handle(self);
323
+ return a->connection && PQstatus(a->connection) == CONNECTION_OK ? Qtrue : Qfalse;
324
+ }
325
+
322
326
  VALUE db_postgres_adapter_prepare(VALUE self, VALUE sql) {
323
327
  return db_postgres_statement_initialize(db_postgres_statement_allocate(cDPS), self, sql);
324
328
  }
@@ -569,6 +573,7 @@ void init_swift_db_postgres_adapter() {
569
573
  rb_define_method(cDPA, "transaction", db_postgres_adapter_transaction, -1);
570
574
  rb_define_method(cDPA, "close", db_postgres_adapter_close, 0);
571
575
  rb_define_method(cDPA, "closed?", db_postgres_adapter_closed_q, 0);
576
+ rb_define_method(cDPA, "ping", db_postgres_adapter_ping, 0);
572
577
  rb_define_method(cDPA, "escape", db_postgres_adapter_escape, 1);
573
578
  rb_define_method(cDPA, "fileno", db_postgres_adapter_fileno, 0);
574
579
  rb_define_method(cDPA, "query", db_postgres_adapter_query, -1);
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'mkmf'
4
4
 
5
- $CFLAGS = '-std=c99'
5
+ $CFLAGS = '-std=c99 -Os'
6
6
 
7
7
  inc_paths = %w(
8
8
  /usr/include/postgresql
data/test/test_adapter.rb CHANGED
@@ -49,9 +49,11 @@ require 'helper'
49
49
  end
50
50
 
51
51
  it 'should close handle' do
52
+ assert db.ping
52
53
  assert !db.closed?
53
54
  assert db.close
54
55
  assert db.closed?
56
+ assert !db.ping
55
57
 
56
58
  assert_raises(Swift::ConnectionError) { db.execute("select * from users") }
57
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swift-db-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-20 00:00:00.000000000 Z
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -36,12 +36,12 @@ extensions:
36
36
  extra_rdoc_files: []
37
37
  files:
38
38
  - ext/swift/db/postgres/datetime.c
39
+ - ext/swift/db/postgres/result.c
39
40
  - ext/swift/db/postgres/common.c
40
41
  - ext/swift/db/postgres/typecast.c
41
42
  - ext/swift/db/postgres/statement.c
42
43
  - ext/swift/db/postgres/adapter.c
43
44
  - ext/swift/db/postgres/main.c
44
- - ext/swift/db/postgres/result.c
45
45
  - ext/swift/db/postgres/typecast.h
46
46
  - ext/swift/db/postgres/common.h
47
47
  - ext/swift/db/postgres/datetime.h
@@ -50,10 +50,10 @@ files:
50
50
  - ext/swift/db/postgres/statement.h
51
51
  - ext/swift/db/postgres/extconf.rb
52
52
  - test/test_ssl.rb
53
+ - test/test_adapter.rb
53
54
  - test/test_encoding.rb
54
55
  - test/helper.rb
55
56
  - test/test_async.rb
56
- - test/test_adapter.rb
57
57
  - lib/swift/db/postgres.rb
58
58
  - lib/swift-db-postgres.rb
59
59
  - README.md