#1 2016-06-08 11:45:30

hnb
Member
Registered: 2015-06-15
Posts: 290

[Zeos] varchar length for PostgreSQL is always multiplied by 4

Hi!

we have small problem for TSQLDBZEOSConnectionProperties:

  Props := TSQLDBZEOSConnectionProperties.Create(Format('postgresql://%s:%s',[eHost.Text,ePort.Text]), eDBName.Text, eUser.Text, ePasswd.Text);

  Prop.GetFieldDefinitions('testtable',Fields,true);
  WriteLn(RawUTF8ArrayToCSV(Fields,#13#10'  ')); 

for table like this (I use db first approach)

CREATE TABLE testtable
(
  id next_num_global_id NOT NULL,
  test character varying(20) NOT NULL

will print:

id [int8 8 0 0] *
  test [varchar 80 0 0] *

best regards,
Maciej Izak

Offline

#2 2016-06-08 12:43:55

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: [Zeos] varchar length for PostgreSQL is always multiplied by 4

So you receive ColumnLength=80 whereas you expect 20?

I do not know where the error comes from (TSQLDBConnectionProperties.SQLGetField sounds correct), but I guess this is not an issue.
With a PostgreSQL database, you may just ignore the text field length, and consider it without any field limit...
See https://www.postgresql.org/docs/9.3/sta … acter.html

Offline

#3 2016-06-08 13:09:20

hnb
Member
Registered: 2015-06-15
Posts: 290

Re: [Zeos] varchar length for PostgreSQL is always multiplied by 4

ab wrote:

So you receive ColumnLength=80 whereas you expect 20?

yes

ab wrote:

I do not know where the error comes from (TSQLDBConnectionProperties.SQLGetField sounds correct), but I guess this is not an issue.
With a PostgreSQL database, you may just ignore the text field length, and consider it without any field limit...
See https://www.postgresql.org/docs/9.3/sta … acter.html

For ODBC (checked in our SynDBExplorer for the same DB) the value of ColumnLength is correct (20). Maybe Zeos bug?

Last edited by hnb (2016-06-08 13:09:38)


best regards,
Maciej Izak

Offline

#4 2016-06-08 13:19:37

hnb
Member
Registered: 2015-06-15
Posts: 290

Re: [Zeos] varchar length for PostgreSQL is always multiplied by 4

My test result for Zeos without mORMot is also depressive:

  WriteLn(ZReadOnlyQuery1.FieldDefs[i].Size); // 80
  WriteLn(ZReadOnlyQuery1.FieldDefs[i].Precision);  // 80

while ODBC + TSQLDBConnectionProperties + PostgreSQL is ok.

maybe for Zeos somehow is returned maximum possible count of bytes for UTF8 string:
https://www.postgresql.org/docs/current … ibyte.html

Last edited by hnb (2016-06-08 13:26:40)


best regards,
Maciej Izak

Offline

#5 2016-06-08 15:37:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: [Zeos] varchar length for PostgreSQL is always multiplied by 4

So perhaps it is time to ask for support on Zeos forum.
They are usually very reactive!

Offline

#6 2016-06-08 17:35:10

miab3
Member
From: Poland
Registered: 2014-10-01
Posts: 188

Re: [Zeos] varchar length for PostgreSQL is always multiplied by 4

Which ZEOS?
At my ZEOS 7.2 and 7.3 (current) seems to be correctly.

Michal

Offline

#7 2016-06-09 13:59:09

hnb
Member
Registered: 2015-06-15
Posts: 290

Re: [Zeos] varchar length for PostgreSQL is always multiplied by 4

@ab, @miab3

thanks for the answers. It was problem on my machine + probably old trunk ZEOS 7.2, anyway now all works as expected.


best regards,
Maciej Izak

Offline

Board footer

Powered by FluxBB