Changeset 13645
- Timestamp:
- 01/31/08 17:32:46 (5 months ago)
- Files:
-
- trunk/gdal/ogr/ogrsf_frmts/ingres/GNUmakefile (modified) (1 diff)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogr_ingres.h (modified) (5 diffs)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresdatasource.cpp (modified) (6 diffs)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogringreslayer.cpp (modified) (2 diffs)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresresultlayer.cpp (added)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresstatement.cpp (modified) (2 diffs)
- trunk/gdal/ogr/ogrsf_frmts/ingres/ogringrestablelayer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/ogr/ogrsf_frmts/ingres/GNUmakefile
r13622 r13645 7 7 8 8 OBJ = ogringresdriver.o ogringresstatement.o ogringresdatasource.o \ 9 ogringrestablelayer.o ogringreslayer.o 9 ogringrestablelayer.o ogringreslayer.o ogringresresultlayer.o 10 10 11 11 # ogringresresultlayer.o trunk/gdal/ogr/ogrsf_frmts/ingres/ogr_ingres.h
r13622 r13645 61 61 char **GetRow(); 62 62 void DumpRow( FILE * ); 63 static void ReportError( IIAPI_GENPARM *, const char * = NULL ); 63 64 }; 64 65 … … 172 173 }; 173 174 174 #ifdef notdef175 175 /************************************************************************/ 176 176 /* OGRIngresResultLayer */ … … 190 190 public: 191 191 OGRIngresResultLayer( OGRIngresDataSource *, 192 const char * pszRawStatement,193 INGRES_RES *hResultSetIn);192 const char * pszRawStatement, 193 OGRIngresStatement *hStmt ); 194 194 virtual ~OGRIngresResultLayer(); 195 195 … … 200 200 virtual int GetFeatureCount( int ); 201 201 }; 202 #endif203 204 class OGRIngresLayer;205 202 206 203 /************************************************************************/ … … 262 259 // nonstandard 263 260 264 void ReportError( const char * = NULL );265 266 261 char *LaunderName( const char * ); 267 262 }; trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresdatasource.cpp
r13622 r13645 83 83 84 84 /************************************************************************/ 85 /* ReportError() */86 /************************************************************************/87 88 void OGRIngresDataSource::ReportError( const char *pszDescription )89 90 {91 #ifdef notdef92 if( pszDescription )93 CPLError( CE_Failure, CPLE_AppDefined,94 "Ingres error message:%s Description: %s",95 ingres_error( hConn ),96 pszDescription );97 else98 CPLError( CE_Failure, CPLE_AppDefined,99 "%s", ingres_error( hConn ) );100 #endif101 }102 103 /************************************************************************/104 85 /* Open() */ 105 86 /************************************************************************/ … … 152 133 153 134 IIapi_connect( &connParm ); 154 135 155 136 while( connParm.co_genParm.gp_completed == FALSE ) 156 137 IIapi_wait( &waitParm ); … … 158 139 hConn = connParm.co_connHandle; 159 140 160 if( hConn == NULL )161 {162 CPLError( CE_Failure, CPLE_OpenFailed,163 "Attempt to connect to Ingres database '%s' failed.",164 pszDBName);141 if( connParm.co_genParm.gp_status != IIAPI_ST_SUCCESS 142 || hConn == NULL ) 143 { 144 OGRIngresStatement::ReportError( &(connParm.co_genParm), 145 "Failed to connect to Ingres database." ); 165 146 return FALSE; 166 147 } … … 543 524 544 525 { 545 #ifdef notdef546 if( poSpatialFilter != NULL )547 {548 CPLDebug( "OGR_INGRES",549 "Spatial filter ignored for now in OGRIngresDataSource::ExecuteSQL()" );550 }551 552 526 /* -------------------------------------------------------------------- */ 553 527 /* Use generic implementation for OGRSQL dialect. */ … … 558 532 pszDialect ); 559 533 560 /* -------------------------------------------------------------------- */ 561 /* Special case DELLAYER: command. */ 562 /* -------------------------------------------------------------------- */ 563 #ifdef notdef 564 if( EQUALN(pszSQLCommand,"DELLAYER:",9) ) 565 { 566 const char *pszLayerName = pszSQLCommand + 9; 567 568 while( *pszLayerName == ' ' ) 569 pszLayerName++; 570 571 DeleteLayer( pszLayerName ); 534 if( poSpatialFilter != NULL ) 535 { 536 CPLDebug( "OGR_INGRES", 537 "Spatial filter ignored for now in OGRIngresDataSource::ExecuteSQL()" ); 538 } 539 540 /* -------------------------------------------------------------------- */ 541 /* Execute the statement. */ 542 /* -------------------------------------------------------------------- */ 543 OGRIngresStatement *poStatement = new OGRIngresStatement( hConn ); 544 545 if( !poStatement->ExecuteSQL( pszSQLCommand ) ) 546 { 547 delete poStatement; 572 548 return NULL; 573 }574 #endif575 576 /* -------------------------------------------------------------------- */577 /* Make sure there isn't an active transaction already. */578 /* -------------------------------------------------------------------- */579 InterruptLongResult();580 581 /* -------------------------------------------------------------------- */582 /* Execute the statement. */583 /* -------------------------------------------------------------------- */584 INGRES_RES *hResultSet;585 586 if( ingres_query( hConn, pszSQLCommand ) )587 {588 ReportError( pszSQLCommand );589 return NULL;590 }591 592 hResultSet = ingres_use_result( hConn );593 if( hResultSet == NULL )594 {595 if( ingres_field_count( hConn ) == 0 )596 {597 CPLDebug( "INGRES", "Command '%s' succeeded, %d rows affected.",598 pszSQLCommand,599 (int) ingres_affected_rows(hConn) );600 return NULL;601 }602 else603 {604 ReportError( pszSQLCommand );605 return NULL;606 }607 549 } 608 550 … … 614 556 OGRIngresResultLayer *poLayer = NULL; 615 557 616 poLayer = new OGRIngresResultLayer( this, pszSQLCommand, hResultSet );558 poLayer = new OGRIngresResultLayer( this, pszSQLCommand, poStatement ); 617 559 618 560 return poLayer; 619 #endif620 return NULL;621 561 } 622 562 trunk/gdal/ogr/ogrsf_frmts/ingres/ogringreslayer.cpp
r13622 r13645 113 113 114 114 { 115 116 115 for( ; TRUE; ) 117 116 { … … 311 310 312 311 if( !poResultSet->ExecuteSQL( pszQueryStatement ) ) 313 {314 poDS->ReportError( pszQueryStatement );315 312 return NULL; 316 }317 313 } 318 314 trunk/gdal/ogr/ogrsf_frmts/ingres/ogringresstatement.cpp
r13622 r13645 129 129 IIapi_wait( &waitParm ); 130 130 131 if( queryParm.qy_genParm.gp_status != IIAPI_ST_SUCCESS 132 || hConn == NULL ) 133 { 134 ReportError( &(queryParm.qy_genParm), 135 CPLString().Printf( "IIapi_query(%s)", pszStatement ) ); 136 return FALSE; 137 } 138 131 139 if( queryParm.qy_stmtHandle == NULL ) 132 140 return FALSE; … … 236 244 } 237 245 246 /************************************************************************/ 247 /* ReportError() */ 248 /************************************************************************/ 249 250 void OGRIngresStatement::ReportError( IIAPI_GENPARM *genParm, 251 const char *pszDescription ) 252 253 { 254 IIAPI_GETEINFOPARM getErrParm; 255 256 /* 257 ** Check API call status. 258 */ 259 const char *pszCode = 260 (genParm->gp_status == IIAPI_ST_SUCCESS) ? 261 "IIAPI_ST_SUCCESS" : 262 (genParm->gp_status == IIAPI_ST_MESSAGE) ? 263 "IIAPI_ST_MESSAGE" : 264 (genParm->gp_status == IIAPI_ST_WARNING) ? 265 "IIAPI_ST_WARNING" : 266 (genParm->gp_status == IIAPI_ST_NO_DATA) ? 267 "IIAPI_ST_NO_DATA" : 268 (genParm->gp_status == IIAPI_ST_ERROR) ? 269 "IIAPI_ST_ERROR" : 270 (genParm->gp_status == IIAPI_ST_FAILURE) ? 271 "IIAPI_ST_FAILURE" : 272 (genParm->gp_status == IIAPI_ST_NOT_INITIALIZED) ? 273 "IIAPI_ST_NOT_INITIALIZED" : 274 (genParm->gp_status == IIAPI_ST_INVALID_HANDLE) ? 275 "IIAPI_ST_INVALID_HANDLE" : 276 (genParm->gp_status == IIAPI_ST_OUT_OF_MEMORY) ? 277 "IIAPI_ST_OUT_OF_MEMORY" : 278 "(unknown status)"; 279 280 /* 281 ** Check for error information. 282 */ 283 if ( ! genParm->gp_errorHandle ) return; 284 getErrParm.ge_errorHandle = genParm->gp_errorHandle; 285 286 CPLString osErrorMessage; 287 CPLErr eType = CE_Failure; 288 289 osErrorMessage.Printf( "%s: %s", pszDescription, pszCode ); 290 291 do 292 { 293 /* 294 ** Invoke API function call. 295 */ 296 IIapi_getErrorInfo( &getErrParm ); 297 298 /* 299 ** Break out of the loop if no data or failed. 300 */ 301 if ( getErrParm.ge_status != IIAPI_ST_SUCCESS ) 302 break; 303 304 /* 305 ** Process result. 306 */ 307 308 switch( getErrParm.ge_type ) 309 { 310 case IIAPI_GE_ERROR : 311 eType = CE_Failure; 312 break; 313 314 case IIAPI_GE_WARNING : 315 eType = CE_Warning; 316 break; 317 318 case IIAPI_GE_MESSAGE : 319 eType = CE_Debug; 320 break; 321 322 default: 323 eType = CE_Failure; 324 break; 325 } 326 327 CPLString osMoreMsg; 328 329 osMoreMsg.Printf( "\n'%s' 0x%x\n%s", 330 getErrParm.ge_SQLSTATE, getErrParm.ge_errorCode, 331 getErrParm.ge_message ? getErrParm.ge_message : "NULL" ); 332 osErrorMessage += osMoreMsg; 333 } while( 1 ); 334 335 CPLError( eType, CPLE_AppDefined, "%s", osErrorMessage.c_str() ); 336 } 337 trunk/gdal/ogr/ogrsf_frmts/ingres/ogringrestablelayer.cpp
r13622 r13645 114 114 if( !oStatement.ExecuteSQL( osCommand ) ) 115 115 { 116 poDS->ReportError( "DESCRIBE Failed" );117 116 return NULL; 118 117 }
