Ticket #1622: mysql_blob.patch
| File mysql_blob.patch, 3.1 kB (added by Kosta, 1 year ago) |
|---|
-
ogr/ogrsf_frmts/mysql/ogrmysqlresultlayer.cpp
old new 158 158 oField.SetWidth((int)psMSField->length); 159 159 poDefn->AddFieldDefn( &oField ); 160 160 break; 161 161 162 case FIELD_TYPE_TINY_BLOB: 163 case FIELD_TYPE_MEDIUM_BLOB: 164 case FIELD_TYPE_LONG_BLOB: 162 165 case FIELD_TYPE_BLOB: 163 oField.SetType( OFT String);166 oField.SetType( OFTBinary ); 164 167 oField.SetWidth((int)psMSField->max_length); 165 168 poDefn->AddFieldDefn( &oField ); 166 169 break; -
ogr/ogrsf_frmts/mysql/ogrmysqltablelayer.cpp
old new 631 631 /* -------------------------------------------------------------------- */ 632 632 /* Execute the delete. */ 633 633 /* -------------------------------------------------------------------- */ 634 poDS->InterruptLongResult(); 634 635 if( mysql_query(poDS->GetConn(), osCommand.c_str() ) ){ 635 636 poDS->ReportError( osCommand.c_str() ); 636 637 return OGRERR_FAILURE; … … 732 733 733 734 for( i = 0; i < poFeatureDefn->GetFieldCount(); i++ ) 734 735 { 735 const char *pszStrValue = poFeature->GetFieldAsString(i);736 char *pszNeedToFree = NULL;737 738 736 if( !poFeature->IsFieldSet( i ) ) 739 737 continue; 740 738 … … 743 741 else 744 742 bNeedComma = TRUE; 745 743 744 const char *pszStrValue = poFeature->GetFieldAsString(i); 745 746 746 if( poFeatureDefn->GetFieldDefn(i)->GetType() != OFTInteger 747 && poFeatureDefn->GetFieldDefn(i)->GetType() != OFTReal ) 747 && poFeatureDefn->GetFieldDefn(i)->GetType() != OFTReal 748 && poFeatureDefn->GetFieldDefn(i)->GetType() != OFTBinary ) 748 749 { 749 750 int iChar; 750 751 … … 776 777 777 778 osCommand += "'"; 778 779 } 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 } 779 792 else 780 793 { 781 794 osCommand += pszStrValue; 782 795 } 783 796 784 if( pszNeedToFree )785 CPLFree( pszNeedToFree );786 797 } 787 798 788 799 osCommand += ")"; … … 884 895 sprintf( szFieldType, "TIME" ); 885 896 } 886 897 898 else if( oField.GetType() == OFTBinary ) 899 { 900 sprintf( szFieldType, "LONGBLOB" ); 901 } 902 887 903 else if( oField.GetType() == OFTString ) 888 904 { 889 905 if( oField.GetWidth() == 0 || !bPreservePrecision )
