--- sql/oracle/parser3oracle.C 2001/11/14 09:30:30 1.10 +++ sql/oracle/parser3oracle.C 2002/10/31 10:13:57 1.22 @@ -1,13 +1,13 @@ /** @file Parser Oracle driver. - Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) + Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + Author: Alexandr Petrosian (http://paf.design.ru) 2001.07.30 using Oracle 8.1.6 [@test tested with Oracle 7.x.x] */ -static const char *RCSId="$Id: parser3oracle.C,v 1.10 2001/11/14 09:30:30 paf Exp $"; +static const char *RCSId="$Id: parser3oracle.C,v 1.22 2002/10/31 10:13:57 paf Exp $"; #include "config_includes.h" @@ -189,7 +189,6 @@ void tolower(char *out, const char *in, /** OracleSQL server driver - @test NLS_LANG=AMERICAN_AMERICA.CL8MSWIN1251 */ class OracleSQL_Driver : public SQL_Driver { public: @@ -317,12 +316,7 @@ public: // return created connection *(OracleSQL_connection_struct **)connection=&cs; } - /// @test remove return void disconnect(void *connection) { - - return; - - OracleSQL_connection_struct &cs=*(OracleSQL_connection_struct *)connection; // Terminate a user session OCISessionEnd( @@ -370,22 +364,19 @@ public: unsigned int quote( SQL_Driver_services&, void *, char *to, const char *from, unsigned int length) { - /* - it's already UNTAINT_TIMES_BIGGER - */ - unsigned int result=length; - while(length--) { - switch(*from) { - case '\'': // "'" -> "''" - *to++='\''; - break; - case '\\': // "\" -> "\\" - *to++='\''; - break; + if(to) { // store mode + unsigned int result=length; + while(length--) { + switch(*from) { + case '\'': // "'" -> "''" + *to++='\''; result++; + break; + } + *to++=*from++; } - *to++=*from++; - } - return result; + return result; + } else // estimate mode + return length*2; } void query( SQL_Driver_services& services, void *connection, @@ -492,7 +483,7 @@ private: // private funcs const char *start=o; bool escaped=false; while(*o && !(o[0]=='\'' && o[1]!='\'' && !escaped)) { - escaped=*o=='\\' || (o[0]=='\'' && o[1]=='\''); + escaped=o[0]=='\'' && o[1]=='\''; if(escaped) { // write pending, skip "\" or "'" if(size_t size=o-start) { @@ -557,6 +548,9 @@ private: // private funcs (dvoid *)stmthp, (ub4)OCI_HTYPE_STMT, (ub1 *)&stmt_type, (ub4 *)0, OCI_ATTR_STMT_TYPE, cs.errhp)); */ + + while(isspace(*statement)) + statement++; if(strncasecmp(statement, "select", 6)==0) stmt_type=OCI_STMT_SELECT; else if(strncasecmp(statement, "insert", 6)==0) @@ -606,19 +600,18 @@ private: // private funcs void fetch_table(SQL_Driver_services& services, OracleSQL_connection_struct &cs, OCIStmt *stmthp, unsigned long offset, unsigned long limit, SQL_Driver_query_event_handlers& handlers) { -/* + ub4 prefetch_rows=100; check(services, cs, "AttrSet prefetch-rows", OCIAttrSet( (dvoid *)stmthp, (ub4)OCI_HTYPE_STMT, (dvoid *)&prefetch_rows, (ub4)0, (ub4)OCI_ATTR_PREFETCH_ROWS, (OCIError *)cs.errhp)); - ub4 prefetch_mem_size=100*1024; + ub4 prefetch_mem_size=100*0x400; check(services, cs, "AttrSet prefetch-memory", OCIAttrSet( (dvoid *)stmthp, (ub4)OCI_HTYPE_STMT, (dvoid *)&prefetch_mem_size, (ub4)0, (ub4)OCI_ATTR_PREFETCH_MEMORY, (OCIError *)cs.errhp)); -*/ OCIParam *mypard; ub2 dtype; @@ -701,7 +694,7 @@ private: // private funcs handlers.before_rows(); - for(unsigned long row=0; !limit||row