do_postgres 0.10.0-x86-mingw32 → 0.10.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/ChangeLog.markdown +22 -0
  2. data/LICENSE +1 -1
  3. data/README.markdown +106 -3
  4. data/Rakefile +56 -9
  5. data/ext/do_postgres/compat.h +55 -0
  6. data/ext/{do_postgres_ext/do_postgres_ext.c → do_postgres/do_postgres.c} +42 -49
  7. data/ext/{do_postgres_ext → do_postgres}/error.h +0 -0
  8. data/ext/{do_postgres_ext → do_postgres}/extconf.rb +4 -3
  9. data/ext/{do_postgres_ext → do_postgres}/pg_config.h +0 -0
  10. data/lib/do_postgres.rb +12 -16
  11. data/lib/do_postgres/1.8/do_postgres.so +0 -0
  12. data/lib/do_postgres/1.9/do_postgres.so +0 -0
  13. data/lib/do_postgres/version.rb +1 -1
  14. data/spec/command_spec.rb +2 -2
  15. data/spec/connection_spec.rb +22 -7
  16. data/spec/encoding_spec.rb +2 -1
  17. data/spec/reader_spec.rb +1 -1
  18. data/spec/result_spec.rb +12 -13
  19. data/spec/spec_helper.rb +27 -36
  20. data/spec/typecast/array_spec.rb +1 -1
  21. data/spec/typecast/bigdecimal_spec.rb +2 -2
  22. data/spec/typecast/boolean_spec.rb +2 -2
  23. data/spec/typecast/byte_array_spec.rb +1 -1
  24. data/spec/typecast/class_spec.rb +1 -1
  25. data/spec/typecast/date_spec.rb +2 -2
  26. data/spec/typecast/datetime_spec.rb +2 -2
  27. data/spec/typecast/float_spec.rb +2 -2
  28. data/spec/typecast/integer_spec.rb +1 -1
  29. data/spec/typecast/nil_spec.rb +3 -3
  30. data/spec/typecast/other_spec.rb +8 -0
  31. data/spec/typecast/range_spec.rb +1 -1
  32. data/spec/typecast/string_spec.rb +1 -1
  33. data/spec/typecast/time_spec.rb +1 -1
  34. data/tasks/compile.rake +81 -0
  35. data/tasks/release.rake +12 -71
  36. data/tasks/retrieve.rake +5 -9
  37. data/tasks/spec.rake +19 -15
  38. metadata +76 -39
  39. data/HISTORY.markdown +0 -12
  40. data/Manifest.txt +0 -34
  41. data/lib/do_postgres_ext.so +0 -0
  42. data/spec/lib/rspec_immediate_feedback_formatter.rb +0 -3
  43. data/tasks/gem.rake +0 -8
  44. data/tasks/install.rake +0 -15
  45. data/tasks/native.rake +0 -35
@@ -0,0 +1,22 @@
1
+ ## 0.10.1 (unreleased, in git)
2
+
3
+ * Support for Ruby 1.8 and 1.9 on Windows.
4
+ * Switch to Jeweler for Gem building tasks (this change may be temporary).
5
+ * Switch to using Bacon for running specs: This should make specs friendlier to
6
+ new Ruby implementations that are not yet 100% MRI-compatible, and in turn,
7
+ prepared the road for our own IronRuby and MacRuby support.
8
+ * Switch to the newly added rake-compiler `JavaExtensionTask` for compiling
9
+ JRuby extensions, instead of our (broken) home-grown solution.
10
+
11
+ ## 0.9.12 2009-05-17
12
+ * Improvements
13
+ * Windows support
14
+
15
+ ## 0.9.11 2009-01-19
16
+ * Improvements
17
+ * Ruby 1.9 support
18
+ * Fixes
19
+ * Fix build issue on certain platforms introduces with 0.9.10
20
+
21
+ ## 0.9.9 2008-11-27
22
+ * No changes since 0.9.8
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007, 2008, 2009 Yehuda Katz, Dirkjan Bussink
1
+ Copyright (c) 2007 - 2010 Yehuda Katz, Dirkjan Bussink
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -1,4 +1,107 @@
1
- do_postgres
2
- ===========
1
+ # do_postgres
3
2
 
4
- A PostgreSQL driver for DataObjects
3
+ * <http://dataobjects.info>
4
+
5
+ ## Description
6
+
7
+ A PostgreSQL driver for DataObjects.
8
+
9
+ ## Features/Problems
10
+
11
+ This driver implements the DataObjects API for the PostgreSQL relational database.
12
+
13
+ ## Synopsis
14
+
15
+ An example of usage:
16
+
17
+ # default user (postgres, postgres), default port (5432)
18
+ DataObjects::Connection.new("postgres://host/database")
19
+ # specified user, specified port
20
+ DataObjects::Connection.new("postgres://user:pass@host:8888/database")
21
+
22
+ @connection = DataObjects::Connection.new("postgres://localhost/employees")
23
+ @reader = @connection.create_command('SELECT * FROM users').execute_reader
24
+ @reader.next!
25
+
26
+ In the future, the `Connection` constructor will be able to be passed either a
27
+ DataObjects-style URL or JDBC style URL, when using do\_postgres on JRuby.
28
+ However, this feature is not currently working reliably and is a known issue.
29
+
30
+ ## Requirements
31
+
32
+ This driver is provided for the following platforms:
33
+ * Ruby MRI (1.8.6/7), 1.9: tested on Linux, Mac OS X and Windows platforms.
34
+ * JRuby 1.3.1 + (1.4+ recommended).
35
+ * Rubinius (experimental).
36
+
37
+ Additionally you should have the following prerequisites:
38
+ * `data_objects` gem
39
+ * `do_jdbc` gem (shared library), if running on JRuby.
40
+
41
+ ## Install
42
+
43
+ To install the gem:
44
+
45
+ gem install do_postgres
46
+
47
+ To compile and install from source:
48
+
49
+ * Install rake-compiler: `gem install rake-compiler`.
50
+
51
+ * For MRI/Rubinius extensions:
52
+ * Install the `gcc` compiler. On OS X, you should install XCode tools. On
53
+ Ubuntu, run `apt-get install build-essential`.
54
+ * Install Ruby and PostgreSQL client.
55
+ * Install the Ruby and PostgreSQL development headers.
56
+ * On Debian-Linux distributions, you can install the following packages
57
+ with `apt`: `ruby-dev` `libpostgresql-dev`.
58
+ * If you want to cross-compile for Windows:
59
+ * Install MinGW:
60
+ * On Debian-Linux distributions, you can install the following package
61
+ with `apt`: `mingw32`.
62
+ * On OS X, this can install the following package with MacPorts: `i386-mingw32-gcc`.
63
+ * Run `rake-compiler cross-ruby`.
64
+ * Run `rake-compiler update-config`.
65
+
66
+ * For JRuby extensions:
67
+ * Install the Java Development Kit (provided if you are
68
+ on a recent version of Mac OS X) from <http://java.sun.com>.
69
+ * Install a recent version of JRuby. Ensure `jruby` is in your `PATH` and/or
70
+ you have configured the `JRUBY_HOME` environment variable to point to your
71
+ JRuby installation.
72
+ * Install `data_objects` and `do_jdbc` with `jruby -S rake install`.
73
+
74
+ * Then, install this driver with `(jruby -S) rake install`.
75
+
76
+ For more information, see the PostgreSQL driver wiki page:
77
+ <http://wiki.github.com/datamapper/do/postgresql>.
78
+
79
+ ## Developers
80
+
81
+ Follow the above installation instructions. Additionally, you'll need:
82
+ * `bacon` gem for running specs.
83
+ * `YARD` gem for generating documentation.
84
+
85
+ See the DataObjects wiki for more comprehensive information on installing and
86
+ contributing to the JRuby-variant of this driver:
87
+ <http://wiki.github.com/datamapper/do/jruby>.
88
+
89
+ To run specs:
90
+
91
+ rake spec
92
+
93
+ To run specs without compiling extensions first:
94
+
95
+ rake spec_no_compile
96
+
97
+ To run individual specs:
98
+
99
+ rake spec TEST=spec/connection_spec.rb
100
+
101
+ (Note that the `rake` task uses a `TEST` parameter, not `SPEC`. This is because
102
+ the `Rake::TestTask` is used for executing the Bacon specs).
103
+
104
+ ## License
105
+
106
+ This code is licensed under an **MIT (X11) License**. Please see the
107
+ accompanying `LICENSE` file.
data/Rakefile CHANGED
@@ -1,16 +1,63 @@
1
+ require 'pathname'
1
2
  require 'rubygems'
2
3
  require 'rake'
3
4
  require 'rake/clean'
4
5
 
5
- require 'pathname'
6
- require 'lib/do_postgres/version'
6
+ ROOT = Pathname(__FILE__).dirname.expand_path
7
+
8
+ require ROOT + 'lib/do_postgres/version'
9
+
10
+ JRUBY = RUBY_PLATFORM =~ /java/
11
+ IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
12
+ WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
13
+ SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
14
+ BINARY_VERSION = '8.3.9'
15
+
16
+ CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_postgres/Makefile ext-java/target ])
17
+
18
+ begin
19
+ gem 'jeweler', '~> 1.4'
20
+ require 'jeweler'
21
+
22
+ Jeweler::Tasks.new do |gem|
23
+ gem.name = 'do_postgres'
24
+ gem.version = DataObjects::Postgres::VERSION
25
+ gem.summary = 'DataObjects PostgreSQL Driver'
26
+ gem.description = 'Implements the DataObjects API for PostgreSQL'
27
+ gem.platform = Gem::Platform::RUBY
28
+ gem.files = Dir['lib/**/*.rb', 'spec/**/*.rb', 'tasks/**/*.rake',
29
+ 'ext/**/*.{rb,c,h}', 'LICENSE', 'Rakefile',
30
+ '*.{markdown,rdoc,txt,yml}']
31
+ gem.extra_rdoc_files = FileList['README*', 'ChangeLog*', 'LICENSE']
32
+ gem.test_files = FileList['spec/**/*.rb']
33
+
34
+ # rake-compiler should generate gemspecs for other platforms (e.g. 'java')
35
+ # and modify dependencies and extensions appropriately
36
+ gem.extensions << 'ext/do_postgres/extconf.rb'
37
+
38
+ gem.add_dependency 'data_objects', DataObjects::Postgres::VERSION
39
+
40
+ gem.add_development_dependency 'bacon', '~>1.1'
41
+ gem.add_development_dependency 'rake-compiler', '~>0.7'
42
+
43
+ gem.has_rdoc = false
44
+ gem.rubyforge_project = 'dorb'
45
+ gem.authors = [ 'Dirkjan Bussink' ]
46
+ gem.email = 'd.bussink@gmail.com'
47
+ end
7
48
 
8
- ROOT = Pathname(__FILE__).dirname.expand_path
9
- JRUBY = RUBY_PLATFORM =~ /java/
10
- WINDOWS = Gem.win_platform?
11
- SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
12
- BINARY_VERSION = '5.0.77'
49
+ if JRUBY
50
+ Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build')
51
+ Rake::Task['install'].clear_actions if Rake::Task.task_defined?('install')
52
+ task :build => [ :java, :gem ]
53
+ task :install do
54
+ sh "#{Config::CONFIG['RUBY_INSTALL_NAME']} -S gem install pkg/do_postgres-#{DataObjects::Postgres::VERSION}-java.gem"
55
+ end
56
+ end
13
57
 
14
- Dir['tasks/*.rake'].sort.each { |f| import f }
58
+ Jeweler::GemcutterTasks.new
15
59
 
16
- CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_postgres_ext/Makefile ext-java/target ])
60
+ FileList['tasks/**/*.rake'].each { |task| import task }
61
+ rescue LoadError
62
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
63
+ end
@@ -0,0 +1,55 @@
1
+ #ifndef RUBY_COMPAT_H
2
+ #define RUBY_COMPAT_H
3
+
4
+ /*
5
+ * Rules for better ruby C extensions:
6
+ *
7
+ * Never use the R<TYPE> macros directly, always use R<TYPE>_<FIELD>
8
+ *
9
+ * Never compare with RBASIC(obj)->klass, always use
10
+ * rb_obj_is_instance_of()
11
+ *
12
+ * Never use RHASH(obj)->tbl or RHASH_TBL().
13
+ *
14
+ */
15
+
16
+
17
+ // Array
18
+ #ifndef RARRAY_PTR
19
+ #define RARRAY_PTR(obj) RARRAY(obj)->ptr
20
+ #endif
21
+
22
+ #ifndef RARRAY_LEN
23
+ #define RARRAY_LEN(obj) RARRAY(obj)->len
24
+ #endif
25
+
26
+ // String
27
+ #ifndef RSTRING_PTR
28
+ #define RSTRING_PTR(obj) RSTRING(obj)->ptr
29
+ #endif
30
+
31
+ #ifndef RSTRING_LEN
32
+ #define RSTRING_LEN(obj) RSTRING(obj)->len
33
+ #endif
34
+
35
+ #ifndef rb_str_ptr
36
+ #define rb_str_ptr(str) RSTRING_PTR(str)
37
+ #endif
38
+
39
+ #ifndef rb_str_ptr_readonly
40
+ #define rb_str_ptr_readonly(str) RSTRING_PTR(str)
41
+ #endif
42
+
43
+ #ifndef rb_str_flush
44
+ #define rb_str_flush(str)
45
+ #endif
46
+
47
+ #ifndef rb_str_update
48
+ #define rb_str_update(str)
49
+ #endif
50
+
51
+ #ifndef rb_str_len
52
+ #define rb_str_len(str) RSTRING_LEN(str)
53
+ #endif
54
+
55
+ #endif
@@ -15,6 +15,10 @@
15
15
  /* On Windows this stuff is also defined by Postgres, but we don't
16
16
  want to use Postgres' version actually */
17
17
  #undef fsync
18
+ #undef ftruncate
19
+ #undef fseeko
20
+ #undef ftello
21
+ #undef stat
18
22
  #undef vsnprintf
19
23
  #undef snprintf
20
24
  #undef sprintf
@@ -32,6 +36,7 @@
32
36
  #include <ctype.h>
33
37
  #include <time.h>
34
38
  #include "error.h"
39
+ #include "compat.h"
35
40
 
36
41
  #define ID_CONST_GET rb_intern("const_get")
37
42
  #define ID_PATH rb_intern("path")
@@ -40,20 +45,6 @@
40
45
 
41
46
  #define CONST_GET(scope, constant) (rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant)))
42
47
  #define POSTGRES_CLASS(klass, parent) (rb_define_class_under(mPostgres, klass, parent))
43
- #define DEBUG(value) data_objects_debug(value)
44
- #define RUBY_CLASS(name) rb_const_get(rb_cObject, rb_intern(name))
45
-
46
- #ifndef RSTRING_PTR
47
- #define RSTRING_PTR(s) (RSTRING(s)->ptr)
48
- #endif
49
-
50
- #ifndef RSTRING_LEN
51
- #define RSTRING_LEN(s) (RSTRING(s)->len)
52
- #endif
53
-
54
- #ifndef RARRAY_LEN
55
- #define RARRAY_LEN(a) RARRAY(a)->len
56
- #endif
57
48
 
58
49
  #ifdef HAVE_RUBY_ENCODING_H
59
50
  #include <ruby/encoding.h>
@@ -122,8 +113,8 @@ static void data_objects_debug(VALUE string, struct timeval* start) {
122
113
  struct timeval stop;
123
114
  char *message;
124
115
 
125
- char *query = RSTRING_PTR(string);
126
- int length = RSTRING_LEN(string);
116
+ const char *query = rb_str_ptr_readonly(string);
117
+ size_t length = rb_str_len(string);
127
118
  char total_time[32];
128
119
  do_int64 duration = 0;
129
120
 
@@ -142,9 +133,9 @@ static void data_objects_debug(VALUE string, struct timeval* start) {
142
133
  }
143
134
  }
144
135
 
145
- static char * get_uri_option(VALUE query_hash, char * key) {
136
+ static const char * get_uri_option(VALUE query_hash, const char * key) {
146
137
  VALUE query_value;
147
- char * value = NULL;
138
+ const char * value = NULL;
148
139
 
149
140
  if(!rb_obj_is_kind_of(query_hash, rb_cHash)) { return NULL; }
150
141
 
@@ -178,7 +169,7 @@ static int jd_from_date(int year, int month, int day) {
178
169
  }
179
170
  a = year / 100;
180
171
  b = 2 - a + (a / 4);
181
- return floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524;
172
+ return (int) (floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524);
182
173
  }
183
174
 
184
175
  static VALUE parse_date(const char *date) {
@@ -268,8 +259,8 @@ static VALUE parse_date_time(const char *date) {
268
259
  if ( is_dst > 0 )
269
260
  gmt_offset -= is_dst;
270
261
 
271
- hour_offset = -(gmt_offset / 3600);
272
- minute_offset = -(gmt_offset % 3600 / 60);
262
+ hour_offset = -((int)gmt_offset / 3600);
263
+ minute_offset = -((int)gmt_offset % 3600 / 60);
273
264
 
274
265
  } else {
275
266
  // Something went terribly wrong
@@ -315,7 +306,7 @@ static VALUE parse_time(const char *date) {
315
306
  // right padding usec with 0. e.g. '012' will become 12000 microsecond, since Time#local use microsecond
316
307
  sscanf(date, "%4d-%2d-%2d %2d:%2d:%2d.%s", &year, &month, &day, &hour, &min, &sec, subsec);
317
308
  usec = atoi(subsec);
318
- usec *= pow(10, (6 - strlen(subsec)));
309
+ usec *= (int) pow(10, (6 - strlen(subsec)));
319
310
  } else {
320
311
  tokens = sscanf(date, "%4d-%2d-%2d %2d:%2d:%2d", &year, &month, &day, &hour, &min, &sec);
321
312
  if (tokens == 3) {
@@ -384,7 +375,7 @@ static VALUE typecast(const char *value, long length, const VALUE type, int enco
384
375
  PQfreemem(unescaped);
385
376
  return byte_array;
386
377
  } else if (type == rb_cClass) {
387
- return rb_funcall(rb_cObject, rb_intern("full_const_get"), 1, rb_str_new(value, length));
378
+ return rb_funcall(mDO, rb_intern("full_const_get"), 1, rb_str_new(value, length));
388
379
  } else if (type == rb_cObject) {
389
380
  return rb_marshal_load(rb_str_new(value, length));
390
381
  } else if (type == rb_cNilClass) {
@@ -498,11 +489,11 @@ static VALUE build_query_from_args(VALUE klass, int count, VALUE *args[]) {
498
489
  static VALUE cConnection_quote_string(VALUE self, VALUE string) {
499
490
  PGconn *db = DATA_PTR(rb_iv_get(self, "@connection"));
500
491
 
501
- const char *source = RSTRING_PTR(string);
502
- int source_len = RSTRING_LEN(string);
492
+ const char *source = rb_str_ptr_readonly(string);
493
+ size_t source_len = rb_str_len(string);
503
494
 
504
495
  char *escaped;
505
- int quoted_length = 0;
496
+ size_t quoted_length = 0;
506
497
  VALUE result;
507
498
 
508
499
  // Allocate space for the escaped version of 'string'
@@ -524,8 +515,8 @@ static VALUE cConnection_quote_string(VALUE self, VALUE string) {
524
515
  static VALUE cConnection_quote_byte_array(VALUE self, VALUE string) {
525
516
  PGconn *db = DATA_PTR(rb_iv_get(self, "@connection"));
526
517
 
527
- const unsigned char *source = (unsigned char*) RSTRING_PTR(string);
528
- size_t source_len = RSTRING_LEN(string);
518
+ const unsigned char *source = (unsigned char*) rb_str_ptr_readonly(string);
519
+ size_t source_len = rb_str_len(string);
529
520
 
530
521
  unsigned char *escaped;
531
522
  unsigned char *escaped_quotes;
@@ -563,6 +554,8 @@ static PGresult* cCommand_execute_sync(VALUE self, PGconn *db, VALUE query) {
563
554
 
564
555
  response = PQexec(db, str);
565
556
 
557
+ data_objects_debug(query, &start);
558
+
566
559
  if (response == NULL) {
567
560
  if(PQstatus(db) != CONNECTION_OK) {
568
561
  PQreset(db);
@@ -580,7 +573,6 @@ static PGresult* cCommand_execute_sync(VALUE self, PGconn *db, VALUE query) {
580
573
  }
581
574
  }
582
575
 
583
- data_objects_debug(query, &start);
584
576
  return response;
585
577
  }
586
578
  #else
@@ -611,13 +603,15 @@ static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) {
611
603
  }
612
604
 
613
605
  if(!retval) {
614
- rb_raise(eConnectionError, PQerrorMessage(db));
606
+ rb_raise(eConnectionError, "%s", PQerrorMessage(db));
615
607
  }
616
608
  }
617
609
 
618
610
  gettimeofday(&start, NULL);
619
611
  socket_fd = PQsocket(db);
620
612
 
613
+ data_objects_debug(query, &start);
614
+
621
615
  for(;;) {
622
616
  FD_ZERO(&rset);
623
617
  FD_SET(socket_fd, &rset);
@@ -631,7 +625,7 @@ static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) {
631
625
  }
632
626
 
633
627
  if (PQconsumeInput(db) == 0) {
634
- rb_raise(eConnectionError, PQerrorMessage(db));
628
+ rb_raise(eConnectionError, "%s", PQerrorMessage(db));
635
629
  }
636
630
 
637
631
  if (PQisBusy(db) == 0) {
@@ -639,7 +633,6 @@ static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) {
639
633
  }
640
634
  }
641
635
 
642
- data_objects_debug(query, &start);
643
636
  return PQgetResult(db);
644
637
  }
645
638
  #endif
@@ -698,14 +691,14 @@ static void full_connect(VALUE self, PGconn *db) {
698
691
 
699
692
  PGresult *result = NULL;
700
693
  VALUE r_host, r_user, r_password, r_path, r_port, r_query, r_options;
701
- char *host = NULL, *user = NULL, *password = NULL, *path;
702
- char *database = "", *port = "5432";
694
+ char *host = NULL, *user = NULL, *password = NULL, *path = NULL, *database = NULL;
695
+ const char *port = "5432";
703
696
  VALUE encoding = Qnil;
704
- char *search_path = NULL;
697
+ const char *search_path = NULL;
705
698
  char *search_path_query = NULL;
706
- char *backslash_off = "SET backslash_quote = off";
707
- char *standard_strings_on = "SET standard_conforming_strings = on";
708
- char *warning_messages = "SET client_min_messages = warning";
699
+ const char *backslash_off = "SET backslash_quote = off";
700
+ const char *standard_strings_on = "SET standard_conforming_strings = on";
701
+ const char *warning_messages = "SET client_min_messages = warning";
709
702
 
710
703
  if((r_host = rb_iv_get(self, "@host")) != Qnil) {
711
704
  host = StringValuePtr(r_host);
@@ -747,7 +740,7 @@ static void full_connect(VALUE self, PGconn *db) {
747
740
  );
748
741
 
749
742
  if ( PQstatus(db) == CONNECTION_BAD ) {
750
- rb_raise(eConnectionError, PQerrorMessage(db));
743
+ rb_raise(eConnectionError, "%s", PQerrorMessage(db));
751
744
  }
752
745
 
753
746
  if (search_path != NULL) {
@@ -757,32 +750,32 @@ static void full_connect(VALUE self, PGconn *db) {
757
750
  result = cCommand_execute(self, db, r_query);
758
751
 
759
752
  if (PQresultStatus(result) != PGRES_COMMAND_OK) {
760
- free(search_path_query);
753
+ free((void *)search_path_query);
761
754
  raise_error(self, result, r_query);
762
755
  }
763
756
 
764
- free(search_path_query);
757
+ free((void *)search_path_query);
765
758
  }
766
759
 
767
760
  r_options = rb_str_new2(backslash_off);
768
761
  result = cCommand_execute(self, db, r_options);
769
762
 
770
763
  if (PQresultStatus(result) != PGRES_COMMAND_OK) {
771
- rb_warn(PQresultErrorMessage(result));
764
+ rb_warn("%s", PQresultErrorMessage(result));
772
765
  }
773
766
 
774
767
  r_options = rb_str_new2(standard_strings_on);
775
768
  result = cCommand_execute(self, db, r_options);
776
769
 
777
770
  if (PQresultStatus(result) != PGRES_COMMAND_OK) {
778
- rb_warn(PQresultErrorMessage(result));
771
+ rb_warn("%s", PQresultErrorMessage(result));
779
772
  }
780
773
 
781
774
  r_options = rb_str_new2(warning_messages);
782
775
  result = cCommand_execute(self, db, r_options);
783
776
 
784
777
  if (PQresultStatus(result) != PGRES_COMMAND_OK) {
785
- rb_warn(PQresultErrorMessage(result));
778
+ rb_warn("%s", PQresultErrorMessage(result));
786
779
  }
787
780
 
788
781
  encoding = rb_iv_get(self, "@encoding");
@@ -790,16 +783,16 @@ static void full_connect(VALUE self, PGconn *db) {
790
783
  #ifdef HAVE_PQSETCLIENTENCODING
791
784
  VALUE pg_encoding = rb_hash_aref(CONST_GET(mEncoding, "MAP"), encoding);
792
785
  if(pg_encoding != Qnil) {
793
- if(PQsetClientEncoding(db, RSTRING_PTR(pg_encoding))) {
794
- rb_raise(eConnectionError, "Couldn't set encoding: %s", RSTRING_PTR(encoding));
786
+ if(PQsetClientEncoding(db, rb_str_ptr_readonly(pg_encoding))) {
787
+ rb_raise(eConnectionError, "Couldn't set encoding: %s", rb_str_ptr_readonly(encoding));
795
788
  } else {
796
789
  #ifdef HAVE_RUBY_ENCODING_H
797
- rb_iv_set(self, "@encoding_id", INT2FIX(rb_enc_find_index(RSTRING_PTR(encoding))));
790
+ rb_iv_set(self, "@encoding_id", INT2FIX(rb_enc_find_index(rb_str_ptr_readonly(encoding))));
798
791
  #endif
799
792
  rb_iv_set(self, "@pg_encoding", pg_encoding);
800
793
  }
801
794
  } else {
802
- rb_warn("Encoding %s is not a known Ruby encoding for PostgreSQL\n", RSTRING_PTR(encoding));
795
+ rb_warn("Encoding %s is not a known Ruby encoding for PostgreSQL\n", rb_str_ptr_readonly(encoding));
803
796
  rb_iv_set(self, "@encoding", rb_str_new2("UTF-8"));
804
797
  #ifdef HAVE_RUBY_ENCODING_H
805
798
  rb_iv_set(self, "@encoding_id", INT2FIX(rb_enc_find_index("UTF-8")));
@@ -997,7 +990,7 @@ static VALUE cReader_field_count(VALUE self) {
997
990
  return rb_iv_get(self, "@field_count");
998
991
  }
999
992
 
1000
- void Init_do_postgres_ext() {
993
+ void Init_do_postgres() {
1001
994
  rb_require("date");
1002
995
  rb_require("bigdecimal");
1003
996