Обсуждение: createdb comments

Поиск
Список
Период
Сортировка

createdb comments

От
"Nigel J. Andrews"
Дата:
Head of development branch (7.3devel) has a problem applying a comment to a
database at the sametime as the database is created  using the createdb
utility.

The error message states the problem:

    pgsql-current-test$ createdb testdb Test
    CREATE DATABASE
    ERROR:  Database comments may only be applied to the current database
    createdb: comment creation failed (database was created)

The database is created but the comment does indeed fail for the reason given,
as illustrated by:

    template1=# \c template1
    You are now connected to database template1.
    template1=# comment on database testdb is 'Test';
    ERROR:  Database comments may only be applied to the current database
    template1=# \c testdb
    You are now connected to database testdb.
    testdb=# comment on database testdb is 'Test';
    COMMENT

Sorry if this isn't news.


--
Nigel J. Andrews
Director

---
Logictree Systems Limited
Computer Consultants

Re: createdb comments

От
Bruce Momjian
Дата:
The following patch fixes the problem.  Applied.

---------------------------------------------------------------------------

Nigel J. Andrews wrote:
>
>
> Head of development branch (7.3devel) has a problem applying a comment to a
> database at the sametime as the database is created  using the createdb
> utility.
>
> The error message states the problem:
>
>     pgsql-current-test$ createdb testdb Test
>     CREATE DATABASE
>     ERROR:  Database comments may only be applied to the current database
>     createdb: comment creation failed (database was created)
>
> The database is created but the comment does indeed fail for the reason given,
> as illustrated by:
>
>     template1=# \c template1
>     You are now connected to database template1.
>     template1=# comment on database testdb is 'Test';
>     ERROR:  Database comments may only be applied to the current database
>     template1=# \c testdb
>     You are now connected to database testdb.
>     testdb=# comment on database testdb is 'Test';
>     COMMENT
>
> Sorry if this isn't news.
>
>
> --
> Nigel J. Andrews
> Director
>
> ---
> Logictree Systems Limited
> Computer Consultants
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: src/bin/scripts/createdb
===================================================================
RCS file: /cvsroot/pgsql/src/bin/scripts/createdb,v
retrieving revision 1.21
diff -c -r1.21 createdb
*** src/bin/scripts/createdb    12 Apr 2002 09:37:10 -0000    1.21
--- src/bin/scripts/createdb    11 Jun 2002 22:09:27 -0000
***************
*** 198,204 ****

  dbcomment=`echo "$dbcomment" | sed "s/'/\\\\\'/g"`

! ${PATHNAME}psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
  if [ "$?" -ne 0 ]; then
      echo "$CMDNAME: comment creation failed (database was created)" 1>&2
      exit 1
--- 198,204 ----

  dbcomment=`echo "$dbcomment" | sed "s/'/\\\\\'/g"`

! ${PATHNAME}psql $PSQLOPT -d "$dbname" -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
  if [ "$?" -ne 0 ]; then
      echo "$CMDNAME: comment creation failed (database was created)" 1>&2
      exit 1