|
|
| version 1.35, 2008/07/08 09:21:08 | version 1.37, 2010/10/27 22:48:50 |
|---|---|
| Line 210 public: | Line 210 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 367 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 529 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 %u", (limit)?limit+offset:0/*no point to skip anything if we need 0 rows*/); |