Changeset 11523

Show
Ignore:
Timestamp:
05/15/07 10:38:49 (2 years ago)
Author:
mloskot
Message:

Backported Kosta's patch fixing BLOB support in OGR MySQL driver to stable branch 1.4 (Ticket #1622).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.4/gdal/ogr/ogrsf_frmts/mysql/ogrmysqlresultlayer.cpp

    r10646 r11523  
    159159            poDefn->AddFieldDefn( &oField ); 
    160160            break; 
    161              
     161 
     162          case FIELD_TYPE_TINY_BLOB: 
     163          case FIELD_TYPE_MEDIUM_BLOB: 
     164          case FIELD_TYPE_LONG_BLOB: 
    162165          case FIELD_TYPE_BLOB: 
    163             oField.SetType( OFTString ); 
     166            oField.SetType( OFTBinary ); 
    164167            oField.SetWidth((int)psMSField->max_length); 
    165168            poDefn->AddFieldDefn( &oField ); 
  • branches/1.4/gdal/ogr/ogrsf_frmts/mysql/ogrmysqltablelayer.cpp

    r10646 r11523  
    632632/*      Execute the delete.                                             */ 
    633633/* -------------------------------------------------------------------- */ 
     634    poDS->InterruptLongResult(); 
    634635    if( mysql_query(poDS->GetConn(), osCommand.c_str() ) ){    
    635636        poDS->ReportError(  osCommand.c_str() ); 
     
    733734    for( i = 0; i < poFeatureDefn->GetFieldCount(); i++ ) 
    734735    { 
    735         const char *pszStrValue = poFeature->GetFieldAsString(i); 
    736         char *pszNeedToFree = NULL; 
    737  
    738736        if( !poFeature->IsFieldSet( i ) ) 
    739737            continue; 
     
    744742            bNeedComma = TRUE; 
    745743 
     744        const char *pszStrValue = poFeature->GetFieldAsString(i); 
     745 
    746746        if( poFeatureDefn->GetFieldDefn(i)->GetType() != OFTInteger 
    747                  && poFeatureDefn->GetFieldDefn(i)->GetType() != OFTReal ) 
     747                 && poFeatureDefn->GetFieldDefn(i)->GetType() != OFTReal 
     748                 && poFeatureDefn->GetFieldDefn(i)->GetType() != OFTBinary ) 
    748749        { 
    749750            int         iChar; 
     
    777778            osCommand += "'"; 
    778779        } 
     780        else if( poFeatureDefn->GetFieldDefn(i)->GetType() == OFTBinary ) 
     781        { 
     782            int binaryCount = 0; 
     783            GByte* binaryData = poFeature->GetFieldAsBinary(i, &binaryCount); 
     784            char* pszHexValue = CPLBinaryToHex( binaryCount, binaryData ); 
     785 
     786            osCommand += "x'"; 
     787            osCommand += pszHexValue; 
     788            osCommand += "'"; 
     789 
     790            CPLFree( pszHexValue ); 
     791        } 
    779792        else 
    780793        { 
     
    782795        } 
    783796 
    784         if( pszNeedToFree ) 
    785             CPLFree( pszNeedToFree ); 
    786797    } 
    787798 
     
    885896    } 
    886897 
     898    else if( oField.GetType() == OFTBinary ) 
     899    { 
     900        sprintf( szFieldType, "LONGBLOB" ); 
     901    } 
     902 
    887903    else if( oField.GetType() == OFTString ) 
    888904    {