-
Notifications
You must be signed in to change notification settings - Fork 173
/
pg_text_decoder.c
717 lines (645 loc) · 19.4 KB
/
pg_text_decoder.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
/*
* pg_text_decoder.c - PG::TextDecoder module
* $Id$
*
*/
/*
*
* Type casts for decoding PostgreSQL string representations to Ruby objects.
*
* Decoder classes are defined with pg_define_coder(). This creates a new coder class and
* assigns a decoder function.
*
* Signature of all type cast decoders is:
* VALUE decoder_function(t_pg_coder *this, char *val, int len, int tuple, int field, int enc_idx)
*
* Params:
* this - The data part of the coder object that belongs to the decoder function.
* val, len - The text or binary data to decode. The caller ensures, that the data is
* zero terminated ( that is val[len] = 0 ). The memory should be used read
* only by the callee.
* tuple - Row of the value within the result set.
* field - Column of the value within the result set.
* enc_idx - Index of the Encoding that any output String should get assigned.
*
* Returns:
* The type casted Ruby object.
*
*/
#include "ruby/version.h"
#include "pg.h"
#include "util.h"
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef RUBY_API_VERSION_MAJOR
# if RUBY_API_VERSION_MAJOR > 2 || (RUBY_API_VERSION_MAJOR == 2 && RUBY_API_VERSION_MINOR >= 3)
/* use C implementation of the SimpleDecoder`s timestamp function
* when using ruby >= 2.3 */
# define PG_TEXT_DECODER_TIMESTAMP_EXT
# endif
#endif
#ifdef PG_TEXT_DECODER_TIMESTAMP_EXT
# include <ctype.h>
# include <time.h>
static VALUE rb_cPG_TimestampWithTimeZone;
static VALUE rb_cPG_TimestampWithoutTimeZone;
#endif
VALUE rb_mPG_TextDecoder;
static ID s_id_decode;
/*
* Document-class: PG::TextDecoder::Boolean < PG::SimpleDecoder
*
* This is a decoder class for conversion of PostgreSQL boolean type
* to Ruby true or false values.
*
*/
static VALUE
pg_text_dec_boolean(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
if (len < 1) {
rb_raise( rb_eTypeError, "wrong data for text boolean converter in tuple %d field %d", tuple, field);
}
return *val == 't' ? Qtrue : Qfalse;
}
/*
* Document-class: PG::TextDecoder::String < PG::SimpleDecoder
*
* This is a decoder class for conversion of PostgreSQL text output to
* to Ruby String object. The output value will have the character encoding
* set with PG::Connection#internal_encoding= .
*
*/
VALUE
pg_text_dec_string(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
VALUE ret = rb_tainted_str_new( val, len );
PG_ENCODING_SET_NOCHECK( ret, enc_idx );
return ret;
}
/*
* Document-class: PG::TextDecoder::Integer < PG::SimpleDecoder
*
* This is a decoder class for conversion of PostgreSQL integer types
* to Ruby Integer objects.
*
*/
static VALUE
pg_text_dec_integer(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
long i;
int max_len;
if( sizeof(i) >= 8 && FIXNUM_MAX >= 1000000000000000000LL ){
/* 64 bit system can safely handle all numbers up to 18 digits as Fixnum */
max_len = 18;
} else if( sizeof(i) >= 4 && FIXNUM_MAX >= 1000000000LL ){
/* 32 bit system can safely handle all numbers up to 9 digits as Fixnum */
max_len = 9;
} else {
/* unknown -> don't use fast path for int conversion */
max_len = 0;
}
if( len <= max_len ){
/* rb_cstr2inum() seems to be slow, so we do the int conversion by hand.
* This proved to be 40% faster by the following benchmark:
*
* conn.type_mapping_for_results = PG::BasicTypeMapForResults.new conn
* Benchmark.measure do
* conn.exec("select generate_series(1,1000000)").values }
* end
*/
char *val_pos = val;
char digit = *val_pos;
int neg;
int error = 0;
if( digit=='-' ){
neg = 1;
i = 0;
}else if( digit>='0' && digit<='9' ){
neg = 0;
i = digit - '0';
} else {
error = 1;
}
while (!error && (digit=*++val_pos)) {
if( digit>='0' && digit<='9' ){
i = i * 10 + (digit - '0');
} else {
error = 1;
}
}
if( !error ){
return LONG2FIX(neg ? -i : i);
}
}
/* Fallback to ruby method if number too big or unrecognized. */
return rb_cstr2inum(val, 10);
}
/*
* Document-class: PG::TextDecoder::Float < PG::SimpleDecoder
*
* This is a decoder class for conversion of PostgreSQL float4 and float8 types
* to Ruby Float objects.
*
*/
static VALUE
pg_text_dec_float(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
return rb_float_new(strtod(val, NULL));
}
/*
* Document-class: PG::TextDecoder::Bytea < PG::SimpleDecoder
*
* This is a decoder class for conversion of PostgreSQL bytea type
* to binary String objects.
*
*/
static VALUE
pg_text_dec_bytea(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
unsigned char *to;
size_t to_len;
VALUE ret;
to = PQunescapeBytea( (unsigned char *)val, &to_len);
ret = rb_tainted_str_new((char*)to, to_len);
PQfreemem(to);
return ret;
}
/*
* array_isspace() --- a non-locale-dependent isspace()
*
* We used to use isspace() for parsing array values, but that has
* undesirable results: an array value might be silently interpreted
* differently depending on the locale setting. Now we just hard-wire
* the traditional ASCII definition of isspace().
*/
static int
array_isspace(char ch)
{
if (ch == ' ' ||
ch == '\t' ||
ch == '\n' ||
ch == '\r' ||
ch == '\v' ||
ch == '\f')
return 1;
return 0;
}
static int
array_isdim(char ch)
{
if ( (ch >= '0' && ch <= '9') ||
(ch == '-') ||
(ch == '+') ||
(ch == ':') )
return 1;
return 0;
}
/*
* Array parser functions are thankfully borrowed from here:
* https://github.com/dockyard/pg_array_parser
*/
static VALUE
read_array_without_dim(t_pg_composite_coder *this, int *index, char *c_pg_array_string, int array_string_length, char *word, int enc_idx, int tuple, int field, t_pg_coder_dec_func dec_func)
{
/* Return value: array */
VALUE array;
int word_index = 0;
/* The current character in the input string. */
char c;
/* 0: Currently outside a quoted string, current word never quoted
* 1: Currently inside a quoted string
* -1: Currently outside a quoted string, current word previously quoted */
int openQuote = 0;
/* Inside quoted input means the next character should be treated literally,
* instead of being treated as a metacharacter.
* Outside of quoted input, means that the word shouldn't be pushed to the array,
* used when the last entry was a subarray (which adds to the array itself). */
int escapeNext = 0;
array = rb_ary_new();
/* Special case the empty array, so it doesn't need to be handled manually inside
* the loop. */
if(((*index) < array_string_length) && c_pg_array_string[*index] == '}')
{
return array;
}
for(;(*index) < array_string_length; ++(*index))
{
c = c_pg_array_string[*index];
if(openQuote < 1)
{
if(c == this->delimiter || c == '}')
{
if(!escapeNext)
{
if(openQuote == 0 && word_index == 4 && !strncmp(word, "NULL", word_index))
{
rb_ary_push(array, Qnil);
}
else
{
VALUE val;
word[word_index] = 0;
val = dec_func(this->elem, word, word_index, tuple, field, enc_idx);
rb_ary_push(array, val);
}
}
if(c == '}')
{
return array;
}
escapeNext = 0;
openQuote = 0;
word_index = 0;
}
else if(c == '"')
{
openQuote = 1;
}
else if(c == '{')
{
VALUE subarray;
(*index)++;
subarray = read_array_without_dim(this, index, c_pg_array_string, array_string_length, word, enc_idx, tuple, field, dec_func);
rb_ary_push(array, subarray);
escapeNext = 1;
}
else
{
word[word_index] = c;
word_index++;
}
}
else if (escapeNext) {
word[word_index] = c;
word_index++;
escapeNext = 0;
}
else if (c == '\\')
{
escapeNext = 1;
}
else if (c == '"')
{
openQuote = -1;
}
else
{
word[word_index] = c;
word_index++;
}
}
return array;
}
static VALUE
read_array(t_pg_composite_coder *this, int *index, char *c_pg_array_string, int array_string_length, char *word, int enc_idx, int tuple, int field, t_pg_coder_dec_func dec_func)
{
int ndim = 0;
/*
* If the input string starts with dimension info, read and use that.
* Otherwise, we require the input to be in curly-brace style, and we
* prescan the input to determine dimensions.
*
* Dimension info takes the form of one or more [n] or [m:n] items. The
* outer loop iterates once per dimension item.
*/
for (;;)
{
/*
* Note: we currently allow whitespace between, but not within,
* dimension items.
*/
while (array_isspace(c_pg_array_string[*index]))
(*index)++;
if (c_pg_array_string[*index] != '[')
break; /* no more dimension items */
(*index)++;
while (array_isdim(c_pg_array_string[*index]))
(*index)++;
if (c_pg_array_string[*index] != ']')
rb_raise( rb_eTypeError, "missing \"]\" in array dimensions");
(*index)++;
ndim++;
}
if (ndim == 0)
{
/* No array dimensions */
}
else
{
/* If array dimensions are given, expect '=' operator */
if (c_pg_array_string[*index] != '=')
rb_raise( rb_eTypeError, "missing assignment operator");
(*index)++;
while (array_isspace(c_pg_array_string[*index]))
(*index)++;
}
if (c_pg_array_string[*index] != '{')
rb_raise( rb_eTypeError, "array value must start with \"{\" or dimension information");
(*index)++;
return read_array_without_dim(this, index, c_pg_array_string, array_string_length, word, enc_idx, tuple, field, dec_func);
}
/*
* Document-class: PG::TextDecoder::Array < PG::CompositeDecoder
*
* This is a decoder class for PostgreSQL array types.
*
* It returns an Array with possibly an arbitrary number of sub-Arrays.
* All values are decoded according to the #elements_type accessor.
* Sub-arrays are decoded recursively.
*
* This decoder simply ignores any dimension decorations preceding the array values.
* It returns all array values as regular ruby Array with a zero based index, regardless of the index given in the dimension decoration.
*
* An array decoder which respects dimension decorations is waiting to be implemented.
*
*/
static VALUE
pg_text_dec_array(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
t_pg_composite_coder *this = (t_pg_composite_coder *)conv;
t_pg_coder_dec_func dec_func = pg_coder_dec_func(this->elem, 0);
/* create a buffer of the same length, as that will be the worst case */
char *word = xmalloc(len + 1);
int index = 0;
VALUE return_value = read_array(this, &index, val, len, word, enc_idx, tuple, field, dec_func);
free(word);
return return_value;
}
/*
* Document-class: PG::TextDecoder::Identifier < PG::SimpleDecoder
*
* This is the decoder class for PostgreSQL identifiers.
*
* Returns an Array of identifiers:
* PG::TextDecoder::Identifier.new.decode('schema."table"."column"')
* => ["schema", "table", "column"]
*
*/
static VALUE
pg_text_dec_identifier(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
/* Return value: array */
VALUE array;
VALUE elem;
int word_index = 0;
int index;
/* Use a buffer of the same length, as that will be the worst case */
PG_VARIABLE_LENGTH_ARRAY(char, word, len + 1, NAMEDATALEN)
/* The current character in the input string. */
char c;
/* 0: Currently outside a quoted string
* 1: Currently inside a quoted string, last char was a quote
* 2: Currently inside a quoted string, last char was no quote */
int openQuote = 0;
array = rb_ary_new();
for(index = 0; index < len; ++index) {
c = val[index];
if(c == '.' && openQuote < 2 ) {
word[word_index] = 0;
elem = pg_text_dec_string(conv, word, word_index, tuple, field, enc_idx);
rb_ary_push(array, elem);
openQuote = 0;
word_index = 0;
} else if(c == '"') {
if (openQuote == 1) {
word[word_index] = c;
word_index++;
openQuote = 2;
} else if (openQuote == 2){
openQuote = 1;
} else {
openQuote = 2;
}
} else {
word[word_index] = c;
word_index++;
}
}
word[word_index] = 0;
elem = pg_text_dec_string(conv, word, word_index, tuple, field, enc_idx);
rb_ary_push(array, elem);
return array;
}
/*
* Document-class: PG::TextDecoder::FromBase64 < PG::CompositeDecoder
*
* This is a decoder class for conversion of base64 encoded data
* to it's binary representation. It outputs a binary Ruby String
* or some other Ruby object, if a #elements_type decoder was defined.
*
*/
static VALUE
pg_text_dec_from_base64(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
t_pg_composite_coder *this = (t_pg_composite_coder *)conv;
t_pg_coder_dec_func dec_func = pg_coder_dec_func(this->elem, this->comp.format);
int decoded_len;
/* create a buffer of the expected decoded length */
VALUE out_value = rb_tainted_str_new(NULL, BASE64_DECODED_SIZE(len));
decoded_len = base64_decode( RSTRING_PTR(out_value), val, len );
rb_str_set_len(out_value, decoded_len);
/* Is it a pure String conversion? Then we can directly send out_value to the user. */
if( this->comp.format == 0 && dec_func == pg_text_dec_string ){
PG_ENCODING_SET_NOCHECK( out_value, enc_idx );
return out_value;
}
if( this->comp.format == 1 && dec_func == pg_bin_dec_bytea ){
PG_ENCODING_SET_NOCHECK( out_value, rb_ascii8bit_encindex() );
return out_value;
}
out_value = dec_func(this->elem, RSTRING_PTR(out_value), decoded_len, tuple, field, enc_idx);
return out_value;
}
#ifdef PG_TEXT_DECODER_TIMESTAMP_EXT
static inline int char_to_digit(char c)
{
return c - '0';
}
static int str4_to_int(const char *str)
{
return char_to_digit(str[0]) * 1000
+ char_to_digit(str[1]) * 100
+ char_to_digit(str[2]) * 10
+ char_to_digit(str[3]);
}
static int str2_to_int(const char *str)
{
return char_to_digit(str[0]) * 10
+ char_to_digit(str[1]);
}
static VALUE pg_text_decoder_timestamp_do(VALUE rstr, int with_timezone)
{
const char *str = StringValuePtr(rstr);
if (isdigit(str[0]) && isdigit(str[1]) && isdigit(str[2]) && isdigit(str[3])
&& str[4] == '-'
&& isdigit(str[5]) && isdigit(str[6])
&& str[7] == '-'
&& isdigit(str[8]) && isdigit(str[9])
&& str[10] == ' '
&& isdigit(str[11]) && isdigit(str[12])
&& str[13] == ':'
&& isdigit(str[14]) && isdigit(str[15])
&& str[16] == ':'
&& isdigit(str[17]) && isdigit(str[18])
)
{
struct tm tm;
int nsec = 0;
int tz_neg = 0;
int tz_hour = 0;
int tz_min = 0;
int tz_sec = 0;
tm.tm_year = str4_to_int(&str[0]) - 1900;
tm.tm_mon = str2_to_int(&str[5]) - 1;
tm.tm_mday = str2_to_int(&str[8]);
tm.tm_hour = str2_to_int(&str[11]);
tm.tm_min = str2_to_int(&str[14]);
tm.tm_sec = str2_to_int(&str[17]);
tm.tm_isdst = 0;
str += 19;
if (str[0] == '.' && isdigit(str[1]))
{
/* nano second part, up to 9 digits */
static const int coef[9] = {
100000000, 10000000, 1000000,
100000, 10000, 1000, 100, 10, 1
};
int i;
str++;
for (i = 0; i < 9 && isdigit(*str); i++)
{
nsec += coef[i] * char_to_digit(*str++);
}
}
if (with_timezone)
{
if ((str[0] == '+' || str[0] == '-') && isdigit(str[1]) && isdigit(str[2]))
{
tz_neg = str[0] == '-';
tz_hour = str2_to_int(&str[1]);
str += 3;
}
if (str[0] == ':')
{
str++;
}
if (isdigit(str[0]) && isdigit(str[1]))
{
tz_min = str2_to_int(str);
str += 2;
}
if (str[0] == ':')
{
str++;
}
if (isdigit(str[0]) && isdigit(str[1]))
{
tz_sec = str2_to_int(str);
str += 2;
}
}
if (*str != '\0')
{
// not consumed all the string
return rstr;
}
if (with_timezone)
{
#ifdef _WIN32
/* we can't use _mkgmtime because it is not available when using mingw32 */
time_t time;
time_t prevTZ = _timezone;
_timezone = 0;
time = mktime(&tm);
_timezone = prevTZ;
#else
time_t time = timegm(&tm);
#endif
if (time != -1)
{
struct timespec ts;
int gmt_offset;
gmt_offset = tz_hour * 3600 + tz_min * 60 + tz_sec;
if (tz_neg)
{
gmt_offset = - gmt_offset;
}
ts.tv_sec = time - gmt_offset;
ts.tv_nsec = nsec;
return rb_time_timespec_new(&ts, gmt_offset);
}
}
else
{
time_t time = mktime(&tm);
if (time != -1)
{
struct timespec ts;
ts.tv_sec = time;
ts.tv_nsec = nsec;
return rb_time_timespec_new(&ts, 0);
}
}
}
return rstr;
}
static VALUE
pg_text_dec_timestamp_with_time_zone(int argc, VALUE *argv, VALUE self)
{
if (argc < 1 || argc > 3)
{
rb_raise(rb_eArgError, "wrong number of arguments (%i for 1..3)", argc);
}
if (NIL_P(argv[0]))
{
return Qnil;
}
return pg_text_decoder_timestamp_do(argv[0], 1);
}
static VALUE
pg_text_dec_timestamp_without_time_zone(int argc, VALUE *argv, VALUE self)
{
if (argc < 1 || argc > 3)
{
rb_raise(rb_eArgError, "wrong number of arguments (%i for 1..3)", argc);
}
if (NIL_P(argv[0]))
{
return Qnil;
}
return pg_text_decoder_timestamp_do(argv[0], 0);
}
#endif
void
init_pg_text_decoder()
{
s_id_decode = rb_intern("decode");
/* This module encapsulates all decoder classes with text input format */
rb_mPG_TextDecoder = rb_define_module_under( rb_mPG, "TextDecoder" );
/* Make RDoc aware of the decoder classes... */
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Boolean", rb_cPG_SimpleDecoder ); */
pg_define_coder( "Boolean", pg_text_dec_boolean, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Integer", rb_cPG_SimpleDecoder ); */
pg_define_coder( "Integer", pg_text_dec_integer, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Float", rb_cPG_SimpleDecoder ); */
pg_define_coder( "Float", pg_text_dec_float, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "String", rb_cPG_SimpleDecoder ); */
pg_define_coder( "String", pg_text_dec_string, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Bytea", rb_cPG_SimpleDecoder ); */
pg_define_coder( "Bytea", pg_text_dec_bytea, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Identifier", rb_cPG_SimpleDecoder ); */
pg_define_coder( "Identifier", pg_text_dec_identifier, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Array", rb_cPG_CompositeDecoder ); */
pg_define_coder( "Array", pg_text_dec_array, rb_cPG_CompositeDecoder, rb_mPG_TextDecoder );
/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "FromBase64", rb_cPG_CompositeDecoder ); */
pg_define_coder( "FromBase64", pg_text_dec_from_base64, rb_cPG_CompositeDecoder, rb_mPG_TextDecoder );
#ifdef PG_TEXT_DECODER_TIMESTAMP_EXT
/* Document-class: PG::TimestampWithTimeZone < PG::SimpleDecoder */
rb_cPG_TimestampWithTimeZone = rb_define_class_under( rb_mPG_TextDecoder, "TimestampWithTimeZone", rb_cPG_SimpleDecoder );
rb_define_method( rb_cPG_TimestampWithTimeZone, "decode", pg_text_dec_timestamp_with_time_zone, -1 );
/* Document-class: PG::TimestampWithoutTimeZone < PG::SimpleDecoder */
rb_cPG_TimestampWithoutTimeZone = rb_define_class_under( rb_mPG_TextDecoder, "TimestampWithoutTimeZone", rb_cPG_SimpleDecoder );
rb_define_method( rb_cPG_TimestampWithoutTimeZone, "decode", pg_text_dec_timestamp_without_time_zone, -1 );
#endif
}