Revision 14782
Added by Aaron Marcuse-Kubitza about 10 years ago
trunk/schemas/util.sql | ||
---|---|---|
1507 | 1507 |
CREATE FUNCTION col_rename(from_ col, to_name text) RETURNS void |
1508 | 1508 |
LANGUAGE sql |
1509 | 1509 |
AS $_$ |
1510 |
SELECT util.eval($$ALTER TABLE $$||(from_).table_||$$ RENAME $$ |
|
1510 |
SELECT CASE WHEN to_name != (from_).name THEN -- don't try to rename to itself |
|
1511 |
util.eval($$ALTER TABLE $$||(from_).table_||$$ RENAME $$ |
|
1511 | 1512 |
||util.quote_ident((from_).name)||$$ TO $$||util.quote_ident(to_name)) |
1513 |
END |
|
1512 | 1514 |
$_$; |
1513 | 1515 |
|
1514 | 1516 |
|
Also available in: Unified diff
fix: schemas/util.sql: col_rename(): don't try to rename a column to itself (this will cause an error)