sequel_pg 1.8.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e8add8de4c52910c3da49f3604b1bd10992174d18c6b83ee9973f3cc674df2f
4
- data.tar.gz: 7c5b6dbf5b48299699cf5f56cf5b62ddb7b6736438a18a044592ec1b1aad8bed
3
+ metadata.gz: a7e56aa87f96c34298bba6a14bac49f79938415c9d9d8546b5621ac82c45161a
4
+ data.tar.gz: 85a21e58594078a962344e2308d6ae4b860de0b3af34a99be4ad93cdb39f4163
5
5
  SHA512:
6
- metadata.gz: d8911f1f4470918a27a624dbcc3ef67956a836e84c159a3bb3487ff136c7ee471db436d3872e91045c966ad385a0a9e9c6505e80d8ab573b2ea441c454f71bbf
7
- data.tar.gz: fc43429b58160b8ce16bb7bf313a56e9518fae265a829450de19d831787e4cd176da4e75f9840a1f070beb4cf66bbdc0d76e52ed0a883b43bb33075bdc749bcc
6
+ metadata.gz: 81ee2f7a944480110a254dbf6517e1b1d6eb64993c6e20f6425eab84e9f833213004c02857148bc36782bcef0862bacd17e8b12a7aa76e2f09b9c9aabe1c73dc
7
+ data.tar.gz: 5ff9e1e8750040e82c2cc9157d12f9c4fcf927f2dbb4576483b14d417bb5f65b45cacbd2c588ddc3db9ab5f0eca114f83b69455609e0bf8b6c92ec1b74b7423b
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.9.0 (2018-06-06)
2
+
3
+ * Return arrays of common data types as PGArray instances automatically with much improved performance (jeremyevans)
4
+
5
+ * Borrow pg_text_dec_integer function from ruby-pg and use it to improve performance (jeremyevans)
6
+
7
+ * Borrow PG_ENCODING_SET_NOCHECK macro from ruby-pg and use it to improve performance (jeremyevans)
8
+
1
9
  === 1.8.2 (2018-05-25)
2
10
 
3
11
  * Use Kernel.BigDecimal instead of BigDecimal.new to avoid verbose mode deprecation warnings (jeremyevans)
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2017 Jeremy Evans
1
+ Copyright (c) 2010-2018 Jeremy Evans
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to
@@ -45,3 +45,30 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
45
45
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
46
46
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47
47
 
48
+
49
+ Some improvements were taken from the ruby pg library
50
+ (https://bitbucket.org/ged/ruby-pg/wiki/Home), under the following
51
+ license:
52
+
53
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
54
+
55
+ Redistribution and use in source and binary forms, with or without
56
+ modification, are permitted provided that the following conditions
57
+ are met:
58
+ 1. Redistributions of source code must retain the above copyright
59
+ notice, this list of conditions and the following disclaimer.
60
+ 2. Redistributions in binary form must reproduce the above copyright
61
+ notice, this list of conditions and the following disclaimer in the
62
+ documentation and/or other materials provided with the distribution.
63
+
64
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
65
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
66
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
68
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
69
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
70
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
71
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
72
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
73
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74
+ SUCH DAMAGE.
data/README.rdoc CHANGED
@@ -128,6 +128,8 @@ sequel_pg has been tested on the following:
128
128
  * ruby 2.2
129
129
  * ruby 2.3
130
130
  * ruby 2.4
131
+ * ruby 2.5
132
+ * ruby 2.6
131
133
 
132
134
  == Known Issues
133
135
 
@@ -1,4 +1,4 @@
1
- #define SEQUEL_PG_VERSION_INTEGER 10802
1
+ #define SEQUEL_PG_VERSION_INTEGER 10900
2
2
 
3
3
  #include <string.h>
4
4
  #include <stdio.h>
@@ -42,6 +42,7 @@ PGconn* pg_get_pgconn(VALUE);
42
42
  PGresult* pgresult_get(VALUE);
43
43
 
44
44
  static VALUE spg_Sequel;
45
+ static VALUE spg_PGArray;
45
46
  static VALUE spg_Blob;
46
47
  static VALUE spg_Kernel;
47
48
  static VALUE spg_Date;
@@ -59,6 +60,33 @@ static VALUE spg_sym_model;
59
60
  static VALUE spg_sym__sequel_pg_type;
60
61
  static VALUE spg_sym__sequel_pg_value;
61
62
 
63
+ static VALUE spg_sym_text;
64
+ static VALUE spg_sym_character_varying;
65
+ static VALUE spg_sym_integer;
66
+ static VALUE spg_sym_timestamp;
67
+ static VALUE spg_sym_timestamptz;
68
+ static VALUE spg_sym_time;
69
+ static VALUE spg_sym_timetz;
70
+ static VALUE spg_sym_bigint;
71
+ static VALUE spg_sym_numeric;
72
+ static VALUE spg_sym_double_precision;
73
+ static VALUE spg_sym_boolean;
74
+ static VALUE spg_sym_bytea;
75
+ static VALUE spg_sym_date;
76
+ static VALUE spg_sym_smallint;
77
+ static VALUE spg_sym_oid;
78
+ static VALUE spg_sym_real;
79
+ static VALUE spg_sym_xml;
80
+ static VALUE spg_sym_money;
81
+ static VALUE spg_sym_bit;
82
+ static VALUE spg_sym_bit_varying;
83
+ static VALUE spg_sym_uuid;
84
+ static VALUE spg_sym_xid;
85
+ static VALUE spg_sym_cid;
86
+ static VALUE spg_sym_name;
87
+ static VALUE spg_sym_tid;
88
+ static VALUE spg_sym_int2vector;
89
+
62
90
  static VALUE spg_nan;
63
91
  static VALUE spg_pos_inf;
64
92
  static VALUE spg_neg_inf;
@@ -109,7 +137,74 @@ static int enc_get_index(VALUE val) {
109
137
  return i;
110
138
  }
111
139
 
112
- static VALUE read_array(int *index, char *c_pg_array_string, int array_string_length, VALUE buf, VALUE converter, int enc_index) {
140
+ #define PG_ENCODING_SET_NOCHECK(obj,i) \
141
+ do { \
142
+ if ((i) < ENCODING_INLINE_MAX) \
143
+ ENCODING_SET_INLINED((obj), (i)); \
144
+ else \
145
+ rb_enc_set_index((obj), (i)); \
146
+ } while(0)
147
+
148
+ static VALUE
149
+ pg_text_dec_integer(char *val, int len)
150
+ {
151
+ long i;
152
+ int max_len;
153
+
154
+ if( sizeof(i) >= 8 && FIXNUM_MAX >= 1000000000000000000LL ){
155
+ /* 64 bit system can safely handle all numbers up to 18 digits as Fixnum */
156
+ max_len = 18;
157
+ } else if( sizeof(i) >= 4 && FIXNUM_MAX >= 1000000000LL ){
158
+ /* 32 bit system can safely handle all numbers up to 9 digits as Fixnum */
159
+ max_len = 9;
160
+ } else {
161
+ /* unknown -> don't use fast path for int conversion */
162
+ max_len = 0;
163
+ }
164
+
165
+ if( len <= max_len ){
166
+ /* rb_cstr2inum() seems to be slow, so we do the int conversion by hand.
167
+ * This proved to be 40% faster by the following benchmark:
168
+ *
169
+ * conn.type_mapping_for_results = PG::BasicTypeMapForResults.new conn
170
+ * Benchmark.measure do
171
+ * conn.exec("select generate_series(1,1000000)").values }
172
+ * end
173
+ */
174
+ char *val_pos = val;
175
+ char digit = *val_pos;
176
+ int neg;
177
+ int error = 0;
178
+
179
+ if( digit=='-' ){
180
+ neg = 1;
181
+ i = 0;
182
+ }else if( digit>='0' && digit<='9' ){
183
+ neg = 0;
184
+ i = digit - '0';
185
+ } else {
186
+ error = 1;
187
+ }
188
+
189
+ while (!error && (digit=*++val_pos)) {
190
+ if( digit>='0' && digit<='9' ){
191
+ i = i * 10 + (digit - '0');
192
+ } else {
193
+ error = 1;
194
+ }
195
+ }
196
+
197
+ if( !error ){
198
+ return LONG2FIX(neg ? -i : i);
199
+ }
200
+ }
201
+ /* Fallback to ruby method if number too big or unrecognized. */
202
+ return rb_cstr2inum(val, 10);
203
+ }
204
+
205
+ static VALUE spg__array_col_value(char *v, size_t length, VALUE converter, int enc_index, int oid, VALUE db);
206
+
207
+ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_length, VALUE buf, VALUE converter, int enc_index, int oid, VALUE db) {
113
208
  int word_index = 0;
114
209
  char *word = RSTRING_PTR(buf);
115
210
 
@@ -152,16 +247,8 @@ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_le
152
247
  }
153
248
  else
154
249
  {
155
- VALUE rword = rb_tainted_str_new(word, word_index);
156
- RB_GC_GUARD(rword);
157
-
158
- rb_enc_associate_index(rword, enc_index);
159
-
160
- if (RTEST(converter)) {
161
- rword = rb_funcall(converter, spg_id_call, 1, rword);
162
- }
163
-
164
- rb_ary_push(array, rword);
250
+ word[word_index] = '\0';
251
+ rb_ary_push(array, spg__array_col_value(word, word_index, converter, enc_index, oid, db));
165
252
  }
166
253
  }
167
254
  if(c == '}')
@@ -179,7 +266,7 @@ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_le
179
266
  else if(c == '{')
180
267
  {
181
268
  (*index)++;
182
- rb_ary_push(array, read_array(index, c_pg_array_string, array_string_length, buf, converter, enc_index));
269
+ rb_ary_push(array, read_array(index, c_pg_array_string, array_string_length, buf, converter, enc_index, oid, db));
183
270
  escapeNext = 1;
184
271
  }
185
272
  else
@@ -213,29 +300,23 @@ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_le
213
300
  return array;
214
301
  }
215
302
 
216
- static VALUE parse_pg_array(VALUE self, VALUE pg_array_string, VALUE converter) {
217
-
218
- /* convert to c-string, create additional ruby string buffer of
219
- * the same length, as that will be the worst case. */
220
- char *c_pg_array_string = StringValueCStr(pg_array_string);
221
- int array_string_length = RSTRING_LEN(pg_array_string);
222
- VALUE buf = rb_str_buf_new(array_string_length);
223
- int index = 1;
224
-
303
+ static VALUE check_pg_array(int* index, char *c_pg_array_string, int array_string_length) {
225
304
  if (array_string_length == 0) {
226
305
  rb_raise(rb_eArgError, "unexpected PostgreSQL array format, empty");
306
+ } else if (array_string_length == 2 && c_pg_array_string[0] == '{' && c_pg_array_string[0] == '}') {
307
+ return rb_ary_new();
227
308
  }
228
309
 
229
310
  switch (c_pg_array_string[0]) {
230
311
  case '[':
231
312
  /* Skip explicit subscripts, scanning until opening array */
232
- for(;index < array_string_length && c_pg_array_string[index] != '{'; ++index)
313
+ for(;(*index) < array_string_length && c_pg_array_string[(*index)] != '{'; ++(*index))
233
314
  /* nothing */;
234
315
 
235
- if (index >= array_string_length) {
316
+ if ((*index) >= array_string_length) {
236
317
  rb_raise(rb_eArgError, "unexpected PostgreSQL array format, no {");
237
318
  } else {
238
- ++index;
319
+ ++(*index);
239
320
  }
240
321
  case '{':
241
322
  break;
@@ -243,9 +324,29 @@ static VALUE parse_pg_array(VALUE self, VALUE pg_array_string, VALUE converter)
243
324
  rb_raise(rb_eArgError, "unexpected PostgreSQL array format, doesn't start with { or [");
244
325
  }
245
326
 
246
- return read_array(&index, c_pg_array_string, array_string_length, buf, converter
247
- , enc_get_index(pg_array_string)
248
- );
327
+ return Qnil;
328
+ }
329
+
330
+ static VALUE parse_pg_array(VALUE self, VALUE pg_array_string, VALUE converter) {
331
+ /* convert to c-string, create additional ruby string buffer of
332
+ * the same length, as that will be the worst case. */
333
+ char *c_pg_array_string = StringValueCStr(pg_array_string);
334
+ int array_string_length = RSTRING_LEN(pg_array_string);
335
+ int index = 1;
336
+ VALUE ary;
337
+
338
+ if(RTEST(ary = check_pg_array(&index, c_pg_array_string, array_string_length))) {
339
+ return ary;
340
+ }
341
+
342
+ return read_array(&index,
343
+ c_pg_array_string,
344
+ array_string_length,
345
+ rb_str_buf_new(array_string_length),
346
+ converter,
347
+ enc_get_index(pg_array_string),
348
+ 0,
349
+ Qnil);
249
350
  }
250
351
 
251
352
  static VALUE spg_time(const char *s) {
@@ -272,11 +373,10 @@ static VALUE spg_time(const char *s) {
272
373
  }
273
374
 
274
375
  static VALUE spg_timestamp_error(const char *s, VALUE self, const char *error_msg) {
275
- VALUE db;
276
- db = rb_funcall(self, spg_id_db, 0);
277
- if(RTEST(rb_funcall(db, spg_id_convert_infinite_timestamps, 0))) {
376
+ self = rb_funcall(self, spg_id_db, 0);
377
+ if(RTEST(rb_funcall(self, spg_id_convert_infinite_timestamps, 0))) {
278
378
  if((strcmp(s, "infinity") == 0) || (strcmp(s, "-infinity") == 0)) {
279
- return rb_funcall(db, spg_id_infinite_timestamp_value, 1, rb_tainted_str_new2(s));
379
+ return rb_funcall(self, spg_id_infinite_timestamp_value, 1, rb_tainted_str_new2(s));
280
380
  }
281
381
  }
282
382
  rb_raise(rb_eArgError, "%s", error_msg);
@@ -454,17 +554,95 @@ static VALUE spg_fetch_rows_set_cols(VALUE self, VALUE ignore) {
454
554
  return Qnil;
455
555
  }
456
556
 
557
+ static VALUE spg__array_col_value(char *v, size_t length, VALUE converter, int enc_index, int oid, VALUE db) {
558
+ VALUE rv;
559
+ size_t l;
560
+
561
+ switch(oid) {
562
+ case 16: /* boolean */
563
+ rv = *v == 't' ? Qtrue : Qfalse;
564
+ break;
565
+ case 17: /* bytea */
566
+ v = (char *)PQunescapeBytea((unsigned char*)v, &l);
567
+ rv = rb_funcall(spg_Blob, spg_id_new, 1, rb_str_new(v, l));
568
+ PQfreemem(v);
569
+ break;
570
+ case 20: /* integer */
571
+ case 21:
572
+ case 23:
573
+ case 26:
574
+ rv = pg_text_dec_integer(v, length);
575
+ break;
576
+ case 700: /* float */
577
+ case 701:
578
+ if (strcmp("NaN", v) == 0) {
579
+ rv = spg_nan;
580
+ } else if (strcmp("Infinity", v) == 0) {
581
+ rv = spg_pos_inf;
582
+ } else if (strcmp("-Infinity", v) == 0) {
583
+ rv = spg_neg_inf;
584
+ } else {
585
+ rv = rb_float_new(rb_cstr_to_dbl(v, Qfalse));
586
+ }
587
+ break;
588
+ case 1700: /* numeric */
589
+ rv = rb_funcall(spg_Kernel, spg_id_BigDecimal, 1, rb_str_new(v, length));
590
+ break;
591
+ case 1082: /* date */
592
+ rv = spg_date(v, db);
593
+ break;
594
+ case 1083: /* time */
595
+ case 1266:
596
+ rv = spg_time(v);
597
+ break;
598
+ case 1114: /* timestamp */
599
+ case 1184:
600
+ rv = spg_timestamp(v, db);
601
+ break;
602
+ case 18: /* char */
603
+ case 25: /* text */
604
+ case 1043: /* varchar*/
605
+ rv = rb_tainted_str_new(v, length);
606
+ PG_ENCODING_SET_NOCHECK(rv, enc_index);
607
+ break;
608
+ default:
609
+ rv = rb_tainted_str_new(v, length);
610
+ PG_ENCODING_SET_NOCHECK(rv, enc_index);
611
+ if (RTEST(converter)) {
612
+ rv = rb_funcall(converter, spg_id_call, 1, rv);
613
+ }
614
+ }
615
+
616
+ return rv;
617
+ }
618
+
619
+ static VALUE spg_array_value(char *c_pg_array_string, int array_string_length, VALUE converter, int enc_index, int oid, VALUE self, VALUE array_type) {
620
+ int index = 1;
621
+ VALUE args[2];
622
+ args[1] = array_type;
623
+
624
+ if(RTEST(args[0] = check_pg_array(&index, c_pg_array_string, array_string_length))) {
625
+ return rb_class_new_instance(2, args, spg_PGArray);
626
+ }
627
+
628
+ args[0] = read_array(&index, c_pg_array_string, array_string_length, rb_str_buf_new(array_string_length), converter, enc_index, oid, self);
629
+ return rb_class_new_instance(2, args, spg_PGArray);
630
+ }
631
+
457
632
  static VALUE spg__col_value(VALUE self, PGresult *res, long i, long j, VALUE* colconvert, int enc_index) {
458
633
  char *v;
459
634
  VALUE rv;
460
635
  size_t l;
636
+ int ftype = PQftype(res, j);
637
+ VALUE array_type;
638
+ VALUE scalar_oid;
461
639
 
462
640
  if(PQgetisnull(res, i, j)) {
463
641
  rv = Qnil;
464
642
  } else {
465
643
  v = PQgetvalue(res, i, j);
466
644
 
467
- switch(PQftype(res, j)) {
645
+ switch(ftype) {
468
646
  case 16: /* boolean */
469
647
  rv = *v == 't' ? Qtrue : Qfalse;
470
648
  break;
@@ -477,7 +655,7 @@ static VALUE spg__col_value(VALUE self, PGresult *res, long i, long j, VALUE* co
477
655
  case 21:
478
656
  case 23:
479
657
  case 26:
480
- rv = rb_cstr2inum(v, 10);
658
+ rv = pg_text_dec_integer(v, PQgetlength(res, i, j));
481
659
  break;
482
660
  case 700: /* float */
483
661
  case 701:
@@ -509,11 +687,148 @@ static VALUE spg__col_value(VALUE self, PGresult *res, long i, long j, VALUE* co
509
687
  case 25: /* text */
510
688
  case 1043: /* varchar*/
511
689
  rv = rb_tainted_str_new(v, PQgetlength(res, i, j));
512
- rb_enc_associate_index(rv, enc_index);
690
+ PG_ENCODING_SET_NOCHECK(rv, enc_index);
691
+ break;
692
+ /* array types */
693
+ case 1009:
694
+ case 1014:
695
+ case 1015:
696
+ case 1007:
697
+ case 1115:
698
+ case 1185:
699
+ case 1183:
700
+ case 1270:
701
+ case 1016:
702
+ case 1231:
703
+ case 1022:
704
+ case 1000:
705
+ case 1001:
706
+ case 1182:
707
+ case 1005:
708
+ case 1028:
709
+ case 1021:
710
+ case 143:
711
+ case 791:
712
+ case 1561:
713
+ case 1563:
714
+ case 2951:
715
+ case 1011:
716
+ case 1012:
717
+ case 1003:
718
+ case 1010:
719
+ case 1006:
720
+ switch(ftype) {
721
+ case 1009:
722
+ case 1014:
723
+ array_type = spg_sym_text;
724
+ scalar_oid = 25;
725
+ break;
726
+ case 1015:
727
+ array_type = spg_sym_character_varying;
728
+ scalar_oid = 25;
729
+ break;
730
+ case 1007:
731
+ array_type = spg_sym_integer;
732
+ scalar_oid = 23;
733
+ break;
734
+ case 1115:
735
+ array_type = spg_sym_timestamp;
736
+ scalar_oid = 1114;
737
+ break;
738
+ case 1185:
739
+ array_type = spg_sym_timestamptz;
740
+ scalar_oid = 1184;
741
+ break;
742
+ case 1183:
743
+ array_type = spg_sym_time;
744
+ scalar_oid = 1083;
745
+ break;
746
+ case 1270:
747
+ array_type = spg_sym_timetz;
748
+ scalar_oid = 1266;
749
+ break;
750
+ case 1016:
751
+ array_type = spg_sym_bigint;
752
+ scalar_oid = 20;
753
+ break;
754
+ case 1231:
755
+ array_type = spg_sym_numeric;
756
+ scalar_oid = 1700;
757
+ break;
758
+ case 1022:
759
+ array_type = spg_sym_double_precision;
760
+ scalar_oid = 701;
761
+ break;
762
+ case 1000:
763
+ array_type = spg_sym_boolean;
764
+ scalar_oid = 16;
765
+ break;
766
+ case 1001:
767
+ array_type = spg_sym_bytea;
768
+ scalar_oid = 17;
769
+ break;
770
+ case 1182:
771
+ array_type = spg_sym_date;
772
+ scalar_oid = 1082;
773
+ break;
774
+ case 1005:
775
+ array_type = spg_sym_smallint;
776
+ scalar_oid = 21;
777
+ break;
778
+ case 1028:
779
+ array_type = spg_sym_oid;
780
+ scalar_oid = 26;
781
+ break;
782
+ case 1021:
783
+ array_type = spg_sym_real;
784
+ scalar_oid = 700;
785
+ break;
786
+ case 143:
787
+ array_type = spg_sym_xml;
788
+ scalar_oid = 142;
789
+ break;
790
+ case 791:
791
+ array_type = spg_sym_money;
792
+ scalar_oid = 790;
793
+ break;
794
+ case 1561:
795
+ array_type = spg_sym_bit;
796
+ scalar_oid = 1560;
797
+ break;
798
+ case 1563:
799
+ array_type = spg_sym_bit_varying;
800
+ scalar_oid = 1562;
801
+ break;
802
+ case 2951:
803
+ array_type = spg_sym_uuid;
804
+ scalar_oid = 2950;
805
+ break;
806
+ case 1011:
807
+ array_type = spg_sym_xid;
808
+ scalar_oid = 28;
809
+ break;
810
+ case 1012:
811
+ array_type = spg_sym_cid;
812
+ scalar_oid = 29;
813
+ break;
814
+ case 1003:
815
+ array_type = spg_sym_name;
816
+ scalar_oid = 19;
817
+ break;
818
+ case 1010:
819
+ array_type = spg_sym_tid;
820
+ scalar_oid = 27;
821
+ break;
822
+ case 1006:
823
+ array_type = spg_sym_int2vector;
824
+ scalar_oid = 22;
825
+ break;
826
+ }
827
+ rv = spg_array_value(v, PQgetlength(res, i, j), Qnil, enc_index, scalar_oid, self, array_type);
513
828
  break;
514
829
  default:
515
830
  rv = rb_tainted_str_new(v, PQgetlength(res, i, j));
516
- rb_enc_associate_index(rv, enc_index);
831
+ PG_ENCODING_SET_NOCHECK(rv, enc_index);
517
832
  if (colconvert[j] != Qnil) {
518
833
  rv = rb_funcall(colconvert[j], spg_id_call, 1, rv);
519
834
  }
@@ -1002,6 +1317,7 @@ void Init_sequel_pg(void) {
1002
1317
  return;
1003
1318
  }
1004
1319
  }
1320
+ rb_funcall(spg_Postgres, rb_intern("const_set"), 2, ID2SYM(rb_intern("SEQUEL_PG_VERSION_INTEGER")), INT2FIX(SEQUEL_PG_VERSION_INTEGER));
1005
1321
 
1006
1322
  spg_id_BigDecimal = rb_intern("BigDecimal");
1007
1323
  spg_id_new = rb_intern("new");
@@ -1046,6 +1362,33 @@ void Init_sequel_pg(void) {
1046
1362
  spg_sym__sequel_pg_type = ID2SYM(rb_intern("_sequel_pg_type"));
1047
1363
  spg_sym__sequel_pg_value = ID2SYM(rb_intern("_sequel_pg_value"));
1048
1364
 
1365
+ spg_sym_text = ID2SYM(rb_intern("text"));
1366
+ spg_sym_character_varying = ID2SYM(rb_intern("character varying"));
1367
+ spg_sym_integer = ID2SYM(rb_intern("integer"));
1368
+ spg_sym_timestamp = ID2SYM(rb_intern("timestamp"));
1369
+ spg_sym_timestamptz = ID2SYM(rb_intern("timestamptz"));
1370
+ spg_sym_time = ID2SYM(rb_intern("time"));
1371
+ spg_sym_timetz = ID2SYM(rb_intern("timetz"));
1372
+ spg_sym_bigint = ID2SYM(rb_intern("bigint"));
1373
+ spg_sym_numeric = ID2SYM(rb_intern("numeric"));
1374
+ spg_sym_double_precision = ID2SYM(rb_intern("double precision"));
1375
+ spg_sym_boolean = ID2SYM(rb_intern("boolean"));
1376
+ spg_sym_bytea = ID2SYM(rb_intern("bytea"));
1377
+ spg_sym_date = ID2SYM(rb_intern("date"));
1378
+ spg_sym_smallint = ID2SYM(rb_intern("smallint"));
1379
+ spg_sym_oid = ID2SYM(rb_intern("oid"));
1380
+ spg_sym_real = ID2SYM(rb_intern("real"));
1381
+ spg_sym_xml = ID2SYM(rb_intern("xml"));
1382
+ spg_sym_money = ID2SYM(rb_intern("money"));
1383
+ spg_sym_bit = ID2SYM(rb_intern("bit"));
1384
+ spg_sym_bit_varying = ID2SYM(rb_intern("bit varying"));
1385
+ spg_sym_uuid = ID2SYM(rb_intern("uuid"));
1386
+ spg_sym_xid = ID2SYM(rb_intern("xid"));
1387
+ spg_sym_cid = ID2SYM(rb_intern("cid"));
1388
+ spg_sym_name = ID2SYM(rb_intern("name"));
1389
+ spg_sym_tid = ID2SYM(rb_intern("tid"));
1390
+ spg_sym_int2vector = ID2SYM(rb_intern("int2vector"));
1391
+
1049
1392
  spg_Blob = rb_funcall(rb_funcall(spg_Sequel, cg, 1, rb_str_new2("SQL")), cg, 1, rb_str_new2("Blob"));
1050
1393
  spg_SQLTime= rb_funcall(spg_Sequel, cg, 1, rb_str_new2("SQLTime"));
1051
1394
  spg_Kernel = rb_funcall(rb_cObject, cg, 1, rb_str_new2("Kernel"));
@@ -1089,4 +1432,8 @@ void Init_sequel_pg(void) {
1089
1432
  rb_define_singleton_method(spg_Postgres, "parse_pg_array", parse_pg_array, 2);
1090
1433
 
1091
1434
  rb_require("sequel_pg/sequel_pg");
1435
+
1436
+ rb_require("sequel/extensions/pg_array");
1437
+ spg_PGArray = rb_funcall(spg_Postgres, cg, 1, rb_str_new2("PGArray"));
1438
+ rb_global_variable(&spg_PGArray);
1092
1439
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-25 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.7.6
94
+ rubygems_version: 3.0.0.beta1
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Faster SELECTs when using Sequel with pg