Search Postgresql Archives

Re: Converting non-null unique idx to pkey

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Ed L." <pgsql@xxxxxxxxxxxxx> writes:
> Are there 
> are any known or obvious gotchas associated with transforming a 
> unique index on a non null column into a primary key via this 
> sql?

> update pg_index 
> set indisprimary = 't' 
> where indexrelid = <my non-null unique index oid>

The problem with that is there won't be any pg_constraint entry,
nor any pg_depend entries linking to/from the constraint.

I don't offhand know which bits of logic look at indisprimary
and which pay attention to the pg_constraint entry (and 7.4 is
probably different from current sources on the point anyway).
Things could get a bit weird though, particularly for pg_dump.

Of course, you could gin up the required pg_constraint and pg_depend
entries by hand too, but it's a lot more complex than the above.

If you really wanna do this I'd strongly recommend experimenting
in a scratch database.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux