Richard Frith-Macdonald richard
Tue Sep 7 17:42:34 PDT 2004
I have applications which perform a set of schema changes in response 
to end-user activity ...
adding new tables and adding/deleting/altering columns in a small set 
of tables.

I see that slony has some support for this, in the form of adding and 
merging sets (to add a new table),
and the 'execute script' command to change columns in a table already 
being replicated, so theoretically
it can do what I need.

However ... I need to do this from a web-based application (java 
servlet communicating with postgresql
using jdbc).  I think ideally I would modify the existing jdbc code 
which changes tables in an unreplicated
database to work on a replicated system.  I think I should be able to 
do this by using the underlying
stored procedures that slonik uses.

The documentation focusses on using slonik rather than calling the 
stored procedures directly ...
does this imply that use of the stored procedures is discouraged or 
that the api is unstable?

It looks like DDL changes are the simpler problem ...
If I call the ddlScript stored procedure it should change things for me.
However ... can I detect a failure?   If I make a mistake in the sql 
passed to ddlScript, what will the result be?
Perhaps jdbc would raise an exception which I could catch, but I don't 
know, and I worry that
the stored procedure might hide failures rather than passing them back 
to me.
Also, I'm not sure of the effect of ddlScript ... does it return 
*after* all the changes have been made,
or does it just schedule them to occur at some point.  I would hope it 
makes master changes immediately
and guarantees that any slave changes have taken place before any data 
updates from the master are
replicated to the slave.

Similarly, for the case of adding a new table, if I call setAddTable 
then mergeSet and then dropSet
in rapid succession within my servlet, how would any errors be 
indicated, and would it immediately
be safe to start using the new table to store data?
Could I do the whole process of creating the new table, adding it to a 
set, merging it into
an existing set and dropping the temporary set, all as a single 
transaction?

Answers/help much appreciated.



More information about the Slony1-general mailing list