skytools-legacy
skytools-legacy copied to clipboard
unique key names are not escaped
one of our programmers created a table with a column called "iso_639-1", it replicates fine. There's a uniqe key on that column caled "unq_iso_639-1", which causes londiste to crash when adding the table to the subscriber.
2013-01-09 12:48:07,082 11289 INFO Creating unq_iso_639-1 2013-01-09 12:48:07,101 11289 CRITICAL Job londiste-woordenboek crashed: <class 'psycopg2.ProgrammingError'>: 'syntax error at or near "-" LINE 1: ...LY dictionary.languages ADD CONSTRAINT unq_iso_639-1 UNIQUE ... ^' (<traceback object at 0x7f8af1168758>: [' File "/var/lib/python-support/python2.5/skytools/scripting.py", line 510, in run_once\n return self.work()\n', ' File "/var/lib/python-support/python2.5/pgq/consumer.py", line 175, in work\n self._launch_process_batch(db, batch_id, list)\n', ' File "/var/lib/python-support/python2.5/pgq/consumer.py", line 207, in _launch_process_batch\n self.process_batch(db, batch_id, list)\n', ' File "/var/lib/python-support/python2.5/pgq/consumer.py", line 409, in process_batch\n self.process_remote_batch(db, batch_id, event_list, dst_db)\n', ' File "/var/lib/python-support/python2.5/londiste/playback.py", line 304, in process_remote_batch\n self.sync_tables(dst_db)\n', ' File "/var/lib/python-support/python2.5/londiste/playback.py", line 348, in sync_tables\n res = self.sync_from_copy_thread(cnt, dst_db)\n', ' File "/var/lib/python-support/python2.5/londiste/playback.py", line 448, in sync_from_copy_thread\n self.do_copy(t)\n', ' File "/var/lib/python-support/python2.5/londiste/table_copy.py", line 79, in do_copy\n dst_struct.create(dst_curs, objs, log = self.log)\n', ' File "/var/lib/python-support/python2.5/skytools/dbstruct.py", line 350, in create\n curs.execute(sql)\n', ' File "/usr/lib/python2.5/site-packages/psycopg2/extras.py", line 88, in execute\n return _cursor.execute(self, query, vars, async)\n'])
It seems you are using Skytools 2.1. This bug seems to be fixed in 3.x.
You could either move to skytools 3.x... :) or instead copy this file from master:
https://github.com/markokr/skytools/blob/master/python/skytools/dbstruct.py
it should be mostly compatible. If you confirm it works fine as-is (or with few fixes) then I can commit it to 2.1 branch too. But I really don't want to do any 2.1-specific fixing (and testing) myself.
Hi, thanks for your answer.
On Wed, Jan 9, 2013 at 5:56 PM, Marko Kreen [email protected]:
It seems you are using Skytools 2.1.
Correct.
This bug seems to be fixed in 3.x.
You could either move to skytools 3.x... :) or instead copy this file from master:
https://github.com/markokr/skytools/blob/master/python/skytools/dbstruct.py
it should be mostly compatible. If you confirm it works fine as-is (or with few fixes) then I can commit it to 2.1 branch too. But I really don't want to do any 2.1-specific fixing (and testing) myself.
I've worked around it by renaming the Unique Key. If i find time to test the replacement file, i'll keep you posted. Is there anything particular i should test? I was thinking about removing, and adding colums with unique keys on them (including the funny names) and replicating some data. Anything else that is important?
Cheers,
Willy-Bas
"Quality comes from focus and clarity of purpose" -- Mark Shuttleworth
Initial copy (or resync) will test the module. So pick or create tables with various functionality or weird naming and see if it works.