Project

General

Profile

« Previous | Next » 

Revision 14134

schemas/util.sql: col_ref: renamed to just col

View differences:

trunk/schemas/util.sql
30 30
SET search_path = util, pg_catalog;
31 31

  
32 32
--
33
-- Name: col_cast; Type: TYPE; Schema: util; Owner: -
33
-- Name: col; Type: TYPE; Schema: util; Owner: -
34 34
--
35 35

  
36
CREATE TYPE col_cast AS (
37
	col_name text,
38
	type regtype
36
CREATE TYPE col AS (
37
	table_ regclass,
38
	name text
39 39
);
40 40

  
41 41

  
42 42
--
43
-- Name: col_ref; Type: TYPE; Schema: util; Owner: -
43
-- Name: col_cast; Type: TYPE; Schema: util; Owner: -
44 44
--
45 45

  
46
CREATE TYPE col_ref AS (
47
	table_ regclass,
48
	name text
46
CREATE TYPE col_cast AS (
47
	col_name text,
48
	type regtype
49 49
);
50 50

  
51 51

  
......
925 925

  
926 926

  
927 927
--
928
-- Name: col__min(col_ref); Type: FUNCTION; Schema: util; Owner: -
928
-- Name: col__min(col); Type: FUNCTION; Schema: util; Owner: -
929 929
--
930 930

  
931
CREATE FUNCTION col__min(col col_ref) RETURNS integer
931
CREATE FUNCTION col__min(col col) RETURNS integer
932 932
    LANGUAGE sql STABLE
933 933
    AS $_$
934 934
SELECT util.eval2val($$
......
941 941

  
942 942

  
943 943
--
944
-- Name: col_comment(col_ref); Type: FUNCTION; Schema: util; Owner: -
944
-- Name: col_comment(col); Type: FUNCTION; Schema: util; Owner: -
945 945
--
946 946

  
947
CREATE FUNCTION col_comment(col col_ref) RETURNS text
947
CREATE FUNCTION col_comment(col col) RETURNS text
948 948
    LANGUAGE plpgsql STABLE STRICT
949 949
    AS $$
950 950
DECLARE
......
965 965

  
966 966

  
967 967
--
968
-- Name: col_default_sql(col_ref); Type: FUNCTION; Schema: util; Owner: -
968
-- Name: col_default_sql(col); Type: FUNCTION; Schema: util; Owner: -
969 969
--
970 970

  
971
CREATE FUNCTION col_default_sql(col col_ref) RETURNS text
971
CREATE FUNCTION col_default_sql(col col) RETURNS text
972 972
    LANGUAGE plpgsql STABLE STRICT
973 973
    AS $$
974 974
DECLARE
......
988 988

  
989 989

  
990 990
--
991
-- Name: col_default_value(col_ref, anyelement); Type: FUNCTION; Schema: util; Owner: -
991
-- Name: col_default_value(col, anyelement); Type: FUNCTION; Schema: util; Owner: -
992 992
--
993 993

  
994
CREATE FUNCTION col_default_value(col col_ref, ret_type_null anyelement DEFAULT NULL::text) RETURNS anyelement
994
CREATE FUNCTION col_default_value(col col, ret_type_null anyelement DEFAULT NULL::text) RETURNS anyelement
995 995
    LANGUAGE sql STABLE
996 996
    AS $_$
997 997
SELECT util.eval_expr_passthru(util.col_default_sql($1), $2)
......
999 999

  
1000 1000

  
1001 1001
--
1002
-- Name: FUNCTION col_default_value(col col_ref, ret_type_null anyelement); Type: COMMENT; Schema: util; Owner: -
1002
-- Name: FUNCTION col_default_value(col col, ret_type_null anyelement); Type: COMMENT; Schema: util; Owner: -
1003 1003
--
1004 1004

  
1005
COMMENT ON FUNCTION col_default_value(col col_ref, ret_type_null anyelement) IS '
1005
COMMENT ON FUNCTION col_default_value(col col, ret_type_null anyelement) IS '
1006 1006
ret_type_null: NULL::ret_type
1007 1007
';
1008 1008

  
1009 1009

  
1010 1010
--
1011
-- Name: col_exists(col_ref); Type: FUNCTION; Schema: util; Owner: -
1011
-- Name: col_exists(col); Type: FUNCTION; Schema: util; Owner: -
1012 1012
--
1013 1013

  
1014
CREATE FUNCTION col_exists(col col_ref) RETURNS boolean
1014
CREATE FUNCTION col_exists(col col) RETURNS boolean
1015 1015
    LANGUAGE plpgsql STRICT
1016 1016
    AS $$
1017 1017
BEGIN
......
1068 1068

  
1069 1069

  
1070 1070
--
1071
-- Name: col_num(col_ref); Type: FUNCTION; Schema: util; Owner: -
1071
-- Name: col_num(col); Type: FUNCTION; Schema: util; Owner: -
1072 1072
--
1073 1073

  
1074
CREATE FUNCTION col_num(col col_ref) RETURNS smallint
1074
CREATE FUNCTION col_num(col col) RETURNS smallint
1075 1075
    LANGUAGE sql STABLE
1076 1076
    AS $_$
1077 1077
SELECT attnum FROM pg_attribute WHERE attrelid = $1.table_ AND attname = $1.name
......
1079 1079

  
1080 1080

  
1081 1081
--
1082
-- Name: col_type(col_ref); Type: FUNCTION; Schema: util; Owner: -
1082
-- Name: col_type(col); Type: FUNCTION; Schema: util; Owner: -
1083 1083
--
1084 1084

  
1085
CREATE FUNCTION col_type(col col_ref) RETURNS regtype
1085
CREATE FUNCTION col_type(col col) RETURNS regtype
1086 1086
    LANGUAGE plpgsql STABLE STRICT
1087 1087
    AS $$
1088 1088
DECLARE
......
1105 1105
-- Name: cols(regclass); Type: FUNCTION; Schema: util; Owner: -
1106 1106
--
1107 1107

  
1108
CREATE FUNCTION cols(table_ regclass) RETURNS SETOF col_ref
1108
CREATE FUNCTION cols(table_ regclass) RETURNS SETOF col
1109 1109
    LANGUAGE sql STABLE
1110 1110
    AS $_$
1111
SELECT ($1, name)::util.col_ref FROM util.col_names($1) name
1111
SELECT ($1, name)::util.col FROM util.col_names($1) name
1112 1112
$_$;
1113 1113

  
1114 1114

  
1115 1115
--
1116
-- Name: comment(col_ref); Type: FUNCTION; Schema: util; Owner: -
1116
-- Name: comment(col); Type: FUNCTION; Schema: util; Owner: -
1117 1117
--
1118 1118

  
1119
CREATE FUNCTION comment(col col_ref) RETURNS text
1119
CREATE FUNCTION comment(col col) RETURNS text
1120 1120
    LANGUAGE sql STABLE
1121 1121
    AS $_$
1122 1122
SELECT description
......
1588 1588

  
1589 1589

  
1590 1590
--
1591
-- Name: drop_column(col_ref, boolean); Type: FUNCTION; Schema: util; Owner: -
1591
-- Name: drop_column(col, boolean); Type: FUNCTION; Schema: util; Owner: -
1592 1592
--
1593 1593

  
1594
CREATE FUNCTION drop_column(col col_ref, force boolean DEFAULT false) RETURNS void
1594
CREATE FUNCTION drop_column(col col, force boolean DEFAULT false) RETURNS void
1595 1595
    LANGUAGE sql
1596 1596
    AS $_$
1597 1597
SELECT util.eval($$ALTER TABLE $$||$1.table_||$$ DROP COLUMN IF EXISTS $$||
......
1600 1600

  
1601 1601

  
1602 1602
--
1603
-- Name: FUNCTION drop_column(col col_ref, force boolean); Type: COMMENT; Schema: util; Owner: -
1603
-- Name: FUNCTION drop_column(col col, force boolean); Type: COMMENT; Schema: util; Owner: -
1604 1604
--
1605 1605

  
1606
COMMENT ON FUNCTION drop_column(col col_ref, force boolean) IS '
1606
COMMENT ON FUNCTION drop_column(col col, force boolean) IS '
1607 1607
idempotent
1608 1608
';
1609 1609

  
......
2339 2339

  
2340 2340

  
2341 2341
--
2342
-- Name: is_constant(col_ref); Type: FUNCTION; Schema: util; Owner: -
2342
-- Name: is_constant(col); Type: FUNCTION; Schema: util; Owner: -
2343 2343
--
2344 2344

  
2345
CREATE FUNCTION is_constant(col col_ref) RETURNS boolean
2345
CREATE FUNCTION is_constant(col col) RETURNS boolean
2346 2346
    LANGUAGE sql STABLE
2347 2347
    AS $_$
2348 2348
SELECT COALESCE(util.col_comment($1) LIKE '
......
2680 2680

  
2681 2681

  
2682 2682
--
2683
-- Name: mk_const_col(col_ref, anyelement); Type: FUNCTION; Schema: util; Owner: -
2683
-- Name: mk_const_col(col, anyelement); Type: FUNCTION; Schema: util; Owner: -
2684 2684
--
2685 2685

  
2686
CREATE FUNCTION mk_const_col(col col_ref, value anyelement) RETURNS void
2686
CREATE FUNCTION mk_const_col(col col, value anyelement) RETURNS void
2687 2687
    LANGUAGE sql
2688 2688
    AS $_$
2689 2689
SELECT util.create_if_not_exists($$
......
2698 2698

  
2699 2699

  
2700 2700
--
2701
-- Name: FUNCTION mk_const_col(col col_ref, value anyelement); Type: COMMENT; Schema: util; Owner: -
2701
-- Name: FUNCTION mk_const_col(col col, value anyelement); Type: COMMENT; Schema: util; Owner: -
2702 2702
--
2703 2703

  
2704
COMMENT ON FUNCTION mk_const_col(col col_ref, value anyelement) IS '
2704
COMMENT ON FUNCTION mk_const_col(col col, value anyelement) IS '
2705 2705
idempotent
2706 2706
';
2707 2707

  
2708 2708

  
2709 2709
--
2710
-- Name: mk_derived_col(col_ref, text, boolean); Type: FUNCTION; Schema: util; Owner: -
2710
-- Name: mk_derived_col(col, text, boolean); Type: FUNCTION; Schema: util; Owner: -
2711 2711
--
2712 2712

  
2713
CREATE FUNCTION mk_derived_col(col col_ref, expr text, overwrite boolean DEFAULT false) RETURNS void
2713
CREATE FUNCTION mk_derived_col(col col, expr text, overwrite boolean DEFAULT false) RETURNS void
2714 2714
    LANGUAGE plpgsql STRICT
2715 2715
    AS $_$
2716 2716
DECLARE
......
2727 2727

  
2728 2728

  
2729 2729
--
2730
-- Name: FUNCTION mk_derived_col(col col_ref, expr text, overwrite boolean); Type: COMMENT; Schema: util; Owner: -
2730
-- Name: FUNCTION mk_derived_col(col col, expr text, overwrite boolean); Type: COMMENT; Schema: util; Owner: -
2731 2731
--
2732 2732

  
2733
COMMENT ON FUNCTION mk_derived_col(col col_ref, expr text, overwrite boolean) IS '
2733
COMMENT ON FUNCTION mk_derived_col(col col, expr text, overwrite boolean) IS '
2734 2734
idempotent
2735 2735
';
2736 2736

  
......
2823 2823
    LANGUAGE sql
2824 2824
    AS $_$
2825 2825
SELECT util.create_if_not_exists($$
2826
CREATE FUNCTION $$||util.qual_name(util.schema($1), $3)||$$(value $$
2826
CREATE OR REPLACE FUNCTION $$||util.qual_name(util.schema($1), $3)||$$(value $$
2827 2827
||util.qual_name($1)||$$)
2828 2828
  RETURNS $$||util.qual_name($2)||$$ AS
2829 2829
$BODY1$
......
2916 2916

  
2917 2917

  
2918 2918
--
2919
-- Name: mk_set_comment(col_ref); Type: FUNCTION; Schema: util; Owner: -
2919
-- Name: mk_set_comment(col); Type: FUNCTION; Schema: util; Owner: -
2920 2920
--
2921 2921

  
2922
CREATE FUNCTION mk_set_comment(col col_ref) RETURNS text
2922
CREATE FUNCTION mk_set_comment(col col) RETURNS text
2923 2923
    LANGUAGE sql STABLE
2924 2924
    AS $_$
2925 2925
SELECT util.mk_set_comment($1, util.comment($1))
......
2938 2938

  
2939 2939

  
2940 2940
--
2941
-- Name: mk_set_comment(col_ref, text); Type: FUNCTION; Schema: util; Owner: -
2941
-- Name: mk_set_comment(col, text); Type: FUNCTION; Schema: util; Owner: -
2942 2942
--
2943 2943

  
2944
CREATE FUNCTION mk_set_comment(col col_ref, comment text) RETURNS text
2944
CREATE FUNCTION mk_set_comment(col col, comment text) RETURNS text
2945 2945
    LANGUAGE sql STABLE
2946 2946
    AS $_$
2947 2947
SELECT util.mk_set_comment('COLUMN '||util.sql($1), $2)
......
3492 3492

  
3493 3493

  
3494 3494
--
3495
-- Name: raise_undefined_column(col_ref); Type: FUNCTION; Schema: util; Owner: -
3495
-- Name: raise_undefined_column(col); Type: FUNCTION; Schema: util; Owner: -
3496 3496
--
3497 3497

  
3498
CREATE FUNCTION raise_undefined_column(col col_ref) RETURNS text
3498
CREATE FUNCTION raise_undefined_column(col col) RETURNS text
3499 3499
    LANGUAGE plpgsql IMMUTABLE STRICT
3500 3500
    AS $$
3501 3501
BEGIN
......
4519 4519

  
4520 4520

  
4521 4521
--
4522
-- Name: sql(col_ref); Type: FUNCTION; Schema: util; Owner: -
4522
-- Name: sql(col); Type: FUNCTION; Schema: util; Owner: -
4523 4523
--
4524 4524

  
4525
CREATE FUNCTION sql(col col_ref) RETURNS text
4525
CREATE FUNCTION sql(col col) RETURNS text
4526 4526
    LANGUAGE sql STABLE
4527 4527
    AS $_$
4528 4528
SELECT $1.table_||'.'||quote_ident($1.name)
......
4837 4837

  
4838 4838

  
4839 4839
--
4840
-- Name: try_mk_derived_col(col_ref, text); Type: FUNCTION; Schema: util; Owner: -
4840
-- Name: try_mk_derived_col(col, text); Type: FUNCTION; Schema: util; Owner: -
4841 4841
--
4842 4842

  
4843
CREATE FUNCTION try_mk_derived_col(col col_ref, expr text) RETURNS void
4843
CREATE FUNCTION try_mk_derived_col(col col, expr text) RETURNS void
4844 4844
    LANGUAGE sql
4845 4845
    AS $_$
4846 4846
SELECT util.try_create($$SELECT util.mk_derived_col($$||quote_literal($1)||$$, $$||quote_literal($2)||$$)$$)
......
4848 4848

  
4849 4849

  
4850 4850
--
4851
-- Name: FUNCTION try_mk_derived_col(col col_ref, expr text); Type: COMMENT; Schema: util; Owner: -
4851
-- Name: FUNCTION try_mk_derived_col(col col, expr text); Type: COMMENT; Schema: util; Owner: -
4852 4852
--
4853 4853

  
4854
COMMENT ON FUNCTION try_mk_derived_col(col col_ref, expr text) IS '
4854
COMMENT ON FUNCTION try_mk_derived_col(col col, expr text) IS '
4855 4855
idempotent
4856 4856
';
4857 4857

  

Also available in: Unified diff