Revision 6243
Added by Aaron Marcuse-Kubitza about 12 years ago
schemas/functions.sql | ||
---|---|---|
146 | 146 |
LANGUAGE plpgsql IMMUTABLE |
147 | 147 |
AS $$ |
148 | 148 |
DECLARE |
149 |
match text := map -> value; |
|
149 |
map hstore := '*' => '!' || map; -- set default value for '*' |
|
150 |
match text := COALESCE(map -> value, map -> '*'); |
|
150 | 151 |
BEGIN |
151 |
IF match IS NOT NULL THEN RETURN match; |
|
152 |
ELSE |
|
153 |
DECLARE |
|
154 |
default_ text := map -> '*'; |
|
155 |
BEGIN |
|
156 |
IF default_ = '*' THEN RETURN value; |
|
157 |
ELSIF default_ IS NOT NULL OR map ? '*' THEN RETURN default_; -- default provided |
|
158 |
ELSE RAISE 'Value not in map: %', value USING ERRCODE = 'data_exception'; |
|
159 |
END IF; |
|
160 |
END; |
|
152 |
IF match = '!' THEN RAISE 'Value not in map: %', value USING ERRCODE = 'data_exception'; |
|
153 |
ELSIF match = '*' THEN RETURN value; |
|
154 |
ELSE RETURN match; |
|
161 | 155 |
END IF; |
162 | 156 |
END; |
163 | 157 |
$$; |
Also available in: Unified diff
schemas/functions.sql: _map(): Support any entry having the value '*' (not just the '*' entry), which passes through that value. Support an entry having the value '!', which raises an exception.