Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pJUYY-0005lx-0M for pgsql-hackers@arkaria.postgresql.org; Sun, 22 Jan 2023 07:14:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pJUYW-0006Z6-Qg for pgsql-hackers@arkaria.postgresql.org; Sun, 22 Jan 2023 07:14:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pJUYW-0006Yx-AA for pgsql-hackers@lists.postgresql.org; Sun, 22 Jan 2023 07:14:20 +0000 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pJUYP-0002AI-Ns for pgsql-hackers@postgresql.org; Sun, 22 Jan 2023 07:14:19 +0000 Received: by mail-qt1-x82a.google.com with SMTP id j9so7472557qtv.4 for ; Sat, 21 Jan 2023 23:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=v8GsZSmFEEuwVaIxwmqKvMrEl3QWBgLdtMvNSSeQdzc=; b=NstgMVTZk0kxLl9QK4B63mp404D6aFJgucPyp6cOaB3H11nD+6jOBcJ7mA30UsX8Xb HJIClLN5ryVBvEv/RQLWG2eM8mqU+pIET3JRHRYKN0VVwwv3U9Fd7+noNdvcYGY3VoyZ HafLGQ49zMEPqeYxOTRQ53OpXWnuPeh7tS4a0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v8GsZSmFEEuwVaIxwmqKvMrEl3QWBgLdtMvNSSeQdzc=; b=S9NgR9oFA/V7ym8pbCfH6xRpStOnhcoAnOehpj4VGPGscYL9jNLfc9Gn8erXNC1X0j 4kc8QN82wZlkGHrSPDQLPAdkufjU53P/eEuJzYjRqpPoPduWt672dyVZTaOSSN4dg8dw Tnm8OzyvmBf9jR65fIH5OVOvsuX0wRWRLKNPE/sLRkCczQbHgZ4dxCMX/7uk+Bn+KEYg giwfmZ0Wovs/G9YrN8wQ0e/HusfvjA+AlXqbeLttQ+EtJYKC6fDtnXFet0G8AWIKNrDI OhAKGVCSI7TS27qa41qnYKyWfROlQmBJpfw5dceWXx2MBwG/XvRarSWT4M8M4kPE+yso wutQ== X-Gm-Message-State: AFqh2kpMnKua6WGzdCS4thAGa5Ozogus6gkyoiKjX1yDT3iKevqg+axX EL69+rvQ1bltsFzX9GgpD1RNNveIPNIu3q8c X-Google-Smtp-Source: AMrXdXtZu5cJba21ftmOfR7EZmw4oKRUWreuDkSeoB/fsqDJY8JXOtcrfcWxHfdZtQYyLOLQlNy+0Q== X-Received: by 2002:ac8:478c:0:b0:3b6:3c0a:82e8 with SMTP id k12-20020ac8478c000000b003b63c0a82e8mr27822822qtq.1.1674371651740; Sat, 21 Jan 2023 23:14:11 -0800 (PST) Received: from rfd.leadboat.com ([2600:1702:a20:5750::2e]) by smtp.gmail.com with ESMTPSA id fb12-20020a05622a480c00b003b63c9c59easm7932707qtb.97.2023.01.21.23.14.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jan 2023 23:14:11 -0800 (PST) Date: Sat, 21 Jan 2023 23:14:08 -0800 From: Noah Misch To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: libpqrcv_connect() leaks PGconn Message-ID: <20230122071408.GB1400215@rfd.leadboat.com> References: <20230121011237.q52apbvlarfv6jm6@awork3.anarazel.de> <20230121025037.mildbmgylv4ybp4a@awork3.anarazel.de> <20230121161642.GD1356297@rfd.leadboat.com> <20230121200453.ba7eftju7hwaf3cd@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230121200453.ba7eftju7hwaf3cd@awork3.anarazel.de> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Jan 21, 2023 at 12:04:53PM -0800, Andres Freund wrote: > On 2023-01-21 08:16:42 -0800, Noah Misch wrote: > > On Fri, Jan 20, 2023 at 06:50:37PM -0800, Andres Freund wrote: > > > I seems we don't have any tests for creating a subscription that fails during > > > connection establishment? That doesn't seem optimal - I guess there may have > > > been concern around portability of the error messages? > > > > Perhaps. We have various (non-subscription) tests using "\set VERBOSITY > > sqlstate" for that problem. If even the sqlstate varies, a DO block is the > > next level of error swallowing. > > That's a good trick I need to remember. And the errcode for an invalid > connection string luckily differs from the one for a not working one. > > > I think found an even easier way - port=-1 is rejected during PQconnectPoll() > and will never even open a socket. That'd make it reasonable for the test to > happen in subscription.sql, instead of a tap test, I think (faster, easier to > maintain). It may be that we'll one day move that error into the > PQconninfoParse() phase, but I don't think we need to worry about it now. > > Any reason not to go for that? No, a port=-1 test in subscription.sql sounds ideal. > If not, I'll add a test for an invalid conninfo and a non-working connection > string to subscription.sql.