Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wKeVp-001DRr-2r for pgsql-hackers@arkaria.postgresql.org; Wed, 06 May 2026 15:50:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wKeVn-000AX8-2N for pgsql-hackers@arkaria.postgresql.org; Wed, 06 May 2026 15:50:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wKeVn-000AWj-0b for pgsql-hackers@lists.postgresql.org; Wed, 06 May 2026 15:50:11 +0000 Received: from mail-vs1-xe35.google.com ([2607:f8b0:4864:20::e35]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wKeVj-00000000VhS-3yvq for pgsql-hackers@postgresql.org; Wed, 06 May 2026 15:50:09 +0000 Received: by mail-vs1-xe35.google.com with SMTP id ada2fe7eead31-6121f20650dso2674000137.1 for ; Wed, 06 May 2026 08:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20251104.gappssmtp.com; s=20251104; t=1778082607; x=1778687407; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=MSefqqE2R7NEVUOF+7qzeHTnSSEbGbHjO097Yd81g1A=; b=lmNp4jIzJF2oWSDj9vxDBqPsg/JBgStJm2s1Fe9JlZXQqf9EcE11wWVLmzxkvm9o5Y 0J0Iuoqv7OCkD+Q/zuALsiQnliCHXSNG5ngWgAV4W6aRZg8sr8Douj+U4cP4LOGFjzhX bXj5fIKIBsyKGHFexhd579SwF3cXvbtbxLiqDhLols2BDtrJ7CCLgKgcrcJqqnauzJIs FEe96gJ69JK2ZswmstKGCmiQYSPfxS60ZfPpGZq65v37RgyF+fmm3ZI5JeAe2Cltnl+o vkA+xcMQWLpKJA75YKMvAlS+BIgcbilL2oajPLLhG1zyYO8Ay18ylPPEV9KJ5RZ3qezJ ldJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778082607; x=1778687407; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MSefqqE2R7NEVUOF+7qzeHTnSSEbGbHjO097Yd81g1A=; b=U823OrnKojF+lThPh8InSqieUVdIUaqozx3kwgQTs638BuT7aR4t5FST26D29tk0rd I4GfmJM+1zi3pdwkdsIkOtrFWSbXFlefmogRqY9J2k6vbpp21YYe/fKnDaYGMtC7YS9k C04sfAfGAKS1Jf0ZVlWb2k3+WZJfZimurp3p2OdADG0W7OfbG09XYCrEqTW4w5FqvMm8 VqrSkGKqNiNQLPIPlkHzoXcLTNUE9wGjB//a0r+SnAl9whaNrOWk7r2PN2SxMlOimpbV SFreFLfR9+s8knFMsJ7/2qn3pVbdWL4oUi10SkiHWu6qWjpRBZg9nE47U1GCTK5FG/GL 4n0g== X-Forwarded-Encrypted: i=1; AFNElJ8cOuRutWSkgSR0fSkks1izuqiEBQMyJbN6RJ2UIzqb9lfI+yErjCSdsReW11IOmFfStDcW7MxfogtT1bJj@postgresql.org X-Gm-Message-State: AOJu0YzQOOAi2tPm4IFJ769O6xN30fS5vYp8vBL7LuQgROQYlpwZGZmS JIkKL9DM924UkkfgSy8Lwl6K19AF24kh6qpvUSLdqev0UG44Rviefw87ajkVpkOYm/4= X-Gm-Gg: AeBDiesFOqExx42y2ovuKM2nihZ6Xj6+PRQAmi/3SMh2tXdnHCWqBEiVRAKKs4ur5e9 DgjkIcYa7KSqh4elHOKnEMKlrCWSYLgW1EZJHPAzXNio8w+TGGRdnMCGtCq+T7eSyZJcLp0jld9 YVPmsW4Sv9poTL1HiRj7n0W/EwPtDVVGq73OAcQFlWG/GAkk+1np8I3ybETy28rRh3n7xpTgAyv 4SKn4tNJklIwajZndBw4umr3VJlDoUfOoFNGqohDNDzZR/2Jq8GDsuuYJTQT6mcowogckuQvty+ Bko0v+cbgymxnYrJxQImV9x9sAv2yhFqoY4SGgDDdOSNHXQ8exOc6tRF39Stx1rYonshsWTYzit BdCh9po1U2aFV1pMgylF785FzasszvaaTLWZ/JcNSf2D5MHFxjY8O/yIQwgVNL9GC+SvAUQC32b G2tvElguEpOfvua7MXf/eB9+Bh0bIeyhUAKLab0Y7X X-Received: by 2002:a05:6102:4411:b0:609:2cf6:51d8 with SMTP id ada2fe7eead31-630f8e6781dmr1872016137.3.1778082606899; Wed, 06 May 2026 08:50:06 -0700 (PDT) Received: from ?IPV6:2605:a601:a6b0:500::1cb? ([2605:a601:a6b0:500::1cb]) by smtp.googlemail.com with ESMTPSA id ada2fe7eead31-62bfd8b5aeesm9519820137.7.2026.05.06.08.50.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 May 2026 08:50:06 -0700 (PDT) Message-ID: Date: Wed, 6 May 2026 11:50:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [BUG] CRASH: ECPGprepared_statement() and ECPGdeallocate_all() when connection is NULL To: Tom Lane Cc: Alexander Lakhin , Nishant Sharma , Shruthi Gowda , Mahendra Singh Thalor , Fujii Masao , PostgreSQL Development References: <75460b3c-2! 55d-47eb-b889-d99de38e6758@gmail.com> <699623.1778013161@sss.pgh.pa.us> <53e7527c-eb! 86-4ef5-a3fb-df98cd9c973a@dunslane.net> <771392.1778079507@sss.pgh.pa.us> From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@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cdzlIY/NFN hFGW/9dkEiGjgna2Rk6e15kln4ZvFBWUg23p93w/pqXcxY6+k/8TEk+C4R+M6w7o2PLGOjdZ +kPiUcw5H85zf/yZJwQXzisXaNduwWB6Vads9YC9dj6kPR1c4VGRqAaYL++LAEOqrlvm2Tvq QqZRtnEAEQEAAcLAfAQYAQgAJgIbDBYhBOQ+WEYd/Hy/RGkVpZn6f8tZ/DuBBQJoGNI2BQkd EODdAAoJEJn6f8tZ/DuBfw0IAKTsfD40teP/pp+bsLLMSxPXUYrrprTj7WFB5v61p6dkpSr/ qXmMlyahdxQFaPmfVgVirB1Vk/kHiWNnnGjfUV9nB2Zg9LI0Xb9/ts3LsUiRWXzG3tkMY6XL vsVOxW4XFRND9l2q+WW93aZ1DZl+fqWfYgMvsusFRhmGFOKTRfKPta2Pkv+AhA24N4+PrR5p bU4k2MO8PAGiK8eaYKGFG1bHKuAvoDoF7WXJ3FHxuWqLnKEt4dfOLm5pAe3zq1Lt6q8azT9i QWGpSAK5vQUWQHBHpiDjdPeqKZ6HiAXIIKfSmb+jrvXBqoP+D6/K7rUjG2aXiRtTIAXms9sm VRu7cmw= In-Reply-To: <771392.1778079507@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-05-06 We 10:58 AM, Tom Lane wrote: > Andrew Dunstan writes: >> Attached is a patch with the fix, courtesy of claude. It's a slight >> behaviour change: > Yeah. So we could either do something like this, or say that the > test case is buggy and needs to provide its own mutexes, per the > existing comment > > - * if no connection in TSD for this thread, get the global default > - * connection and hope the user knows what they're doing (i.e. using > - * their own mutex to protect that connection from concurrent accesses > > On the whole I think I favor the behavior change. We might get some > complaints, but it just seems a lot safer to redefine it like this. I agree. > > Either way, it seems like some documentation adjustments are called > for. > > As far as the patch itself goes, I'd be inclined to pull the > preparatory step > > ecpg_pthreads_init(); /* ensure actual_connection_key is valid */ > > into the new ecpg_default_connection() subroutine, especially since > its proposed comment doesn't mention that prerequisite. > > Right. Given the lack of field complaints, maybe we should wait until after next week's releases? cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com