Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-21 Thread Robert Haas
On Tue, Mar 20, 2012 at 2:48 PM, Tom Lane wrote: >> I think Tom's correct about what the right behavior would be if >> composite types supported defaults, but they don't, never have, and >> maybe never will.  I had a previous argument about this with Tom, and >> lost, though I am not sure that any

Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-20 Thread Merlin Moncure
On Tue, Mar 20, 2012 at 12:16 PM, Robert Haas wrote: > I think Tom's correct about what the right behavior would be if > composite types supported defaults, but they don't, never have, and > maybe never will.  I had a previous argument about this with Tom, and > lost, though I am not sure that any

Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-20 Thread Tom Lane
Robert Haas writes: > On Wed, Mar 7, 2012 at 3:49 PM, Merlin Moncure wrote: >> On Wed, Mar 7, 2012 at 2:31 PM, Tom Lane wrote: >>> It is not a bug. The ALTER ADD ... DEFAULT ... form implies rewriting >>> every existing tuple of the rowtype to insert a non-null value in the >>> added column, an

Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-20 Thread Robert Haas
On Wed, Mar 7, 2012 at 3:49 PM, Merlin Moncure wrote: > On Wed, Mar 7, 2012 at 2:31 PM, Tom Lane wrote: >> Merlin Moncure writes: >>> On Wed, Mar 7, 2012 at 11:45 AM, Mike Blackwell >>> wrote: alter table a add column even_more_stuff boolean not null default false; >> >>> aha! that's not

Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-08 Thread Mike Blackwell
Not a bad idea. I'd need to convert existing data, but it'd be an excuse to try out hstore. ^_^ Mike * * On Thu, Mar 8, 2012 at 11:08, Merlin Moncure wrote: > On Wed, Mar 7, 2012 at 2:49 PM, Merlin Moncure wrote: > > On a practical level, the error blocks nothing -- you can bypass it > > tri

Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-08 Thread Merlin Moncure
On Wed, Mar 7, 2012 at 2:49 PM, Merlin Moncure wrote: > On a practical level, the error blocks nothing -- you can bypass it > trivially.   It's just an annoyance that prevents things that users > would like to be able to do with table row types.  So I'd argue to > remove the check, although I can

Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-07 Thread Merlin Moncure
On Wed, Mar 7, 2012 at 2:31 PM, Tom Lane wrote: > Merlin Moncure writes: >> On Wed, Mar 7, 2012 at 11:45 AM, Mike Blackwell >> wrote: >>> alter table a add column even_more_stuff boolean not null default false; > >> aha! that's not what you posted last time.  you appended 'not null >> default f

Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-07 Thread Alvaro Herrera
Excerpts from Tom Lane's message of mié mar 07 17:31:32 -0300 2012: > This probably could be done for rowtype columns as well, but nobody has > collected the necessary round tuits. I think there was some fear of > locking/deadlock issues, too. It's probably easy to do if you require it to be ma

Re: [BUGS] [GENERAL] Altering a table with a rowtype column

2012-03-07 Thread Tom Lane
Merlin Moncure writes: > On Wed, Mar 7, 2012 at 11:45 AM, Mike Blackwell > wrote: >> alter table a add column even_more_stuff boolean not null default false; > aha! that's not what you posted last time. you appended 'not null > default false'; which inexplicably breaks the ALTER. > try this:

Re: [GENERAL] Altering a table with a rowtype column

2012-03-07 Thread Merlin Moncure
On Wed, Mar 7, 2012 at 1:17 PM, Mike Blackwell wrote: > As a followup, the workaround fails if there is data in the source table due > to the initial null value placed in the existing data rows. > > [wcs1459@aclnx-cisp01 ~]$ psql --port=5433 -e -f x > begin; > BEGIN > create table a ( >   id seria

Re: [GENERAL] Altering a table with a rowtype column

2012-03-07 Thread Merlin Moncure
On Wed, Mar 7, 2012 at 11:45 AM, Mike Blackwell wrote: > > works for me -- what version are you on? > > merlin > > -- > > [wcs1459@aclnx-cisp01 ~]$ psql --version > psql (PostgreSQL) 9.1.1 > contains support for command-line editing > > > [wcs1459@aclnx-cisp01 ~]$ cat x > create table a ( >  

Re: [GENERAL] Altering a table with a rowtype column

2012-03-07 Thread Mike Blackwell
> > > works for me -- what version are you on? > > merlin > > -- > > [wcs1459@aclnx-cisp01 ~]$ psql --version > psql (PostgreSQL) 9.1.1 > contains support for command-line editing > > > [wcs1459@aclnx-cisp01 ~]$ cat x > create table a ( > id serial, > stuff text, > more_stuff text > ); >

Re: [GENERAL] Altering a table with a rowtype column

2012-03-07 Thread Merlin Moncure
On Wed, Mar 7, 2012 at 11:22 AM, Mike Blackwell wrote: > Given a pair of tables: > > create table a ( >   id serial, >   stuff text, >   more_stuff text > ); > > create table a_audit ( >   id serial, >   old_record a, >   new_record a > ); > > How can one alter the structure of table a?  Attemptin

[GENERAL] Altering a table with a rowtype column

2012-03-07 Thread Mike Blackwell
Given a pair of tables: create table a ( id serial, stuff text, more_stuff text ); create table a_audit ( id serial, old_record a, new_record a ); How can one alter the structure of table a? Attempting ALTER TABLE a ADD COLUMN even_more_stuff text; results in the message: ERROR:

Re: [GENERAL] altering a table to set serial function

2004-07-28 Thread Scott Marlowe
On Wed, 2004-07-28 at 06:09, Prabu Subroto wrote: > Dear Scott... > > My God so I can not use "alter table" to define a > column with int data type? Not define, REdefine. Right now, the version going into beta will let you redefine columns from one type to another. Til then, you have to mak

Re: [GENERAL] altering a table to set serial function

2004-07-28 Thread Prabu Subroto
This is exactly what I need.. Thank you very much for your kindness, Doug. Thank you...thank you...veryvery,,, much. --- Doug McNaught <[EMAIL PROTECTED]> wrote: > Prabu Subroto <[EMAIL PROTECTED]> writes: > > > If I read your suggestion, that means...I have > drop > > the column "salesid" a

Re: [GENERAL] altering a table to set serial function

2004-07-28 Thread Doug McNaught
Prabu Subroto <[EMAIL PROTECTED]> writes: > If I read your suggestion, that means...I have drop > the column "salesid" and re-create the column > "salesid". and it means, I will the data in the > current "salesid" column. > > Do you have further suggestion? You can do it "by hand" without droppin

Re: [GENERAL] altering a table to set serial function

2004-07-28 Thread Martijn van Oosterhout
On Wed, Jul 28, 2004 at 05:09:33AM -0700, Prabu Subroto wrote: > Dear Scott... > > My God so I can not use "alter table" to define a > column with int data type? eh? Sure you can: alter table x add column y integer; What's he's saying is that the "serial" shortcut isn't there and proceeded

Re: [GENERAL] altering a table to set serial function

2004-07-28 Thread Prabu Subroto
Dear Scott... My God so I can not use "alter table" to define a column with int data type? Here is the detail condition: I have created a table "sales". And I forgot to define auto_increment for primary key "salesid" (int4). the table has already contented the data. I built an application wi

Re: [GENERAL] ALTERING A TABLE

2000-06-01 Thread Richard Smith
--snip-- Or is that CAST it on the wasy. Richard