public override void SetGeneratedColumnInfo(int generate, ResultMetaData meta) { if (base.type == 50) { int identityColumnIndex = base.BaseTable.GetIdentityColumnIndex(); if (identityColumnIndex != -1) { this.GeneratedType = generate; this.GeneratedInputMetaData = meta; if (generate != 1) { if (generate == 2) { return; } } else { base.GeneratedIndexes = new int[] { identityColumnIndex }; } base.generatedResultMetaData = ResultMetaData.NewResultMetaData(base.GeneratedIndexes.Length); for (int i = 0; i < base.GeneratedIndexes.Length; i++) { base.generatedResultMetaData.columns[i] = base.BaseTable.GetColumn(base.GeneratedIndexes[i]); } base.generatedResultMetaData.PrepareData(); this.IsSimpleInsert = false; } } }
public Result PrepareStatement() { this._resultOut = Result.NewPrepareStatementRequest(); this._resultOut.SetMainString(this._sqlStatement); this._resultOut.SetPrepareOrExecuteProperties(this._sqlStatement, 0, 0, 0, this.queryTimeout, ResultProperties.DefaultPropsValue, this._command.FetchGeneratedResults ? 1 : 2, null, null); Result r = this._command.Connection.InnerConnection.SessionProxy.Execute(this._resultOut); if (r.IsError()) { UtlException.ThrowError(r); } try { this._statementId = r.GetStatementId(); this._pmdDescriptor = r.ParameterMetaData; this._parameterTypes = this._pmdDescriptor.GetParameterTypes(); this._parameterValues = new object[this._parameterTypes.Length]; this._streamLengths = new long[this._parameterTypes.Length]; this._parameterModes = this._pmdDescriptor.ParamModes; this._parameterNames = this._pmdDescriptor.ColumnLabels; this._isNamedParameters = this._pmdDescriptor.IsNamedParameters; } catch (Exception exception) { throw Error.GetError(0x1ca, exception.ToString()); } this._resultOut = Result.NewPreparedExecuteRequest(this._parameterTypes, this._statementId); this._resultOut.SetStatement(r.GetStatement()); return(r); }
public ResultWithMetaData( ResultMetaData metadata, T result) { Metadata = metadata; Result = result; }
private ResultMetaData GetResultTableMetaData() { ResultMetaData data = ResultMetaData.NewResultMetaData(this.ReturnTable.GetColumnCount()); for (int i = 0; i < this.ReturnTable.GetColumnCount(); i++) { data.columns[i] = this.ReturnTable.GetColumn(i); data.ColumnTypes[i] = this.ReturnTable.GetColumnTypes()[i]; } return(data); }
public void Read(IRowInputInterface i, ResultMetaData meta) { base.Id = i.ReadLong(); int num = i.ReadInt(); i.ReadInt(); i.ReadInt(); while (num-- > 0) { this.Add(i.ReadData(meta.ColumnTypes)); } }
public TabularResultContentSet(ResultConfig resultConfig, List <ResultSpecificationField> resultFields, IDataReader reader) : base() { Reader = reader; Meta = new ResultMetaData() { Columns = ResultColumn.Map(resultFields, SourceColumnType.GetColumnTypes(reader)) }; Data = new ResultData() { DataCollection = Iterator.ToList() }; RequestId = resultConfig.RequestId; }
private static ResultMetaData GetResultMetaData(UtlDataRecord record) { System.Data.LibCore.Clr.UtlMetaData[] metaData = record.GetMetaData(); int length = metaData.Length; int[] baseColumnIndexes = new int[length]; SqlType[] types = new SqlType[length]; for (int i = 0; i < length; i++) { baseColumnIndexes[i] = i; types[i] = GetDataType(metaData[i]); } return(ResultMetaData.NewResultMetaData(types, baseColumnIndexes, length, length)); }
public void Write(IRowOutputInterface o, ResultMetaData meta) { base.BeforeFirst(); o.WriteLong(base.Id); o.WriteInt(base.Size); o.WriteInt(0); o.WriteInt(base.Size); while (base.HasNext()) { object[] next = base.GetNext(); o.WriteData(meta.GetColumnCount(), meta.ColumnTypes, next, null, null); } base.BeforeFirst(); }
public void Close() { if (this._statementId != -1L) { try { this._command.Connection.InnerConnection.SessionProxy.Execute(Result.NewFreeStmtRequest(this._statementId)); this._statementId = -1L; this._pmdDescriptor = null; } catch (Exception) { } } this._sqlWarnings = null; this._generatedResult = null; }
public void SetParameterMetaData() { int num = 0; if (this.Parameters.Length == 0) { this.ParameterMetaData = ResultMetaData.EmptyParamMetaData; } else { this.ParameterMetaData = ResultMetaData.NewParameterMetaData(this.Parameters.Length); for (int i = 0; i < this.Parameters.Length; i++) { int index = i + num; if (this.Parameters[i].OpType == 0x62) { if (!this.ParameterMetaData.IsNamedParameters) { if (i != 0) { throw Error.GetError(0x1a91); } this.ParameterMetaData.IsNamedParameters = true; } this.ParameterMetaData.ColumnLabels[index] = this.Parameters[i].ColumnName; } else { if (this.ParameterMetaData.IsNamedParameters) { throw Error.GetError(0x1a91); } this.ParameterMetaData.ColumnLabels[index] = PcolPrefix + (i + 1); } this.ParameterMetaData.ColumnTypes[index] = this.Parameters[i].DataType; byte parameterMode = 1; if ((this.Parameters[i].column != null) && (this.Parameters[i].column.GetParameterMode() != 0)) { parameterMode = this.Parameters[i].column.GetParameterMode(); } this.ParameterMetaData.ParamModes[index] = parameterMode; this.ParameterMetaData.ParamNullable[index] = (this.Parameters[i].column == null) ? ((byte)1) : this.Parameters[i].column.GetNullability(); } } }
public virtual void ResolveTypesPartTwo(Session session) { ArrayUtil.ProjectRowReverse(this._leftQueryExpression.UnionColumnTypes, this._leftQueryExpression.UnionColumnMap, this.UnionColumnTypes); ArrayUtil.ProjectRowReverse(this._leftQueryExpression.UnionColumnNullability, this._leftQueryExpression.UnionColumnMap, this.UnionColumnNullability); this._leftQueryExpression.ResolveTypesPartTwo(session); ArrayUtil.ProjectRowReverse(this._rightQueryExpression.UnionColumnTypes, this._rightQueryExpression.UnionColumnMap, this.UnionColumnTypes); ArrayUtil.ProjectRowReverse(this._rightQueryExpression.UnionColumnNullability, this._rightQueryExpression.UnionColumnMap, this.UnionColumnNullability); this._rightQueryExpression.ResolveTypesPartTwo(session); if (this._unionCorresponding) { this.resultMetaData = this._leftQueryExpression.GetMetaData().GetNewMetaData(this._leftQueryExpression.UnionColumnMap); this.CreateTable(session); } if (this.ExprSortAndSlice.HasOrder()) { QueryExpression expression = this; while ((expression._leftQueryExpression != null) && !expression._unionCorresponding) { expression = expression._leftQueryExpression; } this.ExprSortAndSlice.SetIndex(null, expression.ResultTable); } }
public override ResultMetaData GetResultMetaData() { if (this._resultMetaData != null) { return(this._resultMetaData); } if (base.type != 7) { throw Error.RuntimeError(0xc9, "StatementProcedure"); } if (this._expression == null) { return(ResultMetaData.EmptyResultMetaData); } ResultMetaData data2 = ResultMetaData.NewResultMetaData(1); ColumnBase base2 = new ColumnBase(null, null, null, StatementDMQL.ReturnColumnName); base2.SetType(this._expression.GetDataType()); data2.columns[0] = base2; data2.PrepareData(); this._resultMetaData = data2; return(data2); }
public virtual void SetGeneratedColumnInfo(int mode, ResultMetaData meta) { }
public override DataTable GetSchemaTable() { this.CheckClosed(); if ((this._rResult == null) || (!this._rResult.IsData() && ((this._commandBehavior & CommandBehavior.SchemaOnly) == CommandBehavior.Default))) { throw UtlException.GetException(0x1ca); } DataTable table = new DataTable("SchemaTable"); ResultMetaData metaData = this._rResult.MetaData; table.Locale = CultureInfo.InvariantCulture; table.Columns.Add(SchemaTableColumn.ColumnName, typeof(string)); table.Columns.Add(SchemaTableColumn.ColumnOrdinal, typeof(int)); table.Columns.Add(SchemaTableColumn.ColumnSize, typeof(long)); table.Columns.Add(SchemaTableColumn.NumericPrecision, typeof(long)); table.Columns.Add(SchemaTableColumn.NumericScale, typeof(short)); table.Columns.Add(SchemaTableColumn.IsUnique, typeof(bool)); table.Columns.Add(SchemaTableColumn.IsKey, typeof(bool)); table.Columns.Add(SchemaTableOptionalColumn.BaseServerName, typeof(string)); table.Columns.Add(SchemaTableOptionalColumn.BaseCatalogName, typeof(string)); table.Columns.Add(SchemaTableColumn.BaseColumnName, typeof(string)); table.Columns.Add(SchemaTableColumn.BaseSchemaName, typeof(string)); table.Columns.Add(SchemaTableColumn.BaseTableName, typeof(string)); table.Columns.Add(SchemaTableColumn.DataType, typeof(Type)); table.Columns.Add(SchemaTableColumn.AllowDBNull, typeof(bool)); table.Columns.Add(SchemaTableColumn.ProviderType, typeof(int)); table.Columns.Add(SchemaTableColumn.IsAliased, typeof(bool)); table.Columns.Add(SchemaTableColumn.IsExpression, typeof(bool)); table.Columns.Add(SchemaTableOptionalColumn.IsAutoIncrement, typeof(bool)); table.Columns.Add(SchemaTableOptionalColumn.IsRowVersion, typeof(bool)); table.Columns.Add(SchemaTableOptionalColumn.IsHidden, typeof(bool)); table.Columns.Add(SchemaTableColumn.IsLong, typeof(bool)); table.Columns.Add(SchemaTableOptionalColumn.IsReadOnly, typeof(bool)); table.Columns.Add(SchemaTableOptionalColumn.ProviderSpecificDataType, typeof(Type)); table.Columns.Add(SchemaTableOptionalColumn.DefaultValue, typeof(string)); DataTable schema = null; DataTable table3 = null; if ((this._commandBehavior & CommandBehavior.KeyInfo) != CommandBehavior.Default) { string[] restrictionValues = new string[6]; restrictionValues[1] = metaData.columns[0].GetSchemaNameString(); restrictionValues[2] = metaData.columns[0].GetTableNameString(); restrictionValues[5] = "true"; schema = this._command.Connection.GetSchema("INDEXCOLUMNS", restrictionValues); string[] textArray2 = new string[3]; textArray2[1] = metaData.columns[0].GetSchemaNameString(); textArray2[2] = metaData.columns[0].GetTableNameString(); table3 = this._command.Connection.GetSchema("COLUMNS", textArray2); } table.BeginLoadData(); for (int i = 0; i < metaData.GetColumnCount(); i++) { DataRow row = table.NewRow(); if ((metaData.ColumnLabels[i] == null) && string.IsNullOrEmpty(metaData.columns[i].GetNameString())) { row[SchemaTableColumn.ColumnName] = DBNull.Value; } else { row[SchemaTableColumn.ColumnName] = metaData.ColumnLabels[i] ?? metaData.columns[i].GetNameString(); } row[SchemaTableColumn.ColumnOrdinal] = i; row[SchemaTableColumn.ColumnSize] = metaData.ColumnTypes[i].GetAdoPrecision(); row[SchemaTableColumn.ProviderType] = metaData.ColumnTypes[i].GetAdoTypeCode(); SqlType type = metaData.ColumnTypes[i]; if (type.IsNumberType()) { if (type.AcceptsPrecision()) { row[SchemaTableColumn.NumericPrecision] = ((NumberType)metaData.ColumnTypes[i]).GetNumericPrecisionInRadix(); } else { row[SchemaTableColumn.NumericPrecision] = DBNull.Value; } if (type.AcceptsScale()) { row[SchemaTableColumn.NumericScale] = type.GetAdoScale(); } else { row[SchemaTableColumn.NumericScale] = DBNull.Value; } } row[SchemaTableColumn.IsLong] = type.IsLobType(); row[SchemaTableColumn.AllowDBNull] = metaData.columns[i].GetNullability() > 0; row[SchemaTableOptionalColumn.IsReadOnly] = !metaData.columns[i].IsWriteable(); row[SchemaTableOptionalColumn.IsAutoIncrement] = metaData.columns[i].IsIdentity(); row[SchemaTableOptionalColumn.IsHidden] = false; row[SchemaTableOptionalColumn.IsRowVersion] = false; row[SchemaTableColumn.IsUnique] = false; row[SchemaTableColumn.IsKey] = false; row[SchemaTableColumn.DataType] = this.GetFieldType(i); if (string.IsNullOrEmpty(metaData.columns[i].GetNameString())) { row[SchemaTableColumn.BaseColumnName] = DBNull.Value; } else { row[SchemaTableColumn.BaseColumnName] = metaData.columns[i].GetNameString(); } row[SchemaTableColumn.IsExpression] = string.IsNullOrEmpty(metaData.columns[i].GetNameString()); row[SchemaTableColumn.IsAliased] = string.Compare(metaData.columns[i].GetNameString(), metaData.ColumnLabels[i], StringComparison.OrdinalIgnoreCase) > 0; if (string.IsNullOrEmpty(metaData.columns[i].GetTableNameString())) { row[SchemaTableColumn.BaseTableName] = DBNull.Value; } else { row[SchemaTableColumn.BaseTableName] = metaData.columns[i].GetTableNameString(); } if (string.IsNullOrEmpty(metaData.columns[i].GetCatalogNameString())) { row[SchemaTableOptionalColumn.BaseCatalogName] = "PUBLIC"; } else { row[SchemaTableOptionalColumn.BaseCatalogName] = metaData.columns[i].GetCatalogNameString(); } if (string.IsNullOrEmpty(metaData.columns[i].GetSchemaNameString())) { row[SchemaTableColumn.BaseSchemaName] = DBNull.Value; } else { row[SchemaTableColumn.BaseSchemaName] = metaData.columns[i].GetSchemaNameString(); } if ((this._commandBehavior & CommandBehavior.KeyInfo) != CommandBehavior.Default) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); for (int j = 0; j < schema.Rows.Count; j++) { string key = (string)schema.Rows[j]["INDEX_NAME"]; if (!dictionary.ContainsKey(key)) { dictionary.Add(key, (string)schema.Rows[j]["COLUMN_NAME"]); } else { dictionary[key] = string.Empty; } } foreach (string str2 in dictionary.Keys) { if (!string.IsNullOrEmpty(dictionary[str2]) && (string.Compare(metaData.columns[i].GetNameString(), dictionary[str2], StringComparison.OrdinalIgnoreCase) == 0)) { row[SchemaTableColumn.IsUnique] = true; } } for (int k = 0; k < table3.Rows.Count; k++) { if (string.Compare(metaData.columns[i].GetNameString(), (string)table3.Rows[k]["COLUMN_NAME"], StringComparison.OrdinalIgnoreCase) == 0) { row[SchemaTableOptionalColumn.DefaultValue] = table3.Rows[k]["COLUMN_DEF"]; row[SchemaTableColumn.IsKey] = table3.Rows[k]["IS_PRIMARY_KEY"]; } } } table.Rows.Add(row); } table.AcceptChanges(); table.EndLoadData(); return(table); }
public Result InvokeClrMethod(Session session, object[] data) { try { object obj2; if (this.DataImpact == 1) { session.sessionContext.IsReadOnly = true; session.SetNoSql(); } else if (this.DataImpact == 2) { session.sessionContext.IsReadOnly = true; } else if (this.DataImpact == 3) { session.sessionContext.IsReadOnly = true; } try { UtlContext.session = session; obj2 = this._cSharpMethod.Invoke(this.CSharpClassInstance, data); } finally { UtlContext.session = null; } if (this.ReturnsTable()) { IEnumerable enumerable = obj2 as IEnumerable; if ((obj2 == null) || (enumerable == null)) { throw Error.RuntimeError(0xc9, "FunctionSQLInvoked"); } ResultMetaData resultTableMetaData = this.GetResultTableMetaData(); Result result = Result.NewDataResult(resultTableMetaData); RowSetNavigator navigator = result.InitialiseNavigator(); object[] fillRowTemplate = this.GetFillRowTemplate(); foreach (object obj3 in enumerable) { object[] objArray2 = new object[resultTableMetaData.GetColumnCount()]; fillRowTemplate[0] = obj3; this.FillRowMethod.Invoke(this.CSharpClassInstance, fillRowTemplate); for (int i = 0; i < objArray2.Length; i++) { objArray2[i] = fillRowTemplate[i + 1]; } navigator.Add(objArray2); } return(result); } return(Result.NewPsmResult(this.ReturnType.ConvertCSharpToSQL(session, obj2))); } catch (TargetInvocationException) { return(Result.NewErrorResult(Error.GetError(0x1770, this.GetName().Name), null)); } catch (Exception) { return(Result.NewErrorResult(Error.GetError(0x1770, this.GetName().Name), null)); } }
public virtual void WriteSimple(IRowOutputInterface o, ResultMetaData meta) { throw Error.RuntimeError(0xc9, "RowSetNavigator"); }
public virtual void ReadSimple(IRowInputInterface i, ResultMetaData meta) { throw Error.RuntimeError(0xc9, "RowSetNavigator"); }