postgres 0.7.9.2008.01.03 → 0.7.9.2008.01.09

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -59,27 +59,55 @@ For example:
59
59
  ruby extconf.rb --with-pgsql-include=/usr/local/pgsql/include \
60
60
  --with-pgsql-lib=/usr/local/pgsql/lib
61
61
 
62
- - How to use ?
63
-
64
- You need to specify:
62
+ - Modules
65
63
 
66
- require 'pg' or
67
- require 'postgres'
64
+ 'pg': The 'pg' module is the newer module, that has been greatly improved, and
65
+ is almost a complete rewrite. It is not backwards compatible. Use this module
66
+ for newly written code. It should be more stable, less buggy, and has more
67
+ features.
68
68
 
69
- These are two different modules, with important differences.
69
+ 'postgres': Older module, maintained for backwards compatibility. It
70
+ has known flaws that aren't reasonably fixable without breaking backwards
71
+ compatibility. Use this module if you have code that already works, and
72
+ you just want the fixes that I've committed to this module (for instance,
73
+ this module is compatible with PostgreSQL 8.3).
70
74
 
71
- The 'postgres' module is the older module, maintained for backwards
72
- compatibility. It has known flaws that aren't reasonably fixable without
73
- breaking backwards compatibility. Use this module if you have code that
74
- already works, and you just want the fixes that I've committed to this
75
- module (for instance, this module is compatible with PostgreSQL 8.3).
76
-
77
- The 'pg' module is the newer module, that has been greatly improved, and
78
- is almost a complete rewrite. It is not backwards compatible. Use this module
79
- for newly written code. It should be more stable, less buggy, and has more
80
- features.
75
+ - How to use ?
81
76
 
82
- See the RDoc documentation for detailed usage instructions.
77
+ This gem builds and installs two PostgreSQL database adapters, 'postgres'
78
+ and 'pg'. 'postgres' is currently (Jan 2008) the recommended PostgreSQL
79
+ adapter for use with Rails.
80
+
81
+ The standard way to download and install the most current stable
82
+ version of the postgres gem (from http://gems.rubyforge.org) is to use
83
+ the RubyGem package manager. You may need to supply RubyGem with the
84
+ location of the libpq library and the libpq.h and libpq/libpq-fs.h
85
+ files, and may need to run as root.
86
+ If you installed from source on a Unix system you can locate these
87
+ libpq files with:
88
+ find <path to install directory> -name "libpq-fe.h" -print
89
+ With binary distributions, you may need to install additional
90
+ PostgreSQL development libraries to get these files.
91
+
92
+ Then run:
93
+ sudo gem install postgres -- --with-pgsql-include-dir=<location of
94
+ Postgresql>/include --with-pgsql-lib-dir=<location of Postgresql/lib
95
+
96
+ Example:
97
+ on Mac OS X with PostgreSQL in /Library/PostgreSQL8 use
98
+ --with-pgsql-include-dir=/Library/PostgreSQL8/include --with-pgsql-lib-
99
+ dir=/Library/PostgreSQL8/lib
100
+
101
+ To use the postgres adapter with Rails:
102
+ refer to it as
103
+ adapter: postgresql
104
+ in your database:yaml file
105
+
106
+ The pg adapter cannot be used with Rails yet and is available for
107
+ testing and developer use.
108
+
109
+ To use these modules in Ruby directly (not Rails), refer to the RDoc
110
+ documentation.
83
111
 
84
112
  - Acknowledgments
85
113
 
data/ext/extconf.rb CHANGED
@@ -19,33 +19,16 @@ end
19
19
 
20
20
  dir_config('pgsql', config_value('include'), config_value('lib'))
21
21
 
22
- desired_functions = %w(
23
- PQsetClientEncoding
24
- PQfreemem
25
- PQescapeStringConn
26
- PQprepare
27
- PQescapeString
28
- PQexecParams
29
- PQconnectionUsedPassword
30
- PQisthreadsafe
31
- PQnparams
32
- PQparamtype
33
- PQsendDescribePrepared
34
- PQsendDescribePortal
35
- PQsendPrepare
36
- PQencryptPassword
37
- PQdescribePrepared
38
- PQdescribePortal
39
- lo_create
40
- lo_truncate
41
- pg_encoding_to_char
42
- )
22
+ required_libraries = []
23
+ desired_functions = %w(PQsetClientEncoding pg_encoding_to_char PQfreemem PQserverVersion)
24
+ compat_functions = %w(PQescapeString PQexecParams)
43
25
 
44
26
  if have_build_env
27
+ required_libraries.each(&method(:have_library))
45
28
  desired_functions.each(&method(:have_func))
46
- $OBJS = ['pg.o','compat.o']
47
- $CFLAGS << ' -Wall -Wmissing-prototypes'
48
- create_makefile("pg")
29
+ $objs = ['postgres.o','libpq-compat.o'] if compat_functions.all?(&method(:have_func))
30
+ $CFLAGS << ' -Wall '
31
+ create_makefile("postgres")
49
32
  else
50
33
  puts 'Could not find PostgreSQL build environment (libraries & headers): Makefile not created'
51
34
  end
File without changes
@@ -15,14 +15,16 @@
15
15
  #include "ruby.h"
16
16
  #include "rubyio.h"
17
17
 
18
- #if RUBY_VM == 1
19
- /* ruby 1.9 */
20
- #include "ruby/st.h"
21
- #include "ruby/intern.h"
22
- #else
23
- /* ruby 1.8 */
18
+ #if RUBY_VM != 1
19
+ #define RUBY_18_COMPAT
20
+ #endif
21
+
22
+ #ifdef RUBY_18_COMPAT
24
23
  #include "st.h"
25
24
  #include "intern.h"
25
+ #else
26
+ #include "ruby/st.h"
27
+ #include "ruby/intern.h"
26
28
  #endif
27
29
 
28
30
  /* grep '^#define' $(pg_config --includedir)/server/catalog/pg_type.h | grep OID */
@@ -53,14 +55,6 @@ PQserverVersion(const PGconn *conn)
53
55
  #define RSTRING_PTR(x) RSTRING((x))->ptr
54
56
  #endif /* RSTRING_PTR */
55
57
 
56
- #if RUBY_VM == 1
57
- /* ruby 1.9 */
58
- #define RB_REG_NEW(s, len, opt) rb_reg_new(rb_str_new((s),(len)), opt)
59
- #else
60
- /* ruby 1.8 */
61
- #define RB_REG_NEW(s, len, opt) rb_reg_new((s), (len), (opt))
62
- #endif
63
-
64
58
  #ifndef HAVE_PG_ENCODING_TO_CHAR
65
59
  #define pg_encoding_to_char(x) "SQL_ASCII"
66
60
  #endif
@@ -925,7 +919,6 @@ pgconn_get_notify(obj)
925
919
  return ary;
926
920
  }
927
921
 
928
- static VALUE pg_escape_regex;
929
922
  static VALUE pg_escape_str;
930
923
  static ID pg_gsub_bang_id;
931
924
 
@@ -980,7 +973,8 @@ pgconn_insert_table(obj, table, values)
980
973
  rb_str_cat(buffer, "\\N",2);
981
974
  } else {
982
975
  s = rb_obj_as_string(row->ptr[j]);
983
- rb_funcall(s,pg_gsub_bang_id,2,pg_escape_regex,pg_escape_str);
976
+ rb_funcall(s,pg_gsub_bang_id,2,
977
+ rb_str_new("([\\t\\n\\\\])", 10),pg_escape_str);
984
978
  rb_str_cat(buffer, StringValuePtr(s), RSTRING_LEN(s));
985
979
  }
986
980
  }
@@ -2617,8 +2611,6 @@ void
2617
2611
  Init_postgres()
2618
2612
  {
2619
2613
  pg_gsub_bang_id = rb_intern("gsub!");
2620
- pg_escape_regex = RB_REG_NEW("([\\t\\n\\\\])", 10, 0);
2621
- rb_global_variable(&pg_escape_regex);
2622
2614
  pg_escape_str = rb_str_new("\\\\\\1", 4);
2623
2615
  rb_global_variable(&pg_escape_str);
2624
2616
 
File without changes
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: postgres
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.9.2008.01.03
7
- date: 2008-01-03 00:00:00 -08:00
6
+ version: 0.7.9.2008.01.09
7
+ date: 2008-01-09 00:00:00 -08:00
8
8
  summary: Ruby extension library providing an API to PostgreSQL
9
9
  require_paths:
10
10
  - lib
@@ -39,24 +39,19 @@ files:
39
39
  - GPL
40
40
  - LICENSE
41
41
  - README
42
- - ext/compat.c
43
- - ext/compat.h
44
- - ext/pg.h
45
- - ext/pg.c
46
- - compat-ruby-postgres/libpq-compat.c
47
- - compat-ruby-postgres/type-oids.h
48
- - compat-ruby-postgres/postgres.c
42
+ - ext/libpq-compat.c
43
+ - ext/type-oids.h
44
+ - ext/postgres.c
49
45
  test_files: []
50
46
 
51
47
  rdoc_options: []
52
48
 
53
- extra_rdoc_files: []
54
-
49
+ extra_rdoc_files:
50
+ - ext/postgres.c
55
51
  executables: []
56
52
 
57
53
  extensions:
58
54
  - ext/extconf.rb
59
- - compat-ruby-postgres/extconf.rb
60
55
  requirements:
61
56
  - PostgreSQL libpq library and headers
62
57
  dependencies: []
@@ -1,34 +0,0 @@
1
- if RUBY_VERSION < '1.3'
2
- puts 'This library is for ruby-1.3 or higher.'
3
- exit 1
4
- end
5
-
6
- require 'mkmf'
7
-
8
- def config_value(type)
9
- ENV["POSTGRES_#{type.upcase}"] || pg_config(type)
10
- end
11
-
12
- def pg_config(type)
13
- IO.popen("pg_config --#{type}dir").readline.chomp rescue nil
14
- end
15
-
16
- def have_build_env
17
- have_library('pq') && have_header('libpq-fe.h') && have_header('libpq/libpq-fs.h')
18
- end
19
-
20
- dir_config('pgsql', config_value('include'), config_value('lib'))
21
-
22
- required_libraries = []
23
- desired_functions = %w(PQsetClientEncoding pg_encoding_to_char PQfreemem PQserverVersion)
24
- compat_functions = %w(PQescapeString PQexecParams)
25
-
26
- if have_build_env
27
- required_libraries.each(&method(:have_library))
28
- desired_functions.each(&method(:have_func))
29
- $objs = ['postgres.o','libpq-compat.o'] if compat_functions.all?(&method(:have_func))
30
- $CFLAGS << ' -Wall '
31
- create_makefile("postgres")
32
- else
33
- puts 'Could not find PostgreSQL build environment (libraries & headers): Makefile not created'
34
- end