/* =============================================================== * Create CLASSES * =============================================================== */ create s2k_comments ( /* stores S2K object descriptions */ s2k_name = char16, /* Object being described */ s2k_is_a = char16, /* class? attribute? function? */ s2k_comment = text, /* short comment (30 characters) */ s2k_description = text /* long description */ ) \g create ca10stn ( /* Station info for ca10clim */ ncdcstn = char8, /* Station */ name = text, /* Name */ lat = float4, /* latitude */ long = float4, /* longitude */ elev = int2 /* elevation */ ) \g create SNOW ( course_ID = int2, course = text, basin = text, elev = int2, /* elevation */ lat = int2, /* latitude */ latmin = float4, longt = int2, longmin = float4, pts = int2, year = int2, apravg = float4, coop = text, aspect = text, exposure = text, dateaband = text, basinnum = int2, login = text, cdecid = char16 ) \g create SNOWCOURSE ( course_ID = int2, date = text, /* YYYYMMDD */ depth = float4, water_content = float4 ) \g create ca10clim ( /* NCDC climatology from Climated */ ncdcstn = char8, /* Station */ date = int4, /* YYYYMMDD */ maxtemp = int2, /* Maximum temperature */ mintemp = int2, /* Minimum temperature */ precip = int2, /* Precipitation */ snowfall = int2, /* Snowfall */ evap = int2 /* Evaporation */ ) \g create FNF ( station_ID = text, date = text, /* YYYYMMDD */ value = float4, name = char16, /* Name */ id = int2, day = int2, month = int2, year = int2, intdate = int4 ) \g /* =============================================================== * Create INDEXES * =============================================================== */ define index s2k_namex on s2k_comments /* index on s2k_comments class */ using btree (s2k_name char16_ops) \g define index ind_snowwtr on SNOWCOURSE using btree (water_content float4_ops) \g define index ind_snowid on SNOWCOURSE using btree (course_ID int2_ops) \g define index ind_fnfmonth on FNF using btree (month int2_ops) \g define index ind_snowdate on SNOWCOURSE using btree (date text_ops) \g define index ind_ncdcstn on ca10clim using btree (ncdcstn ??? (indclass=50153)) \g define index ind_fnfvalue on FNF using btree (value float4_ops) \g define index ind_snowdepth on SNOWCOURSE using btree (depth float4_ops) \g define index ind_precip on ca10clim using btree (precip int2_ops) \g define index ind_fnfname on FNF using btree (name char16_ops) \g define index ind_fnfyear on FNF using btree (year int2_ops) \g /* =============================================================== * Create FUNCTIONS * =============================================================== */ define function char2in (language="c", returntype=char2) arg is () as "newchar.o" \g define function char2out (language="c", returntype=char16) arg is () as "newchar.o" \g define function char4in (language="c", returntype=char4) arg is () as "newchar.o" \g define function char4out (language="c", returntype=char16) arg is () as "newchar.o" \g define function char8in (language="c", returntype=char8) arg is () as "newchar.o" \g define function char8out (language="c", returntype=char16) arg is () as "newchar.o" \g define function char2lt (language="c", returntype=bool) arg is (char2, char2) as "newchar.o" \g define function char2le (language="c", returntype=bool) arg is (char2, char2) as "newchar.o" \g define function char2eq (language="c", returntype=bool) arg is (char2, char2) as "newchar.o" \g define function char2ne (language="c", returntype=bool) arg is (char2, char2) as "newchar.o" \g define function char2ge (language="c", returntype=bool) arg is (char2, char2) as "newchar.o" \g define function char2gt (language="c", returntype=bool) arg is (char2, char2) as "newchar.o" \g define function char2cmp (language="c", returntype=int4) arg is (char2, char2) as "newchar.o" \g define function char4lt (language="c", returntype=bool) arg is (char4, char4) as "newchar.o" \g define function char4le (language="c", returntype=bool) arg is (char4, char4) as "newchar.o" \g define function char4eq (language="c", returntype=bool) arg is (char4, char4) as "newchar.o" \g define function char4ne (language="c", returntype=bool) arg is (char4, char4) as "newchar.o" \g define function char4ge (language="c", returntype=bool) arg is (char4, char4) as "newchar.o" \g define function char4gt (language="c", returntype=bool) arg is (char4, char4) as "newchar.o" \g define function char4cmp (language="c", returntype=int4) arg is (char4, char4) as "newchar.o" \g define function char8lt (language="c", returntype=bool) arg is (char8, char8) as "newchar.o" \g define function char8le (language="c", returntype=bool) arg is (char8, char8) as "newchar.o" \g define function char8eq (language="c", returntype=bool) arg is (char8, char8) as "newchar.o" \g define function char8ne (language="c", returntype=bool) arg is (char8, char8) as "newchar.o" \g define function char8ge (language="c", returntype=bool) arg is (char8, char8) as "newchar.o" \g define function char8gt (language="c", returntype=bool) arg is (char8, char8) as "newchar.o" \g define function char8cmp (language="c", returntype=int4) arg is (char8, char8) as "newchar.o" \g define function oidint2eq (language="c", returntype=bool) arg is (oid, int2) as "oidint2.o" \g define function oidint2ne (language="c", returntype=bool) arg is (oid, int2) as "oidint2.o" \g define function int2oideq (language="c", returntype=bool) arg is (int2, oid) as "oidint2.o" \g define function int2oidne (language="c", returntype=bool) arg is (int2, oid) as "oidint2.o" \g define function gdi_get_type (language="postquel", returntype=char16) arg is (oid) as "retrieve (pg_type.typname) where pg_type.oid = $1" \g define function gdi_attnelems (language="postquel", returntype=int4) arg is (char16) as "retrieve (pg_attribute.attnelems) where pg_attribute.attname = $1" \g define function gdi_get_relid (language="postquel", returntype=oid) arg is (char16) as "retrieve (pg_class.oid) where pg_class.relname = $1" \g define function s2k_get_comment /* pass it s2k_name and s2k_is_a */ (language="postquel", returntype=text) arg is (char16, char16) as "retrieve (s2k_comments.s2k_comment) where s2k_comments.s2k_name = $1 and s2k_comments.s2k_is_a = $2" \g define function s2k_inherits /* says if attname is inherited */ (language="postquel", returntype=int4) arg is (oid, char16) as "retrieve (total = count {a1.oid from a1 in pg_attribute, a2 in pg_attribute where a1.attrelid = $1 and a1.attname = $2 and a1.attname = a2.attname and (a2.attrelid = pg_inherits.inhparent and a1.attrelid = pg_inherits.inhrel) })" \g define function s2k_contains (language="postquel", returntype=char16) arg is (char16) as "retrieve(pg_class.relname)where pg_class.oid=pg_attribute.attrelid and pg_attribute.attname="$1"" \g