[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema PgAbstractDbSchema
Status: Inactive
Brought to you by:
carlosga_fb
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema In directory sc8-pr-cvs1:/tmp/cvs-serv15737 Modified Files: PgAbstractDbSchema.cs PgAggregatesSchema.cs PgCastsSchema.cs PgCheckConstraints.cs PgCheckConstraintsByTable.cs PgColumnsSchema.cs PgDatabaseSchema.cs PgDomainsSchema.cs PgForeignKeysSchema.cs PgFunctionPrivilegesSchema.cs PgFunctionsSchema.cs PgGroupsSchema.cs PgIndexesSchema.cs PgPrimaryKeysSchema.cs PgProviderTypesSchema.cs PgSchemataSchema.cs PgSqlLanguagesSchema.cs PgTableConstraintsSchema.cs PgTablePrivilegesSchema.cs PgTablesSchema.cs PgTableStatisticsSchema.cs PgTriggersSchema.cs PgUsersSchema.cs PgViewPrivilegesSchema.cs PgViewsSchema.cs Log Message: 2003-12-14 Carlos Guzmán Álvarez <car...@te...> * Changed #region names in all source files. Index: PgAbstractDbSchema.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema/PgAbstractDbSchema.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PgAbstractDbSchema.cs 25 Oct 2003 21:01:23 -0000 1.2 --- PgAbstractDbSchema.cs 14 Dec 2003 15:07:38 -0000 1.3 *************** *** 1,465 **** ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! using System.Text.RegularExpressions; ! using System.Collections; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! #region STRUCTS ! ! internal struct PgColumn ! { ! public string ColumnName; ! public string ColumnAlias; ! public string WhereColumnName; ! } ! ! internal struct PgTableJoin ! { ! public string JoinType; ! public string RightTable; ! public string Expression; ! } ! ! internal struct PgPrivilege ! { ! public string User; ! public MatchCollection Privileges; ! } ! ! #endregion ! ! internal abstract class PgAbstractDbSchema : IDbSchema ! { ! #region FIELDS ! ! private ArrayList restrictionColumns; ! private ArrayList dataColumns; ! private ArrayList tables; ! private ArrayList joins; ! private ArrayList orderByColumns; ! private ArrayList whereFilters; ! ! private string tableName; ! ! #endregion ! ! #region PROPERTIES ! ! public ArrayList RestrictionColumns ! { ! get { return restrictionColumns; } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public PgAbstractDbSchema() ! { ! restrictionColumns = new ArrayList(); ! dataColumns = new ArrayList(); ! tables = new ArrayList(); ! joins = new ArrayList(); ! orderByColumns = new ArrayList(); ! whereFilters = new ArrayList(); ! ! AddTables(); ! AddRestrictionColumns(); ! AddDataColumns(); ! AddJoins(); ! AddOrderByColumns(); ! AddWhereFilters(); ! } ! ! public PgAbstractDbSchema(string tableName) : this() ! { ! this.tableName = tableName; ! } ! ! #endregion ! ! #region ABSTRACT_METHODS ! ! public abstract void AddTables(); ! public abstract void AddRestrictionColumns(); ! public abstract void AddDataColumns(); ! public abstract void AddJoins(); ! public abstract void AddOrderByColumns(); ! public abstract void AddWhereFilters(); ! public abstract object[] ParseRestrictions(object[] restrictions); ! ! #endregion ! ! #region ADD_METHODS ! ! public void AddTable(string tableName) ! { ! tables.Add(tableName); ! } ! ! public void AddRestrictionColumn(string columnName, string columnAlias, string whereColumnName) ! { ! PgColumn column = new PgColumn(); ! ! column.ColumnName = columnName; ! column.ColumnAlias = columnAlias; ! if (whereColumnName != null) ! { ! column.WhereColumnName = whereColumnName; ! } ! else ! { ! column.WhereColumnName = columnName; ! } ! ! ! restrictionColumns.Add(column); ! } ! ! public void AddDataColumn(string columnName, string columnAlias) ! { ! PgColumn column = new PgColumn(); ! ! column.ColumnName = columnName; ! column.ColumnAlias = columnAlias; ! ! dataColumns.Add(column); ! } ! ! public void AddJoin(string joinType, string rightTable, string expression) ! { ! PgTableJoin join = new PgTableJoin(); ! ! join.JoinType = joinType; ! join.RightTable = rightTable; ! join.Expression = expression; ! ! joins.Add(join); ! } ! ! public void AddOrderBy(string column) ! { ! orderByColumns.Add(column); ! } ! ! public void AddWhereFilter(string filter) ! { ! whereFilters.Add(filter); ! } ! ! #endregion ! ! #region METHODS ! ! public virtual DataTable GetDbSchemaTable(PgConnection connection, object[] restrictions) ! { ! restrictions = ParseRestrictions(restrictions); ! ! DataSet dataSet = null; ! PgDataAdapter adapter = null; ! PgCommand command = new PgCommand(); ! ! try ! { ! command.Connection = connection; ! command.CommandText = GetCommandText(restrictions); ! if (connection.ActiveTransaction != null && ! !connection.ActiveTransaction.IsUpdated) ! { ! command.Transaction = connection.ActiveTransaction; ! } ! ! adapter = new PgDataAdapter(command); ! dataSet = new DataSet(tableName); ! ! adapter.Fill(dataSet, tableName); ! } ! catch (PgException pgex) ! { ! throw pgex; ! } ! catch (Exception ex) ! { ! throw new PgException(ex.Message); ! } ! finally ! { ! command.Dispose(); ! adapter.Dispose(); ! } ! ! return dataSet.Tables[tableName]; ! } ! ! public string GetCommandText(object[] restrictions) ! { ! StringBuilder sql = new StringBuilder(); ! ! // Add restriction columns ! sql.Append("SELECT "); ! foreach (PgColumn column in restrictionColumns) ! { ! sql.AppendFormat("{0} AS {1}", column.ColumnName, column.ColumnAlias); ! if ((restrictionColumns.IndexOf(column) + 1) < restrictionColumns.Count) ! { ! sql.Append(", "); ! } ! } ! ! // Add DataColumns ! if (restrictionColumns.Count > 0 && dataColumns.Count > 0) ! { ! sql.Append(", "); ! } ! foreach (PgColumn column in dataColumns) ! { ! sql.AppendFormat("{0} AS {1}", column.ColumnName, column.ColumnAlias); ! if ((dataColumns.IndexOf(column) + 1) < dataColumns.Count) ! { ! sql.Append(", "); ! } ! } ! ! // Add tables ! sql.Append(" FROM "); ! foreach (string table in tables) ! { ! sql.Append(table); ! if ((tables.IndexOf(table) + 1) < tables.Count) ! { ! sql.Append(", "); ! } ! } ! ! if (joins.Count != 0) ! { ! foreach (PgTableJoin join in joins) ! { ! sql.AppendFormat(" {0} {1} ON {2}", ! join.JoinType, ! join.RightTable, ! join.Expression); ! } ! } ! ! // Add restrictions ! StringBuilder whereFilter = new StringBuilder(); ! ! if (restrictions != null && restrictions.Length > 0) ! { ! for (int i = 0; i < restrictions.Length; i++) ! { ! if (restrictions[i] != null) ! { ! if (whereFilter.Length > 0) ! { ! whereFilter.Append(" AND "); ! } ! whereFilter.AppendFormat("{0} = '{1}'", ! ((PgColumn)restrictionColumns[i]).WhereColumnName, ! restrictions[i]); ! } ! } ! } ! ! if (whereFilters != null && whereFilters.Count > 0) ! { ! foreach (string condition in whereFilters) ! { ! if (whereFilter.Length > 0) ! { ! whereFilter.Append(" AND "); ! } ! whereFilter.Append(condition); ! } ! } ! ! if (whereFilter.Length > 0) ! { ! sql.AppendFormat(" WHERE {0}", whereFilter); ! } ! ! // Add Order By ! if (orderByColumns.Count > 0) ! { ! sql.Append(" ORDER BY "); ! ! foreach (string columnName in orderByColumns) ! { ! sql.Append(columnName); ! ! if ((orderByColumns.IndexOf(columnName) + 1) < orderByColumns.Count) ! { ! sql.Append(", "); ! } ! } ! } ! ! return sql.ToString(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected void AddPrivilegesColumns(DataTable table) ! { ! table.Columns.Add("INSERT", Type.GetType("System.Boolean")); ! table.Columns["INSERT"].DefaultValue = false; ! ! table.Columns.Add("INSERT_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["INSERT_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("SELECT", Type.GetType("System.Boolean")); ! table.Columns["SELECT"].DefaultValue = false; ! ! table.Columns.Add("SELECT_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["SELECT_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("UPDATE", Type.GetType("System.Boolean")); ! table.Columns["UPDATE"].DefaultValue = false; ! ! table.Columns.Add("UPDATE_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["UPDATE_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("DELETE", Type.GetType("System.Boolean")); ! table.Columns["DELETE"].DefaultValue = false; ! ! table.Columns.Add("DELETE_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["DELETE_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("RULE", Type.GetType("System.Boolean")); ! table.Columns["RULE"].DefaultValue = false; ! ! table.Columns.Add("RULE_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["RULE_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("REFERENCES", Type.GetType("System.Boolean")); ! table.Columns["REFERENCES"].DefaultValue = false; ! ! table.Columns.Add("REFERENCES_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["REFERENCES_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("TRIGGER", Type.GetType("System.Boolean")); ! table.Columns["TRIGGER"].DefaultValue = false; ! ! table.Columns.Add("TRIGGER_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["TRIGGER_WITH_GRANT"].DefaultValue = false; ! } ! ! protected PgPrivilege[] DecodePrivileges(string[] acl) ! { ! Regex search = new Regex(@"((a|r|w|d|R|x|t)\*?)"); ! PgPrivilege[] priv = new PgPrivilege[acl.Length]; ! ! for (int i = 0; i < acl.Length; i++) ! { ! priv[i].User = acl[i].Split('=')[0]; ! if (priv[i].User.Length == 0) ! { ! priv[i].User = "PUBLIC"; ! } ! string aclitem = acl[i].Split('=')[1]; ! aclitem = aclitem.Split('/')[0]; ! ! priv[i].Privileges = search.Matches(aclitem); ! } ! ! return priv; ! } ! ! protected void FillPrivileges(DataRow row, MatchCollection privileges) ! { ! foreach (Match privilege in privileges) ! { ! switch (privilege.Value) ! { ! case "a": ! case "a*": ! row["INSERT"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["INSERT_WITH_GRANT"] = true; ! } ! break; ! ! case "r": ! case "r*": ! row["SELECT"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["SELECT_WITH_GRANT"] = true; ! } ! break; ! ! case "w": ! case "w*": ! row["UPDATE"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["UPDATE_WITH_GRANT"] = true; ! } ! break; ! ! case "d": ! case "d*": ! row["DELETE"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["DELETE_WITH_GRANT"] = false; ! } ! break; ! ! case "R": ! case "R*": ! row["RULE"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["RULE_WITH_GRANT"] = true; ! } ! break; ! ! case "x": ! case "x*": ! row["REFERENCES"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["REFERENCES_WITH_GRANT"] = true; ! } ! break; ! ! case "t": ! case "t*": ! row["TRIGGER"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["TRIGGER_WITH_GRANT"] = true; ! } ! break; ! } ! } ! } ! ! #endregion ! } ! } --- 1,465 ---- ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! using System.Text.RegularExpressions; ! using System.Collections; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! #region STRUCTS ! ! internal struct PgColumn ! { ! public string ColumnName; ! public string ColumnAlias; ! public string WhereColumnName; ! } ! ! internal struct PgTableJoin ! { ! public string JoinType; ! public string RightTable; ! public string Expression; ! } ! ! internal struct PgPrivilege ! { ! public string User; ! public MatchCollection Privileges; ! } ! ! #endregion ! ! internal abstract class PgAbstractDbSchema : IDbSchema ! { ! #region Fields ! ! private ArrayList restrictionColumns; ! private ArrayList dataColumns; ! private ArrayList tables; ! private ArrayList joins; ! private ArrayList orderByColumns; ! private ArrayList whereFilters; ! ! private string tableName; ! ! #endregion ! ! #region Properties ! ! public ArrayList RestrictionColumns ! { ! get { return restrictionColumns; } ! } ! ! #endregion ! ! #region Constructors ! ! public PgAbstractDbSchema() ! { ! restrictionColumns = new ArrayList(); ! dataColumns = new ArrayList(); ! tables = new ArrayList(); ! joins = new ArrayList(); ! orderByColumns = new ArrayList(); ! whereFilters = new ArrayList(); ! ! AddTables(); ! AddRestrictionColumns(); ! AddDataColumns(); ! AddJoins(); ! AddOrderByColumns(); ! AddWhereFilters(); ! } ! ! public PgAbstractDbSchema(string tableName) : this() ! { ! this.tableName = tableName; ! } ! ! #endregion ! ! #region Abstract Methods ! ! public abstract void AddTables(); ! public abstract void AddRestrictionColumns(); ! public abstract void AddDataColumns(); ! public abstract void AddJoins(); ! public abstract void AddOrderByColumns(); ! public abstract void AddWhereFilters(); ! public abstract object[] ParseRestrictions(object[] restrictions); ! ! #endregion ! ! #region ADD_METHODS ! ! public void AddTable(string tableName) ! { ! tables.Add(tableName); ! } ! ! public void AddRestrictionColumn(string columnName, string columnAlias, string whereColumnName) ! { ! PgColumn column = new PgColumn(); ! ! column.ColumnName = columnName; ! column.ColumnAlias = columnAlias; ! if (whereColumnName != null) ! { ! column.WhereColumnName = whereColumnName; ! } ! else ! { ! column.WhereColumnName = columnName; ! } ! ! ! restrictionColumns.Add(column); ! } ! ! public void AddDataColumn(string columnName, string columnAlias) ! { ! PgColumn column = new PgColumn(); ! ! column.ColumnName = columnName; ! column.ColumnAlias = columnAlias; ! ! dataColumns.Add(column); ! } ! ! public void AddJoin(string joinType, string rightTable, string expression) ! { ! PgTableJoin join = new PgTableJoin(); ! ! join.JoinType = joinType; ! join.RightTable = rightTable; ! join.Expression = expression; ! ! joins.Add(join); ! } ! ! public void AddOrderBy(string column) ! { ! orderByColumns.Add(column); ! } ! ! public void AddWhereFilter(string filter) ! { ! whereFilters.Add(filter); ! } ! ! #endregion ! ! #region Methods ! ! public virtual DataTable GetDbSchemaTable(PgConnection connection, object[] restrictions) ! { ! restrictions = ParseRestrictions(restrictions); ! ! DataSet dataSet = null; ! PgDataAdapter adapter = null; ! PgCommand command = new PgCommand(); ! ! try ! { ! command.Connection = connection; ! command.CommandText = GetCommandText(restrictions); ! if (connection.ActiveTransaction != null && ! !connection.ActiveTransaction.IsUpdated) ! { ! command.Transaction = connection.ActiveTransaction; ! } ! ! adapter = new PgDataAdapter(command); ! dataSet = new DataSet(tableName); ! ! adapter.Fill(dataSet, tableName); ! } ! catch (PgException pgex) ! { ! throw pgex; ! } ! catch (Exception ex) ! { ! throw new PgException(ex.Message); ! } ! finally ! { ! command.Dispose(); ! adapter.Dispose(); ! } ! ! return dataSet.Tables[tableName]; ! } ! ! public string GetCommandText(object[] restrictions) ! { ! StringBuilder sql = new StringBuilder(); ! ! // Add restriction columns ! sql.Append("SELECT "); ! foreach (PgColumn column in restrictionColumns) ! { ! sql.AppendFormat("{0} AS {1}", column.ColumnName, column.ColumnAlias); ! if ((restrictionColumns.IndexOf(column) + 1) < restrictionColumns.Count) ! { ! sql.Append(", "); ! } ! } ! ! // Add DataColumns ! if (restrictionColumns.Count > 0 && dataColumns.Count > 0) ! { ! sql.Append(", "); ! } ! foreach (PgColumn column in dataColumns) ! { ! sql.AppendFormat("{0} AS {1}", column.ColumnName, column.ColumnAlias); ! if ((dataColumns.IndexOf(column) + 1) < dataColumns.Count) ! { ! sql.Append(", "); ! } ! } ! ! // Add tables ! sql.Append(" FROM "); ! foreach (string table in tables) ! { ! sql.Append(table); ! if ((tables.IndexOf(table) + 1) < tables.Count) ! { ! sql.Append(", "); ! } ! } ! ! if (joins.Count != 0) ! { ! foreach (PgTableJoin join in joins) ! { ! sql.AppendFormat(" {0} {1} ON {2}", ! join.JoinType, ! join.RightTable, ! join.Expression); ! } ! } ! ! // Add restrictions ! StringBuilder whereFilter = new StringBuilder(); ! ! if (restrictions != null && restrictions.Length > 0) ! { ! for (int i = 0; i < restrictions.Length; i++) ! { ! if (restrictions[i] != null) ! { ! if (whereFilter.Length > 0) ! { ! whereFilter.Append(" AND "); ! } ! whereFilter.AppendFormat("{0} = '{1}'", ! ((PgColumn)restrictionColumns[i]).WhereColumnName, ! restrictions[i]); ! } ! } ! } ! ! if (whereFilters != null && whereFilters.Count > 0) ! { ! foreach (string condition in whereFilters) ! { ! if (whereFilter.Length > 0) ! { ! whereFilter.Append(" AND "); ! } ! whereFilter.Append(condition); ! } ! } ! ! if (whereFilter.Length > 0) ! { ! sql.AppendFormat(" WHERE {0}", whereFilter); ! } ! ! // Add Order By ! if (orderByColumns.Count > 0) ! { ! sql.Append(" ORDER BY "); ! ! foreach (string columnName in orderByColumns) ! { ! sql.Append(columnName); ! ! if ((orderByColumns.IndexOf(columnName) + 1) < orderByColumns.Count) ! { ! sql.Append(", "); ! } ! } ! } ! ! return sql.ToString(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected void AddPrivilegesColumns(DataTable table) ! { ! table.Columns.Add("INSERT", Type.GetType("System.Boolean")); ! table.Columns["INSERT"].DefaultValue = false; ! ! table.Columns.Add("INSERT_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["INSERT_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("SELECT", Type.GetType("System.Boolean")); ! table.Columns["SELECT"].DefaultValue = false; ! ! table.Columns.Add("SELECT_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["SELECT_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("UPDATE", Type.GetType("System.Boolean")); ! table.Columns["UPDATE"].DefaultValue = false; ! ! table.Columns.Add("UPDATE_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["UPDATE_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("DELETE", Type.GetType("System.Boolean")); ! table.Columns["DELETE"].DefaultValue = false; ! ! table.Columns.Add("DELETE_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["DELETE_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("RULE", Type.GetType("System.Boolean")); ! table.Columns["RULE"].DefaultValue = false; ! ! table.Columns.Add("RULE_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["RULE_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("REFERENCES", Type.GetType("System.Boolean")); ! table.Columns["REFERENCES"].DefaultValue = false; ! ! table.Columns.Add("REFERENCES_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["REFERENCES_WITH_GRANT"].DefaultValue = false; ! ! table.Columns.Add("TRIGGER", Type.GetType("System.Boolean")); ! table.Columns["TRIGGER"].DefaultValue = false; ! ! table.Columns.Add("TRIGGER_WITH_GRANT", Type.GetType("System.Boolean")); ! table.Columns["TRIGGER_WITH_GRANT"].DefaultValue = false; ! } ! ! protected PgPrivilege[] DecodePrivileges(string[] acl) ! { ! Regex search = new Regex(@"((a|r|w|d|R|x|t)\*?)"); ! PgPrivilege[] priv = new PgPrivilege[acl.Length]; ! ! for (int i = 0; i < acl.Length; i++) ! { ! priv[i].User = acl[i].Split('=')[0]; ! if (priv[i].User.Length == 0) ! { ! priv[i].User = "PUBLIC"; ! } ! string aclitem = acl[i].Split('=')[1]; ! aclitem = aclitem.Split('/')[0]; ! ! priv[i].Privileges = search.Matches(aclitem); ! } ! ! return priv; ! } ! ! protected void FillPrivileges(DataRow row, MatchCollection privileges) ! { ! foreach (Match privilege in privileges) ! { ! switch (privilege.Value) ! { ! case "a": ! case "a*": ! row["INSERT"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["INSERT_WITH_GRANT"] = true; ! } ! break; ! ! case "r": ! case "r*": ! row["SELECT"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["SELECT_WITH_GRANT"] = true; ! } ! break; ! ! case "w": ! case "w*": ! row["UPDATE"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["UPDATE_WITH_GRANT"] = true; ! } ! break; ! ! case "d": ! case "d*": ! row["DELETE"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["DELETE_WITH_GRANT"] = false; ! } ! break; ! ! case "R": ! case "R*": ! row["RULE"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["RULE_WITH_GRANT"] = true; ! } ! break; ! ! case "x": ! case "x*": ! row["REFERENCES"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["REFERENCES_WITH_GRANT"] = true; ! } ! break; ! ! case "t": ! case "t*": ! row["TRIGGER"] = true; ! if (privilege.Value.IndexOf("*") != -1) ! { ! row["TRIGGER_WITH_GRANT"] = true; ! } ! break; ! } ! } ! } ! ! #endregion ! } ! } Index: PgAggregatesSchema.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema/PgAggregatesSchema.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PgAggregatesSchema.cs 2 Aug 2003 21:11:37 -0000 1.2 --- PgAggregatesSchema.cs 14 Dec 2003 15:07:38 -0000 1.3 *************** *** 1,82 **** ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgAggregatesSchema : PgAbstractDbSchema ! { ! #region CONSTRUCTORS ! ! public PgAggregatesSchema() : base("Aggregates") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_aggregate"); ! } ! ! public override void AddRestrictionColumns() ! { ! AddRestrictionColumn("pg_aggregate.aggfnoid", "AGGREGATE_FUNCTION", null); ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_aggregate.aggtransfn" , "TRANSITION_FUNCTION"); ! AddDataColumn("pg_aggregate.aggfinalfn" , "FINAL_FUNCTION"); ! AddDataColumn("pg_aggregate.agginitval" , "INITIAL_VALUE"); ! AddDataColumn("pg_type.typname" , "BASE_TYPE"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_type", "pg_aggregate.aggtranstype = pg_type.oid"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_aggregate.aggfnoid"); ! } ! ! public override void AddWhereFilters() ! { ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! return parsed; ! } ! ! #endregion ! } } --- 1,82 ---- ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgAggregatesSchema : PgAbstractDbSchema ! { ! #region Constructors ! ! public PgAggregatesSchema() : base("Aggregates") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_aggregate"); ! } ! ! public override void AddRestrictionColumns() ! { ! AddRestrictionColumn("pg_aggregate.aggfnoid", "AGGREGATE_FUNCTION", null); ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_aggregate.aggtransfn" , "TRANSITION_FUNCTION"); ! AddDataColumn("pg_aggregate.aggfinalfn" , "FINAL_FUNCTION"); ! AddDataColumn("pg_aggregate.agginitval" , "INITIAL_VALUE"); ! AddDataColumn("pg_type.typname" , "BASE_TYPE"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_type", "pg_aggregate.aggtranstype = pg_type.oid"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_aggregate.aggfnoid"); ! } ! ! public override void AddWhereFilters() ! { ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! return parsed; ! } ! ! #endregion ! } } Index: PgCastsSchema.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema/PgCastsSchema.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PgCastsSchema.cs 2 Aug 2003 21:11:37 -0000 1.2 --- PgCastsSchema.cs 14 Dec 2003 15:07:38 -0000 1.3 *************** *** 1,102 **** ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgCastsSchema : PgAbstractDbSchema ! { ! #region CONSTRUCTORS ! ! public PgCastsSchema() : base("Casts") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_cast"); ! } ! ! public override void AddRestrictionColumns() ! { ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_typesrc.typname" , "SOURCE_TYPE"); ! AddDataColumn("pg_typetgt.typname" , "TARGET_TYPE"); ! AddDataColumn("pg_namespace.nspname", "FUNCTION_SCHEMA"); ! AddDataColumn("pg_proc.proname" , "FUNCTION_NAME"); ! AddDataColumn(getContextExpression("pg_cast.castcontext"), "CAST_CONTEXT"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_type as pg_typesrc", "pg_cast.castsource = pg_typesrc.oid"); ! AddJoin("left join", "pg_type as pg_typetgt", "pg_cast.casttarget = pg_typetgt.oid"); ! AddJoin("left join", "pg_proc" , "pg_cast.castfunc = pg_proc.oid"); ! AddJoin("left join", "pg_namespace" , "pg_proc.pronamespace = pg_namespace.oid"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_proc.proname"); ! } ! ! public override void AddWhereFilters() ! { ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! return parsed; ! } ! ! #endregion ! ! #region PRIVATE_METHODS ! ! private string getContextExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 'e' THEN 'EXPLICIT'"); ! expression.Append(" when 'a' THEN 'ASSIGNMENT'"); ! expression.Append(" when 'i' THEN 'EXPRESSIONS'"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! #endregion ! } } --- 1,102 ---- ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgCastsSchema : PgAbstractDbSchema ! { ! #region Constructors ! ! public PgCastsSchema() : base("Casts") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_cast"); ! } ! ! public override void AddRestrictionColumns() ! { ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_typesrc.typname" , "SOURCE_TYPE"); ! AddDataColumn("pg_typetgt.typname" , "TARGET_TYPE"); ! AddDataColumn("pg_namespace.nspname", "FUNCTION_SCHEMA"); ! AddDataColumn("pg_proc.proname" , "FUNCTION_NAME"); ! AddDataColumn(getContextExpression("pg_cast.castcontext"), "CAST_CONTEXT"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_type as pg_typesrc", "pg_cast.castsource = pg_typesrc.oid"); ! AddJoin("left join", "pg_type as pg_typetgt", "pg_cast.casttarget = pg_typetgt.oid"); ! AddJoin("left join", "pg_proc" , "pg_cast.castfunc = pg_proc.oid"); ! AddJoin("left join", "pg_namespace" , "pg_proc.pronamespace = pg_namespace.oid"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_proc.proname"); ! } ! ! public override void AddWhereFilters() ! { ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! return parsed; ! } ! ! #endregion ! ! #region Private Methods ! ! private string getContextExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 'e' THEN 'EXPLICIT'"); ! expression.Append(" when 'a' THEN 'ASSIGNMENT'"); ! expression.Append(" when 'i' THEN 'EXPRESSIONS'"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! #endregion ! } } Index: PgCheckConstraints.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema/PgCheckConstraints.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PgCheckConstraints.cs 2 Aug 2003 21:11:37 -0000 1.2 --- PgCheckConstraints.cs 14 Dec 2003 15:07:38 -0000 1.3 *************** *** 1,127 **** ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgCheckConstraintsSchema : PgAbstractDbSchema ! { ! #region CONSTRUCTORS ! ! public PgCheckConstraintsSchema() : base("CheckConstraints") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_constraint"); ! } ! ! public override void AddRestrictionColumns() ! { ! AddRestrictionColumn("pg_namespace.nspname", "CONSTRAINT_SCHEMA", null); ! AddRestrictionColumn("pg_constraint.conname", "CONSTRAINT_NAME", null); ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_get_constraintdef(pg_constraint.oid)", "CHECK_CLAUSULE"); ! AddDataColumn("pg_description.description", "DESCRIPTION"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_namespace" , "pg_constraint.connamespace = pg_namespace.oid"); ! AddJoin("left join", "pg_description" , "pg_constraint.oid = pg_description.objoid"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_namespace.nspname"); ! AddOrderBy("pg_constraint.conname"); ! } ! ! public override void AddWhereFilters() ! { ! AddWhereFilter("pg_constraint.contype = 'c'"); ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! if (parsed != null) ! { ! if (parsed.Length == 7 && parsed[6] != null) ! { ! switch (parsed[6].ToString().ToUpper()) ! { ! case "UNIQUE": ! parsed[3] = "u"; ! break; ! ! case "PRIMARY KEY": ! parsed[3] = "p"; ! break; ! ! case "FOREIGN KEY": ! parsed[3] = "f"; ! break; ! ! case "CHECK": ! parsed[3] = "c"; ! break; ! } ! } ! } ! ! return parsed; ! } ! ! #endregion ! ! #region PRIVATE_METHODS ! ! private string getConstraintTypeExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 'u' THEN 'UNIQUE'"); ! expression.Append(" when 'p' THEN 'PRIMARY KEY'"); ! expression.Append(" when 'f' THEN 'FOREIGN KEY'"); ! expression.Append(" when 'c' THEN 'CHECK'"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! #endregion ! } } --- 1,127 ---- ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgCheckConstraintsSchema : PgAbstractDbSchema ! { ! #region Constructors ! ! public PgCheckConstraintsSchema() : base("CheckConstraints") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_constraint"); ! } ! ! public override void AddRestrictionColumns() ! { ! AddRestrictionColumn("pg_namespace.nspname", "CONSTRAINT_SCHEMA", null); ! AddRestrictionColumn("pg_constraint.conname", "CONSTRAINT_NAME", null); ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_get_constraintdef(pg_constraint.oid)", "CHECK_CLAUSULE"); ! AddDataColumn("pg_description.description", "DESCRIPTION"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_namespace" , "pg_constraint.connamespace = pg_namespace.oid"); ! AddJoin("left join", "pg_description" , "pg_constraint.oid = pg_description.objoid"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_namespace.nspname"); ! AddOrderBy("pg_constraint.conname"); ! } ! ! public override void AddWhereFilters() ! { ! AddWhereFilter("pg_constraint.contype = 'c'"); ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! if (parsed != null) ! { ! if (parsed.Length == 7 && parsed[6] != null) ! { ! switch (parsed[6].ToString().ToUpper()) ! { ! case "UNIQUE": ! parsed[3] = "u"; ! break; ! ! case "PRIMARY KEY": ! parsed[3] = "p"; ! break; ! ! case "FOREIGN KEY": ! parsed[3] = "f"; ! break; ! ! case "CHECK": ! parsed[3] = "c"; ! break; ! } ! } ! } ! ! return parsed; ! } ! ! #endregion ! ! #region Private Methods ! ! private string getConstraintTypeExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 'u' THEN 'UNIQUE'"); ! expression.Append(" when 'p' THEN 'PRIMARY KEY'"); ! expression.Append(" when 'f' THEN 'FOREIGN KEY'"); ! expression.Append(" when 'c' THEN 'CHECK'"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! #endregion ! } } Index: PgCheckConstraintsByTable.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema/PgCheckConstraintsByTable.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PgCheckConstraintsByTable.cs 2 Aug 2003 21:11:37 -0000 1.2 --- PgCheckConstraintsByTable.cs 14 Dec 2003 15:07:38 -0000 1.3 *************** *** 1,133 **** ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgCheckConstraintsByTableSchema : PgAbstractDbSchema ! { ! #region CONSTRUCTORS ! ! public PgCheckConstraintsByTableSchema() : base("CheckConstraintsByTable") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_constraint"); ! } ! ! public override void AddRestrictionColumns() ! { ! AddRestrictionColumn("pg_namespace.nspname" , "CONSTRAINT_SCHEMA" , null); ! AddRestrictionColumn("pg_constraint.conname", "CONSTRAINT_NAME" , null); ! AddRestrictionColumn("tbn.nspname" , "TABLE_SCHEMA" , null); ! AddRestrictionColumn("pg_class.relname" , "TABLE_NAME" , null); ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_get_constraintdef(pg_constraint.oid)", "CHECK_CLAUSULE"); ! AddDataColumn("pg_description.description", "DESCRIPTION"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_class" , "pg_class.oid = pg_constraint.conrelid"); ! AddJoin("left join", "pg_namespace tbn" , "pg_class.relnamespace = tbn.oid"); ! AddJoin("left join", "pg_namespace" , "pg_constraint.connamespace = pg_namespace.oid"); ! AddJoin("left join", "pg_description" , "pg_constraint.oid = pg_description.objoid"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_namespace.nspname"); ! AddOrderBy("pg_class.relname"); ! AddOrderBy("pg_constraint.conname"); ! } ! ! public override void AddWhereFilters() ! { ! AddWhereFilter("pg_constraint.contype = 'c'"); ! AddWhereFilter("pg_class.relkind = 'r'"); ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! if (parsed != null) ! { ! if (parsed.Length == 7 && parsed[6] != null) ! { ! switch (parsed[6].ToString().ToUpper()) ! { ! case "UNIQUE": ! parsed[3] = "u"; ! break; ! ! case "PRIMARY KEY": ! parsed[3] = "p"; ! break; ! ! case "FOREIGN KEY": ! parsed[3] = "f"; ! break; ! ! case "CHECK": ! parsed[3] = "c"; ! break; ! } ! } ! } ! ! return parsed; ! } ! ! #endregion ! ! #region PRIVATE_METHODS ! ! private string getConstraintTypeExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 'u' THEN 'UNIQUE'"); ! expression.Append(" when 'p' THEN 'PRIMARY KEY'"); ! expression.Append(" when 'f' THEN 'FOREIGN KEY'"); ! expression.Append(" when 'c' THEN 'CHECK'"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! #endregion ! } } --- 1,133 ---- ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgCheckConstraintsByTableSchema : PgAbstractDbSchema ! { ! #region Constructors ! ! public PgCheckConstraintsByTableSchema() : base("CheckConstraintsByTable") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_constraint"); ! } ! ! public override void AddRestrictionColumns() ! { ! AddRestrictionColumn("pg_namespace.nspname" , "CONSTRAINT_SCHEMA" , null); ! AddRestrictionColumn("pg_constraint.conname", "CONSTRAINT_NAME" , null); ! AddRestrictionColumn("tbn.nspname" , "TABLE_SCHEMA" , null); ! AddRestrictionColumn("pg_class.relname" , "TABLE_NAME" , null); ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_get_constraintdef(pg_constraint.oid)", "CHECK_CLAUSULE"); ! AddDataColumn("pg_description.description", "DESCRIPTION"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_class" , "pg_class.oid = pg_constraint.conrelid"); ! AddJoin("left join", "pg_namespace tbn" , "pg_class.relnamespace = tbn.oid"); ! AddJoin("left join", "pg_namespace" , "pg_constraint.connamespace = pg_namespace.oid"); ! AddJoin("left join", "pg_description" , "pg_constraint.oid = pg_description.objoid"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_namespace.nspname"); ! AddOrderBy("pg_class.relname"); ! AddOrderBy("pg_constraint.conname"); ! } ! ! public override void AddWhereFilters() ! { ! AddWhereFilter("pg_constraint.contype = 'c'"); ! AddWhereFilter("pg_class.relkind = 'r'"); ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! if (parsed != null) ! { ! if (parsed.Length == 7 && parsed[6] != null) ! { ! switch (parsed[6].ToString().ToUpper()) ! { ! case "UNIQUE": ! parsed[3] = "u"; ! break; ! ! case "PRIMARY KEY": ! parsed[3] = "p"; ! break; ! ! case "FOREIGN KEY": ! parsed[3] = "f"; ! break; ! ! case "CHECK": ! parsed[3] = "c"; ! break; ! } ! } ! } ! ! return parsed; ! } ! ! #endregion ! ! #region Private Methods ! ! private string getConstraintTypeExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 'u' THEN 'UNIQUE'"); ! expression.Append(" when 'p' THEN 'PRIMARY KEY'"); ! expression.Append(" when 'f' THEN 'FOREIGN KEY'"); ! expression.Append(" when 'c' THEN 'CHECK'"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! #endregion ! } } Index: PgColumnsSchema.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/DbSchema/PgColumnsSchema.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PgColumnsSchema.cs 3 Aug 2003 10:23:03 -0000 1.4 --- PgColumnsSchema.cs 14 Dec 2003 15:07:38 -0000 1.5 *************** *** 1,132 **** ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgColumnsSchema : PgAbstractDbSchema ! { ! #region CONSTRUCTORS ! ! public PgColumnsSchema() : base("Columns") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_attribute"); ! } ! ! public override void AddRestrictionColumns() ! { ! AddRestrictionColumn("pg_namespace.nspname" , "TABLE_SCHEMA", null); ! AddRestrictionColumn("pg_class.relname" , "TABLE_NAME", null); ! AddRestrictionColumn("pg_attribute.attname" , "COLUMN_NAME", null); ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_attribute.atttypid" , "DATA_TYPE"); ! AddDataColumn("pg_attribute.attlen" , "COLUMN_SIZE"); ! AddDataColumn("pg_attribute.attndims" , "COLUMN_DIMENSIONS"); ! AddDataColumn("pg_attribute.attnum" , "ORDINAL_POSITION"); ! AddDataColumn("pg_attribute.atthasdef" , "HAS_DEFAULT"); ! AddDataColumn("pg_attrdef.adsrc" , "COLUMN_DEFAULT"); ! AddDataColumn("pg_attribute.attnotnull" , "IS_NOT_NULL"); ! AddDataColumn("(pg_depend.objid is not null)", "IS_AUTOINCREMENT"); ! AddDataColumn(getStorageExpression("pg_attribute.attstorage"), "STORAGE"); ! AddDataColumn("pg_description.description", "DESCRIPTION"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_class" , "pg_attribute.attrelid = pg_class.oid"); ! AddJoin("left join", "pg_namespace" , "pg_class.relnamespace = pg_namespace.oid"); ! AddJoin("left join", "pg_attrdef" , "(pg_class.oid = pg_attrdef.adrelid AND pg_attribute.attnum = pg_attrdef.adnum)"); ! AddJoin("left join", "pg_description", "(pg_attribute.attrelid = pg_description.objoid AND pg_attribute.attnum = pg_description.objsubid)"); ! AddJoin("left join", ! "pg_depend", ! "(pg_attribute.attrelid = pg_depend.refobjid AND pg_attribute.attnum = pg_depend.refobjsubid AND pg_depend.deptype = 'i')"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_namespace.nspname"); ! AddOrderBy("pg_class.relname"); ! AddOrderBy("pg_attribute.attnum"); ! } ! ! public override void AddWhereFilters() ! { ! // Do not get dropped columns ! AddWhereFilter("pg_attribute.attisdropped = false"); ! // Get only columns with a number > 0 ! AddWhereFilter("pg_attribute.attnum > 0"); ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! return parsed; ! } ! ! #endregion ! ! #region PRIVATE_METHODS ! ! private string getSerialExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 0 THEN true"); ! expression.Append(" default THEN false"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! private string getStorageExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 'p' THEN 'PLAIN'"); ! expression.Append(" when 'e' THEN 'EXTERNAL'"); ! expression.Append(" when 'm' THEN 'MAIN'"); ! expression.Append(" when 'x' THEN 'EXTENDED'"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! #endregion ! } ! } --- 1,132 ---- ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (C) 2003 Carlos Guzmán Álvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! using System; ! using System.Data; ! using System.Text; ! ! namespace PostgreSql.Data.PgSqlClient.DbSchema ! { ! internal class PgColumnsSchema : PgAbstractDbSchema ! { ! #region Constructors ! ! public PgColumnsSchema() : base("Columns") ! { ! } ! ! #endregion ! ! #region ADD_METHODS ! ! public override void AddTables() ! { ! AddTable("pg_attribute"); ! } ! ! public override void AddRestrictionColumns() ! { ! AddRestrictionColumn("pg_namespace.nspname" , "TABLE_SCHEMA", null); ! AddRestrictionColumn("pg_class.relname" , "TABLE_NAME", null); ! AddRestrictionColumn("pg_attribute.attname" , "COLUMN_NAME", null); ! } ! ! public override void AddDataColumns() ! { ! AddDataColumn("pg_attribute.atttypid" , "DATA_TYPE"); ! AddDataColumn("pg_attribute.attlen" , "COLUMN_SIZE"); ! AddDataColumn("pg_attribute.attndims" , "COLUMN_DIMENSIONS"); ! AddDataColumn("pg_attribute.attnum" , "ORDINAL_POSITION"); ! AddDataColumn("pg_attribute.atthasdef" , "HAS_DEFAULT"); ! AddDataColumn("pg_attrdef.adsrc" , "COLUMN_DEFAULT"); ! AddDataColumn("pg_attribute.attnotnull" , "IS_NOT_NULL"); ! AddDataColumn("(pg_depend.objid is not null)", "IS_AUTOINCREMENT"); ! AddDataColumn(getStorageExpression("pg_attribute.attstorage"), "STORAGE"); ! AddDataColumn("pg_description.description", "DESCRIPTION"); ! } ! ! public override void AddJoins() ! { ! AddJoin("left join", "pg_class" , "pg_attribute.attrelid = pg_class.oid"); ! AddJoin("left join", "pg_namespace" , "pg_class.relnamespace = pg_namespace.oid"); ! AddJoin("left join", "pg_attrdef" , "(pg_class.oid = pg_attrdef.adrelid AND pg_attribute.attnum = pg_attrdef.adnum)"); ! AddJoin("left join", "pg_description", "(pg_attribute.attrelid = pg_description.objoid AND pg_attribute.attnum = pg_description.objsubid)"); ! AddJoin("left join", ! "pg_depend", ! "(pg_attribute.attrelid = pg_depend.refobjid AND pg_attribute.attnum = pg_depend.refobjsubid AND pg_depend.deptype = 'i')"); ! } ! ! public override void AddOrderByColumns() ! { ! AddOrderBy("pg_namespace.nspname"); ! AddOrderBy("pg_class.relname"); ! AddOrderBy("pg_attribute.attnum"); ! } ! ! public override void AddWhereFilters() ! { ! // Do not get dropped columns ! AddWhereFilter("pg_attribute.attisdropped = false"); ! // Get only columns with a number > 0 ! AddWhereFilter("pg_attribute.attnum > 0"); ! } ! ! #endregion ! ! #region PARSE_METHODS ! ! public override object[] ParseRestrictions(object[] restrictions) ! { ! object[] parsed = restrictions; ! ! return parsed; ! } ! ! #endregion ! ! #region Private Methods ! ! private string getSerialExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 0 THEN true"); ! expression.Append(" default THEN false"); ! expression.Append(" END "); ! ! return expression.ToString(); ! } ! ! private string getStorageExpression(string fieldName) ! { ! StringBuilder expression = new StringBuilder(); ! ! expression.AppendFormat(" case {0} ", fieldName); ! expression.Append(" when 'p' THEN 'PLAIN'"); ! expression.Append(" when 'e' THEN 'EXTERNAL'"); ! expression.Append(" when 'm' THEN 'MAIN'"); ! expression.Append(" when ... [truncated message content] |