Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UkR37-0000Td-Ic for pgsql-odbc@arkaria.postgresql.org; Thu, 06 Jun 2013 03:39:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UkR36-0003vS-RG for pgsql-odbc@arkaria.postgresql.org; Thu, 06 Jun 2013 03:39:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UkR36-0003vM-1D for pgsql-odbc@postgresql.org; Thu, 06 Jun 2013 03:39:40 +0000 Received: from sd.tpf.co.jp ([210.161.239.34]) by magus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UkR30-0001Aw-Nr for pgsql-odbc@postgresql.org; Thu, 06 Jun 2013 03:39:39 +0000 Received: (qmail 1765 invoked by uid 512); 6 Jun 2013 03:39:29 -0000 Received: from unknown (HELO ?100.0.33.224?) (100.0.33.224) by sd2.tpf-fw-c.co.jp with SMTP; 6 Jun 2013 03:39:29 -0000 Message-ID: <51B0046F.8080908@tpf.co.jp> Date: Thu, 06 Jun 2013 12:39:27 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Joshua Berry CC: pgsql-odbc@postgresql.org Subject: Re: Segmentation Fault in Postgres server when using psqlODBC References: <519FDAB3.3010009@tpf.co.jp> <51A51147.2060103@tpf.co.jp> <51A75999.6030701@tpf.co.jp> <51AD6351.4030208@tpf.co.jp> In-Reply-To: Content-Type: multipart/mixed; boundary="------------000206060500000003020404" X-Pg-Spam-Score: -2.4 (--) 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 This is a multi-part message in MIME format. --------------000206060500000003020404 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit (2013/06/05 0:48), Joshua Berry wrote: > Hi Hiroshi, > > On Tue, Jun 4, 2013 at 9:46 AM, Joshua Berry > wrote: > > > On Mon, Jun 3, 2013 at 10:47 PM, Inoue, Hiroshi > wrote: > > It's also preferrable to fix the crash at backend. > The crash is caused by execute commands after commit. > > That would be the best solution. Thanks for your help. > > > Is there any test code that I could leverage to put together a test case > which can quickly invoke the backend problem that I'm seeing? Perhaps > something that is used in the pgsqlODBC project or something else you or > others might have sitting around? I would like to have a > testapp/function that could help verify that the issue has been fixed in > a future backend patch/release. It seems difficult to provide a test code. However I can reproduce the crash by changing 1 line of psqlodbc driver source code with a test case. For example, the crash is fixed by the attached patch. > I've never explicitly used EXECUTE. Could I construct a plpgsql script > which could use EXECUTE in a similar manner as psqlODBC, thus creating a > test case that would have greater portability? Oops it's an Execute message used in extended query protocol not a *EXECUTE* command. regards, Hiroshi Inoue --------------000206060500000003020404 Content-Type: text/x-patch; name="printtup_holdable_cursor.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="printtup_holdable_cursor.patch" diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index e87e675..258a4c2 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -238,6 +238,7 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) { int16 *formats = myState->portal->formats; int i; + bool resownerIsNull = false; /* get rid of any old data */ if (myState->myinfo) @@ -252,6 +253,15 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) myState->myinfo = (PrinttupAttrInfo *) palloc0(numAttrs * sizeof(PrinttupAttrInfo)); + if (NULL == CurrentResourceOwner) + { + /* + * This occurs when processing execute messages + * for holdable cursors after commit. + */ + resownerIsNull = true; + CurrentResourceOwner = CurTransactionResourceOwner; + } for (i = 0; i < numAttrs; i++) { PrinttupAttrInfo *thisState = myState->myinfo + i; @@ -273,10 +283,16 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) fmgr_info(thisState->typsend, &thisState->finfo); } else + { + if (resownerIsNull) + CurrentResourceOwner = NULL; ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + } } + if (resownerIsNull) + CurrentResourceOwner = NULL; } /* ---------------- --------------000206060500000003020404 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc --------------000206060500000003020404--