Revision: 60
Author: carlosga_fb
Date: 2006-03-28 03:24:30 -0800 (Tue, 28 Mar 2006)
ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=60&view=rev
Log Message:
-----------
?\194?\183 Fixed Key Column info retrieval in GetSchema Methods
?\194?\183 Changed SQL statements used to retrieve column info to get only the nedded information.
Modified Paths:
--------------
trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs
Modified: trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs
===================================================================
--- trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs 2006-03-28 11:23:24 UTC (rev 59)
+++ trunk/pgsqlclient/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs 2006-03-28 11:24:30 UTC (rev 60)
@@ -252,15 +252,15 @@
if (primaryKeyCmd.Statement.Rows != null && primaryKeyCmd.Statement.Rows.Length > 0)
{
object[] temp = (object[])primaryKeyCmd.Statement.Rows[0];
- pKeyInfo = (Array)temp[4];
+ pKeyInfo = (Array)temp[0];
}
// Add row information
- DataRow schemaRow = schemaTable.NewRow();
+ DataRow schemaRow = schemaTable.NewRow();
- schemaRow["ColumnName"] = this.GetName(i);
- schemaRow["ColumnOrdinal"] = i;
- schemaRow["ColumnSize"] = this.GetSize(i);
+ schemaRow["ColumnName"] = Convert.ToString(columnInfo[2]);
+ schemaRow["ColumnOrdinal"] = Convert.ToInt32(columnInfo[5]);
+ schemaRow["ColumnSize"] = this.GetSize(i);
if (this.IsNumeric(i))
{
schemaRow["NumericPrecision"] = this.GetNumericPrecision(i);
@@ -279,15 +279,16 @@
schemaRow["IsAliased"] = this.IsAliased(i);
schemaRow["IsExpression"] = this.IsExpression(i);
schemaRow["BaseCatalogName"] = System.DBNull.Value;
+
if (columnInfo != null)
{
- schemaRow["BaseSchemaName"] = columnInfo[1].ToString();
- schemaRow["BaseTableName"] = columnInfo[2].ToString();
- schemaRow["BaseColumnName"] = columnInfo[3].ToString();
- schemaRow["IsReadOnly"] = (bool)columnInfo[10];
- schemaRow["IsAutoIncrement"] = (bool)columnInfo[10];
- schemaRow["IsKey"] = this.IsPrimaryKey(pKeyInfo, (int)columnInfo[6]);
- schemaRow["AllowDBNull"] = ((bool)columnInfo[9]) ? false : true;
+ schemaRow["BaseSchemaName"] = columnInfo[0].ToString();
+ schemaRow["BaseTableName"] = columnInfo[1].ToString();
+ schemaRow["BaseColumnName"] = columnInfo[2].ToString();
+ schemaRow["IsReadOnly"] = (bool)columnInfo[7];
+ schemaRow["IsAutoIncrement"] = (bool)columnInfo[7];
+ schemaRow["IsKey"] = this.IsPrimaryKey(pKeyInfo, (int)schemaRow["ColumnOrdinal"]);
+ schemaRow["AllowDBNull"] = ((bool)columnInfo[6]) ? false : true;
}
else
{
@@ -314,45 +315,32 @@
private string GetColumnsSql()
{
- return "SELECT " +
- "null AS TABLE_CATALOG, " +
+ return
+ "SELECT " +
"pg_namespace.nspname AS TABLE_SCHEMA, " +
"pg_class.relname AS TABLE_NAME, " +
"pg_attribute.attname AS COLUMN_NAME, " +
"pg_attribute.atttypid AS DATA_TYPE, " +
"pg_attribute.attlen AS COLUMN_SIZE, " +
- "pg_attribute.attndims AS COLUMN_DIMENSIONS, " +
"pg_attribute.attnum AS ORDINAL_POSITION, " +
- "pg_attrdef.adsrc AS COLUMN_DEFAULT, " +
"pg_attribute.attnotnull AS IS_NOT_NULL, " +
- "(pg_depend.objid is not null) AS IS_AUTOINCREMENT, " +
- "case pg_attribute.attstorage " +
- "when 'p' THEN 'PLAIN' " +
- "when 'e' THEN 'EXTERNAL' "+
- "when 'm' THEN 'MAIN' " +
- "when 'x' THEN 'EXTENDED' " +
- "END AS STORAGE, " +
- "pg_description.description AS DESCRIPTION " +
+ "(pg_depend.objid is not null) AS IS_AUTOINCREMENT " +
"FROM pg_attribute " +
"left join pg_class ON pg_attribute.attrelid = pg_class.oid " +
"left join pg_namespace ON pg_class.relnamespace = pg_namespace.oid " +
- "left join pg_attrdef ON (pg_class.oid = pg_attrdef.adrelid AND pg_attribute.attnum = pg_attrdef.adnum) " +
- "left join pg_description ON (pg_attribute.attrelid = pg_description.objoid AND pg_attribute.attnum = pg_description.objsubid) " +
- "left join pg_depend ON (pg_attribute.attrelid = pg_depend.refobjid AND pg_attribute.attnum = pg_depend.refobjsubid AND pg_depend.deptype = 'i') " +
- "WHERE pg_attribute.attisdropped = false AND pg_attribute.attnum > 0 AND " +
- "pg_attribute.attnum = @OidNumber AND " +
- "pg_attribute.attrelid = @OidTable";
+ "left join pg_attrdef ON (pg_class.oid = pg_attrdef.adrelid AND pg_attribute.attnum = pg_attrdef.adnum) " +
+ "left join pg_depend ON (pg_attribute.attrelid = pg_depend.refobjid AND pg_attribute.attnum = pg_depend.refobjsubid AND pg_depend.deptype = 'i') " +
+ "WHERE " +
+ "pg_attribute.attisdropped = false AND " +
+ "pg_attribute.attnum > 0 AND " +
+ "pg_attribute.attnum = @OidNumber AND " +
+ "pg_attribute.attrelid = @OidTable";
}
private string GetPrimaryKeysSql()
{
return "SELECT " +
- "null AS TABLE_CATALOG, " +
- "pg_namespace.nspname AS TABLE_SCHEMA, " +
- "pg_class.relname AS TABLE_NAME, " +
- "pg_constraint.conname AS PK_NAME, " +
- "pg_constraint.conkey AS PK_COLUMNS, " +
- "pg_description.description AS DESCRIPTION " +
+ "pg_constraint.conkey AS PK_COLUMNS " +
"FROM pg_constraint " +
"left join pg_class ON pg_constraint.conrelid = pg_class.oid " +
"left join pg_namespace ON pg_constraint.connamespace = pg_namespace.oid " +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|