Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id A8B772E0079 for ; Sun, 20 Apr 2008 00:19:26 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 56225-07 for ; Sun, 20 Apr 2008 00:19:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by developer.postgresql.org (Postfix) with SMTP id 4FFE32E0078 for ; Sun, 20 Apr 2008 00:19:21 -0300 (ADT) Received: (qmail 26406 invoked from network); 20 Apr 2008 12:19:18 +0900 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 20 Apr 2008 12:19:18 +0900 Received: from unknown (HELO ?192.168.11.2?) (219.61.40.6) by sd.tpf.co.jp with SMTP; 20 Apr 2008 12:19:18 +0900 Message-ID: <480AB639.2020502@tpf.co.jp> Date: Sun, 20 Apr 2008 12:19:21 +0900 From: Hiroshi Inoue User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Jeremy Faith CC: pgsql-odbc@postgresql.org Subject: Re: SQLBulkOperations Segfault References: <4808C57D.1080600@cemsys.com> In-Reply-To: <4808C57D.1080600@cemsys.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/36 X-Sequence-Number: 9499 Jeremy Faith wrote: > Hi, > > I have been experimenting with SQLBulkOperations to see if it is faster > at inserting rows than using individual insert statements. > But when I run the attached(bo.c) example program it segfaults(note, > this program works correctly with an Oracle ODBC connection). > > The program requires the following table. > create table customer > ( > cust_num integer not null, > first_name char(20), > last_name char(20) > ); > > Also the odb_db_open function call uses a hard coded DSN=pg_cdc_w, > username=username and password=password. > > I am using the latest versions of pgsql+postgres on Linux i.e. > psqlodbc-08.03.0100 > postgresql-8.3.1 > > I turned on the ODBC debug log and added some log output to the driver > and found that the segfault is occurring in the results.c:SC_pos_add > function. > > In particular the log shows > POS ADD fi=(nil) ti=(nil) > > and the segfault occurs on this line:- > if (*used != SQL_IGNORE && fi[i]->updatable) > So fi is NULL but is being referenced. > > I did a bit more checking and found that parse_statement sets up > stmt->ird->irdopts.fi i.e. > if (SC_update_not_ready(stmt)) > parse_statement(s.stmt, TRUE); /* not preferable */ > so adding > fi=stmt->ird->irdopts.fi; > after parse_statement gets past this segfault. > > But then another segfault occurs in the results.c:positioned_load > function as stmt->load_stmt is NULL > so strlen(stmt->load_stmt) segfaults. > > The code is complicated and I have not been able to determine how to fix > this, it seems likely to me that even the fi fix may be covering up an > earlier problem somewhere else in the code. Before calling SQLExecDirect(), please set the SQL_ATTR_CURSOR_TYPE to SQL_CURSOR_STATIC or SQL_CURSOR_KEYSET_DRIVER and also set the SQL_ATTR_CONCURRENCY to SQL_CONCUR_ROWVER. regards, Hiroshi Inoue