[Mono-bugs] [Bug 58505][Maj] New - Arrays with invalid bounds

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 14 May 2004 09:40:59 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by g.bour@aposition.com.

http://bugzilla.ximian.com/show_bug.cgi?id=58505

--- shadow/58505	2004-05-14 09:40:59.000000000 -0400
+++ shadow/58505.tmp.6241	2004-05-14 09:40:59.000000000 -0400
@@ -0,0 +1,110 @@
+Bug#: 58505
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Mandrake 9.1
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: g.bour@aposition.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Arrays with invalid bounds
+
+I am trying to get results from a Postgresql DB table, using the 
+pgsqlclient library.
+The concerned table is as following:
+
+CREATE TABLE test (
+  id int4,
+
+  a int4[],
+  b int4[],
+  c int4[]
+);
+
+Here is the program I made:
+// project created on 10/05/04 at 15:28
+using System;
+using System.Collections;
+using PostgreSql.Data.PgSqlClient;
+
+class MainClass
+{
+  public static void Main(string[] args)
+  {
+    PgConnection conn = new
+PgConnection("User=xxx;Password=xxx;Database=xxx;DataSource=xxx;SSL=false;Pooling=false");
+		conn.Open();
+		
+    PgCommand cmd = new PgCommand("SELECT id, a, b, c FROM test LIMIT 4",
+conn);
+    PgDataReader read = cmd.ExecuteReader();
+		
+    while(read.Read())
+    {
+	Int32 id	= (Int32) read["id"];
+	Array a 	= (Array) read["a"];
+	Array b		= (Array) read["b"];
+	Array c 	= (Array) read["c"];
+			
+	Console.WriteLine("sizes({3}): {0}/{1}/{2}", a.GetUpperBound(0),
+b.GetUpperBound(0), c.GetUpperBound(0), id);
+    }
+		
+    conn.Close();
+  }
+}
+
+pgsqlclient return int[] database fields as Arrays. It dynamically create
+those arrays by calling the 'CreateInstance' Array static function.
+
+The problem is that arrays are correctly created, but when I get them from
+the data reader, they had incorrect bounds
+
+Here is a correct result (the 'readPrimitiveArray...' lines are printed
+just after the array creation) (I get it with querying 3 lines) :
+--- result - without the bug ---
+readPrimitiveArray::Array size: 1-50
+readPrimitiveArray::Array size: 1-50
+readPrimitiveArray::Array size: 1-50
+readPrimitiveArray::Array size: 1-100
+readPrimitiveArray::Array size: 1-100
+readPrimitiveArray::Array size: 1-100
+readPrimitiveArray::Array size: 1-99
+readPrimitiveArray::Array size: 1-99
+readPrimitiveArray::Array size: 1-99
+sizes(-1233364945): 50/50/50
+sizes(-2129416499): 100/100/100
+sizes(-1577476903): 99/99/99
+
+
+And an Incorrect One (querying 4 lines):
+--- result - with the bug ---
+readPrimitiveArray::Array size: 1-50
+readPrimitiveArray::Array size: 1-50
+readPrimitiveArray::Array size: 1-50
+readPrimitiveArray::Array size: 1-100
+readPrimitiveArray::Array size: 1-100
+readPrimitiveArray::Array size: 1-100
+readPrimitiveArray::Array size: 1-99
+readPrimitiveArray::Array size: 1-99
+readPrimitiveArray::Array size: 1-99
+readPrimitiveArray::Array size: 1-100
+readPrimitiveArray::Array size: 1-100
+readPrimitiveArray::Array size: 1-100
+sizes(-1233364945): 100/100/100
+sizes(-2129416499): 134807255/134807247/134807239
+sizes(-1577476903): 134807231/134807223/134807215
+sizes(-1310993322): 100/100/100
+
+So the bug don't occur all the time: with 1,2,3 queried lines, its ok, but
+with more lines, arrays bounds are no more valids.
+
+Tested with Mono 0.91, pgsqlclient CVS and 1.0Beta6 and postgresql 7.4.1.
+Note that it works correctly under Windows/.Net