Forum OpenACS Q&A: Pgdriver for windows NT

Collapse
Posted by MK Tam on
Hi,

  Anybody know where to get a Pgdriver for Windows NT?

Thanks.

Collapse
Posted by Zhou Shaofang on
I also need the Pgdriver for Windows NT.

Thanks.

Collapse
Posted by Adam Farkas on
Slightly off-topic, but are there _any_ binaries for postgresql on NT? I have yet to see a really comprehensive description of a low-hassle way to get it working on windows.

The thought of cygwin and compilation sends chills down my spine.

Collapse
Posted by Andrei Popov on
Adam,

If you install latest cygwin, postgres is included: no need to compile it anymore.  However, the problem is that all libraries are compiled as static (.a), not shared.  I've tried a few times to compile pgdriver against them to no avail...

Collapse
Posted by Pascal Scheffers on
I have just uploaded a compiled version of the Postgres driver for aolserver 3.2+ad12. It should also work with other versions. See readme.txt for usage details.

Also note that I am not going to maintain this thing. I compiled it for my own tests and do not wish to persue this any further. Have fun with it, though :) You can find it in file-storage: https://openacs.org/new-file-storage/one-file?file_id=109

Collapse
Posted by Andrei Popov on
Pascal,

That was fast :) ... but for whatever reason does not seem to work in my case :(

I know that you said that you won't maintain it, but what would you say of the following errors:

[07/May/2001:14:02:55][441.114][-conn0-] Notice: dbdrv: opening database 'postgres:localhost:5432:test'
[07/May/2001:14:02:55][441.114][-conn0-] Notice: Opening test on localhost
[07/May/2001:14:02:55][441.114][-conn0-] Error: Ns_PgOpenDb(postgres):  Could not connect to localhost:5432:test:
  connectDBStart() -- socket() failed: errno=0 No error
[07/May/2001:14:02:55][441.114][-conn0-] Error: dbdrv: failed to open database 'postgres:localhost:5432:test'
[07/May/2001:14:02:55][441.114][-conn0-] Error: could not allocate 1 handle from pool "pg_test"
could not allocate 1 handle from pool "pg_test"
    while executing
"ns_db gethandle $pool"
    invoked from within
"set db         [ns_db gethandle $pool]"
    (file "d:/Program Files/AOLserver/servers/server1/pages/test.tcl" line 4)
    invoked from within
"source $file"
    invoked from within
"ns_sourceproc cns0 {}"

The following ${homedir}/config.tcl is used (pgdriver-related section only):

#
# db drivers
#
ns_section "ns/db/drivers"
ns_param mysql	nsmysql.so
ns_param postgres pgdriver.dll

ns_section "ns/db/pool/pg_flex"
ns_param        Driver          postgres
ns_param        Connections     5                       ;# 5 is a good number. Increase according to your needs
ns_param        DataSource      localhost:5432:flex     ;# Replace 'yourdb' with the name of your database in PG
ns_param        User            nsadmin                 ;# User and password AOLserver will use to connect
ns_param        Password        ""
ns_param        Verbose         On                     ;# Set it to On to see all queries. Good for debugging SQL.
ns_param        LogSQLErrors    On
ns_param        ExtendedTableInfo       On
# ns_param      MaxOpen         1000000000             ;# Max time to keep idle db connection open
# ns_param      MaxIdle         1000000000             ;# Max time to keep active db connection open

This is all on WinNT4 with AOLServer 3.2 (AOLserver/3.2 (aolserver3_2) for win32 built on Oct 25 2000 at 17:19:06)


Thanks,
Collapse
Posted by Pascal Scheffers on
I knew I had forgotten to mention something. The resolver in the driver doesn't work on Win32. You need to specify 127.0.0.1 instead of localhost. After that, it worked fine for me.
Collapse
Posted by Andrei Popov on
Ok, it is better now (somewhat), but still not quite working:
[08/May/2001:09:15:04][502.471][-conn0-] Notice: dbdrv: opening database 'postgres:127.0.0.1::flex'
[08/May/2001:09:15:04][502.471][-conn0-] Notice: Opening flex on 127.0.0.1, port
[08/May/2001:09:15:05][502.471][-conn0-] Notice: Ns_PgOpenDb(postgres):  Openned connection to 127.0
.0.1::flex.
[08/May/2001:09:15:05][502.471][-conn0-] Notice: Querying 'select count(*) from coa;'
[08/May/2001:09:15:05][502.471][-conn0-] Notice: dbinit: sql(127.0.0.1::flex): 'select count(*) from
 coa'
[08/May/2001:09:15:05][502.471][-conn0-] Notice: Querying 't2;'
[08/May/2001:09:15:05][502.471][-conn0-] Error: Ns_PgExec: result status: 7 message: ERROR:  parser:
 parse error at or near "t2"

[08/May/2001:09:15:05][502.471][-conn0-] Error: dbinit: error(127.0.0.1::flex,ERROR:  parser: parse
error at or near "t2"
): 't2'
[08/May/2001:09:15:05][502.471][-conn0-] Error: Database operation "0or1row" failed (exception NSDB,
 "Query was not a statement returning rows.")
Why 't2'??
Collapse
Posted by Pascal Scheffers on
[08/May/2001:09:15:05][502.471][-conn0-] Notice: Querying 't2;'
(...)
Why 't2'??
't2' is, most likely, the identifier of an ns_set. That will probably contain the count(*) from the previous query. Show your code, because DB log alone is not enough...

Collapse
Posted by Andrei Popov on
Code is very simple, this is just a test:
set pool		"pg_flex"
set db		[ns_db gethandle $pool]
set query		[ns_db select $db "select count(*) from coa"]
ns_db		0or1row $db $query
set cnt		[ns_set get $query cnt]
ns_write		"Retrieving $cnt records"
Collapse
Posted by Andrei Popov on
What is interesting is that this way:
set pool "pg_flex"
set db [ns_db gethandle $pool]
set cnt [ns_set get [ns_db 0or1row $db "select count(*) from coa"] count]
ns_write "Retrieving $cnt records"
it works fine... Why does it not work with ns_db select?..
Collapse
Posted by Pascal Scheffers on
ns_db 0or1row is just a special form of ns_db select, the first returns a set of columns or null, the latter a ns_set of columns through which you can iterate with ns_db getrow.

The first code sample doesn't work because the 'set query' already returns the 'count(*)', not a query that needs to be executed. You could do ns_set get $query "count" (I think it's count, you should really 'select count(*) as cnt from coa')

Collapse
Posted by Andrei Popov on
ns_db 0or1row is just a special form of ns_db select, the first returns a set of columns or null, the latter a ns_set of columns through which you can iterate with ns_db getrow.
strangely, the same setup works with mysql... thanks a lot, however, most helpful.
Collapse
Posted by Andrei Popov on
and another (hopefully last one :)): what does
[08/May/2001:12:16:20][502.601][-conn7-] Error: Ns_PgGetRow(127.0.0.1::flex): Get row called outside a fetch row loop.
mean?
Collapse
Posted by Andrei Popov on
Ok, sorry: that was an exercise in RTFM... I know understand why there are 3 separate db pools (main, subquery and log) defined in ACS: onces I've done ns_db gethandle on a database all my requests will go through it. If I then try to use the same connection for a different query, I get error. My question is, though: why can I not get a new handle on the same db? Related: if I do ns_db gethandle $pool_name 2, will I be able to do independent getrows?