Add back lost Postgres creation sql for storage backend
This commit is contained in:
parent
049e086b07
commit
04bbc50ccb
|
@ -41,6 +41,36 @@ CREATE TABLE vault_kv_store (
|
|||
CREATE INDEX parent_path_idx ON vault_kv_store (parent_path);
|
||||
```
|
||||
|
||||
If you're using a version of PostgreSQL prior to 9.5, create the following function:
|
||||
|
||||
```sql
|
||||
CREATE FUNCTION vault_kv_put(_parent_path TEXT, _path TEXT, _key TEXT, _value BYTEA) RETURNS VOID AS
|
||||
$$
|
||||
BEGIN
|
||||
LOOP
|
||||
-- first try to update the key
|
||||
UPDATE vault_kv_store
|
||||
SET (parent_path, path, key, value) = (_parent_path, _path, _key, _value)
|
||||
WHERE _path = path AND key = _key;
|
||||
IF found THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
-- not there, so try to insert the key
|
||||
-- if someone else inserts the same key concurrently,
|
||||
-- we could get a unique-key failure
|
||||
BEGIN
|
||||
INSERT INTO vault_kv_store (parent_path, path, key, value)
|
||||
VALUES (_parent_path, _path, _key, _value);
|
||||
RETURN;
|
||||
EXCEPTION WHEN unique_violation THEN
|
||||
-- Do nothing, and loop to try the UPDATE again.
|
||||
END;
|
||||
END LOOP;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
```
|
||||
|
||||
## `postgresql` Parameters
|
||||
|
||||
- `connection_url` `(string: <required>)` – Specifies the connection string to
|
||||
|
|
Loading…
Reference in New Issue