Page 1 of 1
Indexnames
Posted: 12.08.2011, 07:43
by aebi
Hello,
when reading indexnames from "pg_indexes", they are cut to 32 characters. Regarding the PostgreSQL-documenation, the type of this column is "name" which is 64 Byte.
What I found : the function "TZPostgreSQLResultSet.DefinePostgreSQLToSQLType" gives a precision of 32, which is used to truncate the resulting string (I use still Zeos 6.5.1, but also in 7.0.0 the value is 32).
Why this difference ?
Regards
Andreas
Posted: 12.08.2011, 14:05
by seawolf
Postgresql 7.x defined this field with a precision of 32
Postgresql 8.x defined this field with a precision of 64
So it is necessary do a change, because Zeos lib support both versions
Posted: 12.08.2011, 14:46
by aebi
Thanks for the information; seems to be changed from 32 to 64 Byte with PostgrSQL-version 7.3 (documentation for 7.2 says 32 Byte, documentation for 7.3 has 64 Byte).
Regards
Andreas
Posted: 12.08.2011, 14:52
by seawolf
Thank, you're right.
So, I changed the function
procedure TZPostgreSQLResultSet.DefinePostgreSQLToSQLType(ColumnIndex: Integer;
ColumnInfo: TZColumnInfo; TypeOid: Oid);
var
SQLType: TZSQLType;
Connection: IZPostgreSQLConnection;
begin
Connection := Statement.GetConnection as IZPostgreSQLConnection;
case TypeOid of
790: ColumnInfo.Currency := True; { money }
19: if ((Connection.GetServerMajorVersion = 7) and (Connection.GetServerMinorVersion < 3)) then ColumnInfo.Precision := 32
else ColumnInfo.Precision := 64; { name }
1186: ColumnInfo.Precision := 32; { interval }
24: ColumnInfo.Precision := 10; { regproc }
17:{ bytea }
if Connection.IsOidAsBlob then
ColumnInfo.Precision := 256;
end;
SQLType := PostgreSQLToSQLType(Connection, TypeOid);
if Connection.GetCharactersetCode = csUTF8 then
case SQLType of
stString: SQLType := stUnicodeString;
stAsciiStream: SQLType := stUnicodeStream;
end;
if SQLType <> stUnknown then
ColumnInfo.ColumnType := SQLType
else
begin
ColumnInfo.ColumnType := stString;
ColumnInfo.Precision := 255;
ColumnInfo.ReadOnly := True;
end;
end;
All the test works fine, so in a short time this change will be added to the
SVN trunk
Thank you
Posted: 16.08.2011, 08:54
by aebi
Maybe, someone uses even older versions of Postgresql, then the "if" should be like
if (Connection.GetServerMajorVersion < 7) or((Connection.GetServerMajorVersion = 7) and (Connection.GetServerMinorVersion < 3))
But it works fine for my needs,
Thank You, best regards
Andreas
Posted: 30.08.2011, 15:55
by mdaems
aebi,
Did this little fix. SVN Testing branch revision 926.
The previous patch did get into trunk already (Attention: New subversion SVN repository). This one will follow on next merge.
Mark