Createdb problem report - Mailing list pgsql-hackers

From Oliver Elphick
Subject Createdb problem report
Date
Msg-id 199911182119.VAA22284@linda.lfix.co.uk
Whole thread Raw
Responses Re: [HACKERS] Createdb problem report  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
The attached report is still correct as of 6.5.3; but will having a
database name that has to be quoted cause problems anywhere that SQL
queries are constructed to do internal operations?

The SQL command `CREATE DATABASE "www-data"' works correctly.

------- Forwarded Message

Date:    Thu, 18 Nov 1999 20:39:51 +0100
From:    Eric Gentilini <eric.gentilini@eleve.emn.fr>
To:      olly@lfix.co.uk
Subject: [POSTGRESQL] Does createdb belong to postgresql ?

hi !

I fixed a _very_ little bug in createdb and destroydb that prevents the
creation of postgresql users whose name contains special characters, and
especially '-', useful when accessing a database through a CGI script, whose
user is 'www-data' by default.

But I don't know if this prog is debian specific or if it belongs to
postrgesql.

Can you help me ?
thx !


============================================================================                       POSTGRESQL BUG
REPORTTEMPLATE
 
============================================================================


Your name               :       Eric Gentilini
Your email address      :       eric.gentilini@eleve.emn.fr


System Configuration
- --------------------- Architecture (example: Intel Pentium)         : Intel Pentium&PentiumII
 Operating System (example: Linux 2.0.26 ELF)  : Linux 2.2.13 ELF
 PostgreSQL version (example: PostgreSQL-6.5.2): PostgreSQL-6.5.2 
 Compiler used (example:  gcc 2.8.0)           : not compiled by me


Please enter a FULL description of your problem:
- ------------------------------------------------
I don't know if it is really a bug or if it is intentionnal, but
I found out that createdb and destroydb prevented the
creation/destruction of postgresql users whose
name contained special characters, and
especially '-', useful when accessing a database through a CGI script, whose
user is 'www-data' by default.
(In this case, createdb is executed by createuser)
The query aborts with the message "ERROR:  parser: parse error at or near "-""

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 
- ----------------------------------------------------------------------
for instance : createdb www-data


If you know how this problem might be fixed, list the solution below:
- ---------------------------------------------------------------------
The simplest solution I found is to modify the scripts createdb and destroydb.
createdb : replace line 114 with :
psql $PASSWDOPT -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "create
database \"$dbname\" $location $encoding" template1       ^^^      ^^^
destroydb : replace line 78 with :
psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "drop database \"$dbname\"" template
1                                                        ^^^      ^^^

Eric (Yam) Gentilini

Linux à Nantes sur http://www.linux-nantes.fr.eu.org


------- End of Forwarded Message


--      Vote against SPAM: http://www.politik-digital.de/spam/                ========================================
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver              PGP key from public servers; key
ID32B8FAA1                ========================================    "A Song for the sabbath day. It is a good thing
to     give thanks unto the LORD, and to sing praises unto      thy name, O most High."   Psalms 92:1 
 




pgsql-hackers by date:

Previous
From: Brook Milligan
Date:
Subject: Re: [HACKERS] rules use lztext - initdb required
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Createdb problem report