message-db 2.1.6 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/database/VERSION.txt +1 -1
- data/database/benchmark.sh +8 -4
- data/database/benchmark_get.sql +0 -3
- data/database/benchmark_write.sql +0 -3
- data/database/clear-messages.sh +1 -1
- data/database/functions/get-last-stream-message.sql +14 -3
- data/database/functions/message-store-version.sql +1 -1
- data/database/install-functions.sh +24 -27
- data/database/install-indexes.sh +14 -10
- data/database/install-privileges.sh +16 -12
- data/database/install-views.sh +17 -13
- data/database/install.sh +8 -4
- data/database/print-category-type-summary.sh +8 -4
- data/database/print-message-store-version.sh +1 -1
- data/database/print-messages.sh +6 -2
- data/database/print-stream-summary.sh +8 -4
- data/database/print-stream-type-summary.sh +8 -4
- data/database/print-type-category-summary.sh +8 -4
- data/database/print-type-stream-summary.sh +8 -4
- data/database/print-type-summary.sh +8 -4
- data/database/privileges/functions.sql +1 -1
- data/database/uninstall.sh +6 -2
- data/database/update/1.3.0.md +13 -0
- data/database/update/1.3.0.sh +95 -0
- data/database/write-test-message.sh +12 -3
- metadata +17 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47624b22850abd2ee71b60e2b721c215dc20e2ca6985b495ffe3d8013cf78a89
|
4
|
+
data.tar.gz: eea2b47d9026568e707383ec60dd9c0595f8f1723992a14743392ca3f19ddecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6acf0100e509408dcf6934031b0e1308e405cfb3319fab40d5149ce2a6910763fdb9e8a16359d4141adc50d030d17d6036ce125e42adae94f5610fd2bac9eccd
|
7
|
+
data.tar.gz: 995ea8891da3435e9c818c17120e2d0c9e0807382193c1b0be7d7a2b4d15e9f1770b28c67aced4195a6b0294105c89fbc43e82cecef8b70695669e1c3694f724
|
data/database/VERSION.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/database/benchmark.sh
CHANGED
@@ -35,18 +35,22 @@ fi
|
|
35
35
|
echo "Database name is: $database"
|
36
36
|
echo
|
37
37
|
|
38
|
+
function run_psql {
|
39
|
+
psql $database -v ON_ERROR_STOP=1 "$@"
|
40
|
+
}
|
41
|
+
|
38
42
|
echo "Installing benchmark scripts"
|
39
43
|
echo
|
40
44
|
|
41
|
-
|
42
|
-
|
45
|
+
run_psql -q -f $base/benchmark_write.sql
|
46
|
+
run_psql -q -f $base/benchmark_get.sql
|
43
47
|
|
44
48
|
echo
|
45
49
|
echo "Benchmarking write"
|
46
50
|
echo "- - -"
|
47
51
|
echo
|
48
52
|
|
49
|
-
|
53
|
+
run_psql -U message_store -c "EXPLAIN ANALYZE SELECT benchmark_write('$stream_name'::varchar, $cycles::int);"
|
50
54
|
|
51
55
|
echo
|
52
56
|
|
@@ -55,7 +59,7 @@ echo "Benchmarking get"
|
|
55
59
|
echo "- - -"
|
56
60
|
echo
|
57
61
|
|
58
|
-
|
62
|
+
run_psql -U message_store -c "EXPLAIN ANALYZE SELECT benchmark_get('$stream_name'::varchar, $cycles::int);"
|
59
63
|
|
60
64
|
echo "= = ="
|
61
65
|
echo "Done"
|
data/database/benchmark_get.sql
CHANGED
data/database/clear-messages.sh
CHANGED
@@ -19,7 +19,7 @@ echo "Database name is: $database"
|
|
19
19
|
|
20
20
|
echo
|
21
21
|
|
22
|
-
psql $database -q -c "TRUNCATE message_store.messages RESTART IDENTITY;"
|
22
|
+
psql $database -v ON_ERROR_STOP=1 -q -c "TRUNCATE message_store.messages RESTART IDENTITY;"
|
23
23
|
|
24
24
|
echo "= = ="
|
25
25
|
echo "Done Clearing Messages Table"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
CREATE OR REPLACE FUNCTION message_store.get_last_stream_message(
|
2
|
-
stream_name varchar
|
2
|
+
stream_name varchar,
|
3
|
+
type varchar DEFAULT NULL
|
3
4
|
)
|
4
5
|
RETURNS SETOF message_store.message
|
5
6
|
AS $$
|
@@ -19,7 +20,14 @@ BEGIN
|
|
19
20
|
FROM
|
20
21
|
messages
|
21
22
|
WHERE
|
22
|
-
stream_name = $1
|
23
|
+
stream_name = $1';
|
24
|
+
|
25
|
+
IF get_last_stream_message.type IS NOT NULL THEN
|
26
|
+
_command := _command || ' AND
|
27
|
+
type = $2';
|
28
|
+
END IF;
|
29
|
+
|
30
|
+
_command := _command || '
|
23
31
|
ORDER BY
|
24
32
|
position DESC
|
25
33
|
LIMIT
|
@@ -28,10 +36,13 @@ BEGIN
|
|
28
36
|
IF current_setting('message_store.debug_get', true) = 'on' OR current_setting('message_store.debug', true) = 'on' THEN
|
29
37
|
RAISE NOTICE '» get_last_message';
|
30
38
|
RAISE NOTICE 'stream_name ($1): %', get_last_stream_message.stream_name;
|
39
|
+
RAISE NOTICE 'type ($2): %', get_last_stream_message.type;
|
31
40
|
RAISE NOTICE 'Generated Command: %', _command;
|
32
41
|
END IF;
|
33
42
|
|
34
|
-
RETURN QUERY EXECUTE _command USING
|
43
|
+
RETURN QUERY EXECUTE _command USING
|
44
|
+
get_last_stream_message.stream_name,
|
45
|
+
get_last_stream_message.type;
|
35
46
|
END;
|
36
47
|
$$ LANGUAGE plpgsql
|
37
48
|
VOLATILE;
|
@@ -2,70 +2,67 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
+
if [ -z ${DATABASE_NAME+x} ]; then
|
6
|
+
database=message_store
|
7
|
+
echo "(DATABASE_NAME is not set. Using: $database.)"
|
8
|
+
else
|
9
|
+
database=$DATABASE_NAME
|
10
|
+
fi
|
11
|
+
|
12
|
+
function run_psql_file {
|
13
|
+
psql $database -q -v ON_ERROR_STOP=1 -f "$1"
|
14
|
+
}
|
15
|
+
|
5
16
|
function script_dir {
|
6
17
|
val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
7
18
|
echo "$val"
|
8
19
|
}
|
9
20
|
|
10
21
|
function create-types {
|
11
|
-
if [ -z ${DATABASE_NAME+x} ]; then
|
12
|
-
database=message_store
|
13
|
-
echo "(DATABASE_NAME is not set. Using: $database.)"
|
14
|
-
else
|
15
|
-
database=$DATABASE_NAME
|
16
|
-
fi
|
17
|
-
|
18
22
|
base=$(script_dir)
|
19
23
|
|
20
24
|
echo "» message type"
|
21
|
-
|
25
|
+
run_psql_file $base/types/message.sql
|
22
26
|
}
|
23
27
|
|
24
28
|
function create-functions {
|
25
|
-
if [ -z ${DATABASE_NAME+x} ]; then
|
26
|
-
database=message_store
|
27
|
-
echo "(DATABASE_NAME is not set. Using: $database.)"
|
28
|
-
else
|
29
|
-
database=$DATABASE_NAME
|
30
|
-
fi
|
31
|
-
|
32
29
|
base=$(script_dir)
|
33
30
|
|
34
31
|
echo "» message_store_version function"
|
35
|
-
|
32
|
+
run_psql_file $base/functions/message-store-version.sql
|
36
33
|
|
37
34
|
echo "» hash_64 function"
|
38
|
-
|
35
|
+
run_psql_file $base/functions/hash-64.sql
|
39
36
|
|
40
37
|
echo "» acquire_lock function"
|
41
|
-
|
38
|
+
run_psql_file $base/functions/acquire-lock.sql
|
42
39
|
|
43
40
|
echo "» category function"
|
44
|
-
|
41
|
+
run_psql_file $base/functions/category.sql
|
45
42
|
|
46
43
|
echo "» is_category function"
|
47
|
-
|
44
|
+
run_psql_file $base/functions/is-category.sql
|
48
45
|
|
49
46
|
echo "» id function"
|
50
|
-
|
47
|
+
run_psql_file $base/functions/id.sql
|
51
48
|
|
52
49
|
echo "» cardinal_id function"
|
53
|
-
|
50
|
+
run_psql_file $base/functions/cardinal-id.sql
|
54
51
|
|
55
52
|
echo "» stream_version function"
|
56
|
-
|
53
|
+
run_psql_file $base/functions/stream-version.sql
|
57
54
|
|
58
55
|
echo "» write_message function"
|
59
|
-
|
56
|
+
run_psql_file $base/functions/write-message.sql
|
60
57
|
|
61
58
|
echo "» get_stream_messages function"
|
62
|
-
|
59
|
+
run_psql_file $base/functions/get-stream-messages.sql
|
63
60
|
|
64
61
|
echo "» get_category_messages function"
|
65
|
-
|
62
|
+
run_psql_file $base/functions/get-category-messages.sql
|
66
63
|
|
67
64
|
echo "» get_last_stream_message function"
|
68
|
-
|
65
|
+
run_psql_file $base/functions/get-last-stream-message.sql
|
69
66
|
}
|
70
67
|
|
71
68
|
echo "Creating Types"
|
data/database/install-indexes.sh
CHANGED
@@ -2,29 +2,33 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
+
if [ -z ${DATABASE_NAME+x} ]; then
|
6
|
+
database=message_store
|
7
|
+
echo "(DATABASE_NAME is not set. Using: $database.)"
|
8
|
+
else
|
9
|
+
database=$DATABASE_NAME
|
10
|
+
fi
|
11
|
+
|
12
|
+
function run_psql_file {
|
13
|
+
psql $database -q -v ON_ERROR_STOP=1 -f "$1"
|
14
|
+
}
|
15
|
+
|
5
16
|
function script_dir {
|
6
17
|
val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
7
18
|
echo "$val"
|
8
19
|
}
|
9
20
|
|
10
21
|
function create-indexes {
|
11
|
-
if [ -z ${DATABASE_NAME+x} ]; then
|
12
|
-
database=message_store
|
13
|
-
echo "(DATABASE_NAME is not set. Using: $database.)"
|
14
|
-
else
|
15
|
-
database=$DATABASE_NAME
|
16
|
-
fi
|
17
|
-
|
18
22
|
base=$(script_dir)
|
19
23
|
|
20
24
|
echo "» messages_id index"
|
21
|
-
|
25
|
+
run_psql_file $base/indexes/messages-id.sql
|
22
26
|
|
23
27
|
echo "» messages_stream index"
|
24
|
-
|
28
|
+
run_psql_file $base/indexes/messages-stream.sql
|
25
29
|
|
26
30
|
echo "» messages_category index"
|
27
|
-
|
31
|
+
run_psql_file $base/indexes/messages-category.sql
|
28
32
|
}
|
29
33
|
|
30
34
|
echo "Creating Indexes"
|
@@ -2,35 +2,39 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
+
if [ -z ${DATABASE_NAME+x} ]; then
|
6
|
+
database=message_store
|
7
|
+
echo "(DATABASE_NAME is not set. Using: $database.)"
|
8
|
+
else
|
9
|
+
database=$DATABASE_NAME
|
10
|
+
fi
|
11
|
+
|
12
|
+
function run_psql_file {
|
13
|
+
psql $database -q -v ON_ERROR_STOP=1 -f "$1"
|
14
|
+
}
|
15
|
+
|
5
16
|
function script_dir {
|
6
17
|
val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
7
18
|
echo "$val"
|
8
19
|
}
|
9
20
|
|
10
21
|
function grant-privileges {
|
11
|
-
if [ -z ${DATABASE_NAME+x} ]; then
|
12
|
-
database=message_store
|
13
|
-
echo "(DATABASE_NAME is not set. Using: $database.)"
|
14
|
-
else
|
15
|
-
database=$DATABASE_NAME
|
16
|
-
fi
|
17
|
-
|
18
22
|
base=$(script_dir)
|
19
23
|
|
20
24
|
echo "» schema privileges"
|
21
|
-
|
25
|
+
run_psql_file $base/privileges/schema.sql
|
22
26
|
|
23
27
|
echo "» messages table privileges"
|
24
|
-
|
28
|
+
run_psql_file $base/privileges/table.sql
|
25
29
|
|
26
30
|
echo "» sequence privileges"
|
27
|
-
|
31
|
+
run_psql_file $base/privileges/sequence.sql
|
28
32
|
|
29
33
|
echo "» functions privileges"
|
30
|
-
|
34
|
+
run_psql_file $base/privileges/functions.sql
|
31
35
|
|
32
36
|
echo "» views privileges"
|
33
|
-
|
37
|
+
run_psql_file $base/privileges/views.sql
|
34
38
|
}
|
35
39
|
|
36
40
|
echo "Granting Privileges"
|
data/database/install-views.sh
CHANGED
@@ -2,38 +2,42 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
+
if [ -z ${DATABASE_NAME+x} ]; then
|
6
|
+
database=message_store
|
7
|
+
echo "(DATABASE_NAME is not set. Using: $database.)"
|
8
|
+
else
|
9
|
+
database=$DATABASE_NAME
|
10
|
+
fi
|
11
|
+
|
12
|
+
function run_psql_file {
|
13
|
+
psql $database -q -v ON_ERROR_STOP=1 -f "$1"
|
14
|
+
}
|
15
|
+
|
5
16
|
function script_dir {
|
6
17
|
val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
7
18
|
echo "$val"
|
8
19
|
}
|
9
20
|
|
10
21
|
function create-views {
|
11
|
-
if [ -z ${DATABASE_NAME+x} ]; then
|
12
|
-
database=message_store
|
13
|
-
echo "(DATABASE_NAME is not set. Using: $database.)"
|
14
|
-
else
|
15
|
-
database=$DATABASE_NAME
|
16
|
-
fi
|
17
|
-
|
18
22
|
base=$(script_dir)
|
19
23
|
|
20
24
|
echo "» stream_summary view"
|
21
|
-
|
25
|
+
run_psql_file $base/views/stream-summary.sql
|
22
26
|
|
23
27
|
echo "» type_summary view"
|
24
|
-
|
28
|
+
run_psql_file $base/views/type-summary.sql
|
25
29
|
|
26
30
|
echo "» stream_type_summary view"
|
27
|
-
|
31
|
+
run_psql_file $base/views/stream-type-summary.sql
|
28
32
|
|
29
33
|
echo "» type_stream_summary view"
|
30
|
-
|
34
|
+
run_psql_file $base/views/type-stream-summary.sql
|
31
35
|
|
32
36
|
echo "» category_type_summary view"
|
33
|
-
|
37
|
+
run_psql_file $base/views/category-type-summary.sql
|
34
38
|
|
35
39
|
echo "» type_category_summary view"
|
36
|
-
|
40
|
+
run_psql_file $base/views/type-category-summary.sql
|
37
41
|
}
|
38
42
|
|
39
43
|
echo "Creating Views"
|
data/database/install.sh
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
+
function run_psql {
|
6
|
+
psql -q -v ON_ERROR_STOP=1 "$@"
|
7
|
+
}
|
8
|
+
|
5
9
|
function script_dir {
|
6
10
|
val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
7
11
|
echo "$val"
|
@@ -41,7 +45,7 @@ function create-user {
|
|
41
45
|
base=$(script_dir)
|
42
46
|
|
43
47
|
echo "» message_store role"
|
44
|
-
|
48
|
+
run_psql postgres -f $base/roles/message-store.sql
|
45
49
|
}
|
46
50
|
|
47
51
|
function create-database {
|
@@ -51,21 +55,21 @@ function create-database {
|
|
51
55
|
|
52
56
|
function create-schema {
|
53
57
|
echo "» message_store schema"
|
54
|
-
|
58
|
+
run_psql $database -f $base/schema/message-store.sql
|
55
59
|
}
|
56
60
|
|
57
61
|
function create-extensions {
|
58
62
|
base=$(script_dir)
|
59
63
|
|
60
64
|
echo "» pgcrypto extension"
|
61
|
-
|
65
|
+
run_psql $database -f $base/extensions/pgcrypto.sql
|
62
66
|
}
|
63
67
|
|
64
68
|
function create-table {
|
65
69
|
base=$(script_dir)
|
66
70
|
|
67
71
|
echo "» messages table"
|
68
|
-
|
72
|
+
run_psql $database -f $base/tables/messages.sql
|
69
73
|
}
|
70
74
|
|
71
75
|
echo
|
@@ -30,15 +30,19 @@ else
|
|
30
30
|
echo "Category is: $CATEGORY"
|
31
31
|
fi
|
32
32
|
|
33
|
+
function run_psql_command {
|
34
|
+
psql $database -v ON_ERROR_STOP=1 -U $user -P pager=off -c "$1"
|
35
|
+
}
|
36
|
+
|
33
37
|
echo
|
34
38
|
echo "Category Type Summary"
|
35
39
|
echo "= = ="
|
36
40
|
echo
|
37
41
|
|
38
42
|
if [ -z $category ]; then
|
39
|
-
|
40
|
-
|
43
|
+
run_psql_command "SELECT * FROM category_type_summary;"
|
44
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages;"
|
41
45
|
else
|
42
|
-
|
43
|
-
|
46
|
+
run_psql_command "SELECT * FROM category_type_summary WHERE category LIKE '%$category%';"
|
47
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages WHERE category(stream_name) LIKE '%$category%';"
|
44
48
|
fi
|
data/database/print-messages.sh
CHANGED
@@ -35,10 +35,14 @@ else
|
|
35
35
|
echo "Stream name is: $STREAM_NAME"
|
36
36
|
fi
|
37
37
|
|
38
|
+
function run_psql_command {
|
39
|
+
psql $database -v ON_ERROR_STOP=1 -U $user -P pager=off -x -c "$1"
|
40
|
+
}
|
41
|
+
|
38
42
|
echo
|
39
43
|
|
40
44
|
if [ -z $stream_name ]; then
|
41
|
-
|
45
|
+
run_psql_command "SELECT * FROM messages ORDER BY global_position ASC"
|
42
46
|
else
|
43
|
-
|
47
|
+
run_psql_command "SELECT * FROM messages WHERE stream_name = '$stream_name' ORDER BY global_position ASC"
|
44
48
|
fi
|
@@ -30,15 +30,19 @@ else
|
|
30
30
|
echo "Stream name is: $STREAM_NAME"
|
31
31
|
fi
|
32
32
|
|
33
|
+
function run_psql_command {
|
34
|
+
psql $database -v ON_ERROR_STOP=1 -U $user -P pager=off -c "$1"
|
35
|
+
}
|
36
|
+
|
33
37
|
echo
|
34
38
|
echo "Stream Summary"
|
35
39
|
echo "= = ="
|
36
40
|
echo
|
37
41
|
|
38
42
|
if [ -z $stream_name ]; then
|
39
|
-
|
40
|
-
|
43
|
+
run_psql_command "SELECT * FROM stream_summary ORDER BY message_count DESC;"
|
44
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages;"
|
41
45
|
else
|
42
|
-
|
43
|
-
|
46
|
+
run_psql_command "SELECT * FROM stream_summary WHERE stream_name LIKE '%$stream_name%' ORDER BY message_count DESC;"
|
47
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages WHERE stream_name LIKE '%$stream_name%';"
|
44
48
|
fi
|
@@ -30,15 +30,19 @@ else
|
|
30
30
|
echo "Stream name is: $STREAM_NAME"
|
31
31
|
fi
|
32
32
|
|
33
|
+
function run_psql_command {
|
34
|
+
psql $database -v ON_ERROR_STOP=1 -U $user -P pager=off -c "$1"
|
35
|
+
}
|
36
|
+
|
33
37
|
echo
|
34
38
|
echo "Stream Type Summary"
|
35
39
|
echo "= = ="
|
36
40
|
echo
|
37
41
|
|
38
42
|
if [ -z $stream_name ]; then
|
39
|
-
|
40
|
-
|
43
|
+
run_psql_command "SELECT * FROM stream_type_summary ORDER BY stream_name, message_count DESC, type;"
|
44
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages;"
|
41
45
|
else
|
42
|
-
|
43
|
-
|
46
|
+
run_psql_command "SELECT * FROM stream_type_summary WHERE stream_name LIKE '%$stream_name%' ORDER BY stream_name, message_count DESC;"
|
47
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages WHERE stream_name LIKE '%$stream_name%';"
|
44
48
|
fi
|
@@ -30,15 +30,19 @@ else
|
|
30
30
|
echo "Type is: $TYPE"
|
31
31
|
fi
|
32
32
|
|
33
|
+
function run_psql_command {
|
34
|
+
psql $database -v ON_ERROR_STOP=1 -U $user -P pager=off -c "$1"
|
35
|
+
}
|
36
|
+
|
33
37
|
echo
|
34
38
|
echo "Type Category Summary"
|
35
39
|
echo "= = ="
|
36
40
|
echo
|
37
41
|
|
38
42
|
if [ -z $type ]; then
|
39
|
-
|
40
|
-
|
43
|
+
run_psql_command "SELECT * FROM type_category_summary;"
|
44
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages;"
|
41
45
|
else
|
42
|
-
|
43
|
-
|
46
|
+
run_psql_command "SELECT * FROM type_category_summary WHERE type LIKE '%$type%';"
|
47
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages WHERE type LIKE '%$type%';"
|
44
48
|
fi
|
@@ -30,15 +30,19 @@ else
|
|
30
30
|
echo "Type is: $TYPE"
|
31
31
|
fi
|
32
32
|
|
33
|
+
function run_psql_command {
|
34
|
+
psql $database -v ON_ERROR_STOP=1 -U $user -P pager=off -c "$1"
|
35
|
+
}
|
36
|
+
|
33
37
|
echo
|
34
38
|
echo "Type Stream Summary"
|
35
39
|
echo "= = ="
|
36
40
|
echo
|
37
41
|
|
38
42
|
if [ -z $type ]; then
|
39
|
-
|
40
|
-
|
43
|
+
run_psql_command "SELECT * FROM type_stream_summary ORDER BY type, message_count DESC, stream_name;"
|
44
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages;"
|
41
45
|
else
|
42
|
-
|
43
|
-
|
46
|
+
run_psql_command "SELECT * FROM type_stream_summary WHERE type LIKE '%$type%' ORDER BY type, message_count DESC, stream_name;"
|
47
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages WHERE type LIKE '%$type%';"
|
44
48
|
fi
|
@@ -30,15 +30,19 @@ else
|
|
30
30
|
echo "Type is: $TYPE"
|
31
31
|
fi
|
32
32
|
|
33
|
+
function run_psql_command {
|
34
|
+
psql $database -v ON_ERROR_STOP=1 -U $user -P pager=off -c "$1"
|
35
|
+
}
|
36
|
+
|
33
37
|
echo
|
34
38
|
echo "Type Summary"
|
35
39
|
echo "= = ="
|
36
40
|
echo
|
37
41
|
|
38
42
|
if [ -z $type ]; then
|
39
|
-
|
40
|
-
|
43
|
+
run_psql_command "SELECT * FROM type_summary ORDER BY message_count DESC;"
|
44
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages;"
|
41
45
|
else
|
42
|
-
|
43
|
-
|
46
|
+
run_psql_command "SELECT * FROM type_summary WHERE type LIKE '%$type%' ORDER BY message_count DESC;"
|
47
|
+
run_psql_command "SELECT COUNT(*) AS total_count FROM messages WHERE type LIKE '%$type%';"
|
44
48
|
fi
|
@@ -4,7 +4,7 @@ GRANT EXECUTE ON FUNCTION message_store.acquire_lock(varchar) TO message_store;
|
|
4
4
|
GRANT EXECUTE ON FUNCTION message_store.cardinal_id(varchar) TO message_store;
|
5
5
|
GRANT EXECUTE ON FUNCTION message_store.category(varchar) TO message_store;
|
6
6
|
GRANT EXECUTE ON FUNCTION message_store.get_category_messages(varchar, bigint, bigint, varchar, bigint, bigint, varchar) TO message_store;
|
7
|
-
GRANT EXECUTE ON FUNCTION message_store.get_last_stream_message(varchar) TO message_store;
|
7
|
+
GRANT EXECUTE ON FUNCTION message_store.get_last_stream_message(varchar, varchar) TO message_store;
|
8
8
|
GRANT EXECUTE ON FUNCTION message_store.get_stream_messages(varchar, bigint, bigint, varchar) TO message_store;
|
9
9
|
GRANT EXECUTE ON FUNCTION message_store.hash_64(varchar) TO message_store;
|
10
10
|
GRANT EXECUTE ON FUNCTION message_store.id(varchar) TO message_store;
|
data/database/uninstall.sh
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
+
function run_psql_command {
|
6
|
+
psql -q -v ON_ERROR_STOP=1 -P pager=off postgres -c "$1"
|
7
|
+
}
|
8
|
+
|
5
9
|
function script_dir {
|
6
10
|
val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
7
11
|
echo "$val"
|
@@ -28,12 +32,12 @@ fi
|
|
28
32
|
|
29
33
|
function delete-user {
|
30
34
|
echo "» message_store user"
|
31
|
-
|
35
|
+
run_psql_command "DROP ROLE IF EXISTS message_store;"
|
32
36
|
}
|
33
37
|
|
34
38
|
function delete-database {
|
35
39
|
echo "» $database database"
|
36
|
-
|
40
|
+
run_psql_command "DROP DATABASE IF EXISTS \"$database\";"
|
37
41
|
}
|
38
42
|
|
39
43
|
echo "Deleting database"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# 1.3.0 Update
|
2
|
+
|
3
|
+
Note: There are no backward-incompatible changes in this update.
|
4
|
+
|
5
|
+
For more information about Message DB update scripts, see:
|
6
|
+
|
7
|
+
[http://docs.eventide-project.org/user-guide/message-db/update.html](http://docs.eventide-project.org/user-guide/message-db/update.html)
|
8
|
+
|
9
|
+
The following changes are made by the v1.3.0 update script:
|
10
|
+
|
11
|
+
- The `get_last_stream_message` function is replaced with an implementation that receives the additional `type` argument that constrains the result to the last message of a stream of a specified message type (see: [http://docs.eventide-project.org/user-guide/message-db/server-functions.html#get-last-message-from-a-stream](http://docs.eventide-project.org/user-guide/message-db/server-functions.html#get-last-message-from-a-stream))
|
12
|
+
- Grants the execution privilege for the new `get_last_stream_message` function implementation to the `message_store` role
|
13
|
+
- The database installation scripts terminate on error, rather than proceeding with the rest of the installation when a script error occurs, as was the case with previous versions
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
echo
|
6
|
+
echo "Message DB"
|
7
|
+
echo
|
8
|
+
echo "Update the message_store database to v1.3.0"
|
9
|
+
echo
|
10
|
+
echo "Fore more information about the changes made to the message store by"
|
11
|
+
echo "this update, see: https://github.com/message-db/message-db/blob/master/database/update/1.3.0.md"
|
12
|
+
echo
|
13
|
+
echo "- Press CTRL+C to cancel"
|
14
|
+
echo "- Press RETURN to proceed with the update"
|
15
|
+
echo
|
16
|
+
|
17
|
+
read
|
18
|
+
|
19
|
+
function run_psql {
|
20
|
+
psql $database -q -v ON_ERROR_STOP=1 -c "$@"
|
21
|
+
}
|
22
|
+
|
23
|
+
function run_psql_file {
|
24
|
+
psql $database -q -v ON_ERROR_STOP=1 -f "$1"
|
25
|
+
}
|
26
|
+
|
27
|
+
function script_dir {
|
28
|
+
val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
29
|
+
echo "$val"
|
30
|
+
}
|
31
|
+
|
32
|
+
base="$(script_dir)/.."
|
33
|
+
echo $base
|
34
|
+
|
35
|
+
echo
|
36
|
+
echo "Updating Database"
|
37
|
+
echo "Version: 1.3.0"
|
38
|
+
echo "= = ="
|
39
|
+
|
40
|
+
if [ -z ${DATABASE_NAME+x} ]; then
|
41
|
+
echo "(DATABASE_NAME is not set. Default will be used.)"
|
42
|
+
database=message_store
|
43
|
+
export DATABASE_NAME=$database
|
44
|
+
else
|
45
|
+
database=$DATABASE_NAME
|
46
|
+
fi
|
47
|
+
echo
|
48
|
+
|
49
|
+
if [ -z ${PGOPTIONS+x} ]; then
|
50
|
+
export PGOPTIONS='-c client_min_messages=warning'
|
51
|
+
fi
|
52
|
+
|
53
|
+
function delete-functions {
|
54
|
+
echo "» get_last_message function"
|
55
|
+
run_psql "DROP FUNCTION IF EXISTS message_store.get_last_stream_message(varchar) CASCADE";
|
56
|
+
|
57
|
+
echo "» message_store_version function"
|
58
|
+
run_psql "DROP FUNCTION IF EXISTS message_store.message_store_version CASCADE";
|
59
|
+
}
|
60
|
+
|
61
|
+
function install-functions {
|
62
|
+
echo "» get_last_stream_message function"
|
63
|
+
run_psql_file $base/functions/get-last-stream-message.sql
|
64
|
+
|
65
|
+
echo "» message_store_version function"
|
66
|
+
run_psql_file $base/functions/message-store-version.sql
|
67
|
+
}
|
68
|
+
|
69
|
+
function grant-privileges {
|
70
|
+
echo "» get_last_stream_message function privilege"
|
71
|
+
run_psql "GRANT EXECUTE ON FUNCTION message_store.get_last_stream_message(varchar, varchar) TO message_store;"
|
72
|
+
|
73
|
+
echo "» message_store_version function"
|
74
|
+
run_psql "GRANT EXECUTE ON FUNCTION message_store.message_store_version TO message_store;"
|
75
|
+
}
|
76
|
+
|
77
|
+
echo "Deleting Functions"
|
78
|
+
echo "- - -"
|
79
|
+
delete-functions
|
80
|
+
echo
|
81
|
+
|
82
|
+
echo "Installing Functions"
|
83
|
+
echo "- - -"
|
84
|
+
install-functions
|
85
|
+
echo
|
86
|
+
|
87
|
+
echo "Granting Privileges to the Function"
|
88
|
+
echo "- - -"
|
89
|
+
grant-privileges
|
90
|
+
echo
|
91
|
+
|
92
|
+
echo "= = ="
|
93
|
+
echo "Done Updating Database"
|
94
|
+
echo "Version: 1.3.0"
|
95
|
+
echo
|
@@ -1,6 +1,10 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
-
set -
|
3
|
+
set -ue
|
4
|
+
|
5
|
+
function run_psql {
|
6
|
+
psql -v ON_ERROR_STOP=1 "$@"
|
7
|
+
}
|
4
8
|
|
5
9
|
instances=1
|
6
10
|
if [ ! -z ${INSTANCES+x} ]; then
|
@@ -13,6 +17,11 @@ if [ ! -z ${STREAM_NAME+x} ]; then
|
|
13
17
|
stream_name=$STREAM_NAME
|
14
18
|
fi
|
15
19
|
|
20
|
+
type="SomeType"
|
21
|
+
if [ ! -z ${TYPE+x} ]; then
|
22
|
+
type=$TYPE
|
23
|
+
fi
|
24
|
+
|
16
25
|
title="Writing $instances Messages to Stream $stream_name"
|
17
26
|
if [ -z ${METADATA+x} ]; then
|
18
27
|
metadata="'{\"metaAttribute\": \"some meta value\"}'"
|
@@ -53,11 +62,11 @@ for (( i=1; i<=instances; i++ )); do
|
|
53
62
|
|
54
63
|
echo "Instance: $i, Message ID: $uuid"
|
55
64
|
|
56
|
-
|
65
|
+
run_psql $database -U $user -c "SELECT write_message('$uuid'::varchar, '$stream_name'::varchar, '$type'::varchar, '{\"attribute\": \"some value\"}'::jsonb, $metadata);" > /dev/null
|
57
66
|
done
|
58
67
|
|
59
68
|
|
60
69
|
echo
|
61
|
-
|
70
|
+
run_psql $database -U $user -P pager=off -x -c "SELECT * FROM messages WHERE stream_name = '$stream_name';"
|
62
71
|
|
63
72
|
echo
|
metadata
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: scripts
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " "
|
14
14
|
email: opensource@eventide-project.org
|
15
15
|
executables:
|
16
|
-
- mdb-
|
16
|
+
- mdb-clear-messages
|
17
17
|
- mdb-create-db
|
18
|
-
- mdb-print-type-category-summary
|
19
|
-
- mdb-install-views
|
20
18
|
- mdb-delete-db
|
21
|
-
- mdb-
|
22
|
-
- mdb-
|
19
|
+
- mdb-install-functions
|
20
|
+
- mdb-install-indexes
|
23
21
|
- mdb-install-privileges
|
24
|
-
- mdb-
|
25
|
-
- mdb-print-
|
26
|
-
- mdb-print-message-store-version
|
22
|
+
- mdb-install-views
|
23
|
+
- mdb-print-category-type-summary
|
27
24
|
- mdb-print-database-scripts-dir
|
25
|
+
- mdb-print-message-store-version
|
26
|
+
- mdb-print-messages
|
27
|
+
- mdb-print-stream-summary
|
28
|
+
- mdb-print-stream-type-summary
|
29
|
+
- mdb-print-type-category-summary
|
28
30
|
- mdb-print-type-stream-summary
|
31
|
+
- mdb-print-type-summary
|
32
|
+
- mdb-recreate-db
|
29
33
|
- mdb-write-test-message
|
30
|
-
- mdb-install-indexes
|
31
|
-
- mdb-install-functions
|
32
|
-
- mdb-clear-messages
|
33
|
-
- mdb-print-category-type-summary
|
34
34
|
extensions: []
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
@@ -83,6 +83,8 @@ files:
|
|
83
83
|
- database/update/1.0.0.sh
|
84
84
|
- database/update/1.2.2.md
|
85
85
|
- database/update/1.2.2.sh
|
86
|
+
- database/update/1.3.0.md
|
87
|
+
- database/update/1.3.0.sh
|
86
88
|
- database/views/category-type-summary.sql
|
87
89
|
- database/views/stream-summary.sql
|
88
90
|
- database/views/stream-type-summary.sql
|
@@ -127,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
129
|
- !ruby/object:Gem::Version
|
128
130
|
version: '0'
|
129
131
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.3.3
|
131
133
|
signing_key:
|
132
134
|
specification_version: 4
|
133
135
|
summary: Microservice native event store and message store for Postgres
|