Skip site navigation (1) Skip section navigation (2)

Problem with using SOCK_put_int method PGAPI_PutData

From: Marcin Ligorowski <ligo(at)interia(dot)pl>
To: pgsql-odbc(at)postgresql(dot)org
Subject: Problem with using SOCK_put_int method PGAPI_PutData
Date: 2008-09-17 10:23:47
Message-ID: (view raw or whole thread)
Lists: pgsql-odbc
I%u2019ve detected problem with using psqlodbc driver on Sun Sparc Solaris platform. 
An error occurs when Sparc converts unsigned short to unsigned int and back to unsigned short.
With default implementation 00 00 01 02 is converted to 00 00 (last two bytes are skipped), but it should be converted to 01 and 02.
Problem occurs every time when through method SOCK_put_int two bytes integer was transferred and doesn%u2019t allow using PGAPI_PutData (odbc_lo_write) to put large objects to database.

To resolve described problem I%u2019ve attached patch bellow.


--- 769,793 ----
  SOCK_put_int(SocketClass *self, int value, short len)
      if (!self)
      switch (len)
         case 2:
+          {
+             unsigned short rv;
              rv = self->reverse ? value : htons((unsigned short) value);
              SOCK_put_n_char(self, (char *) &rv, 2);
+          }

         case 4:
+          {
+             unsigned int rv;
              rv = self->reverse ? value : htonl((unsigned int) value);
              SOCK_put_n_char(self, (char *) &rv, 4);
+          }

           SOCK_set_error(self, SOCKET_PUT_INT_WRONG_LENGTH, "Cannot write ints of that length");

Dzwon taniej na zagraniczne komorki!
Sprawdz >> 

pgsql-odbc by date

Next:From: Brent AustinDate: 2008-09-18 18:10:15
Subject: compiling odbc
Previous:From: Hiroshi SaitoDate: 2008-09-16 14:45:36
Subject: Re: Compiler warnings in psqloodbc 08.03.0200

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group