From: Adrian Klaver <adrian.klaver@aklaver.com>
To: nikhil raj <nikhilraj474@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Rob Sargent <robjsargent@gmail.com>
Cc: Dan Livingston <danlivingstone@gmail.com>
Cc: Karsten Hilbert <Karsten.Hilbert@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: database "cdf_100_1313" does not exist
Date: Mon, 9 Sep 2019 07:34:43 -0700
Message-ID: <0c3c64fa-d80b-e4ec-787d-aed2a66f22e2@aklaver.com> (raw)
In-Reply-To: <CAG1ps1wFkVhqxd4u90070KjU8_TGUE-3b9BWZ9oE9z4cShqxJA@mail.gmail.com>
References: <CAG1ps1w3_Ewc7EaPDWWpm1hae1v4DQsgdDyBFPtE=cBQ66k_kA@mail.gmail.com>
<20190909115454.GC2813@hermes.hilbert.loc>
<CAG1ps1x=MQDNQkB7xh6jkO7bgbeUf1JeYTKLJvkKhdEqbh4Ytw@mail.gmail.com>
<CAG9w53r3U8X5R2xLTZ1voQUyNm9SgSJerVkd=QDzYTM0HHa93g@mail.gmail.com>
<CAG1ps1we0a9F9xg-2vkRXZcyA1FVFqNZ5QD=i9XU1==6SD2YsA@mail.gmail.com>
<45AD213B-B975-4A43-9C02-3C1513CF23F5@gmail.com>
<28857.1568038643@sss.pgh.pa.us>
<CAG1ps1wFkVhqxd4u90070KjU8_TGUE-3b9BWZ9oE9z4cShqxJA@mail.gmail.com>
On 9/9/19 7:30 AM, nikhil raj wrote:
> Hi All,
>
> just did few modification of the shell command still having the same
> issue. Having the issue with the Grant command only its not taking the
> parameters.
>
> /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d $DBLIST -c
> "GRANT CONNECT ON DATABASE \"$DBLIST\" TO cpupdate"
> ERROR: database " CDF_100_1313" does not exist
You are not showing how you are currently generating DBLIST. From the
looks of it you have a leading space in the database name:
" CDF_100_1313"
> *
> *
> *** For the above one we have its taking space in the Databases name
> starting.*
>
> /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d $DBLIST -c "GRANT
> CONNECT ON DATABASE "$DBLIST" TO cpupdate"
> psql: warning: extra command-line argument "ASD_100_1313 TO cpupdate"
> ignored
> ERROR: syntax error at end of input
> LINE 1: GRANT CONNECT ON DATABASE
> ^
>
>
>
> On Mon, Sep 9, 2019 at 7:47 PM Tom Lane <tgl@sss.pgh.pa.us
> <mailto:tgl@sss.pgh.pa.us>> wrote:
>
> > On Sep 9, 2019, at 7:16 AM, nikhil raj <nikhilraj474@gmail.com
> <mailto:nikhilraj474@gmail.com>> wrote:
> >> /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d $DBLIST
> -c "GRANT CONNECT ON DATABASE $DBLIST TO cpupdate"
> >> ERROR: database "cdf_100_1313" does not exist
>
> This still isn't quoted properly. It's tricky since double-quote is
> special to both the shell and SQL. You need something like
>
> /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d "$DBLIST" -c
> "GRANT CONNECT ON DATABASE \"$DBLIST\" TO cpupdate"
>
> regards, tom lane
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, nikhilraj474@gmail.com, tgl@sss.pgh.pa.us, robjsargent@gmail.com, danlivingstone@gmail.com, Karsten.Hilbert@gmx.net
Subject: Re: database "cdf_100_1313" does not exist
In-Reply-To: <0c3c64fa-d80b-e4ec-787d-aed2a66f22e2@aklaver.com>
References: <CAG1ps1w3_Ewc7EaPDWWpm1hae1v4DQsgdDyBFPtE=cBQ66k_kA@mail.gmail.com> <20190909115454.GC2813@hermes.hilbert.loc> <CAG1ps1x=MQDNQkB7xh6jkO7bgbeUf1JeYTKLJvkKhdEqbh4Ytw@mail.gmail.com> <CAG9w53r3U8X5R2xLTZ1voQUyNm9SgSJerVkd=QDzYTM0HHa93g@mail.gmail.com> <CAG1ps1we0a9F9xg-2vkRXZcyA1FVFqNZ5QD=i9XU1==6SD2YsA@mail.gmail.com> <45AD213B-B975-4A43-9C02-3C1513CF23F5@gmail.com> <28857.1568038643@sss.pgh.pa.us> <CAG1ps1wFkVhqxd4u90070KjU8_TGUE-3b9BWZ9oE9z4cShqxJA@mail.gmail.com> <0c3c64fa-d80b-e4ec-787d-aed2a66f22e2@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox