autocompl 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/lib/autocompl/repository.rb +11 -1
  3. data/lib/autocompl/version.rb +1 -1
  4. data/test/dummy/log/development.log +467 -0
  5. data/test/dummy/log/test.log +3 -0
  6. data/test/dummy/vendor/bundle/ruby/2.3.0/bin/console +23 -0
  7. data/test/dummy/vendor/bundle/ruby/2.3.0/cache/pg-0.19.0.gem +0 -0
  8. data/test/dummy/vendor/bundle/ruby/2.3.0/cache/pq-0.0.1.gem +0 -0
  9. data/test/dummy/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-0.19.0/gem.build_complete +0 -0
  10. data/test/dummy/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-0.19.0/gem_make.out +78 -0
  11. data/test/dummy/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-0.19.0/mkmf.log +1346 -0
  12. data/test/dummy/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-0.19.0/pg_ext.bundle +0 -0
  13. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/BSDL +22 -0
  14. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ChangeLog +6378 -0
  15. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/Contributors.rdoc +46 -0
  16. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/History.rdoc +363 -0
  17. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/LICENSE +56 -0
  18. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/Manifest.txt +85 -0
  19. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/POSTGRES +23 -0
  20. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/README-OS_X.rdoc +68 -0
  21. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/README-Windows.rdoc +56 -0
  22. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/README.ja.rdoc +14 -0
  23. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/README.rdoc +168 -0
  24. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/Rakefile +216 -0
  25. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/Rakefile.cross +301 -0
  26. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/Makefile +261 -0
  27. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/errorcodes.def +947 -0
  28. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/errorcodes.rb +45 -0
  29. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/errorcodes.txt +467 -0
  30. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/extconf.h +38 -0
  31. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/extconf.rb +112 -0
  32. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/gvl_wrappers.c +13 -0
  33. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/gvl_wrappers.h +257 -0
  34. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/gvl_wrappers.o +0 -0
  35. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg.c +667 -0
  36. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg.h +395 -0
  37. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg.o +0 -0
  38. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_binary_decoder.c +162 -0
  39. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_binary_decoder.o +0 -0
  40. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_binary_encoder.c +162 -0
  41. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_binary_encoder.o +0 -0
  42. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_coder.c +500 -0
  43. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_coder.o +0 -0
  44. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_connection.c +4102 -0
  45. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_connection.o +0 -0
  46. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_copy_coder.c +591 -0
  47. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_copy_coder.o +0 -0
  48. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_errors.c +95 -0
  49. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_errors.o +0 -0
  50. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_ext.bundle +0 -0
  51. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_result.c +1271 -0
  52. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_result.o +0 -0
  53. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_text_decoder.c +421 -0
  54. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_text_decoder.o +0 -0
  55. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_text_encoder.c +683 -0
  56. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_text_encoder.o +0 -0
  57. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map.c +159 -0
  58. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map.o +0 -0
  59. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_all_strings.c +116 -0
  60. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_all_strings.o +0 -0
  61. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_class.c +239 -0
  62. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_class.o +0 -0
  63. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_column.c +312 -0
  64. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_column.o +0 -0
  65. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_mri_type.c +284 -0
  66. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_mri_type.o +0 -0
  67. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_oid.c +355 -0
  68. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_oid.o +0 -0
  69. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_in_ruby.c +299 -0
  70. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_in_ruby.o +0 -0
  71. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/util.c +149 -0
  72. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/util.h +65 -0
  73. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/util.o +0 -0
  74. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/vc/pg.sln +26 -0
  75. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/vc/pg_18/pg.vcproj +216 -0
  76. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/vc/pg_19/pg_19.vcproj +209 -0
  77. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg.rb +64 -0
  78. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/basic_type_mapping.rb +426 -0
  79. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/coder.rb +83 -0
  80. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/connection.rb +271 -0
  81. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/constants.rb +11 -0
  82. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/exceptions.rb +11 -0
  83. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/result.rb +30 -0
  84. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/text_decoder.rb +51 -0
  85. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/text_encoder.rb +35 -0
  86. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/type_map_by_column.rb +15 -0
  87. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg_ext.bundle +0 -0
  88. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/array_insert.rb +20 -0
  89. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/async_api.rb +106 -0
  90. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/async_copyto.rb +39 -0
  91. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/async_mixed.rb +56 -0
  92. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/check_conn.rb +21 -0
  93. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/copyfrom.rb +81 -0
  94. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/copyto.rb +19 -0
  95. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/cursor.rb +21 -0
  96. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/disk_usage_report.rb +186 -0
  97. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/issue-119.rb +94 -0
  98. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/losample.rb +69 -0
  99. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/minimal-testcase.rb +17 -0
  100. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/notify_wait.rb +72 -0
  101. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/pg_statistics.rb +294 -0
  102. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/replication_monitor.rb +231 -0
  103. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/test_binary_values.rb +33 -0
  104. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/wal_shipper.rb +434 -0
  105. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/warehouse_partitions.rb +320 -0
  106. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/data/expected_trace.out +26 -0
  107. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/data/random_binary_data +0 -0
  108. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/helpers.rb +352 -0
  109. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/basic_type_mapping_spec.rb +305 -0
  110. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/connection_spec.rb +1676 -0
  111. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/result_spec.rb +449 -0
  112. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_by_class_spec.rb +138 -0
  113. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_by_column_spec.rb +222 -0
  114. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_by_mri_type_spec.rb +136 -0
  115. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_by_oid_spec.rb +149 -0
  116. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_in_ruby_spec.rb +164 -0
  117. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_spec.rb +22 -0
  118. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_spec.rb +777 -0
  119. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg_spec.rb +50 -0
  120. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/Gemfile +4 -0
  121. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/LICENSE.txt +22 -0
  122. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/README.md +76 -0
  123. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/Rakefile +1 -0
  124. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/bin/console +7 -0
  125. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/lib/pq.rb +99 -0
  126. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/pq.gemspec +29 -0
  127. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/spec/helpers.rb +10 -0
  128. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/spec/queue_spec.rb +84 -0
  129. data/test/dummy/vendor/bundle/ruby/2.3.0/specifications/pg-0.19.0.gemspec +63 -0
  130. data/test/dummy/vendor/bundle/ruby/2.3.0/specifications/pq-0.0.1.gemspec +49 -0
  131. metadata +253 -1
@@ -0,0 +1,395 @@
1
+ #ifndef __pg_h
2
+ #define __pg_h
3
+
4
+ #ifdef RUBY_EXTCONF_H
5
+ # include RUBY_EXTCONF_H
6
+ #endif
7
+
8
+ /* System headers */
9
+ #include <stdio.h>
10
+ #include <stdlib.h>
11
+ #include <sys/types.h>
12
+ #if !defined(_WIN32)
13
+ # include <sys/time.h>
14
+ #endif
15
+ #if defined(HAVE_UNISTD_H) && !defined(_WIN32)
16
+ # include <unistd.h>
17
+ #endif /* HAVE_UNISTD_H */
18
+
19
+ /* Ruby headers */
20
+ #include "ruby.h"
21
+ #ifdef HAVE_RUBY_ST_H
22
+ # include "ruby/st.h"
23
+ #elif HAVE_ST_H
24
+ # include "st.h"
25
+ #endif
26
+
27
+ #if defined(HAVE_RUBY_ENCODING_H) && HAVE_RUBY_ENCODING_H
28
+ # include "ruby/encoding.h"
29
+ # define M17N_SUPPORTED
30
+ # ifdef HAVE_RB_ENCDB_ALIAS
31
+ extern int rb_encdb_alias(const char *, const char *);
32
+ # define ENC_ALIAS(name, orig) rb_encdb_alias((name), (orig))
33
+ # elif HAVE_RB_ENC_ALIAS
34
+ extern int rb_enc_alias(const char *, const char *);
35
+ # define ENC_ALIAS(name, orig) rb_enc_alias((name), (orig))
36
+ # else
37
+ extern int rb_enc_alias(const char *alias, const char *orig); /* declaration missing in Ruby 1.9.1 */
38
+ # define ENC_ALIAS(name, orig) rb_enc_alias((name), (orig))
39
+ # endif
40
+
41
+
42
+ # if !defined(ENCODING_SET_INLINED)
43
+ /* Rubinius doesn't define ENCODING_SET_INLINED, so we fall back to the more
44
+ * portable version.
45
+ */
46
+ # define PG_ENCODING_SET_NOCHECK(obj,i) \
47
+ do { \
48
+ rb_enc_set_index((obj), (i)); \
49
+ } while(0)
50
+ # else
51
+ # define PG_ENCODING_SET_NOCHECK(obj,i) \
52
+ do { \
53
+ if ((i) < ENCODING_INLINE_MAX) \
54
+ ENCODING_SET_INLINED((obj), (i)); \
55
+ else \
56
+ rb_enc_set_index((obj), (i)); \
57
+ } while(0)
58
+ # endif
59
+
60
+ #else
61
+ # define PG_ENCODING_SET_NOCHECK(obj,i) /* nothing */
62
+ #endif
63
+
64
+ #if RUBY_VM != 1
65
+ # define RUBY_18_COMPAT
66
+ #endif
67
+
68
+ #ifndef RARRAY_LEN
69
+ # define RARRAY_LEN(x) RARRAY((x))->len
70
+ #endif /* RARRAY_LEN */
71
+
72
+ #ifndef RSTRING_LEN
73
+ # define RSTRING_LEN(x) RSTRING((x))->len
74
+ #endif /* RSTRING_LEN */
75
+
76
+ #ifndef RSTRING_PTR
77
+ # define RSTRING_PTR(x) RSTRING((x))->ptr
78
+ #endif /* RSTRING_PTR */
79
+
80
+ #ifndef StringValuePtr
81
+ # define StringValuePtr(x) STR2CSTR(x)
82
+ #endif /* StringValuePtr */
83
+
84
+ #ifdef RUBY_18_COMPAT
85
+ # define rb_io_stdio_file GetWriteFile
86
+ # include "rubyio.h"
87
+ #else
88
+ # include "ruby/io.h"
89
+ #endif
90
+
91
+ #ifdef RUBINIUS
92
+ /* Workaround for wrong FIXNUM_MAX definition */
93
+ typedef intptr_t native_int;
94
+ #endif
95
+
96
+ #ifndef RETURN_SIZED_ENUMERATOR
97
+ #define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn) RETURN_ENUMERATOR((obj), (argc), (argv))
98
+ #endif
99
+
100
+ #ifndef HAVE_RB_HASH_DUP
101
+ /* Rubinius doesn't define rb_hash_dup() */
102
+ #define rb_hash_dup(tuple) rb_funcall((tuple), rb_intern("dup"), 0)
103
+ #endif
104
+
105
+ #ifndef timeradd
106
+ #define timeradd(a, b, result) \
107
+ do { \
108
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
109
+ (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
110
+ if ((result)->tv_usec >= 1000000L) { \
111
+ ++(result)->tv_sec; \
112
+ (result)->tv_usec -= 1000000L; \
113
+ } \
114
+ } while (0)
115
+ #endif
116
+
117
+ #ifndef timersub
118
+ #define timersub(a, b, result) \
119
+ do { \
120
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
121
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
122
+ if ((result)->tv_usec < 0) { \
123
+ --(result)->tv_sec; \
124
+ (result)->tv_usec += 1000000L; \
125
+ } \
126
+ } while (0)
127
+ #endif
128
+
129
+ /* PostgreSQL headers */
130
+ #include "libpq-fe.h"
131
+ #include "libpq/libpq-fs.h" /* large-object interface */
132
+ #include "pg_config_manual.h"
133
+
134
+ #if defined(_WIN32)
135
+ # include <fcntl.h>
136
+ typedef long suseconds_t;
137
+ #endif
138
+
139
+ #if defined(HAVE_VARIABLE_LENGTH_ARRAYS)
140
+ #define PG_VARIABLE_LENGTH_ARRAY(type, name, len, maxlen) type name[(len)];
141
+ #else
142
+ #define PG_VARIABLE_LENGTH_ARRAY(type, name, len, maxlen) \
143
+ type name[(maxlen)] = {(len)>(maxlen) ? (rb_raise(rb_eArgError, "Number of " #name " (%d) exceeds allowed maximum of " #maxlen, (len) ), (type)1) : (type)0};
144
+
145
+ #define PG_MAX_COLUMNS 4000
146
+ #endif
147
+
148
+ /* The data behind each PG::Connection object */
149
+ typedef struct {
150
+ PGconn *pgconn;
151
+
152
+ /* Cached IO object for the socket descriptor */
153
+ VALUE socket_io;
154
+ /* Proc object that receives notices as PG::Result objects */
155
+ VALUE notice_receiver;
156
+ /* Proc object that receives notices as String objects */
157
+ VALUE notice_processor;
158
+ /* Kind of PG::TypeMap object for casting query params */
159
+ VALUE type_map_for_queries;
160
+ /* Kind of PG::TypeMap object for casting result values */
161
+ VALUE type_map_for_results;
162
+ /* IO object internally used for the trace stream */
163
+ VALUE trace_stream;
164
+ /* Cached Encoding object */
165
+ VALUE external_encoding;
166
+ /* Kind of PG::Coder object for casting ruby values to COPY rows */
167
+ VALUE encoder_for_put_copy_data;
168
+ /* Kind of PG::Coder object for casting COPY rows to ruby values */
169
+ VALUE decoder_for_get_copy_data;
170
+
171
+ } t_pg_connection;
172
+
173
+ typedef struct pg_coder t_pg_coder;
174
+ typedef struct pg_typemap t_typemap;
175
+
176
+ /* The data behind each PG::Result object */
177
+ typedef struct {
178
+ PGresult *pgresult;
179
+
180
+ /* The connection object used to build this result */
181
+ VALUE connection;
182
+
183
+ /* The TypeMap used to type cast result values */
184
+ VALUE typemap;
185
+
186
+ /* Pointer to the typemap object data. This is assumed to be
187
+ * always valid.
188
+ */
189
+ t_typemap *p_typemap;
190
+
191
+ /* 0 = PGresult is cleared by PG::Result#clear or by the GC
192
+ * 1 = PGresult is cleared internally by libpq
193
+ */
194
+ int autoclear;
195
+
196
+ /* Number of fields in fnames[] .
197
+ * Set to -1 if fnames[] is not yet initialized.
198
+ */
199
+ int nfields;
200
+
201
+ /* Prefilled tuple Hash with fnames[] as keys. */
202
+ VALUE tuple_hash;
203
+
204
+ /* List of field names as frozen String objects.
205
+ * Only valid if nfields != -1
206
+ */
207
+ VALUE fnames[0];
208
+ } t_pg_result;
209
+
210
+
211
+ typedef int (* t_pg_coder_enc_func)(t_pg_coder *, VALUE, char *, VALUE *, int);
212
+ typedef VALUE (* t_pg_coder_dec_func)(t_pg_coder *, char *, int, int, int, int);
213
+ typedef VALUE (* t_pg_fit_to_result)(VALUE, VALUE);
214
+ typedef VALUE (* t_pg_fit_to_query)(VALUE, VALUE);
215
+ typedef int (* t_pg_fit_to_copy_get)(VALUE);
216
+ typedef VALUE (* t_pg_typecast_result)(t_typemap *, VALUE, int, int);
217
+ typedef t_pg_coder *(* t_pg_typecast_query_param)(t_typemap *, VALUE, int);
218
+ typedef VALUE (* t_pg_typecast_copy_get)( t_typemap *, VALUE, int, int, int );
219
+
220
+ struct pg_coder {
221
+ t_pg_coder_enc_func enc_func;
222
+ t_pg_coder_dec_func dec_func;
223
+ VALUE coder_obj;
224
+ Oid oid;
225
+ int format;
226
+ };
227
+
228
+ typedef struct {
229
+ t_pg_coder comp;
230
+ t_pg_coder *elem;
231
+ int needs_quotation;
232
+ char delimiter;
233
+ } t_pg_composite_coder;
234
+
235
+ struct pg_typemap {
236
+ struct pg_typemap_funcs {
237
+ t_pg_fit_to_result fit_to_result;
238
+ t_pg_fit_to_query fit_to_query;
239
+ t_pg_fit_to_copy_get fit_to_copy_get;
240
+ t_pg_typecast_result typecast_result_value;
241
+ t_pg_typecast_query_param typecast_query_param;
242
+ t_pg_typecast_copy_get typecast_copy_get;
243
+ } funcs;
244
+ VALUE default_typemap;
245
+ };
246
+
247
+ typedef struct {
248
+ t_typemap typemap;
249
+ int nfields;
250
+ struct pg_tmbc_converter {
251
+ t_pg_coder *cconv;
252
+ } convs[0];
253
+ } t_tmbc;
254
+
255
+
256
+ #include "gvl_wrappers.h"
257
+
258
+ /***************************************************************************
259
+ * Globals
260
+ **************************************************************************/
261
+
262
+ extern VALUE rb_mPG;
263
+ extern VALUE rb_ePGerror;
264
+ extern VALUE rb_eServerError;
265
+ extern VALUE rb_eUnableToSend;
266
+ extern VALUE rb_eConnectionBad;
267
+ extern VALUE rb_eInvalidResultStatus;
268
+ extern VALUE rb_eNoResultError;
269
+ extern VALUE rb_eInvalidChangeOfResultFields;
270
+ extern VALUE rb_mPGconstants;
271
+ extern VALUE rb_cPGconn;
272
+ extern VALUE rb_cPGresult;
273
+ extern VALUE rb_hErrors;
274
+ extern VALUE rb_cTypeMap;
275
+ extern VALUE rb_cTypeMapAllStrings;
276
+ extern VALUE rb_mDefaultTypeMappable;
277
+ extern VALUE rb_cPG_Coder;
278
+ extern VALUE rb_cPG_SimpleEncoder;
279
+ extern VALUE rb_cPG_SimpleDecoder;
280
+ extern VALUE rb_cPG_CompositeEncoder;
281
+ extern VALUE rb_cPG_CompositeDecoder;
282
+ extern VALUE rb_cPG_CopyCoder;
283
+ extern VALUE rb_cPG_CopyEncoder;
284
+ extern VALUE rb_cPG_CopyDecoder;
285
+ extern VALUE rb_mPG_TextEncoder;
286
+ extern VALUE rb_mPG_TextDecoder;
287
+ extern VALUE rb_mPG_BinaryEncoder;
288
+ extern VALUE rb_mPG_BinaryDecoder;
289
+ extern VALUE rb_mPG_BinaryFormatting;
290
+ extern const struct pg_typemap_funcs pg_tmbc_funcs;
291
+ extern const struct pg_typemap_funcs pg_typemap_funcs;
292
+
293
+ extern VALUE pg_typemap_all_strings;
294
+
295
+ /***************************************************************************
296
+ * MACROS
297
+ **************************************************************************/
298
+
299
+ #define UNUSED(x) ((void)(x))
300
+ #define SINGLETON_ALIAS(klass,new,old) rb_define_alias(rb_singleton_class((klass)),(new),(old))
301
+
302
+
303
+ /***************************************************************************
304
+ * PROTOTYPES
305
+ **************************************************************************/
306
+ void Init_pg_ext _(( void ));
307
+
308
+ void init_pg_connection _(( void ));
309
+ void init_pg_result _(( void ));
310
+ void init_pg_errors _(( void ));
311
+ void init_pg_type_map _(( void ));
312
+ void init_pg_type_map_all_strings _(( void ));
313
+ void init_pg_type_map_by_class _(( void ));
314
+ void init_pg_type_map_by_column _(( void ));
315
+ void init_pg_type_map_by_mri_type _(( void ));
316
+ void init_pg_type_map_by_oid _(( void ));
317
+ void init_pg_type_map_in_ruby _(( void ));
318
+ void init_pg_coder _(( void ));
319
+ void init_pg_copycoder _(( void ));
320
+ void init_pg_text_encoder _(( void ));
321
+ void init_pg_text_decoder _(( void ));
322
+ void init_pg_binary_encoder _(( void ));
323
+ void init_pg_binary_decoder _(( void ));
324
+ VALUE lookup_error_class _(( const char * ));
325
+ VALUE pg_bin_dec_bytea _(( t_pg_coder*, char *, int, int, int, int ));
326
+ VALUE pg_text_dec_string _(( t_pg_coder*, char *, int, int, int, int ));
327
+ int pg_coder_enc_to_s _(( t_pg_coder*, VALUE, char *, VALUE *, int));
328
+ int pg_text_enc_identifier _(( t_pg_coder*, VALUE, char *, VALUE *, int));
329
+ t_pg_coder_enc_func pg_coder_enc_func _(( t_pg_coder* ));
330
+ t_pg_coder_dec_func pg_coder_dec_func _(( t_pg_coder*, int ));
331
+ void pg_define_coder _(( const char *, void *, VALUE, VALUE ));
332
+ VALUE pg_obj_to_i _(( VALUE ));
333
+ VALUE pg_tmbc_allocate _(( void ));
334
+ void pg_coder_init_encoder _(( VALUE ));
335
+ void pg_coder_init_decoder _(( VALUE ));
336
+ char *pg_rb_str_ensure_capa _(( VALUE, long, char *, char ** ));
337
+
338
+ #define PG_RB_STR_ENSURE_CAPA( str, expand_len, curr_ptr, end_ptr ) \
339
+ do { \
340
+ if( (curr_ptr) + (expand_len) >= (end_ptr) ) \
341
+ (curr_ptr) = pg_rb_str_ensure_capa( (str), (expand_len), (curr_ptr), &(end_ptr) ); \
342
+ } while(0);
343
+
344
+ #define PG_RB_STR_NEW( str, curr_ptr, end_ptr ) ( \
345
+ (str) = rb_str_new( NULL, 0 ), \
346
+ (curr_ptr) = (end_ptr) = RSTRING_PTR(str) \
347
+ )
348
+
349
+ #define PG_RB_TAINTED_STR_NEW( str, curr_ptr, end_ptr ) ( \
350
+ (str) = rb_tainted_str_new( NULL, 0 ), \
351
+ (curr_ptr) = (end_ptr) = RSTRING_PTR(str) \
352
+ )
353
+
354
+ VALUE pg_typemap_fit_to_result _(( VALUE, VALUE ));
355
+ VALUE pg_typemap_fit_to_query _(( VALUE, VALUE ));
356
+ int pg_typemap_fit_to_copy_get _(( VALUE ));
357
+ VALUE pg_typemap_result_value _(( t_typemap *, VALUE, int, int ));
358
+ t_pg_coder *pg_typemap_typecast_query_param _(( t_typemap *, VALUE, int ));
359
+ VALUE pg_typemap_typecast_copy_get _(( t_typemap *, VALUE, int, int, int ));
360
+
361
+ PGconn *pg_get_pgconn _(( VALUE ));
362
+ t_pg_connection *pg_get_connection _(( VALUE ));
363
+
364
+ VALUE pg_new_result _(( PGresult *, VALUE ));
365
+ VALUE pg_new_result_autoclear _(( PGresult *, VALUE ));
366
+ PGresult* pgresult_get _(( VALUE ));
367
+ VALUE pg_result_check _(( VALUE ));
368
+ VALUE pg_result_clear _(( VALUE ));
369
+
370
+ /*
371
+ * Fetch the data pointer for the result object
372
+ */
373
+ static inline t_pg_result *
374
+ pgresult_get_this( VALUE self )
375
+ {
376
+ t_pg_result *this = DATA_PTR(self);
377
+
378
+ if( this == NULL )
379
+ rb_raise(rb_ePGerror, "result has been cleared");
380
+
381
+ return this;
382
+ }
383
+
384
+
385
+ #ifdef M17N_SUPPORTED
386
+ rb_encoding * pg_get_pg_encoding_as_rb_encoding _(( int ));
387
+ rb_encoding * pg_get_pg_encname_as_rb_encoding _(( const char * ));
388
+ const char * pg_get_rb_encoding_as_pg_encoding _(( rb_encoding * ));
389
+ rb_encoding *pg_conn_enc_get _(( PGconn * ));
390
+ #endif /* M17N_SUPPORTED */
391
+
392
+ void notice_receiver_proxy(void *arg, const PGresult *result);
393
+ void notice_processor_proxy(void *arg, const char *message);
394
+
395
+ #endif /* end __pg_h */
@@ -0,0 +1,162 @@
1
+ /*
2
+ * pg_column_map.c - PG::ColumnMap class extension
3
+ * $Id: pg_binary_decoder.c,v fcf731d3dff7 2015/09/08 12:25:06 jfali $
4
+ *
5
+ */
6
+
7
+ #include "pg.h"
8
+ #include "util.h"
9
+ #ifdef HAVE_INTTYPES_H
10
+ #include <inttypes.h>
11
+ #endif
12
+
13
+ VALUE rb_mPG_BinaryDecoder;
14
+
15
+
16
+ /*
17
+ * Document-class: PG::BinaryDecoder::Boolean < PG::SimpleDecoder
18
+ *
19
+ * This is a decoder class for conversion of PostgreSQL binary bool type
20
+ * to Ruby true or false objects.
21
+ *
22
+ */
23
+ static VALUE
24
+ pg_bin_dec_boolean(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
25
+ {
26
+ if (len < 1) {
27
+ rb_raise( rb_eTypeError, "wrong data for binary boolean converter in tuple %d field %d", tuple, field);
28
+ }
29
+ return *val == 0 ? Qfalse : Qtrue;
30
+ }
31
+
32
+ /*
33
+ * Document-class: PG::BinaryDecoder::Integer < PG::SimpleDecoder
34
+ *
35
+ * This is a decoder class for conversion of PostgreSQL binary int2, int4 and int8 types
36
+ * to Ruby Integer objects.
37
+ *
38
+ */
39
+ static VALUE
40
+ pg_bin_dec_integer(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
41
+ {
42
+ switch( len ){
43
+ case 2:
44
+ return INT2NUM(read_nbo16(val));
45
+ case 4:
46
+ return LONG2NUM(read_nbo32(val));
47
+ case 8:
48
+ return LL2NUM(read_nbo64(val));
49
+ default:
50
+ rb_raise( rb_eTypeError, "wrong data for binary integer converter in tuple %d field %d length %d", tuple, field, len);
51
+ }
52
+ }
53
+
54
+ /*
55
+ * Document-class: PG::BinaryDecoder::Float < PG::SimpleDecoder
56
+ *
57
+ * This is a decoder class for conversion of PostgreSQL binary float4 and float8 types
58
+ * to Ruby Float objects.
59
+ *
60
+ */
61
+ static VALUE
62
+ pg_bin_dec_float(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
63
+ {
64
+ union {
65
+ float f;
66
+ int32_t i;
67
+ } swap4;
68
+ union {
69
+ double f;
70
+ int64_t i;
71
+ } swap8;
72
+
73
+ switch( len ){
74
+ case 4:
75
+ swap4.i = read_nbo32(val);
76
+ return rb_float_new(swap4.f);
77
+ case 8:
78
+ swap8.i = read_nbo64(val);
79
+ return rb_float_new(swap8.f);
80
+ default:
81
+ rb_raise( rb_eTypeError, "wrong data for BinaryFloat converter in tuple %d field %d length %d", tuple, field, len);
82
+ }
83
+ }
84
+
85
+ /*
86
+ * Document-class: PG::BinaryDecoder::Bytea < PG::SimpleDecoder
87
+ *
88
+ * This decoder class delivers the data received from the server as binary String object.
89
+ * It is therefore suitable for conversion of PostgreSQL bytea data as well as any other
90
+ * data in binary format.
91
+ *
92
+ */
93
+ VALUE
94
+ pg_bin_dec_bytea(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
95
+ {
96
+ VALUE ret;
97
+ ret = rb_tainted_str_new( val, len );
98
+ PG_ENCODING_SET_NOCHECK( ret, rb_ascii8bit_encindex() );
99
+ return ret;
100
+ }
101
+
102
+ /*
103
+ * Document-class: PG::BinaryDecoder::ToBase64 < PG::CompositeDecoder
104
+ *
105
+ * This is a decoder class for conversion of binary (bytea) to base64 data.
106
+ *
107
+ */
108
+ static VALUE
109
+ pg_bin_dec_to_base64(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
110
+ {
111
+ t_pg_composite_coder *this = (t_pg_composite_coder *)conv;
112
+ t_pg_coder_dec_func dec_func = pg_coder_dec_func(this->elem, this->comp.format);
113
+ int encoded_len = BASE64_ENCODED_SIZE(len);
114
+ /* create a buffer of the encoded length */
115
+ VALUE out_value = rb_tainted_str_new(NULL, encoded_len);
116
+
117
+ base64_encode( RSTRING_PTR(out_value), val, len );
118
+
119
+ /* Is it a pure String conversion? Then we can directly send out_value to the user. */
120
+ if( this->comp.format == 0 && dec_func == pg_text_dec_string ){
121
+ PG_ENCODING_SET_NOCHECK( out_value, enc_idx );
122
+ return out_value;
123
+ }
124
+ if( this->comp.format == 1 && dec_func == pg_bin_dec_bytea ){
125
+ PG_ENCODING_SET_NOCHECK( out_value, rb_ascii8bit_encindex() );
126
+ return out_value;
127
+ }
128
+ out_value = dec_func(this->elem, RSTRING_PTR(out_value), encoded_len, tuple, field, enc_idx);
129
+
130
+ return out_value;
131
+ }
132
+
133
+ /*
134
+ * Document-class: PG::BinaryDecoder::String < PG::SimpleDecoder
135
+ *
136
+ * This is a decoder class for conversion of PostgreSQL text output to
137
+ * to Ruby String object. The output value will have the character encoding
138
+ * set with PG::Connection#internal_encoding= .
139
+ *
140
+ */
141
+
142
+ void
143
+ init_pg_binary_decoder()
144
+ {
145
+ /* This module encapsulates all decoder classes with binary input format */
146
+ rb_mPG_BinaryDecoder = rb_define_module_under( rb_mPG, "BinaryDecoder" );
147
+
148
+ /* Make RDoc aware of the decoder classes... */
149
+ /* dummy = rb_define_class_under( rb_mPG_BinaryDecoder, "Boolean", rb_cPG_SimpleDecoder ); */
150
+ pg_define_coder( "Boolean", pg_bin_dec_boolean, rb_cPG_SimpleDecoder, rb_mPG_BinaryDecoder );
151
+ /* dummy = rb_define_class_under( rb_mPG_BinaryDecoder, "Integer", rb_cPG_SimpleDecoder ); */
152
+ pg_define_coder( "Integer", pg_bin_dec_integer, rb_cPG_SimpleDecoder, rb_mPG_BinaryDecoder );
153
+ /* dummy = rb_define_class_under( rb_mPG_BinaryDecoder, "Float", rb_cPG_SimpleDecoder ); */
154
+ pg_define_coder( "Float", pg_bin_dec_float, rb_cPG_SimpleDecoder, rb_mPG_BinaryDecoder );
155
+ /* dummy = rb_define_class_under( rb_mPG_BinaryDecoder, "String", rb_cPG_SimpleDecoder ); */
156
+ pg_define_coder( "String", pg_text_dec_string, rb_cPG_SimpleDecoder, rb_mPG_BinaryDecoder );
157
+ /* dummy = rb_define_class_under( rb_mPG_BinaryDecoder, "Bytea", rb_cPG_SimpleDecoder ); */
158
+ pg_define_coder( "Bytea", pg_bin_dec_bytea, rb_cPG_SimpleDecoder, rb_mPG_BinaryDecoder );
159
+
160
+ /* dummy = rb_define_class_under( rb_mPG_BinaryDecoder, "ToBase64", rb_cPG_CompositeDecoder ); */
161
+ pg_define_coder( "ToBase64", pg_bin_dec_to_base64, rb_cPG_CompositeDecoder, rb_mPG_BinaryDecoder );
162
+ }