14 lines
374 B
Bash
14 lines
374 B
Bash
|
#!/bin/bash
|
||
|
psql template1 << EOF
|
||
|
CREATE EXTENSION hstore;
|
||
|
CREATE OR REPLACE FUNCTION idx(anyarray, anyelement)
|
||
|
RETURNS int AS
|
||
|
$$
|
||
|
SELECT i FROM (
|
||
|
SELECT generate_series(array_lower($1,1),array_upper($1,1))
|
||
|
) g(i)
|
||
|
WHERE $1[i] = $2
|
||
|
LIMIT 1;
|
||
|
$$ LANGUAGE sql IMMUTABLE;
|
||
|
EOF
|