Diff for /sql/pgsql/parser3pgsql.C between versions 1.10 and 1.13

version 1.10, 2002/12/15 08:52:10 version 1.13, 2003/07/24 10:09:40
Line 1 Line 1
 /** @file  /** @file
         Parser PgSQL driver.          Parser PgSQL driver.
   
         Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)          Copyright(c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com)
   
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
   
Line 175  public: Line 175  public:
                 return PQstatus((PGconn *)connection)==CONNECTION_OK;                  return PQstatus((PGconn *)connection)==CONNECTION_OK;
         }          }
   
         unsigned int quote(          const char* quote(
                 SQL_Driver_services&, void *connection,                  SQL_Driver_services& services, void *connection,
                 char *to, const char *from, unsigned int length) {                  const char *from, unsigned int length) {
                 if(to) { // store mode                  char *result=(char*)services.malloc_atomic(length*2+1);
                         unsigned int result=length;                  char *to=result;
                         while(length--) {                  while(length--) {
                                 switch(*from) {                          switch(*from) {
                                 case '\'': // "'" -> "''"                          case '\'': // "'" -> "''"
                                         *to++='\''; result++;                                  *to++='\''; result++;
                                         break;                                  break;
                                 case '\\': // "\" -> "\\"                          case '\\': // "\" -> "\\"
                                         *to++='\\'; result++;                                  *to++='\\'; result++;
                                         break;                                  break;
                                 }  
                                 *to++=*from++;  
                         }                          }
                         return result;                          *to++=*from++;
                 } else // estimate mode                  }
                         return length*2;                  *to=0;
         }                  return result;
                   }
         void query(          void query(
                 SQL_Driver_services& services, void *connection,                   SQL_Driver_services& services, void *connection, 
                 const char *astatement, unsigned long offset, unsigned long limit,                  const char *astatement, unsigned long offset, unsigned long limit,
Line 240  public: Line 239  public:
                 for(int i=0; i<column_count; i++){                  for(int i=0; i<column_count; i++){
                         char *name=PQfname(res, i);                          char *name=PQfname(res, i);
                         size_t size=strlen(name);                          size_t size=strlen(name);
                         void *ptr=services.malloc(size);                          char* str=(char*)services.malloc(size+1);
                         memcpy(ptr, name, size);                          memcpy(str, name, size+1);
                         CHECK(handlers.add_column(sql_error, ptr, size));                          CHECK(handlers.add_column(sql_error, str, size));
                 }                  }
   
                 CHECK(handlers.before_rows(sql_error));                  CHECK(handlers.before_rows(sql_error));
Line 253  public: Line 252  public:
                                 for(int i=0; i<column_count; i++){                                  for(int i=0; i<column_count; i++){
                                         const char *cell=PQgetvalue(res, r, i);                                          const char *cell=PQgetvalue(res, r, i);
                                         size_t size;                                          size_t size;
                                         void *ptr;                                          char* str;
                                         if(PQftype(res, i)==OIDOID) {                                          if(PQftype(res, i)==OIDOID) {
                                                 // ObjectID column, read object bytes                                                  // ObjectID column, read object bytes
   
Line 274  public: Line 273  public:
                                                         size=(size_t)size_tell;                                                          size=(size_t)size_tell;
                                                         if(size) {                                                          if(size) {
                                                                 // read                                                                   // read 
                                                                 ptr=services.malloc(size);                                                                  str=(char*)services.malloc(size+1);
                                                                 if(!lo_read_ex(conn, fd, (const char *)ptr, size_tell))                                                                  if(!lo_read_ex(conn, fd, str, size_tell))
                                                                         PQclear_throw("lo_read can not read all bytes of object");                                                                          PQclear_throw("lo_read can not read all bytes of object");
                                                                   str[size]=0;
                                                         } else                                                          } else
                                                                 ptr=0;                                                                  str=0;
                                                         if(lo_close(conn, fd)<0)                                                          if(lo_close(conn, fd)<0)
                                                                 PQclear_throwPQerror;                                                                  PQclear_throwPQerror;
                                                 } else                                                  } else
Line 287  public: Line 287  public:
                                                 // normal column, read it normally                                                  // normal column, read it normally
                                                 size=(size_t)PQgetlength(res, r, i);                                                  size=(size_t)PQgetlength(res, r, i);
                                                 if(size) {                                                  if(size) {
                                                         ptr=services.malloc(size);                                                          str=(char*)services.malloc(size+1);
                                                         memcpy(ptr, cell, size);                                                          memcpy(str, cell, size+1);
                                                 } else                                                  } else
                                                         ptr=0;                                                          str=0;
                                         }                                          }
                                         CHECK(handlers.add_row_cell(sql_error, ptr, size));                                          CHECK(handlers.add_row_cell(sql_error, str, size));
                                 }                                  }
                         }                          }
 cleanup:  cleanup:
Line 448  private: // conn client library funcs Line 448  private: // conn client library funcs
 private: // conn client library funcs linking  private: // conn client library funcs linking
   
         const char *dlink(const char *dlopen_file_spec) {          const char *dlink(const char *dlopen_file_spec) {
                   if(lt_dlinit())
                           return lt_dlerror();
         lt_dlhandle handle=lt_dlopen(dlopen_file_spec);          lt_dlhandle handle=lt_dlopen(dlopen_file_spec);
         if(!handle)          if(!handle)
                         return "can not open the dynamic link module";                          return "can not open the dynamic link module";

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


E-mail: