pg 1.3.0.rc2-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data/.appveyor.yml +36 -0
- data/.gems +6 -0
- data/.gemtest +0 -0
- data/.github/workflows/binary-gems.yml +85 -0
- data/.github/workflows/source-gem.yml +130 -0
- data/.gitignore +13 -0
- data/.hgsigs +34 -0
- data/.hgtags +41 -0
- data/.irbrc +23 -0
- data/.pryrc +23 -0
- data/.tm_properties +21 -0
- data/.travis.yml +49 -0
- data/BSDL +22 -0
- data/Contributors.rdoc +46 -0
- data/Gemfile +14 -0
- data/History.rdoc +648 -0
- data/LICENSE +56 -0
- data/Manifest.txt +72 -0
- data/POSTGRES +23 -0
- data/README-OS_X.rdoc +68 -0
- data/README-Windows.rdoc +56 -0
- data/README.ja.rdoc +13 -0
- data/README.rdoc +214 -0
- data/Rakefile +106 -0
- data/Rakefile.cross +300 -0
- data/certs/ged.pem +24 -0
- data/ext/errorcodes.def +1040 -0
- data/ext/errorcodes.rb +45 -0
- data/ext/errorcodes.txt +496 -0
- data/ext/extconf.rb +165 -0
- data/ext/gvl_wrappers.c +21 -0
- data/ext/gvl_wrappers.h +264 -0
- data/ext/pg.c +732 -0
- data/ext/pg.h +385 -0
- data/ext/pg_binary_decoder.c +229 -0
- data/ext/pg_binary_encoder.c +163 -0
- data/ext/pg_coder.c +615 -0
- data/ext/pg_connection.c +4415 -0
- data/ext/pg_copy_coder.c +628 -0
- data/ext/pg_errors.c +95 -0
- data/ext/pg_record_coder.c +519 -0
- data/ext/pg_result.c +1683 -0
- data/ext/pg_text_decoder.c +987 -0
- data/ext/pg_text_encoder.c +814 -0
- data/ext/pg_tuple.c +575 -0
- data/ext/pg_type_map.c +199 -0
- data/ext/pg_type_map_all_strings.c +129 -0
- data/ext/pg_type_map_by_class.c +269 -0
- data/ext/pg_type_map_by_column.c +349 -0
- data/ext/pg_type_map_by_mri_type.c +313 -0
- data/ext/pg_type_map_by_oid.c +385 -0
- data/ext/pg_type_map_in_ruby.c +330 -0
- data/ext/pg_util.c +149 -0
- data/ext/pg_util.h +65 -0
- data/ext/vc/pg.sln +26 -0
- data/ext/vc/pg_18/pg.vcproj +216 -0
- data/ext/vc/pg_19/pg_19.vcproj +209 -0
- data/lib/3.1/pg_ext.so +0 -0
- data/lib/pg/basic_type_map_based_on_result.rb +47 -0
- data/lib/pg/basic_type_map_for_queries.rb +193 -0
- data/lib/pg/basic_type_map_for_results.rb +81 -0
- data/lib/pg/basic_type_registry.rb +296 -0
- data/lib/pg/binary_decoder.rb +23 -0
- data/lib/pg/coder.rb +104 -0
- data/lib/pg/connection.rb +813 -0
- data/lib/pg/constants.rb +12 -0
- data/lib/pg/exceptions.rb +12 -0
- data/lib/pg/result.rb +43 -0
- data/lib/pg/text_decoder.rb +46 -0
- data/lib/pg/text_encoder.rb +59 -0
- data/lib/pg/tuple.rb +30 -0
- data/lib/pg/type_map_by_column.rb +16 -0
- data/lib/pg/version.rb +4 -0
- data/lib/pg.rb +87 -0
- data/lib/x64-mingw-ucrt/libpq.dll +0 -0
- data/misc/openssl-pg-segfault.rb +31 -0
- data/misc/postgres/History.txt +9 -0
- data/misc/postgres/Manifest.txt +5 -0
- data/misc/postgres/README.txt +21 -0
- data/misc/postgres/Rakefile +21 -0
- data/misc/postgres/lib/postgres.rb +16 -0
- data/misc/ruby-pg/History.txt +9 -0
- data/misc/ruby-pg/Manifest.txt +5 -0
- data/misc/ruby-pg/README.txt +21 -0
- data/misc/ruby-pg/Rakefile +21 -0
- data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
- data/pg.gemspec +32 -0
- data/sample/array_insert.rb +20 -0
- data/sample/async_api.rb +106 -0
- data/sample/async_copyto.rb +39 -0
- data/sample/async_mixed.rb +56 -0
- data/sample/check_conn.rb +21 -0
- data/sample/copydata.rb +71 -0
- data/sample/copyfrom.rb +81 -0
- data/sample/copyto.rb +19 -0
- data/sample/cursor.rb +21 -0
- data/sample/disk_usage_report.rb +177 -0
- data/sample/issue-119.rb +94 -0
- data/sample/losample.rb +69 -0
- data/sample/minimal-testcase.rb +17 -0
- data/sample/notify_wait.rb +72 -0
- data/sample/pg_statistics.rb +285 -0
- data/sample/replication_monitor.rb +222 -0
- data/sample/test_binary_values.rb +33 -0
- data/sample/wal_shipper.rb +434 -0
- data/sample/warehouse_partitions.rb +311 -0
- data.tar.gz.sig +0 -0
- metadata +188 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
/*
|
2
|
+
* pg_column_map.c - PG::ColumnMap class extension
|
3
|
+
* $Id$
|
4
|
+
*
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include "pg.h"
|
8
|
+
#include "pg_util.h"
|
9
|
+
#ifdef HAVE_INTTYPES_H
|
10
|
+
#include <inttypes.h>
|
11
|
+
#endif
|
12
|
+
|
13
|
+
VALUE rb_mPG_BinaryEncoder;
|
14
|
+
|
15
|
+
|
16
|
+
/*
|
17
|
+
* Document-class: PG::BinaryEncoder::Boolean < PG::SimpleEncoder
|
18
|
+
*
|
19
|
+
* This is the encoder class for the PostgreSQL boolean type.
|
20
|
+
*
|
21
|
+
* It accepts true and false. Other values will raise an exception.
|
22
|
+
*
|
23
|
+
*/
|
24
|
+
static int
|
25
|
+
pg_bin_enc_boolean(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate, int enc_idx)
|
26
|
+
{
|
27
|
+
char mybool;
|
28
|
+
if (value == Qtrue) {
|
29
|
+
mybool = 1;
|
30
|
+
} else if (value == Qfalse) {
|
31
|
+
mybool = 0;
|
32
|
+
} else {
|
33
|
+
rb_raise( rb_eTypeError, "wrong data for binary boolean converter" );
|
34
|
+
}
|
35
|
+
if(out) *out = mybool;
|
36
|
+
return 1;
|
37
|
+
}
|
38
|
+
|
39
|
+
/*
|
40
|
+
* Document-class: PG::BinaryEncoder::Int2 < PG::SimpleEncoder
|
41
|
+
*
|
42
|
+
* This is the encoder class for the PostgreSQL +int2+ (alias +smallint+) type.
|
43
|
+
*
|
44
|
+
* Non-Number values are expected to have method +to_i+ defined.
|
45
|
+
*
|
46
|
+
*/
|
47
|
+
static int
|
48
|
+
pg_bin_enc_int2(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate, int enc_idx)
|
49
|
+
{
|
50
|
+
if(out){
|
51
|
+
write_nbo16(NUM2INT(*intermediate), out);
|
52
|
+
}else{
|
53
|
+
*intermediate = pg_obj_to_i(value);
|
54
|
+
}
|
55
|
+
return 2;
|
56
|
+
}
|
57
|
+
|
58
|
+
/*
|
59
|
+
* Document-class: PG::BinaryEncoder::Int4 < PG::SimpleEncoder
|
60
|
+
*
|
61
|
+
* This is the encoder class for the PostgreSQL +int4+ (alias +integer+) type.
|
62
|
+
*
|
63
|
+
* Non-Number values are expected to have method +to_i+ defined.
|
64
|
+
*
|
65
|
+
*/
|
66
|
+
static int
|
67
|
+
pg_bin_enc_int4(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate, int enc_idx)
|
68
|
+
{
|
69
|
+
if(out){
|
70
|
+
write_nbo32(NUM2LONG(*intermediate), out);
|
71
|
+
}else{
|
72
|
+
*intermediate = pg_obj_to_i(value);
|
73
|
+
}
|
74
|
+
return 4;
|
75
|
+
}
|
76
|
+
|
77
|
+
/*
|
78
|
+
* Document-class: PG::BinaryEncoder::Int8 < PG::SimpleEncoder
|
79
|
+
*
|
80
|
+
* This is the encoder class for the PostgreSQL +int8+ (alias +bigint+) type.
|
81
|
+
*
|
82
|
+
* Non-Number values are expected to have method +to_i+ defined.
|
83
|
+
*
|
84
|
+
*/
|
85
|
+
static int
|
86
|
+
pg_bin_enc_int8(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate, int enc_idx)
|
87
|
+
{
|
88
|
+
if(out){
|
89
|
+
write_nbo64(NUM2LL(*intermediate), out);
|
90
|
+
}else{
|
91
|
+
*intermediate = pg_obj_to_i(value);
|
92
|
+
}
|
93
|
+
return 8;
|
94
|
+
}
|
95
|
+
|
96
|
+
/*
|
97
|
+
* Document-class: PG::BinaryEncoder::FromBase64 < PG::CompositeEncoder
|
98
|
+
*
|
99
|
+
* This is an encoder class for conversion of base64 encoded data
|
100
|
+
* to it's binary representation.
|
101
|
+
*
|
102
|
+
*/
|
103
|
+
static int
|
104
|
+
pg_bin_enc_from_base64(t_pg_coder *conv, VALUE value, char *out, VALUE *intermediate, int enc_idx)
|
105
|
+
{
|
106
|
+
int strlen;
|
107
|
+
VALUE subint;
|
108
|
+
t_pg_composite_coder *this = (t_pg_composite_coder *)conv;
|
109
|
+
t_pg_coder_enc_func enc_func = pg_coder_enc_func(this->elem);
|
110
|
+
|
111
|
+
if(out){
|
112
|
+
/* Second encoder pass, if required */
|
113
|
+
strlen = enc_func(this->elem, value, out, intermediate, enc_idx);
|
114
|
+
strlen = base64_decode( out, out, strlen );
|
115
|
+
|
116
|
+
return strlen;
|
117
|
+
} else {
|
118
|
+
/* First encoder pass */
|
119
|
+
strlen = enc_func(this->elem, value, NULL, &subint, enc_idx);
|
120
|
+
|
121
|
+
if( strlen == -1 ){
|
122
|
+
/* Encoded string is returned in subint */
|
123
|
+
VALUE out_str;
|
124
|
+
|
125
|
+
strlen = RSTRING_LENINT(subint);
|
126
|
+
out_str = rb_str_new(NULL, BASE64_DECODED_SIZE(strlen));
|
127
|
+
|
128
|
+
strlen = base64_decode( RSTRING_PTR(out_str), RSTRING_PTR(subint), strlen);
|
129
|
+
rb_str_set_len( out_str, strlen );
|
130
|
+
*intermediate = out_str;
|
131
|
+
|
132
|
+
return -1;
|
133
|
+
} else {
|
134
|
+
*intermediate = subint;
|
135
|
+
|
136
|
+
return BASE64_DECODED_SIZE(strlen);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
void
|
142
|
+
init_pg_binary_encoder()
|
143
|
+
{
|
144
|
+
/* This module encapsulates all encoder classes with binary output format */
|
145
|
+
rb_mPG_BinaryEncoder = rb_define_module_under( rb_mPG, "BinaryEncoder" );
|
146
|
+
|
147
|
+
/* Make RDoc aware of the encoder classes... */
|
148
|
+
/* dummy = rb_define_class_under( rb_mPG_BinaryEncoder, "Boolean", rb_cPG_SimpleEncoder ); */
|
149
|
+
pg_define_coder( "Boolean", pg_bin_enc_boolean, rb_cPG_SimpleEncoder, rb_mPG_BinaryEncoder );
|
150
|
+
/* dummy = rb_define_class_under( rb_mPG_BinaryEncoder, "Int2", rb_cPG_SimpleEncoder ); */
|
151
|
+
pg_define_coder( "Int2", pg_bin_enc_int2, rb_cPG_SimpleEncoder, rb_mPG_BinaryEncoder );
|
152
|
+
/* dummy = rb_define_class_under( rb_mPG_BinaryEncoder, "Int4", rb_cPG_SimpleEncoder ); */
|
153
|
+
pg_define_coder( "Int4", pg_bin_enc_int4, rb_cPG_SimpleEncoder, rb_mPG_BinaryEncoder );
|
154
|
+
/* dummy = rb_define_class_under( rb_mPG_BinaryEncoder, "Int8", rb_cPG_SimpleEncoder ); */
|
155
|
+
pg_define_coder( "Int8", pg_bin_enc_int8, rb_cPG_SimpleEncoder, rb_mPG_BinaryEncoder );
|
156
|
+
/* dummy = rb_define_class_under( rb_mPG_BinaryEncoder, "String", rb_cPG_SimpleEncoder ); */
|
157
|
+
pg_define_coder( "String", pg_coder_enc_to_s, rb_cPG_SimpleEncoder, rb_mPG_BinaryEncoder );
|
158
|
+
/* dummy = rb_define_class_under( rb_mPG_BinaryEncoder, "Bytea", rb_cPG_SimpleEncoder ); */
|
159
|
+
pg_define_coder( "Bytea", pg_coder_enc_to_s, rb_cPG_SimpleEncoder, rb_mPG_BinaryEncoder );
|
160
|
+
|
161
|
+
/* dummy = rb_define_class_under( rb_mPG_BinaryEncoder, "FromBase64", rb_cPG_CompositeEncoder ); */
|
162
|
+
pg_define_coder( "FromBase64", pg_bin_enc_from_base64, rb_cPG_CompositeEncoder, rb_mPG_BinaryEncoder );
|
163
|
+
}
|