[patch_done] PgSQL - Possible metadata mistaken information
Posted: 08.07.2009, 21:41
I'm using PostgreSQL 8.3 since this version has been released, always with Zeos Query, ROQuery etc.. But I'm new on ZMetadata component.
In past I get metadata from PostgreSQL using direct queries, which precess was not so easy to do. My reference was always this wiki http://pt.wikibooks.org/wiki/PostgreSQL ... /Metadados (don't know about english version).
However, inspecting metadata result, I've noticed missing and incorrect information about numeric type. Numeric type in Pg is defined by precision and scale ( see http://www.postgresql.org/docs/8.3/inte ... IC-DECIMAL).
Since data returning by metadata seems to be wrong, I turn back to those old SQL scripts and changed Zeos code a little, for testing, so:
unit ZDbcPostgreSqlMetadata.pas
else if (PgType = 'numeric') or (PgType = 'decimal') then
begin
{
//Old code here
AttTypMod := GetInt(8) - 4;
Result.UpdateInt(7, (AttTypMod shr 16) and $FFFF);
Result.UpdateInt(9, AttTypMod and $FFFF);
Result.UpdateInt(10, 10);
}
AttTypMod := GetIntByName('atttypmod') - 4;
Result.UpdateInt(7, (AttTypMod div 65536)); //precision
Result.UpdateInt(9, (AttTypMod mod 65536)); //scale
Result.UpdateInt(10, 10); //base?
Here's my point: those changes solved my problem, and inspecting the whole system, seems to work fine. But, are those changes accurate?
In past I get metadata from PostgreSQL using direct queries, which precess was not so easy to do. My reference was always this wiki http://pt.wikibooks.org/wiki/PostgreSQL ... /Metadados (don't know about english version).
However, inspecting metadata result, I've noticed missing and incorrect information about numeric type. Numeric type in Pg is defined by precision and scale ( see http://www.postgresql.org/docs/8.3/inte ... IC-DECIMAL).
Since data returning by metadata seems to be wrong, I turn back to those old SQL scripts and changed Zeos code a little, for testing, so:
unit ZDbcPostgreSqlMetadata.pas
else if (PgType = 'numeric') or (PgType = 'decimal') then
begin
{
//Old code here
AttTypMod := GetInt(8) - 4;
Result.UpdateInt(7, (AttTypMod shr 16) and $FFFF);
Result.UpdateInt(9, AttTypMod and $FFFF);
Result.UpdateInt(10, 10);
}
AttTypMod := GetIntByName('atttypmod') - 4;
Result.UpdateInt(7, (AttTypMod div 65536)); //precision
Result.UpdateInt(9, (AttTypMod mod 65536)); //scale
Result.UpdateInt(10, 10); //base?
Here's my point: those changes solved my problem, and inspecting the whole system, seems to work fine. But, are those changes accurate?