Diff for /sql/odbc/parser3odbc.C between versions 1.27 and 1.28

version 1.27, 2008/06/27 12:54:44 version 1.28, 2008/06/27 13:38:36
Line 44  static const char *RCSId="$Id$"; Line 44  static const char *RCSId="$Id$";
 #ifndef strncasecmp  #ifndef strncasecmp
 #       define strncasecmp _strnicmp  #       define strncasecmp _strnicmp
 #endif  #endif
   #ifndef strcasecmp
   #       define strcasecmp _stricmp
   #endif
   
 static char *lsplit(char *string, char delim){  static char *lsplit(char *string, char delim){
         if(string){          if(string){
Line 55  static char *lsplit(char *string, char d Line 58  static char *lsplit(char *string, char d
         return 0;          return 0;
 }  }
   
   static char *lsplit(char **string_ref, char delim){
           char *result=*string_ref;
           char *next=lsplit(*string_ref, delim);
           *string_ref=next;
           return result;
   }
   
 static void toupper_str(char *out, const char *in, size_t size){  static void toupper_str(char *out, const char *in, size_t size){
         while(size--)          while(size--)
                 *out++=(char)toupper(*in++);                  *out++=(char)toupper(*in++);
Line 66  struct Connection { Line 76  struct Connection {
         CDatabase* db;          CDatabase* db;
         const char* client_charset;          const char* client_charset;
         bool autocommit;          bool autocommit;
         bool use_multi_row_fetch;          bool fast_offset_search;
 };  };
   
 /**  /**
Line 84  public: Line 94  public:
         const char *initialize(char *dlopen_file_spec) { return 0; }          const char *initialize(char *dlopen_file_spec) { return 0; }
         /**     connect          /**     connect
                 @param url                  @param url
                         format: @b DSN=dsn;UID=user;PWD=password (ODBC connect string)                          format: @b DSN=dsn;UID=user;PWD=password? (ODBC connect string)
                                 ;ClientCharset=charset  // transcode with parser                                  ClientCharset=charset&  // transcode with parser
                                 ;MultiRowFetch=1        // 0 -- disable (slower)                                  MultiRowFetch=1&        // 0 -- disable (slower)
                                 ;autocommit=1           // 0 -- disable auto commit                                  autocommit=1&           // 0 -- disable auto commit
                         WARNING: must be used only to connect, for buffer doesn't live long                          WARNING: must be used only to connect, for buffer doesn't live long
         */          */
   
Line 100  public: Line 110  public:
                 *connection_ref=&connection;                  *connection_ref=&connection;
                 connection.services=&services;                  connection.services=&services;
                 connection.client_charset=0;                  connection.client_charset=0;
                 connection.use_multi_row_fetch=true;                  connection.fast_offset_search=true;
                 connection.autocommit=true;                  connection.autocommit=true;
   
                 size_t url_length=strlen(url);                  size_t url_length=strlen(url);
                   char *options=lsplit(url, '?');
   
                 if(const char* key_start=strstr(url, "ClientCharset=")){                  while(options){
                         const char* value_start=key_start+14/*strlen("ClientCharset=")*/;                          if(char *key=lsplit(&options, '&')){
                         const char* value_end=strchr(value_start, ';');                                  if(*key){
                         if(!value_end)                                          if(char *value=lsplit(key, '=')){
                                 value_end=url+url_length;                                                  if(strcmp(key, "ClientCharset")==0){
                                                           toupper_str(value, value, strlen(value));
                         if(size_t value_length=value_end-value_start){                                                          connection.client_charset=value;
                                 char* client_charset=(char*)services.malloc_atomic(value_length+1);                                                  } else if(strcasecmp(key, "autocommit")==0){
                                 toupper_str(client_charset, value_start, value_length);                                                          if(atoi(value)==0)
                                 client_charset[value_length]=0;                                                                  connection.autocommit=false;
                                                   } else if(strcmp(key, "FastOffsetSearch")==0){
                                 connection.client_charset=client_charset;                                                          if(atoi(value)==0)
                         }                                                                  connection.fast_offset_search=false;
                 }                                                  } else
                 if(const char* key_start=strstr(url, "MultiRowFetch=")){                                                          services._throw("unknown connect option" /*key*/);
                         const char* value_start=key_start+14/*strlen("MultiRowFetch=")*/;                                          } else 
                         const char* value_end=strchr(value_start, ';');                                                  services._throw("connect option without =value" /*key*/);
                         if(!value_end)                                  }
                                 value_end=url+url_length;  
   
                         if(size_t value_length=value_end-value_start){  
                                 char* value=(char*)services.malloc_atomic(value_length+1);  
                                 memcpy(value, value_start, value_length);  
                                 value[value_length]=0;  
                                 if(atoi(value)==0)  
                                         connection.use_multi_row_fetch=false;  
                         }  
                 }  
                 if(const char* key_start=strstr(url, "autocommit=")){  
                         const char* value_start=key_start+11/*strlen("autocommit=")*/;  
                         const char* value_end=strchr(value_start, ';');  
                         if(!value_end)  
                                 value_end=url+url_length;  
   
                         if(size_t value_length=value_end-value_start){  
                                 char* value=(char*)services.malloc_atomic(value_length+1);  
                                 memcpy(value, value_start, value_length);  
                                 value[value_length]=0;  
                                 if(atoi(value)==0)  
                                         connection.autocommit=false;  
                         }                          }
                 }                  }
   
Line 266  public: Line 255  public:
                                 //CRecordset::useMultiRowFetch                                  //CRecordset::useMultiRowFetch
                                 //CRecordset::userAllocMultiRowBuffers                                  //CRecordset::userAllocMultiRowBuffers
                                 //CRecordset::useExtendedFetch                                  //CRecordset::useExtendedFetch
                                 /*  /*
                                 if(connection.use_multi_row_fetch){                                  if(connection.fast_offset_search){
                                         options+=CRecordset::useMultiRowFetch+CRecordset::userAllocMultiRowBuffers;                                          options+=CRecordset::useMultiRowFetch+CRecordset::userAllocMultiRowBuffers;
                                 } else {                                  } else {
                                         options+=CRecordset::skipDeletedRecords;                                          options+=CRecordset::skipDeletedRecords;
                                 }                                  }
                                 */  */
                                 TRY {                                  TRY {
                                         rs.Open(                                          rs.Open(
                                                 (connection.use_multi_row_fetch)?CRecordset::dynamic:CRecordset::forwardOnly,                                                  (connection.fast_offset_search)?CRecordset::dynamic:CRecordset::forwardOnly,
                                                 statement,                                                  statement,
                                                 options                                                  options
                                         );                                          );
Line 330  public: Line 319  public:
                                                                   
                                 // skip offset rows                                  // skip offset rows
                                 if(offset){                                  if(offset){
                                         if(connection.use_multi_row_fetch){                                          if(connection.fast_offset_search){
                                                 rs.Move(offset);                                                  rs.Move(offset);
                                         } else {                                          } else {
                                                 unsigned long row=offset;                                                  unsigned long row=offset;

Removed from v.1.27  
changed lines
  Added in v.1.28


E-mail: