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.94.2) (envelope-from ) id 1tITBb-00EXHw-15 for pgsql-novice@arkaria.postgresql.org; Tue, 03 Dec 2024 13:43:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tITBY-009vaB-FN for pgsql-novice@arkaria.postgresql.org; Tue, 03 Dec 2024 13:43:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIOiA-008cCL-Gt for pgsql-novice@lists.postgresql.org; Tue, 03 Dec 2024 08:56:51 +0000 Received: from sender4-of-o52.zoho.com ([136.143.188.52]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIOi7-000nti-0j for pgsql-novice@lists.postgresql.org; Tue, 03 Dec 2024 08:56:51 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1733216202; cv=none; d=zohomail.com; s=zohoarc; b=dCnzX3UJXoTVaOk9I4BqIKaWtwMbAudc4d/AlydFLVzq3kH2new+OXWVcMibq8Hz4W8WW+Mb1tKz/H9DFMwsCnV4odb6bcVMMPTSdimjG2KAfEtEwTy0+GfK0uMviUjr/ldrBtOiLCB0hwwLu+jNv8rh9hk1GSRymka7rsWK6AI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733216202; h=Content-Type:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=CxWyHKnuwiywhUxI0JR+swKV/mlo+gmtBNoqXNgL0Ac=; b=Soh2ybVErpKU6ihP7EPNAg0x01AYRt2SPEBYY2vU/P2udYDW5yqYlCXEhj3FnCUg08g29Ij7gHmmzGiKtqGvWdXbd/T4ufTeDoApZ7pS8Reemv1fShdEtbBZObvII9yNe6e2U/wQ68qHGRRewj/Vs67KkEGuqbpxzLCsmqbNcIY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass smtp.mailfrom=ken@beckydibble.com; dmarc=pass header.from= Received: by mx.zohomail.com with SMTPS id 173321620060746.453760037010056; Tue, 3 Dec 2024 00:56:40 -0800 (PST) Content-Type: multipart/alternative; boundary="------------hf2uoSm44phlteYKqSfxwT8s" Message-ID: Date: Tue, 3 Dec 2024 03:56:22 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Command Line option misunderstanding To: pgsql-novice@lists.postgresql.org References: <487DB217-EA37-4139-AB97-B61B04ECAEA7.1@smtp-inbound1.duck.com> <493C622D-D3B6-4662-A617-EBCCDE5AA4DF.1@smtp-inbound1.duck.com> <30948e6771500c0e9d8b587f4e34165aadb1cc0b.camel@cybertec.at> <4FB93541-3986-4C8F-9571-1FBD8655A686.1@smtp-inbound1.duck.com> <3C5B4EBF-AA44-4707-8D3E-C33E4F04208E.1@smtp-inbound1.duck.com> Content-Language: en-US From: Ken Dibble In-Reply-To: <3C5B4EBF-AA44-4707-8D3E-C33E4F04208E.1@smtp-inbound1.duck.com> X-ZohoMailClient: External List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------hf2uoSm44phlteYKqSfxwT8s Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/2/24 19:11, David G. Johnston wrote: > On Mon, Dec 2, 2024 at 4:50 PM wrote: The problem seems to be, as > alluded to by others attempting to help me that the problem only > exists when using -c on the same line a > *DuckDuckGo* did not detect any trackers. More > > > > Deactivate > > > > On Mon, Dec 2, 2024 at 4:50 PM wrote: > > The problem seems to be, as alluded to by others attempting to help me > > that the problem only exists when using -c on the same line as -v. > > The word "line" here belies further misunderstanding of how > shell-executed commands work (the following "two line" command is > still just one actual multiple-option command invocation). > psql -v a=1 \ > -c 'select :a' > > It is best to just say "using -c and -v together". > > It is correct that we haven't pointed out, probably because for > experienced people it seems obvious, that using -v and -c (or putting > \set in -c) is a pointless thing to do.  But psql doesn't go about > trying to analyze intent here so, yes, you either get useless > successful output in response or a confused server. > > That said... > psql -v a=1 -c '\echo :a' postgres > 1 > > So it truly is just this specific SQL-related usage that is pointless, > not combining -v and -c generally (I'm sure a useful backslash command > can be substituted for \echo) > > > Related Question: > > Documentation says: > > /|command|/ must be either a command string that is completely > parsable by the server (i.e., it contains no psql-specific > features), or a single backslash command. > > $psql -h anna -d GT7   -c "\set  a '11117' \\ select evt_id from > events where sport_mode_evt_id=:a" > > Really not caring that you are turning on autocommit... > > Anyway, what I believe you managed to accomplish here is to set the > named variable "a" to the value blah-blah-blah equals colon a> > > Then proceeded to do nothing with that variable since the -c command > was done being evaluated in the "single backslash command" mode. > > David J. > Thanks for your time and explanations. Ken --------------hf2uoSm44phlteYKqSfxwT8s Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 12/2/24 19:11, David G. Johnston wrote:
On Mon, Dec 2, 2024 at 4:50 PM <punch-hassle-guise@duck.com> wrote:

The problem seems to be, as alluded to by others attempting to help me

that the problem only exists when using -c on the same line as -v.

The word "line" here belies further misunderstanding of how shell-executed commands work (the following "two line" command is still just one actual multiple-option command invocation).
psql -v a=1 \
-c 'select :a'

It is best to just say "using -c and -v together".

It is correct that we haven't pointed out, probably because for experienced people it seems obvious, that using -v and -c (or putting \set in -c) is a pointless thing to do.  But psql doesn't go about trying to analyze intent here so, yes, you either get useless successful output in response or a confused server.

That said...
psql -v a=1 -c '\echo :a' postgres
1

So it truly is just this specific SQL-related usage that is pointless, not combining -v and -c generally (I'm sure a useful backslash command can be substituted for \echo)


Related Question:

Documentation says:

command must be either a command string that is completely parsable by the server (i.e., it contains no psql-specific features), or a single backslash command.

$psql -h anna -d GT7   -c "\set  a '11117' \\ select evt_id from events where sport_mode_evt_id=:a"

Really not caring that you are turning on autocommit...

Anyway, what I believe you managed to accomplish here is to set the named variable "a" to the value <single-quote 11117 single-quote blah-blah-blah equals colon a>

Then proceeded to do nothing with that variable since the -c command was done being evaluated in the "single backslash command" mode.

David J.

Thanks for your time and explanations.

Ken

--------------hf2uoSm44phlteYKqSfxwT8s--