Diff for /sql/sqlite/parser3sqlite.C between versions 1.13 and 1.14

version 1.13, 2012/06/15 09:09:33 version 1.14, 2017/01/13 16:54:37
Line 14 Line 14
 #include "sqlite3.h"  #include "sqlite3.h"
 #include "ltdl.h"  #include "ltdl.h"
   
 #define MAX_COLS   500  
 #define MAX_STRING 0x400  #define MAX_STRING 0x400
 #define MAX_NUMBER 20  #define MAX_NUMBER 20
   
Line 295  public: Line 294  public:
                         if(!column_count){ // empty result: insert|delete|update|...                          if(!column_count){ // empty result: insert|delete|update|...
                                 rc=sqlite3_step(SQL);                                  rc=sqlite3_step(SQL);
                         } else {                          } else {
                                 if(column_count>MAX_COLS)  
                                         column_count=MAX_COLS;  
   
                                 int column_types[MAX_COLS];  
                                 bool transcode_column[MAX_COLS];  
   
                                 for(int i=0; i<column_count; i++){                                  for(int i=0; i<column_count; i++){
                                         const char *column_name=sqlite3_column_name(SQL, i);                                          const char *column_name=sqlite3_column_name(SQL, i);
                                         size_t length=strlen(column_name);                                          size_t length=strlen(column_name);
Line 322  public: Line 315  public:
   
                                 const char *str;                                  const char *str;
                                 size_t length=0;                                  size_t length=0;
                                 bool first_row=true;  
   
                                 do{                                  do{
                                         rc=sqlite3_step(SQL);                                          rc=sqlite3_step(SQL);
Line 331  public: Line 323  public:
                                                 CHECK(handlers.add_row(sql_error));                                                  CHECK(handlers.add_row(sql_error));
   
                                                 for(int i=0; i<column_count; i++){                                                  for(int i=0; i<column_count; i++){
                                                         if(first_row){  
                                                                 column_types[i]=sqlite3_column_type(SQL, i);  
                                                                 switch(column_types[i]){  
                                                                         case SQLITE_INTEGER:  
                                                                         case SQLITE_FLOAT:  
                                                                         case SQLITE_NULL:  
                                                                                 transcode_column[i]=false;  
                                                                                 break;  
                                                                         default:  
                                                                                 transcode_column[i]=transcode_needed;  
                                                                                 break;  
                                                                 }  
                                                         }  
   
                                                         // SQLite allow to get value of any type using sqlite3_column_text function                                                          // SQLite allow to get value of any type using sqlite3_column_text function
                                                         switch(column_types[i]){                                                          bool transcode_value=false;
                                                           int column_type=sqlite3_column_type(SQL, i);
                                                           switch(column_type){
                                                                 case SQLITE_NULL:                                                                  case SQLITE_NULL:
                                                                         length=0;                                                                          length=0;
                                                                         str=NULL;                                                                          str=NULL;
Line 355  public: Line 335  public:
                                                                         str=(const char*)sqlite3_column_blob(SQL, i);                                                                          str=(const char*)sqlite3_column_blob(SQL, i);
                                                                         length=(size_t)sqlite3_column_bytes(SQL, i);                                                                          length=(size_t)sqlite3_column_bytes(SQL, i);
                                                                         break;                                                                          break;
                                                                   case SQLITE_TEXT: // for text transcoding can be required
                                                                 default: // anything else?                                                                  default: // anything else?
                                                                           transcode_value=transcode_needed;
                                                                   case SQLITE_INTEGER:
                                                                   case SQLITE_FLOAT:
                                                                         str=(const char*)sqlite3_column_text(SQL, i);                                                                          str=(const char*)sqlite3_column_text(SQL, i);
                                                                         length=(size_t)sqlite3_column_bytes(SQL, i);                                                                          length=(size_t)sqlite3_column_bytes(SQL, i);
                                                                         break;                                                                          break;
Line 363  public: Line 347  public:
   
                                                         if(length){                                                          if(length){
                                                                 char* strm=(char*)services.malloc_atomic(length+1);                                                                  char* strm=(char*)services.malloc_atomic(length+1);
                                                                 memcpy(strm, str, length+1);                                                                  memcpy(strm, str, length);
                                                                   strm[length]=0;
                                                                 str=strm;                                                                  str=strm;
   
                                                                 if(transcode_column[i]){                                                                  if(transcode_value){
                                                                         // transcode cell value from ?ClientCharset to $request:charset                                                                          // transcode cell value from ?ClientCharset to $request:charset
                                                                         services.transcode(str, length,                                                                          services.transcode(str, length,
                                                                                 str, length,                                                                                  str, length,
Line 379  public: Line 364  public:
                                                         CHECK(handlers.add_row_cell(sql_error, str, length));                                                          CHECK(handlers.add_row_cell(sql_error, str, length));
   
                                                 }                                                  }
                                                 first_row=false;  
                                         }                                          }
                                 } while(rc==SQLITE_BUSY || rc==SQLITE_ROW);                                  } while(rc==SQLITE_BUSY || rc==SQLITE_ROW);
   

Removed from v.1.13  
changed lines
  Added in v.1.14


E-mail: