I see a todo item
* Views with spaces in view name fail when referenced

I have another one for you:
* Databases with spaces in name fail to be created and destroyed despite
responses to the contrary.

A sample session:
template1=> create database "with space";
CREATEDB
template1=> \q
$ psql -d "with space"
Connection to database 'with space' failed.
FATAL 1:  InitPostgres could not validate that the database version is
compatible with this level of Postgres
        even though the database system as a whole appears to be at a
compatible level.
        You may need to recreate the database with SQL commands DROP
DATABASE and CREATE DATABASE.
        File '/usr/local/pgsql/data/base/with space/PG_VERSION' does not
exist or no read permission.

(You can't do \c with space or \c "with space" yet. That will be (is) in
the new version.)

Further investigation shows that the directory
/usr/local/pgsql/data/base/with space is totally empty.

But:
template1=> select * from pg_database;
datname   |datdba|encoding|datpath
----------+------+--------+----------
template1 |   100|       0|template1
 . . .
with space|   101|       0|with space
(4 rows)

template1=> drop database "with space";
DESTROYDB

Yet, the mysterious empty directory is still there.

BUG?

-- 
Peter Eisentraut - peter_e@gmx.net
http://yi.org/peter-e


Mon, 4 Oct 1999 16:03:34 +0200 (CEST)
Peter Eisentraut <peter_e@gmx.net>
Database names with spaces

Looks like bug to me.


> I see a todo item
> * Views with spaces in view name fail when referenced
> 
> I have another one for you:
> * Databases with spaces in name fail to be created and destroyed despite
> responses to the contrary.
> 
> A sample session:
> template1=> create database "with space";
> CREATEDB
> template1=> \q
> $ psql -d "with space"
> Connection to database 'with space' failed.
> FATAL 1:  InitPostgres could not validate that the database version is
> compatible with this level of Postgres
>         even though the database system as a whole appears to be at a
> compatible level.
>         You may need to recreate the database with SQL commands DROP
> DATABASE and CREATE DATABASE.
>         File '/usr/local/pgsql/data/base/with space/PG_VERSION' does not
> exist or no read permission.
> 
> (You can't do \c with space or \c "with space" yet. That will be (is) in
> the new version.)
> 
> Further investigation shows that the directory
> /usr/local/pgsql/data/base/with space is totally empty.
> 
> But:
> template1=> select * from pg_database;
> datname   |datdba|encoding|datpath
> ----------+------+--------+----------
> template1 |   100|       0|template1
>  . . .
> with space|   101|       0|with space
> (4 rows)
> 
> template1=> drop database "with space";
> DESTROYDB
> 
> Yet, the mysterious empty directory is still there.
> 
> BUG?
> 
> -- 
> Peter Eisentraut - peter_e@gmx.net
> http://yi.org/peter-e
> 
> 
> ************
> 


-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@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

Tue, 5 Oct 1999 17:11:34 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] Database names with spaces

Looks like a bug.  Added to TODO list.



> I see a todo item
> * Views with spaces in view name fail when referenced
> 
> I have another one for you:
> * Databases with spaces in name fail to be created and destroyed despite
> responses to the contrary.
> 
> A sample session:
> template1=> create database "with space";
> CREATEDB
> template1=> \q
> $ psql -d "with space"
> Connection to database 'with space' failed.
> FATAL 1:  InitPostgres could not validate that the database version is
> compatible with this level of Postgres
>         even though the database system as a whole appears to be at a
> compatible level.
>         You may need to recreate the database with SQL commands DROP
> DATABASE and CREATE DATABASE.
>         File '/usr/local/pgsql/data/base/with space/PG_VERSION' does not
> exist or no read permission.
> 
> (You can't do \c with space or \c "with space" yet. That will be (is) in
> the new version.)
> 
> Further investigation shows that the directory
> /usr/local/pgsql/data/base/with space is totally empty.
> 
> But:
> template1=> select * from pg_database;
> datname   |datdba|encoding|datpath
> ----------+------+--------+----------
> template1 |   100|       0|template1
>  . . .
> with space|   101|       0|with space
> (4 rows)
> 
> template1=> drop database "with space";
> DESTROYDB
> 
> Yet, the mysterious empty directory is still there.
> 
> BUG?
> 
> -- 
> Peter Eisentraut - peter_e@gmx.net
> http://yi.org/peter-e
> 
> 
> ************
> 


-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@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

Tue, 5 Oct 1999 17:11:50 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] Database names with spaces
Bruce Momjian <maillist@candle.pha.pa.us> writes:
> Looks like a bug.  Added to TODO list.

>> I see a todo item
>> * Views with spaces in view name fail when referenced
>> 
>> I have another one for you:
>> * Databases with spaces in name fail to be created and destroyed despite
>> responses to the contrary.

IIRC, createdb and destroydb use "cp -r" and "rm -r" respectively.
Lack of careful quoting in the system calls is probably what's
causing the problem here.

However, I wonder if it wouldn't be a better idea to forbid funny
characters in things that will become Unix filenames.  In particular,
something like CREATE DATABASE "../../../something" could have real
bad consequences...

			regards, tom lane

Tue, 05 Oct 1999 18:42:31 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] Database names with spaces 
> Bruce Momjian <maillist@candle.pha.pa.us> writes:
> > Looks like a bug.  Added to TODO list.
> 
> >> I see a todo item
> >> * Views with spaces in view name fail when referenced
> >> 
> >> I have another one for you:
> >> * Databases with spaces in name fail to be created and destroyed despite
> >> responses to the contrary.
> 
> IIRC, createdb and destroydb use "cp -r" and "rm -r" respectively.
> Lack of careful quoting in the system calls is probably what's
> causing the problem here.
> 
> However, I wonder if it wouldn't be a better idea to forbid funny
> characters in things that will become Unix filenames.  In particular,
> something like CREATE DATABASE "../../../something" could have real
> bad consequences...

I just tried it:

	test=> create database "../../pg_hba.conf"
	test-> \g
	ERROR:  Unable to locate path '../../pg_hba.conf'
	        This may be due to a missing environment variable in the server

Seems we are safe.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@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

Tue, 5 Oct 1999 23:08:47 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] Database names with spaces