Browse Source

* Only the lowest 16 bits of pqfmod gives the scale

git-svn-id: trunk@12313 -
joost 16 years ago
parent
commit
b3ebc67be2
1 changed files with 5 additions and 4 deletions
  1. 5 4
      packages/fcl-db/src/sqldb/postgres/pqconnection.pp

+ 5 - 4
packages/fcl-db/src/sqldb/postgres/pqconnection.pp

@@ -389,7 +389,7 @@ begin
                              size := PQfsize(Res, Tuple);
                              size := PQfsize(Res, Tuple);
                              if (size = -1) then
                              if (size = -1) then
                                begin
                                begin
-                               size := pqfmod(res,Tuple)-4;
+                               size := (PQfmod(res,Tuple)-4) and $FFFF;
                                if size = -5 then size := dsMaxStringSize;
                                if size = -5 then size := dsMaxStringSize;
                                end;
                                end;
                              if size > dsMaxStringSize then size := dsMaxStringSize;
                              if size > dsMaxStringSize then size := dsMaxStringSize;
@@ -409,11 +409,12 @@ begin
     Oid_Bool               : Result := ftBoolean;
     Oid_Bool               : Result := ftBoolean;
     Oid_Numeric            : begin
     Oid_Numeric            : begin
                              Result := ftBCD;
                              Result := ftBCD;
-                             size := PQfmod(res,Tuple);
+                             // The precision is the high 16 bits, the scale the
+                             // low 16 bits. Both with an offset of 4.
+                             // In this case we need the scale:
+                             size := (PQfmod(res,Tuple)-4) and $FFFF;
                              if size = -1 then
                              if size = -1 then
                                size := 4
                                size := 4
-                             else
-                               size := size -4;
                              end;
                              end;
     Oid_Money              : Result := ftCurrency;
     Oid_Money              : Result := ftCurrency;
     Oid_Unknown            : Result := ftUnknown;
     Oid_Unknown            : Result := ftUnknown;