![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
-----Original Message----- From: pgsql-odbc-owner (AT) postgresql (DOT) org=20 [mailto gsql-odbc-owner (AT) postgresql (DOT) org] On Behalf Of Marko RistolaSent: 01 August 2005 18:15 To: Joel Fradkin Cc: 'James Dornan'; pgsql-odbc (AT) postgresql (DOT) org Subject: Re: [ODBC] IIS Postgres ASP ADO - Problem =20 =20 I found a crashing problem during CONNECT into a database. =20 Here is the problem description: =20 Used Environment: libpq-API under PostgreSQL 8.0.3 CVS HEAD of psqlodbc =20 libpq does have a problem with freeing memory, that has not=20 been alloced with malloc()! =20 Here is the problem (I don't know, wether the PostgreSQL CVS=20 HEAD has a fix for this): =20 postgresql-8.0.3/src/interfaces/libpq/fe-connect.c, function conninfo_parse(): =20 /* Make a working copy of PQconninfoOptions */ options =3D malloc(sizeof(PQconninfoOptions)); ... memcpy(options, PQconninfoOptions,=20 sizeof(PQconninfoOptions)); =20 Unfortunately PQconninfoOptions[] contains only char*val=20 style pointers instead of char val[32] type character containers. Because of this, the assumption, that memcpy() is enough to copy the structure, is not true anymore. You should NOT copy a static structure this way! =20 Working code would be something like this: =20 options =3D malloc(sizeof(PQconninfoOptions)); memcpy(options, PQconninfoOptions, sizeof(PQconninfoOptions)); for (i=3D0; PQconninfoOptions[i].val !=3D NULL; i++) { options[i].val =3D strdup(PQconninfoOptions[i].val); ... same for all other values } NULL termination. =20 =20 =20 Because of this, isql fails with me at the beginning, maybe because dmalloc library, that I use for testing, discovered the problem. =20 Marko Ristola =20 =20 Joel Fradkin wrote: =20 James, The odbc is not working well for me (I can connect but get=20 intermittent issues of the IIS server locking up in regards to connectivity). My understanding is the snapshot version is the best odbc=20 out at this time. Also can you connect via pgadmin (IE have the hba and config=20 files set to allow external connections)? My conection is not using dsn, but I did get dsn to work in testing. My dsnless string is=20 Session("StringConn") =3D "DRIVER=3D{PostgreSQL};DATABASE=3Dwazagua;SERVER=3 D192.168.123.121; PORT=3D5432;UID=3Dp ostgres;PWD=3D;ReadOnly=3D0;Protocol=3D6.4;FakeOid Index=3D0;ShowOidCo lumn=3D0;RowVersi oning=3D0;ShowSystemTables=3D0;ConnSettings=3D;Fet ch=3D100;Socket=3D409 6;UnknownSizes=3D 0;MaxVarcharSize=3D254;MaxLongVarcharSize=3D8190;D ebug=3D0;CommLog=3D 0;Optimizer=3D1;K sqo=3D1;UseDeclareFetch=3D0;TextAsLongVarchar=3D1; UnknownsAsLongVar char=3D0;BoolsAsC har=3D1;Parse=3D0;CancelAsFreeStmt=3D0;ExtraSysTab lePrefixes=3Ddd_;LF Conversion=3D1;Up datableCursors=3D1;DisallowPremature=3D0;TrueIsMin us1=3D0;BI=3D0;Byte aAsLongVarBinar y=3D0;UseServerSidePrepare=3D0" My test using dsn used Session("StringConn") =3D"DSN=3Dpostgresql;" & _ "UID=3Dpostgres;" & _ "PWD=3D;" & _ "Database=3Dwazuni;" asp code to use connection is : dim Arec, Acmd, SQL ,AConn set Arec =3D server.CreateObject("ADODB.Recordset") Set AConn =3D Server.CreateObject("ADODB.CONNECTION") set Acmd =3D server.CreateObject("ADODB.Command")=20=20 AConn.ConnectionTimeOut=3D30 AConn.commandtimeout=3D30 AConn.Open Session("StringConn") For .net I use the npgsql .net objects. Hope this helps you. Joel Fradkin =20 =20 -----Original Message----- From: James Dornan [mailto:james (AT) catch22 (DOT) com]=20 Sent: Sunday, July 31, 2005 4:44 PM To: jfradkin (AT) wazagua (DOT) com Subject: IIS Postgres ASP ADO - Problem I noticed more than a few post from you about trying to=20 get Postgres=20 working with ODBC. I'm hoping that maybe you would share some of that information. I am=20 running IIS under windos 2003 server, and the latest(8.0.3) Postgres server on=20 the same=20 machine. I cannot connect no matter what I do. I have tried everything. The funny part is that I'm not new to ODBC, or windows.=20 I've worked=20 with windows all the time, but just can't figure this one out. I've tried using a=20 connection string, a DSN, reinstalling, IIS, Postgres, ODBC drivers, MDAC, Jet, and so=20 on. I still=20 have the same problem. The odbc drive and it's dependant DDLs are in the path. The=20 permisions=20 are wide open (for testing this specific problem). Is there any insight you could shed on the dark world of=20 windows and=20 ODBC, where feed- back is rare. Thanks for any help you can provide. -- James ---------------------------(end of=20 broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster =20=20 =20 =20 ---------------------------(end of=20 broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster =20 |
#2
| |||
| |||
|
|
Forwarded to -bugs in case it gets missed. This looks like it might be an issue to me, though I may well have overlooked something in my brief look at the code. Regards, Dave -----Original Message----- From: pgsql-odbc-owner (AT) postgresql (DOT) org [mailto gsql-odbc-owner (AT) postgresql (DOT) org] On Behalf Of Marko RistolaSent: 01 August 2005 18:15 To: Joel Fradkin Cc: 'James Dornan'; pgsql-odbc (AT) postgresql (DOT) org Subject: Re: [ODBC] IIS Postgres ASP ADO - Problem I found a crashing problem during CONNECT into a database. Here is the problem description: Used Environment: libpq-API under PostgreSQL 8.0.3 CVS HEAD of psqlodbc libpq does have a problem with freeing memory, that has not been alloced with malloc()! Here is the problem (I don't know, wether the PostgreSQL CVS HEAD has a fix for this): postgresql-8.0.3/src/interfaces/libpq/fe-connect.c, function conninfo_parse(): /* Make a working copy of PQconninfoOptions */ options = malloc(sizeof(PQconninfoOptions)); ... memcpy(options, PQconninfoOptions, sizeof(PQconninfoOptions)); Unfortunately PQconninfoOptions[] contains only char*val style pointers instead of char val[32] type character containers. Because of this, the assumption, that memcpy() is enough to copy the structure, is not true anymore. You should NOT copy a static structure this way! Working code would be something like this: options = malloc(sizeof(PQconninfoOptions)); memcpy(options, PQconninfoOptions, sizeof(PQconninfoOptions)); for (i=0; PQconninfoOptions[i].val != NULL; i++) { options[i].val = strdup(PQconninfoOptions[i].val); ... same for all other values } NULL termination. Because of this, isql fails with me at the beginning, maybe because dmalloc library, that I use for testing, discovered the problem. Marko Ristola Joel Fradkin wrote: James, The odbc is not working well for me (I can connect but get intermittent issues of the IIS server locking up in regards to connectivity). My understanding is the snapshot version is the best odbc out at this time. Also can you connect via pgadmin (IE have the hba and config files set to allow external connections)? My conection is not using dsn, but I did get dsn to work in testing. My dsnless string is Session("StringConn") = "DRIVER={PostgreSQL};DATABASE=wazagua;SERVER=192.1 68.123.121; PORT=5432;UID=p ostgres;PWD=;ReadOnly=0;Protocol=6.4;FakeOidIndex= 0;ShowOidCo lumn=0;RowVersi oning=0;ShowSystemTables=0;ConnSettings=;Fetch=100 ;Socket=409 6;UnknownSizes= 0;MaxVarcharSize=254;MaxLongVarcharSize=8190;Debug =0;CommLog= 0;Optimizer=1;K sqo=1;UseDeclareFetch=0;TextAsLongVarchar=1;Unknow nsAsLongVar char=0;BoolsAsC har=1;Parse=0;CancelAsFreeStmt=0;ExtraSysTablePref ixes=dd_;LF Conversion=1;Up datableCursors=1;DisallowPremature=0;TrueIsMinus1= 0;BI=0;Byte aAsLongVarBinar y=0;UseServerSidePrepare=0" My test using dsn used Session("StringConn") ="DSN=postgresql;" & _ "UID=postgres;" & _ "PWD=;" & _ "Database=wazuni;" asp code to use connection is : dim Arec, Acmd, SQL ,AConn set Arec = server.CreateObject("ADODB.Recordset") Set AConn = Server.CreateObject("ADODB.CONNECTION") set Acmd = server.CreateObject("ADODB.Command") AConn.ConnectionTimeOut=30 AConn.commandtimeout=30 AConn.Open Session("StringConn") For .net I use the npgsql .net objects. Hope this helps you. Joel Fradkin -----Original Message----- From: James Dornan [mailto:james (AT) catch22 (DOT) com] Sent: Sunday, July 31, 2005 4:44 PM To: jfradkin (AT) wazagua (DOT) com Subject: IIS Postgres ASP ADO - Problem I noticed more than a few post from you about trying to get Postgres working with ODBC. I'm hoping that maybe you would share some of that information. I am running IIS under windos 2003 server, and the latest(8.0.3) Postgres server on the same machine. I cannot connect no matter what I do. I have tried everything. The funny part is that I'm not new to ODBC, or windows. I've worked with windows all the time, but just can't figure this one out. I've tried using a connection string, a DSN, reinstalling, IIS, Postgres, ODBC drivers, MDAC, Jet, and so on. I still have the same problem. The odbc drive and it's dependant DDLs are in the path. The permisions are wide open (for testing this specific problem). Is there any insight you could shed on the dark world of windows and ODBC, where feed- back is rare. Thanks for any help you can provide. -- James ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
![]() |
| Thread Tools | |
| Display Modes | |
| |