Indexnames

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

Post Reply
User avatar
aebi
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.05.2006, 10:26

Indexnames

Post 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
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post 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
User avatar
aebi
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.05.2006, 10:26

Post 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
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post 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
User avatar
aebi
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.05.2006, 10:26

Post 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
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Post Reply