Commit 1ce2bd4
committed
spock.sub_alter_options: validate input, skip no-op restarts, add regression tests
Harden the sub_alter_options() implementation in three ways:
* No-op optimisation: track a `changed` flag through the JSONB parsing
loop. alter_subscription() — which sends SIGTERM to the apply worker
at commit — is only called when at least one option was actually
modified. An empty object '{}' now returns false without disturbing
the apply worker.
* Return value: the function now returns false when nothing changed and
true when at least one subscription field was updated, giving callers
a reliable signal about whether a worker restart is coming.
* Input validation: forward_origins elements are checked against the
only supported sentinel value "all". Any other string raises
INVALID_PARAMETER_VALUE with a hint, replacing the previous TODO
comment.
Add tests/regress/sql/alter_options.sql covering: baseline state
snapshot, no-op '{}', each option individually (forward_origins,
apply_delay, skip_schema), a multi-option call, baseline restore, and
all expected error paths (non-object JSON, unknown key, wrong value
types, invalid interval, non-existent subscription, invalid
forward_origins value).1 parent f020a1f commit 1ce2bd4
4 files changed
Lines changed: 642 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
947 | 947 | | |
948 | 948 | | |
949 | 949 | | |
| 950 | + | |
950 | 951 | | |
951 | 952 | | |
952 | 953 | | |
| |||
984 | 985 | | |
985 | 986 | | |
986 | 987 | | |
| 988 | + | |
| 989 | + | |
987 | 990 | | |
988 | 991 | | |
989 | 992 | | |
990 | 993 | | |
991 | 994 | | |
992 | | - | |
993 | | - | |
994 | | - | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
995 | 1008 | | |
996 | 1009 | | |
997 | 1010 | | |
998 | 1011 | | |
999 | 1012 | | |
1000 | 1013 | | |
| 1014 | + | |
1001 | 1015 | | |
1002 | 1016 | | |
1003 | 1017 | | |
| |||
1015 | 1029 | | |
1016 | 1030 | | |
1017 | 1031 | | |
| 1032 | + | |
1018 | 1033 | | |
1019 | 1034 | | |
1020 | 1035 | | |
| |||
1026 | 1041 | | |
1027 | 1042 | | |
1028 | 1043 | | |
1029 | | - | |
| 1044 | + | |
| 1045 | + | |
1030 | 1046 | | |
1031 | | - | |
| 1047 | + | |
1032 | 1048 | | |
1033 | 1049 | | |
1034 | 1050 | | |
| |||
0 commit comments