[pgsqlclient-checkins] pgsqlclient/PostgreSql.Data.PGSqlClient/source/NPGClient PGDecodeType.cs,1.1,
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-07-17 21:13:08
|
Update of /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient/source/NPGClient In directory sc8-pr-cvs1:/tmp/cvs-serv29383 Modified Files: PGDecodeType.cs PGEncodeType.cs PGResponsePacket.cs Log Message: CleanUp Index: PGDecodeType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient/source/NPGClient/PGDecodeType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PGDecodeType.cs 17 Jul 2003 09:50:40 -0000 1.1 --- PGDecodeType.cs 17 Jul 2003 21:13:05 -0000 1.2 *************** *** 23,29 **** internal class PGDecodeType { - public static void DecodeNumeric() - { - } } } --- 23,26 ---- Index: PGEncodeType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient/source/NPGClient/PGEncodeType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PGEncodeType.cs 17 Jul 2003 13:41:42 -0000 1.2 --- PGEncodeType.cs 17 Jul 2003 21:13:05 -0000 1.3 *************** *** 23,81 **** internal class PGEncodeType { - public static Decimal EncodeNumeric(int ndigits, int weight, int sign, int dscale, short[] digits) - { - Decimal result = 0M; - - // This code was ported from PostgreSQL sources - // src/Backend/utils/adt/numeric.c - if (sign == PGCodes.NUMERIC_NAN) - { - result = (decimal)Single.NaN; - } - else - { - int n = ndigits - 1; - - // truncate leading zeroes - while (n > 0 && digits[n] == 0) - { - weight--; - n--; - } - - // truncate trailing zeroes - while (n > 0 && digits[n - 1] == 0) - { - n--; - } - - // If zero result, force to weight=0 and positive sign - if (n == 0) - { - weight = 0; - sign = PGCodes.NUMERIC_POS; - } - - // Build the result - byte[] res = new Byte[PGCodes.NUMERIC_HDRSZ + n * 1]; - - Buffer.BlockCopy(digits, 0, res, 0, res.Length); - - /* - result = (Numeric) palloc(len); - result->varlen = len; - result->n_weight = weight; - result->n_sign_dscale = sign | (var->dscale & NUMERIC_DSCALE_MASK); - - // Check for overflow of int16 fields - if (result->n_weight != weight || - NUMERIC_DSCALE(result) != var->dscale) - elog(ERROR, "Value overflows numeric format"); - */ - - } - - return result; - } } } --- 23,26 ---- Index: PGResponsePacket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient/source/NPGClient/PGResponsePacket.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PGResponsePacket.cs 17 Jul 2003 13:41:42 -0000 1.3 --- PGResponsePacket.cs 17 Jul 2003 21:13:05 -0000 1.4 *************** *** 127,146 **** } - public decimal ReadNumeric() - { - short ndigits = ReadShort(); - short weight = ReadShort(); - short sign = ReadShort(); - short dscale = ReadShort(); - short[] digits = new short[ndigits]; - - for (int i = 0; i < digits.Length; i++) - { - digits[i] = ReadShort(); - } - - return PGEncodeType.EncodeNumeric(ndigits, weight, sign, dscale, digits); - } - public decimal ReadMoney() { --- 127,130 ---- *************** *** 279,282 **** --- 263,275 ---- case DbType.Decimal: + /* + Data sent by PostgreSQL In binary mode + short ndigits = ReadShort(); + short weight = ReadShort(); + short sign = ReadShort(); + short dscale = ReadShort(); + short[] digits = new short[ndigits]; + */ + string numericValue = ReadString(length); return Decimal.Parse(numericValue, NumberFormatInfo.InvariantInfo); |