[Mono-list] OdbcDataReader.cs bug. Attached with fix.

ndo at rockwellcollins.com ndo at rockwellcollins.com
Mon Jun 13 18:21:39 EDT 2005


Skipped content of type multipart/alternative-------------- next part --------------
5c5
< //   Brian Ritchie (brianlritchie at hotmail.com)
---
> //   Brian Ritchie (brianlritchie at hotmail.com) 
23c23
< //
---
> // 
26c26
< //
---
> // 
92c92
<                 private CommandBehavior CommandBehavior
---
>                 private CommandBehavior CommandBehavior 
107c107
<                 protected override bool IsValidRow
---
>                 protected override bool IsValidRow 
225,226c225,226
< 				OdbcReturn ret=libodbc.SQLDescribeCol(hstmt, Convert.ToUInt16(ordinal+1),
< 					colname_buffer, bufsize, ref colname_size, ref dt, ref ColSize,
---
> 				OdbcReturn ret=libodbc.SQLDescribeCol(hstmt, Convert.ToUInt16(ordinal+1), 
> 					colname_buffer, bufsize, ref colname_size, ref dt, ref ColSize, 
228c228
< 				if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
---
> 				if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) 
250c250
< 			if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
---
> 			if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) 
256,257c256,257
< 			ret = libodbc.SQLFreeHandle( (ushort) OdbcHandleType.Stmt, hstmt);
< 			if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
---
> 			ret = libodbc.SQLFreeHandle( (ushort) OdbcHandleType.Stmt, hstmt);
> 			if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) 
270c270
< 		public
---
> 		public 
279c279
< 		public
---
> 		public 
288c288
< 		public
---
> 		public 
300c300
<                         ret=libodbc.SQLGetData (hstmt, (ushort) (ordinal+1), SQL_C_TYPE.BINARY, tbuff, length,
---
>                         ret=libodbc.SQLGetData (hstmt, (ushort) (ordinal+1), SQL_C_TYPE.BINARY, tbuff, length, 
306c306
<                         if ( (ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo))
---
>                         if ( (ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo)) 
325c325
<                                         if (sqlstate != libodbc.SQLSTATE_RIGHT_TRUNC)
---
>                                         if (sqlstate != libodbc.SQLSTATE_RIGHT_TRUNC) 
346c346
< 		public
---
> 		public 
356c356
< 		public
---
> 		public 
367c367
< 		public
---
> 		public 
376c376
< 		public
---
> 		public 
389c389
< 		public
---
> 		public 
399c399
< 		public
---
> 		public 
408c408
< 		public
---
> 		public 
417c417
< 		public
---
> 		public 
426c426
< 		public
---
> 		public 
436c436
< 		public
---
> 		public 
445c445
< 		public
---
> 		public 
454c454
< 		public
---
> 		public 
463c463
< 		public
---
> 		public 
472c472
< 		public
---
> 		public 
481c481
< 		public
---
> 		public 
500c500
<                 DataTable GetSchemaTable()
---
>                 DataTable GetSchemaTable() 
502c502
<                         // FIXME :
---
>                         // FIXME : 
506c506
<                         // * Cache this DataTable so that it is not contacting
---
>                         // * Cache this DataTable so that it is not contacting 
510c510
< 			// Only Results from SQL SELECT Queries
---
> 			// Only Results from SQL SELECT Queries 
513c513
< 			if(cols.Length > 0)
---
> 			if(cols.Length > 0) 
546c546
< 				for (int i = 0; i < cols.Length; i += 1 )
---
> 				for (int i = 0; i < cols.Length; i += 1 ) 
599c599
< 					// FIXME: according to Brian,
---
> 					// FIXME: according to Brian, 
601c601
< 					// however, we need it for Mono
---
> 					// however, we need it for Mono 
611c611
< 		public
---
> 		public 
626c626
< 		public
---
> 		public 
651a652
> 					case OdbcType.Numeric:
654,655c655
< 						buffer=new byte[bufsize];  // According to sqlext.h, use SQL_CHAR for decima.
<                                                 // 2005 03 10 : this now works with unixodbc with numeric c type.
---
> 						buffer=new byte[bufsize];  // According to sqlext.h, use SQL_CHAR for decimal. 
657,661c657,660
< 						byte[] temp = new byte[outsize];
<                                                 for (int i=0;i<outsize;i++)
<                                                         temp[i]=buffer[i];
< 
< 						if (outsize!=-1)
---
> 						if (outsize!=-1) {
> 							byte[] temp = new byte[outsize];
> 							for (int i=0;i<outsize;i++)
> 								temp[i]=buffer[i];
662a662
> 						}
716c716
<                                                 if (outsize!=-1) // This means SQL_NULL_DATA
---
>                                                 if (outsize!=-1) // This means SQL_NULL_DATA 
739c739
< 				if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
---
> 				if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) 
742c742
< 				if (outsize==-1) // This means SQL_NULL_DATA
---
> 				if (outsize==-1) // This means SQL_NULL_DATA 
750c750
< 		public
---
> 		public 
823c823
< 			}
---
> 			}	
854,855c854,855
<                         ret = libodbc.SQLColAttribute (hstmt, column, fieldId,
<                                                        buffer, buffer.Length,
---
>                         ret = libodbc.SQLColAttribute (hstmt, column, fieldId, 
>                                                        buffer, buffer.Length, 
872,873c872,873
<                         ret = libodbc.SQLColAttribute (hstmt, column, fieldId,
<                                                        buffer, buffer.Length,
---
>                         ret = libodbc.SQLColAttribute (hstmt, column, fieldId, 
>                                                        buffer, buffer.Length, 
891,892c891
<                         //string [] keys = new string [cols.Length];
< 						string [] keys = null;
---
>                         string [] keys = new string [cols.Length];
894c893
<                         OdbcReturn ret = OdbcReturn.Error;
---
>                         OdbcReturn ret = OdbcReturn.Error;                  
896c895
<                                 ret=libodbc.SQLAllocHandle(OdbcHandleType.Stmt,
---
>                                 ret=libodbc.SQLAllocHandle(OdbcHandleType.Stmt, 
898c897
< 				if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
---
> 				if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) 
906,907c905,906
<                                 ret = libodbc.SQLPrimaryKeys (handle, catalogName, -3,
<                                                               schemaName, -3,
---
>                                 ret = libodbc.SQLPrimaryKeys (handle, catalogName, -3,  
>                                                               schemaName, -3, 
919,922c918,919
<                                 //int i = 0;
< 								ArrayList keysList = new ArrayList();
< 						
< 								while (true) {
---
>                                 int i = 0;                              
>                                 while (true) {
927,937c924,926
<                                         
< 										//keys [i++] = pkey;
< 										keysList.Add(pkey);
< 								}
< 								
< 								if(keysList.Count > 0) {
< 									keys = new string[keysList.Count];
< 									keysList.CopyTo(keys);
< 								}
< 						
< 						} catch (OdbcException){
---
>                                         keys [i++] = pkey;
>                                 }
>                         } catch (OdbcException){
940,941d928
< 								if(keys == null) keys = new string[0];
< 						
944c931
<                                         if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
---
>                                         if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) 
948c935
<                                                 if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
---
>                                                 if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) 
950c937
<                                 }
---
>                                 }                             


More information about the Mono-list mailing list