Indexnames

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

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

Indexnames

Postby aebi » 12.08.2011, 07:43

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:

Postby seawolf » 12.08.2011, 14:05

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

Postby aebi » 12.08.2011, 14:46

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:

Postby seawolf » 12.08.2011, 14:52

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

Postby aebi » 16.08.2011, 08:54

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:

Postby mdaems » 30.08.2011, 15:55

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


Return to “PostgreSQL”

Who is online

Users browsing this forum: No registered users and 1 guest