Revision 12258
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/schemas/vegbien.my.sql | ||
---|---|---|
666 | 666 |
|
667 | 667 |
|
668 | 668 |
-- |
669 |
-- Name: source_by_shortname(varchar(255)); Type: FUNCTION; Schema: public; Owner: - |
|
669 |
-- Name: source_by_shortname(varchar(255), anyelement); Type: FUNCTION; Schema: public; Owner: -
|
|
670 | 670 |
-- |
671 | 671 |
|
672 | 672 |
|
trunk/schemas/vegbien.sql | ||
---|---|---|
1433 | 1433 |
|
1434 | 1434 |
|
1435 | 1435 |
-- |
1436 |
-- Name: source_by_shortname(text); Type: FUNCTION; Schema: public; Owner: - |
|
1436 |
-- Name: source_by_shortname(text, anyelement); Type: FUNCTION; Schema: public; Owner: -
|
|
1437 | 1437 |
-- |
1438 | 1438 |
|
1439 |
CREATE FUNCTION source_by_shortname(shortname text) RETURNS integer |
|
1440 |
LANGUAGE sql STABLE STRICT |
|
1441 |
AS $_$ |
|
1442 |
SELECT source_id FROM source WHERE shortname = $1 LIMIT 1 |
|
1443 |
$_$; |
|
1439 |
CREATE FUNCTION source_by_shortname(shortname text, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS integer |
|
1440 |
LANGUAGE plpgsql STABLE STRICT |
|
1441 |
AS $$ |
|
1442 |
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime |
|
1443 |
changes of search_path (schema elements are bound at inline time rather than |
|
1444 |
runtime) */ |
|
1445 |
DECLARE |
|
1446 |
source_id integer; |
|
1447 |
shortname_ text = shortname; |
|
1448 |
BEGIN |
|
1449 |
PERFORM set_config('search_path', util.schema_esc(schema_anchor), true); |
|
1450 |
|
|
1451 |
SELECT source_id INTO source_id |
|
1452 |
FROM source WHERE shortname = shortname_ LIMIT 1 |
|
1453 |
; |
|
1454 |
|
|
1455 |
RETURN source_id; |
|
1456 |
END; |
|
1457 |
$$; |
|
1444 | 1458 |
|
1445 | 1459 |
|
1446 | 1460 |
-- |
Also available in: Unified diff
bugfix: schemas/vegbien.sql: source_by_shortname(): added schema_anchor so that it always applies to the schema it's defined in, even if `public` is not in the search_path