Re: ALTER TABLE name RENAME TO new_name; does not work immediately

From: megous(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: ALTER TABLE name RENAME TO new_name; does not work immediately
Date: 2008-08-09 19:26:01
Message-ID: d31f3b33-9319-4043-a1fc-1d8ca07fa6fe@f36g2000hsa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Here is a script that is able to reproduce the problem (on my machine
anyway), you may need to play with the number of rows or workmem
settings to be able to reproduce it:

regards,
Ondrej Jirman

#!/bin/sh

dropdb bug
createdb bug

psql bug << EOF

CREATE TABLE xxx (id SERIAL, col1 TEXT, col2 TEXT);

INSERT INTO xxx
SELECT s AS id, s || 'XXXX' AS col1, s || 'YYYYY' AS col2
FROM generate_series(0, 2000000) AS s;

EOF

psql bug << EOF

SET maintenance_work_mem = 256000;
SET work_mem = 256000;
SHOW maintenance_work_mem;
SHOW work_mem;

VACUUM FULL ANALYZE;
REINDEX DATABASE bug;

BEGIN;

ALTER TABLE xxx RENAME TO yyy;
ALTER TABLE yyy RENAME COLUMN col1 TO colA;
ALTER TABLE yyy RENAME COLUMN col2 TO colB;

COMMIT;

EOF

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Evans 2008-08-09 19:46:02 Re: BUG #3818: Cross compilation problems
Previous Message megous 2008-08-09 19:07:45 Re: ALTER TABLE name RENAME TO new_name; does not work immediately