Wrongly trim trailing spaces

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

wobben
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 25.09.2008, 11:16
Contact:

Wrongly trim trailing spaces

Postby wobben » 21.01.2013, 11:34

After inserting varchar values into the database tables, where values contained trailing spaces, the values were always trimmed when returned. Even if the trailing spaces were in the database table. Even when ANSI_PADDING was set for Sql Server.

After much debugging, I found the reason why. It's an absolete codeline which always removes trailing spaces. Removing the codeline fixes the behaviour.

Code: Select all

function TZAdoResultSet.GetString(ColumnIndex: Integer): string;
var
  NL: Integer;
begin
  Result := '';
  LastWasNull := IsNull(ColumnIndex);
  if LastWasNull then Exit;
  Result := FAdoRecordSet.Fields.Item[ColumnIndex - 1].Value;
  NL := Length(Result);
  while (NL > 0) and (Result[NL] = ' ') do Dec(NL);   // <<< PLEASE REMOVE THIS LINE
  SetLength(Result, NL);
end;

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 22.01.2013, 17:50

wobben,

We've stopper maintaining the 6 series.. We've not enougth manpower. Would you like doing this job?

May i ask you for purpose of ANSI_PADDING?

I think you're right with removing this line. On the other hand.. I have the impression somebody added it with a good reason. Is it possibe other providers adding spaces to the string values? I'll run the tests with you patch tonight and see what happens...
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

wobben
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 25.09.2008, 11:16
Contact:

Postby wobben » 12.02.2013, 12:56

ANSI_PADDING regulates the trailing spaces in varchar fields. For this reason the older code may have needed these lines, but nowadays most dbms's support some kind of ANSI_PADDING control. The driver should not perform this without any developer support for turning it off.

I love the Zeos stuff, but use it very little, having the responsibility for maintaining v6 is a little much to ask for.

Maybe sometime in the future if more of my efforts get sponsorship. ;-)

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 12.02.2013, 16:26

wobben,

is theire a way to find out if ANSI_PADDING is set? I've omited these lines on Testing-7.1 and added a test to confirm this behavior. Now you write me some old servers do return fields filled with spaces. It would be nice to know which one or how to check this option... Do you know some more details about it or is theire a link for it?
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

wobben
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 25.09.2008, 11:16
Contact:

Postby wobben » 14.02.2013, 14:42

Perhaps you may start of at this link?

http://msdn.microsoft.com/en-us/library/ms187403.aspx

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 15.02.2013, 10:02

wobben,

i've already found this link. It tells me the porpose and how to switch ANSI_PADDING. But i'm asking how to find out if ANSI_PADDING is ON or OFF.

If we can't determine ANSI_PADDING then i propose to use:
TZConnection.Properties.Values['ANSI_PADDING'] := 'ON' or 'OFF'; to tell Zeos how to work with the related (var)char/(var)binary fields. So we've an option to keep control about the behavior. What do you think?
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

wobben
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 25.09.2008, 11:16
Contact:

Postby wobben » 15.02.2013, 12:11

Since Microsoft decided to turn it on, always, it would not make much sense to stay with the trimming code lines. However, they offer session properties to check if this is turned on of off:

http://msdn.microsoft.com/en-us/library/ms175001.aspx


Return to “6.6 - stable”

Who is online

Users browsing this forum: No registered users and 1 guest