Negative numbers on Linux using PostgreSQL

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Negative numbers on Linux using PostgreSQL

Hermann Ottens
Hi group,

we are using using VASmalltalk 9.1 (64 bit) and right now we are trying to make parts of our software run against PostgreSQL (via ODBC).
On Windows everything works fine.
On Linux we encountered some trouble with negative integers.
If a column in a database table contains a -1, we get a 2^32-1 instead.
As far as i was able to discern, this is due do the fact, that OSLong has a size of 4 bytes on Windows and 8 bytes on Linux
(see comment in OSLong class>>defaultFixedSize).
We try to select a single row and column containing a -1, ...
... on Windows the result from the db is a ByteArray with 4 bytes #(255 255 255 255).
... on Linux the result is a ByteArray with 8 bytes #(255 255 255 255 0 0 0 0).

We would like to continue our work, but i'm reluctant to change the size of OSLong.
Perhaps an additional #length method to AbtOdbcLongIntegerField? Or a subclass of AbtOdbcDatabaseManager?
Any ideas where we should fix this?


Cheers,
Hermann

P.S.:
You can check the behaviour with the following script.
(Note that the sql explicitly contains a comparison for -1.)

| conSpec connection sqlTab collTab |
conSpec := AbtDatabaseConnectionSpec
forDbmClass: #AbtOdbcDatabaseManager
databaseName: '<dbname>'.
sqlTab := 'SELECT id_parent FROM <schema>.<table> WHERE id_parent=-1'.
collTab := OrderedCollection new.

["================================"
| querySpecTab rtTab |
connection := conSpec connect.
(querySpecTab := AbtQuerySpec new) statement: sqlTab.
rtTab := connection
resultTableWithHoldFromQuerySpec: querySpecTab
withValues: nil
ifError: connection errorBlock.
rtTab do: [:each | collTab add: each asArray.].
"================================"]
ensure: [connection disconnect].

collTab inspect.


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Negative numbers on Linux using PostgreSQL

Bob Brodd
Hi Hermaan,

I am opening a support case for you on this issue.  I'll send you the new case information soon.

Thanks,
Bob

On Thursday, April 11, 2019 at 6:21:10 AM UTC-4, Hermann Ottens wrote:
Hi group,

we are using using VASmalltalk 9.1 (64 bit) and right now we are trying to make parts of our software run against PostgreSQL (via ODBC).
On Windows everything works fine.
On Linux we encountered some trouble with negative integers.
If a column in a database table contains a -1, we get a 2^32-1 instead.
As far as i was able to discern, this is due do the fact, that OSLong has a size of 4 bytes on Windows and 8 bytes on Linux
(see comment in OSLong class>>defaultFixedSize).
We try to select a single row and column containing a -1, ...
... on Windows the result from the db is a ByteArray with 4 bytes #(255 255 255 255).
... on Linux the result is a ByteArray with 8 bytes #(255 255 255 255 0 0 0 0).

We would like to continue our work, but i'm reluctant to change the size of OSLong.
Perhaps an additional #length method to AbtOdbcLongIntegerField? Or a subclass of AbtOdbcDatabaseManager?
Any ideas where we should fix this?


Cheers,
Hermann

P.S.:
You can check the behaviour with the following script.
(Note that the sql explicitly contains a comparison for -1.)

| conSpec connection sqlTab collTab |
conSpec := AbtDatabaseConnectionSpec
forDbmClass: #AbtOdbcDatabaseManager
databaseName: '<dbname>'.
sqlTab := 'SELECT id_parent FROM <schema>.<table> WHERE id_parent=-1'.
collTab := OrderedCollection new.

["================================"
| querySpecTab rtTab |
connection := conSpec connect.
(querySpecTab := AbtQuerySpec new) statement: sqlTab.
rtTab := connection
resultTableWithHoldFromQuerySpec: querySpecTab
withValues: nil
ifError: connection errorBlock.
rtTab do: [:each | collTab add: each asArray.].
"================================"]
ensure: [connection disconnect].

collTab inspect.


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Negative numbers on Linux using PostgreSQL

Bob Brodd
Hi Hermann,
I have tried all of the email addresses we have on file for you, but they are all bouncing back.  Can you open a new support case with the information in your original post ?
Thanks,
Bob

On Thursday, April 11, 2019 at 3:08:34 PM UTC-4, Bob Brodd wrote:
Hi Hermaan,

I am opening a support case for you on this issue.  I'll send you the new case information soon.

Thanks,
Bob

On Thursday, April 11, 2019 at 6:21:10 AM UTC-4, Hermann Ottens wrote:
Hi group,

we are using using VASmalltalk 9.1 (64 bit) and right now we are trying to make parts of our software run against PostgreSQL (via ODBC).
On Windows everything works fine.
On Linux we encountered some trouble with negative integers.
If a column in a database table contains a -1, we get a 2^32-1 instead.
As far as i was able to discern, this is due do the fact, that OSLong has a size of 4 bytes on Windows and 8 bytes on Linux
(see comment in OSLong class>>defaultFixedSize).
We try to select a single row and column containing a -1, ...
... on Windows the result from the db is a ByteArray with 4 bytes #(255 255 255 255).
... on Linux the result is a ByteArray with 8 bytes #(255 255 255 255 0 0 0 0).

We would like to continue our work, but i'm reluctant to change the size of OSLong.
Perhaps an additional #length method to AbtOdbcLongIntegerField? Or a subclass of AbtOdbcDatabaseManager?
Any ideas where we should fix this?


Cheers,
Hermann

P.S.:
You can check the behaviour with the following script.
(Note that the sql explicitly contains a comparison for -1.)

| conSpec connection sqlTab collTab |
conSpec := AbtDatabaseConnectionSpec
forDbmClass: #AbtOdbcDatabaseManager
databaseName: '<dbname>'.
sqlTab := 'SELECT id_parent FROM <schema>.<table> WHERE id_parent=-1'.
collTab := OrderedCollection new.

["================================"
| querySpecTab rtTab |
connection := conSpec connect.
(querySpecTab := AbtQuerySpec new) statement: sqlTab.
rtTab := connection
resultTableWithHoldFromQuerySpec: querySpecTab
withValues: nil
ifError: connection errorBlock.
rtTab do: [:each | collTab add: each asArray.].
"================================"]
ensure: [connection disconnect].

collTab inspect.


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Negative numbers on Linux using PostgreSQL

Hermann Ottens
Hello Bob,

thank you for your fix. It works as expected.

Yours,
Hermann

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.