Bug 186 - slonik command to update comments
Summary: slonik command to update comments
Status: NEW
Alias: None
Product: Slony-I
Classification: Unclassified
Component: slonik (show other bugs)
Version: devel
Hardware: PC Linux
: low enhancement
Assignee: Slony Bugs List
URL:
Depends on:
Blocks:
 
Reported: 2010-12-21 13:20 UTC by Steve Singer
Modified: 2010-12-30 09:25 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Singer 2010-12-21 13:20:26 UTC
Slonik allows you to specify a descriptive comment on sets, nodes and tables.

However we provide no way of changing that comment after it has been entered (short of manually executing UPDATE on sl_set on all nodes, which is discouraged)

We should add a command to update comments on objects or at least nodes and sets.

This feature request was passed to me from a DBA.
Comment 1 Jeff Frost 2010-12-29 15:20:38 UTC
Looks like there is already some functionality for updating in the storenode_int(integer, text) and storeset_int(integer, integer, text) functions:

It's just not exposed in slonik.

So, you would think you can do something like this:

select _schemadoc.createEvent('_schemadoc', 'STORE_NODE', '1', 'Node 1 description');


select _schemadoc.createEvent('_schemadoc', 'STORE_SET', '1', '1', 'new set description');

but at least on 1.2, it causes the slons to crash.
Comment 2 Christopher Browne 2010-12-30 09:13:11 UTC
The function
Comment 3 Christopher Browne 2010-12-30 09:25:46 UTC
The event STORE_NODE leads to calling the function storeNode_int(),
which seems to be suitably idempotent, where:

- If the node doesn't exist, it'll add it;
- If the node *does* exist, it updates the comment.

Similarly, STORE_SET leads to calling the function storeSet_int(),
which has the equivalent logic (with the appropriate s/node/set/g
substitution).

Taking one step back, Slonik calls, for STORE NODE, storeNode(), which
simply passes the work on to storeNode_int(), which again should "just
work."

Unfortunately, in slonik, slonik_store_node() assumes it's creating a
new node, so some rework would need to be done to allow it to cope
with this reconfiguration of the node.

On the SET side, slonik uses the command CREATE SET, which is pretty
clearly intended to create a new set.  It should be straightforward to
create another command, STORE SET, which is only permitted to alter
the comment on the set.  It's a bit of work, but shouldn't be
difficult.

I'm not sure why it didn't work to inject the events by hand; in
reading the code (in HEAD), it seems as though that ought to work
already.  Hopefully fixing it involves a little debugging, and adding
some examples to the regression tests to ensure the logic gets
exercised regularly.

The changes are straightforward enough that I'd encourage having someone that's new to altering Slonik work on it, so that we have more people that understand how to do so.