[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient PgDataType.cs,1.1
Status: Inactive
Brought to you by:
carlosga_fb
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient
In directory sc8-pr-cvs1:/tmp/cvs-serv29474
Modified Files:
PgDataType.cs PgDbClient.cs PgType.cs PgTypeCollection.cs
Log Message:
- Improved types handling
- Added definitions of geometric array types
Index: PgDataType.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDataType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PgDataType.cs 17 Oct 2003 18:24:02 -0000 1.1
--- PgDataType.cs 18 Oct 2003 19:14:43 -0000 1.2
***************
*** 30,34 ****
Boolean ,
Box ,
! Byte ,
Char ,
Circle ,
--- 30,34 ----
Boolean ,
Box ,
! Byte ,
Char ,
Circle ,
***************
*** 39,50 ****
Float ,
Int2 ,
! Int4 ,
Int8 ,
Line ,
LSeg ,
! Numeric ,
Path ,
Point ,
! Polygon ,
Text ,
Time ,
--- 39,50 ----
Float ,
Int2 ,
! Int4 ,
Int8 ,
Line ,
LSeg ,
! Numeric ,
Path ,
Point ,
! Polygon ,
Text ,
Time ,
Index: PgDbClient.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDbClient.cs,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** PgDbClient.cs 18 Oct 2003 14:46:26 -0000 1.25
--- PgDbClient.cs 18 Oct 2003 19:14:43 -0000 1.26
***************
*** 650,696 ****
types = new PgTypeCollection();
! types.Add(16 , "bool" , PgDataType.Boolean , Type.GetType("System.Boolean") , 0, 1, 1);
! types.Add(17 , "bytea" , PgDataType.Binary , Type.GetType("System.Array") , 0, 1, 0);
! types.Add(18 , "char" , PgDataType.Char , Type.GetType("System.String") , 0, 0, 0);
! types.Add(19 , "name" , PgDataType.VarChar , Type.GetType("System.String") , 0, 0, 0);
! types.Add(20 , "int8" , PgDataType.Int8 , Type.GetType("System.Int64") , 0, 1, 8);
! types.Add(21 , "int2" , PgDataType.Int2 , Type.GetType("System.Int16") , 0, 1, 2);
! types.Add(22 , "int2vector", PgDataType.Vector , Type.GetType("System.Array") , 21, 1, 2);
! types.Add(23 , "int4" , PgDataType.Int4 , Type.GetType("System.Int32") , 0, 1, 4);
! types.Add(24 , "regproc" , PgDataType.VarChar , Type.GetType("System.String") , 0, 0, 0);
! types.Add(25 , "text" , PgDataType.VarChar , Type.GetType("System.String") , 0, 0, 0);
! types.Add(26 , "oid" , PgDataType.Int4 , Type.GetType("System.Int32") , 0, 1, 4);
! types.Add(30 , "oidvector", PgDataType.Vector , Type.GetType("System.Array") , 26, 1, 4);
!
! types.Add(600 , "point" , PgDataType.Point , Type.GetType("System.Array") , 701, 1, 16);
! types.Add(601 , "lseg" , PgDataType.LSeg , Type.GetType("System.Array") , 600, 1, 32);
! types.Add(602 , "path" , PgDataType.Path , Type.GetType("System.Array") , 0, 1, -1);
! types.Add(603 , "box" , PgDataType.Box , Type.GetType("System.Array") , 600, 1, 32);
! types.Add(604 , "polygon" , PgDataType.Polygon , Type.GetType("System.Array") , 0, 1, 16);
! types.Add(628 , "line" , PgDataType.Line , Type.GetType("System.Array") , 701, 1, 32);
! types.Add(718 , "circle" , PgDataType.Circle , Type.GetType("System.Array") , 0, 1, 24);
!
! types.Add(700 , "float4" , PgDataType.Float , Type.GetType("System.Single") , 0, 1, 4);
! types.Add(701 , "float8" , PgDataType.Double , Type.GetType("System.Double") , 0, 1, 8);
! // types.Add(705 , "unknown" , DbType.Object , Type.GetType("System.Object") , 0, 0, 0);
! types.Add(790 , "money" , PgDataType.Currency , Type.GetType("System.Decimal") , 0, 1, 4);
! types.Add(829 , "macaddr" , PgDataType.VarChar , Type.GetType("System.String") , 0, 0, 6);
! types.Add(869 , "inet" , PgDataType.VarChar , Type.GetType("System.String") , 0, 0, 0);
! types.Add(1005 , "_int2" , PgDataType.Binary , Type.GetType("System.Array") , 21, 1, 2);
! types.Add(1007 , "_int4" , PgDataType.Binary , Type.GetType("System.Array") , 23, 1, 4);
! types.Add(1016 , "_int8" , PgDataType.Binary , Type.GetType("System.Array") , 20, 1, 8);
! types.Add(1009 , "_text" , PgDataType.Binary , Type.GetType("System.Array") , 25, 1, 0);
! types.Add(1021 , "_float4" , PgDataType.Binary , Type.GetType("System.Array") , 700, 1, 4);
! types.Add(1033 , "aclitem" , PgDataType.VarChar , Type.GetType("System.String") , 0, 0, 12);
! types.Add(1034 , "_aclitem", PgDataType.Binary , Type.GetType("System.Array") , 1033, 0, 0);
! types.Add(1042 , "bpchar" , PgDataType.VarChar , Type.GetType("System.String") , 0, 0, 0);
! types.Add(1043 , "varchar" , PgDataType.VarChar , Type.GetType("System.String") , 0, 0, 0);
! types.Add(1082 , "date" , PgDataType.Date , Type.GetType("System.DateTime") , 0, 1, 4);
! types.Add(1083 , "time" , PgDataType.Time , Type.GetType("System.DateTime") , 0, 1, 8);
! types.Add(1114 , "timestamp", PgDataType.TimeStamp , Type.GetType("System.DateTime") , 0, 1, 8);
! types.Add(1560 , "bit" , PgDataType.Byte , Type.GetType("System.Byte") , 0, 0, 1);
! types.Add(1562 , "varbit" , PgDataType.Byte , Type.GetType("System.Byte") , 0, 1, 0);
! types.Add(1700 , "numeric" , PgDataType.Decimal , Type.GetType("System.Decimal") , 0, 0, 8);
! types.Add(2277 , "anyarray", PgDataType.Binary , Type.GetType("System.Array") , 0, 1, 8);
}
--- 650,701 ----
types = new PgTypeCollection();
! types.Add(16 , "bool" , PgDataType.Boolean , 0, 1, 1);
! types.Add(17 , "bytea" , PgDataType.Binary , 0, 1, 0);
! types.Add(18 , "char" , PgDataType.Char , 0, 0, 0);
! types.Add(19 , "name" , PgDataType.VarChar , 0, 0, 0);
! types.Add(20 , "int8" , PgDataType.Int8 , 0, 1, 8);
! types.Add(21 , "int2" , PgDataType.Int2 , 0, 1, 2);
! types.Add(22 , "int2vector" , PgDataType.Vector , 21, 1, 2);
! types.Add(23 , "int4" , PgDataType.Int4 , 0, 1, 4);
! types.Add(24 , "regproc" , PgDataType.VarChar , 0, 0, 0);
! types.Add(25 , "text" , PgDataType.VarChar , 0, 0, 0);
! types.Add(26 , "oid" , PgDataType.Int4 , 0, 1, 4);
! types.Add(30 , "oidvector" , PgDataType.Vector , 26, 1, 4);
! types.Add(600 , "point" , PgDataType.Point , 701, 1, 16);
! types.Add(601 , "lseg" , PgDataType.LSeg , 600, 1, 32);
! types.Add(602 , "path" , PgDataType.Path , 0, 1, -1);
! types.Add(603 , "box" , PgDataType.Box , 600, 1, 32);
! types.Add(604 , "polygon" , PgDataType.Polygon , 0, 1, 16);
! types.Add(628 , "line" , PgDataType.Line , 701, 1, 32);
! types.Add(629 , "_line" , PgDataType.Array , 628, 1, 32);
! types.Add(718 , "circle" , PgDataType.Circle , 0, 1, 24);
! types.Add(719 , "_circle" , PgDataType.Array , 718, 1, 24);
! types.Add(700 , "float4" , PgDataType.Float , 0, 1, 4);
! types.Add(701 , "float8" , PgDataType.Double , 0, 1, 8);
! types.Add(705 , "unknown" , PgDataType.Binary , 0, 1, 0);
! types.Add(790 , "money" , PgDataType.Currency , 0, 1, 4);
! types.Add(829 , "macaddr" , PgDataType.VarChar , 0, 0, 6);
! types.Add(869 , "inet" , PgDataType.VarChar , 0, 0, 0);
! types.Add(1005 , "_int2" , PgDataType.Array , 21, 1, 2);
! types.Add(1007 , "_int4" , PgDataType.Array , 23, 1, 4);
! types.Add(1009 , "_text" , PgDataType.Array , 25, 1, 0);
! types.Add(1016 , "_int8" , PgDataType.Array , 20, 1, 8);
! types.Add(1017 , "_point" , PgDataType.Array , 600, 1, 16);
! types.Add(1018 , "_lseg" , PgDataType.Array , 601, 1, 32);
! types.Add(1019 , "_path" , PgDataType.Array , 602, 1, -1);
! types.Add(1020 , "_box" , PgDataType.Array , 603, 1, 32);
! types.Add(1021 , "_float4" , PgDataType.Array , 700, 1, 4);
! types.Add(1027 , "_polygon" , PgDataType.Array , 604, 1, 16);
! types.Add(1033 , "aclitem" , PgDataType.VarChar , 0, 0, 12);
! types.Add(1034 , "_aclitem" , PgDataType.Array , 1033, 0, 0);
! types.Add(1042 , "bpchar" , PgDataType.VarChar , 0, 0, 0);
! types.Add(1043 , "varchar" , PgDataType.VarChar , 0, 0, 0);
! types.Add(1082 , "date" , PgDataType.Date , 0, 1, 4);
! types.Add(1083 , "time" , PgDataType.Time , 0, 1, 8);
! types.Add(1114 , "timestamp" , PgDataType.TimeStamp , 0, 1, 8);
! types.Add(1560 , "bit" , PgDataType.Byte , 0, 0, 1);
! types.Add(1562 , "varbit" , PgDataType.Byte , 0, 1, 0);
! types.Add(1700 , "numeric" , PgDataType.Decimal , 0, 0, 8);
! types.Add(2277 , "anyarray" , PgDataType.Array , 0, 1, 8);
}
Index: PgType.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgType.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PgType.cs 17 Oct 2003 18:55:04 -0000 1.5
--- PgType.cs 18 Oct 2003 19:14:43 -0000 1.6
***************
*** 57,61 ****
get { return systemType; }
}
!
public int ElementType
{
--- 57,61 ----
get { return systemType; }
}
!
public int ElementType
{
***************
*** 87,99 ****
#region CONSTRUCTORS
! public PgType(int oid, string name, PgDataType dataType, Type systemType, int elementType, short formatCode, int size)
{
this.oid = oid;
this.name = name;
this.dataType = dataType;
- this.systemType = systemType;
this.elementType = elementType;
this.formatCode = formatCode;
this.size = size;
}
--- 87,99 ----
#region CONSTRUCTORS
! public PgType(int oid, string name, PgDataType dataType, int elementType, short formatCode, int size)
{
this.oid = oid;
this.name = name;
this.dataType = dataType;
this.elementType = elementType;
this.formatCode = formatCode;
this.size = size;
+ this.systemType = this.inferSystemType();
}
***************
*** 106,117 ****
bool returnValue = false;
! if (dataType == PgDataType.Currency ||
! dataType == PgDataType.Int2 ||
! dataType == PgDataType.Int4 ||
! dataType == PgDataType.Int8 ||
! dataType == PgDataType.Float ||
! dataType == PgDataType.Double ||
! dataType == PgDataType.Decimal ||
! dataType == PgDataType.Byte)
{
returnValue = true;
--- 106,117 ----
bool returnValue = false;
! if (this.dataType == PgDataType.Currency ||
! this.dataType == PgDataType.Int2 ||
! this.dataType == PgDataType.Int4 ||
! this.dataType == PgDataType.Int8 ||
! this.dataType == PgDataType.Float ||
! this.dataType == PgDataType.Double ||
! this.dataType == PgDataType.Decimal ||
! this.dataType == PgDataType.Byte)
{
returnValue = true;
***************
*** 125,129 ****
bool returnValue = false;
! if (dataType == PgDataType.Binary)
{
returnValue = true;
--- 125,129 ----
bool returnValue = false;
! if (this.dataType == PgDataType.Binary)
{
returnValue = true;
***************
*** 131,134 ****
--- 131,197 ----
return returnValue;
+ }
+
+ #endregion
+
+ #region PRIVATE_METHODS
+
+ private Type inferSystemType()
+ {
+ switch (this.dataType)
+ {
+ case PgDataType.Array:
+ case PgDataType.Binary:
+ case PgDataType.Vector:
+ return Type.GetType("System.Array");
+
+ case PgDataType.Boolean:
+ return Type.GetType("System.Boolean");
+
+ case PgDataType.Box:
+ case PgDataType.Circle:
+ case PgDataType.Line:
+ case PgDataType.LSeg:
+ case PgDataType.Path:
+ case PgDataType.Point:
+ case PgDataType.Polygon:
+ return Type.GetType("System.Object");
+
+ case PgDataType.Byte:
+ return Type.GetType("System.Byte");
+
+ case PgDataType.Char:
+ case PgDataType.Text:
+ case PgDataType.VarChar:
+ return Type.GetType("System.String");
+
+ case PgDataType.Currency:
+ case PgDataType.Decimal:
+ case PgDataType.Numeric:
+ return Type.GetType("System.Decimal");
+
+ case PgDataType.Date:
+ case PgDataType.Time:
+ case PgDataType.TimeStamp:
+ return Type.GetType("System.DateTime");
+
+ case PgDataType.Double:
+ return Type.GetType("System.Double");
+
+ case PgDataType.Float:
+ return Type.GetType("System.Float");
+
+ case PgDataType.Int2:
+ return Type.GetType("System.Int16");
+
+ case PgDataType.Int4:
+ return Type.GetType("System.Int32");
+
+ case PgDataType.Int8:
+ return Type.GetType("System.Int64");
+
+ default:
+ return Type.GetType("System.Object");
+ }
}
Index: PgTypeCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgTypeCollection.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PgTypeCollection.cs 17 Oct 2003 18:55:04 -0000 1.5
--- PgTypeCollection.cs 18 Oct 2003 19:14:43 -0000 1.6
***************
*** 95,101 ****
}
! public PgType Add(int oid, string name, PgDataType dataType, Type systemType, int elementType, short formatCode, int size)
{
! PgType type = new PgType(oid, name, dataType, systemType, elementType, formatCode, size);
base.Add(type);
--- 95,101 ----
}
! public PgType Add(int oid, string name, PgDataType dataType, int elementType, short formatCode, int size)
{
! PgType type = new PgType(oid, name, dataType, elementType, formatCode, size);
base.Add(type);
|