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 1tIBSE-00Cjcp-27 for pgsql-novice@arkaria.postgresql.org; Mon, 02 Dec 2024 18:47:30 +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 1tIBSB-002Sxz-8x for pgsql-novice@arkaria.postgresql.org; Mon, 02 Dec 2024 18:47:28 +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.94.2) (envelope-from ) id 1tIBSA-002Sxr-QC for pgsql-novice@lists.postgresql.org; Mon, 02 Dec 2024 18:47:28 +0000 Received: from smtp-outbound6.duck.com ([20.67.221.11]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tIBS8-000hDW-TL for pgsql-novice@lists.postgresql.org; Mon, 02 Dec 2024 18:47:26 +0000 MIME-Version: 1.0 Content-Language: en-US Subject: Command Line option misunderstanding Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Bar: - X-Rspamd-Report: MIME_GOOD(-0.1) R_SPF_ALLOW(-0.2) ARC_ALLOW(-1) X-Rspamd-Score: -1.3 X-Rspamd-Action: no action To: pgsql-novice@lists.postgresql.org Received: by smtp-inbound1.duck.com; Mon, 02 Dec 2024 13:47:22 -0500 Message-ID: <487DB217-EA37-4139-AB97-B61B04ECAEA7.1@smtp-inbound1.duck.com> Date: Mon, 02 Dec 2024 13:47:22 -0500 From: punch-hassle-guise@duck.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=duck.com; h=From: Date: Message-ID: To: Content-Transfer-Encoding: Content-Type: Subject: Content-Language: MIME-Version; q=dns/txt; s=postal-KpyQVw; t=1733165242; bh=XZ1ij6XXw5mVIEydJLOoOiGxhhhSaOEvDXOxYLA58BQ=; b=tDVljnyt6oFH1avEhI2SB7pgabpfnvHQEEKyYZcxcsCG6jwprFIzhduoQ/+XEqXzp+OZnZRBN Q4XhZmHnJ1XgEGpVHy7KKvUiN4Er/03ZQFy+2DBZnQLe62BXXspl4+uMVZakfTV70vNhMdJFu2x 1H19tpwzMR2gD4B+T52whLU= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk It would appear that I have a fundamental misunderstanding of either the english language or the psql man page. A query of all the mailing lists returned no hits that I could find relevant to this problem.  Some references to platform dependent ticks, hence my guessing on some attempts. Perhaps some kind soul could enlighten me. Thanks. psql --version psql (PostgreSQL) 15.10 (Debian 15.10-0+deb12u1) Simple "HERE" document that works psql -h anna -d GT7 << HERE \set v1 12 select :v1; HERE autocommit on  ?column? ----------        12 (1 row) --end result-- Excerpt from man page man psql ---cut---- -v assignment        --set=assignment        --variable=assignment            Perform a variable assignment, like the \set meta-command. Note            that you must separate name and value, if any, by an equal sign on            the command line. To unset a variable, leave off the equal sign. To            set a variable with an empty value, use the equal sign but leave            off the value. These assignments are done during command line            processing, so variables that reflect connection state will get            overwritten later. ---end cut --- On the surface it would appear that -v implies declaration and assignment of a single variable to a value.  -v VARIABLE_NAME=VARIABLE_VALUE which of course doesn't work for me. the -- options are even more problematic for me These read to me as --set=VARIABLE_NAME=VARIABLE_VALUE and --variable=VARIABLE_NAME=VARIABLE_VALUE OR --VARIABLE_NAME=VARIABLE_VALUE and I could find no combination of any type of any of these that would work for me. My attempts at implementing my understanding of man page and attempts at implementing what I perceive to be someones mis-writing of man page ----attempt 1-- psql -h anna -d GT7 -v v1=12 -c 'select :v1' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ----end attempt--- ---attempt 2 --- psql -h anna -d GT7 -vv1=1 -c 'select ":v1" ' autocommit on ERROR:  column ":v1" does not exist LINE 1: select ":v1" ---end attempt --- --- atttempt 3---- psql -h anna -d GT7 -vv1=1 -c 'select :v1' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt ---attempt 4---- sql -h anna -d GT7 -v "v1=1"  -c "select :v1" autocommit on ERROR:  syntax error at or near ":" LINE 1: select ":v1" --- end attempt--- ---attempt 5 --- psql -h anna -d GT7 -v 'v1=1'  -c 'select ":v1" ' autocommit on ERROR:  column ":v1" does not exist LINE 1: select ":v1" ----end attempt --- attempt 6--- psql -h anna -d GT7 -v :v1=1  -c 'select ":v1" ' psql: error: invalid variable name: ":v1" ---end attempt --- attempt 7 --- psql -h anna -d GT7 -v "v1"=1  -c 'select ":v1" ' autocommit on ERROR:  column ":v1" does not exist LINE 1: select ":v1" --- end attempt ---attempt 8 --- psql -h anna -d GT7 -v 'v1'=1  -c 'select ":v1" ' autocommit on ERROR:  column ":v1" does not exist LINE 1: select ":v1" --- end attempt --- ---attempt 9 ---  psql -h anna -d GT7   -c '\set v1 12; select ":v1" ' autocommit on --- end attempt ---- --- attempt 10 --- psql -h anna -d GT7   -c '\set v1=12; select ":v1" ' autocommit on invalid variable name: "v1=12;" ---end attempt ---attempt 11 --- psql -h anna -d GT7   -c '\set v1 = 12; select ":v1" ' autocommit on ---end attempt --- ---attempt 12 --- psql -h anna -d GT7   -c '\set "v1 = 12"; select ":v1" ' autocommit on invalid variable name: ""v1 = 12";" ---end attempt ---- ---attempt 13 ---- psql -h anna -d GT7   -c '\set "v1=12"; select ":v1" ' autocommit on invalid variable name: ""v1=12";" ---end attempt--- ---attempt 14 --- psql -h anna -d GT7   -c '\set "v1=12" select ":v1" ' autocommit on invalid variable name: ""v1=12"" ---end attempt--- ---attempt 15--- psql -h anna -d GT7   -c '\set v1:=12; select ":v1" ' autocommit on invalid variable name: "v1:=12;" ---end attempt--- ---attempt 16 --- kdibble@thinkstation:~/development/gt7-scraper$ psql -h anna -d GT7   -c '\set v1:=12\n select ":v1" ' autocommit on invalid variable name: "v1:=12" ---end attempt--- ---attempt 17--- psql -h anna -d GT7   -c '\set v1 12\n select ":v1" ' autocommit on ---end attempt ---attempt 18--- psql -h anna -d GT7  -v  --set v1=12 -c 'select :v1 ' Password for user v1=12: ---end attempt--- ---attempt 19 --- kdibble@thinkstation:~/development/gt7-scraper$ psql -h anna -d GT7   --set v1=12 -c 'select :v1 ' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt --- attempt 20--- psql -h anna -d GT7   -v --set v1=12 -c 'select :v1 ' Password for user v1=12: --end attempt--- ---attempt 21 ---  psql -h anna -d GT7   -v v1  --set v1=12 -c 'select :v1 ' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt ---attempt 22 --- psql -h anna -d GT7   -v v1  --set =12 -c 'select :v1 ' psql: error: invalid variable name: "" ---end attempt--- ---attempt 23--- psql -h anna -d GT7   -v v1 --set 12 -c 'select :v1 ' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt ---attempt 24 --- psql -h anna -d GT7   -v v1  --set v1=12 -c 'select :v1 ' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt--- ---attempt 25--- psql -h anna -d GT7    -v --set v1=12 -c 'select :v1 ' Password for user v1=12: ---- ---attempt 26 --- psql -h anna -d GT7    --set v1=12 -c 'select :v1 ' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt ---attempt 27---  psql -h anna -d GT7  -v v1="3" -c "select :v1" + psql -h anna -d GT7 -v v1=3 -c 'select :v1' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt ---attempt 28--- psql -h anna -d GT7  -v v1='3' -c "select :v1" autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 --- end attempt --- ---attempt 29--- psql -h anna -d GT7   -c '\set v1 12; select :v1 ' autocommit on ---end attempt --- ---attempt 30 --- psql -h anna -d GT7 -v --set v1:=12 -c 'select :v1 ' Password for user v1:=12: ---end attempt --- ---attempt 31 --- psql -h anna -d GT7  --variable=v1=12 -c 'select :v1 ' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt--- ---attempt 32--- psql -h anna -d GT7  --variable="v1=12" -c 'select :v1 ' autocommit on ERROR:  syntax error at or near ":" LINE 1: select :v1 ---end attempt---