Exemplo n.º 1
0
        public void ReadFromStream()
        {
            HsqlDataReader expected = NewTestSubject();

            MemoryStream ms = new MemoryStream(HsqlDataReader.ToByteArray(expected));

            HsqlDataReader.WriteToStream(ms, expected);

            ms.Position = 0;

            HsqlDataReader actual = HsqlDataReader.ReadFromStream(ms);

            Assert.AreEqual(expected.Depth, actual.Depth, "Depth");
            Assert.AreEqual(expected.FieldCount, actual.FieldCount, "FieldCount");
            Assert.AreEqual(expected.HasRows, actual.HasRows, "HasRows");
            Assert.AreEqual(expected.IsClosed, actual.IsClosed, "IsClosed");
            Assert.AreEqual(expected.RecordsAffected, actual.RecordsAffected, "RecordsAffected");
            Assert.AreEqual(expected.VisibleFieldCount, actual.VisibleFieldCount, "VisibleFieldCount");

            object[] expectedValues = new object[expected.FieldCount];
            object[] actualValues   = new object[actual.FieldCount];

            while (expected.Read())
            {
                Assert.That(actual.Read());

                expected.GetValues(expectedValues);
                actual.GetValues(actualValues);

                for (int i = 0; i < expectedValues.Length; i++)
                {
                    Assert.AreEqual(expectedValues[i], actualValues[i]);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fills the table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 4);

            string catalogName           = restrictions[0];
            string schemaNamePattern     = restrictions[1];
            string tableNamePattern      = restrictions[2];
            string constraintNamePattern = restrictions[3];

            if (WantsIsNull(schemaNamePattern) ||
                WantsIsNull(tableNamePattern) ||
                WantsIsNull(constraintNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("TABLE_CATALOG", "=", catalogName))
            .Append(And("TABLE_SCHEMA", "LIKE", schemaNamePattern))
            .Append(And("TABLE_NAME", "LIKE", tableNamePattern))
            .Append(And("CONSTRAINT_NAME", "LIKE", constraintNamePattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string constraintCatalog = (string)values[0];
                    string constraintSchema  = (string)values[1];
                    string constraintName    = (string)values[2];
                    string constraintType    = (string)values[3];
                    string tableCatalog      = (string)values[4];
                    string tableSchema       = (string)values[5];
                    string tableName         = (string)values[6];
                    string isDeferrable      = (string)values[7];
                    string initiallyDeferred = (string)values[8];
                    string checkClause       = (string)values[9];

                    AddRow(
                        table,
                        constraintCatalog,
                        constraintSchema,
                        constraintName,
                        constraintType,
                        tableCatalog,
                        tableSchema,
                        tableName,
                        isDeferrable,
                        initiallyDeferred,
                        checkClause
                        );
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Fills a <c>Databases</c> metadata collection table using the
        /// given connection and restrictions.
        /// </summary>
        /// <param name="connection">The connection from which to fill the table.</param>
        /// <param name="table">The table to fill.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            string databaseNamePattern = GetRestrictions(restrictions, 1)[0];

            if (WantsIsNull(databaseNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query.Append(And("value", "LIKE", databaseNamePattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string databaseName = (string)values[0];

                    AddRow(table, databaseName, null, null);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Fills the procedures table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 4);

            string catalogName           = restrictions[0];
            string specificSchemaPattern = restrictions[1];
            string specificNamePattern   = restrictions[2];
            string typePattern           = restrictions[3];

            if (WantsIsNull(specificSchemaPattern) ||
                WantsIsNull(specificNamePattern) ||
                WantsIsNull(typePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("SPECIFIC_CATALOG", "=", catalogName))
            .Append(And("SPECIFIC_SCHEMA", "LIKE", specificSchemaPattern))
            .Append(And("SPECIFIC_NAME", "LIKE", specificNamePattern))
            .Append(And("ROUTINE_TYPE", "LIKE", typePattern))
            .Append(" ORDER BY 1, 2, 3");

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string   specificCatalog = (string)values[0];
                    string   specificSchema  = (string)values[1];
                    string   specifcName     = (string)values[2];
                    string   routineCatalog  = (string)values[3];
                    string   routineSchema   = (string)values[4];
                    string   routineName     = (string)values[5];
                    string   routineType     = (string)values[6];
                    DateTime?created         = (DateTime?)values[7];
                    DateTime?lastAltered     = (DateTime?)values[8];

                    AddRow(
                        table,
                        specificCatalog,
                        specificSchema,
                        specifcName,
                        routineCatalog,
                        routineSchema,
                        routineName,
                        routineType,
                        created,
                        lastAltered);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Fills the tables table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 4);

            string catalogName   = restrictions[0];
            string schemaPattern = restrictions[1];
            string tablePattern  = restrictions[2];
            string typePattern   = restrictions[3];

            if (schemaPattern != null && schemaPattern.StartsWith("\"") && schemaPattern.EndsWith("\""))
            {
                schemaPattern = schemaPattern.Substring(1, schemaPattern.Length - 2);
            }

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("TABLE_CAT", "=", catalogName))
            .Append(And("TABLE_SCHEM", "LIKE", schemaPattern))
            .Append(And("TABLE_NAME", "LIKE", tablePattern));

            if (typePattern != null)
            {
                string[] types = typePattern.Split(Comma);

                if (types.Length == 1)
                {
                    query.Append(And("TABLE_TYPE", "LIKE", types[0]));
                }
                else
                {
                    query.Append(And("TABLE_TYPE", "IN", ToSQLInList(types)));
                }
            }

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string tableCatalog = (string)values[0];
                    string tableSchema  = (string)values[1];
                    string tableName    = (string)values[2];
                    string tableType    = (string)values[3];

                    AddRow(
                        table,
                        tableCatalog,
                        tableSchema,
                        tableName,
                        tableType);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Fills the table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 3);

            string catalogName         = restrictions[0];
            string schemaNamePattern   = restrictions[1];
            string sequenceNamePattern = restrictions[2];

            if (WantsIsNull(schemaNamePattern) ||
                WantsIsNull(sequenceNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("SEQUENCE_CATALOG", "=", catalogName))
            .Append(And("SEQUENCE_SCHEMA", "LIKE", schemaNamePattern))
            .Append(And("SEQUENCE_NAME", "LIKE", sequenceNamePattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string sequenceCatalog = (string)values[0];
                    string sequenceSchema  = (string)values[1];
                    string sequenceName    = (string)values[2];
                    string dtdIdentifier   = (string)values[3];
                    string maximumValue    = (string)values[4];
                    string minimumValue    = (string)values[5];
                    string increment       = (string)values[6];
                    string cycleOption     = (string)values[7];
                    string startWith       = (string)values[8];

                    AddRow(
                        table,
                        sequenceCatalog,
                        sequenceSchema,
                        sequenceName,
                        dtdIdentifier,
                        maximumValue,
                        minimumValue,
                        increment,
                        cycleOption,
                        startWith
                        );
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Fills a <c>DataTypes</c> metadata collection table
        /// using the given connection and restrictions.
        /// </summary>
        /// <param name="connection">The connection from which to fill the table.</param>
        /// <param name="table">The table to file.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            using (HsqlDataReader reader = Execute(connection, sql))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string providerTypeName      = (string)values[0];
                    int    providerDbType        = (int)values[1];
                    int?   columnSize            = (int?)values[2];
                    string literalPrefix         = (string)values[3];
                    string literalSuffix         = (string)values[4];
                    string createParameters      = (string)values[5];
                    short  nullability           = (short)(int)values[6];
                    bool?  isCaseSensitive       = (bool?)values[7];
                    short  searchability         = (short)(int)values[8];
                    bool?  isUnsigned            = (bool?)values[9];
                    bool?  isFixedPrecisionScale = (bool?)values[10];
                    bool?  isAutoIncrementable   = (bool?)values[11];
                    //string localTypeName = (string) values[12];
                    short?minimumScale = (short?)(int?)values[13];
                    short?maximumScale = (short?)(int?)values[14];
                    //int? sqlDataType = (int?) values[15];
                    //int? dateTimeSub = (int?)values[16];
                    //int? numPrecRadix = (int?)values[17];
                    //int? typeSub = (int?)values[18];

                    string createFormat         = ToCreateFormat(providerTypeName, createParameters);
                    string dataType             = Convert.ToString(HsqlConvert.ToDataType(providerDbType));
                    bool   isBestMatch          = IsBestMatchProviderTypeName(providerTypeName);
                    bool   isFixedLength        = IsFixedLength(providerDbType);
                    bool   isLong               = IsLongProviderType(providerDbType);
                    bool   isNullable           = IsNullable(nullability);
                    bool   isSearchable         = IsSearchable(searchability);
                    bool   isSearchableWithLike = IsSearchableWithLike(searchability);
                    bool   isConcurrencyType    = false;
                    bool   isLiteralSupported   = true;

                    AddRow(table,
                           providerTypeName, providerDbType,
                           columnSize,
                           createFormat, createParameters,
                           dataType, isAutoIncrementable, isBestMatch,
                           isCaseSensitive, isFixedLength, isFixedPrecisionScale, isLong,
                           isNullable, isSearchable, isSearchableWithLike, isUnsigned,
                           maximumScale, minimumScale, isConcurrencyType,
                           isLiteralSupported, literalPrefix, literalSuffix);
                }
            }
        }
Exemplo n.º 8
0
        public void GetValues()
        {
            HsqlDataReader testSubject = NewTestSubject();

            testSubject.Read();

            object[] values = new object[testSubject.FieldCount];

            int count = testSubject.GetValues(values);

            Assert.Fail("TODO");
        }
Exemplo n.º 9
0
        /// <summary>
        /// Fills the view columns table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 4);

            string catalogName       = restrictions[0];
            string viewSchemaPattern = restrictions[1];
            string viewNamePattern   = restrictions[2];
            string columnNamePattern = restrictions[3];

            if (WantsIsNull(viewSchemaPattern) ||
                WantsIsNull(viewNamePattern) ||
                WantsIsNull(columnNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("VIEW_CATALOG", "=", catalogName))
            .Append(And("VIEW_SCHEMA", "LIKE", viewSchemaPattern))
            .Append(And("VIEW_NAME", "LIKE", viewNamePattern))
            .Append(And("COLUMN_NAME", "LIKE", columnNamePattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string viewCatalog  = (string)values[0];
                    string viewSchema   = (string)values[1];
                    string viewName     = (string)values[2];
                    string tableCatalog = (string)values[3];
                    string tableSchema  = (string)values[4];
                    string tableName    = (string)values[5];
                    string columnName   = (string)values[6];

                    AddRow(
                        table,
                        viewCatalog,
                        viewSchema,
                        viewName,
                        tableCatalog,
                        tableSchema,
                        tableName,
                        columnName);
                }
            }
        }
Exemplo n.º 10
0
        public void ExecuteReader()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.CommandText = "select * from information_schema.system_tables";

                    using (HsqlDataReader reader = testSubject.ExecuteReader())
                    {
                        object[] values = new object[reader.FieldCount];

                        while (reader.Read())
                        {
                            int fieldCount = reader.GetValues(values);

                            for (int i = 0; i < fieldCount; i++)
                            {
                                object value = values[i];
                                Console.Write(value);
                                Console.Write(" : ");
                            }
                            Console.WriteLine();
                        }
                    }
                }

            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.CommandText = "select * from information_schema.system_tables";
                    HsqlDataReader reader      = testSubject.ExecuteReader(CommandBehavior.SchemaOnly);
                    DataTable      schemaTable = reader.GetSchemaTable();

                    foreach (DataRow row in schemaTable.Rows)
                    {
                        object[] values = row.ItemArray;

                        foreach (object value in values)
                        {
                            Console.Write(value);
                            Console.Write(" : ");
                        }
                        Console.WriteLine();
                    }
                }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Fills the given data table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 3);

            string catalogName        = restrictions[0];
            string schemaNamePattern  = restrictions[1];
            string schemaOwnerPattern = restrictions[2];

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("catalog_name", "=", catalogName))
            .Append(And("schema_name", "LIKE", schemaNamePattern))
            .Append(And("schema_owner", "LIKE", schemaOwnerPattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    catalogName = (string)values[0];
                    string schemaName  = (string)values[1];
                    string schemaOwner = (string)values[2];
                    string dcsCatalog  = (string)values[3];
                    string dcsSchema   = (string)values[4];
                    string dcsName     = (string)values[5];
                    string sqlPath     = (string)values[6];

                    AddRow(
                        table,
                        catalogName,
                        schemaName,
                        schemaOwner,
                        dcsCatalog,
                        dcsSchema,
                        dcsName,
                        sqlPath);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Fills the views table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 3);

            string catalogName       = restrictions[0];
            string schemaNamePattern = restrictions[1];
            string tableNamePattern  = restrictions[2];

            if (WantsIsNull(schemaNamePattern) ||
                WantsIsNull(tableNamePattern))
            {
                return;
            }

            StringBuilder query = ToQueryPrefix("INFORMATION_SCHEMA.SYSTEM_VIEWS");

            query
            //.Append(And("TABLE_CATALOG", "=", catalogName))
            .Append(And("TABLE_SCHEMA", "LIKE", schemaNamePattern))
            .Append(And("TABLE_NAME", "LIKE", tableNamePattern));


            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    AddRow(
                        table,
                        (string)values[0],
                        (string)values[1],
                        (string)values[2],
                        (string)values[3],
                        (string)values[4],
                        (string)values[5]);
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Fills a Users metadata collection table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 1);

            string userNamePattern = restrictions[0];

            if (WantsIsNull(userNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query.Append(And("SA.AUTHORIZATION_NAME", "LIKE", userNamePattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    short?   uid               = (short?)values[0];
                    string   userName          = (string)values[1];
                    DateTime?createDate        = (DateTime?)values[2];
                    DateTime?updateDate        = (DateTime?)values[3];
                    string   authorizationType = (string)values[4];
                    bool?    isAdmin           = (bool?)values[5];

                    AddRow(
                        table,
                        uid,
                        userName,
                        createDate,
                        updateDate,
                        authorizationType,
                        isAdmin);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Fills the given <c>Indexes</c> metadata collection table
        /// using the given connection and restrictions.
        /// </summary>
        /// <param name="connection">The connection from which to fill the table.</param>
        /// <param name="table">The table to fill.</param>
        /// <param name="restrictions">The restrictions to apply.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 6);

            string catalogName       = restrictions[0];
            string schemaNamePattern = restrictions[1];
            string tableNamePattern  = restrictions[2];
            string indexNamePattern  = restrictions[3];
            string isUnique          = restrictions[4];
            string isPrimaryKey      = restrictions[5];

            if (WantsIsNull(schemaNamePattern) ||
                WantsIsNull(tableNamePattern) ||
                WantsIsNull(indexNamePattern) ||
                WantsIsNull(isUnique) ||
                WantsIsNull(isPrimaryKey))
            {
                return;
            }

            if (isUnique != null)
            {
                isUnique = isUnique.ToUpperInvariant();
            }

            if (isPrimaryKey != null)
            {
                isPrimaryKey = isPrimaryKey.ToUpperInvariant();
            }

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("TABLE_CATALOG", "=", catalogName))
            .Append(And("TABLE_SCHEMA", "LIKE", schemaNamePattern))
            .Append(And("TABLE_NAME", "LIKE", tableNamePattern))
            .Append(And("INDEX_NAME", "LIKE", indexNamePattern))
            .Append(And("UNIQUE", "=", isUnique))
            .Append(And("PRIMARY_KEY", "=", isPrimaryKey))
            .Append(" ORDER BY 5, 6, 7, 8");
            // table_catalog, table_schema, table_name, index_name

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string constraintCatalog = (string)values[0];
                    string constraintSchema  = (string)values[1];
                    string constraintName    = (string)values[2];
                    string constraintType    = (string)values[3];
                    string tableCatalog      = (string)values[4];
                    string tableSchema       = (string)values[5];
                    string tableName         = (string)values[6];
                    string indexName         = (string)values[7];

                    bool unique     = (bool)values[8];
                    bool primaryKey = (bool)values[9];

                    AddRow(
                        table,
                        constraintCatalog,
                        constraintSchema,
                        constraintName,
                        constraintType,
                        tableCatalog,
                        tableSchema,
                        tableName,
                        indexName,
                        unique,
                        primaryKey);
                }
            }
        }
        /// <summary>
        /// Fills the procedure parameters table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 4);

            string catalogName           = restrictions[0];
            string specificSchemaPattern = restrictions[1];
            string specificNamePattern   = restrictions[2];
            string columnNamePattern     = restrictions[3];

            if (WantsIsNull(specificSchemaPattern) ||
                WantsIsNull(specificNamePattern) ||
                WantsIsNull(columnNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("SPECIFIC_CATALOG", "=", catalogName))
            .Append(And("SPECIFIC_SCHEMA", "LIKE", specificSchemaPattern))
            .Append(And("SPECIFIC_NAME", "LIKE", specificNamePattern))
            .Append(And("COLUMN_NAME", "LIKE", columnNamePattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string specificCatalog        = (string)values[0];
                    string specificSchema         = (string)values[1];
                    string specificName           = (string)values[2];
                    int    ordinalPosition        = (int)values[3];
                    string parameterMode          = (string)values[4];
                    string isResult               = (string)values[5];
                    string asLocator              = (string)values[6];
                    string parameterName          = (string)values[7];
                    string dataType               = (string)values[8];
                    int?   characterMaximumLength = (int?)values[9];
                    int?   characterOctetLength   = (int?)values[10];
                    string collationCatalog       = (string)values[11];
                    string collationSchema        = (string)values[12];
                    string collationName          = (string)values[13];
                    string characterSetCatalog    = (string)values[14];
                    string characterSetSchema     = (string)values[15];
                    string characterSetName       = (string)values[16];
                    int?   numericPrecision       = (int?)values[17];
                    short? numericPrecisionRadix  = (short?)(int?)values[18];
                    int?   numericScale           = (int?)values[19];
                    short? datetimePrecision      = (short?)(int?)values[20];
                    string intervalType           = (string)values[21];
                    short? intervalPrecision      = (short?)(int?)values[22];
                    string parameterDirection     = (string)values[23];

                    AddRow(
                        table,
                        specificCatalog,
                        specificSchema,
                        specificName,
                        ordinalPosition,
                        parameterMode,
                        isResult,
                        asLocator,
                        parameterName,
                        dataType,
                        characterMaximumLength,
                        characterOctetLength,
                        collationCatalog,
                        collationSchema,
                        collationName,
                        characterSetCatalog,
                        characterSetSchema,
                        characterSetName,
                        numericPrecision,
                        numericPrecisionRadix,
                        numericScale,
                        datetimePrecision,
                        intervalType,
                        intervalPrecision,
                        parameterDirection);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Fills the table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 4);

            string catalogName        = restrictions[0];
            string schemaNamePattern  = restrictions[1];
            string tableNamePattern   = restrictions[2];
            string triggerNamePattern = restrictions[3];

            if (WantsIsNull(schemaNamePattern) ||
                WantsIsNull(tableNamePattern) ||
                WantsIsNull(triggerNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query
            //.Append(And("TABLE_CATALOG", "=", catalogName))
            .Append(And("TABLE_SCHEMA", "LIKE", schemaNamePattern))
            .Append(And("TABLE_NAME", "LIKE", tableNamePattern))
            .Append(And("TRIGGER_NAME", "LIKE", triggerNamePattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string triggerCatalog   = (string)values[0];
                    string triggerSchema    = (string)values[1];
                    string triggerName      = (string)values[2];
                    string tableCatalog     = (string)values[3];
                    string tableSchema      = (string)values[4];
                    string baseObjectType   = (string)values[5];
                    string tableName        = (string)values[6];
                    string columnName       = (string)values[7];
                    string referencingNames = (string)values[8];
                    string whenClause       = (string)values[9];
                    string status           = (string)values[10];
                    string description      = (string)values[11];
                    string actionType       = (string)values[12];
                    string triggerBody      = (string)values[13];

                    AddRow(
                        table,
                        triggerCatalog,
                        triggerSchema,
                        triggerName,
                        tableCatalog,
                        tableSchema,
                        baseObjectType,
                        tableName,
                        columnName,
                        referencingNames,
                        whenClause,
                        status,
                        description,
                        actionType,
                        triggerBody
                        );
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Fills the given <c>ForeignKeyColumnsCollection</c> table
        /// using the given connection and restrictions.
        /// </summary>
        /// <param name="connection">The connection from which to fill the table.</param>
        /// <param name="table">The table to fill.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 5);

            string catalogName           = restrictions[0];
            string schemaNamePattern     = restrictions[1];
            string tableNamePattern      = restrictions[2];
            string constraintNamePattern = restrictions[3];
            string columnNamePattern     = restrictions[4];

            if (WantsIsNull(schemaNamePattern) ||
                WantsIsNull(tableNamePattern) ||
                WantsIsNull(constraintNamePattern) ||
                WantsIsNull(columnNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query
#if CATALOG_RESTRICTIONS
            .Append(And("TABLE_CATALOG", "=", catalogName))
#endif
            .Append(And("TABLE_SCHEMA", "LIKE", schemaNamePattern))
            .Append(And("TABLE_NAME", "LIKE", tableNamePattern))
            .Append(And("CONSTRAINT_NAME", "LIKE", constraintNamePattern))
            .Append(And("COLUMN_NAME", "LIKE", columnNamePattern));

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string constraintCatalog  = (string)values[0];
                    string constraintSchema   = (string)values[1];
                    string constraintName     = (string)values[2];
                    string tableCatalog       = (string)values[3];
                    string tableSchema        = (string)values[4];
                    string tableName          = (string)values[5];
                    string columnName         = (string)values[6];
                    string uniqueTableCatalog = (string)values[7];
                    string uniqueTableSchema  = (string)values[8];
                    string uniqueTableName    = (string)values[9];
                    string uniqueColumnName   = (string)values[10];
                    int    ordinalPosition    = (int)values[11];

                    AddRow(
                        table,
                        constraintCatalog,
                        constraintSchema,
                        constraintName,
                        tableCatalog,
                        tableSchema,
                        tableName,
                        columnName,
                        uniqueTableCatalog,
                        uniqueTableSchema,
                        uniqueTableName,
                        uniqueColumnName,
                        ordinalPosition);
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Fills the <c>UniqueConstraintColumns</c> metadata collection table.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="table">The table.</param>
        /// <param name="restrictions">The restrictions.</param>
        public override void FillTable(HsqlConnection connection,
                                       DataTable table, string[] restrictions)
        {
            restrictions = GetRestrictions(restrictions, 5);

            string catalogName           = restrictions[0];
            string schemaNamePattern     = restrictions[1];
            string tableNamePattern      = restrictions[2];
            string constraintNamePattern = restrictions[3];
            string columnNamePattern     = restrictions[4];

            if (WantsIsNull(tableNamePattern) ||
                WantsIsNull(constraintNamePattern) ||
                WantsIsNull(columnNamePattern))
            {
                return;
            }

            StringBuilder query = new StringBuilder(sql);

            query.Append(And("TABLE_CATALOG", "=", catalogName))
            .Append(And("TABLE_SCHEMA", "LIKE", schemaNamePattern))
            .Append(And("TABLE_NAME", "LIKE", tableNamePattern))
            .Append(And("CONSTRAINT_NAME", "LIKE", constraintNamePattern))
            .Append(And("COLUMN_NAME", "LIKE", columnNamePattern))
            .Append(" ORDER BY 1, 2, 3, 8");
            // constraint_catalog, constraint_schema, constraint_name, ordinal_position

            using (HsqlDataReader reader = Execute(connection, query.ToString()))
            {
                object[] values = new object[reader.FieldCount];

                while (reader.Read())
                {
                    reader.GetValues(values);

                    string constraintCatalog = (string)values[0];
                    string constraintSchema  = (string)values[1];
                    string constraintName    = (string)values[2];
                    string tableCatalog      = (string)values[3];
                    string tableSchema       = (string)values[4];
                    string tableName         = (string)values[5];
                    string columnName        = (string)values[6];
                    int    ordinalPosition   = (int)values[7];
                    short  keyType           = (short)(int)values[8];
                    string indexName         = (string)values[9];

                    AddRow(
                        table,
                        constraintCatalog,
                        constraintSchema,
                        constraintName,
                        tableCatalog,
                        tableSchema,
                        tableName,
                        columnName,
                        ordinalPosition,
                        keyType,
                        indexName);
                }
            }
        }