Diff for /sql/odbc/parser3odbc.C between versions 1.35 and 1.41

version 1.35, 2008/07/08 09:21:08 version 1.41, 2015/10/26 16:00:50
Line 1 Line 1
 /** @file  /** @file
         Parser ODBC driver.          Parser ODBC driver.
   
         Copyright(c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)
   
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
 */  */
 static const char *RCSId="$Id$";   
   
 #ifndef _MSC_VER  #ifndef _MSC_VER
 #       error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)]  #       error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)]
Line 21  static const char *RCSId="$Id$"; Line 20  static const char *RCSId="$Id$";
 #define WINVER 0x0400  #define WINVER 0x0400
 #include <AFXDB.H>  #include <AFXDB.H>
   
   volatile const char * IDENT_PARSER3ODBC_C="$Id$" IDENT_PA_SQL_DRIVER_H;
   
 // defines  // defines
   
 #define MAX_COLS 500  #define MAX_COLS 500
Line 210  public: Line 211  public:
                 return true;                  return true;
         }          }
   
         const char* quote(void *aconnection, const char *from, unsigned int length){          // charset here is services.request_charset(), not connection.client_charset
           // thus we can't use the sql server quoting support
           const char* quote(void *aconnection, const char *str, unsigned int length) 
           {
                   const char* from;
                   const char* from_end=str+length;
   
                   size_t quoted=0;
   
                   for(from=str; from<from_end; from++){
                           if(*from=='\'')
                                   quoted++;
                   }
   
                   if(!quoted)
                           return str;
   
                 Connection& connection=*static_cast<Connection*>(aconnection);                  Connection& connection=*static_cast<Connection*>(aconnection);
                 char *result=(char*)connection.services->malloc_atomic(length*2+1);                  char *result=(char*)connection.services->malloc_atomic(length + quoted + 1);
                 char *to=result;                  char *to = result;
                 while(length--){  
                         if(*from=='\'') { // ' -> ''                  for(from=str; from<from_end; from++){
                                 *to++='\'';                          if(*from=='\'')
                         }                                  *to++= '\''; // ' -> ''
                         *to++=*from++;                          *to++=*from;
                 }                  }
                   
                 *to=0;                  *to=0;
                 return result;                  return result;
         }          }
Line 350  public: Line 368  public:
                                 CHECK(handlers.before_rows(sql_error));                                  CHECK(handlers.before_rows(sql_error));
                                                                   
                                 // skip offset rows                                  // skip offset rows
                                 if(offset && !mstatement.offset){                                  if(offset && limit!=0 && !mstatement.offset){
                                         unsigned long row=offset;                                          unsigned long row=offset;
                                         while(!rs.IsEOF() && row--)                                          while(!rs.IsEOF() && row--)
                                                 rs.MoveNext();                                                  rs.MoveNext();
Line 512  private: Line 530  private:
                                                         );                                                          );
   
                                                 result.limit=true;                                                  result.limit=true;
                                                 if(!limit)  
                                                         result.offset=true; // mark as we'll did it in query because of no point to skip anything if we need 0 rows  
                                                 result.statement=statement_limited;                                                  result.statement=statement_limited;
   
                                                 snprintf(statement_limited, MAX_NUMBER+11, "SELECT TOP %u", (limit)?limit+offset:0/*no point to skip anything if we need 0 rows*/);                                                  snprintf(statement_limited, MAX_NUMBER+11, "SELECT TOP %lu", (limit)?limit+offset:0/*no point to skip anything if we need 0 rows*/);
   
                                                 astatement+=6;/*skip 'select'*/                                                  astatement+=6;/*skip 'select'*/
                                                 strcat(statement_limited, astatement);                                                  strcat(statement_limited, astatement);
Line 539  private: Line 555  private:
                                                 result.offset=true;                                                  result.offset=true;
                                                 result.statement=statement_limited;                                                  result.statement=statement_limited;
   
                                                 statement_limited+=snprintf(statement_limited, MAX_NUMBER+15, "SELECT FIRST (%u)", limit);                                                  statement_limited+=snprintf(statement_limited, MAX_NUMBER+15, "SELECT FIRST (%lu)", limit);
                                                 if(offset && limit/*no reasons to skip something if we need 0 rows*/)                                                  if(offset && limit/*no reasons to skip something if we need 0 rows*/)
                                                         statement_limited+=snprintf(statement_limited, MAX_NUMBER+8, " SKIP (%u)", offset);                                                          statement_limited+=snprintf(statement_limited, MAX_NUMBER+8, " SKIP (%lu)", offset);
   
                                                 astatement+=6;/*skip 'select'*/                                                  astatement+=6;/*skip 'select'*/
                                                 strcat((char*)result.statement, astatement);                                                  strcat((char*)result.statement, astatement);
Line 569  private: Line 585  private:
   
         void _throw(Connection& connection, long value){          void _throw(Connection& connection, long value){
                 char msg[MAX_STRING];                  char msg[MAX_STRING];
                 snprintf(msg, MAX_STRING, "%u", value);                  snprintf(msg, MAX_STRING, "%lu", value);
                 connection.services->_throw(msg);                  connection.services->_throw(msg);
         }          }
   

Removed from v.1.35  
changed lines
  Added in v.1.41


E-mail: