Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UP9tL-0002O9-HB for pgsql-odbc@arkaria.postgresql.org; Mon, 08 Apr 2013 11:05:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UP9tL-00036p-0s for pgsql-odbc@arkaria.postgresql.org; Mon, 08 Apr 2013 11:05:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UP9tK-00036j-5b for pgsql-odbc@postgresql.org; Mon, 08 Apr 2013 11:05:38 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UP9tC-00052T-4S for pgsql-odbc@postgresql.org; Mon, 08 Apr 2013 11:05:37 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1UP9t9-0006tJ-4a for pgsql-odbc@postgresql.org; Mon, 08 Apr 2013 04:05:27 -0700 Date: Mon, 8 Apr 2013 04:05:27 -0700 (PDT) From: blegay To: pgsql-odbc@postgresql.org Message-ID: <1365419127118-5751192.post@n5.nabble.com> In-Reply-To: <1365232946306-5751040.post@n5.nabble.com> References: <1365106058286-5750832.post@n5.nabble.com> <1365133737522-5750890.post@n5.nabble.com> <1365232946306-5751040.post@n5.nabble.com> Subject: Re: psqlodbc 09.01.0200 - OS X 10.6 - memory leak ? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org Hi, I have been able to reproduce and isolate the problem in a C code... It is related to the SQLNumResultCols ODBC function after a call to SQLMoreResults which does not return any lines (it is an INSERT statement). Can anybody help ? // // main.c // odbctest // // Created by Bruno LEGAY on 05/04/13. // Copyright 2013 A&C Consulting. All rights reserved. // #include #include #include #include #include /* * see Retrieving ODBC Diagnostics * for a definition of extract_error(). */ static void extract_error( char *fn, SQLHANDLE handle, SQLSMALLINT type); int main (int argc, const char * argv[]) { SQLHENV env; SQLHDBC dbc; SQLHSTMT stmt; SQLRETURN ret; SQLCHAR outstr[1024]; =20=20=20=20 SQLSMALLINT infos; SQLSMALLINT resultlen; =20=20=20=20 =20=20=20=20 double iters; SQLUSMALLINT getFuncRes; SQLSMALLINT nbcols; SQLLEN rowcount; =20=20=20=20 /* Allocate an environment handle */ SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); =20=20=20=20 /* We want ODBC 3 support */ SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); =20=20=20=20 /* Allocate a connection handle */ SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc); =20=20=20=20 /* Connect to the DSN oncdPostgreSQL_Unicode */ /*ret =3D SQLDriverConnect(dbc, NULL, "DSN=3DoncdPostgreSQL_Unicode;UID=3Dpostgres;PWD=3Dpostgres;", SQL_NTS, outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);*/ =20=20=20=20 =20=20=20=20 SQLCHAR* dsn =3D (SQLCHAR*)"oncdPostgreSQL_Unicode"; SQLCHAR* uid =3D (SQLCHAR*)"postgres"; SQLCHAR* auth =3D (SQLCHAR*)"postgres"; ret =3D SQLConnect(dbc, dsn, SQL_NTS, uid, SQL_NTS, auth, SQL_NTS); =20=20=20=20 /* SQLWCHAR* dsn =3D "oncdPostgreSQL_Unicode"; SQLWCHAR* uid =3D "postgres"; SQLWCHAR* auth =3D "postgres"; ret =3D SQLConnectW(dbc, dsn, SQL_NTS, uid, SQL_NTS, auth, SQL_NTS); */ =20=20=20=20 //strcpy((char*)dsn,"oncdPostgreSQL_Unicode"); //strcpy((char*)uid,"postgres"); //strcpy((char*)auth,"postgres"); =20=20=20=20 //dsn =3D "oncdPostgreSQL_Unicode"; //uid =3D "postgres"; //auth =3D "postgres"; =20=20=20=20 //ret =3D SQLConnectW(dbc, (SQLWCHAR*)dsn, SQL_NTS, (SQLWCHAR*)uid, SQL_NTS, (SQLWCHAR*)auth, SQL_NTS); //ret =3D SQLConnectW(dbc, (SQLCHAR*)"oncdPostgreSQL_Unicode", SQL_NTS, (SQLCHAR*)"postgres", SQL_NTS, (SQLCHAR*)"postgres", SQL_NTS); =20=20=20=20 =20=20=20=20 if (SQL_SUCCEEDED(ret)) { printf("Connected\n"); =20=20=20=20=20=20=20=20 ret =3D SQLGetInfo(dbc,SQL_ASYNC_MODE,&infos, sizeof(infos), &resultlen); =20=20=20=20=20=20=20=20=20=20=20=20 ret =3D SQLSetConnectAttr(dbc,SQL_ATTR_AUTOCOMMIT,(void*)SQL_AUTOCOMMIT_ON,SQL_IS_I= NTEGER); =20=20=20=20=20=20=20=20 printf("Returned connection string was:\n\t%s\n", outstr); =20=20=20=20=20=20=20=20 if (ret =3D=3D SQL_SUCCESS_WITH_INFO) { printf("Driver reported the following diagnostics\n"); extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC); } =20=20=20=20=20=20=20=20 //SQLCHAR* sqlStatement; //strcpy (sqlStatement,"INSERT INTO bug_127330 (urn,app,ts) VALUES (?,'C',clock_timestamp())"); SQLCHAR* sqlStatement =3D (SQLCHAR*)"INSERT INTO bug_127330 (urn,app,ts) VALUES (?,'C',clock_timestamp())"; =20=20=20=20=20=20=20=20 printf("Statement : %s\n",sqlStatement); while (1) {=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20 iters++; //printf("iters : %d\n",iters); /* Allocate a statement handle */ ret =3D SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt); =20=20=20=20=20=20=20=20=20=20=20=20 //printf("AllocHandle : %i \n",ret); if (ret =3D=3D SQL_SUCCESS || ret =3D=3D SQL_SUCCESS_WITH_INFO)= { // infinite loop...=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 SQLGetFunctions(dbc,SQL_API_SQLPUTDATA,&getFuncRes); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 // SQL FIXER PARAMETRE($vl_iters;SQL Param=C3=A8tre ent= r=C3=A9e) //ret =3D SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, // SQL_C_SLONG, SQL_INTEGER, 0, 0, // &iters, sizeof(iters), NULL);= =20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 // SQL EXECUTER($vt_sql) ret =3D SQLPrepare(stmt, sqlStatement, SQL_NTS); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ret =3D SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_DOUBLE, 7, 0, &iters, sizeof(iters), NULL);=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ret =3D SQLExecute(stmt); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ret =3D SQLNumResultCols(stmt,&nbcols); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ret =3D SQLMoreResults(stmt); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // This call will generate leaks !!! ret =3D SQLNumResultCols(stmt,&nbcols); //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ret =3D SQLRowCount(stmt,&rowcount); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 if (fmod(iters,1000) =3D=3D 0) printf("Insert data OK : %g\n",iters); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 // SQL ANNULER CHARGEMENT //ret =3D SQLFreeStmt(stmt, SQL_RESET_PARAMS); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 SQLFreeHandle(SQL_HANDLE_STMT, stmt); } else {=20=20=20=20=20=20=20=20=20=20=20=20 printf("Error Allocating Handle: %d\n", ret); } =20=20=20=20=20=20=20=20=20=20=20=20 }=20=20=20=20 SQLDisconnect(dbc); /* disconnect from driver */ =20=20=20=20=20=20=20=20 printf("Disconnected\n"); =20=20=20=20=20=20=20=20 } else { fprintf(stderr, "Failed to connect\n"); extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC); } /* free up allocated handles */ SQLFreeHandle(SQL_HANDLE_DBC, dbc); SQLFreeHandle(SQL_HANDLE_ENV, env); =20=20=20=20 return 0; } static void extract_error( char *fn, SQLHANDLE handle, SQLSMALLINT type) { SQLINTEGER i =3D 0; SQLINTEGER native; SQLCHAR state[ 7 ]; SQLCHAR text[256]; SQLSMALLINT len; SQLRETURN ret; =20=20=20=20 fprintf(stderr, "\n" "The driver reported the following diagnostics whilst running " "%s\n\n", fn); =20=20=20=20 do { ret =3D SQLGetDiagRec(type, handle, ++i, state, &native, text, sizeof(text), &len ); if (SQL_SUCCEEDED(ret)) printf("%s:%i:%i:%s\n", state, i, native, text); } while( ret =3D=3D SQL_SUCCESS ); } =20 =20 =20 -- View this message in context: http://postgresql.1045698.n5.nabble.com/psqlo= dbc-09-01-0200-OS-X-10-6-memory-leak-tp5750832p5751192.html Sent from the PostgreSQL - odbc mailing list archive at Nabble.com. --=20 Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc