From: Carlos G. Á. <car...@us...> - 2005-09-13 18:30:46
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Schema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31653 Added Files: PgIndexColumns.cs PgIndexes.cs PgPrimaryKeys.cs Log Message: Continue the rework of the Schema support --- NEW FILE: PgPrimaryKeys.cs --- /* * PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * * The contents of this file are subject to the Initial * Developer's Public License Version 1.0 (the "License"); * you may not use this file except in compliance with the * License. * * Software distributed under the License is distributed on * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the License for the specific * language governing rights and limitations under the License. * * Copyright (c) 2003, 2005 Carlos Guzman Alvarez * All Rights Reserved. */ using System; namespace PostgreSql.Data.Schema { internal sealed class PgPrimaryKeys : PgSchema { #region · Protected Methods · protected override string BuildSql(string[] restrictions) { string sql = "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 " + "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 " + "left join pg_description ON pg_constraint.oid = pg_description.objoid " + "WHERE " + "pg_constraint.contype = 'p' "; if (restrictions != null && restrictions.Length > 0) { // TABLE_CATALOG if (restrictions.Length > 0) { } // TABLE_SCHEMA if (restrictions.Length > 1 && restrictions[1] != null) { sql += String.Format(" and pg_namespace.nspname = '{0}'", restrictions[1]); } // TABLE_NAME if (restrictions.Length > 2 && restrictions[2] != null) { sql += String.Format(" and pg_class.relname = '{0}'", restrictions[1]); } } sql += " ORDER BY pg_namespace.nspname, pg_class.relname, pg_constraint.conname"; return sql; } #endregion } } --- NEW FILE: PgIndexes.cs --- /* * PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * * The contents of this file are subject to the Initial * Developer's Public License Version 1.0 (the "License"); * you may not use this file except in compliance with the * License. * * Software distributed under the License is distributed on * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the License for the specific * language governing rights and limitations under the License. * * Copyright (c) 2003, 2005 Carlos Guzman Alvarez * All Rights Reserved. */ using System; namespace PostgreSql.Data.Schema { internal sealed class PgIndexes : PgSchema { #region · Protected Methods · protected override string BuildSql(string[] restrictions) { string sql = "SELECT " + "null AS TABLE_CATALOG " + "pg_namespace.nspname AS TABLE_SCHEMA, " + "pg_class.relname AS TABLE_NAME, " + "null AS INDEX_CATALOG, " + "pg_classidx.relname AS INDEX_NAME, " + "pg_namespidx.nspname AS INDEX_SCHEMA, " + "pg_am.amname AS TYPE, " + "pg_index.indkey AS INDEX_KEY, " + "pg_index.indisclustered AS CLUSTERED, " + "pg_index.indisunique AS UNIQUE, " + "pg_index.indisprimary AS PRIMARY, " + "pg_am.amindexnulls AS ALLOW_NULLS, " + "pg_am.amcanmulticol AS MULTICOLUMN, " + "pg_am.amconcurrent AS CONCURRENT, " + "pg_description.description AS DESCRIPTION " + "FROM pg_index " + "left join pg_class ON pg_index.indrelid = pg_class.oid " + "left join pg_class as pg_classidx ON pg_index.indexrelid = pg_classidx.oid " + "left join pg_namespace ON pg_classidx.relnamespace = pg_namespace.oid " + "left join pg_namespace as pg_namespidx ON pg_classidx.relnamespace = pg_namespidx.oid " + "left join pg_am ON pg_classidx.relam = pg_am.oid left join pg_description ON pg_index.indexrelid = pg_description.objoid "; if (restrictions != null && restrictions.Length > 0) { throw new NotImplementedException(); } sql += "ORDER BY pg_namespace.nspname, pg_class.relname, pg_classidx.relname"; return sql; } #endregion } } --- NEW FILE: PgIndexColumns.cs --- /* * PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ * * The contents of this file are subject to the Initial * Developer's Public License Version 1.0 (the "License"); * you may not use this file except in compliance with the * License. * * Software distributed under the License is distributed on * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the License for the specific * language governing rights and limitations under the License. * * Copyright (c) 2003, 2005 Carlos Guzman Alvarez * All Rights Reserved. */ using System; namespace PostgreSql.Data.Schema { internal sealed class PgIndexColumns : PgSchema { #region · Protected Methods · protected override string BuildSql(string[] restrictions) { throw new Exception("The method or operation is not implemented."); } #endregion } } |