do_postgres 0.10.1-x86-mingw32 → 0.10.2-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog.markdown +7 -2
- data/Rakefile +1 -1
- data/ext/do_postgres/do_postgres.c +82 -68
- data/lib/do_postgres/1.8/do_postgres.so +0 -0
- data/lib/do_postgres/1.9/do_postgres.so +0 -0
- data/lib/do_postgres/version.rb +1 -1
- data/spec/encoding_spec.rb +2 -1
- data/spec/spec_helper.rb +1 -2
- data/tasks/compile.rake +1 -1
- metadata +37 -20
    
        data/ChangeLog.markdown
    CHANGED
    
    | @@ -1,10 +1,15 @@ | |
| 1 | 
            -
            ## 0.10. | 
| 1 | 
            +
            ## 0.10.2 2010-05-19
         | 
| 2 | 
            +
            * Make Encoding.default_internal aware
         | 
| 3 | 
            +
            * Rework logging for making callbacks possible
         | 
| 4 | 
            +
            * Remove handling Object types directly
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            ## 0.10.1 2010-01-08
         | 
| 2 7 |  | 
| 3 8 | 
             
            * Support for Ruby 1.8 and 1.9 on Windows.
         | 
| 4 9 | 
             
            * Switch to Jeweler for Gem building tasks (this change may be temporary).
         | 
| 5 10 | 
             
            * Switch to using Bacon for running specs: This should make specs friendlier to
         | 
| 6 11 | 
             
              new Ruby implementations that are not yet 100% MRI-compatible, and in turn,
         | 
| 7 | 
            -
               | 
| 12 | 
            +
              pave the road for our own IronRuby and MacRuby support.
         | 
| 8 13 | 
             
            * Switch to the newly added rake-compiler `JavaExtensionTask` for compiling
         | 
| 9 14 | 
             
              JRuby extensions, instead of our (broken) home-grown solution.
         | 
| 10 15 |  | 
    
        data/Rakefile
    CHANGED
    
    | @@ -11,7 +11,7 @@ JRUBY    = RUBY_PLATFORM =~ /java/ | |
| 11 11 | 
             
            IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
         | 
| 12 12 | 
             
            WINDOWS  = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
         | 
| 13 13 | 
             
            SUDO     = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
         | 
| 14 | 
            -
            BINARY_VERSION = '8.3. | 
| 14 | 
            +
            BINARY_VERSION = '8.3.10'
         | 
| 15 15 |  | 
| 16 16 | 
             
            CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_postgres/Makefile ext-java/target ])
         | 
| 17 17 |  | 
| @@ -38,52 +38,52 @@ | |
| 38 38 | 
             
            #include "error.h"
         | 
| 39 39 | 
             
            #include "compat.h"
         | 
| 40 40 |  | 
| 41 | 
            -
            #define ID_CONST_GET rb_intern("const_get")
         | 
| 42 | 
            -
            #define ID_PATH rb_intern("path")
         | 
| 43 | 
            -
            #define ID_NEW rb_intern("new")
         | 
| 44 | 
            -
            #define ID_ESCAPE rb_intern("escape_sql")
         | 
| 45 | 
            -
             | 
| 46 41 | 
             
            #define CONST_GET(scope, constant) (rb_funcall(scope, ID_CONST_GET, 1, rb_str_new2(constant)))
         | 
| 47 | 
            -
            #define  | 
| 42 | 
            +
            #define DRIVER_CLASS(klass, parent) (rb_define_class_under(mPostgres, klass, parent))
         | 
| 48 43 |  | 
| 49 44 | 
             
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 50 45 | 
             
            #include <ruby/encoding.h>
         | 
| 51 46 |  | 
| 52 | 
            -
            #define DO_STR_NEW2(str, encoding) \
         | 
| 47 | 
            +
            #define DO_STR_NEW2(str, encoding, internal_encoding) \
         | 
| 53 48 | 
             
              ({ \
         | 
| 54 49 | 
             
                VALUE _string = rb_str_new2((const char *)str); \
         | 
| 55 50 | 
             
                if(encoding != -1) { \
         | 
| 56 51 | 
             
                  rb_enc_associate_index(_string, encoding); \
         | 
| 57 52 | 
             
                } \
         | 
| 53 | 
            +
                if(internal_encoding) { \
         | 
| 54 | 
            +
                  _string = rb_str_export_to_enc(_string, internal_encoding); \
         | 
| 55 | 
            +
                } \
         | 
| 58 56 | 
             
                _string; \
         | 
| 59 57 | 
             
              })
         | 
| 60 58 |  | 
| 61 | 
            -
            #define DO_STR_NEW(str, len, encoding) \
         | 
| 59 | 
            +
            #define DO_STR_NEW(str, len, encoding, internal_encoding) \
         | 
| 62 60 | 
             
              ({ \
         | 
| 63 61 | 
             
                VALUE _string = rb_str_new((const char *)str, (long)len); \
         | 
| 64 62 | 
             
                if(encoding != -1) { \
         | 
| 65 63 | 
             
                  rb_enc_associate_index(_string, encoding); \
         | 
| 66 64 | 
             
                } \
         | 
| 65 | 
            +
                if(internal_encoding) { \
         | 
| 66 | 
            +
                  _string = rb_str_export_to_enc(_string, internal_encoding); \
         | 
| 67 | 
            +
                } \
         | 
| 67 68 | 
             
                _string; \
         | 
| 68 69 | 
             
              })
         | 
| 69 70 |  | 
| 70 71 | 
             
            #else
         | 
| 71 72 |  | 
| 72 | 
            -
            #define DO_STR_NEW2(str,  | 
| 73 | 
            +
            #define DO_STR_NEW2(str, encoding, internal_encoding) \
         | 
| 73 74 | 
             
              rb_str_new2((const char *)str)
         | 
| 74 75 |  | 
| 75 | 
            -
            #define DO_STR_NEW(str, len,  | 
| 76 | 
            +
            #define DO_STR_NEW(str, len, encoding, internal_encoding) \
         | 
| 76 77 | 
             
              rb_str_new((const char *)str, (long)len)
         | 
| 77 78 | 
             
            #endif
         | 
| 78 79 |  | 
| 79 | 
            -
             | 
| 80 80 | 
             
            // To store rb_intern values
         | 
| 81 81 | 
             
            static ID ID_NEW_DATE;
         | 
| 82 | 
            -
            static ID ID_LOGGER;
         | 
| 83 | 
            -
            static ID ID_DEBUG;
         | 
| 84 | 
            -
            static ID ID_LEVEL;
         | 
| 85 | 
            -
            static ID ID_TO_S;
         | 
| 86 82 | 
             
            static ID ID_RATIONAL;
         | 
| 83 | 
            +
            static ID ID_CONST_GET;
         | 
| 84 | 
            +
            static ID ID_NEW;
         | 
| 85 | 
            +
            static ID ID_ESCAPE;
         | 
| 86 | 
            +
            static ID ID_LOG;
         | 
| 87 87 |  | 
| 88 88 | 
             
            static VALUE mExtlib;
         | 
| 89 89 | 
             
            static VALUE mDO;
         | 
| @@ -93,6 +93,8 @@ static VALUE cDO_Connection; | |
| 93 93 | 
             
            static VALUE cDO_Command;
         | 
| 94 94 | 
             
            static VALUE cDO_Result;
         | 
| 95 95 | 
             
            static VALUE cDO_Reader;
         | 
| 96 | 
            +
            static VALUE cDO_Logger;
         | 
| 97 | 
            +
            static VALUE cDO_Logger_Message;
         | 
| 96 98 |  | 
| 97 99 | 
             
            static VALUE rb_cDate;
         | 
| 98 100 | 
             
            static VALUE rb_cDateTime;
         | 
| @@ -105,32 +107,19 @@ static VALUE cCommand; | |
| 105 107 | 
             
            static VALUE cResult;
         | 
| 106 108 | 
             
            static VALUE cReader;
         | 
| 107 109 |  | 
| 108 | 
            -
            static VALUE eArgumentError;
         | 
| 109 110 | 
             
            static VALUE eConnectionError;
         | 
| 110 111 | 
             
            static VALUE eDataError;
         | 
| 111 112 |  | 
| 112 | 
            -
            static void data_objects_debug(VALUE string, struct timeval* start) {
         | 
| 113 | 
            +
            static void data_objects_debug(VALUE connection, VALUE string, struct timeval* start) {
         | 
| 113 114 | 
             
              struct timeval stop;
         | 
| 114 | 
            -
               | 
| 115 | 
            -
             | 
| 116 | 
            -
              const char *query = rb_str_ptr_readonly(string);
         | 
| 117 | 
            -
              size_t length     = rb_str_len(string);
         | 
| 118 | 
            -
              char total_time[32];
         | 
| 119 | 
            -
              do_int64 duration = 0;
         | 
| 120 | 
            -
             | 
| 121 | 
            -
              VALUE logger = rb_funcall(mPostgres, ID_LOGGER, 0);
         | 
| 122 | 
            -
              int log_level = NUM2INT(rb_funcall(logger, ID_LEVEL, 0));
         | 
| 115 | 
            +
              VALUE message;
         | 
| 123 116 |  | 
| 124 | 
            -
               | 
| 125 | 
            -
             | 
| 117 | 
            +
              gettimeofday(&stop, NULL);
         | 
| 118 | 
            +
              do_int64 duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
         | 
| 126 119 |  | 
| 127 | 
            -
             | 
| 120 | 
            +
              message = rb_funcall(cDO_Logger_Message, ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
         | 
| 128 121 |  | 
| 129 | 
            -
             | 
| 130 | 
            -
                message = (char *)calloc(length + strlen(total_time) + 4, sizeof(char));
         | 
| 131 | 
            -
                snprintf(message, length + strlen(total_time) + 4, "(%s) %s", total_time, query);
         | 
| 132 | 
            -
                rb_funcall(logger, ID_DEBUG, 1, rb_str_new(message, length + strlen(total_time) + 3));
         | 
| 133 | 
            -
              }
         | 
| 122 | 
            +
              rb_funcall(connection, ID_LOG, 1, message);
         | 
| 134 123 | 
             
            }
         | 
| 135 124 |  | 
| 136 125 | 
             
            static const char * get_uri_option(VALUE query_hash, const char * key) {
         | 
| @@ -352,10 +341,16 @@ static VALUE infer_ruby_type(Oid type) { | |
| 352 341 |  | 
| 353 342 | 
             
            static VALUE typecast(const char *value, long length, const VALUE type, int encoding) {
         | 
| 354 343 |  | 
| 344 | 
            +
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 345 | 
            +
              rb_encoding * internal_encoding = rb_default_internal_encoding();
         | 
| 346 | 
            +
            #else
         | 
| 347 | 
            +
              void * internal_encoding = NULL;
         | 
| 348 | 
            +
            #endif
         | 
| 349 | 
            +
             | 
| 355 350 | 
             
              if (type == rb_cInteger) {
         | 
| 356 351 | 
             
                return rb_cstr2inum(value, 10);
         | 
| 357 352 | 
             
              } else if (type == rb_cString) {
         | 
| 358 | 
            -
                return DO_STR_NEW(value, length, encoding);
         | 
| 353 | 
            +
                return DO_STR_NEW(value, length, encoding, internal_encoding);
         | 
| 359 354 | 
             
              } else if (type == rb_cFloat) {
         | 
| 360 355 | 
             
                return rb_float_new(rb_cstr_to_dbl(value, Qfalse));
         | 
| 361 356 | 
             
              } else if (type == rb_cBigDecimal) {
         | 
| @@ -376,12 +371,10 @@ static VALUE typecast(const char *value, long length, const VALUE type, int enco | |
| 376 371 | 
             
                return byte_array;
         | 
| 377 372 | 
             
              } else if (type == rb_cClass) {
         | 
| 378 373 | 
             
                return rb_funcall(mDO, rb_intern("full_const_get"), 1, rb_str_new(value, length));
         | 
| 379 | 
            -
              } else if (type == rb_cObject) {
         | 
| 380 | 
            -
                return rb_marshal_load(rb_str_new(value, length));
         | 
| 381 374 | 
             
              } else if (type == rb_cNilClass) {
         | 
| 382 375 | 
             
                return Qnil;
         | 
| 383 376 | 
             
              } else {
         | 
| 384 | 
            -
                return DO_STR_NEW(value, length, encoding);
         | 
| 377 | 
            +
                return DO_STR_NEW(value, length, encoding, internal_encoding);
         | 
| 385 378 | 
             
              }
         | 
| 386 379 |  | 
| 387 380 | 
             
            }
         | 
| @@ -460,11 +453,11 @@ static VALUE cCommand_set_types(int argc, VALUE *argv, VALUE self) { | |
| 460 453 | 
             
                    if(TYPE(sub_entry) == T_CLASS) {
         | 
| 461 454 | 
             
                      rb_ary_push(type_strings, sub_entry);
         | 
| 462 455 | 
             
                    } else {
         | 
| 463 | 
            -
                      rb_raise( | 
| 456 | 
            +
                      rb_raise(rb_eArgError, "Invalid type given");
         | 
| 464 457 | 
             
                    }
         | 
| 465 458 | 
             
                  }
         | 
| 466 459 | 
             
                } else {
         | 
| 467 | 
            -
                  rb_raise( | 
| 460 | 
            +
                  rb_raise(rb_eArgError, "Invalid type given");
         | 
| 468 461 | 
             
                }
         | 
| 469 462 | 
             
              }
         | 
| 470 463 |  | 
| @@ -506,7 +499,7 @@ static VALUE cConnection_quote_string(VALUE self, VALUE string) { | |
| 506 499 | 
             
              // Wrap the escaped string in single-quotes, this is DO's convention
         | 
| 507 500 | 
             
              escaped[quoted_length + 1] = escaped[0] = '\'';
         | 
| 508 501 |  | 
| 509 | 
            -
              result = DO_STR_NEW(escaped, quoted_length + 2, FIX2INT(rb_iv_get(self, "@encoding_id")));
         | 
| 502 | 
            +
              result = DO_STR_NEW(escaped, quoted_length + 2, FIX2INT(rb_iv_get(self, "@encoding_id")), NULL);
         | 
| 510 503 |  | 
| 511 504 | 
             
              free(escaped);
         | 
| 512 505 | 
             
              return result;
         | 
| @@ -541,7 +534,7 @@ static VALUE cConnection_quote_byte_array(VALUE self, VALUE string) { | |
| 541 534 | 
             
            static void full_connect(VALUE self, PGconn *db);
         | 
| 542 535 |  | 
| 543 536 | 
             
            #ifdef _WIN32
         | 
| 544 | 
            -
            static PGresult* cCommand_execute_sync(VALUE self, PGconn *db, VALUE query) {
         | 
| 537 | 
            +
            static PGresult* cCommand_execute_sync(VALUE self, VALUE connection, PGconn *db, VALUE query) {
         | 
| 545 538 | 
             
              PGresult *response;
         | 
| 546 539 | 
             
              struct timeval start;
         | 
| 547 540 | 
             
              char* str = StringValuePtr(query);
         | 
| @@ -554,15 +547,12 @@ static PGresult* cCommand_execute_sync(VALUE self, PGconn *db, VALUE query) { | |
| 554 547 |  | 
| 555 548 | 
             
              response = PQexec(db, str);
         | 
| 556 549 |  | 
| 557 | 
            -
              data_objects_debug(query, &start);
         | 
| 558 | 
            -
             | 
| 559 550 | 
             
              if (response == NULL) {
         | 
| 560 551 | 
             
                if(PQstatus(db) != CONNECTION_OK) {
         | 
| 561 552 | 
             
                  PQreset(db);
         | 
| 562 553 | 
             
                  if (PQstatus(db) == CONNECTION_OK) {
         | 
| 563 554 | 
             
                    response = PQexec(db, str);
         | 
| 564 555 | 
             
                  } else {
         | 
| 565 | 
            -
                    VALUE connection = rb_iv_get(self, "@connection");
         | 
| 566 556 | 
             
                    full_connect(connection, db);
         | 
| 567 557 | 
             
                    response = PQexec(db, str);
         | 
| 568 558 | 
             
                  }
         | 
| @@ -573,10 +563,12 @@ static PGresult* cCommand_execute_sync(VALUE self, PGconn *db, VALUE query) { | |
| 573 563 | 
             
                }
         | 
| 574 564 | 
             
              }
         | 
| 575 565 |  | 
| 566 | 
            +
              data_objects_debug(connection, query, &start);
         | 
| 567 | 
            +
             | 
| 576 568 | 
             
              return response;
         | 
| 577 569 | 
             
            }
         | 
| 578 570 | 
             
            #else
         | 
| 579 | 
            -
            static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) {
         | 
| 571 | 
            +
            static PGresult* cCommand_execute_async(VALUE self, VALUE connection, PGconn *db, VALUE query) {
         | 
| 580 572 | 
             
              int socket_fd;
         | 
| 581 573 | 
             
              int retval;
         | 
| 582 574 | 
             
              fd_set rset;
         | 
| @@ -588,6 +580,8 @@ static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) { | |
| 588 580 | 
             
                PQclear(response);
         | 
| 589 581 | 
             
              }
         | 
| 590 582 |  | 
| 583 | 
            +
              gettimeofday(&start, NULL);
         | 
| 584 | 
            +
             | 
| 591 585 | 
             
              retval = PQsendQuery(db, str);
         | 
| 592 586 |  | 
| 593 587 | 
             
              if (!retval) {
         | 
| @@ -596,7 +590,6 @@ static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) { | |
| 596 590 | 
             
                  if (PQstatus(db) == CONNECTION_OK) {
         | 
| 597 591 | 
             
                    retval = PQsendQuery(db, str);
         | 
| 598 592 | 
             
                  } else {
         | 
| 599 | 
            -
                    VALUE connection = rb_iv_get(self, "@connection");
         | 
| 600 593 | 
             
                    full_connect(connection, db);
         | 
| 601 594 | 
             
                    retval = PQsendQuery(db, str);
         | 
| 602 595 | 
             
                  }
         | 
| @@ -607,11 +600,8 @@ static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) { | |
| 607 600 | 
             
                }
         | 
| 608 601 | 
             
              }
         | 
| 609 602 |  | 
| 610 | 
            -
              gettimeofday(&start, NULL);
         | 
| 611 603 | 
             
              socket_fd = PQsocket(db);
         | 
| 612 604 |  | 
| 613 | 
            -
              data_objects_debug(query, &start);
         | 
| 614 | 
            -
             | 
| 615 605 | 
             
              for(;;) {
         | 
| 616 606 | 
             
                  FD_ZERO(&rset);
         | 
| 617 607 | 
             
                  FD_SET(socket_fd, &rset);
         | 
| @@ -633,6 +623,8 @@ static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) { | |
| 633 623 | 
             
                  }
         | 
| 634 624 | 
             
              }
         | 
| 635 625 |  | 
| 626 | 
            +
              data_objects_debug(connection, query, &start);
         | 
| 627 | 
            +
             | 
| 636 628 | 
             
              return PQgetResult(db);
         | 
| 637 629 | 
             
            }
         | 
| 638 630 | 
             
            #endif
         | 
| @@ -747,7 +739,7 @@ static void full_connect(VALUE self, PGconn *db) { | |
| 747 739 | 
             
                search_path_query = (char *)calloc(256, sizeof(char));
         | 
| 748 740 | 
             
                snprintf(search_path_query, 256, "set search_path to %s;", search_path);
         | 
| 749 741 | 
             
                r_query = rb_str_new2(search_path_query);
         | 
| 750 | 
            -
                result = cCommand_execute(self, db, r_query);
         | 
| 742 | 
            +
                result = cCommand_execute(Qnil, self, db, r_query);
         | 
| 751 743 |  | 
| 752 744 | 
             
                if (PQresultStatus(result) != PGRES_COMMAND_OK) {
         | 
| 753 745 | 
             
                  free((void *)search_path_query);
         | 
| @@ -758,21 +750,21 @@ static void full_connect(VALUE self, PGconn *db) { | |
| 758 750 | 
             
              }
         | 
| 759 751 |  | 
| 760 752 | 
             
              r_options = rb_str_new2(backslash_off);
         | 
| 761 | 
            -
              result = cCommand_execute(self, db, r_options);
         | 
| 753 | 
            +
              result = cCommand_execute(Qnil, self, db, r_options);
         | 
| 762 754 |  | 
| 763 755 | 
             
              if (PQresultStatus(result) != PGRES_COMMAND_OK) {
         | 
| 764 756 | 
             
                rb_warn("%s", PQresultErrorMessage(result));
         | 
| 765 757 | 
             
              }
         | 
| 766 758 |  | 
| 767 759 | 
             
              r_options = rb_str_new2(standard_strings_on);
         | 
| 768 | 
            -
              result = cCommand_execute(self, db, r_options);
         | 
| 760 | 
            +
              result = cCommand_execute(Qnil, self, db, r_options);
         | 
| 769 761 |  | 
| 770 762 | 
             
              if (PQresultStatus(result) != PGRES_COMMAND_OK) {
         | 
| 771 763 | 
             
                rb_warn("%s", PQresultErrorMessage(result));
         | 
| 772 764 | 
             
              }
         | 
| 773 765 |  | 
| 774 766 | 
             
              r_options = rb_str_new2(warning_messages);
         | 
| 775 | 
            -
              result = cCommand_execute(self, db, r_options);
         | 
| 767 | 
            +
              result = cCommand_execute(Qnil, self, db, r_options);
         | 
| 776 768 |  | 
| 777 769 | 
             
              if (PQresultStatus(result) != PGRES_COMMAND_OK) {
         | 
| 778 770 | 
             
                rb_warn("%s", PQresultErrorMessage(result));
         | 
| @@ -823,7 +815,7 @@ static VALUE cCommand_execute_non_query(int argc, VALUE *argv[], VALUE self) { | |
| 823 815 |  | 
| 824 816 | 
             
              VALUE query = build_query_from_args(self, argc, argv);
         | 
| 825 817 |  | 
| 826 | 
            -
              response = cCommand_execute(self, db, query);
         | 
| 818 | 
            +
              response = cCommand_execute(self, connection, db, query);
         | 
| 827 819 |  | 
| 828 820 | 
             
              status = PQresultStatus(response);
         | 
| 829 821 |  | 
| @@ -863,7 +855,7 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv[], VALUE self) { | |
| 863 855 |  | 
| 864 856 | 
             
              query = build_query_from_args(self, argc, argv);
         | 
| 865 857 |  | 
| 866 | 
            -
              response = cCommand_execute(self, db, query);
         | 
| 858 | 
            +
              response = cCommand_execute(self, connection, db, query);
         | 
| 867 859 |  | 
| 868 860 | 
             
              if ( PQresultStatus(response) != PGRES_TUPLES_OK ) {
         | 
| 869 861 | 
             
                raise_error(self, response, query);
         | 
| @@ -887,7 +879,7 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv[], VALUE self) { | |
| 887 879 | 
             
                // Whoops...  wrong number of types passed to set_types.  Close the reader and raise
         | 
| 888 880 | 
             
                // and error
         | 
| 889 881 | 
             
                rb_funcall(reader, rb_intern("close"), 0);
         | 
| 890 | 
            -
                rb_raise( | 
| 882 | 
            +
                rb_raise(rb_eArgError, "Field-count mismatch. Expected %ld fields, but the query yielded %d", RARRAY_LEN(field_types), field_count);
         | 
| 891 883 | 
             
              }
         | 
| 892 884 |  | 
| 893 885 | 
             
              for ( i = 0; i < field_count; i++ ) {
         | 
| @@ -993,24 +985,24 @@ static VALUE cReader_field_count(VALUE self) { | |
| 993 985 | 
             
            void Init_do_postgres() {
         | 
| 994 986 | 
             
              rb_require("date");
         | 
| 995 987 | 
             
              rb_require("bigdecimal");
         | 
| 988 | 
            +
              rb_require("data_objects");
         | 
| 989 | 
            +
             | 
| 990 | 
            +
              ID_CONST_GET = rb_intern("const_get");
         | 
| 996 991 |  | 
| 997 992 | 
             
              // Get references classes needed for Date/Time parsing
         | 
| 998 993 | 
             
              rb_cDate = CONST_GET(rb_mKernel, "Date");
         | 
| 999 994 | 
             
              rb_cDateTime = CONST_GET(rb_mKernel, "DateTime");
         | 
| 1000 995 | 
             
              rb_cBigDecimal = CONST_GET(rb_mKernel, "BigDecimal");
         | 
| 1001 996 |  | 
| 1002 | 
            -
              rb_funcall(rb_mKernel, rb_intern("require"), 1, rb_str_new2("data_objects"));
         | 
| 1003 | 
            -
             | 
| 1004 997 | 
             
            #ifdef RUBY_LESS_THAN_186
         | 
| 1005 998 | 
             
              ID_NEW_DATE = rb_intern("new0");
         | 
| 1006 999 | 
             
            #else
         | 
| 1007 1000 | 
             
              ID_NEW_DATE = rb_intern("new!");
         | 
| 1008 1001 | 
             
            #endif
         | 
| 1009 | 
            -
              ID_LOGGER = rb_intern("logger");
         | 
| 1010 | 
            -
              ID_DEBUG = rb_intern("debug");
         | 
| 1011 | 
            -
              ID_LEVEL = rb_intern("level");
         | 
| 1012 | 
            -
              ID_TO_S = rb_intern("to_s");
         | 
| 1013 1002 | 
             
              ID_RATIONAL = rb_intern("Rational");
         | 
| 1003 | 
            +
              ID_NEW = rb_intern("new");
         | 
| 1004 | 
            +
              ID_ESCAPE = rb_intern("escape_sql");
         | 
| 1005 | 
            +
              ID_LOG = rb_intern("log");
         | 
| 1014 1006 |  | 
| 1015 1007 | 
             
              // Get references to the Extlib module
         | 
| 1016 1008 | 
             
              mExtlib = CONST_GET(rb_mKernel, "Extlib");
         | 
| @@ -1023,34 +1015,56 @@ void Init_do_postgres() { | |
| 1023 1015 | 
             
              cDO_Command = CONST_GET(mDO, "Command");
         | 
| 1024 1016 | 
             
              cDO_Result = CONST_GET(mDO, "Result");
         | 
| 1025 1017 | 
             
              cDO_Reader = CONST_GET(mDO, "Reader");
         | 
| 1018 | 
            +
              cDO_Logger = CONST_GET(mDO, "Logger");
         | 
| 1019 | 
            +
              cDO_Logger_Message = CONST_GET(cDO_Logger, "Message");
         | 
| 1026 1020 |  | 
| 1027 | 
            -
              eArgumentError = CONST_GET(rb_mKernel, "ArgumentError");
         | 
| 1028 1021 | 
             
              mPostgres = rb_define_module_under(mDO, "Postgres");
         | 
| 1029 1022 | 
             
              eConnectionError = CONST_GET(mDO, "ConnectionError");
         | 
| 1030 1023 | 
             
              eDataError = CONST_GET(mDO, "DataError");
         | 
| 1031 1024 | 
             
              mEncoding = rb_define_module_under(mPostgres, "Encoding");
         | 
| 1032 1025 |  | 
| 1033 | 
            -
              cConnection =  | 
| 1026 | 
            +
              cConnection = DRIVER_CLASS("Connection", cDO_Connection);
         | 
| 1034 1027 | 
             
              rb_define_method(cConnection, "initialize", cConnection_initialize, 1);
         | 
| 1035 1028 | 
             
              rb_define_method(cConnection, "dispose", cConnection_dispose, 0);
         | 
| 1036 1029 | 
             
              rb_define_method(cConnection, "character_set", cConnection_character_set , 0);
         | 
| 1037 1030 | 
             
              rb_define_method(cConnection, "quote_string", cConnection_quote_string, 1);
         | 
| 1038 1031 | 
             
              rb_define_method(cConnection, "quote_byte_array", cConnection_quote_byte_array, 1);
         | 
| 1039 1032 |  | 
| 1040 | 
            -
              cCommand =  | 
| 1033 | 
            +
              cCommand = DRIVER_CLASS("Command", cDO_Command);
         | 
| 1041 1034 | 
             
              rb_define_method(cCommand, "set_types", cCommand_set_types, -1);
         | 
| 1042 1035 | 
             
              rb_define_method(cCommand, "execute_non_query", cCommand_execute_non_query, -1);
         | 
| 1043 1036 | 
             
              rb_define_method(cCommand, "execute_reader", cCommand_execute_reader, -1);
         | 
| 1044 1037 |  | 
| 1045 | 
            -
              cResult =  | 
| 1038 | 
            +
              cResult = DRIVER_CLASS("Result", cDO_Result);
         | 
| 1046 1039 |  | 
| 1047 | 
            -
              cReader =  | 
| 1040 | 
            +
              cReader = DRIVER_CLASS("Reader", cDO_Reader);
         | 
| 1048 1041 | 
             
              rb_define_method(cReader, "close", cReader_close, 0);
         | 
| 1049 1042 | 
             
              rb_define_method(cReader, "next!", cReader_next, 0);
         | 
| 1050 1043 | 
             
              rb_define_method(cReader, "values", cReader_values, 0);
         | 
| 1051 1044 | 
             
              rb_define_method(cReader, "fields", cReader_fields, 0);
         | 
| 1052 1045 | 
             
              rb_define_method(cReader, "field_count", cReader_field_count, 0);
         | 
| 1053 1046 |  | 
| 1047 | 
            +
              rb_global_variable(&ID_NEW_DATE);
         | 
| 1048 | 
            +
              rb_global_variable(&ID_RATIONAL);
         | 
| 1049 | 
            +
              rb_global_variable(&ID_CONST_GET);
         | 
| 1050 | 
            +
              rb_global_variable(&ID_ESCAPE);
         | 
| 1051 | 
            +
              rb_global_variable(&ID_LOG);
         | 
| 1052 | 
            +
              rb_global_variable(&ID_NEW);
         | 
| 1053 | 
            +
             | 
| 1054 | 
            +
              rb_global_variable(&rb_cDate);
         | 
| 1055 | 
            +
              rb_global_variable(&rb_cDateTime);
         | 
| 1056 | 
            +
              rb_global_variable(&rb_cBigDecimal);
         | 
| 1057 | 
            +
              rb_global_variable(&rb_cByteArray);
         | 
| 1058 | 
            +
             | 
| 1059 | 
            +
              rb_global_variable(&mDO);
         | 
| 1060 | 
            +
              rb_global_variable(&cDO_Logger_Message);
         | 
| 1061 | 
            +
             | 
| 1062 | 
            +
              rb_global_variable(&cResult);
         | 
| 1063 | 
            +
              rb_global_variable(&cReader);
         | 
| 1064 | 
            +
             | 
| 1065 | 
            +
              rb_global_variable(&eConnectionError);
         | 
| 1066 | 
            +
              rb_global_variable(&eDataError);
         | 
| 1067 | 
            +
             | 
| 1054 1068 | 
             
              struct errcodes *errs;
         | 
| 1055 1069 |  | 
| 1056 1070 | 
             
              for (errs = errors; errs->error_name; errs++) {
         | 
| Binary file | 
| Binary file | 
    
        data/lib/do_postgres/version.rb
    CHANGED
    
    
    
        data/spec/encoding_spec.rb
    CHANGED
    
    | @@ -15,6 +15,7 @@ describe DataObjects::Postgres::Connection do | |
| 15 15 | 
             
                #   can be overridden -- but for now, we won't support doing this.
         | 
| 16 16 | 
             
                #
         | 
| 17 17 | 
             
                behaves_like 'a driver supporting different encodings'
         | 
| 18 | 
            -
                behaves_like 'returning correctly encoded strings for the default encoding'
         | 
| 18 | 
            +
                behaves_like 'returning correctly encoded strings for the default database encoding'
         | 
| 19 | 
            +
                behaves_like 'returning correctly encoded strings for the default internal encoding'
         | 
| 19 20 | 
             
              end
         | 
| 20 21 | 
             
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        data/tasks/compile.rake
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,12 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: do_postgres
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
               | 
| 4 | 
            +
              prerelease: false
         | 
| 5 | 
            +
              segments: 
         | 
| 6 | 
            +
              - 0
         | 
| 7 | 
            +
              - 10
         | 
| 8 | 
            +
              - 2
         | 
| 9 | 
            +
              version: 0.10.2
         | 
| 5 10 | 
             
            platform: x86-mingw32
         | 
| 6 11 | 
             
            authors: 
         | 
| 7 12 | 
             
            - Dirkjan Bussink
         | 
| @@ -9,39 +14,49 @@ autorequire: | |
| 9 14 | 
             
            bindir: bin
         | 
| 10 15 | 
             
            cert_chain: []
         | 
| 11 16 |  | 
| 12 | 
            -
            date: 2010- | 
| 17 | 
            +
            date: 2010-05-19 00:00:00 +02:00
         | 
| 13 18 | 
             
            default_executable: 
         | 
| 14 19 | 
             
            dependencies: 
         | 
| 15 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 16 21 | 
             
              name: data_objects
         | 
| 17 | 
            -
               | 
| 18 | 
            -
               | 
| 19 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 22 | 
            +
              prerelease: false
         | 
| 23 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 20 24 | 
             
                requirements: 
         | 
| 21 25 | 
             
                - - "="
         | 
| 22 26 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 23 | 
            -
                     | 
| 24 | 
            -
             | 
| 27 | 
            +
                    segments: 
         | 
| 28 | 
            +
                    - 0
         | 
| 29 | 
            +
                    - 10
         | 
| 30 | 
            +
                    - 2
         | 
| 31 | 
            +
                    version: 0.10.2
         | 
| 32 | 
            +
              type: :runtime
         | 
| 33 | 
            +
              version_requirements: *id001
         | 
| 25 34 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 26 35 | 
             
              name: bacon
         | 
| 27 | 
            -
               | 
| 28 | 
            -
               | 
| 29 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 36 | 
            +
              prerelease: false
         | 
| 37 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 30 38 | 
             
                requirements: 
         | 
| 31 39 | 
             
                - - ~>
         | 
| 32 40 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 41 | 
            +
                    segments: 
         | 
| 42 | 
            +
                    - 1
         | 
| 43 | 
            +
                    - 1
         | 
| 33 44 | 
             
                    version: "1.1"
         | 
| 34 | 
            -
             | 
| 45 | 
            +
              type: :development
         | 
| 46 | 
            +
              version_requirements: *id002
         | 
| 35 47 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 36 48 | 
             
              name: rake-compiler
         | 
| 37 | 
            -
               | 
| 38 | 
            -
               | 
| 39 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 40 51 | 
             
                requirements: 
         | 
| 41 52 | 
             
                - - ~>
         | 
| 42 53 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 54 | 
            +
                    segments: 
         | 
| 55 | 
            +
                    - 0
         | 
| 56 | 
            +
                    - 7
         | 
| 43 57 | 
             
                    version: "0.7"
         | 
| 44 | 
            -
             | 
| 58 | 
            +
              type: :development
         | 
| 59 | 
            +
              version_requirements: *id003
         | 
| 45 60 | 
             
            description: Implements the DataObjects API for PostgreSQL
         | 
| 46 61 | 
             
            email: d.bussink@gmail.com
         | 
| 47 62 | 
             
            executables: []
         | 
| @@ -101,13 +116,13 @@ post_install_message: |+ | |
| 101 116 | 
             
                ======================================================================================================
         | 
| 102 117 |  | 
| 103 118 | 
             
                  You've installed the binary version of do_postgres.
         | 
| 104 | 
            -
                  It was built using PostgreSQL version 8.3. | 
| 119 | 
            +
                  It was built using PostgreSQL version 8.3.10.
         | 
| 105 120 | 
             
                  It's recommended to use the exact same version to avoid potential issues.
         | 
| 106 121 |  | 
| 107 122 | 
             
                  At the time of building this gem, the necessary DLL files where available
         | 
| 108 123 | 
             
                  in the following download:
         | 
| 109 124 |  | 
| 110 | 
            -
                  http://wwwmaster.postgresql.org/redir/107/h/binary/v8.3. | 
| 125 | 
            +
                  http://wwwmaster.postgresql.org/redir/107/h/binary/v8.3.10/win32/postgresql-8.3.10-1-binaries-no-installer.zip
         | 
| 111 126 |  | 
| 112 127 | 
             
                  You can put the following files available in this package in your Ruby bin
         | 
| 113 128 | 
             
                  directory, for example C:\Ruby\bin
         | 
| @@ -132,18 +147,20 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 132 147 | 
             
              requirements: 
         | 
| 133 148 | 
             
              - - ">="
         | 
| 134 149 | 
             
                - !ruby/object:Gem::Version 
         | 
| 150 | 
            +
                  segments: 
         | 
| 151 | 
            +
                  - 0
         | 
| 135 152 | 
             
                  version: "0"
         | 
| 136 | 
            -
              version: 
         | 
| 137 153 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 138 154 | 
             
              requirements: 
         | 
| 139 155 | 
             
              - - ">="
         | 
| 140 156 | 
             
                - !ruby/object:Gem::Version 
         | 
| 157 | 
            +
                  segments: 
         | 
| 158 | 
            +
                  - 0
         | 
| 141 159 | 
             
                  version: "0"
         | 
| 142 | 
            -
              version: 
         | 
| 143 160 | 
             
            requirements: []
         | 
| 144 161 |  | 
| 145 162 | 
             
            rubyforge_project: dorb
         | 
| 146 | 
            -
            rubygems_version: 1.3. | 
| 163 | 
            +
            rubygems_version: 1.3.6
         | 
| 147 164 | 
             
            signing_key: 
         | 
| 148 165 | 
             
            specification_version: 3
         | 
| 149 166 | 
             
            summary: DataObjects PostgreSQL Driver
         |