Saturday, August 9, 2008

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

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

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

No comments: