[pgsqlclient-checkins] SF.net SVN: pgsqlclient: [104] trunk/PostgreSqlClient/source/PostgreSql/Data/
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2006-04-12 14:56:18
|
Revision: 104 Author: carlosga_fb Date: 2006-04-12 07:55:36 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=104&view=rev Log Message: ----------- ?\194?\183 More changes on schema support NOT FINISHED !!! Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/MetaData.xml trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgColumns.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgForeignKeyColumns.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgPrimaryKeys.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgSchemaFactory.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgUniqueKeys.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/MetaData.xml =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/MetaData.xml 2006-04-12 13:41:56 UTC (rev 103) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/MetaData.xml 2006-04-12 14:55:36 UTC (rev 104) @@ -161,7 +161,13 @@ <NumberOfIdentifierParts>0</NumberOfIdentifierParts> <PopulationMechanism>PrepareCollection</PopulationMechanism> </MetaDataCollections> - <MetaDataCollections> + <MetaDataCollections> + <CollectionName>FunctionParameters</CollectionName> + <NumberOfRestrictions>3</NumberOfRestrictions> + <NumberOfIdentifierParts>0</NumberOfIdentifierParts> + <PopulationMechanism>PrepareCollection</PopulationMechanism> + </MetaDataCollections> + <MetaDataCollections> <CollectionName>Groups</CollectionName> <NumberOfRestrictions>0</NumberOfRestrictions> <NumberOfIdentifierParts>0</NumberOfIdentifierParts> @@ -392,6 +398,24 @@ <RestrictionNumber>3</RestrictionNumber> </Restrictions> <Restrictions> + <CollectionName>FunctionParameters</CollectionName> + <RestrictionName>Catalog</RestrictionName> + <RestrictionDefault>function_catalog</RestrictionDefault> + <RestrictionNumber>1</RestrictionNumber> + </Restrictions> + <Restrictions> + <CollectionName>FunctionParameters</CollectionName> + <RestrictionName>Schema</RestrictionName> + <RestrictionDefault>function_schema</RestrictionDefault> + <RestrictionNumber>2</RestrictionNumber> + </Restrictions> + <Restrictions> + <CollectionName>FunctionParameters</CollectionName> + <RestrictionName>Name</RestrictionName> + <RestrictionDefault>function_name</RestrictionDefault> + <RestrictionNumber>3</RestrictionNumber> + </Restrictions> + <Restrictions> <CollectionName>ForeignKeys</CollectionName> <RestrictionName>ConstraintCatalog</RestrictionName> <RestrictionDefault>constraint_catalog</RestrictionDefault> @@ -615,7 +639,7 @@ <SupportedJoinOperators>15</SupportedJoinOperators> </DataSourceInformation> <DataTypes> - <TypeName>smallint</TypeName> + <TypeName>int2</TypeName> <ProviderDbType>12</ProviderDbType> <ColumnSize>2</ColumnSize> <CreateFormat /> @@ -640,7 +664,7 @@ <DbType>10</DbType> </DataTypes> <DataTypes> - <TypeName>integer</TypeName> + <TypeName>int4</TypeName> <ProviderDbType>13</ProviderDbType> <ColumnSize>4</ColumnSize> <CreateFormat /> @@ -665,7 +689,7 @@ <DbType>11</DbType> </DataTypes> <DataTypes> - <TypeName>bigint</TypeName> + <TypeName>int8</TypeName> <ProviderDbType>14</ProviderDbType> <ColumnSize>8</ColumnSize> <CreateFormat /> @@ -740,7 +764,7 @@ <DbType>7</DbType> </DataTypes> <DataTypes> - <TypeName>real</TypeName> + <TypeName>float4</TypeName> <ProviderDbType>11</ProviderDbType> <ColumnSize>8</ColumnSize> <CreateFormat /> @@ -765,7 +789,7 @@ <DbType>15</DbType> </DataTypes> <DataTypes> - <TypeName>double precision</TypeName> + <TypeName>float8</TypeName> <ProviderDbType>10</ProviderDbType> <ColumnSize>8</ColumnSize> <CreateFormat /> @@ -790,7 +814,7 @@ <DbType>8</DbType> </DataTypes> <DataTypes> - <TypeName>money</TypeName> + <TypeName>currency</TypeName> <ProviderDbType>7</ProviderDbType> <ColumnSize>4</ColumnSize> <CreateFormat /> @@ -840,7 +864,7 @@ <DbType>16</DbType> </DataTypes> <DataTypes> - <TypeName>character varying</TypeName> + <TypeName>varchar</TypeName> <ProviderDbType>27</ProviderDbType> <ColumnSize>2147483647</ColumnSize> <CreateFormat /> @@ -940,7 +964,7 @@ <DbType>6</DbType> </DataTypes> <DataTypes> - <TypeName>timestamp without time zone</TypeName> + <TypeName>timestamp</TypeName> <ProviderDbType>23</ProviderDbType> <ColumnSize>8</ColumnSize> <CreateFormat /> @@ -965,7 +989,7 @@ <DbType>6</DbType> </DataTypes> <DataTypes> - <TypeName>time with time zone</TypeName> + <TypeName>timetz</TypeName> <ProviderDbType>24</ProviderDbType> <ColumnSize>12</ColumnSize> <CreateFormat /> @@ -990,7 +1014,7 @@ <DbType>6</DbType> </DataTypes> <DataTypes> - <TypeName>timestamp without time zone</TypeName> + <TypeName>timestamp</TypeName> <ProviderDbType>25</ProviderDbType> <ColumnSize>8</ColumnSize> <CreateFormat /> @@ -1015,7 +1039,7 @@ <DbType>6</DbType> </DataTypes> <DataTypes> - <TypeName>timestamp with time zone</TypeName> + <TypeName>timestamptz</TypeName> <ProviderDbType>26</ProviderDbType> <ColumnSize>8</ColumnSize> <CreateFormat /> Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgColumns.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgColumns.cs 2006-04-12 13:41:56 UTC (rev 103) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgColumns.cs 2006-04-12 14:55:36 UTC (rev 104) @@ -27,80 +27,82 @@ protected override string BuildSql(string[] restrictions) { - string where = ""; - string sql = - "SELECT " + - "table_catalog, " + - "table_schema, " + - "table_name, " + - "column_name, " + - "data_type, " + - "0 AS COLUMN_SIZE, " + - "numeric_precision, " + - "numeric_scale, " + - "ordinal_position, " + - "case is_nullable " + - "when 'NO' then false " + - "when 'YES' then true " + - "end AS is_nullable, " + - "column_default, " + - "character_maximum_length AS CHARACTER_LENGTH, " + - "character_octet_length, " + - "character_set_catalog, " + - "character_set_schema, " + - "character_set_name, " + - "collation_catalog, " + - "collation_schema, " + - "collation_name, " + - "domain_catalog, " + - "domain_schema, " + - "domain_name " + - "FROM information_schema.columns "; - + string sql = + "SELECT " + + "current_database() AS TABLE_CATALOG, " + + "pg_namespace.nspname AS TABLE_SCHEMA, " + + "pg_class.relname AS TABLE_NAME, " + + "pg_attribute.attname AS COLUMN_NAME, " + + "CASE " + + "WHEN pg_type.typname = 'bpchar' THEN 'char' " + + "WHEN pg_type.typname = '_bpchar' THEN '_char' " + + "ELSE pg_type.typname " + + "END AS DATA_TYPE, " + + "pg_attribute.attlen AS COLUMN_SIZE, " + + "information_schema.columns.character_octet_length AS CHARACTER_OCTET_LENGTH, " + + "information_schema.columns.character_maximum_length AS CHARACTER_LENGTH, " + + "0 AS NUMERIC_PRECISION, " + + "0 AS NUMERIC_SCALE, " + + "CASE " + + "WHEN pg_attribute.attndims > 0 THEN true " + + "ELSE false " + + "END AS IS_ARRAY, " + + "pg_attribute.attndims AS COLUMN_DIMENSIONS, " + + "pg_attribute.attnum AS ORDINAL_POSITION, " + + "pg_attribute.atthasdef AS HAS_DEFAULT, " + + "pg_attrdef.adsrc AS COLUMN_DEFAULT, " + + "CASE pg_attribute.attnotnull " + + "when true then false " + + "when false then true " + + "END AS IS_NULLABLE, " + + "(pg_depend.objid is not null) AS IS_AUTOINCREMENT, " + + "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') " + + "LEFT JOIN " + + "pg_type on (pg_type.oid = pg_attribute.atttypid) " + + "LEFT JOIN " + + "information_schema.columns on (table_catalog=current_database() and table_schema=pg_namespace.nspname and table_name=pg_class.relname and ordinal_position=pg_attribute.attnum) " + + "WHERE " + + "pg_attribute.attisdropped = false AND pg_attribute.attnum > 0 "; + if (restrictions != null && restrictions.Length > 0) { // TABLE_CATALOG if (restrictions.Length > 0 && restrictions[0] != null) { - if (where.Length > 0) - { - where += " and "; - } - where += String.Format("table_catalog = '{0}'", restrictions[0]); } // TABLE_SCHEMA if (restrictions.Length > 1 && restrictions[1] != null) { - if (where.Length > 0) - { - where += " and "; - } - where += String.Format("table_schema = '{0}'", restrictions[1]); + sql += String.Format(" and pg_namespace.nspname = '{0}'", restrictions[1]); } // TABLE_NAME if (restrictions.Length > 2 && restrictions[2] != null) { - if (where.Length > 0) - { - where += " and "; - } - where += String.Format("table_name = '{0}'", restrictions[2]); + sql += String.Format("pg_class.relname = '{0}'", restrictions[2]); } // COLUMN_NAME if (restrictions.Length > 3 && restrictions[3] != null) { - if (where.Length > 0) - { - where += " and "; - } - where += String.Format("column_name = '{0}'", restrictions[3]); + sql += String.Format("pg_attribute.attname = '{0}'", restrictions[3]); } } - sql += "WHERE " + where + " ORDER BY table_catalog, table_schema, table_name, ordinal_position"; + sql += " ORDER BY pg_namespace.nspname, pg_class.relname, pg_attribute.attnum"; return sql; } @@ -109,6 +111,8 @@ { DataTable dataTypes = connection.GetSchema("DataTypes"); + schema.BeginLoadData(); + foreach (DataRow column in schema.Rows) { switch (column["DATA_TYPE"].ToString()) @@ -117,8 +121,8 @@ column["COLUMN_SIZE"] = column["CHARACTER_OCTET_LENGTH"]; break; - case "character": - case "character variying": + case "char": + case "varchar": column["COLUMN_SIZE"] = column["CHARACTER_LENGTH"]; break; @@ -133,6 +137,7 @@ } } + schema.EndLoadData(); schema.AcceptChanges(); return schema; Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgForeignKeyColumns.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgForeignKeyColumns.cs 2006-04-12 13:41:56 UTC (rev 103) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgForeignKeyColumns.cs 2006-04-12 14:55:36 UTC (rev 104) @@ -105,6 +105,8 @@ selectColumn.Prepare(); + foreignKeyColumns.BeginLoadData(); + foreach (DataRow row in schema.Rows) { Array tableColumns = (Array)row["CONSTRAINT_TABLE_COLUMNS"]; @@ -145,7 +147,9 @@ } } + foreignKeyColumns.EndLoadData(); foreignKeyColumns.AcceptChanges(); + foreignKeyColumns.Columns.Remove("CONSTRAINT_TABLE_COLUMNS"); foreignKeyColumns.Columns.Remove("REFERENCED_TABLE_COLUMNS"); Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgPrimaryKeys.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgPrimaryKeys.cs 2006-04-12 13:41:56 UTC (rev 103) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgPrimaryKeys.cs 2006-04-12 14:55:36 UTC (rev 104) @@ -89,6 +89,8 @@ try { + primaryKeyColumns.BeginLoadData(); + selectColumn.Prepare(); foreach (DataRow row in schema.Rows) @@ -126,7 +128,9 @@ // CleanUp selectColumn.Dispose(); + primaryKeyColumns.EndLoadData(); primaryKeyColumns.AcceptChanges(); + primaryKeyColumns.Columns.Remove("PK_COLUMNS"); } Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgSchemaFactory.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgSchemaFactory.cs 2006-04-12 13:41:56 UTC (rev 103) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgSchemaFactory.cs 2006-04-12 14:55:36 UTC (rev 104) @@ -114,6 +114,10 @@ schema = new PgFunctions(); break; + case "functionparameters": + schema = new PgFunctionParameters(); + break; + case "foreignkeys": schema = new PgForeignKeys(); break; Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgUniqueKeys.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgUniqueKeys.cs 2006-04-12 13:41:56 UTC (rev 103) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Schema/PgUniqueKeys.cs 2006-04-12 14:55:36 UTC (rev 104) @@ -89,6 +89,8 @@ try { + uniqueKeyColumns.BeginLoadData(); + selectColumn.Prepare(); foreach (DataRow row in schema.Rows) @@ -126,7 +128,9 @@ // CleanUp selectColumn.Dispose(); + uniqueKeyColumns.EndLoadData(); uniqueKeyColumns.AcceptChanges(); + uniqueKeyColumns.Columns.Remove("UK_COLUMNS"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |