SELECT 'very loooooong literal' - result is truncated to 126 characters

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
jaco
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 03.06.2015, 10:15

SELECT 'very loooooong literal' - result is truncated to 126 characters

Post by jaco »

Hi.

Code: Select all

 
  String literal = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
  int literalLen = literal.Length(); // 130
  ZQuery1->SQL->Text = "select '" + literal + "'";
  ZQuery1->Active = true;
  String string = ZQuery1->Fields->FieldByNumber(1)->AsString; // { u"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456" }
  int strLen = string.Length(); // 126
  int size = ZQuery1->Fields->FieldByNumber(1)->Size; // 126
  ZQuery1->Active = false;
Why result string is truncated?
How to solve my problem without changing query sql text?

db: Postgresql 9.3
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: SELECT 'very loooooong literal' - result is truncated to 126 characters

Post by marsupilami »

Hello Jaco,

in my test environment (Delphi XE7, PostgreSQL 9.4, Zeos 7.2) this works as expected. Which Version of Zeos and C++ Builder do you use?

My test:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  Teststring: String;
begin
  Teststring := '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890';
  ZQuery1.SQL.Text := 'select ''' + Teststring + '''';
  ZQuery1.Open;
  ShowMessage(IntToStr(Length(ZQuery1.Fields[0].AsString))); // Shows 130
end;
With best regards,

Jan
jaco
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 03.06.2015, 10:15

Re: SELECT 'very loooooong literal' - result is truncated to 126 characters

Post by jaco »

Hi all.

I use C++Builder XE8 and ZEOS rev. 3628 from branch testing-7.2... with small (very old, I forgot about it) own modification.
This modification is cause of truncation... so sorry for confusing you.

Primary problem is unicode literals handling.
In TZPostgreSQLResultSet.DefinePostgreSQLToSQLType procedure we have:

Code: Select all

  if SQLType <> stUnknown then
    ColumnInfo.ColumnType := SQLType
  else
  begin
    ColumnInfo.ColumnType := stString;
    ColumnInfo.Precision := 255;
    ColumnInfo.ReadOnly := True;
  end;
Literal has unknown SQLType... and then... ColumnInfo.ColumnType := stString;... :?:

Code: Select all

  if SQLType <> stUnknown then
    ColumnInfo.ColumnType := SQLType
  else
  begin
    if (Connection.GetConSettings.CPType = cCP_UTF16) then
      ColumnInfo.ColumnType := stUnicodeString
    else
      ColumnInfo.ColumnType := stString;
    ColumnInfo.Precision := 255;
    ColumnInfo.ReadOnly := True;
  end;
Will this fix resolve my problem with unicode literals?
Thanks for any help.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: SELECT 'very loooooong literal' - result is truncated to 126 characters

Post by marsupilami »

Hello Jaco,

I suggest you try it. If you don't get the expected result, let's solve the problems.
With best regards,

Jan
Post Reply