pg 0.12.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +2 -0
  3. data/BSDL +22 -0
  4. data/ChangeLog +1504 -11
  5. data/Contributors.rdoc +7 -0
  6. data/History.rdoc +181 -3
  7. data/LICENSE +12 -14
  8. data/Manifest.txt +29 -15
  9. data/{BSD → POSTGRES} +0 -0
  10. data/{README.OS_X.rdoc → README-OS_X.rdoc} +0 -0
  11. data/{README.windows.rdoc → README-Windows.rdoc} +0 -0
  12. data/README.ja.rdoc +10 -3
  13. data/README.rdoc +54 -28
  14. data/Rakefile +53 -26
  15. data/Rakefile.cross +235 -196
  16. data/ext/errorcodes.def +931 -0
  17. data/ext/errorcodes.rb +45 -0
  18. data/ext/errorcodes.txt +463 -0
  19. data/ext/extconf.rb +37 -7
  20. data/ext/gvl_wrappers.c +19 -0
  21. data/ext/gvl_wrappers.h +211 -0
  22. data/ext/pg.c +317 -4277
  23. data/ext/pg.h +124 -21
  24. data/ext/pg_connection.c +3642 -0
  25. data/ext/pg_errors.c +89 -0
  26. data/ext/pg_result.c +920 -0
  27. data/lib/pg/connection.rb +86 -0
  28. data/lib/pg/constants.rb +11 -0
  29. data/lib/pg/exceptions.rb +11 -0
  30. data/lib/pg/result.rb +16 -0
  31. data/lib/pg.rb +26 -43
  32. data/sample/array_insert.rb +20 -0
  33. data/sample/async_api.rb +21 -24
  34. data/sample/async_copyto.rb +2 -2
  35. data/sample/async_mixed.rb +56 -0
  36. data/sample/check_conn.rb +21 -0
  37. data/sample/copyfrom.rb +1 -1
  38. data/sample/copyto.rb +1 -1
  39. data/sample/cursor.rb +2 -2
  40. data/sample/disk_usage_report.rb +186 -0
  41. data/sample/issue-119.rb +94 -0
  42. data/sample/losample.rb +6 -6
  43. data/sample/minimal-testcase.rb +17 -0
  44. data/sample/notify_wait.rb +51 -22
  45. data/sample/pg_statistics.rb +294 -0
  46. data/sample/replication_monitor.rb +231 -0
  47. data/sample/test_binary_values.rb +4 -6
  48. data/sample/wal_shipper.rb +434 -0
  49. data/sample/warehouse_partitions.rb +320 -0
  50. data/spec/lib/helpers.rb +70 -23
  51. data/spec/pg/connection_spec.rb +1128 -0
  52. data/spec/{pgresult_spec.rb → pg/result_spec.rb} +142 -47
  53. data/spec/pg_spec.rb +44 -0
  54. data.tar.gz.sig +0 -0
  55. metadata +145 -100
  56. metadata.gz.sig +0 -0
  57. data/GPL +0 -340
  58. data/ext/compat.c +0 -541
  59. data/ext/compat.h +0 -184
  60. data/misc/openssl-pg-segfault.rb +0 -31
  61. data/sample/psql.rb +0 -1181
  62. data/sample/psqlHelp.rb +0 -158
  63. data/sample/test1.rb +0 -60
  64. data/sample/test2.rb +0 -44
  65. data/sample/test4.rb +0 -71
  66. data/spec/m17n_spec.rb +0 -151
  67. data/spec/pgconn_spec.rb +0 -643
data/ext/pg.h CHANGED
@@ -1,53 +1,156 @@
1
- #ifndef PG_H_C98VS4AD
2
- #define PG_H_C98VS4AD
3
-
4
- #include <stdio.h>
5
- #include <stdlib.h>
6
- #include <sys/types.h>
1
+ #ifndef __pg_h
2
+ #define __pg_h
7
3
 
8
4
  #ifdef RUBY_EXTCONF_H
9
- #include RUBY_EXTCONF_H
5
+ # include RUBY_EXTCONF_H
10
6
  #endif
11
7
 
12
- #ifdef HAVE_UNISTD_H
8
+ /* System headers */
9
+ #include <stdio.h>
10
+ #include <stdlib.h>
11
+ #include <sys/types.h>
12
+ #if defined(HAVE_UNISTD_H) && !defined(_WIN32)
13
13
  # include <unistd.h>
14
14
  #endif /* HAVE_UNISTD_H */
15
15
 
16
+ /* Ruby headers */
16
17
  #include "ruby.h"
17
- #include "libpq-fe.h"
18
- #include "libpq/libpq-fs.h" /* large-object interface */
19
- #include "compat.h"
18
+ #ifdef HAVE_RUBY_ST_H
19
+ # include "ruby/st.h"
20
+ #elif HAVE_ST_H
21
+ # include "st.h"
22
+ #endif
23
+
24
+ #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H
25
+ # include "ruby/encoding.h"
26
+ # define M17N_SUPPORTED
27
+ # define ASSOCIATE_INDEX( obj, index_holder ) rb_enc_associate_index((obj), pg_enc_get_index((index_holder)))
28
+ # ifdef HAVE_RB_ENCDB_ALIAS
29
+ extern int rb_encdb_alias(const char *, const char *);
30
+ # define ENC_ALIAS(name, orig) rb_encdb_alias((name), (orig))
31
+ # elif HAVE_RB_ENC_ALIAS
32
+ extern int rb_enc_alias(const char *, const char *);
33
+ # define ENC_ALIAS(name, orig) rb_enc_alias((name), (orig))
34
+ # else
35
+ extern int rb_enc_alias(const char *alias, const char *orig); /* declaration missing in Ruby 1.9.1 */
36
+ # define ENC_ALIAS(name, orig) rb_enc_alias((name), (orig))
37
+ # endif
38
+ #else
39
+ # define ASSOCIATE_INDEX( obj, index_holder ) /* nothing */
40
+ #endif
20
41
 
21
42
  #if RUBY_VM != 1
22
- #define RUBY_18_COMPAT
43
+ # define RUBY_18_COMPAT
23
44
  #endif
24
45
 
25
46
  #ifndef RARRAY_LEN
26
- #define RARRAY_LEN(x) RARRAY((x))->len
47
+ # define RARRAY_LEN(x) RARRAY((x))->len
27
48
  #endif /* RARRAY_LEN */
28
49
 
29
50
  #ifndef RSTRING_LEN
30
- #define RSTRING_LEN(x) RSTRING((x))->len
51
+ # define RSTRING_LEN(x) RSTRING((x))->len
31
52
  #endif /* RSTRING_LEN */
32
53
 
33
54
  #ifndef RSTRING_PTR
34
- #define RSTRING_PTR(x) RSTRING((x))->ptr
55
+ # define RSTRING_PTR(x) RSTRING((x))->ptr
35
56
  #endif /* RSTRING_PTR */
36
57
 
37
58
  #ifndef StringValuePtr
38
- #define StringValuePtr(x) STR2CSTR(x)
59
+ # define StringValuePtr(x) STR2CSTR(x)
39
60
  #endif /* StringValuePtr */
40
61
 
41
62
  #ifdef RUBY_18_COMPAT
42
- #define rb_io_stdio_file GetWriteFile
43
- #include "rubyio.h"
63
+ # define rb_io_stdio_file GetWriteFile
64
+ # include "rubyio.h"
44
65
  #else
45
- #include "ruby/io.h"
66
+ # include "ruby/io.h"
67
+ #endif
68
+
69
+ #ifndef timeradd
70
+ #define timeradd(a, b, result) \
71
+ do { \
72
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
73
+ (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
74
+ if ((result)->tv_usec >= 1000000L) { \
75
+ ++(result)->tv_sec; \
76
+ (result)->tv_usec -= 1000000L; \
77
+ } \
78
+ } while (0)
79
+ #endif
80
+
81
+ #ifndef timersub
82
+ #define timersub(a, b, result) \
83
+ do { \
84
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
85
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
86
+ if ((result)->tv_usec < 0) { \
87
+ --(result)->tv_sec; \
88
+ (result)->tv_usec += 1000000L; \
89
+ } \
90
+ } while (0)
46
91
  #endif
47
92
 
93
+ /* PostgreSQL headers */
94
+ #include "libpq-fe.h"
95
+ #include "libpq/libpq-fs.h" /* large-object interface */
96
+ #include "pg_config_manual.h"
97
+
48
98
  #if defined(_WIN32)
99
+ # include <fcntl.h>
49
100
  __declspec(dllexport)
101
+ typedef long suseconds_t;
50
102
  #endif
51
- void Init_pg_ext(void);
52
103
 
53
- #endif /* end of include guard: PG_H_C98VS4AD */
104
+ #include "gvl_wrappers.h"
105
+
106
+ /***************************************************************************
107
+ * Globals
108
+ **************************************************************************/
109
+
110
+ extern VALUE rb_mPG;
111
+ extern VALUE rb_ePGerror;
112
+ extern VALUE rb_eServerError;
113
+ extern VALUE rb_eUnableToSend;
114
+ extern VALUE rb_eConnectionBad;
115
+ extern VALUE rb_mPGconstants;
116
+ extern VALUE rb_cPGconn;
117
+ extern VALUE rb_cPGresult;
118
+ extern VALUE rb_hErrors;
119
+
120
+
121
+ /***************************************************************************
122
+ * MACROS
123
+ **************************************************************************/
124
+
125
+ #define UNUSED(x) ((void)(x))
126
+ #define SINGLETON_ALIAS(klass,new,old) rb_define_alias(rb_singleton_class((klass)),(new),(old))
127
+
128
+
129
+ /***************************************************************************
130
+ * PROTOTYPES
131
+ **************************************************************************/
132
+ void Init_pg_ext _(( void ));
133
+
134
+ void init_pg_connection _(( void ));
135
+ void init_pg_result _(( void ));
136
+ void init_pg_errors _(( void ));
137
+ VALUE lookup_error_class _(( const char *sqlstate ));
138
+
139
+ PGconn *pg_get_pgconn _(( VALUE ));
140
+
141
+ VALUE pg_new_result _(( PGresult *, VALUE ));
142
+ VALUE pg_result_check _(( VALUE ));
143
+ VALUE pg_result_clear _(( VALUE ));
144
+
145
+ #ifdef M17N_SUPPORTED
146
+ rb_encoding * pg_get_pg_encoding_as_rb_encoding _(( int ));
147
+ rb_encoding * pg_get_pg_encname_as_rb_encoding _(( const char * ));
148
+ const char * pg_get_rb_encoding_as_pg_encoding _(( rb_encoding * ));
149
+ int pg_enc_get_index _(( VALUE ));
150
+ rb_encoding *pg_conn_enc_get _(( PGconn * ));
151
+ #endif /* M17N_SUPPORTED */
152
+
153
+ void notice_receiver_proxy(void *arg, const PGresult *result);
154
+ void notice_processor_proxy(void *arg, const char *message);
155
+
156
+ #endif /* end __pg_h */