-
Notifications
You must be signed in to change notification settings - Fork 49
Add docs for spock.sub_alter_options() #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+145
−48
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| ## NAME | ||
|
|
||
| spock.sub_alter_options() | ||
|
|
||
| ### SYNOPSIS | ||
|
|
||
| spock.sub_alter_options (subscription_name name, options jsonb) | ||
|
|
||
| ### RETURNS | ||
|
|
||
| - true if the `options` object contained at least one key; the Spock | ||
| catalog is updated and the apply worker is signalled to restart. | ||
|
|
||
| - false if the `options` object was empty (`{}`); the catalog is not | ||
| touched and the apply worker is not restarted. | ||
|
|
||
| - Raises an ERROR if the subscription does not exist, if `options` is | ||
| not a JSON object, if an unrecognised key is supplied, or if any | ||
| option value fails validation. | ||
|
|
||
| ### DESCRIPTION | ||
|
|
||
| Changes one or more options on an existing subscription in a single | ||
| atomic operation. | ||
|
|
||
| Only the keys present in the `options` object are modified; omitted | ||
| options retain their current values. If the object is empty (`{}`), the | ||
| function returns false without touching the catalog or restarting the | ||
| apply worker. | ||
|
|
||
| When at least one key is present in `options`, the function writes the | ||
| new values to the Spock catalog and signals the apply worker to restart | ||
| so that they take effect. The caller can use `spock.sub_show_status()` | ||
| or `spock.sub_wait_for_sync()` to confirm the worker has restarted and | ||
| reached `replicating` status. | ||
|
|
||
| ### ARGUMENTS | ||
|
|
||
| subscription_name | ||
|
|
||
| The name of an existing subscription. | ||
|
|
||
| options | ||
|
|
||
| A JSON object whose keys are the option names to change. Unrecognised | ||
| keys raise an error. Supported keys: | ||
|
|
||
| forward_origins | ||
|
|
||
| A JSON array of origin names whose transactions the subscriber | ||
| should apply or receive based on their origin. The only accepted | ||
| element is the string "all". Pass an empty array ([]) to disable | ||
| origin forwarding. | ||
|
|
||
| apply_delay | ||
|
|
||
| A PostgreSQL interval string (e.g. "2 seconds", "500ms", "0") | ||
| that sets how long the apply worker waits before applying each | ||
| transaction. The value must be a string; passing a bare number | ||
| raises an error. | ||
|
|
||
| skip_schema | ||
|
|
||
| A JSON array of schema names to exclude from apply. Pass an | ||
| empty array ([]) to clear the exclusion list. | ||
|
|
||
| ### EXAMPLE | ||
|
|
||
| Set a 2-second apply delay: | ||
|
|
||
| postgres=# SELECT spock.sub_alter_options('sub_n2_n1', | ||
| '{"apply_delay": "2 seconds"}'); | ||
| sub_alter_options | ||
| ------------------- | ||
| t | ||
| (1 row) | ||
|
|
||
| Enable forwarding of all origins and exclude the `audit` schema in a | ||
| single call: | ||
|
|
||
| postgres=# SELECT spock.sub_alter_options('sub_n2_n1', | ||
| '{"forward_origins": ["all"], "skip_schema": ["audit"]}'); | ||
| sub_alter_options | ||
| ------------------- | ||
| t | ||
| (1 row) | ||
|
|
||
| No-op call (empty object); returns false without restarting the worker: | ||
|
|
||
| postgres=# SELECT spock.sub_alter_options('sub_n2_n1', '{}'); | ||
| sub_alter_options | ||
| ------------------- | ||
| f | ||
| (1 row) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix spelling error: "subcription" → "subscription".
The description contains a typo that should be corrected for documentation quality.
📝 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~34-~34: Ensure spelling is correct
Context: ..._status.md) | Display the status of the subcription. | | [spock.sub_show_table](functions/s...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents
Source: Linters/SAST tools