Mon Jan 22 04:34:50 PST 2007
- Previous message: [Slony1-general] PATCH: improved support for "slonik_execute_script -c"
- Next message: [Slony1-general] slony replication lag and pgpool
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
--On Donnerstag, Januar 18, 2007 14:33:36 -0500 Mark Stosberg <mark at summersault.com> wrote: > slonik_execute_script has a "-c" option to give a single command to run > on the command line, which is convenient. > > I ran something like this: > > slonik_execute_script -c 'ALTER TABLE a RENAME to b' set3 | slonik > > This silently failed. Slonik accepted the command, but nothing happened. Hmm, i see the following: [bernd slony] (1) HEAD $ slonik_execute_script --config ~/pgsql-dev/configs/slony/slon_tools.conf -c 'ALTER TABLE tapes DROP COLUMN idf2' set1 | slonik DDL script consisting of 0 SQL statements Submit DDL Event to subscribers... So slonik tells you indeed that something went wrong... > The reason is there is no trailing semicolon, so slonik interpreted this > as "0 commands". > > I addressed this in the script by adding a trailing semicolon if there > is not one given with the "-c" option. > I don't like this idea, because it mask's a fundamental problem in slonik, i think. A better option would be at least to check if the last command in the given SQL string is terminated and if not, to error out. But as already said, i think this is the wrong place... > However, I think "slonik" should also be updated to at least provide a > warning if it receives "0 commands" to process. > The problem is scan_for_statements() in src/parsestatements/scanner.c, which scans for multiple query strings in a given command string. These needs to be terminated by ';', otherwise the last query string doesn't get counted and is going to be ignored. What we can do here in slonik is to check wether we have any remaining bytes left in the current query string and to issue them as the final query. I propose the attached fix to scanner.c, but i admit that it needs a deeper thinking maybe. Comments? Bernd -- Thanks Bernd -------------- next part -------------- A non-text attachment was scrubbed... Name: scanner.c.patch Type: text/x-diff Size: 705 bytes Desc: not available Url : http://gborg.postgresql.org/pipermail/slony1-general/attachments/20070122/371c1ea7/attachment.bin
- Previous message: [Slony1-general] PATCH: improved support for "slonik_execute_script -c"
- Next message: [Slony1-general] slony replication lag and pgpool
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-general mailing list