Project

General

Profile

« Previous | Next » 

Revision 8169

schemas/functions.sql: col_type(): Raise undefined_column exception if column does not exist, instead of silently returning NULL

View differences:

schemas/functions.sql
578 578
--
579 579

  
580 580
CREATE FUNCTION col_type(col col_ref) RETURNS regtype
581
    LANGUAGE sql STABLE STRICT
582
    AS $_$
583
SELECT atttypid FROM pg_attribute
584
WHERE attrelid = $1.table_ AND attname = $1.name
585
$_$;
581
    LANGUAGE plpgsql STABLE STRICT
582
    AS $$
583
DECLARE
584
    type regtype;
585
BEGIN
586
    SELECT atttypid FROM pg_attribute
587
    WHERE attrelid = col.table_ AND attname = col.name
588
    INTO STRICT type
589
    ;
590
    RETURN type;
591
EXCEPTION
592
    WHEN no_data_found THEN RAISE undefined_column;
593
END;
594
$$;
586 595

  
587 596

  
588 597
--

Also available in: Unified diff