X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1E33D9FB1B9 for ; Tue, 11 Jul 2006 21:47:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 83647-06 for ; Tue, 11 Jul 2006 21:47:33 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by postgresql.org (Postfix) with ESMTP id 21A289FB25A for ; Tue, 11 Jul 2006 21:47:32 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id u2so71876uge for ; Tue, 11 Jul 2006 17:47:31 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=cLgxvSNLzDNDVyDUmADjtgxLYralu/9tp1SA9QppQjh91cs5/hrgw7a/ULsSXXXiJ+R/90hoy5KrJwP6NpiKDibvh+uLGptGuywwbmJjYC65dGsSwmf5NnLm1KAMUXUnDtJFo7nSciFe3w92qj0Pk6lnWGmZLWAvOOAxSYX6lwI= Received: by 10.78.178.5 with SMTP id a5mr55318huf; Tue, 11 Jul 2006 17:47:31 -0700 (PDT) Received: by 10.78.123.14 with HTTP; Tue, 11 Jul 2006 17:47:31 -0700 (PDT) Message-ID: Date: Tue, 11 Jul 2006 17:47:31 -0700 From: aurora To: pgsql-sql@postgresql.org Subject: Unexpected SQL error for UPDATE MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_17756_4936150.1152665251583" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/187 X-Sequence-Number: 25761 ------=_Part_17756_4936150.1152665251583 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Originally I have a table like this create table users ( userid integer not null, email_address varchar (255) unique not null, PRIMARY KEY (userid) ); Later I find that varchar(255) is not enough. I designed to change the type to text. There is no simple SQL to alter the type. So I use a series of SQLs to create a new column, copy the data over and then replace the old column with the new. ALTER TABLE users ADD email_address_text text UNIQUE; UPDATE users set email_address_text=email_address; ALTER TABLE users DROP email_address; ALTER TABLE users RENAME email_address_text TO email_address; ALTER TABLE users ALTER email_address SET not null; This works mostly OK. Until I have one database that has over 1 million records in table user. It fails with an inexplicable error: mydb=# UPDATE users set email_address_text=email_address; ERROR: invalid page header in block 6776 of relation "users_email_address_text_key" Anyone can shred some light what has went wrong? wy ------=_Part_17756_4936150.1152665251583 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Originally I have a table like this


create table users (
userid integer not null,
email_address varchar (255) unique not null,
PRIMARY KEY (userid)
);


Later I find that varchar(255) is not enough. I designed to change the type to
text. There is no simple SQL to alter the type. So I use a series of SQLs to
create a new column, copy the data over and then replace the old column with the
new.

ALTER TABLE users ADD email_address_text text UNIQUE;
UPDATE users set email_address_text=email_address;
ALTER TABLE users DROP email_address;
ALTER TABLE users RENAME email_address_text TO email_address;
ALTER TABLE users ALTER email_address SET not null;


This works mostly OK. Until I have one database that has over 1 million records
in table user. It fails with an inexplicable error:


mydb=# UPDATE users set email_address_text=email_address;
ERROR: invalid page header in block 6776 of relation "users_email_address_text_key"


Anyone can shred some light what has went wrong?

wy



------=_Part_17756_4936150.1152665251583--