From: Carlos G. Á. <car...@us...> - 2005-09-12 18:27:53
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PostgreSqlClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1495/Data/PostgreSqlClient Modified Files: PgDataAdapter.cs PgDataReader.cs Log Message: Started the rework of the Schema support Index: PgDataAdapter.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PostgreSqlClient/PgDataAdapter.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PgDataAdapter.cs 11 Sep 2005 12:12:31 -0000 1.3 --- PgDataAdapter.cs 12 Sep 2005 18:27:45 -0000 1.4 *************** *** 25,40 **** namespace PostgreSql.Data.PostgreSqlClient { ! #region Delegates ! ! public delegate void PgRowUpdatedEventHandler(object sender, PgRowUpdatedEventArgs e); ! public delegate void PgRowUpdatingEventHandler(object sender, PgRowUpdatingEventArgs e); ! ! #endregion ! ! [ToolboxItem(true), ToolboxBitmap(typeof(PgDataAdapter), "Resources.ToolBox.PgDataAdapter.bmp"), ! DefaultEvent("RowUpdated")] public sealed class PgDataAdapter : DbDataAdapter, ICloneable { ! #region Events private static readonly object EventRowUpdated = new object(); --- 25,34 ---- namespace PostgreSql.Data.PostgreSqlClient { ! [ToolboxItem(true)] ! [ToolboxBitmap(typeof(PgDataAdapter), "Resources.ToolBox.PgDataAdapter.bmp")] ! [DefaultEvent("RowUpdated")] public sealed class PgDataAdapter : DbDataAdapter, ICloneable { ! #region · Events · private static readonly object EventRowUpdated = new object(); *************** *** 45,53 **** #region · Fields · ! private PgCommand selectCommand; ! private PgCommand insertCommand; ! private PgCommand updateCommand; ! private PgCommand deleteCommand; ! private bool disposed; #endregion --- 39,43 ---- #region · Fields · ! private bool disposed; #endregion *************** *** 59,64 **** public new PgCommand SelectCommand { ! get { return this.selectCommand; } ! set { this.selectCommand = value; } } --- 49,54 ---- public new PgCommand SelectCommand { ! get { return (PgCommand)base.SelectCommand; } ! set { base.SelectCommand = value; } } *************** *** 67,72 **** public new PgCommand InsertCommand { ! get { return this.insertCommand; } ! set { this.insertCommand = value; } } --- 57,62 ---- public new PgCommand InsertCommand { ! get { return (PgCommand)base.InsertCommand; } ! set { base.InsertCommand = value; } } *************** *** 75,80 **** public new PgCommand UpdateCommand { ! get { return this.updateCommand; } ! set { this.updateCommand = value; } } --- 65,70 ---- public new PgCommand UpdateCommand { ! get { return (PgCommand)base.UpdateCommand; } ! set { base.UpdateCommand = value; } } *************** *** 83,88 **** public new PgCommand DeleteCommand { ! get { return this.deleteCommand; } ! set { this.deleteCommand = value; } } --- 73,78 ---- public new PgCommand DeleteCommand { ! get { return (PgCommand)base.DeleteCommand; } ! set { base.DeleteCommand = value; } } Index: PgDataReader.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/PostgreSqlClient/PgDataReader.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PgDataReader.cs 11 Sep 2005 13:29:16 -0000 1.4 --- PgDataReader.cs 12 Sep 2005 18:27:45 -0000 1.5 *************** *** 225,261 **** schemaTable.BeginLoadData(); ! PgCommand cInfoCmd = this.GetColumnInfoCmd(); ! PgCommand pKeyCmd = this.GetPrimaryKeyInfoCmd(); for (int i = 0; i < command.Statement.RowDescriptor.Fields.Length; i++) { ! object[] columnInfo = null; ! System.Array pKeyInfo = null; // Execute commands ! cInfoCmd.Parameters[0].Value = command.Statement.RowDescriptor.Fields[i].OidNumber; ! cInfoCmd.Parameters[1].Value = command.Statement.RowDescriptor.Fields[i].OidTable; ! ! pKeyCmd.Parameters[0].Value = command.Statement.RowDescriptor.Fields[i].OidTable; ! cInfoCmd.InternalPrepare(); ! pKeyCmd.InternalPrepare(); ! cInfoCmd.InternalExecute(); ! pKeyCmd.InternalExecute(); // Get Column Information ! if (cInfoCmd.Statement.Rows != null && ! cInfoCmd.Statement.Rows.Length > 0) { ! columnInfo = (object[])cInfoCmd.Statement.Rows[0]; } // Get Primary Key Info ! if (pKeyCmd.Statement.Rows != null && ! pKeyCmd.Statement.Rows.Length > 0) { ! object[] temp = (object[])pKeyCmd.Statement.Rows[0]; ! pKeyInfo = (System.Array)temp[3]; } --- 225,261 ---- schemaTable.BeginLoadData(); ! PgCommand columnsCmd = new PgCommand(this.GetColumnsSql(), this.connection); ! columnsCmd.Parameters.Add("@OidNumber", PgDbType.Int4); ! columnsCmd.Parameters.Add("@OidTable", PgDbType.Int4); ! columnsCmd.InternalPrepare(); ! ! PgCommand primaryKeyCmd = new PgCommand(this.GetPrimaryKeysSql(), this.connection); ! primaryKeyCmd.Parameters.Add("@OidTable", PgDbType.Int4); for (int i = 0; i < command.Statement.RowDescriptor.Fields.Length; i++) { ! object[] columnInfo = null; ! Array pKeyInfo = null; // Execute commands ! columnsCmd.Parameters[0].Value = command.Statement.RowDescriptor.Fields[i].OidNumber; ! columnsCmd.Parameters[1].Value = command.Statement.RowDescriptor.Fields[i].OidTable; ! primaryKeyCmd.Parameters[0].Value = command.Statement.RowDescriptor.Fields[i].OidTable; ! columnsCmd.InternalExecute(); ! primaryKeyCmd.InternalExecute(); // Get Column Information ! if (columnsCmd.Statement.Rows != null && columnsCmd.Statement.Rows.Length > 0) { ! columnInfo = (object[])columnsCmd.Statement.Rows[0]; } // Get Primary Key Info ! if (primaryKeyCmd.Statement.Rows != null && primaryKeyCmd.Statement.Rows.Length > 0) { ! object[] temp = (object[])primaryKeyCmd.Statement.Rows[0]; ! pKeyInfo = (Array)temp[3]; } *************** *** 310,315 **** schemaTable.EndLoadData(); ! cInfoCmd.Dispose(); ! pKeyCmd.Dispose(); } --- 310,315 ---- schemaTable.EndLoadData(); ! columnsCmd.Dispose(); ! primaryKeyCmd.Dispose(); } *************** *** 317,326 **** } ! private PgCommand GetColumnInfoCmd() { ! throw new NotImplementedException(); } ! private PgCommand GetPrimaryKeyInfoCmd() { throw new NotImplementedException(); --- 317,355 ---- } ! private string GetColumnsSql() { ! return "SELECT " + ! "null AS TABLE_CATALOG, " + ! "pg_namespace.nspname AS TABLE_SCHEMA, " + ! "pg_class.relname AS TABLE_NAME, " + ! "pg_attribute.attname AS COLUMN_NAME, " + ! "pg_attribute.atttypid AS DATA_TYPE, " + ! "0 AS NUMERIC_PRECISION, " + ! "0 AS NUMERIC_SCALE, " + ! "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 " + ! "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"; } ! private string GetPrimaryKeysSql() { throw new NotImplementedException(); |