Project

General

Profile

« Previous | Next » 

Revision 10130

schemas/util.sql: added col_default_sql()

View differences:

util.sql
569 569

  
570 570

  
571 571
--
572
-- Name: col_default_sql(col_ref); Type: FUNCTION; Schema: util; Owner: -
573
--
574

  
575
CREATE FUNCTION col_default_sql(col col_ref) RETURNS text
576
    LANGUAGE plpgsql STABLE STRICT
577
    AS $$
578
DECLARE
579
	default_sql text;
580
BEGIN
581
	SELECT adsrc
582
	FROM pg_attribute
583
	LEFT JOIN pg_attrdef ON adrelid = attrelid AND adnum = attnum
584
	WHERE attrelid = col.table_ AND attname = col.name
585
	INTO STRICT default_sql
586
	;
587
	RETURN default_sql;
588
EXCEPTION
589
	WHEN no_data_found THEN PERFORM util.raise_undefined_column(col);
590
END;
591
$$;
592

  
593

  
594
--
572 595
-- Name: col_exists(col_ref); Type: FUNCTION; Schema: util; Owner: -
573 596
--
574 597

  

Also available in: Unified diff