Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-05-05 Thread Tom Lane
I wrote: Peter Eisentraut pete...@gmx.net writes: AFAIR, the only reason that we haven't disallowed this sort of stuff years and years ago is that people use it; the Japanese in particular. I don't see what is different now. What's different now is that 8.4 has already established the

[HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Tom Lane
If I have locale set to C, I can do this: regression=# create database u8 encoding 'utf8'; CREATE DATABASE regression=# create database l1 encoding 'latin1' template u8; CREATE DATABASE Had I had any actual utf8 data in u8, l1 would now contain encoding-corrupt information. Given that we've

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Heikki Linnakangas
Tom Lane wrote: If I have locale set to C, I can do this: regression=# create database u8 encoding 'utf8'; CREATE DATABASE regression=# create database l1 encoding 'latin1' template u8; CREATE DATABASE Had I had any actual utf8 data in u8, l1 would now contain encoding-corrupt information.

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Bill Moran
In response to Tom Lane t...@sss.pgh.pa.us: If I have locale set to C, I can do this: regression=# create database u8 encoding 'utf8'; CREATE DATABASE regression=# create database l1 encoding 'latin1' template u8; CREATE DATABASE Had I had any actual utf8 data in u8, l1 would now

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Andrew Dunstan
Tom Lane wrote: If I have locale set to C, I can do this: regression=# create database u8 encoding 'utf8'; CREATE DATABASE regression=# create database l1 encoding 'latin1' template u8; CREATE DATABASE Had I had any actual utf8 data in u8, l1 would now contain encoding-corrupt information.

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Tom Lane
Bill Moran wmo...@potentialtech.com writes: In response to Tom Lane t...@sss.pgh.pa.us: We should presumably let the encoding be changed when cloning from template0, and probably it's reasonable to trust the user if either source or destination DB encoding is SQL_ASCII. In other cases I'm

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Heikki Linnakangas
Bill Moran wrote: In response to Tom Lane t...@sss.pgh.pa.us: We should presumably let the encoding be changed when cloning from template0, and probably it's reasonable to trust the user if either source or destination DB encoding is SQL_ASCII. In other cases I'm thinking it should fail. On a

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: So the following sequence woiuld be illegal: initdb -E latin1 createdb -E utf8 Yes, that's rather the point. Note that it already *is* illegal unless you happen to have selected C locale; AFAICS that is an oversight and not intentional. For

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Andrew Dunstan
Tom Lane wrote: Andrew Dunstan and...@dunslane.net writes: So the following sequence woiuld be illegal: initdb -E latin1 createdb -E utf8 Yes, that's rather the point. Note that it already *is* illegal unless you happen to have selected C locale; AFAICS that is an

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Bill Moran
In response to Tom Lane t...@sss.pgh.pa.us: Bill Moran wmo...@potentialtech.com writes: In response to Tom Lane t...@sss.pgh.pa.us: We should presumably let the encoding be changed when cloning from template0, and probably it's reasonable to trust the user if either source or destination

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Greg Stark
So it would still be possible to byass this check by cloning a database into SQL_ASCII and then cloning it into the desired encoding? Doesn't sound like it really accomplishes much. I do seem to recall some discussion about this way back. I don't recall the conclusion but I remember some

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Tom Lane
Greg Stark greg.st...@enterprisedb.com writes: So it would still be possible to byass this check by cloning a database into SQL_ASCII and then cloning it into the desired encoding? Doesn't sound like it really accomplishes much. Well, it accomplishes preventing stupid encoding violations.

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Andrew Dunstan
Tom Lane wrote: If we wanted to be entirely anal about this, we could allow SQL_ASCII destination with a different source encoding, but not the reverse. However, we currently consider that you're on your own to ensure sanity when using SQL_ASCII as far as locale goes, so I'm not sure why the

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread David E. Wheeler
On Apr 23, 2009, at 12:00 PM, Tom Lane wrote: You can get around this by cloning template0 instead of template1 (we assume template0 contains nothing that's encoding-specific). Possibly the docs will need to be improved to emphasize that. I was just about to suggest that. With this change,

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Peter Eisentraut
On Thursday 23 April 2009 22:00:25 Tom Lane wrote: Andrew Dunstan and...@dunslane.net writes: So the following sequence woiuld be illegal: initdb -E latin1 createdb -E utf8 Yes, that's rather the point. Note that it already is illegal unless you happen to have selected C locale;

Re: [HACKERS] Why do we let CREATE DATABASE reassign encoding?

2009-04-23 Thread Tom Lane
Peter Eisentraut pete...@gmx.net writes: AFAIR, the only reason that we haven't disallowed this sort of stuff years and years ago is that people use it; the Japanese in particular. I don't see what is different now. What's different now is that 8.4 has already established the principle that