private void AddFunctionColumnListSupport(Stream st) { bool isFirstOutputOrInputOutput = true; PGUtil.WriteString(st, " AS ("); for (int i = 0; i < Parameters.Count; i++) { var p = Parameters[i]; switch (p.Direction) { case ParameterDirection.Output: case ParameterDirection.InputOutput: if (isFirstOutputOrInputOutput) { isFirstOutputOrInputOutput = false; } else { st.WriteString(", "); } st .WriteString(p.CleanName) .WriteBytes((byte)ASCIIBytes.Space) .WriteString(p.TypeInfo.Name); break; } } st.WriteByte((byte)ASCIIBytes.ParenRight); }
private byte[] GetExecuteCommandText() { NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "GetPreparedCommandText"); MemoryStream result = new MemoryStream(); result.WriteString("EXECUTE {0}", planName); if (parameters.Count != 0) { result.WriteByte((byte)ASCIIBytes.ParenLeft); for (int i = 0; i < Parameters.Count; i++) { var p = Parameters[i]; if (i > 0) { result.WriteByte((byte)ASCIIBytes.Comma); } // Add parentheses wrapping parameter value before the type cast to avoid problems with Int16.MinValue, Int32.MinValue and Int64.MinValue // See bug #1010543 result.WriteByte((byte)ASCIIBytes.ParenLeft); byte[] serialization; serialization = p.TypeInfo.ConvertToBackend(p.Value, false, Connector.NativeToBackendTypeConverterOptions); result .WriteBytes(serialization) .WriteBytes((byte)ASCIIBytes.ParenRight); if (p.UseCast) { PGUtil.WriteString(result, string.Format("::{0}", p.TypeInfo.CastName)); if (p.TypeInfo.UseSize && (p.Size > 0)) { result.WriteString("({0})", p.Size); } } } result.WriteByte((byte)ASCIIBytes.ParenRight); } return(result.ToArray()); }