PostGreSQL ODBC 3.0 Error

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

PostGreSQL ODBC 3.0 Error

Jerome Chan
I've just installed the postgresql odbc driver on my xp box and I can't
get DBConnection to work. The following throws an exception

dbC := DBConnection new.
dbC open.

Here is the connectString.

'DSN=PostgreSQL30;DATABASE=money;SERVER=192.168.168.2;PORT=5432;UID=akira
;PWD=moomoo;A6=;A7=100;A8=4096;B0=254;B1=8190;BI=0;C2=dd_;;CX=1a503ab'

It appears to be dying at the place where there is a null parameter,
where there are two semi-colons at the end of the string.

'C2=dd_;;CX=1a503ab'

If I manually edit out the two semi-colons and it works.

It appears that the VM is trying to create a string of size -1.


Reply | Threaded
Open this post in threaded view
|

Re: PostGreSQL ODBC 3.0 Error

Chris Uppal-3
Jerome Chan wrote:
> I've just installed the postgresql odbc driver on my xp box and I
> can't get DBConnection to work. The following throws an exception
>
> dbC := DBConnection new.
> dbC open.

I see the same problem.  Which surprised me since I was playing with a
connection to PostgreSQL just a couple of weeks ago, and that worked OK.
Anyway it turns out that I was driving it slightly differently; the following
works for me, and may be a workaround for you:

--------------------
  conn := (DBConnection new)
      dsn: 'DATASOURCE';
      uid: 'USER';
      pwd: 'PASSWORD';
      connect.
  query := conn query: 'SELECT *  FROM weather'.
--------------------

Alternatively you could change DBConnection class>>connectString:do: to be
defensive about empty strings:
--------------------
    ...
     ((aString subStrings: $;) select: [:s | s notEmpty]) do: [:s |
    ...
--------------------
which seems like a reasonable change to propose for the base image ?

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: PostGreSQL ODBC 3.0 Error

Blair McGlashan
Jerome, Chris

"Chris Uppal" <[hidden email]> wrote in message
news:3edf12ce$0$45171$[hidden email]...

> Jerome Chan wrote:
> > I've just installed the postgresql odbc driver on my xp box and I
> > can't get DBConnection to work. The following throws an exception
> >
> > dbC := DBConnection new.
> > dbC open.
>
> I see the same problem.  Which surprised me since I was playing with a
> connection to PostgreSQL just a couple of weeks ago, and that worked OK.
>...
> Alternatively you could change DBConnection class>>connectString:do: to be
> defensive about empty strings:
> --------------------
>     ...
>      ((aString subStrings: $;) select: [:s | s notEmpty]) do: [:s |
>     ...
> --------------------
> which seems like a reasonable change to propose for the base image ?

Yes, this is actually a bug (#1284) in the connection string handling since
the ODBC spec explicitly allows for empty "attributes". Odd but true.

Anyway the proposed patch is below.

Regards

Blair
-------------------------
!DBConnection class methodsFor!

connectString: aString do: aTwoArgBlock
 "Private - Interpret the connection string and pass the parameter name and
value from each $; separated
 substring to aTwoArgBlock."

 (aString subStrings: $;) do:
   [:each |
   each isEmpty
    ifFalse:
     [| equals paramName paramValue |
     equals := each indexOf: $=.
     paramName := each copyFrom: 1 to: equals - 1.
     paramValue := each copyFrom: equals + 1 to: each size.
     aTwoArgBlock value: paramName value: paramValue]]! !
!DBConnection class categoriesFor: #connectString:do:!operations!private! !