Project

General

Profile

« Previous | Next » 

Revision 12349

schemas/util.sql: added rename_relation(regclass/text, text)

View differences:

util.sql
2376 2376

  
2377 2377

  
2378 2378
--
2379
-- Name: rename_relation(regclass, text); Type: FUNCTION; Schema: util; Owner: -
2380
--
2381

  
2382
CREATE FUNCTION rename_relation(from_ regclass, to_ text) RETURNS void
2383
    LANGUAGE sql
2384
    AS $_$
2385
SELECT util.rename_relation($1::text, $2)
2386
$_$;
2387

  
2388

  
2389
--
2390
-- Name: rename_relation(text, text); Type: FUNCTION; Schema: util; Owner: -
2391
--
2392

  
2393
CREATE FUNCTION rename_relation(from_ text, to_ text) RETURNS void
2394
    LANGUAGE sql
2395
    AS $_$
2396
/* 'ALTER TABLE can be used with views too'
2397
(http://www.postgresql.org/docs/9.3/static/sql-alterview.html) */
2398
SELECT util.eval($$ALTER TABLE IF EXISTS $$||$1||$$ RENAME TO $$||$2)
2399
$_$;
2400

  
2401

  
2402
--
2403
-- Name: FUNCTION rename_relation(from_ text, to_ text); Type: COMMENT; Schema: util; Owner: -
2404
--
2405

  
2406
COMMENT ON FUNCTION rename_relation(from_ text, to_ text) IS '
2407
idempotent
2408
';
2409

  
2410

  
2411
--
2379 2412
-- Name: reset_col_names(regclass, regclass); Type: FUNCTION; Schema: util; Owner: -
2380 2413
--
2381 2414

  

Also available in: Unified diff